[Home] [Help]
PACKAGE BODY: APPS.XLA_00206_AAD_S_000004_BC_PKG
Source
1 PACKAGE BODY XLA_00206_AAD_S_000004_BC_PKG AS
2 --
3 /*======================================================================+
4 | Copyright (c) 1997 Oracle Corporation |
5 | Redwood Shores, CA, USA |
6 | All rights reserved. |
7 +=======================================================================+
8 | Package Name |
9 | XLA_00206_AAD_S_000004_BC_PKG |
10 | |
11 | DESCRIPTION |
12 | Package generated From Product Accounting Definition |
13 | Name : Loans US Federal |
14 | Code : LNS_US_FEDERAL |
15 | Owner : PRODUCT |
16 | Version : |
17 | AMB Context Code: DEFAULT |
18 | HISTORY |
19 | Generated at 06-11-2008 at 02:11:46 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_00206_AAD_S_000004_BC_PKG';
82
83 C_CHAR CONSTANT VARCHAR2(30) := fnd_global.local_chr(12); -- 4219869 Business flow
84 C_NUM CONSTANT NUMBER := 9.99E125; -- 4219869 Business flow
85
86 g_log_level NUMBER;
87 g_log_enabled BOOLEAN;
88
89 PROCEDURE trace
90 (p_msg IN VARCHAR2
91 ,p_level IN NUMBER
92 ,p_module IN VARCHAR2 ) IS
93 BEGIN
94 ----------------------------------------------------------------------------
95 -- Following is for FND log.
96 ----------------------------------------------------------------------------
97 IF (p_msg IS NULL AND p_level >= g_log_level) THEN
98 fnd_log.message(p_level, p_module);
99 ELSIF p_level >= g_log_level THEN
100 fnd_log.string(p_level, p_module, p_msg);
101 END IF;
102
103 EXCEPTION
104 WHEN xla_exceptions_pkg.application_exception THEN
105 RAISE;
106 WHEN OTHERS THEN
107 xla_exceptions_pkg.raise_message
108 (p_location => 'XLA_00206_AAD_S_000004_BC_PKG.trace');
109 END trace;
110
111 --
112 --+============================================+
113 --| |
114 --| PRIVATE PROCEDURES/FUNCTIONS |
115 --| |
116 --+============================================+
117 --
118
119 --
120 /*======================================================================+
121 | |
122 | Private Function |
123 | ValidateLookupMeaning |
124 | |
125 +======================================================================*/
126 FUNCTION ValidateLookupMeaning(
127 p_meaning IN VARCHAR2
128 , p_lookup_code IN VARCHAR2
129 , p_lookup_type IN VARCHAR2
130 , p_source_code IN VARCHAR2
131 , p_source_type_code IN VARCHAR2
132 , p_source_application_id IN INTEGER
133 )
134 RETURN VARCHAR2
135 IS
136 l_log_module VARCHAR2(240);
137 BEGIN
138 IF g_log_enabled THEN
139 l_log_module := C_DEFAULT_MODULE||'.ValidateLookupMeaning';
140 END IF;
141 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
142 trace
143 (p_msg => 'BEGIN of ValidateLookupMeaning'
144 ,p_level => C_LEVEL_PROCEDURE
145 ,p_module => l_log_module);
146 END IF;
147 --
148 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
149 trace
150 (p_msg => 'p_source_code = '|| p_source_code||
151 ' - p_source_type_code = '|| p_source_type_code||
152 ' - p_source_application_id = '|| p_source_application_id||
153 ' - p_lookup_code = '|| p_lookup_code||
154 ' - p_lookup_type = '|| p_lookup_type||
155 ' - p_meaning = '|| p_meaning
156 ,p_level => C_LEVEL_PROCEDURE
157 ,p_module => l_log_module);
158
159 END IF;
160
161 IF p_lookup_code IS NOT NULL AND p_meaning IS NULL THEN
162 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
163 xla_accounting_err_pkg. build_message
164 (p_appli_s_name => 'XLA'
165 ,p_msg_name => 'XLA_AP_NO_LOOKUP_MEANING'
166 ,p_token_1 => 'SOURCE_NAME'
167 ,p_value_1 => xla_ae_sources_pkg.GetSourceName(
168 p_source_code
169 , p_source_type_code
170 , p_source_application_id
171 )
172 ,p_token_2 => 'LOOKUP_CODE'
173 ,p_value_2 => p_lookup_code
174 ,p_token_3 => 'LOOKUP_TYPE'
175 ,p_value_3 => p_lookup_type
176 ,p_token_4 => 'PRODUCT_NAME'
177 ,p_value_4 => xla_ae_journal_entry_pkg.g_cache_event.application_name
178 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
179 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
180 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
181 );
182
183 IF (C_LEVEL_ERROR >= g_log_level) THEN
184 trace
185 (p_msg => 'ERROR: XLA_AP_NO_LOOKUP_MEANING'
186 ,p_level => C_LEVEL_ERROR
187 ,p_module => l_log_module);
188 END IF;
189 END IF;
190
191 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
192 trace
193 (p_msg => 'END of ValidateLookupMeaning'
194 ,p_level => C_LEVEL_PROCEDURE
195 ,p_module => l_log_module);
196 END IF;
197 RETURN p_meaning;
198 EXCEPTION
199 WHEN xla_exceptions_pkg.application_exception THEN
200 RETURN p_meaning;
201 WHEN OTHERS THEN
202 xla_exceptions_pkg.raise_message
203 (p_location => 'XLA_00206_AAD_S_000004_BC_PKG.ValidateLookupMeaning');
204 --
205 END ValidateLookupMeaning;
206 --
207 --
208
209 FUNCTION GetMeaning (
210 p_flex_value_set_id IN INTEGER
211 , p_flex_value IN VARCHAR2
212 , p_source_code IN VARCHAR2
213 , p_source_type_code IN VARCHAR2
214 , p_source_application_id IN INTEGER
215 )
216 RETURN VARCHAR2
217 IS
218 BEGIN
219 --
220 RETURN NULL ;
221 --
222 EXCEPTION
223 WHEN xla_exceptions_pkg.application_exception THEN
224 RAISE;
225 WHEN OTHERS THEN
226 xla_exceptions_pkg.raise_message
227 (p_location => 'XLA_00206_AAD_S_000004_BC_PKG.GetMeaning');
228 END GetMeaning;
229 --
230
231 ---------------------------------------
232 --
233 -- PRIVATE FUNCTION
234 -- Description_1
235 --
236 ---------------------------------------
237 FUNCTION Description_1 (
238 p_application_id IN NUMBER
239 , p_ae_header_id IN NUMBER DEFAULT NULL
240 --Loan Class
241 , p_source_1 IN VARCHAR2
242 , p_source_1_meaning IN VARCHAR2
243 --Loan Type
244 , p_source_2 IN VARCHAR2
245 --Loan Number
246 , p_source_3 IN VARCHAR2
247 )
248 RETURN VARCHAR2
249 IS
250 l_component_type VARCHAR2(80) ;
251 l_component_code VARCHAR2(30) ;
252 l_component_type_code VARCHAR2(1) ;
253 l_component_appl_id INTEGER ;
254 l_amb_context_code VARCHAR2(30) ;
255 l_ledger_language VARCHAR2(30) ;
256 l_source VARCHAR2(1996) ;
257 l_description VARCHAR2(2000) ;
258 l_log_module VARCHAR2(240) ;
259 BEGIN
260 IF g_log_enabled THEN
261 l_log_module := C_DEFAULT_MODULE||'.Description_1';
262 END IF;
263 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
264 trace
265 (p_msg => 'BEGIN of Description_1'
266 ,p_level => C_LEVEL_PROCEDURE
267 ,p_module => l_log_module);
268 END IF;
269
270 l_ledger_language := xla_ae_journal_entry_pkg.g_cache_ledgers_info.description_language;
271 l_component_type := 'AMB_DESCRIPTION';
272 l_component_code := 'LNS_HEADER_DESCRIPTION';
273 l_component_type_code := 'S';
274 l_component_appl_id := 206;
275 l_amb_context_code := 'DEFAULT';
276 l_source := NULL;
277 l_description := NULL;
278
279
280
281 IF
282 l_ledger_language = 'US' THEN
283 l_description := SUBSTR(CONCAT(l_description,'Loan Class'),1,2000);
284 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
285 END IF;
286 IF
287 l_ledger_language = 'US' THEN
288 l_description := SUBSTR(CONCAT(l_description,':'),1,2000);
289 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
290 END IF;
291 l_source := SUBSTR(
292 ValidateLookupMeaning(
293 p_meaning => p_source_1_meaning
294 , p_lookup_code => TO_CHAR(p_source_1)
295 , p_lookup_type => 'LOAN_CLASS'
296 , p_source_code => 'LOAN_CLASS_CODE'
297 , p_source_type_code => 'S'
298 , p_source_application_id => 206
299 )
300 ,1,1996);
301 IF l_source IS NOT NULL THEN
302 l_description := SUBSTR(CONCAT(l_description,l_source),1,2000);
303 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
304 END IF;
305 IF
306 l_ledger_language = 'US' THEN
307 l_description := SUBSTR(CONCAT(l_description,' Loan Type'),1,2000);
308 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
309 END IF;
310 IF
311 l_ledger_language = 'US' THEN
312 l_description := SUBSTR(CONCAT(l_description,':'),1,2000);
313 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
314 END IF;
315 l_source := SUBSTR(p_source_2,1,1996);
316 IF l_source IS NOT NULL THEN
317 l_description := SUBSTR(CONCAT(l_description,l_source),1,2000);
321 l_ledger_language = 'US' THEN
318 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
319 END IF;
320 IF
322 l_description := SUBSTR(CONCAT(l_description,' Loan Number'),1,2000);
323 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
324 END IF;
325 IF
326 l_ledger_language = 'US' THEN
327 l_description := SUBSTR(CONCAT(l_description,' :'),1,2000);
328 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
329 END IF;
330 l_source := SUBSTR(p_source_3,1,1996);
331 IF l_source IS NOT NULL THEN
332 l_description := SUBSTR(CONCAT(l_description,l_source),1,2000);
333 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
334 END IF;
335 l_description := SUBSTR(l_description,1,1996);
336 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
337 trace
338 (p_msg => 'END of Description_1'
339 ,p_level => C_LEVEL_PROCEDURE
340 ,p_module => l_log_module);
341
342 END IF;
343 RETURN l_description;
344
345 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
346 trace
347 (p_msg => 'END of Description_1'
348 ,p_level => C_LEVEL_PROCEDURE
349 ,p_module => l_log_module);
350 END IF;
351 RETURN NULL;
352 EXCEPTION
353 WHEN VALUE_ERROR THEN
354 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
355 trace
356 (p_msg => 'ERROR: '||sqlerrm
357 ,p_level => C_LEVEL_EXCEPTION
358 ,p_module => l_log_module);
359 END IF;
360 RAISE;
361 WHEN xla_exceptions_pkg.application_exception THEN
362 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
363 trace
364 (p_msg => 'ERROR: '||sqlerrm
365 ,p_level => C_LEVEL_EXCEPTION
366 ,p_module => l_log_module);
367 END IF;
368 RAISE;
369 WHEN OTHERS THEN
370 xla_exceptions_pkg.raise_message
371 (p_location => 'XLA_00206_AAD_S_000004_BC_PKG.Description_1');
372 END Description_1;
373
374 ---------------------------------------
375 --
376 -- PRIVATE FUNCTION
377 -- Description_2
378 --
379 ---------------------------------------
380 FUNCTION Description_2 (
381 p_application_id IN NUMBER
382 , p_ae_header_id IN NUMBER DEFAULT NULL
383 --Account Name
384 , p_source_4 IN VARCHAR2
385 , p_source_4_meaning IN VARCHAR2
386 )
387 RETURN VARCHAR2
388 IS
389 l_component_type VARCHAR2(80) ;
390 l_component_code VARCHAR2(30) ;
391 l_component_type_code VARCHAR2(1) ;
392 l_component_appl_id INTEGER ;
393 l_amb_context_code VARCHAR2(30) ;
394 l_ledger_language VARCHAR2(30) ;
395 l_source VARCHAR2(1996) ;
396 l_description VARCHAR2(2000) ;
397 l_log_module VARCHAR2(240) ;
398 BEGIN
399 IF g_log_enabled THEN
400 l_log_module := C_DEFAULT_MODULE||'.Description_2';
401 END IF;
402 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
403 trace
404 (p_msg => 'BEGIN of Description_2'
405 ,p_level => C_LEVEL_PROCEDURE
406 ,p_module => l_log_module);
407 END IF;
408
409 l_ledger_language := xla_ae_journal_entry_pkg.g_cache_ledgers_info.description_language;
410 l_component_type := 'AMB_DESCRIPTION';
411 l_component_code := 'LNS_LINE_DESCRIPTION';
412 l_component_type_code := 'S';
413 l_component_appl_id := 206;
414 l_amb_context_code := 'DEFAULT';
415 l_source := NULL;
416 l_description := NULL;
417
418
419
420 IF
421 l_ledger_language = 'US' THEN
422 l_description := SUBSTR(CONCAT(l_description,'Distribution Account Type'),1,2000);
423 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
424 END IF;
425 IF
426 l_ledger_language = 'US' THEN
427 l_description := SUBSTR(CONCAT(l_description,':'),1,2000);
428 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
429 END IF;
430 l_source := SUBSTR(
431 ValidateLookupMeaning(
432 p_meaning => p_source_4_meaning
433 , p_lookup_code => TO_CHAR(p_source_4)
434 , p_lookup_type => 'LOAN_DISTRIBUTION_ACCOUNTS'
435 , p_source_code => 'ACCOUNT_NAME'
436 , p_source_type_code => 'S'
437 , p_source_application_id => 206
438 )
439 ,1,1996);
440 IF l_source IS NOT NULL THEN
441 l_description := SUBSTR(CONCAT(l_description,l_source),1,2000);
442 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
443 END IF;
444 l_description := SUBSTR(l_description,1,1996);
445 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
446 trace
447 (p_msg => 'END of Description_2'
448 ,p_level => C_LEVEL_PROCEDURE
449 ,p_module => l_log_module);
450
451 END IF;
452 RETURN l_description;
453
454 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
455 trace
456 (p_msg => 'END of Description_2'
457 ,p_level => C_LEVEL_PROCEDURE
458 ,p_module => l_log_module);
459 END IF;
460 RETURN NULL;
461 EXCEPTION
462 WHEN VALUE_ERROR THEN
466 ,p_level => C_LEVEL_EXCEPTION
463 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
464 trace
465 (p_msg => 'ERROR: '||sqlerrm
467 ,p_module => l_log_module);
468 END IF;
469 RAISE;
470 WHEN xla_exceptions_pkg.application_exception THEN
471 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
472 trace
473 (p_msg => 'ERROR: '||sqlerrm
474 ,p_level => C_LEVEL_EXCEPTION
475 ,p_module => l_log_module);
476 END IF;
477 RAISE;
478 WHEN OTHERS THEN
479 xla_exceptions_pkg.raise_message
480 (p_location => 'XLA_00206_AAD_S_000004_BC_PKG.Description_2');
481 END Description_2;
482
483 ---------------------------------------
484 --
485 -- PRIVATE FUNCTION
486 -- AcctDerRule_3
487 --
488 ---------------------------------------
489 FUNCTION AcctDerRule_3 (
490 p_application_id IN NUMBER
491 , p_ae_header_id IN NUMBER
492 , p_side IN VARCHAR2
493 , p_override_seg_flag IN VARCHAR2
494 --Derived Program Account BSV
495 , p_source_5 IN VARCHAR2
496 , x_transaction_coa_id OUT NOCOPY NUMBER
497 , x_accounting_coa_id OUT NOCOPY NUMBER
498 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
499 , x_flex_value_set_id OUT NOCOPY NUMBER
500 , x_value_type_code OUT NOCOPY VARCHAR2
501 , x_value_combination_id OUT NOCOPY NUMBER
502 , x_value_segment_code OUT NOCOPY VARCHAR2
503 )
504 RETURN VARCHAR2
505 IS
506 l_component_type VARCHAR2(80) ;
507 l_component_code VARCHAR2(30) ;
508 l_component_type_code VARCHAR2(1) ;
509 l_component_appl_id INTEGER ;
510 l_amb_context_code VARCHAR2(30) ;
511 l_log_module VARCHAR2(240) ;
512 l_output_value VARCHAR2(30) ;
513 BEGIN
514 IF g_log_enabled THEN
515 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_3';
516 END IF;
517 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
518
519 trace
520 (p_msg => 'BEGIN of AcctDerRule_3'
521 ,p_level => C_LEVEL_PROCEDURE
522 ,p_module => l_log_module);
523
524 END IF;
525
526 l_component_type := 'AMB_ADR';
527 l_component_code := 'PROGRAM_ACCOUNT_BSV';
528 l_component_type_code := 'S';
529 l_component_appl_id := 206;
530 l_amb_context_code := 'DEFAULT';
531 x_transaction_coa_id := null;
532 x_accounting_coa_id := null;
533 x_flexfield_segment_code := 'GL_BALANCING';
534 x_flex_value_set_id := null ;
535
536
537 --
538 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
539
540 trace
541 (p_msg => 'END of AcctDerRule_3'
542 ,p_level => C_LEVEL_PROCEDURE
543 ,p_module => l_log_module);
544
545 END IF;
546 x_value_combination_id := null ;
547 x_value_segment_code := null ;
548 x_value_type_code := 'S';
549 l_output_value := TO_CHAR(p_source_5);
550 RETURN l_output_value;
551
552
553 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
554
555 trace
556 (p_msg => 'END of AcctDerRule_3(invalid)'
557 ,p_level => C_LEVEL_PROCEDURE
558 ,p_module => l_log_module);
559
560 END IF;
561
562 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
563 x_value_combination_id := null;
564 x_value_segment_code := null;
565 x_value_type_code := null;
566 l_output_value := null;
570 ,p_token_1 => 'COMPONENT_NAME'
567 xla_accounting_err_pkg.build_message
568 (p_appli_s_name => 'XLA'
569 ,p_msg_name => 'XLA_AP_INVALID_ADR'
571 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
572 l_component_type
573 , l_component_code
574 , l_component_type_code
575 , l_component_appl_id
576 , l_amb_context_code
577 )
578 ,p_token_2 => 'OWNER'
579 ,p_value_2 => xla_lookups_pkg.get_meaning(
580 'XLA_OWNER_TYPE'
581 ,l_component_type_code
582 )
583 ,p_token_3 => 'PAD_NAME'
584 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
585 ,p_token_4 => 'PAD_OWNER'
586 ,p_value_4 => xla_lookups_pkg.get_meaning(
587 'XLA_OWNER_TYPE'
588 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
589 )
590 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
591 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
592 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
593 ,p_ae_header_id => NULL
594 );
595 RETURN l_output_value;
596 EXCEPTION
597 WHEN xla_exceptions_pkg.application_exception THEN
598 RAISE;
599 WHEN OTHERS THEN
600 xla_exceptions_pkg.raise_message
601 (p_location => 'XLA_00206_AAD_S_000004_BC_PKG.AcctDerRule_3');
602 END AcctDerRule_3;
603 --
604
605 ---------------------------------------
606 --
607 -- PRIVATE FUNCTION
608 -- AcctDerRule_4
609 --
610 ---------------------------------------
611 FUNCTION AcctDerRule_4 (
612 p_application_id IN NUMBER
613 , p_ae_header_id IN NUMBER
614 , p_side IN VARCHAR2
615 --Code Combination ID
616 , p_source_6 IN NUMBER
617 , x_transaction_coa_id OUT NOCOPY NUMBER
618 , x_accounting_coa_id OUT NOCOPY NUMBER
619 , x_value_type_code OUT NOCOPY VARCHAR2
620 )
621 RETURN NUMBER
622 IS
623 l_component_type VARCHAR2(80) ;
624 l_component_code VARCHAR2(30) ;
625 l_component_type_code VARCHAR2(1) ;
626 l_component_appl_id INTEGER ;
627 l_amb_context_code VARCHAR2(30) ;
628 l_log_module VARCHAR2(240) ;
629 l_output_value NUMBER ;
630 BEGIN
631 IF g_log_enabled THEN
632 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_4';
633 END IF;
634 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
635 trace
636 (p_msg => 'BEGIN of AcctDerRule_4'
637 ,p_level => C_LEVEL_PROCEDURE
638 ,p_module => l_log_module);
639 END IF;
640 --
641 l_component_type := 'AMB_ADR';
642 l_component_code := 'LNS_DIST_CCID';
643 l_component_type_code := 'S';
644 l_component_appl_id := 206;
645 l_amb_context_code := 'DEFAULT';
646 x_transaction_coa_id := null;
647 x_accounting_coa_id := null;
648 --
649
650 --
651 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
652 trace
653 (p_msg => 'END of AcctDerRule_4'
654 ,p_level => C_LEVEL_PROCEDURE
655 ,p_module => l_log_module);
656 END IF;
657 x_value_type_code := 'S';
658 l_output_value := TO_NUMBER(TO_NUMBER(p_source_6));
659 RETURN l_output_value;
660
661 --
662 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
663 trace
664 (p_msg => 'END of AcctDerRule_4(invalid)'
665 ,p_level => C_LEVEL_PROCEDURE
666 ,p_module => l_log_module);
667 END IF;
668 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
669 x_value_type_code := null;
670 l_output_value := null;
671 xla_accounting_err_pkg.build_message
672 (p_appli_s_name => 'XLA'
673 ,p_msg_name => 'XLA_AP_INVALID_ADR'
674 ,p_token_1 => 'COMPONENT_NAME'
675 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
676 l_component_type
677 , l_component_code
678 , l_component_type_code
679 , l_component_appl_id
680 , l_amb_context_code
681 )
685 ,l_component_type_code
682 ,p_token_2 => 'OWNER'
683 ,p_value_2 => xla_lookups_pkg.get_meaning(
684 'XLA_OWNER_TYPE'
686 )
687 ,p_token_3 => 'PAD_NAME'
688 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
689 ,p_token_4 => 'PAD_OWNER'
690 ,p_value_4 => xla_lookups_pkg.get_meaning(
691 'XLA_OWNER_TYPE'
692 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
693 )
694 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
695 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
696 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
697 ,p_ae_header_id => NULL
698 );
699 RETURN l_output_value;
700 EXCEPTION
701 WHEN xla_exceptions_pkg.application_exception THEN
702 RAISE;
703 WHEN OTHERS THEN
704 xla_exceptions_pkg.raise_message
705 (p_location => 'XLA_00206_AAD_S_000004_BC_PKG.AcctDerRule_4');
706 END AcctDerRule_4;
707 --
708
709 ---------------------------------------
710 --
711 -- PRIVATE FUNCTION
712 -- AcctDerRule_5
713 --
714 ---------------------------------------
715 FUNCTION AcctDerRule_5 (
716 p_application_id IN NUMBER
717 , p_ae_header_id IN NUMBER
718 , p_side IN VARCHAR2
719 , p_override_seg_flag IN VARCHAR2
720 , x_transaction_coa_id OUT NOCOPY NUMBER
721 , x_accounting_coa_id OUT NOCOPY NUMBER
722 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
723 , x_flex_value_set_id OUT NOCOPY NUMBER
724 , x_value_type_code OUT NOCOPY VARCHAR2
725 , x_value_combination_id OUT NOCOPY NUMBER
726 , x_value_segment_code OUT NOCOPY VARCHAR2
727 )
728 RETURN VARCHAR2
729 IS
730 l_component_type VARCHAR2(80) ;
731 l_component_code VARCHAR2(30) ;
732 l_component_type_code VARCHAR2(1) ;
733 l_component_appl_id INTEGER ;
734 l_amb_context_code VARCHAR2(30) ;
735 l_log_module VARCHAR2(240) ;
736 l_output_value VARCHAR2(30) ;
737 BEGIN
738 IF g_log_enabled THEN
739 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_5';
740 END IF;
741 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
742
743 trace
744 (p_msg => 'BEGIN of AcctDerRule_5'
745 ,p_level => C_LEVEL_PROCEDURE
746 ,p_module => l_log_module);
747
748 END IF;
749
750 l_component_type := 'AMB_ADR';
751 l_component_code := 'USGL_ACCOUNT_461001';
752 l_component_type_code := 'S';
753 l_component_appl_id := 206;
754 l_amb_context_code := 'DEFAULT';
755 x_transaction_coa_id := null;
756 x_accounting_coa_id := null;
757 x_flexfield_segment_code := null;
758 x_flex_value_set_id := null ;
759
760
761 --
762 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
763
764 trace
765 (p_msg => 'END of AcctDerRule_5'
766 ,p_level => C_LEVEL_PROCEDURE
767 ,p_module => l_log_module);
768
769 END IF;
770 x_value_combination_id := null ;
771 x_value_segment_code := null ;
772 x_value_type_code := 'C';
773 l_output_value := '461002';
774 RETURN l_output_value;
775
776
777 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
778
779 trace
780 (p_msg => 'END of AcctDerRule_5(invalid)'
781 ,p_level => C_LEVEL_PROCEDURE
782 ,p_module => l_log_module);
783
784 END IF;
785
786 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
790 l_output_value := null;
787 x_value_combination_id := null;
788 x_value_segment_code := null;
789 x_value_type_code := null;
791 xla_accounting_err_pkg.build_message
792 (p_appli_s_name => 'XLA'
793 ,p_msg_name => 'XLA_AP_INVALID_ADR'
794 ,p_token_1 => 'COMPONENT_NAME'
795 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
796 l_component_type
797 , l_component_code
798 , l_component_type_code
799 , l_component_appl_id
800 , l_amb_context_code
801 )
802 ,p_token_2 => 'OWNER'
803 ,p_value_2 => xla_lookups_pkg.get_meaning(
804 'XLA_OWNER_TYPE'
805 ,l_component_type_code
806 )
807 ,p_token_3 => 'PAD_NAME'
808 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
809 ,p_token_4 => 'PAD_OWNER'
810 ,p_value_4 => xla_lookups_pkg.get_meaning(
811 'XLA_OWNER_TYPE'
812 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
813 )
814 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
815 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
816 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
817 ,p_ae_header_id => NULL
818 );
819 RETURN l_output_value;
820 EXCEPTION
821 WHEN xla_exceptions_pkg.application_exception THEN
822 RAISE;
823 WHEN OTHERS THEN
824 xla_exceptions_pkg.raise_message
825 (p_location => 'XLA_00206_AAD_S_000004_BC_PKG.AcctDerRule_5');
826 END AcctDerRule_5;
827 --
828
829 ---------------------------------------
830 --
831 -- PRIVATE FUNCTION
832 -- AcctDerRule_6
833 --
834 ---------------------------------------
835 FUNCTION AcctDerRule_6 (
836 p_application_id IN NUMBER
837 , p_ae_header_id IN NUMBER
838 , p_side IN VARCHAR2
839 , p_override_seg_flag IN VARCHAR2
840 , x_transaction_coa_id OUT NOCOPY NUMBER
841 , x_accounting_coa_id OUT NOCOPY NUMBER
842 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
843 , x_flex_value_set_id OUT NOCOPY NUMBER
844 , x_value_type_code OUT NOCOPY VARCHAR2
845 , x_value_combination_id OUT NOCOPY NUMBER
846 , x_value_segment_code OUT NOCOPY VARCHAR2
847 )
848 RETURN VARCHAR2
849 IS
850 l_component_type VARCHAR2(80) ;
851 l_component_code VARCHAR2(30) ;
852 l_component_type_code VARCHAR2(1) ;
853 l_component_appl_id INTEGER ;
854 l_amb_context_code VARCHAR2(30) ;
855 l_log_module VARCHAR2(240) ;
856 l_output_value VARCHAR2(30) ;
857 BEGIN
858 IF g_log_enabled THEN
859 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_6';
860 END IF;
861 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
862
863 trace
864 (p_msg => 'BEGIN of AcctDerRule_6'
865 ,p_level => C_LEVEL_PROCEDURE
866 ,p_module => l_log_module);
867
868 END IF;
869
870 l_component_type := 'AMB_ADR';
871 l_component_code := 'USGL_ACCOUNT_480102';
872 l_component_type_code := 'S';
873 l_component_appl_id := 206;
874 l_amb_context_code := 'DEFAULT';
875 x_transaction_coa_id := null;
876 x_accounting_coa_id := null;
877 x_flexfield_segment_code := null;
878 x_flex_value_set_id := null ;
879
880
881 --
882 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
883
884 trace
885 (p_msg => 'END of AcctDerRule_6'
886 ,p_level => C_LEVEL_PROCEDURE
887 ,p_module => l_log_module);
888
889 END IF;
890 x_value_combination_id := null ;
891 x_value_segment_code := null ;
892 x_value_type_code := 'C';
893 l_output_value := '480101';
894 RETURN l_output_value;
895
896
897 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
898
899 trace
900 (p_msg => 'END of AcctDerRule_6(invalid)'
901 ,p_level => C_LEVEL_PROCEDURE
902 ,p_module => l_log_module);
903
904 END IF;
905
906 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
907 x_value_combination_id := null;
908 x_value_segment_code := null;
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'
917 , l_component_code
914 ,p_token_1 => 'COMPONENT_NAME'
915 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
916 l_component_type
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_00206_AAD_S_000004_BC_PKG.AcctDerRule_6');
946 END AcctDerRule_6;
947 --
948
949 ---------------------------------------
950 --
951 -- PRIVATE FUNCTION
952 -- AcctLineType_7
953 --
954 ---------------------------------------
955 PROCEDURE AcctLineType_7 (
956 p_application_id IN NUMBER
957 ,p_event_id IN NUMBER
958 ,p_calculate_acctd_flag IN VARCHAR2
959 ,p_calculate_g_l_flag IN VARCHAR2
960 ,p_actual_flag IN OUT VARCHAR2
961 ,p_balance_type_code OUT VARCHAR2
962 ,p_gain_or_loss_ref OUT VARCHAR2
963
964 --Account Name
965 , p_source_4 IN VARCHAR2
966 , p_source_4_meaning IN VARCHAR2
967 --Derived Program Account BSV
968 , p_source_5 IN VARCHAR2
969 --Code Combination ID
970 , p_source_6 IN NUMBER
971 --Distribution Line Type
972 , p_source_7 IN VARCHAR2
973 --Account Type
974 , p_source_8 IN VARCHAR2
975 , p_source_8_meaning IN VARCHAR2
976 --EVENT_TYPE
977 , p_source_9 IN VARCHAR2
978 , p_source_9_meaning IN VARCHAR2
979 --Disbursement Number
980 , p_source_10 IN NUMBER
981 --FUNDS_RESERVED_FLAG
982 , p_source_11 IN VARCHAR2
983 --Distribution ID
984 , p_source_12 IN NUMBER
985 --Distribution Type
986 , p_source_13 IN VARCHAR2
987 , p_source_13_meaning IN VARCHAR2
988 --Distribution Amount
989 , p_source_14 IN NUMBER
990 --Currency
991 , p_source_15 IN VARCHAR2
992 , p_source_15_meaning IN VARCHAR2
993 --EXCHANGE_DATE
994 , p_source_16 IN DATE
995 --EXCHANGE_RATE
996 , p_source_17 IN NUMBER
997 --EXCHANGE_RATE_TYPE
998 , p_source_18 IN VARCHAR2
999 )
1000 IS
1001
1002 l_component_type VARCHAR2(80);
1003 l_component_code VARCHAR2(30);
1004 l_component_type_code VARCHAR2(1);
1005 l_component_appl_id INTEGER;
1006 l_amb_context_code VARCHAR2(30);
1007 l_entity_code VARCHAR2(30);
1008 l_event_class_code VARCHAR2(30);
1009 l_ae_header_id NUMBER;
1010 l_event_type_code VARCHAR2(30);
1011 l_line_definition_code VARCHAR2(30);
1012 l_line_definition_owner_code VARCHAR2(1);
1013 --
1014 -- adr variables
1015 l_segment VARCHAR2(30);
1016 l_ccid NUMBER;
1017 l_adr_transaction_coa_id NUMBER;
1018 l_adr_accounting_coa_id NUMBER;
1019 l_adr_flexfield_segment_code VARCHAR2(30);
1020 l_adr_flex_value_set_id NUMBER;
1021 l_adr_value_type_code VARCHAR2(30);
1022 l_adr_value_combination_id NUMBER;
1023 l_adr_value_segment_code VARCHAR2(30);
1024
1025 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
1026 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
1027 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
1028 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
1029
1030 -- 4262811 Variables ------------------------------------------------------------------------------------------
1031 l_entered_amt_idx NUMBER;
1032 l_accted_amt_idx NUMBER;
1036 l_acc_rev_natural_side_code VARCHAR2(1);
1033 l_acc_rev_flag VARCHAR2(1);
1034 l_accrual_line_num NUMBER;
1035 l_tmp_amt NUMBER;
1037
1038 l_num_entries NUMBER;
1039 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
1040 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
1041 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
1042 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
1043 l_recog_line_1 NUMBER;
1044 l_recog_line_2 NUMBER;
1045
1046 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
1047 l_bflow_applied_to_amt NUMBER; -- 5132302
1048 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
1049
1050 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
1051
1052 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
1053 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
1054
1055 ---------------------------------------------------------------------------------------------------------------
1056
1057
1058 --
1059 -- bulk performance
1060 --
1061 l_balance_type_code VARCHAR2(1);
1062 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
1063 l_log_module VARCHAR2(240);
1064
1065 --
1066 -- Upgrade strategy
1067 --
1068 l_actual_upg_option VARCHAR2(1);
1069 l_enc_upg_option VARCHAR2(1);
1070
1071 --
1072 BEGIN
1073 --
1074 IF g_log_enabled THEN
1075 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_7';
1076 END IF;
1077 --
1078 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1079
1080 trace
1081 (p_msg => 'BEGIN of AcctLineType_7'
1082 ,p_level => C_LEVEL_PROCEDURE
1083 ,p_module => l_log_module);
1084
1085 END IF;
1086 --
1087 l_component_type := 'AMB_JLT';
1088 l_component_code := 'USSGL_TC_A150_PROG_ACT_4610';
1089 l_component_type_code := 'S';
1090 l_component_appl_id := 206;
1091 l_amb_context_code := 'DEFAULT';
1092 l_entity_code := 'LOANS';
1093 l_event_class_code := 'DIRECT';
1094 l_event_type_code := 'DIRECT_LOAN_APPROVED';
1095 l_line_definition_owner_code := 'S';
1096 l_line_definition_code := 'FED_LNS_APPROVAL';
1097 --
1098 l_balance_type_code := 'A';
1099 l_segment := NULL;
1100 l_ccid := NULL;
1101 l_adr_transaction_coa_id := NULL;
1102 l_adr_accounting_coa_id := NULL;
1103 l_adr_flexfield_segment_code := NULL;
1104 l_adr_flex_value_set_id := NULL;
1105 l_adr_value_type_code := NULL;
1106 l_adr_value_combination_id := NULL;
1107 l_adr_value_segment_code := NULL;
1108
1109 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
1110 l_bflow_class_code := ''; -- 4219869 Business Flow
1111 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
1112 l_budgetary_control_flag := 'Y';
1113
1114 l_bflow_applied_to_amt_idx := NULL; -- 5132302
1115 l_bflow_applied_to_amt := NULL; -- 5132302
1116 l_entered_amt_idx := NULL; -- 4262811
1117 l_accted_amt_idx := NULL; -- 4262811
1118 l_acc_rev_flag := NULL; -- 4262811
1119 l_accrual_line_num := NULL; -- 4262811
1120 l_tmp_amt := NULL; -- 4262811
1121 --
1122
1123 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
1124 l_balance_type_code <> 'B' THEN
1125 IF NVL(p_source_7,'
1126 ') = 'SUBSIDY' AND
1127 NVL(p_source_8,'
1128 ') = 'DR' AND
1129 ((NVL(p_source_9,'
1130 ') = 'DIRECT_LOAN_APPROVED') OR
1131 (NVL(p_source_9,'
1132 ') = 'DISBURSEMENT_FUNDED' AND
1133 NVL(p_source_10,9E125) = 1 AND
1134 NVL(p_source_11,'
1135 ') = 'N')
1136 ) THEN
1137
1138 --
1139 XLA_AE_LINES_PKG.SetNewLine;
1140
1141 p_balance_type_code := l_balance_type_code;
1142 -- set the flag so later we will know whether the gain loss line needs to be created
1143
1144 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
1145 p_actual_flag :='A';
1146 END IF;
1147
1148 --
1149 -- bulk performance
1150 --
1151 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
1152 p_header_num => 0); -- 4262811
1153 --
1154 -- set accounting line options
1155 --
1156 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
1157 p_natural_side_code => 'D'
1158 , p_gain_or_loss_flag => 'N'
1159 , p_gl_transfer_mode_code => 'D'
1160 , p_acct_entry_type_code => 'A'
1161 , p_switch_side_flag => 'N'
1162 , p_merge_duplicate_code => 'N'
1163 );
1164 --
1165 l_acc_rev_natural_side_code := 'C'; -- 4262811
1166 --
1167 --
1168 -- set accounting line type info
1169 --
1170 xla_ae_lines_pkg.SetAcctLineType
1174 ,p_line_definition_code => l_line_definition_code
1171 (p_component_type => l_component_type
1172 ,p_event_type_code => l_event_type_code
1173 ,p_line_definition_owner_code => l_line_definition_owner_code
1175 ,p_accounting_line_code => l_component_code
1176 ,p_accounting_line_type_code => l_component_type_code
1177 ,p_accounting_line_appl_id => l_component_appl_id
1178 ,p_amb_context_code => l_amb_context_code
1179 ,p_entity_code => l_entity_code
1180 ,p_event_class_code => l_event_class_code);
1181 --
1182 -- set accounting class
1183 --
1184 xla_ae_lines_pkg.SetAcctClass(
1185 p_accounting_class_code => 'PROG_ACT'
1186 , p_ae_header_id => l_ae_header_id
1187 );
1188
1189 --
1190 -- set rounding class
1191 --
1192 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
1193 'PROG_ACT';
1194
1195 --
1196 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
1197 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
1198 --
1199 -- bulk performance
1200 --
1201 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
1202
1203 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
1204 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
1205
1206 -- 4955764
1207 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
1208 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
1209
1210 -- 4458381 Public Sector Enh
1211
1212 --
1213 -- set accounting attributes for the line type
1214 --
1215 l_entered_amt_idx := 3;
1216 l_accted_amt_idx := 8;
1217 l_bflow_applied_to_amt_idx := NULL; -- 5132302
1218 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
1219 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_12);
1220 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
1221 l_rec_acct_attrs.array_char_value(2) := p_source_13;
1222 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
1223 l_rec_acct_attrs.array_num_value(3) := p_source_14;
1224 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
1225 l_rec_acct_attrs.array_char_value(4) := p_source_15;
1226 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
1227 l_rec_acct_attrs.array_date_value(5) := p_source_16;
1228 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
1229 l_rec_acct_attrs.array_num_value(6) := p_source_17;
1230 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
1231 l_rec_acct_attrs.array_char_value(7) := p_source_18;
1232 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
1233 l_rec_acct_attrs.array_num_value(8) := p_source_14;
1234
1235 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
1236 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
1237
1238 ---------------------------------------------------------------------------------------------------------------
1239 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
1240 ---------------------------------------------------------------------------------------------------------------
1241 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
1242
1243 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
1244 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
1245
1246 IF xla_accounting_cache_pkg.GetValueChar
1247 (p_source_code => 'LEDGER_CATEGORY_CODE'
1248 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
1249 AND l_bflow_method_code = 'PRIOR_ENTRY'
1250 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
1251 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
1252 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
1253 )
1254 THEN
1255 xla_ae_lines_pkg.BflowUpgEntry
1256 (p_business_method_code => l_bflow_method_code
1257 ,p_business_class_code => l_bflow_class_code
1258 ,p_balance_type => l_balance_type_code);
1259 ELSE
1260 NULL;
1261 -- No business flow processing for business flow method of NONE.
1262 END IF;
1263
1264 --
1265 -- call analytical criteria
1266 --
1267
1268 --
1269 -- call description
1270 --
1271
1272 xla_ae_lines_pkg.SetLineDescription(
1273 p_ae_header_id => l_ae_header_id
1274 ,p_description => Description_2 (
1275 p_application_id => p_application_id
1276 , p_ae_header_id => l_ae_header_id
1277 , p_source_4 => p_source_4
1278 , p_source_4_meaning => p_source_4_meaning
1279 )
1280 );
1281
1282
1283 --
1284 -- call ADRs
1285 -- Bug 4922099
1286 --
1287 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
1288 (NVL(l_actual_upg_option, 'N') = 'O') OR
1289 (NVL(l_enc_upg_option, 'N') = 'O')
1290 )
1294 --
1291 THEN
1292 NULL;
1293 --
1295
1296 l_ccid := AcctDerRule_4(
1297 p_application_id => p_application_id
1298 , p_ae_header_id => l_ae_header_id
1299 , p_source_6 => p_source_6
1300 , x_transaction_coa_id => l_adr_transaction_coa_id
1301 , x_accounting_coa_id => l_adr_accounting_coa_id
1302 , x_value_type_code => l_adr_value_type_code
1303 , p_side => 'NA'
1304 );
1305
1306 xla_ae_lines_pkg.set_ccid(
1307 p_code_combination_id => l_ccid
1308 , p_value_type_code => l_adr_value_type_code
1309 , p_transaction_coa_id => l_adr_transaction_coa_id
1310 , p_accounting_coa_id => l_adr_accounting_coa_id
1311 , p_adr_code => 'LNS_DIST_CCID'
1312 , p_adr_type_code => 'S'
1313 , p_component_type => l_component_type
1314 , p_component_code => l_component_code
1315 , p_component_type_code => l_component_type_code
1316 , p_component_appl_id => l_component_appl_id
1317 , p_amb_context_code => l_amb_context_code
1318 , p_side => 'NA'
1319 );
1320
1321
1322 l_segment := AcctDerRule_3(
1323 p_application_id => p_application_id
1324 , p_ae_header_id => l_ae_header_id
1325 , p_source_5 => p_source_5
1326 , x_transaction_coa_id => l_adr_transaction_coa_id
1327 , x_accounting_coa_id => l_adr_accounting_coa_id
1328 , x_flexfield_segment_code => l_adr_flexfield_segment_code
1329 , x_flex_value_set_id => l_adr_flex_value_set_id
1330 , x_value_type_code => l_adr_value_type_code
1331 , x_value_combination_id => l_adr_value_combination_id
1332 , x_value_segment_code => l_adr_value_segment_code
1333 , p_side => 'NA'
1334 , p_override_seg_flag => 'Y'
1335 );
1336
1337 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
1338
1339 xla_ae_lines_pkg.set_segment(
1340 p_to_segment_code => 'GL_BALANCING'
1341 , p_segment_value => l_segment
1342 , p_from_segment_code => l_adr_value_segment_code
1343 , p_from_combination_id => l_adr_value_combination_id
1344 , p_value_type_code => l_adr_value_type_code
1345 , p_transaction_coa_id => l_adr_transaction_coa_id
1346 , p_accounting_coa_id => l_adr_accounting_coa_id
1347 , p_flexfield_segment_code => l_adr_flexfield_segment_code
1348 , p_flex_value_set_id => l_adr_flex_value_set_id
1349 , p_adr_code => 'PROGRAM_ACCOUNT_BSV'
1350 , p_adr_type_code => 'S'
1351 , p_component_type => l_component_type
1352 , p_component_code => l_component_code
1353 , p_component_type_code => l_component_type_code
1354 , p_component_appl_id => l_component_appl_id
1355 , p_amb_context_code => l_amb_context_code
1356 , p_entity_code => 'LOANS'
1357 , p_event_class_code => 'DIRECT'
1358 , p_side => 'NA'
1359 );
1360
1361 END IF;
1362
1363 l_segment := AcctDerRule_5(
1364 p_application_id => p_application_id
1365 , p_ae_header_id => l_ae_header_id
1366 , x_transaction_coa_id => l_adr_transaction_coa_id
1367 , x_accounting_coa_id => l_adr_accounting_coa_id
1368 , x_flexfield_segment_code => l_adr_flexfield_segment_code
1369 , x_flex_value_set_id => l_adr_flex_value_set_id
1370 , x_value_type_code => l_adr_value_type_code
1371 , x_value_combination_id => l_adr_value_combination_id
1372 , x_value_segment_code => l_adr_value_segment_code
1373 , p_side => 'NA'
1374 , p_override_seg_flag => 'Y'
1375 );
1376
1377 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
1378
1382 , p_from_segment_code => l_adr_value_segment_code
1379 xla_ae_lines_pkg.set_segment(
1380 p_to_segment_code => 'GL_ACCOUNT'
1381 , p_segment_value => l_segment
1383 , p_from_combination_id => l_adr_value_combination_id
1384 , p_value_type_code => l_adr_value_type_code
1385 , p_transaction_coa_id => l_adr_transaction_coa_id
1386 , p_accounting_coa_id => l_adr_accounting_coa_id
1387 , p_flexfield_segment_code => l_adr_flexfield_segment_code
1388 , p_flex_value_set_id => l_adr_flex_value_set_id
1389 , p_adr_code => 'USGL_ACCOUNT_461001'
1390 , p_adr_type_code => 'S'
1391 , p_component_type => l_component_type
1392 , p_component_code => l_component_code
1393 , p_component_type_code => l_component_type_code
1394 , p_component_appl_id => l_component_appl_id
1395 , p_amb_context_code => l_amb_context_code
1396 , p_entity_code => 'LOANS'
1397 , p_event_class_code => 'DIRECT'
1398 , p_side => 'NA'
1399 );
1400
1401 END IF;
1402
1403 --
1404 --
1405 END IF;
1406 --
1407 -- Bug 4922099
1408 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
1409 (NVL(l_enc_upg_option, 'N') = 'O')
1410 ) AND
1411 (l_bflow_method_code = 'PRIOR_ENTRY')
1412 )
1413 THEN
1414 IF
1415 --
1416 1 = 2
1417 --
1418 THEN
1419 xla_accounting_err_pkg.build_message
1420 (p_appli_s_name => 'XLA'
1421 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
1422 ,p_token_1 => 'LINE_NUMBER'
1423 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
1424 ,p_token_2 => 'LINE_TYPE_NAME'
1425 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
1426 l_component_type
1427 ,l_component_code
1428 ,l_component_type_code
1429 ,l_component_appl_id
1430 ,l_amb_context_code
1431 ,l_entity_code
1432 ,l_event_class_code
1433 )
1434 ,p_token_3 => 'OWNER'
1435 ,p_value_3 => xla_lookups_pkg.get_meaning(
1436 p_lookup_type => 'XLA_OWNER_TYPE'
1437 ,p_lookup_code => l_component_type_code
1438 )
1439 ,p_token_4 => 'PRODUCT_NAME'
1440 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
1441 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
1442 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
1443 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
1444 ,p_ae_header_id => NULL
1445 );
1446
1447 IF (C_LEVEL_ERROR>= g_log_level) THEN
1448 trace
1449 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
1450 ,p_level => C_LEVEL_ERROR
1451 ,p_module => l_log_module);
1452 END IF;
1453 END IF;
1454 END IF;
1455 --
1456 --
1457 ------------------------------------------------------------------------------------------------
1458 -- 4219869 Business Flow
1459 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
1460 -- Prior Entry. Currently, the following code is always generated.
1461 ------------------------------------------------------------------------------------------------
1462 XLA_AE_LINES_PKG.ValidateCurrentLine;
1463
1464 ------------------------------------------------------------------------------------
1465 -- 4219869 Business Flow
1466 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
1467 ------------------------------------------------------------------------------------
1468 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
1469
1470 ----------------------------------------------------------------------------------
1471 -- 4219869 Business Flow
1472 -- Update journal entry status -- Need to generate this within IF <condition>
1473 ----------------------------------------------------------------------------------
1477 );
1474 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
1475 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
1476 ,p_balance_type_code => l_balance_type_code
1478
1479 -------------------------------------------------------------------------------------------
1480 -- 4262811 - Generate the Accrual Reversal lines
1481 -------------------------------------------------------------------------------------------
1482 BEGIN
1483 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
1484 (g_array_event(p_event_id).array_value_num('header_index'));
1485 IF l_acc_rev_flag IS NULL THEN
1486 l_acc_rev_flag := 'N';
1487 END IF;
1488 EXCEPTION
1489 WHEN OTHERS THEN
1490 l_acc_rev_flag := 'N';
1491 END;
1492 --
1493 IF (l_acc_rev_flag = 'Y') THEN
1494
1495 -- 4645092 ------------------------------------------------------------------------------
1496 -- To allow MPA report to determine if it should generate report process
1497 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
1498 ------------------------------------------------------------------------------------------
1499
1500 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
1501 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
1502
1503 --
1504 -- Update the line information that should be overwritten
1505 --
1506 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
1507 p_header_num => 1);
1508 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
1509
1510 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
1511
1512 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
1513 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
1514 END IF;
1515
1516 --
1517 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
1518 --
1519 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
1520 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
1521 ELSE
1522 ---------------------------------------------------------------------------------------------------
1523 -- 4262811a Switch Sign
1524 ---------------------------------------------------------------------------------------------------
1525 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
1526 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
1527 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
1528 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
1529 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
1530 -- 5132302
1531 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
1532 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
1533
1534 END IF;
1535
1536 -- 4955764
1537 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
1538 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
1539
1540
1541 XLA_AE_LINES_PKG.ValidateCurrentLine;
1542 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
1543
1544 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
1545 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
1546 ,p_balance_type_code => l_balance_type_code);
1547
1548 END IF;
1549
1550 -----------------------------------------------------------------------------------------
1551 -- 4262811 Multiperiod Accounting
1552 -----------------------------------------------------------------------------------------
1553 -- No MPA option is assigned.
1554
1555
1556 END IF;
1557 END IF;
1558 --
1559
1560 --
1561 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1562 trace
1563 (p_msg => 'END of AcctLineType_7'
1564 ,p_level => C_LEVEL_PROCEDURE
1565 ,p_module => l_log_module);
1566 END IF;
1567 --
1568 EXCEPTION
1569 WHEN xla_exceptions_pkg.application_exception THEN
1570 RAISE;
1571 WHEN OTHERS THEN
1572 xla_exceptions_pkg.raise_message
1573 (p_location => 'XLA_00206_AAD_S_000004_BC_PKG.AcctLineType_7');
1574 END AcctLineType_7;
1575 --
1576
1577 ---------------------------------------
1578 --
1579 -- PRIVATE FUNCTION
1580 -- AcctLineType_8
1581 --
1582 ---------------------------------------
1583 PROCEDURE AcctLineType_8 (
1584 p_application_id IN NUMBER
1585 ,p_event_id IN NUMBER
1586 ,p_calculate_acctd_flag IN VARCHAR2
1587 ,p_calculate_g_l_flag IN VARCHAR2
1588 ,p_actual_flag IN OUT VARCHAR2
1589 ,p_balance_type_code OUT VARCHAR2
1593 , p_source_4 IN VARCHAR2
1590 ,p_gain_or_loss_ref OUT VARCHAR2
1591
1592 --Account Name
1594 , p_source_4_meaning IN VARCHAR2
1595 --Derived Program Account BSV
1596 , p_source_5 IN VARCHAR2
1597 --Code Combination ID
1598 , p_source_6 IN NUMBER
1599 --Distribution Line Type
1600 , p_source_7 IN VARCHAR2
1601 --Account Type
1602 , p_source_8 IN VARCHAR2
1603 , p_source_8_meaning IN VARCHAR2
1604 --EVENT_TYPE
1605 , p_source_9 IN VARCHAR2
1606 , p_source_9_meaning IN VARCHAR2
1607 --Distribution ID
1608 , p_source_12 IN NUMBER
1609 --Distribution Type
1610 , p_source_13 IN VARCHAR2
1611 , p_source_13_meaning IN VARCHAR2
1612 --Distribution Amount
1613 , p_source_14 IN NUMBER
1614 --Currency
1615 , p_source_15 IN VARCHAR2
1616 , p_source_15_meaning IN VARCHAR2
1617 --EXCHANGE_DATE
1618 , p_source_16 IN DATE
1619 --EXCHANGE_RATE
1620 , p_source_17 IN NUMBER
1621 --EXCHANGE_RATE_TYPE
1622 , p_source_18 IN VARCHAR2
1623 --Subsidy Cost
1624 , p_source_19 IN NUMBER
1625 )
1626 IS
1627
1628 l_component_type VARCHAR2(80);
1629 l_component_code VARCHAR2(30);
1630 l_component_type_code VARCHAR2(1);
1631 l_component_appl_id INTEGER;
1632 l_amb_context_code VARCHAR2(30);
1633 l_entity_code VARCHAR2(30);
1634 l_event_class_code VARCHAR2(30);
1635 l_ae_header_id NUMBER;
1636 l_event_type_code VARCHAR2(30);
1637 l_line_definition_code VARCHAR2(30);
1638 l_line_definition_owner_code VARCHAR2(1);
1639 --
1640 -- adr variables
1641 l_segment VARCHAR2(30);
1642 l_ccid NUMBER;
1643 l_adr_transaction_coa_id NUMBER;
1644 l_adr_accounting_coa_id NUMBER;
1645 l_adr_flexfield_segment_code VARCHAR2(30);
1646 l_adr_flex_value_set_id NUMBER;
1647 l_adr_value_type_code VARCHAR2(30);
1648 l_adr_value_combination_id NUMBER;
1649 l_adr_value_segment_code VARCHAR2(30);
1650
1651 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
1652 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
1653 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
1654 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
1655
1656 -- 4262811 Variables ------------------------------------------------------------------------------------------
1657 l_entered_amt_idx NUMBER;
1658 l_accted_amt_idx NUMBER;
1659 l_acc_rev_flag VARCHAR2(1);
1660 l_accrual_line_num NUMBER;
1661 l_tmp_amt NUMBER;
1665 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
1662 l_acc_rev_natural_side_code VARCHAR2(1);
1663
1664 l_num_entries NUMBER;
1666 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
1667 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
1668 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
1669 l_recog_line_1 NUMBER;
1670 l_recog_line_2 NUMBER;
1671
1672 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
1673 l_bflow_applied_to_amt NUMBER; -- 5132302
1674 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
1675
1676 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
1677
1678 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
1679 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
1680
1681 ---------------------------------------------------------------------------------------------------------------
1682
1683
1684 --
1685 -- bulk performance
1686 --
1687 l_balance_type_code VARCHAR2(1);
1688 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
1689 l_log_module VARCHAR2(240);
1690
1691 --
1692 -- Upgrade strategy
1693 --
1694 l_actual_upg_option VARCHAR2(1);
1695 l_enc_upg_option VARCHAR2(1);
1696
1697 --
1698 BEGIN
1699 --
1700 IF g_log_enabled THEN
1701 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_8';
1702 END IF;
1703 --
1704 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1705
1706 trace
1707 (p_msg => 'BEGIN of AcctLineType_8'
1708 ,p_level => C_LEVEL_PROCEDURE
1709 ,p_module => l_log_module);
1710
1711 END IF;
1712 --
1713 l_component_type := 'AMB_JLT';
1714 l_component_code := 'USSGL_TC_A150_PROG_ACT_4610_C';
1715 l_component_type_code := 'S';
1716 l_component_appl_id := 206;
1717 l_amb_context_code := 'DEFAULT';
1718 l_entity_code := 'LOANS';
1719 l_event_class_code := 'DIRECT';
1720 l_event_type_code := 'FUTURE_DISBURSEMENT_CANCELLED';
1721 l_line_definition_owner_code := 'S';
1722 l_line_definition_code := 'FED_LNS_CANCEL';
1723 --
1724 l_balance_type_code := 'A';
1725 l_segment := NULL;
1726 l_ccid := NULL;
1727 l_adr_transaction_coa_id := NULL;
1728 l_adr_accounting_coa_id := NULL;
1729 l_adr_flexfield_segment_code := NULL;
1730 l_adr_flex_value_set_id := NULL;
1731 l_adr_value_type_code := NULL;
1732 l_adr_value_combination_id := NULL;
1733 l_adr_value_segment_code := NULL;
1734
1735 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
1736 l_bflow_class_code := ''; -- 4219869 Business Flow
1737 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
1738 l_budgetary_control_flag := 'Y';
1739
1740 l_bflow_applied_to_amt_idx := NULL; -- 5132302
1741 l_bflow_applied_to_amt := NULL; -- 5132302
1742 l_entered_amt_idx := NULL; -- 4262811
1743 l_accted_amt_idx := NULL; -- 4262811
1744 l_acc_rev_flag := NULL; -- 4262811
1745 l_accrual_line_num := NULL; -- 4262811
1746 l_tmp_amt := NULL; -- 4262811
1747 --
1748
1749 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
1750 l_balance_type_code <> 'B' THEN
1751 IF NVL(p_source_7,'
1752 ') = 'SUBSIDY' AND
1753 NVL(p_source_8,'
1754 ') = 'CR' AND
1755 NVL(p_source_9,'
1756 ') = 'FUTURE_DISBURSEMENT_CANCELLED'
1757 THEN
1758
1759 --
1760 XLA_AE_LINES_PKG.SetNewLine;
1761
1762 p_balance_type_code := l_balance_type_code;
1763 -- set the flag so later we will know whether the gain loss line needs to be created
1764
1765 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
1766 p_actual_flag :='A';
1767 END IF;
1768
1769 --
1770 -- bulk performance
1771 --
1772 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
1773 p_header_num => 0); -- 4262811
1774 --
1775 -- set accounting line options
1776 --
1777 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
1778 p_natural_side_code => 'C'
1779 , p_gain_or_loss_flag => 'N'
1780 , p_gl_transfer_mode_code => 'S'
1781 , p_acct_entry_type_code => 'A'
1782 , p_switch_side_flag => 'N'
1783 , p_merge_duplicate_code => 'N'
1784 );
1785 --
1786 l_acc_rev_natural_side_code := 'D'; -- 4262811
1787 --
1788 --
1789 -- set accounting line type info
1790 --
1791 xla_ae_lines_pkg.SetAcctLineType
1792 (p_component_type => l_component_type
1793 ,p_event_type_code => l_event_type_code
1794 ,p_line_definition_owner_code => l_line_definition_owner_code
1795 ,p_line_definition_code => l_line_definition_code
1796 ,p_accounting_line_code => l_component_code
1800 ,p_entity_code => l_entity_code
1797 ,p_accounting_line_type_code => l_component_type_code
1798 ,p_accounting_line_appl_id => l_component_appl_id
1799 ,p_amb_context_code => l_amb_context_code
1801 ,p_event_class_code => l_event_class_code);
1802 --
1803 -- set accounting class
1804 --
1805 xla_ae_lines_pkg.SetAcctClass(
1806 p_accounting_class_code => 'PROG_ACT'
1807 , p_ae_header_id => l_ae_header_id
1808 );
1809
1810 --
1811 -- set rounding class
1812 --
1813 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
1814 'PROG_ACT';
1815
1816 --
1817 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
1818 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
1819 --
1820 -- bulk performance
1821 --
1822 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
1823
1824 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
1825 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
1826
1827 -- 4955764
1828 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
1829 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
1830
1831 -- 4458381 Public Sector Enh
1832
1833 --
1834 -- set accounting attributes for the line type
1835 --
1836 l_entered_amt_idx := 3;
1837 l_accted_amt_idx := 8;
1838 l_bflow_applied_to_amt_idx := NULL; -- 5132302
1839 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
1840 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_12);
1841 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
1842 l_rec_acct_attrs.array_char_value(2) := p_source_13;
1843 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
1844 l_rec_acct_attrs.array_num_value(3) := p_source_14;
1845 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
1846 l_rec_acct_attrs.array_char_value(4) := p_source_15;
1847 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
1848 l_rec_acct_attrs.array_date_value(5) := p_source_16;
1849 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
1850 l_rec_acct_attrs.array_num_value(6) := p_source_17;
1851 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
1852 l_rec_acct_attrs.array_char_value(7) := p_source_18;
1853 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
1854 l_rec_acct_attrs.array_num_value(8) := p_source_19;
1855
1856 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
1857 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
1858
1859 ---------------------------------------------------------------------------------------------------------------
1860 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
1861 ---------------------------------------------------------------------------------------------------------------
1862 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
1863
1864 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
1865 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
1866
1867 IF xla_accounting_cache_pkg.GetValueChar
1868 (p_source_code => 'LEDGER_CATEGORY_CODE'
1869 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
1870 AND l_bflow_method_code = 'PRIOR_ENTRY'
1871 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
1872 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
1873 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
1874 )
1875 THEN
1876 xla_ae_lines_pkg.BflowUpgEntry
1877 (p_business_method_code => l_bflow_method_code
1878 ,p_business_class_code => l_bflow_class_code
1879 ,p_balance_type => l_balance_type_code);
1883 END IF;
1880 ELSE
1881 NULL;
1882 -- No business flow processing for business flow method of NONE.
1884
1885 --
1886 -- call analytical criteria
1887 --
1888
1889 --
1890 -- call description
1891 --
1892
1893 xla_ae_lines_pkg.SetLineDescription(
1894 p_ae_header_id => l_ae_header_id
1895 ,p_description => Description_2 (
1896 p_application_id => p_application_id
1897 , p_ae_header_id => l_ae_header_id
1898 , p_source_4 => p_source_4
1899 , p_source_4_meaning => p_source_4_meaning
1900 )
1901 );
1902
1903
1904 --
1905 -- call ADRs
1906 -- Bug 4922099
1907 --
1908 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
1909 (NVL(l_actual_upg_option, 'N') = 'O') OR
1910 (NVL(l_enc_upg_option, 'N') = 'O')
1911 )
1912 THEN
1913 NULL;
1914 --
1915 --
1916
1917 l_ccid := AcctDerRule_4(
1918 p_application_id => p_application_id
1919 , p_ae_header_id => l_ae_header_id
1920 , p_source_6 => p_source_6
1921 , x_transaction_coa_id => l_adr_transaction_coa_id
1922 , x_accounting_coa_id => l_adr_accounting_coa_id
1923 , x_value_type_code => l_adr_value_type_code
1924 , p_side => 'NA'
1925 );
1926
1927 xla_ae_lines_pkg.set_ccid(
1928 p_code_combination_id => l_ccid
1929 , p_value_type_code => l_adr_value_type_code
1930 , p_transaction_coa_id => l_adr_transaction_coa_id
1931 , p_accounting_coa_id => l_adr_accounting_coa_id
1932 , p_adr_code => 'LNS_DIST_CCID'
1933 , p_adr_type_code => 'S'
1934 , p_component_type => l_component_type
1935 , p_component_code => l_component_code
1936 , p_component_type_code => l_component_type_code
1937 , p_component_appl_id => l_component_appl_id
1938 , p_amb_context_code => l_amb_context_code
1939 , p_side => 'NA'
1940 );
1941
1942
1943 l_segment := AcctDerRule_3(
1944 p_application_id => p_application_id
1945 , p_ae_header_id => l_ae_header_id
1946 , p_source_5 => p_source_5
1947 , x_transaction_coa_id => l_adr_transaction_coa_id
1948 , x_accounting_coa_id => l_adr_accounting_coa_id
1949 , x_flexfield_segment_code => l_adr_flexfield_segment_code
1950 , x_flex_value_set_id => l_adr_flex_value_set_id
1951 , x_value_type_code => l_adr_value_type_code
1952 , x_value_combination_id => l_adr_value_combination_id
1953 , x_value_segment_code => l_adr_value_segment_code
1954 , p_side => 'NA'
1955 , p_override_seg_flag => 'Y'
1956 );
1957
1958 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
1959
1960 xla_ae_lines_pkg.set_segment(
1961 p_to_segment_code => 'GL_BALANCING'
1962 , p_segment_value => l_segment
1963 , p_from_segment_code => l_adr_value_segment_code
1964 , p_from_combination_id => l_adr_value_combination_id
1965 , p_value_type_code => l_adr_value_type_code
1966 , p_transaction_coa_id => l_adr_transaction_coa_id
1967 , p_accounting_coa_id => l_adr_accounting_coa_id
1968 , p_flexfield_segment_code => l_adr_flexfield_segment_code
1969 , p_flex_value_set_id => l_adr_flex_value_set_id
1970 , p_adr_code => 'PROGRAM_ACCOUNT_BSV'
1971 , p_adr_type_code => 'S'
1972 , p_component_type => l_component_type
1973 , p_component_code => l_component_code
1974 , p_component_type_code => l_component_type_code
1975 , p_component_appl_id => l_component_appl_id
1976 , p_amb_context_code => l_amb_context_code
1977 , p_entity_code => 'LOANS'
1978 , p_event_class_code => 'DIRECT'
1979 , p_side => 'NA'
1980 );
1981
1982 END IF;
1983
1984 l_segment := AcctDerRule_5(
1985 p_application_id => p_application_id
1986 , p_ae_header_id => l_ae_header_id
1987 , x_transaction_coa_id => l_adr_transaction_coa_id
1988 , x_accounting_coa_id => l_adr_accounting_coa_id
1989 , x_flexfield_segment_code => l_adr_flexfield_segment_code
1990 , x_flex_value_set_id => l_adr_flex_value_set_id
1991 , x_value_type_code => l_adr_value_type_code
1992 , x_value_combination_id => l_adr_value_combination_id
1993 , x_value_segment_code => l_adr_value_segment_code
1994 , p_side => 'NA'
1995 , p_override_seg_flag => 'Y'
1996 );
1997
2001 p_to_segment_code => 'GL_ACCOUNT'
1998 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
1999
2000 xla_ae_lines_pkg.set_segment(
2002 , p_segment_value => l_segment
2003 , p_from_segment_code => l_adr_value_segment_code
2004 , p_from_combination_id => l_adr_value_combination_id
2005 , p_value_type_code => l_adr_value_type_code
2006 , p_transaction_coa_id => l_adr_transaction_coa_id
2007 , p_accounting_coa_id => l_adr_accounting_coa_id
2008 , p_flexfield_segment_code => l_adr_flexfield_segment_code
2009 , p_flex_value_set_id => l_adr_flex_value_set_id
2010 , p_adr_code => 'USGL_ACCOUNT_461001'
2011 , p_adr_type_code => 'S'
2012 , p_component_type => l_component_type
2013 , p_component_code => l_component_code
2014 , p_component_type_code => l_component_type_code
2015 , p_component_appl_id => l_component_appl_id
2016 , p_amb_context_code => l_amb_context_code
2017 , p_entity_code => 'LOANS'
2018 , p_event_class_code => 'DIRECT'
2019 , p_side => 'NA'
2020 );
2021
2022 END IF;
2023
2024 --
2025 --
2026 END IF;
2027 --
2028 -- Bug 4922099
2029 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
2030 (NVL(l_enc_upg_option, 'N') = 'O')
2031 ) AND
2032 (l_bflow_method_code = 'PRIOR_ENTRY')
2033 )
2034 THEN
2035 IF
2036 --
2037 1 = 2
2038 --
2039 THEN
2040 xla_accounting_err_pkg.build_message
2041 (p_appli_s_name => 'XLA'
2042 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
2043 ,p_token_1 => 'LINE_NUMBER'
2044 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
2045 ,p_token_2 => 'LINE_TYPE_NAME'
2046 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
2047 l_component_type
2048 ,l_component_code
2049 ,l_component_type_code
2050 ,l_component_appl_id
2051 ,l_amb_context_code
2055 ,p_token_3 => 'OWNER'
2052 ,l_entity_code
2053 ,l_event_class_code
2054 )
2056 ,p_value_3 => xla_lookups_pkg.get_meaning(
2057 p_lookup_type => 'XLA_OWNER_TYPE'
2058 ,p_lookup_code => l_component_type_code
2059 )
2060 ,p_token_4 => 'PRODUCT_NAME'
2061 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
2062 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
2063 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
2064 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
2065 ,p_ae_header_id => NULL
2066 );
2067
2068 IF (C_LEVEL_ERROR>= g_log_level) THEN
2069 trace
2070 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
2071 ,p_level => C_LEVEL_ERROR
2072 ,p_module => l_log_module);
2073 END IF;
2074 END IF;
2075 END IF;
2076 --
2077 --
2078 ------------------------------------------------------------------------------------------------
2079 -- 4219869 Business Flow
2080 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
2081 -- Prior Entry. Currently, the following code is always generated.
2082 ------------------------------------------------------------------------------------------------
2083 XLA_AE_LINES_PKG.ValidateCurrentLine;
2084
2085 ------------------------------------------------------------------------------------
2086 -- 4219869 Business Flow
2087 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
2088 ------------------------------------------------------------------------------------
2089 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
2090
2091 ----------------------------------------------------------------------------------
2092 -- 4219869 Business Flow
2093 -- Update journal entry status -- Need to generate this within IF <condition>
2094 ----------------------------------------------------------------------------------
2095 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
2096 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
2097 ,p_balance_type_code => l_balance_type_code
2098 );
2099
2100 -------------------------------------------------------------------------------------------
2101 -- 4262811 - Generate the Accrual Reversal lines
2102 -------------------------------------------------------------------------------------------
2103 BEGIN
2104 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
2105 (g_array_event(p_event_id).array_value_num('header_index'));
2106 IF l_acc_rev_flag IS NULL THEN
2107 l_acc_rev_flag := 'N';
2108 END IF;
2109 EXCEPTION
2110 WHEN OTHERS THEN
2111 l_acc_rev_flag := 'N';
2112 END;
2113 --
2114 IF (l_acc_rev_flag = 'Y') THEN
2115
2116 -- 4645092 ------------------------------------------------------------------------------
2117 -- To allow MPA report to determine if it should generate report process
2118 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
2119 ------------------------------------------------------------------------------------------
2120
2121 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
2122 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
2123
2124 --
2125 -- Update the line information that should be overwritten
2126 --
2127 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
2128 p_header_num => 1);
2129 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
2130
2131 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
2132
2133 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
2134 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
2135 END IF;
2136
2137 --
2138 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
2139 --
2140 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
2141 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
2142 ELSE
2143 ---------------------------------------------------------------------------------------------------
2144 -- 4262811a Switch Sign
2145 ---------------------------------------------------------------------------------------------------
2146 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
2150 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
2147 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
2148 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
2149 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
2151 -- 5132302
2152 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
2153 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
2154
2155 END IF;
2156
2157 -- 4955764
2158 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
2159 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
2160
2161
2162 XLA_AE_LINES_PKG.ValidateCurrentLine;
2163 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
2164
2165 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
2166 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
2167 ,p_balance_type_code => l_balance_type_code);
2168
2169 END IF;
2170
2171 -----------------------------------------------------------------------------------------
2172 -- 4262811 Multiperiod Accounting
2173 -----------------------------------------------------------------------------------------
2174 -- No MPA option is assigned.
2175
2176
2177 END IF;
2178 END IF;
2179 --
2180
2181 --
2182 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2183 trace
2184 (p_msg => 'END of AcctLineType_8'
2185 ,p_level => C_LEVEL_PROCEDURE
2186 ,p_module => l_log_module);
2187 END IF;
2188 --
2189 EXCEPTION
2190 WHEN xla_exceptions_pkg.application_exception THEN
2191 RAISE;
2192 WHEN OTHERS THEN
2193 xla_exceptions_pkg.raise_message
2194 (p_location => 'XLA_00206_AAD_S_000004_BC_PKG.AcctLineType_8');
2195 END AcctLineType_8;
2196 --
2197
2198 ---------------------------------------
2199 --
2200 -- PRIVATE FUNCTION
2201 -- AcctLineType_9
2202 --
2203 ---------------------------------------
2204 PROCEDURE AcctLineType_9 (
2205 p_application_id IN NUMBER
2206 ,p_event_id IN NUMBER
2207 ,p_calculate_acctd_flag IN VARCHAR2
2208 ,p_calculate_g_l_flag IN VARCHAR2
2209 ,p_actual_flag IN OUT VARCHAR2
2210 ,p_balance_type_code OUT VARCHAR2
2211 ,p_gain_or_loss_ref OUT VARCHAR2
2212
2213 --Account Name
2214 , p_source_4 IN VARCHAR2
2215 , p_source_4_meaning IN VARCHAR2
2216 --Derived Program Account BSV
2217 , p_source_5 IN VARCHAR2
2218 --Code Combination ID
2219 , p_source_6 IN NUMBER
2220 --Distribution Line Type
2221 , p_source_7 IN VARCHAR2
2222 --Account Type
2223 , p_source_8 IN VARCHAR2
2224 , p_source_8_meaning IN VARCHAR2
2225 --EVENT_TYPE
2226 , p_source_9 IN VARCHAR2
2227 , p_source_9_meaning IN VARCHAR2
2228 --Disbursement Number
2229 , p_source_10 IN NUMBER
2230 --FUNDS_RESERVED_FLAG
2231 , p_source_11 IN VARCHAR2
2232 --Distribution ID
2233 , p_source_12 IN NUMBER
2234 --Distribution Type
2235 , p_source_13 IN VARCHAR2
2236 , p_source_13_meaning IN VARCHAR2
2237 --Distribution Amount
2238 , p_source_14 IN NUMBER
2239 --Currency
2240 , p_source_15 IN VARCHAR2
2241 , p_source_15_meaning IN VARCHAR2
2242 --EXCHANGE_DATE
2243 , p_source_16 IN DATE
2244 --EXCHANGE_RATE
2245 , p_source_17 IN NUMBER
2246 --EXCHANGE_RATE_TYPE
2247 , p_source_18 IN VARCHAR2
2248 )
2249 IS
2250
2251 l_component_type VARCHAR2(80);
2252 l_component_code VARCHAR2(30);
2253 l_component_type_code VARCHAR2(1);
2254 l_component_appl_id INTEGER;
2255 l_amb_context_code VARCHAR2(30);
2256 l_entity_code VARCHAR2(30);
2257 l_event_class_code VARCHAR2(30);
2258 l_ae_header_id NUMBER;
2259 l_event_type_code VARCHAR2(30);
2260 l_line_definition_code VARCHAR2(30);
2261 l_line_definition_owner_code VARCHAR2(1);
2262 --
2263 -- adr variables
2264 l_segment VARCHAR2(30);
2265 l_ccid NUMBER;
2266 l_adr_transaction_coa_id NUMBER;
2267 l_adr_accounting_coa_id NUMBER;
2268 l_adr_flexfield_segment_code VARCHAR2(30);
2269 l_adr_flex_value_set_id NUMBER;
2270 l_adr_value_type_code VARCHAR2(30);
2271 l_adr_value_combination_id NUMBER;
2272 l_adr_value_segment_code VARCHAR2(30);
2273
2274 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
2275 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
2276 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
2277 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
2278
2279 -- 4262811 Variables ------------------------------------------------------------------------------------------
2280 l_entered_amt_idx NUMBER;
2284 l_tmp_amt NUMBER;
2281 l_accted_amt_idx NUMBER;
2282 l_acc_rev_flag VARCHAR2(1);
2283 l_accrual_line_num NUMBER;
2285 l_acc_rev_natural_side_code VARCHAR2(1);
2286
2287 l_num_entries NUMBER;
2288 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
2289 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
2290 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
2291 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
2292 l_recog_line_1 NUMBER;
2293 l_recog_line_2 NUMBER;
2294
2295 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
2296 l_bflow_applied_to_amt NUMBER; -- 5132302
2297 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
2298
2299 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
2300
2301 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
2302 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
2303
2304 ---------------------------------------------------------------------------------------------------------------
2305
2306
2307 --
2308 -- bulk performance
2309 --
2310 l_balance_type_code VARCHAR2(1);
2311 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
2312 l_log_module VARCHAR2(240);
2313
2314 --
2315 -- Upgrade strategy
2316 --
2317 l_actual_upg_option VARCHAR2(1);
2318 l_enc_upg_option VARCHAR2(1);
2319
2320 --
2321 BEGIN
2322 --
2323 IF g_log_enabled THEN
2324 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_9';
2325 END IF;
2326 --
2327 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2328
2329 trace
2330 (p_msg => 'BEGIN of AcctLineType_9'
2331 ,p_level => C_LEVEL_PROCEDURE
2332 ,p_module => l_log_module);
2333
2334 END IF;
2335 --
2336 l_component_type := 'AMB_JLT';
2337 l_component_code := 'USSGL_TC_A150_PROG_ACT_4801';
2338 l_component_type_code := 'S';
2339 l_component_appl_id := 206;
2340 l_amb_context_code := 'DEFAULT';
2341 l_entity_code := 'LOANS';
2342 l_event_class_code := 'DIRECT';
2343 l_event_type_code := 'DIRECT_LOAN_APPROVED';
2344 l_line_definition_owner_code := 'S';
2345 l_line_definition_code := 'FED_LNS_APPROVAL';
2346 --
2347 l_balance_type_code := 'A';
2348 l_segment := NULL;
2349 l_ccid := NULL;
2350 l_adr_transaction_coa_id := NULL;
2351 l_adr_accounting_coa_id := NULL;
2352 l_adr_flexfield_segment_code := NULL;
2353 l_adr_flex_value_set_id := NULL;
2354 l_adr_value_type_code := NULL;
2355 l_adr_value_combination_id := NULL;
2356 l_adr_value_segment_code := NULL;
2357
2358 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
2359 l_bflow_class_code := ''; -- 4219869 Business Flow
2360 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
2361 l_budgetary_control_flag := 'Y';
2362
2363 l_bflow_applied_to_amt_idx := NULL; -- 5132302
2364 l_bflow_applied_to_amt := NULL; -- 5132302
2365 l_entered_amt_idx := NULL; -- 4262811
2366 l_accted_amt_idx := NULL; -- 4262811
2367 l_acc_rev_flag := NULL; -- 4262811
2368 l_accrual_line_num := NULL; -- 4262811
2369 l_tmp_amt := NULL; -- 4262811
2370 --
2371
2372 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
2373 l_balance_type_code <> 'B' THEN
2374 IF NVL(p_source_7,'
2375 ') = 'SUBSIDY' AND
2376 NVL(p_source_8,'
2377 ') = 'CR' AND
2378 ((NVL(p_source_9,'
2379 ') = 'DIRECT_LOAN_APPROVED') OR
2380 (NVL(p_source_9,'
2381 ') = 'DISBURSEMENT_FUNDED' AND
2382 NVL(p_source_10,9E125) = 1 AND
2383 NVL(p_source_11,'
2384 ') = 'N')
2385 ) THEN
2386
2390 p_balance_type_code := l_balance_type_code;
2387 --
2388 XLA_AE_LINES_PKG.SetNewLine;
2389
2391 -- set the flag so later we will know whether the gain loss line needs to be created
2392
2393 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
2394 p_actual_flag :='A';
2395 END IF;
2396
2397 --
2398 -- bulk performance
2399 --
2400 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
2401 p_header_num => 0); -- 4262811
2402 --
2403 -- set accounting line options
2404 --
2405 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
2406 p_natural_side_code => 'C'
2407 , p_gain_or_loss_flag => 'N'
2408 , p_gl_transfer_mode_code => 'D'
2409 , p_acct_entry_type_code => 'A'
2410 , p_switch_side_flag => 'N'
2411 , p_merge_duplicate_code => 'N'
2412 );
2413 --
2414 l_acc_rev_natural_side_code := 'D'; -- 4262811
2415 --
2416 --
2417 -- set accounting line type info
2418 --
2419 xla_ae_lines_pkg.SetAcctLineType
2420 (p_component_type => l_component_type
2421 ,p_event_type_code => l_event_type_code
2422 ,p_line_definition_owner_code => l_line_definition_owner_code
2423 ,p_line_definition_code => l_line_definition_code
2424 ,p_accounting_line_code => l_component_code
2425 ,p_accounting_line_type_code => l_component_type_code
2426 ,p_accounting_line_appl_id => l_component_appl_id
2427 ,p_amb_context_code => l_amb_context_code
2428 ,p_entity_code => l_entity_code
2429 ,p_event_class_code => l_event_class_code);
2430 --
2431 -- set accounting class
2432 --
2433 xla_ae_lines_pkg.SetAcctClass(
2434 p_accounting_class_code => 'PROG_ACT'
2435 , p_ae_header_id => l_ae_header_id
2436 );
2437
2438 --
2439 -- set rounding class
2440 --
2441 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
2442 'PROG_ACT';
2443
2444 --
2445 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
2446 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
2447 --
2448 -- bulk performance
2449 --
2450 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
2451
2452 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
2453 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
2454
2455 -- 4955764
2456 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
2457 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
2458
2459 -- 4458381 Public Sector Enh
2460
2461 --
2462 -- set accounting attributes for the line type
2463 --
2464 l_entered_amt_idx := 3;
2465 l_accted_amt_idx := 8;
2466 l_bflow_applied_to_amt_idx := NULL; -- 5132302
2467 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
2468 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_12);
2469 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
2470 l_rec_acct_attrs.array_char_value(2) := p_source_13;
2471 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
2472 l_rec_acct_attrs.array_num_value(3) := p_source_14;
2473 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
2474 l_rec_acct_attrs.array_char_value(4) := p_source_15;
2475 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
2476 l_rec_acct_attrs.array_date_value(5) := p_source_16;
2477 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
2478 l_rec_acct_attrs.array_num_value(6) := p_source_17;
2479 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
2480 l_rec_acct_attrs.array_char_value(7) := p_source_18;
2481 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
2482 l_rec_acct_attrs.array_num_value(8) := p_source_14;
2483
2484 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
2485 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
2486
2487 ---------------------------------------------------------------------------------------------------------------
2488 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
2489 ---------------------------------------------------------------------------------------------------------------
2490 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
2491
2492 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
2493 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
2494
2495 IF xla_accounting_cache_pkg.GetValueChar
2496 (p_source_code => 'LEDGER_CATEGORY_CODE'
2497 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
2498 AND l_bflow_method_code = 'PRIOR_ENTRY'
2499 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
2500 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
2504 xla_ae_lines_pkg.BflowUpgEntry
2501 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
2502 )
2503 THEN
2505 (p_business_method_code => l_bflow_method_code
2506 ,p_business_class_code => l_bflow_class_code
2507 ,p_balance_type => l_balance_type_code);
2508 ELSE
2509 NULL;
2510 -- No business flow processing for business flow method of NONE.
2511 END IF;
2512
2513 --
2514 -- call analytical criteria
2515 --
2516
2517 --
2518 -- call description
2519 --
2520
2521 xla_ae_lines_pkg.SetLineDescription(
2522 p_ae_header_id => l_ae_header_id
2523 ,p_description => Description_2 (
2524 p_application_id => p_application_id
2525 , p_ae_header_id => l_ae_header_id
2526 , p_source_4 => p_source_4
2527 , p_source_4_meaning => p_source_4_meaning
2528 )
2529 );
2530
2531
2532 --
2533 -- call ADRs
2534 -- Bug 4922099
2535 --
2536 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
2537 (NVL(l_actual_upg_option, 'N') = 'O') OR
2538 (NVL(l_enc_upg_option, 'N') = 'O')
2539 )
2540 THEN
2541 NULL;
2542 --
2543 --
2544
2545 l_ccid := AcctDerRule_4(
2546 p_application_id => p_application_id
2547 , p_ae_header_id => l_ae_header_id
2548 , p_source_6 => p_source_6
2549 , x_transaction_coa_id => l_adr_transaction_coa_id
2550 , x_accounting_coa_id => l_adr_accounting_coa_id
2551 , x_value_type_code => l_adr_value_type_code
2552 , p_side => 'NA'
2553 );
2554
2555 xla_ae_lines_pkg.set_ccid(
2556 p_code_combination_id => l_ccid
2557 , p_value_type_code => l_adr_value_type_code
2558 , p_transaction_coa_id => l_adr_transaction_coa_id
2559 , p_accounting_coa_id => l_adr_accounting_coa_id
2560 , p_adr_code => 'LNS_DIST_CCID'
2561 , p_adr_type_code => 'S'
2562 , p_component_type => l_component_type
2563 , p_component_code => l_component_code
2564 , p_component_type_code => l_component_type_code
2565 , p_component_appl_id => l_component_appl_id
2566 , p_amb_context_code => l_amb_context_code
2567 , p_side => 'NA'
2568 );
2569
2570
2571 l_segment := AcctDerRule_3(
2572 p_application_id => p_application_id
2573 , p_ae_header_id => l_ae_header_id
2574 , p_source_5 => p_source_5
2575 , x_transaction_coa_id => l_adr_transaction_coa_id
2576 , x_accounting_coa_id => l_adr_accounting_coa_id
2577 , x_flexfield_segment_code => l_adr_flexfield_segment_code
2578 , x_flex_value_set_id => l_adr_flex_value_set_id
2579 , x_value_type_code => l_adr_value_type_code
2580 , x_value_combination_id => l_adr_value_combination_id
2581 , x_value_segment_code => l_adr_value_segment_code
2582 , p_side => 'NA'
2583 , p_override_seg_flag => 'Y'
2584 );
2585
2586 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
2587
2588 xla_ae_lines_pkg.set_segment(
2589 p_to_segment_code => 'GL_BALANCING'
2593 , p_value_type_code => l_adr_value_type_code
2590 , p_segment_value => l_segment
2591 , p_from_segment_code => l_adr_value_segment_code
2592 , p_from_combination_id => l_adr_value_combination_id
2594 , p_transaction_coa_id => l_adr_transaction_coa_id
2595 , p_accounting_coa_id => l_adr_accounting_coa_id
2596 , p_flexfield_segment_code => l_adr_flexfield_segment_code
2597 , p_flex_value_set_id => l_adr_flex_value_set_id
2598 , p_adr_code => 'PROGRAM_ACCOUNT_BSV'
2599 , p_adr_type_code => 'S'
2600 , p_component_type => l_component_type
2601 , p_component_code => l_component_code
2602 , p_component_type_code => l_component_type_code
2603 , p_component_appl_id => l_component_appl_id
2604 , p_amb_context_code => l_amb_context_code
2605 , p_entity_code => 'LOANS'
2606 , p_event_class_code => 'DIRECT'
2607 , p_side => 'NA'
2608 );
2609
2610 END IF;
2611
2612 l_segment := AcctDerRule_6(
2613 p_application_id => p_application_id
2614 , p_ae_header_id => l_ae_header_id
2615 , x_transaction_coa_id => l_adr_transaction_coa_id
2616 , x_accounting_coa_id => l_adr_accounting_coa_id
2617 , x_flexfield_segment_code => l_adr_flexfield_segment_code
2618 , x_flex_value_set_id => l_adr_flex_value_set_id
2619 , x_value_type_code => l_adr_value_type_code
2620 , x_value_combination_id => l_adr_value_combination_id
2621 , x_value_segment_code => l_adr_value_segment_code
2622 , p_side => 'NA'
2623 , p_override_seg_flag => 'Y'
2624 );
2625
2626 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
2627
2628 xla_ae_lines_pkg.set_segment(
2629 p_to_segment_code => 'GL_ACCOUNT'
2630 , p_segment_value => l_segment
2631 , p_from_segment_code => l_adr_value_segment_code
2632 , p_from_combination_id => l_adr_value_combination_id
2633 , p_value_type_code => l_adr_value_type_code
2634 , p_transaction_coa_id => l_adr_transaction_coa_id
2635 , p_accounting_coa_id => l_adr_accounting_coa_id
2636 , p_flexfield_segment_code => l_adr_flexfield_segment_code
2637 , p_flex_value_set_id => l_adr_flex_value_set_id
2638 , p_adr_code => 'USGL_ACCOUNT_480102'
2639 , p_adr_type_code => 'S'
2640 , p_component_type => l_component_type
2641 , p_component_code => l_component_code
2642 , p_component_type_code => l_component_type_code
2643 , p_component_appl_id => l_component_appl_id
2644 , p_amb_context_code => l_amb_context_code
2645 , p_entity_code => 'LOANS'
2646 , p_event_class_code => 'DIRECT'
2647 , p_side => 'NA'
2648 );
2649
2650 END IF;
2651
2652 --
2653 --
2654 END IF;
2655 --
2656 -- Bug 4922099
2657 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
2658 (NVL(l_enc_upg_option, 'N') = 'O')
2659 ) AND
2660 (l_bflow_method_code = 'PRIOR_ENTRY')
2661 )
2662 THEN
2663 IF
2664 --
2665 1 = 2
2666 --
2667 THEN
2668 xla_accounting_err_pkg.build_message
2669 (p_appli_s_name => 'XLA'
2670 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
2671 ,p_token_1 => 'LINE_NUMBER'
2672 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
2673 ,p_token_2 => 'LINE_TYPE_NAME'
2674 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
2675 l_component_type
2676 ,l_component_code
2677 ,l_component_type_code
2678 ,l_component_appl_id
2679 ,l_amb_context_code
2680 ,l_entity_code
2681 ,l_event_class_code
2682 )
2683 ,p_token_3 => 'OWNER'
2684 ,p_value_3 => xla_lookups_pkg.get_meaning(
2685 p_lookup_type => 'XLA_OWNER_TYPE'
2686 ,p_lookup_code => l_component_type_code
2687 )
2688 ,p_token_4 => 'PRODUCT_NAME'
2689 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
2693 ,p_ae_header_id => NULL
2690 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
2691 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
2692 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
2694 );
2695
2696 IF (C_LEVEL_ERROR>= g_log_level) THEN
2697 trace
2698 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
2699 ,p_level => C_LEVEL_ERROR
2700 ,p_module => l_log_module);
2701 END IF;
2702 END IF;
2703 END IF;
2704 --
2705 --
2706 ------------------------------------------------------------------------------------------------
2707 -- 4219869 Business Flow
2708 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
2709 -- Prior Entry. Currently, the following code is always generated.
2710 ------------------------------------------------------------------------------------------------
2711 XLA_AE_LINES_PKG.ValidateCurrentLine;
2712
2713 ------------------------------------------------------------------------------------
2714 -- 4219869 Business Flow
2715 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
2716 ------------------------------------------------------------------------------------
2717 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
2718
2719 ----------------------------------------------------------------------------------
2720 -- 4219869 Business Flow
2721 -- Update journal entry status -- Need to generate this within IF <condition>
2722 ----------------------------------------------------------------------------------
2723 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
2724 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
2725 ,p_balance_type_code => l_balance_type_code
2726 );
2727
2728 -------------------------------------------------------------------------------------------
2729 -- 4262811 - Generate the Accrual Reversal lines
2730 -------------------------------------------------------------------------------------------
2731 BEGIN
2732 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
2733 (g_array_event(p_event_id).array_value_num('header_index'));
2734 IF l_acc_rev_flag IS NULL THEN
2735 l_acc_rev_flag := 'N';
2736 END IF;
2737 EXCEPTION
2738 WHEN OTHERS THEN
2739 l_acc_rev_flag := 'N';
2740 END;
2741 --
2742 IF (l_acc_rev_flag = 'Y') THEN
2743
2744 -- 4645092 ------------------------------------------------------------------------------
2745 -- To allow MPA report to determine if it should generate report process
2746 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
2747 ------------------------------------------------------------------------------------------
2748
2749 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
2750 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
2751
2752 --
2753 -- Update the line information that should be overwritten
2754 --
2755 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
2756 p_header_num => 1);
2757 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
2758
2759 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
2760
2761 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
2762 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
2763 END IF;
2764
2765 --
2766 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
2767 --
2768 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
2769 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
2770 ELSE
2771 ---------------------------------------------------------------------------------------------------
2772 -- 4262811a Switch Sign
2773 ---------------------------------------------------------------------------------------------------
2774 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
2775 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
2776 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
2777 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
2778 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
2779 -- 5132302
2780 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
2781 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
2782
2783 END IF;
2784
2785 -- 4955764
2786 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
2790 XLA_AE_LINES_PKG.ValidateCurrentLine;
2787 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
2788
2789
2791 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
2792
2793 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
2794 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
2795 ,p_balance_type_code => l_balance_type_code);
2796
2797 END IF;
2798
2799 -----------------------------------------------------------------------------------------
2800 -- 4262811 Multiperiod Accounting
2801 -----------------------------------------------------------------------------------------
2802 -- No MPA option is assigned.
2803
2804
2805 END IF;
2806 END IF;
2807 --
2808
2809 --
2810 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2811 trace
2812 (p_msg => 'END of AcctLineType_9'
2813 ,p_level => C_LEVEL_PROCEDURE
2814 ,p_module => l_log_module);
2815 END IF;
2816 --
2817 EXCEPTION
2818 WHEN xla_exceptions_pkg.application_exception THEN
2819 RAISE;
2820 WHEN OTHERS THEN
2821 xla_exceptions_pkg.raise_message
2822 (p_location => 'XLA_00206_AAD_S_000004_BC_PKG.AcctLineType_9');
2823 END AcctLineType_9;
2824 --
2825
2826 ---------------------------------------
2827 --
2828 -- PRIVATE FUNCTION
2829 -- AcctLineType_10
2830 --
2831 ---------------------------------------
2832 PROCEDURE AcctLineType_10 (
2833 p_application_id IN NUMBER
2834 ,p_event_id IN NUMBER
2835 ,p_calculate_acctd_flag IN VARCHAR2
2836 ,p_calculate_g_l_flag IN VARCHAR2
2837 ,p_actual_flag IN OUT VARCHAR2
2838 ,p_balance_type_code OUT VARCHAR2
2839 ,p_gain_or_loss_ref OUT VARCHAR2
2840
2841 --Account Name
2842 , p_source_4 IN VARCHAR2
2843 , p_source_4_meaning IN VARCHAR2
2844 --Derived Program Account BSV
2845 , p_source_5 IN VARCHAR2
2846 --Code Combination ID
2847 , p_source_6 IN NUMBER
2848 --Distribution Line Type
2849 , p_source_7 IN VARCHAR2
2850 --Account Type
2851 , p_source_8 IN VARCHAR2
2852 , p_source_8_meaning IN VARCHAR2
2853 --EVENT_TYPE
2854 , p_source_9 IN VARCHAR2
2855 , p_source_9_meaning IN VARCHAR2
2856 --Distribution ID
2857 , p_source_12 IN NUMBER
2858 --Distribution Type
2859 , p_source_13 IN VARCHAR2
2860 , p_source_13_meaning IN VARCHAR2
2861 --Distribution Amount
2862 , p_source_14 IN NUMBER
2863 --Currency
2864 , p_source_15 IN VARCHAR2
2865 , p_source_15_meaning IN VARCHAR2
2866 --EXCHANGE_DATE
2867 , p_source_16 IN DATE
2868 --EXCHANGE_RATE
2869 , p_source_17 IN NUMBER
2870 --EXCHANGE_RATE_TYPE
2871 , p_source_18 IN VARCHAR2
2872 --Subsidy Cost
2873 , p_source_19 IN NUMBER
2874 )
2875 IS
2876
2877 l_component_type VARCHAR2(80);
2878 l_component_code VARCHAR2(30);
2879 l_component_type_code VARCHAR2(1);
2880 l_component_appl_id INTEGER;
2881 l_amb_context_code VARCHAR2(30);
2882 l_entity_code VARCHAR2(30);
2883 l_event_class_code VARCHAR2(30);
2884 l_ae_header_id NUMBER;
2885 l_event_type_code VARCHAR2(30);
2886 l_line_definition_code VARCHAR2(30);
2887 l_line_definition_owner_code VARCHAR2(1);
2888 --
2889 -- adr variables
2890 l_segment VARCHAR2(30);
2891 l_ccid NUMBER;
2892 l_adr_transaction_coa_id NUMBER;
2893 l_adr_accounting_coa_id NUMBER;
2894 l_adr_flexfield_segment_code VARCHAR2(30);
2895 l_adr_flex_value_set_id NUMBER;
2896 l_adr_value_type_code VARCHAR2(30);
2897 l_adr_value_combination_id NUMBER;
2898 l_adr_value_segment_code VARCHAR2(30);
2899
2900 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
2901 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
2902 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
2903 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
2904
2905 -- 4262811 Variables ------------------------------------------------------------------------------------------
2906 l_entered_amt_idx NUMBER;
2907 l_accted_amt_idx NUMBER;
2908 l_acc_rev_flag VARCHAR2(1);
2909 l_accrual_line_num NUMBER;
2910 l_tmp_amt NUMBER;
2911 l_acc_rev_natural_side_code VARCHAR2(1);
2912
2913 l_num_entries NUMBER;
2914 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
2915 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
2916 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
2917 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
2918 l_recog_line_1 NUMBER;
2919 l_recog_line_2 NUMBER;
2920
2921 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
2922 l_bflow_applied_to_amt NUMBER; -- 5132302
2926
2923 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
2924
2925 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
2927 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
2928 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
2929
2930 ---------------------------------------------------------------------------------------------------------------
2931
2932
2933 --
2934 -- bulk performance
2935 --
2936 l_balance_type_code VARCHAR2(1);
2937 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
2938 l_log_module VARCHAR2(240);
2939
2940 --
2941 -- Upgrade strategy
2942 --
2943 l_actual_upg_option VARCHAR2(1);
2944 l_enc_upg_option VARCHAR2(1);
2945
2946 --
2947 BEGIN
2948 --
2949 IF g_log_enabled THEN
2950 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_10';
2951 END IF;
2952 --
2953 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2954
2955 trace
2956 (p_msg => 'BEGIN of AcctLineType_10'
2957 ,p_level => C_LEVEL_PROCEDURE
2958 ,p_module => l_log_module);
2959
2960 END IF;
2961 --
2962 l_component_type := 'AMB_JLT';
2963 l_component_code := 'USSGL_TC_A150_PROG_ACT_4801_C';
2964 l_component_type_code := 'S';
2965 l_component_appl_id := 206;
2966 l_amb_context_code := 'DEFAULT';
2967 l_entity_code := 'LOANS';
2968 l_event_class_code := 'DIRECT';
2969 l_event_type_code := 'FUTURE_DISBURSEMENT_CANCELLED';
2970 l_line_definition_owner_code := 'S';
2971 l_line_definition_code := 'FED_LNS_CANCEL';
2972 --
2973 l_balance_type_code := 'A';
2974 l_segment := NULL;
2975 l_ccid := NULL;
2976 l_adr_transaction_coa_id := NULL;
2977 l_adr_accounting_coa_id := NULL;
2978 l_adr_flexfield_segment_code := NULL;
2979 l_adr_flex_value_set_id := NULL;
2980 l_adr_value_type_code := NULL;
2981 l_adr_value_combination_id := NULL;
2982 l_adr_value_segment_code := NULL;
2983
2984 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
2985 l_bflow_class_code := ''; -- 4219869 Business Flow
2986 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
2987 l_budgetary_control_flag := 'Y';
2988
2989 l_bflow_applied_to_amt_idx := NULL; -- 5132302
2990 l_bflow_applied_to_amt := NULL; -- 5132302
2991 l_entered_amt_idx := NULL; -- 4262811
2992 l_accted_amt_idx := NULL; -- 4262811
2993 l_acc_rev_flag := NULL; -- 4262811
2994 l_accrual_line_num := NULL; -- 4262811
2995 l_tmp_amt := NULL; -- 4262811
2996 --
2997
2998 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
2999 l_balance_type_code <> 'B' THEN
3000 IF NVL(p_source_7,'
3001 ') = 'SUBSIDY' AND
3002 NVL(p_source_8,'
3003 ') = 'DR' AND
3004 NVL(p_source_9,'
3005 ') = 'FUTURE_DISBURSEMENT_CANCELLED'
3006 THEN
3007
3008 --
3009 XLA_AE_LINES_PKG.SetNewLine;
3010
3011 p_balance_type_code := l_balance_type_code;
3012 -- set the flag so later we will know whether the gain loss line needs to be created
3013
3014 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
3015 p_actual_flag :='A';
3016 END IF;
3017
3018 --
3019 -- bulk performance
3020 --
3021 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
3022 p_header_num => 0); -- 4262811
3023 --
3024 -- set accounting line options
3025 --
3026 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
3027 p_natural_side_code => 'D'
3028 , p_gain_or_loss_flag => 'N'
3029 , p_gl_transfer_mode_code => 'S'
3030 , p_acct_entry_type_code => 'A'
3031 , p_switch_side_flag => 'N'
3032 , p_merge_duplicate_code => 'N'
3033 );
3034 --
3035 l_acc_rev_natural_side_code := 'C'; -- 4262811
3036 --
3037 --
3038 -- set accounting line type info
3039 --
3040 xla_ae_lines_pkg.SetAcctLineType
3041 (p_component_type => l_component_type
3042 ,p_event_type_code => l_event_type_code
3043 ,p_line_definition_owner_code => l_line_definition_owner_code
3044 ,p_line_definition_code => l_line_definition_code
3045 ,p_accounting_line_code => l_component_code
3046 ,p_accounting_line_type_code => l_component_type_code
3047 ,p_accounting_line_appl_id => l_component_appl_id
3048 ,p_amb_context_code => l_amb_context_code
3049 ,p_entity_code => l_entity_code
3050 ,p_event_class_code => l_event_class_code);
3051 --
3052 -- set accounting class
3053 --
3054 xla_ae_lines_pkg.SetAcctClass(
3055 p_accounting_class_code => 'PROG_ACT'
3056 , p_ae_header_id => l_ae_header_id
3057 );
3058
3059 --
3060 -- set rounding class
3061 --
3062 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
3066 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
3063 'PROG_ACT';
3064
3065 --
3067 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
3068 --
3069 -- bulk performance
3070 --
3071 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
3072
3073 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
3074 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
3075
3076 -- 4955764
3077 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
3078 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
3079
3080 -- 4458381 Public Sector Enh
3081
3082 --
3083 -- set accounting attributes for the line type
3084 --
3085 l_entered_amt_idx := 3;
3086 l_accted_amt_idx := 8;
3087 l_bflow_applied_to_amt_idx := NULL; -- 5132302
3088 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
3089 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_12);
3090 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
3091 l_rec_acct_attrs.array_char_value(2) := p_source_13;
3092 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
3093 l_rec_acct_attrs.array_num_value(3) := p_source_14;
3094 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
3095 l_rec_acct_attrs.array_char_value(4) := p_source_15;
3096 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
3097 l_rec_acct_attrs.array_date_value(5) := p_source_16;
3098 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
3099 l_rec_acct_attrs.array_num_value(6) := p_source_17;
3100 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
3101 l_rec_acct_attrs.array_char_value(7) := p_source_18;
3102 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
3103 l_rec_acct_attrs.array_num_value(8) := p_source_19;
3104
3105 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
3106 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
3107
3108 ---------------------------------------------------------------------------------------------------------------
3109 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
3110 ---------------------------------------------------------------------------------------------------------------
3111 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
3112
3113 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
3114 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
3115
3116 IF xla_accounting_cache_pkg.GetValueChar
3117 (p_source_code => 'LEDGER_CATEGORY_CODE'
3118 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
3119 AND l_bflow_method_code = 'PRIOR_ENTRY'
3120 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
3121 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
3122 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
3123 )
3124 THEN
3125 xla_ae_lines_pkg.BflowUpgEntry
3126 (p_business_method_code => l_bflow_method_code
3127 ,p_business_class_code => l_bflow_class_code
3128 ,p_balance_type => l_balance_type_code);
3129 ELSE
3130 NULL;
3131 -- No business flow processing for business flow method of NONE.
3132 END IF;
3133
3134 --
3135 -- call analytical criteria
3136 --
3137
3138 --
3139 -- call description
3140 --
3141
3142 xla_ae_lines_pkg.SetLineDescription(
3143 p_ae_header_id => l_ae_header_id
3144 ,p_description => Description_2 (
3145 p_application_id => p_application_id
3146 , p_ae_header_id => l_ae_header_id
3147 , p_source_4 => p_source_4
3148 , p_source_4_meaning => p_source_4_meaning
3149 )
3150 );
3151
3152
3153 --
3154 -- call ADRs
3155 -- Bug 4922099
3156 --
3157 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
3158 (NVL(l_actual_upg_option, 'N') = 'O') OR
3159 (NVL(l_enc_upg_option, 'N') = 'O')
3160 )
3161 THEN
3162 NULL;
3163 --
3164 --
3165
3166 l_ccid := AcctDerRule_4(
3167 p_application_id => p_application_id
3168 , p_ae_header_id => l_ae_header_id
3169 , p_source_6 => p_source_6
3170 , x_transaction_coa_id => l_adr_transaction_coa_id
3171 , x_accounting_coa_id => l_adr_accounting_coa_id
3172 , x_value_type_code => l_adr_value_type_code
3173 , p_side => 'NA'
3174 );
3175
3176 xla_ae_lines_pkg.set_ccid(
3177 p_code_combination_id => l_ccid
3178 , p_value_type_code => l_adr_value_type_code
3179 , p_transaction_coa_id => l_adr_transaction_coa_id
3180 , p_accounting_coa_id => l_adr_accounting_coa_id
3181 , p_adr_code => 'LNS_DIST_CCID'
3182 , p_adr_type_code => 'S'
3183 , p_component_type => l_component_type
3187 , p_amb_context_code => l_amb_context_code
3184 , p_component_code => l_component_code
3185 , p_component_type_code => l_component_type_code
3186 , p_component_appl_id => l_component_appl_id
3188 , p_side => 'NA'
3189 );
3190
3191
3192 l_segment := AcctDerRule_3(
3193 p_application_id => p_application_id
3194 , p_ae_header_id => l_ae_header_id
3195 , p_source_5 => p_source_5
3196 , x_transaction_coa_id => l_adr_transaction_coa_id
3197 , x_accounting_coa_id => l_adr_accounting_coa_id
3198 , x_flexfield_segment_code => l_adr_flexfield_segment_code
3199 , x_flex_value_set_id => l_adr_flex_value_set_id
3200 , x_value_type_code => l_adr_value_type_code
3201 , x_value_combination_id => l_adr_value_combination_id
3202 , x_value_segment_code => l_adr_value_segment_code
3203 , p_side => 'NA'
3204 , p_override_seg_flag => 'Y'
3205 );
3206
3207 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
3208
3209 xla_ae_lines_pkg.set_segment(
3210 p_to_segment_code => 'GL_BALANCING'
3211 , p_segment_value => l_segment
3212 , p_from_segment_code => l_adr_value_segment_code
3213 , p_from_combination_id => l_adr_value_combination_id
3214 , p_value_type_code => l_adr_value_type_code
3215 , p_transaction_coa_id => l_adr_transaction_coa_id
3216 , p_accounting_coa_id => l_adr_accounting_coa_id
3217 , p_flexfield_segment_code => l_adr_flexfield_segment_code
3218 , p_flex_value_set_id => l_adr_flex_value_set_id
3219 , p_adr_code => 'PROGRAM_ACCOUNT_BSV'
3220 , p_adr_type_code => 'S'
3221 , p_component_type => l_component_type
3222 , p_component_code => l_component_code
3223 , p_component_type_code => l_component_type_code
3224 , p_component_appl_id => l_component_appl_id
3225 , p_amb_context_code => l_amb_context_code
3226 , p_entity_code => 'LOANS'
3227 , p_event_class_code => 'DIRECT'
3228 , p_side => 'NA'
3229 );
3230
3231 END IF;
3232
3233 l_segment := AcctDerRule_6(
3234 p_application_id => p_application_id
3235 , p_ae_header_id => l_ae_header_id
3236 , x_transaction_coa_id => l_adr_transaction_coa_id
3237 , x_accounting_coa_id => l_adr_accounting_coa_id
3238 , x_flexfield_segment_code => l_adr_flexfield_segment_code
3239 , x_flex_value_set_id => l_adr_flex_value_set_id
3240 , x_value_type_code => l_adr_value_type_code
3241 , x_value_combination_id => l_adr_value_combination_id
3242 , x_value_segment_code => l_adr_value_segment_code
3243 , p_side => 'NA'
3244 , p_override_seg_flag => 'Y'
3245 );
3246
3247 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
3248
3249 xla_ae_lines_pkg.set_segment(
3250 p_to_segment_code => 'GL_ACCOUNT'
3251 , p_segment_value => l_segment
3252 , p_from_segment_code => l_adr_value_segment_code
3253 , p_from_combination_id => l_adr_value_combination_id
3254 , p_value_type_code => l_adr_value_type_code
3255 , p_transaction_coa_id => l_adr_transaction_coa_id
3256 , p_accounting_coa_id => l_adr_accounting_coa_id
3257 , p_flexfield_segment_code => l_adr_flexfield_segment_code
3258 , p_flex_value_set_id => l_adr_flex_value_set_id
3259 , p_adr_code => 'USGL_ACCOUNT_480102'
3260 , p_adr_type_code => 'S'
3261 , p_component_type => l_component_type
3262 , p_component_code => l_component_code
3263 , p_component_type_code => l_component_type_code
3264 , p_component_appl_id => l_component_appl_id
3265 , p_amb_context_code => l_amb_context_code
3266 , p_entity_code => 'LOANS'
3267 , p_event_class_code => 'DIRECT'
3268 , p_side => 'NA'
3269 );
3270
3271 END IF;
3272
3273 --
3274 --
3275 END IF;
3276 --
3277 -- Bug 4922099
3278 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
3279 (NVL(l_enc_upg_option, 'N') = 'O')
3280 ) AND
3281 (l_bflow_method_code = 'PRIOR_ENTRY')
3282 )
3283 THEN
3284 IF
3285 --
3286 1 = 2
3287 --
3288 THEN
3289 xla_accounting_err_pkg.build_message
3290 (p_appli_s_name => 'XLA'
3291 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
3292 ,p_token_1 => 'LINE_NUMBER'
3293 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
3294 ,p_token_2 => 'LINE_TYPE_NAME'
3295 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
3296 l_component_type
3300 ,l_amb_context_code
3297 ,l_component_code
3298 ,l_component_type_code
3299 ,l_component_appl_id
3301 ,l_entity_code
3302 ,l_event_class_code
3303 )
3304 ,p_token_3 => 'OWNER'
3305 ,p_value_3 => xla_lookups_pkg.get_meaning(
3306 p_lookup_type => 'XLA_OWNER_TYPE'
3307 ,p_lookup_code => l_component_type_code
3308 )
3309 ,p_token_4 => 'PRODUCT_NAME'
3310 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
3311 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
3312 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
3313 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
3314 ,p_ae_header_id => NULL
3315 );
3316
3317 IF (C_LEVEL_ERROR>= g_log_level) THEN
3318 trace
3319 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
3320 ,p_level => C_LEVEL_ERROR
3321 ,p_module => l_log_module);
3322 END IF;
3323 END IF;
3324 END IF;
3325 --
3326 --
3327 ------------------------------------------------------------------------------------------------
3328 -- 4219869 Business Flow
3329 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
3330 -- Prior Entry. Currently, the following code is always generated.
3331 ------------------------------------------------------------------------------------------------
3332 XLA_AE_LINES_PKG.ValidateCurrentLine;
3333
3334 ------------------------------------------------------------------------------------
3335 -- 4219869 Business Flow
3336 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
3337 ------------------------------------------------------------------------------------
3338 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
3339
3340 ----------------------------------------------------------------------------------
3341 -- 4219869 Business Flow
3342 -- Update journal entry status -- Need to generate this within IF <condition>
3343 ----------------------------------------------------------------------------------
3344 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
3345 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
3346 ,p_balance_type_code => l_balance_type_code
3347 );
3348
3349 -------------------------------------------------------------------------------------------
3350 -- 4262811 - Generate the Accrual Reversal lines
3351 -------------------------------------------------------------------------------------------
3352 BEGIN
3353 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
3354 (g_array_event(p_event_id).array_value_num('header_index'));
3355 IF l_acc_rev_flag IS NULL THEN
3356 l_acc_rev_flag := 'N';
3357 END IF;
3358 EXCEPTION
3359 WHEN OTHERS THEN
3360 l_acc_rev_flag := 'N';
3361 END;
3362 --
3363 IF (l_acc_rev_flag = 'Y') THEN
3364
3365 -- 4645092 ------------------------------------------------------------------------------
3366 -- To allow MPA report to determine if it should generate report process
3367 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
3368 ------------------------------------------------------------------------------------------
3369
3370 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
3371 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
3372
3373 --
3374 -- Update the line information that should be overwritten
3375 --
3376 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
3377 p_header_num => 1);
3378 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
3379
3380 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
3381
3382 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
3383 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
3384 END IF;
3385
3386 --
3387 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
3388 --
3389 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
3393 -- 4262811a Switch Sign
3390 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
3391 ELSE
3392 ---------------------------------------------------------------------------------------------------
3394 ---------------------------------------------------------------------------------------------------
3395 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
3396 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
3397 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
3398 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
3399 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
3400 -- 5132302
3401 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
3402 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
3403
3404 END IF;
3405
3406 -- 4955764
3407 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
3408 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
3409
3410
3411 XLA_AE_LINES_PKG.ValidateCurrentLine;
3412 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
3413
3414 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
3415 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
3416 ,p_balance_type_code => l_balance_type_code);
3417
3418 END IF;
3419
3420 -----------------------------------------------------------------------------------------
3421 -- 4262811 Multiperiod Accounting
3422 -----------------------------------------------------------------------------------------
3423 -- No MPA option is assigned.
3424
3425
3426 END IF;
3427 END IF;
3428 --
3429
3430 --
3431 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3432 trace
3433 (p_msg => 'END of AcctLineType_10'
3434 ,p_level => C_LEVEL_PROCEDURE
3435 ,p_module => l_log_module);
3436 END IF;
3437 --
3438 EXCEPTION
3439 WHEN xla_exceptions_pkg.application_exception THEN
3440 RAISE;
3441 WHEN OTHERS THEN
3442 xla_exceptions_pkg.raise_message
3443 (p_location => 'XLA_00206_AAD_S_000004_BC_PKG.AcctLineType_10');
3444 END AcctLineType_10;
3445 --
3446
3447 ---------------------------------------
3448 --
3449 -- PRIVATE FUNCTION
3450 -- AcctLineType_11
3451 --
3452 ---------------------------------------
3453 PROCEDURE AcctLineType_11 (
3454 p_application_id IN NUMBER
3455 ,p_event_id IN NUMBER
3456 ,p_calculate_acctd_flag IN VARCHAR2
3457 ,p_calculate_g_l_flag IN VARCHAR2
3458 ,p_actual_flag IN OUT VARCHAR2
3459 ,p_balance_type_code OUT VARCHAR2
3460 ,p_gain_or_loss_ref OUT VARCHAR2
3461
3462 --Account Name
3463 , p_source_4 IN VARCHAR2
3464 , p_source_4_meaning IN VARCHAR2
3465 --Code Combination ID
3466 , p_source_6 IN NUMBER
3467 --Distribution Line Type
3468 , p_source_7 IN VARCHAR2
3469 --Account Type
3470 , p_source_8 IN VARCHAR2
3471 , p_source_8_meaning IN VARCHAR2
3472 --EVENT_TYPE
3473 , p_source_9 IN VARCHAR2
3474 , p_source_9_meaning IN VARCHAR2
3475 --Disbursement Number
3476 , p_source_10 IN NUMBER
3477 --FUNDS_RESERVED_FLAG
3478 , p_source_11 IN VARCHAR2
3479 --Distribution ID
3480 , p_source_12 IN NUMBER
3481 --Distribution Type
3482 , p_source_13 IN VARCHAR2
3483 , p_source_13_meaning IN VARCHAR2
3484 --Distribution Amount
3485 , p_source_14 IN NUMBER
3486 --Currency
3487 , p_source_15 IN VARCHAR2
3488 , p_source_15_meaning IN VARCHAR2
3489 --EXCHANGE_DATE
3490 , p_source_16 IN DATE
3491 --EXCHANGE_RATE
3492 , p_source_17 IN NUMBER
3493 --EXCHANGE_RATE_TYPE
3494 , p_source_18 IN VARCHAR2
3495 )
3496 IS
3497
3498 l_component_type VARCHAR2(80);
3499 l_component_code VARCHAR2(30);
3500 l_component_type_code VARCHAR2(1);
3501 l_component_appl_id INTEGER;
3502 l_amb_context_code VARCHAR2(30);
3503 l_entity_code VARCHAR2(30);
3504 l_event_class_code VARCHAR2(30);
3505 l_ae_header_id NUMBER;
3506 l_event_type_code VARCHAR2(30);
3507 l_line_definition_code VARCHAR2(30);
3508 l_line_definition_owner_code VARCHAR2(1);
3509 --
3510 -- adr variables
3511 l_segment VARCHAR2(30);
3512 l_ccid NUMBER;
3513 l_adr_transaction_coa_id NUMBER;
3514 l_adr_accounting_coa_id NUMBER;
3515 l_adr_flexfield_segment_code VARCHAR2(30);
3516 l_adr_flex_value_set_id NUMBER;
3517 l_adr_value_type_code VARCHAR2(30);
3518 l_adr_value_combination_id NUMBER;
3519 l_adr_value_segment_code VARCHAR2(30);
3520
3521 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
3525
3522 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
3523 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
3524 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
3526 -- 4262811 Variables ------------------------------------------------------------------------------------------
3527 l_entered_amt_idx NUMBER;
3528 l_accted_amt_idx NUMBER;
3529 l_acc_rev_flag VARCHAR2(1);
3530 l_accrual_line_num NUMBER;
3531 l_tmp_amt NUMBER;
3532 l_acc_rev_natural_side_code VARCHAR2(1);
3533
3534 l_num_entries NUMBER;
3535 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
3536 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
3537 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
3538 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
3539 l_recog_line_1 NUMBER;
3540 l_recog_line_2 NUMBER;
3541
3542 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
3543 l_bflow_applied_to_amt NUMBER; -- 5132302
3544 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
3545
3546 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
3547
3548 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
3549 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
3550
3551 ---------------------------------------------------------------------------------------------------------------
3552
3553
3554 --
3555 -- bulk performance
3556 --
3557 l_balance_type_code VARCHAR2(1);
3558 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
3559 l_log_module VARCHAR2(240);
3560
3561 --
3562 -- Upgrade strategy
3563 --
3564 l_actual_upg_option VARCHAR2(1);
3565 l_enc_upg_option VARCHAR2(1);
3566
3567 --
3568 BEGIN
3569 --
3570 IF g_log_enabled THEN
3571 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_11';
3572 END IF;
3573 --
3574 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3575
3576 trace
3577 (p_msg => 'BEGIN of AcctLineType_11'
3578 ,p_level => C_LEVEL_PROCEDURE
3579 ,p_module => l_log_module);
3580
3581 END IF;
3582 --
3583 l_component_type := 'AMB_JLT';
3584 l_component_code := 'USSGL_TC_B204_FIN_ACCT_4610';
3585 l_component_type_code := 'S';
3586 l_component_appl_id := 206;
3587 l_amb_context_code := 'DEFAULT';
3588 l_entity_code := 'LOANS';
3589 l_event_class_code := 'DIRECT';
3590 l_event_type_code := 'DIRECT_LOAN_APPROVED';
3591 l_line_definition_owner_code := 'S';
3592 l_line_definition_code := 'FED_LNS_APPROVAL';
3593 --
3594 l_balance_type_code := 'A';
3595 l_segment := NULL;
3596 l_ccid := NULL;
3597 l_adr_transaction_coa_id := NULL;
3598 l_adr_accounting_coa_id := NULL;
3599 l_adr_flexfield_segment_code := NULL;
3600 l_adr_flex_value_set_id := NULL;
3601 l_adr_value_type_code := NULL;
3602 l_adr_value_combination_id := NULL;
3603 l_adr_value_segment_code := NULL;
3604
3605 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
3606 l_bflow_class_code := ''; -- 4219869 Business Flow
3607 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
3608 l_budgetary_control_flag := 'Y';
3609
3610 l_bflow_applied_to_amt_idx := NULL; -- 5132302
3611 l_bflow_applied_to_amt := NULL; -- 5132302
3612 l_entered_amt_idx := NULL; -- 4262811
3613 l_accted_amt_idx := NULL; -- 4262811
3614 l_acc_rev_flag := NULL; -- 4262811
3615 l_accrual_line_num := NULL; -- 4262811
3616 l_tmp_amt := NULL; -- 4262811
3617 --
3618
3619 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
3620 l_balance_type_code <> 'B' THEN
3621 IF NVL(p_source_7,'
3622 ') <> 'SUBSIDY' AND
3623 NVL(p_source_8,'
3624 ') = 'DR' AND
3625 ((NVL(p_source_9,'
3626 ') = 'DIRECT_LOAN_APPROVED') OR
3627 (NVL(p_source_9,'
3628 ') = 'DISBURSEMENT_FUNDED' AND
3629 NVL(p_source_10,9E125) = 1 AND
3630 NVL(p_source_11,'
3631 ') = 'N')
3632 ) THEN
3633
3634 --
3635 XLA_AE_LINES_PKG.SetNewLine;
3636
3637 p_balance_type_code := l_balance_type_code;
3638 -- set the flag so later we will know whether the gain loss line needs to be created
3639
3640 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
3641 p_actual_flag :='A';
3642 END IF;
3643
3644 --
3645 -- bulk performance
3646 --
3647 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
3648 p_header_num => 0); -- 4262811
3649 --
3650 -- set accounting line options
3651 --
3652 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
3653 p_natural_side_code => 'D'
3654 , p_gain_or_loss_flag => 'N'
3655 , p_gl_transfer_mode_code => 'D'
3656 , p_acct_entry_type_code => 'A'
3657 , p_switch_side_flag => 'N'
3661 l_acc_rev_natural_side_code := 'C'; -- 4262811
3658 , p_merge_duplicate_code => 'N'
3659 );
3660 --
3662 --
3663 --
3664 -- set accounting line type info
3665 --
3666 xla_ae_lines_pkg.SetAcctLineType
3667 (p_component_type => l_component_type
3668 ,p_event_type_code => l_event_type_code
3669 ,p_line_definition_owner_code => l_line_definition_owner_code
3670 ,p_line_definition_code => l_line_definition_code
3671 ,p_accounting_line_code => l_component_code
3672 ,p_accounting_line_type_code => l_component_type_code
3673 ,p_accounting_line_appl_id => l_component_appl_id
3674 ,p_amb_context_code => l_amb_context_code
3675 ,p_entity_code => l_entity_code
3676 ,p_event_class_code => l_event_class_code);
3677 --
3678 -- set accounting class
3679 --
3680 xla_ae_lines_pkg.SetAcctClass(
3681 p_accounting_class_code => 'FIN_ACT'
3682 , p_ae_header_id => l_ae_header_id
3683 );
3684
3685 --
3686 -- set rounding class
3687 --
3688 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
3689 'FIN_ACT';
3690
3691 --
3692 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
3693 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
3694 --
3695 -- bulk performance
3696 --
3697 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
3698
3699 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
3700 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
3701
3702 -- 4955764
3703 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
3704 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
3705
3706 -- 4458381 Public Sector Enh
3707
3708 --
3709 -- set accounting attributes for the line type
3710 --
3711 l_entered_amt_idx := 3;
3712 l_accted_amt_idx := 8;
3713 l_bflow_applied_to_amt_idx := NULL; -- 5132302
3714 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
3715 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_12);
3716 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
3717 l_rec_acct_attrs.array_char_value(2) := p_source_13;
3718 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
3719 l_rec_acct_attrs.array_num_value(3) := p_source_14;
3720 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
3721 l_rec_acct_attrs.array_char_value(4) := p_source_15;
3722 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
3723 l_rec_acct_attrs.array_date_value(5) := p_source_16;
3724 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
3725 l_rec_acct_attrs.array_num_value(6) := p_source_17;
3726 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
3727 l_rec_acct_attrs.array_char_value(7) := p_source_18;
3728 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
3729 l_rec_acct_attrs.array_num_value(8) := p_source_14;
3730
3731 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
3732 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
3733
3734 ---------------------------------------------------------------------------------------------------------------
3735 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
3736 ---------------------------------------------------------------------------------------------------------------
3737 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
3738
3739 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
3740 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
3741
3742 IF xla_accounting_cache_pkg.GetValueChar
3743 (p_source_code => 'LEDGER_CATEGORY_CODE'
3744 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
3745 AND l_bflow_method_code = 'PRIOR_ENTRY'
3746 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
3747 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
3748 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
3749 )
3750 THEN
3751 xla_ae_lines_pkg.BflowUpgEntry
3752 (p_business_method_code => l_bflow_method_code
3753 ,p_business_class_code => l_bflow_class_code
3754 ,p_balance_type => l_balance_type_code);
3755 ELSE
3756 NULL;
3757 -- No business flow processing for business flow method of NONE.
3758 END IF;
3759
3760 --
3761 -- call analytical criteria
3762 --
3763
3764 --
3765 -- call description
3766 --
3767
3768 xla_ae_lines_pkg.SetLineDescription(
3769 p_ae_header_id => l_ae_header_id
3770 ,p_description => Description_2 (
3771 p_application_id => p_application_id
3772 , p_ae_header_id => l_ae_header_id
3773 , p_source_4 => p_source_4
3774 , p_source_4_meaning => p_source_4_meaning
3778
3775 )
3776 );
3777
3779 --
3780 -- call ADRs
3781 -- Bug 4922099
3782 --
3783 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
3784 (NVL(l_actual_upg_option, 'N') = 'O') OR
3785 (NVL(l_enc_upg_option, 'N') = 'O')
3786 )
3787 THEN
3788 NULL;
3789 --
3790 --
3791
3792 l_ccid := AcctDerRule_4(
3793 p_application_id => p_application_id
3794 , p_ae_header_id => l_ae_header_id
3795 , p_source_6 => p_source_6
3796 , x_transaction_coa_id => l_adr_transaction_coa_id
3797 , x_accounting_coa_id => l_adr_accounting_coa_id
3798 , x_value_type_code => l_adr_value_type_code
3799 , p_side => 'NA'
3800 );
3801
3802 xla_ae_lines_pkg.set_ccid(
3803 p_code_combination_id => l_ccid
3804 , p_value_type_code => l_adr_value_type_code
3805 , p_transaction_coa_id => l_adr_transaction_coa_id
3806 , p_accounting_coa_id => l_adr_accounting_coa_id
3807 , p_adr_code => 'LNS_DIST_CCID'
3808 , p_adr_type_code => 'S'
3809 , p_component_type => l_component_type
3810 , p_component_code => l_component_code
3811 , p_component_type_code => l_component_type_code
3812 , p_component_appl_id => l_component_appl_id
3813 , p_amb_context_code => l_amb_context_code
3814 , p_side => 'NA'
3815 );
3816
3817
3818 l_segment := AcctDerRule_5(
3819 p_application_id => p_application_id
3820 , p_ae_header_id => l_ae_header_id
3821 , x_transaction_coa_id => l_adr_transaction_coa_id
3822 , x_accounting_coa_id => l_adr_accounting_coa_id
3823 , x_flexfield_segment_code => l_adr_flexfield_segment_code
3824 , x_flex_value_set_id => l_adr_flex_value_set_id
3825 , x_value_type_code => l_adr_value_type_code
3826 , x_value_combination_id => l_adr_value_combination_id
3827 , x_value_segment_code => l_adr_value_segment_code
3828 , p_side => 'NA'
3829 , p_override_seg_flag => 'Y'
3830 );
3831
3832 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
3833
3834 xla_ae_lines_pkg.set_segment(
3835 p_to_segment_code => 'GL_ACCOUNT'
3836 , p_segment_value => l_segment
3837 , p_from_segment_code => l_adr_value_segment_code
3838 , p_from_combination_id => l_adr_value_combination_id
3839 , p_value_type_code => l_adr_value_type_code
3840 , p_transaction_coa_id => l_adr_transaction_coa_id
3841 , p_accounting_coa_id => l_adr_accounting_coa_id
3842 , p_flexfield_segment_code => l_adr_flexfield_segment_code
3843 , p_flex_value_set_id => l_adr_flex_value_set_id
3844 , p_adr_code => 'USGL_ACCOUNT_461001'
3845 , p_adr_type_code => 'S'
3846 , p_component_type => l_component_type
3847 , p_component_code => l_component_code
3848 , p_component_type_code => l_component_type_code
3849 , p_component_appl_id => l_component_appl_id
3850 , p_amb_context_code => l_amb_context_code
3851 , p_entity_code => 'LOANS'
3852 , p_event_class_code => 'DIRECT'
3853 , p_side => 'NA'
3854 );
3855
3856 END IF;
3857
3858 --
3859 --
3860 END IF;
3861 --
3862 -- Bug 4922099
3863 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
3864 (NVL(l_enc_upg_option, 'N') = 'O')
3865 ) AND
3866 (l_bflow_method_code = 'PRIOR_ENTRY')
3867 )
3868 THEN
3869 IF
3870 --
3871 1 = 2
3872 --
3873 THEN
3874 xla_accounting_err_pkg.build_message
3875 (p_appli_s_name => 'XLA'
3876 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
3877 ,p_token_1 => 'LINE_NUMBER'
3878 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
3879 ,p_token_2 => 'LINE_TYPE_NAME'
3880 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
3881 l_component_type
3882 ,l_component_code
3883 ,l_component_type_code
3884 ,l_component_appl_id
3885 ,l_amb_context_code
3886 ,l_entity_code
3887 ,l_event_class_code
3888 )
3889 ,p_token_3 => 'OWNER'
3890 ,p_value_3 => xla_lookups_pkg.get_meaning(
3894 ,p_token_4 => 'PRODUCT_NAME'
3891 p_lookup_type => 'XLA_OWNER_TYPE'
3892 ,p_lookup_code => l_component_type_code
3893 )
3895 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
3896 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
3897 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
3898 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
3899 ,p_ae_header_id => NULL
3900 );
3901
3902 IF (C_LEVEL_ERROR>= g_log_level) THEN
3903 trace
3904 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
3905 ,p_level => C_LEVEL_ERROR
3906 ,p_module => l_log_module);
3907 END IF;
3908 END IF;
3909 END IF;
3910 --
3911 --
3912 ------------------------------------------------------------------------------------------------
3913 -- 4219869 Business Flow
3914 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
3915 -- Prior Entry. Currently, the following code is always generated.
3916 ------------------------------------------------------------------------------------------------
3917 XLA_AE_LINES_PKG.ValidateCurrentLine;
3918
3919 ------------------------------------------------------------------------------------
3920 -- 4219869 Business Flow
3921 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
3922 ------------------------------------------------------------------------------------
3923 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
3924
3925 ----------------------------------------------------------------------------------
3926 -- 4219869 Business Flow
3927 -- Update journal entry status -- Need to generate this within IF <condition>
3928 ----------------------------------------------------------------------------------
3929 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
3930 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
3931 ,p_balance_type_code => l_balance_type_code
3932 );
3933
3934 -------------------------------------------------------------------------------------------
3935 -- 4262811 - Generate the Accrual Reversal lines
3936 -------------------------------------------------------------------------------------------
3937 BEGIN
3938 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
3939 (g_array_event(p_event_id).array_value_num('header_index'));
3940 IF l_acc_rev_flag IS NULL THEN
3941 l_acc_rev_flag := 'N';
3942 END IF;
3943 EXCEPTION
3944 WHEN OTHERS THEN
3945 l_acc_rev_flag := 'N';
3946 END;
3947 --
3948 IF (l_acc_rev_flag = 'Y') THEN
3949
3950 -- 4645092 ------------------------------------------------------------------------------
3951 -- To allow MPA report to determine if it should generate report process
3952 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
3953 ------------------------------------------------------------------------------------------
3954
3955 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
3956 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
3957
3958 --
3959 -- Update the line information that should be overwritten
3960 --
3961 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
3962 p_header_num => 1);
3963 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
3964
3965 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
3966
3967 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
3968 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
3969 END IF;
3970
3971 --
3972 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
3973 --
3974 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
3975 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
3976 ELSE
3977 ---------------------------------------------------------------------------------------------------
3978 -- 4262811a Switch Sign
3979 ---------------------------------------------------------------------------------------------------
3980 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
3981 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
3982 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
3983 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
3987 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
3984 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
3985 -- 5132302
3986 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
3988
3989 END IF;
3990
3991 -- 4955764
3992 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
3993 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
3994
3995
3996 XLA_AE_LINES_PKG.ValidateCurrentLine;
3997 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
3998
3999 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
4000 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
4001 ,p_balance_type_code => l_balance_type_code);
4002
4003 END IF;
4004
4005 -----------------------------------------------------------------------------------------
4006 -- 4262811 Multiperiod Accounting
4007 -----------------------------------------------------------------------------------------
4008 -- No MPA option is assigned.
4009
4010
4011 END IF;
4012 END IF;
4013 --
4014
4015 --
4016 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4017 trace
4018 (p_msg => 'END of AcctLineType_11'
4019 ,p_level => C_LEVEL_PROCEDURE
4020 ,p_module => l_log_module);
4021 END IF;
4022 --
4023 EXCEPTION
4024 WHEN xla_exceptions_pkg.application_exception THEN
4025 RAISE;
4026 WHEN OTHERS THEN
4027 xla_exceptions_pkg.raise_message
4028 (p_location => 'XLA_00206_AAD_S_000004_BC_PKG.AcctLineType_11');
4029 END AcctLineType_11;
4030 --
4031
4032 ---------------------------------------
4033 --
4034 -- PRIVATE FUNCTION
4035 -- AcctLineType_12
4036 --
4037 ---------------------------------------
4038 PROCEDURE AcctLineType_12 (
4039 p_application_id IN NUMBER
4040 ,p_event_id IN NUMBER
4041 ,p_calculate_acctd_flag IN VARCHAR2
4042 ,p_calculate_g_l_flag IN VARCHAR2
4043 ,p_actual_flag IN OUT VARCHAR2
4044 ,p_balance_type_code OUT VARCHAR2
4045 ,p_gain_or_loss_ref OUT VARCHAR2
4046
4047 --Account Name
4048 , p_source_4 IN VARCHAR2
4049 , p_source_4_meaning IN VARCHAR2
4050 --Code Combination ID
4051 , p_source_6 IN NUMBER
4052 --Distribution Line Type
4053 , p_source_7 IN VARCHAR2
4054 --Account Type
4055 , p_source_8 IN VARCHAR2
4056 , p_source_8_meaning IN VARCHAR2
4057 --EVENT_TYPE
4058 , p_source_9 IN VARCHAR2
4059 , p_source_9_meaning IN VARCHAR2
4060 --Distribution ID
4061 , p_source_12 IN NUMBER
4062 --Distribution Type
4063 , p_source_13 IN VARCHAR2
4064 , p_source_13_meaning IN VARCHAR2
4065 --Distribution Amount
4066 , p_source_14 IN NUMBER
4067 --Currency
4068 , p_source_15 IN VARCHAR2
4069 , p_source_15_meaning IN VARCHAR2
4070 --EXCHANGE_DATE
4071 , p_source_16 IN DATE
4072 --EXCHANGE_RATE
4073 , p_source_17 IN NUMBER
4074 --EXCHANGE_RATE_TYPE
4075 , p_source_18 IN VARCHAR2
4076 --Subsidy Cost
4077 , p_source_19 IN NUMBER
4078 )
4079 IS
4080
4081 l_component_type VARCHAR2(80);
4082 l_component_code VARCHAR2(30);
4083 l_component_type_code VARCHAR2(1);
4084 l_component_appl_id INTEGER;
4085 l_amb_context_code VARCHAR2(30);
4086 l_entity_code VARCHAR2(30);
4087 l_event_class_code VARCHAR2(30);
4088 l_ae_header_id NUMBER;
4089 l_event_type_code VARCHAR2(30);
4090 l_line_definition_code VARCHAR2(30);
4091 l_line_definition_owner_code VARCHAR2(1);
4092 --
4093 -- adr variables
4094 l_segment VARCHAR2(30);
4095 l_ccid NUMBER;
4096 l_adr_transaction_coa_id NUMBER;
4097 l_adr_accounting_coa_id NUMBER;
4098 l_adr_flexfield_segment_code VARCHAR2(30);
4099 l_adr_flex_value_set_id NUMBER;
4100 l_adr_value_type_code VARCHAR2(30);
4101 l_adr_value_combination_id NUMBER;
4102 l_adr_value_segment_code VARCHAR2(30);
4103
4104 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
4105 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
4106 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
4107 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
4108
4109 -- 4262811 Variables ------------------------------------------------------------------------------------------
4110 l_entered_amt_idx NUMBER;
4111 l_accted_amt_idx NUMBER;
4112 l_acc_rev_flag VARCHAR2(1);
4113 l_accrual_line_num NUMBER;
4114 l_tmp_amt NUMBER;
4115 l_acc_rev_natural_side_code VARCHAR2(1);
4116
4117 l_num_entries NUMBER;
4118 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
4119 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
4120 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
4124
4121 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
4122 l_recog_line_1 NUMBER;
4123 l_recog_line_2 NUMBER;
4125 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
4126 l_bflow_applied_to_amt NUMBER; -- 5132302
4127 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
4128
4129 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
4130
4131 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
4132 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
4133
4134 ---------------------------------------------------------------------------------------------------------------
4135
4136
4137 --
4138 -- bulk performance
4139 --
4140 l_balance_type_code VARCHAR2(1);
4141 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
4142 l_log_module VARCHAR2(240);
4143
4144 --
4145 -- Upgrade strategy
4146 --
4147 l_actual_upg_option VARCHAR2(1);
4148 l_enc_upg_option VARCHAR2(1);
4149
4150 --
4151 BEGIN
4152 --
4153 IF g_log_enabled THEN
4154 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_12';
4155 END IF;
4156 --
4157 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4158
4159 trace
4160 (p_msg => 'BEGIN of AcctLineType_12'
4161 ,p_level => C_LEVEL_PROCEDURE
4162 ,p_module => l_log_module);
4163
4164 END IF;
4165 --
4166 l_component_type := 'AMB_JLT';
4167 l_component_code := 'USSGL_TC_B204_FIN_ACCT_4610_C';
4168 l_component_type_code := 'S';
4169 l_component_appl_id := 206;
4170 l_amb_context_code := 'DEFAULT';
4171 l_entity_code := 'LOANS';
4172 l_event_class_code := 'DIRECT';
4173 l_event_type_code := 'FUTURE_DISBURSEMENT_CANCELLED';
4174 l_line_definition_owner_code := 'S';
4175 l_line_definition_code := 'FED_LNS_CANCEL';
4176 --
4177 l_balance_type_code := 'A';
4178 l_segment := NULL;
4179 l_ccid := NULL;
4180 l_adr_transaction_coa_id := NULL;
4181 l_adr_accounting_coa_id := NULL;
4182 l_adr_flexfield_segment_code := NULL;
4183 l_adr_flex_value_set_id := NULL;
4184 l_adr_value_type_code := NULL;
4185 l_adr_value_combination_id := NULL;
4186 l_adr_value_segment_code := NULL;
4187
4188 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
4189 l_bflow_class_code := ''; -- 4219869 Business Flow
4190 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
4191 l_budgetary_control_flag := 'Y';
4192
4193 l_bflow_applied_to_amt_idx := NULL; -- 5132302
4194 l_bflow_applied_to_amt := NULL; -- 5132302
4195 l_entered_amt_idx := NULL; -- 4262811
4196 l_accted_amt_idx := NULL; -- 4262811
4197 l_acc_rev_flag := NULL; -- 4262811
4198 l_accrual_line_num := NULL; -- 4262811
4199 l_tmp_amt := NULL; -- 4262811
4200 --
4201
4202 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
4203 l_balance_type_code <> 'B' THEN
4204 IF NVL(p_source_7,'
4205 ') <> 'SUBSIDY' AND
4206 NVL(p_source_8,'
4207 ') = 'CR' AND
4208 NVL(p_source_9,'
4209 ') = 'FUTURE_DISBURSEMENT_CANCELLED'
4210 THEN
4211
4212 --
4213 XLA_AE_LINES_PKG.SetNewLine;
4214
4215 p_balance_type_code := l_balance_type_code;
4216 -- set the flag so later we will know whether the gain loss line needs to be created
4217
4218 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
4219 p_actual_flag :='A';
4220 END IF;
4221
4222 --
4223 -- bulk performance
4224 --
4225 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
4226 p_header_num => 0); -- 4262811
4227 --
4228 -- set accounting line options
4229 --
4230 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
4231 p_natural_side_code => 'C'
4232 , p_gain_or_loss_flag => 'N'
4233 , p_gl_transfer_mode_code => 'S'
4234 , p_acct_entry_type_code => 'A'
4235 , p_switch_side_flag => 'N'
4236 , p_merge_duplicate_code => 'N'
4237 );
4238 --
4239 l_acc_rev_natural_side_code := 'D'; -- 4262811
4240 --
4241 --
4242 -- set accounting line type info
4243 --
4244 xla_ae_lines_pkg.SetAcctLineType
4245 (p_component_type => l_component_type
4246 ,p_event_type_code => l_event_type_code
4247 ,p_line_definition_owner_code => l_line_definition_owner_code
4248 ,p_line_definition_code => l_line_definition_code
4249 ,p_accounting_line_code => l_component_code
4250 ,p_accounting_line_type_code => l_component_type_code
4251 ,p_accounting_line_appl_id => l_component_appl_id
4252 ,p_amb_context_code => l_amb_context_code
4253 ,p_entity_code => l_entity_code
4254 ,p_event_class_code => l_event_class_code);
4255 --
4256 -- set accounting class
4257 --
4258 xla_ae_lines_pkg.SetAcctClass(
4262
4259 p_accounting_class_code => 'FIN_ACT'
4260 , p_ae_header_id => l_ae_header_id
4261 );
4263 --
4264 -- set rounding class
4265 --
4266 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
4267 'FIN_ACT';
4268
4269 --
4270 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
4271 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
4272 --
4273 -- bulk performance
4274 --
4275 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
4276
4277 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
4278 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
4279
4280 -- 4955764
4281 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
4282 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
4283
4284 -- 4458381 Public Sector Enh
4285
4286 --
4287 -- set accounting attributes for the line type
4288 --
4289 l_entered_amt_idx := 3;
4290 l_accted_amt_idx := 8;
4291 l_bflow_applied_to_amt_idx := NULL; -- 5132302
4292 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
4293 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_12);
4294 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
4295 l_rec_acct_attrs.array_char_value(2) := p_source_13;
4296 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
4297 l_rec_acct_attrs.array_num_value(3) := p_source_14;
4298 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
4299 l_rec_acct_attrs.array_char_value(4) := p_source_15;
4300 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
4301 l_rec_acct_attrs.array_date_value(5) := p_source_16;
4302 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
4303 l_rec_acct_attrs.array_num_value(6) := p_source_17;
4304 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
4305 l_rec_acct_attrs.array_char_value(7) := p_source_18;
4306 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
4307 l_rec_acct_attrs.array_num_value(8) := p_source_19;
4308
4309 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
4310 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
4311
4312 ---------------------------------------------------------------------------------------------------------------
4313 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
4314 ---------------------------------------------------------------------------------------------------------------
4315 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
4316
4317 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
4318 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
4319
4320 IF xla_accounting_cache_pkg.GetValueChar
4321 (p_source_code => 'LEDGER_CATEGORY_CODE'
4322 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
4323 AND l_bflow_method_code = 'PRIOR_ENTRY'
4324 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
4325 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
4326 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
4327 )
4328 THEN
4329 xla_ae_lines_pkg.BflowUpgEntry
4330 (p_business_method_code => l_bflow_method_code
4331 ,p_business_class_code => l_bflow_class_code
4332 ,p_balance_type => l_balance_type_code);
4333 ELSE
4334 NULL;
4335 -- No business flow processing for business flow method of NONE.
4336 END IF;
4337
4338 --
4339 -- call analytical criteria
4340 --
4341
4342 --
4343 -- call description
4344 --
4345
4346 xla_ae_lines_pkg.SetLineDescription(
4347 p_ae_header_id => l_ae_header_id
4348 ,p_description => Description_2 (
4349 p_application_id => p_application_id
4350 , p_ae_header_id => l_ae_header_id
4351 , p_source_4 => p_source_4
4352 , p_source_4_meaning => p_source_4_meaning
4353 )
4354 );
4355
4356
4357 --
4358 -- call ADRs
4359 -- Bug 4922099
4360 --
4361 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
4362 (NVL(l_actual_upg_option, 'N') = 'O') OR
4363 (NVL(l_enc_upg_option, 'N') = 'O')
4364 )
4365 THEN
4366 NULL;
4367 --
4368 --
4369
4370 l_ccid := AcctDerRule_4(
4371 p_application_id => p_application_id
4372 , p_ae_header_id => l_ae_header_id
4373 , p_source_6 => p_source_6
4374 , x_transaction_coa_id => l_adr_transaction_coa_id
4375 , x_accounting_coa_id => l_adr_accounting_coa_id
4376 , x_value_type_code => l_adr_value_type_code
4377 , p_side => 'NA'
4378 );
4379
4380 xla_ae_lines_pkg.set_ccid(
4384 , p_accounting_coa_id => l_adr_accounting_coa_id
4381 p_code_combination_id => l_ccid
4382 , p_value_type_code => l_adr_value_type_code
4383 , p_transaction_coa_id => l_adr_transaction_coa_id
4385 , p_adr_code => 'LNS_DIST_CCID'
4386 , p_adr_type_code => 'S'
4387 , p_component_type => l_component_type
4388 , p_component_code => l_component_code
4389 , p_component_type_code => l_component_type_code
4390 , p_component_appl_id => l_component_appl_id
4391 , p_amb_context_code => l_amb_context_code
4392 , p_side => 'NA'
4393 );
4394
4395
4396 l_segment := AcctDerRule_5(
4397 p_application_id => p_application_id
4398 , p_ae_header_id => l_ae_header_id
4399 , x_transaction_coa_id => l_adr_transaction_coa_id
4400 , x_accounting_coa_id => l_adr_accounting_coa_id
4401 , x_flexfield_segment_code => l_adr_flexfield_segment_code
4402 , x_flex_value_set_id => l_adr_flex_value_set_id
4403 , x_value_type_code => l_adr_value_type_code
4404 , x_value_combination_id => l_adr_value_combination_id
4405 , x_value_segment_code => l_adr_value_segment_code
4406 , p_side => 'NA'
4407 , p_override_seg_flag => 'Y'
4408 );
4409
4410 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
4411
4412 xla_ae_lines_pkg.set_segment(
4413 p_to_segment_code => 'GL_ACCOUNT'
4414 , p_segment_value => l_segment
4415 , p_from_segment_code => l_adr_value_segment_code
4416 , p_from_combination_id => l_adr_value_combination_id
4417 , p_value_type_code => l_adr_value_type_code
4418 , p_transaction_coa_id => l_adr_transaction_coa_id
4419 , p_accounting_coa_id => l_adr_accounting_coa_id
4420 , p_flexfield_segment_code => l_adr_flexfield_segment_code
4421 , p_flex_value_set_id => l_adr_flex_value_set_id
4422 , p_adr_code => 'USGL_ACCOUNT_461001'
4423 , p_adr_type_code => 'S'
4424 , p_component_type => l_component_type
4425 , p_component_code => l_component_code
4426 , p_component_type_code => l_component_type_code
4427 , p_component_appl_id => l_component_appl_id
4428 , p_amb_context_code => l_amb_context_code
4429 , p_entity_code => 'LOANS'
4430 , p_event_class_code => 'DIRECT'
4431 , p_side => 'NA'
4432 );
4433
4434 END IF;
4435
4436 --
4437 --
4438 END IF;
4439 --
4440 -- Bug 4922099
4441 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
4442 (NVL(l_enc_upg_option, 'N') = 'O')
4443 ) AND
4444 (l_bflow_method_code = 'PRIOR_ENTRY')
4445 )
4446 THEN
4447 IF
4448 --
4449 1 = 2
4450 --
4451 THEN
4452 xla_accounting_err_pkg.build_message
4453 (p_appli_s_name => 'XLA'
4454 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
4455 ,p_token_1 => 'LINE_NUMBER'
4456 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
4457 ,p_token_2 => 'LINE_TYPE_NAME'
4458 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
4459 l_component_type
4460 ,l_component_code
4461 ,l_component_type_code
4462 ,l_component_appl_id
4463 ,l_amb_context_code
4464 ,l_entity_code
4465 ,l_event_class_code
4466 )
4467 ,p_token_3 => 'OWNER'
4468 ,p_value_3 => xla_lookups_pkg.get_meaning(
4469 p_lookup_type => 'XLA_OWNER_TYPE'
4470 ,p_lookup_code => l_component_type_code
4471 )
4472 ,p_token_4 => 'PRODUCT_NAME'
4473 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
4474 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
4475 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
4476 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
4477 ,p_ae_header_id => NULL
4478 );
4479
4483 ,p_level => C_LEVEL_ERROR
4480 IF (C_LEVEL_ERROR>= g_log_level) THEN
4481 trace
4482 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
4484 ,p_module => l_log_module);
4485 END IF;
4486 END IF;
4487 END IF;
4488 --
4489 --
4490 ------------------------------------------------------------------------------------------------
4491 -- 4219869 Business Flow
4492 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
4493 -- Prior Entry. Currently, the following code is always generated.
4494 ------------------------------------------------------------------------------------------------
4495 XLA_AE_LINES_PKG.ValidateCurrentLine;
4496
4497 ------------------------------------------------------------------------------------
4498 -- 4219869 Business Flow
4499 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
4500 ------------------------------------------------------------------------------------
4501 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
4502
4503 ----------------------------------------------------------------------------------
4504 -- 4219869 Business Flow
4505 -- Update journal entry status -- Need to generate this within IF <condition>
4506 ----------------------------------------------------------------------------------
4507 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
4508 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
4509 ,p_balance_type_code => l_balance_type_code
4510 );
4511
4512 -------------------------------------------------------------------------------------------
4513 -- 4262811 - Generate the Accrual Reversal lines
4514 -------------------------------------------------------------------------------------------
4515 BEGIN
4516 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
4517 (g_array_event(p_event_id).array_value_num('header_index'));
4518 IF l_acc_rev_flag IS NULL THEN
4519 l_acc_rev_flag := 'N';
4520 END IF;
4521 EXCEPTION
4522 WHEN OTHERS THEN
4523 l_acc_rev_flag := 'N';
4524 END;
4525 --
4526 IF (l_acc_rev_flag = 'Y') THEN
4527
4528 -- 4645092 ------------------------------------------------------------------------------
4529 -- To allow MPA report to determine if it should generate report process
4530 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
4531 ------------------------------------------------------------------------------------------
4532
4533 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
4534 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
4535
4536 --
4537 -- Update the line information that should be overwritten
4538 --
4539 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
4540 p_header_num => 1);
4541 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
4542
4543 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
4544
4545 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
4546 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
4547 END IF;
4548
4549 --
4550 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
4551 --
4552 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
4553 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
4554 ELSE
4555 ---------------------------------------------------------------------------------------------------
4556 -- 4262811a Switch Sign
4557 ---------------------------------------------------------------------------------------------------
4558 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
4559 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
4560 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
4561 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
4562 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
4563 -- 5132302
4564 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
4565 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
4566
4567 END IF;
4568
4569 -- 4955764
4570 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
4571 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
4572
4573
4574 XLA_AE_LINES_PKG.ValidateCurrentLine;
4575 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
4576
4577 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
4578 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
4579 ,p_balance_type_code => l_balance_type_code);
4580
4581 END IF;
4582
4586 -- No MPA option is assigned.
4583 -----------------------------------------------------------------------------------------
4584 -- 4262811 Multiperiod Accounting
4585 -----------------------------------------------------------------------------------------
4587
4588
4589 END IF;
4590 END IF;
4591 --
4592
4593 --
4594 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4595 trace
4596 (p_msg => 'END of AcctLineType_12'
4597 ,p_level => C_LEVEL_PROCEDURE
4598 ,p_module => l_log_module);
4599 END IF;
4600 --
4601 EXCEPTION
4602 WHEN xla_exceptions_pkg.application_exception THEN
4603 RAISE;
4604 WHEN OTHERS THEN
4605 xla_exceptions_pkg.raise_message
4606 (p_location => 'XLA_00206_AAD_S_000004_BC_PKG.AcctLineType_12');
4607 END AcctLineType_12;
4608 --
4609
4610 ---------------------------------------
4611 --
4612 -- PRIVATE FUNCTION
4613 -- AcctLineType_13
4614 --
4615 ---------------------------------------
4616 PROCEDURE AcctLineType_13 (
4617 p_application_id IN NUMBER
4618 ,p_event_id IN NUMBER
4619 ,p_calculate_acctd_flag IN VARCHAR2
4620 ,p_calculate_g_l_flag IN VARCHAR2
4621 ,p_actual_flag IN OUT VARCHAR2
4622 ,p_balance_type_code OUT VARCHAR2
4623 ,p_gain_or_loss_ref OUT VARCHAR2
4624
4625 --Account Name
4626 , p_source_4 IN VARCHAR2
4627 , p_source_4_meaning IN VARCHAR2
4628 --Code Combination ID
4629 , p_source_6 IN NUMBER
4630 --Distribution Line Type
4631 , p_source_7 IN VARCHAR2
4632 --Account Type
4633 , p_source_8 IN VARCHAR2
4634 , p_source_8_meaning IN VARCHAR2
4635 --EVENT_TYPE
4636 , p_source_9 IN VARCHAR2
4637 , p_source_9_meaning IN VARCHAR2
4638 --Disbursement Number
4639 , p_source_10 IN NUMBER
4640 --FUNDS_RESERVED_FLAG
4641 , p_source_11 IN VARCHAR2
4642 --Distribution ID
4643 , p_source_12 IN NUMBER
4644 --Distribution Type
4645 , p_source_13 IN VARCHAR2
4646 , p_source_13_meaning IN VARCHAR2
4647 --Distribution Amount
4648 , p_source_14 IN NUMBER
4649 --Currency
4650 , p_source_15 IN VARCHAR2
4651 , p_source_15_meaning IN VARCHAR2
4652 --EXCHANGE_DATE
4653 , p_source_16 IN DATE
4654 --EXCHANGE_RATE
4655 , p_source_17 IN NUMBER
4656 --EXCHANGE_RATE_TYPE
4657 , p_source_18 IN VARCHAR2
4658 )
4659 IS
4660
4661 l_component_type VARCHAR2(80);
4662 l_component_code VARCHAR2(30);
4663 l_component_type_code VARCHAR2(1);
4664 l_component_appl_id INTEGER;
4665 l_amb_context_code VARCHAR2(30);
4666 l_entity_code VARCHAR2(30);
4667 l_event_class_code VARCHAR2(30);
4668 l_ae_header_id NUMBER;
4669 l_event_type_code VARCHAR2(30);
4670 l_line_definition_code VARCHAR2(30);
4671 l_line_definition_owner_code VARCHAR2(1);
4672 --
4673 -- adr variables
4674 l_segment VARCHAR2(30);
4675 l_ccid NUMBER;
4676 l_adr_transaction_coa_id NUMBER;
4677 l_adr_accounting_coa_id NUMBER;
4678 l_adr_flexfield_segment_code VARCHAR2(30);
4679 l_adr_flex_value_set_id NUMBER;
4680 l_adr_value_type_code VARCHAR2(30);
4681 l_adr_value_combination_id NUMBER;
4682 l_adr_value_segment_code VARCHAR2(30);
4683
4684 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
4685 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
4686 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
4687 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
4688
4689 -- 4262811 Variables ------------------------------------------------------------------------------------------
4690 l_entered_amt_idx NUMBER;
4691 l_accted_amt_idx NUMBER;
4692 l_acc_rev_flag VARCHAR2(1);
4693 l_accrual_line_num NUMBER;
4694 l_tmp_amt NUMBER;
4695 l_acc_rev_natural_side_code VARCHAR2(1);
4696
4697 l_num_entries NUMBER;
4698 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
4699 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
4700 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
4701 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
4702 l_recog_line_1 NUMBER;
4703 l_recog_line_2 NUMBER;
4704
4705 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
4706 l_bflow_applied_to_amt NUMBER; -- 5132302
4707 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
4708
4709 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
4710
4711 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
4712 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
4713
4714 ---------------------------------------------------------------------------------------------------------------
4715
4716
4717 --
4718 -- bulk performance
4719 --
4720 l_balance_type_code VARCHAR2(1);
4724 --
4721 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
4722 l_log_module VARCHAR2(240);
4723
4725 -- Upgrade strategy
4726 --
4727 l_actual_upg_option VARCHAR2(1);
4728 l_enc_upg_option VARCHAR2(1);
4729
4730 --
4731 BEGIN
4732 --
4733 IF g_log_enabled THEN
4734 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_13';
4735 END IF;
4736 --
4737 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4738
4739 trace
4740 (p_msg => 'BEGIN of AcctLineType_13'
4741 ,p_level => C_LEVEL_PROCEDURE
4742 ,p_module => l_log_module);
4743
4744 END IF;
4745 --
4746 l_component_type := 'AMB_JLT';
4747 l_component_code := 'USSGL_TC_B204_FIN_ACCT_4801';
4748 l_component_type_code := 'S';
4749 l_component_appl_id := 206;
4750 l_amb_context_code := 'DEFAULT';
4751 l_entity_code := 'LOANS';
4752 l_event_class_code := 'DIRECT';
4753 l_event_type_code := 'DIRECT_LOAN_APPROVED';
4754 l_line_definition_owner_code := 'S';
4755 l_line_definition_code := 'FED_LNS_APPROVAL';
4756 --
4757 l_balance_type_code := 'A';
4758 l_segment := NULL;
4759 l_ccid := NULL;
4760 l_adr_transaction_coa_id := NULL;
4761 l_adr_accounting_coa_id := NULL;
4762 l_adr_flexfield_segment_code := NULL;
4763 l_adr_flex_value_set_id := NULL;
4764 l_adr_value_type_code := NULL;
4765 l_adr_value_combination_id := NULL;
4766 l_adr_value_segment_code := NULL;
4767
4768 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
4769 l_bflow_class_code := ''; -- 4219869 Business Flow
4770 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
4771 l_budgetary_control_flag := 'Y';
4772
4773 l_bflow_applied_to_amt_idx := NULL; -- 5132302
4774 l_bflow_applied_to_amt := NULL; -- 5132302
4775 l_entered_amt_idx := NULL; -- 4262811
4776 l_accted_amt_idx := NULL; -- 4262811
4777 l_acc_rev_flag := NULL; -- 4262811
4778 l_accrual_line_num := NULL; -- 4262811
4779 l_tmp_amt := NULL; -- 4262811
4780 --
4781
4782 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
4783 l_balance_type_code <> 'B' THEN
4784 IF NVL(p_source_7,'
4785 ') <> 'SUBSIDY' AND
4786 NVL(p_source_8,'
4787 ') = 'CR' AND
4788 ((NVL(p_source_9,'
4789 ') = 'DIRECT_LOAN_APPROVED') OR
4790 (NVL(p_source_9,'
4791 ') = 'DISBURSEMENT_FUNDED' AND
4792 NVL(p_source_10,9E125) = 1 AND
4793 NVL(p_source_11,'
4794 ') = 'N')
4795 ) THEN
4796
4797 --
4798 XLA_AE_LINES_PKG.SetNewLine;
4799
4800 p_balance_type_code := l_balance_type_code;
4801 -- set the flag so later we will know whether the gain loss line needs to be created
4802
4803 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
4804 p_actual_flag :='A';
4805 END IF;
4806
4807 --
4808 -- bulk performance
4809 --
4810 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
4811 p_header_num => 0); -- 4262811
4812 --
4813 -- set accounting line options
4814 --
4815 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
4816 p_natural_side_code => 'C'
4817 , p_gain_or_loss_flag => 'N'
4818 , p_gl_transfer_mode_code => 'D'
4819 , p_acct_entry_type_code => 'A'
4820 , p_switch_side_flag => 'N'
4821 , p_merge_duplicate_code => 'N'
4822 );
4823 --
4824 l_acc_rev_natural_side_code := 'D'; -- 4262811
4825 --
4826 --
4827 -- set accounting line type info
4828 --
4829 xla_ae_lines_pkg.SetAcctLineType
4830 (p_component_type => l_component_type
4831 ,p_event_type_code => l_event_type_code
4832 ,p_line_definition_owner_code => l_line_definition_owner_code
4833 ,p_line_definition_code => l_line_definition_code
4834 ,p_accounting_line_code => l_component_code
4835 ,p_accounting_line_type_code => l_component_type_code
4836 ,p_accounting_line_appl_id => l_component_appl_id
4837 ,p_amb_context_code => l_amb_context_code
4838 ,p_entity_code => l_entity_code
4839 ,p_event_class_code => l_event_class_code);
4840 --
4841 -- set accounting class
4842 --
4843 xla_ae_lines_pkg.SetAcctClass(
4844 p_accounting_class_code => 'FIN_ACT'
4845 , p_ae_header_id => l_ae_header_id
4846 );
4847
4848 --
4849 -- set rounding class
4850 --
4851 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
4852 'FIN_ACT';
4853
4854 --
4855 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
4856 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
4857 --
4858 -- bulk performance
4859 --
4860 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
4861
4865 -- 4955764
4862 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
4863 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
4864
4866 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
4867 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
4868
4869 -- 4458381 Public Sector Enh
4870
4871 --
4872 -- set accounting attributes for the line type
4873 --
4874 l_entered_amt_idx := 3;
4875 l_accted_amt_idx := 8;
4876 l_bflow_applied_to_amt_idx := NULL; -- 5132302
4877 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
4878 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_12);
4879 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
4880 l_rec_acct_attrs.array_char_value(2) := p_source_13;
4881 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
4882 l_rec_acct_attrs.array_num_value(3) := p_source_14;
4883 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
4884 l_rec_acct_attrs.array_char_value(4) := p_source_15;
4885 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
4886 l_rec_acct_attrs.array_date_value(5) := p_source_16;
4887 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
4888 l_rec_acct_attrs.array_num_value(6) := p_source_17;
4889 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
4890 l_rec_acct_attrs.array_char_value(7) := p_source_18;
4891 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
4892 l_rec_acct_attrs.array_num_value(8) := p_source_14;
4893
4894 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
4895 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
4896
4897 ---------------------------------------------------------------------------------------------------------------
4898 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
4899 ---------------------------------------------------------------------------------------------------------------
4900 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
4901
4902 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
4903 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
4904
4905 IF xla_accounting_cache_pkg.GetValueChar
4906 (p_source_code => 'LEDGER_CATEGORY_CODE'
4907 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
4908 AND l_bflow_method_code = 'PRIOR_ENTRY'
4909 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
4910 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
4911 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
4912 )
4913 THEN
4914 xla_ae_lines_pkg.BflowUpgEntry
4915 (p_business_method_code => l_bflow_method_code
4916 ,p_business_class_code => l_bflow_class_code
4917 ,p_balance_type => l_balance_type_code);
4918 ELSE
4919 NULL;
4920 -- No business flow processing for business flow method of NONE.
4921 END IF;
4922
4923 --
4924 -- call analytical criteria
4925 --
4926
4927 --
4928 -- call description
4929 --
4930
4931 xla_ae_lines_pkg.SetLineDescription(
4932 p_ae_header_id => l_ae_header_id
4933 ,p_description => Description_2 (
4934 p_application_id => p_application_id
4935 , p_ae_header_id => l_ae_header_id
4936 , p_source_4 => p_source_4
4937 , p_source_4_meaning => p_source_4_meaning
4938 )
4939 );
4940
4941
4942 --
4943 -- call ADRs
4944 -- Bug 4922099
4945 --
4946 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
4947 (NVL(l_actual_upg_option, 'N') = 'O') OR
4948 (NVL(l_enc_upg_option, 'N') = 'O')
4949 )
4950 THEN
4951 NULL;
4952 --
4953 --
4954
4955 l_ccid := AcctDerRule_4(
4956 p_application_id => p_application_id
4957 , p_ae_header_id => l_ae_header_id
4958 , p_source_6 => p_source_6
4959 , x_transaction_coa_id => l_adr_transaction_coa_id
4960 , x_accounting_coa_id => l_adr_accounting_coa_id
4961 , x_value_type_code => l_adr_value_type_code
4962 , p_side => 'NA'
4963 );
4964
4965 xla_ae_lines_pkg.set_ccid(
4966 p_code_combination_id => l_ccid
4967 , p_value_type_code => l_adr_value_type_code
4968 , p_transaction_coa_id => l_adr_transaction_coa_id
4969 , p_accounting_coa_id => l_adr_accounting_coa_id
4970 , p_adr_code => 'LNS_DIST_CCID'
4971 , p_adr_type_code => 'S'
4972 , p_component_type => l_component_type
4973 , p_component_code => l_component_code
4974 , p_component_type_code => l_component_type_code
4975 , p_component_appl_id => l_component_appl_id
4976 , p_amb_context_code => l_amb_context_code
4977 , p_side => 'NA'
4978 );
4979
4980
4981 l_segment := AcctDerRule_6(
4985 , x_accounting_coa_id => l_adr_accounting_coa_id
4982 p_application_id => p_application_id
4983 , p_ae_header_id => l_ae_header_id
4984 , x_transaction_coa_id => l_adr_transaction_coa_id
4986 , x_flexfield_segment_code => l_adr_flexfield_segment_code
4987 , x_flex_value_set_id => l_adr_flex_value_set_id
4988 , x_value_type_code => l_adr_value_type_code
4989 , x_value_combination_id => l_adr_value_combination_id
4990 , x_value_segment_code => l_adr_value_segment_code
4991 , p_side => 'NA'
4992 , p_override_seg_flag => 'Y'
4993 );
4994
4995 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
4996
4997 xla_ae_lines_pkg.set_segment(
4998 p_to_segment_code => 'GL_ACCOUNT'
4999 , p_segment_value => l_segment
5000 , p_from_segment_code => l_adr_value_segment_code
5001 , p_from_combination_id => l_adr_value_combination_id
5002 , p_value_type_code => l_adr_value_type_code
5003 , p_transaction_coa_id => l_adr_transaction_coa_id
5004 , p_accounting_coa_id => l_adr_accounting_coa_id
5005 , p_flexfield_segment_code => l_adr_flexfield_segment_code
5006 , p_flex_value_set_id => l_adr_flex_value_set_id
5007 , p_adr_code => 'USGL_ACCOUNT_480102'
5008 , p_adr_type_code => 'S'
5009 , p_component_type => l_component_type
5010 , p_component_code => l_component_code
5011 , p_component_type_code => l_component_type_code
5012 , p_component_appl_id => l_component_appl_id
5013 , p_amb_context_code => l_amb_context_code
5014 , p_entity_code => 'LOANS'
5015 , p_event_class_code => 'DIRECT'
5016 , p_side => 'NA'
5017 );
5018
5019 END IF;
5020
5021 --
5022 --
5023 END IF;
5024 --
5025 -- Bug 4922099
5026 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
5027 (NVL(l_enc_upg_option, 'N') = 'O')
5028 ) AND
5029 (l_bflow_method_code = 'PRIOR_ENTRY')
5030 )
5031 THEN
5032 IF
5033 --
5034 1 = 2
5035 --
5036 THEN
5037 xla_accounting_err_pkg.build_message
5038 (p_appli_s_name => 'XLA'
5039 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
5040 ,p_token_1 => 'LINE_NUMBER'
5041 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
5042 ,p_token_2 => 'LINE_TYPE_NAME'
5043 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
5044 l_component_type
5045 ,l_component_code
5046 ,l_component_type_code
5047 ,l_component_appl_id
5048 ,l_amb_context_code
5049 ,l_entity_code
5050 ,l_event_class_code
5051 )
5052 ,p_token_3 => 'OWNER'
5053 ,p_value_3 => xla_lookups_pkg.get_meaning(
5054 p_lookup_type => 'XLA_OWNER_TYPE'
5055 ,p_lookup_code => l_component_type_code
5056 )
5057 ,p_token_4 => 'PRODUCT_NAME'
5058 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
5059 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
5060 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
5061 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
5062 ,p_ae_header_id => NULL
5063 );
5064
5065 IF (C_LEVEL_ERROR>= g_log_level) THEN
5066 trace
5067 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
5068 ,p_level => C_LEVEL_ERROR
5069 ,p_module => l_log_module);
5070 END IF;
5071 END IF;
5072 END IF;
5073 --
5074 --
5075 ------------------------------------------------------------------------------------------------
5076 -- 4219869 Business Flow
5077 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
5078 -- Prior Entry. Currently, the following code is always generated.
5079 ------------------------------------------------------------------------------------------------
5083 -- 4219869 Business Flow
5080 XLA_AE_LINES_PKG.ValidateCurrentLine;
5081
5082 ------------------------------------------------------------------------------------
5084 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
5085 ------------------------------------------------------------------------------------
5086 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
5087
5088 ----------------------------------------------------------------------------------
5089 -- 4219869 Business Flow
5090 -- Update journal entry status -- Need to generate this within IF <condition>
5091 ----------------------------------------------------------------------------------
5092 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
5093 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
5094 ,p_balance_type_code => l_balance_type_code
5095 );
5096
5097 -------------------------------------------------------------------------------------------
5098 -- 4262811 - Generate the Accrual Reversal lines
5099 -------------------------------------------------------------------------------------------
5100 BEGIN
5101 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
5102 (g_array_event(p_event_id).array_value_num('header_index'));
5103 IF l_acc_rev_flag IS NULL THEN
5104 l_acc_rev_flag := 'N';
5105 END IF;
5106 EXCEPTION
5107 WHEN OTHERS THEN
5108 l_acc_rev_flag := 'N';
5109 END;
5110 --
5111 IF (l_acc_rev_flag = 'Y') THEN
5112
5113 -- 4645092 ------------------------------------------------------------------------------
5114 -- To allow MPA report to determine if it should generate report process
5115 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
5116 ------------------------------------------------------------------------------------------
5117
5118 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
5119 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
5120
5121 --
5122 -- Update the line information that should be overwritten
5123 --
5124 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
5125 p_header_num => 1);
5126 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
5127
5128 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
5129
5130 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
5131 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
5132 END IF;
5133
5134 --
5135 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
5136 --
5137 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
5138 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
5139 ELSE
5140 ---------------------------------------------------------------------------------------------------
5141 -- 4262811a Switch Sign
5142 ---------------------------------------------------------------------------------------------------
5143 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
5144 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
5145 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
5146 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
5147 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
5148 -- 5132302
5149 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
5150 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
5151
5152 END IF;
5153
5154 -- 4955764
5155 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
5156 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
5157
5158
5159 XLA_AE_LINES_PKG.ValidateCurrentLine;
5160 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
5161
5162 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
5163 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
5164 ,p_balance_type_code => l_balance_type_code);
5165
5166 END IF;
5167
5168 -----------------------------------------------------------------------------------------
5169 -- 4262811 Multiperiod Accounting
5170 -----------------------------------------------------------------------------------------
5171 -- No MPA option is assigned.
5172
5173
5174 END IF;
5175 END IF;
5176 --
5177
5178 --
5179 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5180 trace
5181 (p_msg => 'END of AcctLineType_13'
5182 ,p_level => C_LEVEL_PROCEDURE
5183 ,p_module => l_log_module);
5184 END IF;
5185 --
5186 EXCEPTION
5187 WHEN xla_exceptions_pkg.application_exception THEN
5188 RAISE;
5189 WHEN OTHERS THEN
5190 xla_exceptions_pkg.raise_message
5194
5191 (p_location => 'XLA_00206_AAD_S_000004_BC_PKG.AcctLineType_13');
5192 END AcctLineType_13;
5193 --
5195 ---------------------------------------
5196 --
5197 -- PRIVATE FUNCTION
5198 -- AcctLineType_14
5199 --
5200 ---------------------------------------
5201 PROCEDURE AcctLineType_14 (
5202 p_application_id IN NUMBER
5203 ,p_event_id IN NUMBER
5204 ,p_calculate_acctd_flag IN VARCHAR2
5205 ,p_calculate_g_l_flag IN VARCHAR2
5206 ,p_actual_flag IN OUT VARCHAR2
5207 ,p_balance_type_code OUT VARCHAR2
5208 ,p_gain_or_loss_ref OUT VARCHAR2
5209
5210 --Account Name
5211 , p_source_4 IN VARCHAR2
5212 , p_source_4_meaning IN VARCHAR2
5213 --Code Combination ID
5214 , p_source_6 IN NUMBER
5215 --Distribution Line Type
5216 , p_source_7 IN VARCHAR2
5217 --Account Type
5218 , p_source_8 IN VARCHAR2
5219 , p_source_8_meaning IN VARCHAR2
5220 --EVENT_TYPE
5221 , p_source_9 IN VARCHAR2
5222 , p_source_9_meaning IN VARCHAR2
5223 --Distribution ID
5224 , p_source_12 IN NUMBER
5225 --Distribution Type
5226 , p_source_13 IN VARCHAR2
5227 , p_source_13_meaning IN VARCHAR2
5228 --Distribution Amount
5229 , p_source_14 IN NUMBER
5230 --Currency
5231 , p_source_15 IN VARCHAR2
5232 , p_source_15_meaning IN VARCHAR2
5233 --EXCHANGE_DATE
5234 , p_source_16 IN DATE
5235 --EXCHANGE_RATE
5236 , p_source_17 IN NUMBER
5237 --EXCHANGE_RATE_TYPE
5238 , p_source_18 IN VARCHAR2
5239 --Subsidy Cost
5240 , p_source_19 IN NUMBER
5241 )
5242 IS
5243
5244 l_component_type VARCHAR2(80);
5245 l_component_code VARCHAR2(30);
5246 l_component_type_code VARCHAR2(1);
5247 l_component_appl_id INTEGER;
5248 l_amb_context_code VARCHAR2(30);
5249 l_entity_code VARCHAR2(30);
5250 l_event_class_code VARCHAR2(30);
5251 l_ae_header_id NUMBER;
5252 l_event_type_code VARCHAR2(30);
5253 l_line_definition_code VARCHAR2(30);
5254 l_line_definition_owner_code VARCHAR2(1);
5255 --
5256 -- adr variables
5257 l_segment VARCHAR2(30);
5258 l_ccid NUMBER;
5259 l_adr_transaction_coa_id NUMBER;
5260 l_adr_accounting_coa_id NUMBER;
5261 l_adr_flexfield_segment_code VARCHAR2(30);
5262 l_adr_flex_value_set_id NUMBER;
5263 l_adr_value_type_code VARCHAR2(30);
5264 l_adr_value_combination_id NUMBER;
5265 l_adr_value_segment_code VARCHAR2(30);
5266
5267 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
5268 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
5269 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
5270 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
5271
5272 -- 4262811 Variables ------------------------------------------------------------------------------------------
5273 l_entered_amt_idx NUMBER;
5274 l_accted_amt_idx NUMBER;
5275 l_acc_rev_flag VARCHAR2(1);
5276 l_accrual_line_num NUMBER;
5277 l_tmp_amt NUMBER;
5278 l_acc_rev_natural_side_code VARCHAR2(1);
5279
5280 l_num_entries NUMBER;
5281 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
5282 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
5283 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
5284 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
5285 l_recog_line_1 NUMBER;
5286 l_recog_line_2 NUMBER;
5287
5288 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
5289 l_bflow_applied_to_amt NUMBER; -- 5132302
5290 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
5291
5292 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
5293
5294 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
5295 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
5296
5297 ---------------------------------------------------------------------------------------------------------------
5298
5299
5300 --
5301 -- bulk performance
5302 --
5303 l_balance_type_code VARCHAR2(1);
5304 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
5305 l_log_module VARCHAR2(240);
5306
5307 --
5308 -- Upgrade strategy
5309 --
5310 l_actual_upg_option VARCHAR2(1);
5311 l_enc_upg_option VARCHAR2(1);
5312
5313 --
5314 BEGIN
5315 --
5316 IF g_log_enabled THEN
5317 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_14';
5318 END IF;
5319 --
5320 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5321
5322 trace
5323 (p_msg => 'BEGIN of AcctLineType_14'
5324 ,p_level => C_LEVEL_PROCEDURE
5325 ,p_module => l_log_module);
5326
5327 END IF;
5328 --
5329 l_component_type := 'AMB_JLT';
5330 l_component_code := 'USSGL_TC_B204_FIN_ACCT_4801_C';
5334 l_entity_code := 'LOANS';
5331 l_component_type_code := 'S';
5332 l_component_appl_id := 206;
5333 l_amb_context_code := 'DEFAULT';
5335 l_event_class_code := 'DIRECT';
5336 l_event_type_code := 'FUTURE_DISBURSEMENT_CANCELLED';
5337 l_line_definition_owner_code := 'S';
5338 l_line_definition_code := 'FED_LNS_CANCEL';
5339 --
5340 l_balance_type_code := 'A';
5341 l_segment := NULL;
5342 l_ccid := NULL;
5343 l_adr_transaction_coa_id := NULL;
5344 l_adr_accounting_coa_id := NULL;
5345 l_adr_flexfield_segment_code := NULL;
5346 l_adr_flex_value_set_id := NULL;
5347 l_adr_value_type_code := NULL;
5348 l_adr_value_combination_id := NULL;
5349 l_adr_value_segment_code := NULL;
5350
5351 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
5352 l_bflow_class_code := ''; -- 4219869 Business Flow
5353 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
5354 l_budgetary_control_flag := 'Y';
5355
5356 l_bflow_applied_to_amt_idx := NULL; -- 5132302
5357 l_bflow_applied_to_amt := NULL; -- 5132302
5358 l_entered_amt_idx := NULL; -- 4262811
5359 l_accted_amt_idx := NULL; -- 4262811
5360 l_acc_rev_flag := NULL; -- 4262811
5361 l_accrual_line_num := NULL; -- 4262811
5362 l_tmp_amt := NULL; -- 4262811
5363 --
5364
5365 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
5366 l_balance_type_code <> 'B' THEN
5367 IF NVL(p_source_7,'
5368 ') <> 'SUBSIDY' AND
5369 NVL(p_source_8,'
5370 ') = 'DR' AND
5371 NVL(p_source_9,'
5372 ') = 'FUTURE_DISBURSEMENT_CANCELLED'
5373 THEN
5374
5375 --
5376 XLA_AE_LINES_PKG.SetNewLine;
5377
5378 p_balance_type_code := l_balance_type_code;
5379 -- set the flag so later we will know whether the gain loss line needs to be created
5380
5381 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
5382 p_actual_flag :='A';
5383 END IF;
5384
5385 --
5386 -- bulk performance
5387 --
5388 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
5389 p_header_num => 0); -- 4262811
5390 --
5391 -- set accounting line options
5392 --
5393 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
5394 p_natural_side_code => 'D'
5395 , p_gain_or_loss_flag => 'N'
5396 , p_gl_transfer_mode_code => 'S'
5397 , p_acct_entry_type_code => 'A'
5398 , p_switch_side_flag => 'N'
5399 , p_merge_duplicate_code => 'N'
5400 );
5401 --
5402 l_acc_rev_natural_side_code := 'C'; -- 4262811
5403 --
5404 --
5405 -- set accounting line type info
5406 --
5407 xla_ae_lines_pkg.SetAcctLineType
5408 (p_component_type => l_component_type
5409 ,p_event_type_code => l_event_type_code
5410 ,p_line_definition_owner_code => l_line_definition_owner_code
5411 ,p_line_definition_code => l_line_definition_code
5412 ,p_accounting_line_code => l_component_code
5413 ,p_accounting_line_type_code => l_component_type_code
5414 ,p_accounting_line_appl_id => l_component_appl_id
5415 ,p_amb_context_code => l_amb_context_code
5416 ,p_entity_code => l_entity_code
5417 ,p_event_class_code => l_event_class_code);
5418 --
5419 -- set accounting class
5420 --
5421 xla_ae_lines_pkg.SetAcctClass(
5422 p_accounting_class_code => 'FIN_ACT'
5423 , p_ae_header_id => l_ae_header_id
5424 );
5425
5426 --
5427 -- set rounding class
5428 --
5429 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
5430 'FIN_ACT';
5431
5432 --
5433 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
5434 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
5435 --
5436 -- bulk performance
5437 --
5438 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
5439
5440 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
5441 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
5442
5443 -- 4955764
5444 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
5445 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
5446
5447 -- 4458381 Public Sector Enh
5448
5449 --
5450 -- set accounting attributes for the line type
5451 --
5452 l_entered_amt_idx := 3;
5453 l_accted_amt_idx := 8;
5454 l_bflow_applied_to_amt_idx := NULL; -- 5132302
5455 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
5456 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_12);
5457 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
5458 l_rec_acct_attrs.array_char_value(2) := p_source_13;
5459 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
5460 l_rec_acct_attrs.array_num_value(3) := p_source_14;
5464 l_rec_acct_attrs.array_date_value(5) := p_source_16;
5461 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
5462 l_rec_acct_attrs.array_char_value(4) := p_source_15;
5463 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
5465 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
5466 l_rec_acct_attrs.array_num_value(6) := p_source_17;
5467 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
5468 l_rec_acct_attrs.array_char_value(7) := p_source_18;
5469 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
5470 l_rec_acct_attrs.array_num_value(8) := p_source_19;
5471
5472 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
5473 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
5474
5475 ---------------------------------------------------------------------------------------------------------------
5476 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
5477 ---------------------------------------------------------------------------------------------------------------
5478 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
5479
5480 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
5481 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
5482
5483 IF xla_accounting_cache_pkg.GetValueChar
5484 (p_source_code => 'LEDGER_CATEGORY_CODE'
5485 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
5486 AND l_bflow_method_code = 'PRIOR_ENTRY'
5487 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
5488 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
5489 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
5490 )
5491 THEN
5492 xla_ae_lines_pkg.BflowUpgEntry
5493 (p_business_method_code => l_bflow_method_code
5494 ,p_business_class_code => l_bflow_class_code
5495 ,p_balance_type => l_balance_type_code);
5496 ELSE
5497 NULL;
5498 -- No business flow processing for business flow method of NONE.
5499 END IF;
5500
5501 --
5502 -- call analytical criteria
5503 --
5504
5505 --
5506 -- call description
5507 --
5508
5509 xla_ae_lines_pkg.SetLineDescription(
5510 p_ae_header_id => l_ae_header_id
5511 ,p_description => Description_2 (
5512 p_application_id => p_application_id
5513 , p_ae_header_id => l_ae_header_id
5514 , p_source_4 => p_source_4
5515 , p_source_4_meaning => p_source_4_meaning
5516 )
5517 );
5518
5519
5520 --
5521 -- call ADRs
5522 -- Bug 4922099
5523 --
5524 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
5525 (NVL(l_actual_upg_option, 'N') = 'O') OR
5526 (NVL(l_enc_upg_option, 'N') = 'O')
5527 )
5528 THEN
5529 NULL;
5530 --
5531 --
5532
5533 l_ccid := AcctDerRule_4(
5534 p_application_id => p_application_id
5535 , p_ae_header_id => l_ae_header_id
5536 , p_source_6 => p_source_6
5537 , x_transaction_coa_id => l_adr_transaction_coa_id
5538 , x_accounting_coa_id => l_adr_accounting_coa_id
5539 , x_value_type_code => l_adr_value_type_code
5540 , p_side => 'NA'
5541 );
5542
5543 xla_ae_lines_pkg.set_ccid(
5544 p_code_combination_id => l_ccid
5545 , p_value_type_code => l_adr_value_type_code
5546 , p_transaction_coa_id => l_adr_transaction_coa_id
5547 , p_accounting_coa_id => l_adr_accounting_coa_id
5548 , p_adr_code => 'LNS_DIST_CCID'
5549 , p_adr_type_code => 'S'
5550 , p_component_type => l_component_type
5551 , p_component_code => l_component_code
5552 , p_component_type_code => l_component_type_code
5553 , p_component_appl_id => l_component_appl_id
5554 , p_amb_context_code => l_amb_context_code
5555 , p_side => 'NA'
5556 );
5557
5558
5559 l_segment := AcctDerRule_6(
5560 p_application_id => p_application_id
5561 , p_ae_header_id => l_ae_header_id
5562 , x_transaction_coa_id => l_adr_transaction_coa_id
5563 , x_accounting_coa_id => l_adr_accounting_coa_id
5564 , x_flexfield_segment_code => l_adr_flexfield_segment_code
5565 , x_flex_value_set_id => l_adr_flex_value_set_id
5566 , x_value_type_code => l_adr_value_type_code
5567 , x_value_combination_id => l_adr_value_combination_id
5568 , x_value_segment_code => l_adr_value_segment_code
5569 , p_side => 'NA'
5570 , p_override_seg_flag => 'Y'
5571 );
5572
5573 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
5574
5575 xla_ae_lines_pkg.set_segment(
5576 p_to_segment_code => 'GL_ACCOUNT'
5577 , p_segment_value => l_segment
5578 , p_from_segment_code => l_adr_value_segment_code
5579 , p_from_combination_id => l_adr_value_combination_id
5583 , p_flexfield_segment_code => l_adr_flexfield_segment_code
5580 , p_value_type_code => l_adr_value_type_code
5581 , p_transaction_coa_id => l_adr_transaction_coa_id
5582 , p_accounting_coa_id => l_adr_accounting_coa_id
5584 , p_flex_value_set_id => l_adr_flex_value_set_id
5585 , p_adr_code => 'USGL_ACCOUNT_480102'
5586 , p_adr_type_code => 'S'
5587 , p_component_type => l_component_type
5588 , p_component_code => l_component_code
5589 , p_component_type_code => l_component_type_code
5590 , p_component_appl_id => l_component_appl_id
5591 , p_amb_context_code => l_amb_context_code
5592 , p_entity_code => 'LOANS'
5593 , p_event_class_code => 'DIRECT'
5594 , p_side => 'NA'
5595 );
5596
5597 END IF;
5598
5599 --
5600 --
5601 END IF;
5602 --
5603 -- Bug 4922099
5604 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
5605 (NVL(l_enc_upg_option, 'N') = 'O')
5606 ) AND
5607 (l_bflow_method_code = 'PRIOR_ENTRY')
5608 )
5609 THEN
5610 IF
5611 --
5612 1 = 2
5613 --
5614 THEN
5615 xla_accounting_err_pkg.build_message
5616 (p_appli_s_name => 'XLA'
5617 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
5618 ,p_token_1 => 'LINE_NUMBER'
5619 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
5620 ,p_token_2 => 'LINE_TYPE_NAME'
5621 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
5622 l_component_type
5623 ,l_component_code
5624 ,l_component_type_code
5625 ,l_component_appl_id
5626 ,l_amb_context_code
5627 ,l_entity_code
5628 ,l_event_class_code
5629 )
5630 ,p_token_3 => 'OWNER'
5631 ,p_value_3 => xla_lookups_pkg.get_meaning(
5632 p_lookup_type => 'XLA_OWNER_TYPE'
5633 ,p_lookup_code => l_component_type_code
5634 )
5635 ,p_token_4 => 'PRODUCT_NAME'
5636 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
5637 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
5638 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
5639 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
5640 ,p_ae_header_id => NULL
5641 );
5642
5643 IF (C_LEVEL_ERROR>= g_log_level) THEN
5644 trace
5645 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
5646 ,p_level => C_LEVEL_ERROR
5647 ,p_module => l_log_module);
5648 END IF;
5649 END IF;
5650 END IF;
5651 --
5652 --
5653 ------------------------------------------------------------------------------------------------
5654 -- 4219869 Business Flow
5655 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
5656 -- Prior Entry. Currently, the following code is always generated.
5657 ------------------------------------------------------------------------------------------------
5658 XLA_AE_LINES_PKG.ValidateCurrentLine;
5659
5660 ------------------------------------------------------------------------------------
5661 -- 4219869 Business Flow
5662 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
5663 ------------------------------------------------------------------------------------
5664 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
5665
5666 ----------------------------------------------------------------------------------
5667 -- 4219869 Business Flow
5668 -- Update journal entry status -- Need to generate this within IF <condition>
5669 ----------------------------------------------------------------------------------
5670 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
5671 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
5672 ,p_balance_type_code => l_balance_type_code
5673 );
5674
5675 -------------------------------------------------------------------------------------------
5676 -- 4262811 - Generate the Accrual Reversal lines
5680 (g_array_event(p_event_id).array_value_num('header_index'));
5677 -------------------------------------------------------------------------------------------
5678 BEGIN
5679 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
5681 IF l_acc_rev_flag IS NULL THEN
5682 l_acc_rev_flag := 'N';
5683 END IF;
5684 EXCEPTION
5685 WHEN OTHERS THEN
5686 l_acc_rev_flag := 'N';
5687 END;
5688 --
5689 IF (l_acc_rev_flag = 'Y') THEN
5690
5691 -- 4645092 ------------------------------------------------------------------------------
5692 -- To allow MPA report to determine if it should generate report process
5693 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
5694 ------------------------------------------------------------------------------------------
5695
5696 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
5697 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
5698
5699 --
5700 -- Update the line information that should be overwritten
5701 --
5702 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
5703 p_header_num => 1);
5704 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
5705
5706 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
5707
5708 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
5709 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
5710 END IF;
5711
5712 --
5713 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
5714 --
5715 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
5716 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
5717 ELSE
5718 ---------------------------------------------------------------------------------------------------
5719 -- 4262811a Switch Sign
5720 ---------------------------------------------------------------------------------------------------
5721 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
5722 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
5723 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
5724 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
5725 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
5726 -- 5132302
5727 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
5728 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
5729
5730 END IF;
5731
5732 -- 4955764
5733 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
5734 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
5735
5736
5737 XLA_AE_LINES_PKG.ValidateCurrentLine;
5738 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
5739
5740 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
5741 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
5742 ,p_balance_type_code => l_balance_type_code);
5743
5744 END IF;
5745
5746 -----------------------------------------------------------------------------------------
5747 -- 4262811 Multiperiod Accounting
5748 -----------------------------------------------------------------------------------------
5749 -- No MPA option is assigned.
5750
5751
5752 END IF;
5753 END IF;
5754 --
5755
5756 --
5757 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5758 trace
5759 (p_msg => 'END of AcctLineType_14'
5760 ,p_level => C_LEVEL_PROCEDURE
5761 ,p_module => l_log_module);
5762 END IF;
5763 --
5764 EXCEPTION
5765 WHEN xla_exceptions_pkg.application_exception THEN
5766 RAISE;
5767 WHEN OTHERS THEN
5768 xla_exceptions_pkg.raise_message
5769 (p_location => 'XLA_00206_AAD_S_000004_BC_PKG.AcctLineType_14');
5770 END AcctLineType_14;
5771 --
5772
5773 ---------------------------------------
5774 --
5775 -- PRIVATE PROCEDURE
5776 -- insert_sources_15
5777 --
5778 ----------------------------------------
5779 --
5780 PROCEDURE insert_sources_15(
5781 p_target_ledger_id IN NUMBER
5782 , p_language IN VARCHAR2
5783 , p_sla_ledger_id IN NUMBER
5784 , p_pad_start_date IN DATE
5785 , p_pad_end_date IN DATE
5786 )
5787 IS
5788
5789 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'DIRECT_LOAN_APPROVED';
5790 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'DIRECT';
5791 p_apps_owner VARCHAR2(30);
5792 l_log_module VARCHAR2(240);
5793 BEGIN
5794 IF g_log_enabled THEN
5798
5795 l_log_module := C_DEFAULT_MODULE||'.insert_sources_15';
5796 END IF;
5797 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5799 trace
5800 (p_msg => 'BEGIN of insert_sources_15'
5801 ,p_level => C_LEVEL_PROCEDURE
5802 ,p_module => l_log_module);
5803
5804 END IF;
5805
5806 -- select APPS owner
5807 SELECT oracle_username
5808 INTO p_apps_owner
5809 FROM fnd_oracle_userid
5810 WHERE read_only_flag = 'U'
5811 ;
5812
5813 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5814 trace
5815 (p_msg => 'p_target_ledger_id = '||p_target_ledger_id||
5816 ' - p_language = '||p_language||
5817 ' - p_sla_ledger_id = '||p_sla_ledger_id ||
5818 ' - p_pad_start_date = '||TO_CHAR(p_pad_start_date)||
5819 ' - p_pad_end_date = '||TO_CHAR(p_pad_end_date)||
5820 ' - p_apps_owner = '||TO_CHAR(p_apps_owner)
5821 ,p_level => C_LEVEL_STATEMENT
5822 ,p_module => l_log_module);
5823 END IF;
5824
5825
5826 --
5827 INSERT INTO xla_diag_sources --hdr1
5828 (
5829 event_id
5830 , ledger_id
5831 , sla_ledger_id
5832 , description_language
5833 , object_name
5834 , object_type_code
5835 , line_number
5836 , source_application_id
5837 , source_type_code
5838 , source_code
5839 , source_value
5840 , source_meaning
5841 , created_by
5842 , creation_date
5843 , last_update_date
5844 , last_updated_by
5845 , last_update_login
5846 , program_update_date
5847 , program_application_id
5848 , program_id
5849 , request_id
5850 )
5851 SELECT
5852 event_id
5853 , p_target_ledger_id
5854 , p_sla_ledger_id
5855 , p_language
5856 , object_name
5857 , object_type_code
5858 , line_number
5859 , source_application_id
5860 , source_type_code
5861 , source_code
5862 , SUBSTR(source_value ,1,1996)
5863 , SUBSTR(source_meaning,1,200)
5864 , xla_environment_pkg.g_Usr_Id
5865 , TRUNC(SYSDATE)
5866 , TRUNC(SYSDATE)
5867 , xla_environment_pkg.g_Usr_Id
5868 , xla_environment_pkg.g_Login_Id
5869 , TRUNC(SYSDATE)
5870 , xla_environment_pkg.g_Prog_Appl_Id
5871 , xla_environment_pkg.g_Prog_Id
5872 , xla_environment_pkg.g_Req_Id
5873 FROM (
5874 SELECT xet.event_id event_id
5875 , 0 line_number
5876 , CASE r
5877 WHEN 1 THEN 'LNS_LOAN_HEADERS_EXT_V'
5878 WHEN 2 THEN 'LNS_LOAN_HEADERS_EXT_V'
5879 WHEN 3 THEN 'LNS_LOAN_HEADERS_EXT_V'
5880 WHEN 4 THEN 'LNS_LOAN_HEADERS_EXT_V'
5881 WHEN 5 THEN 'LNS_LOAN_HEADERS_EXT_V'
5882 WHEN 6 THEN 'LNS_LOAN_HEADERS_EXT_V'
5883 WHEN 7 THEN 'LNS_LOAN_HEADERS_EXT_V'
5884 WHEN 8 THEN 'LNS_LOAN_HEADERS_EXT_V'
5885 WHEN 9 THEN 'LNS_LOAN_HEADERS_EXT_V'
5886
5887 ELSE null
5888 END object_name
5889 , CASE r
5890 WHEN 1 THEN 'HEADER'
5891 WHEN 2 THEN 'HEADER'
5892 WHEN 3 THEN 'HEADER'
5893 WHEN 4 THEN 'HEADER'
5894 WHEN 5 THEN 'HEADER'
5895 WHEN 6 THEN 'HEADER'
5896 WHEN 7 THEN 'HEADER'
5897 WHEN 8 THEN 'HEADER'
5898 WHEN 9 THEN 'HEADER'
5899
5900 ELSE null
5901 END object_type_code
5902 , CASE r
5903 WHEN 1 THEN '206'
5904 WHEN 2 THEN '206'
5905 WHEN 3 THEN '206'
5906 WHEN 4 THEN '206'
5907 WHEN 5 THEN '206'
5908 WHEN 6 THEN '206'
5909 WHEN 7 THEN '206'
5910 WHEN 8 THEN '206'
5911 WHEN 9 THEN '206'
5912
5913 ELSE null
5914 END source_application_id
5915 , 'S' source_type_code
5916 , CASE r
5917 WHEN 1 THEN 'LOAN_CLASS_CODE'
5918 WHEN 2 THEN 'LOAN_TYPE'
5919 WHEN 3 THEN 'LOAN_NUMBER'
5920 WHEN 4 THEN 'FUNDS_RESERVED_FLAG'
5921 WHEN 5 THEN 'LOAN_CURRENCY'
5922 WHEN 6 THEN 'EXCHANGE_DATE'
5923 WHEN 7 THEN 'EXCHANGE_RATE'
5924 WHEN 8 THEN 'EXCHANGE_RATE_TYPE'
5925 WHEN 9 THEN 'GL_DATE'
5926
5927 ELSE null
5928 END source_code
5929 , CASE r
5930 WHEN 1 THEN TO_CHAR(h2.LOAN_CLASS_CODE)
5931 WHEN 2 THEN TO_CHAR(h2.LOAN_TYPE)
5932 WHEN 3 THEN TO_CHAR(h2.LOAN_NUMBER)
5933 WHEN 4 THEN TO_CHAR(h2.FUNDS_RESERVED_FLAG)
5934 WHEN 5 THEN TO_CHAR(h2.LOAN_CURRENCY)
5935 WHEN 6 THEN TO_CHAR(h2.EXCHANGE_DATE)
5939
5936 WHEN 7 THEN TO_CHAR(h2.EXCHANGE_RATE)
5937 WHEN 8 THEN TO_CHAR(h2.EXCHANGE_RATE_TYPE)
5938 WHEN 9 THEN TO_CHAR(h2.GL_DATE)
5940 ELSE null
5941 END source_value
5942 , CASE r
5943 WHEN 1 THEN fvl1.meaning
5944 WHEN 5 THEN fvl15.meaning
5945
5946 ELSE null
5947 END source_meaning
5948 FROM xla_events_gt xet
5949 , LNS_LOAN_HEADERS_EXT_V h2
5950 , fnd_lookup_values fvl1
5951 , fnd_lookup_values fvl15
5952 ,(select rownum r from all_objects where rownum <= 9 and owner = p_apps_owner)
5953 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
5954 AND xet.event_type_code = C_EVENT_TYPE_CODE
5955 AND h2.event_id = xet.event_id
5956 AND fvl1.lookup_type(+) = 'LOAN_CLASS'
5957 AND fvl1.lookup_code(+) = h2.LOAN_CLASS_CODE
5958 AND fvl1.view_application_id(+) = 206
5959 AND fvl1.language(+) = USERENV('LANG')
5960 AND fvl15.lookup_type(+) = 'CURRENCY_CODE'
5961 AND fvl15.lookup_code(+) = h2.LOAN_CURRENCY
5962 AND fvl15.view_application_id(+) = 101
5963 AND fvl15.language(+) = USERENV('LANG')
5964
5965 )
5966 ;
5967 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5968
5969 trace
5970 (p_msg => 'number of header sources inserted = '||SQL%ROWCOUNT
5971 ,p_level => C_LEVEL_STATEMENT
5972 ,p_module => l_log_module);
5973
5974 END IF;
5975 --
5976
5977
5978
5979 --
5980 INSERT INTO xla_diag_sources --line1
5981 (
5982 event_id
5983 , ledger_id
5984 , sla_ledger_id
5985 , description_language
5986 , object_name
5987 , object_type_code
5988 , line_number
5989 , source_application_id
5990 , source_type_code
5991 , source_code
5992 , source_value
5993 , source_meaning
5994 , created_by
5995 , creation_date
5996 , last_update_date
5997 , last_updated_by
5998 , last_update_login
5999 , program_update_date
6000 , program_application_id
6001 , program_id
6002 , request_id
6003 )
6004 SELECT event_id
6005 , p_target_ledger_id
6006 , p_sla_ledger_id
6007 , p_language
6008 , object_name
6009 , object_type_code
6010 , line_number
6011 , source_application_id
6012 , source_type_code
6013 , source_code
6014 , SUBSTR(source_value,1,1996)
6015 , SUBSTR(source_meaning,1,200)
6016 , xla_environment_pkg.g_Usr_Id
6017 , TRUNC(SYSDATE)
6018 , TRUNC(SYSDATE)
6019 , xla_environment_pkg.g_Usr_Id
6020 , xla_environment_pkg.g_Login_Id
6021 , TRUNC(SYSDATE)
6022 , xla_environment_pkg.g_Prog_Appl_Id
6023 , xla_environment_pkg.g_Prog_Id
6024 , xla_environment_pkg.g_Req_Id
6025 FROM (
6026 SELECT xet.event_id event_id
6027 , l1.line_number line_number
6028 , CASE r
6029 WHEN 1 THEN 'LNS_LOAN_DETAILS_EXT_V'
6030 WHEN 2 THEN 'LNS_LOAN_DETAILS_EXT_V'
6031 WHEN 3 THEN 'LNS_LOAN_DETAILS_EXT_V'
6032 WHEN 4 THEN 'LNS_LOAN_DETAILS_EXT_V'
6033 WHEN 5 THEN 'LNS_LOAN_DETAILS_EXT_V'
6034 WHEN 6 THEN 'LNS_LOAN_DETAILS_EXT_V'
6035 WHEN 7 THEN 'LNS_LOAN_DETAILS_EXT_V'
6036 WHEN 8 THEN 'LNS_LOAN_DETAILS_EXT_V'
6037 WHEN 9 THEN 'LNS_LOAN_DETAILS_EXT_V'
6038 WHEN 10 THEN 'LNS_LOAN_DETAILS_EXT_V'
6039
6040 ELSE null
6041 END object_name
6042 , CASE r
6043 WHEN 1 THEN 'LINE'
6044 WHEN 2 THEN 'LINE'
6045 WHEN 3 THEN 'LINE'
6046 WHEN 4 THEN 'LINE'
6047 WHEN 5 THEN 'LINE'
6048 WHEN 6 THEN 'LINE'
6049 WHEN 7 THEN 'LINE'
6050 WHEN 8 THEN 'LINE'
6051 WHEN 9 THEN 'LINE'
6052 WHEN 10 THEN 'LINE'
6053
6054 ELSE null
6055 END object_type_code
6056 , CASE r
6057 WHEN 1 THEN '206'
6058 WHEN 2 THEN '206'
6059 WHEN 3 THEN '206'
6060 WHEN 4 THEN '206'
6061 WHEN 5 THEN '206'
6062 WHEN 6 THEN '206'
6063 WHEN 7 THEN '206'
6064 WHEN 8 THEN '206'
6065 WHEN 9 THEN '206'
6066 WHEN 10 THEN '206'
6067
6068 ELSE null
6069 END source_application_id
6070 , 'S' source_type_code
6071 , CASE r
6072 WHEN 1 THEN 'ACCOUNT_NAME'
6073 WHEN 2 THEN 'DERIVED_PROGRAM_ACCOUNT_BSV'
6074 WHEN 3 THEN 'CODE_COMBINATION_ID'
6075 WHEN 4 THEN 'LINE_TYPE'
6076 WHEN 5 THEN 'ACCOUNT_TYPE'
6077 WHEN 6 THEN 'EVENT_TYPE'
6078 WHEN 7 THEN 'DISBURSEMENT_NUMBER'
6082
6079 WHEN 8 THEN 'DISTRIBUTION_ID'
6080 WHEN 9 THEN 'DISTRIBUTION_TYPE'
6081 WHEN 10 THEN 'DISTRIBUTION_AMOUNT'
6083 ELSE null
6084 END source_code
6085 , CASE r
6086 WHEN 1 THEN TO_CHAR(l1.ACCOUNT_NAME)
6087 WHEN 2 THEN TO_CHAR(l1.DERIVED_PROGRAM_ACCOUNT_BSV)
6088 WHEN 3 THEN TO_CHAR(l1.CODE_COMBINATION_ID)
6089 WHEN 4 THEN TO_CHAR(l1.LINE_TYPE)
6090 WHEN 5 THEN TO_CHAR(l1.ACCOUNT_TYPE)
6091 WHEN 6 THEN TO_CHAR(l1.EVENT_TYPE)
6092 WHEN 7 THEN TO_CHAR(l1.DISBURSEMENT_NUMBER)
6093 WHEN 8 THEN TO_CHAR(l1.DISTRIBUTION_ID)
6094 WHEN 9 THEN TO_CHAR(l1.DISTRIBUTION_TYPE)
6095 WHEN 10 THEN TO_CHAR(l1.DISTRIBUTION_AMOUNT)
6096
6097 ELSE null
6098 END source_value
6099 , CASE r
6100 WHEN 1 THEN fvl4.meaning
6101 WHEN 5 THEN fvl8.meaning
6102 WHEN 6 THEN fvl9.meaning
6103 WHEN 9 THEN fvl13.meaning
6104
6105 ELSE null
6106 END source_meaning
6107 FROM xla_events_gt xet
6108 , LNS_LOAN_DETAILS_EXT_V l1
6109 , fnd_lookup_values fvl4
6110 , fnd_lookup_values fvl8
6111 , fnd_lookup_values fvl9
6112 , fnd_lookup_values fvl13
6113 ,(select rownum r from all_objects where rownum <= 10 and owner = p_apps_owner)
6114 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
6115 AND xet.event_type_code = C_EVENT_TYPE_CODE
6116 AND l1.event_id = xet.event_id
6117 AND fvl4.lookup_type(+) = 'LOAN_DISTRIBUTION_ACCOUNTS'
6118 AND fvl4.lookup_code(+) = l1.ACCOUNT_NAME
6119 AND fvl4.view_application_id(+) = 206
6120 AND fvl4.language(+) = USERENV('LANG')
6121 AND fvl8.lookup_type(+) = 'LOAN_DISTRIBUTION_ACCOUNT_DRCR'
6122 AND fvl8.lookup_code(+) = l1.ACCOUNT_TYPE
6123 AND fvl8.view_application_id(+) = 206
6124 AND fvl8.language(+) = USERENV('LANG')
6125 AND fvl9.lookup_type(+) = 'LOAN_ACCOUNTING_EVENT'
6126 AND fvl9.lookup_code(+) = l1.EVENT_TYPE
6127 AND fvl9.view_application_id(+) = 206
6128 AND fvl9.language(+) = USERENV('LANG')
6129 AND fvl13.lookup_type(+) = 'LOAN_DISTRIBUTION_ACCOUNT_DRCR'
6130 AND fvl13.lookup_code(+) = l1.DISTRIBUTION_TYPE
6131 AND fvl13.view_application_id(+) = 206
6132 AND fvl13.language(+) = USERENV('LANG')
6133
6134 )
6135 ;
6136 --
6137 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6138
6139 trace
6140 (p_msg => 'number of line sources inserted = '||SQL%ROWCOUNT
6141 ,p_level => C_LEVEL_STATEMENT
6142 ,p_module => l_log_module);
6143
6144 END IF;
6145
6146
6147 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6148 trace
6149 (p_msg => 'END of insert_sources_15'
6150 ,p_level => C_LEVEL_PROCEDURE
6151 ,p_module => l_log_module);
6152 END IF;
6153 EXCEPTION
6154 WHEN xla_exceptions_pkg.application_exception THEN
6155 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
6156 trace
6157 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
6158 ,p_level => C_LEVEL_EXCEPTION
6159 ,p_module => l_log_module);
6160 END IF;
6161 RAISE;
6162 WHEN OTHERS THEN
6163 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
6164 trace
6165 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
6166 ,p_level => C_LEVEL_EXCEPTION
6167 ,p_module => l_log_module);
6168 END IF;
6169 xla_exceptions_pkg.raise_message
6170 (p_location => 'XLA_00206_AAD_S_000004_BC_PKG.insert_sources_15');
6171 END insert_sources_15;
6172 --
6173
6174 ---------------------------------------
6175 --
6176 -- PRIVATE FUNCTION
6177 -- EventType_15
6178 --
6179 ----------------------------------------
6180 --
6181 FUNCTION EventType_15
6182 (p_application_id IN NUMBER
6183 ,p_base_ledger_id IN NUMBER
6184 ,p_target_ledger_id IN NUMBER
6185 ,p_language IN VARCHAR2
6186 ,p_currency_code IN VARCHAR2
6187 ,p_sla_ledger_id IN NUMBER
6188 ,p_pad_start_date IN DATE
6189 ,p_pad_end_date IN DATE
6190 ,p_primary_ledger_id IN NUMBER)
6191 RETURN BOOLEAN IS
6192 --
6193 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'DIRECT_LOAN_APPROVED';
6194 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'DIRECT';
6195
6196 l_calculate_acctd_flag VARCHAR2(1) :='Y';
6197 l_calculate_g_l_flag VARCHAR2(1) :='Y';
6198 --
6199 l_array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
6200 l_array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
6201 l_array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
6202 l_array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
6203 l_array_event_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
6207 l_array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
6204 l_array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
6205 l_array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
6206 l_array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
6208 l_array_transaction_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
6209 l_array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
6210 l_array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
6211 l_array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
6212 l_array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
6213 l_array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
6214 l_array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
6215 l_array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
6216 l_array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
6217 l_array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
6218 l_array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
6219 l_array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
6220 l_array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
6221 l_array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L;
6222 l_array_budgetary_control_flag XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
6223
6224 l_event_id NUMBER;
6225 l_previous_event_id NUMBER;
6226 l_first_event_id NUMBER;
6227 l_last_event_id NUMBER;
6228
6229 l_rec_acct_attrs XLA_AE_HEADER_PKG.t_rec_acct_attrs;
6230 l_rec_rev_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
6231 --
6232 --
6233 l_result BOOLEAN := TRUE;
6234 l_rows NUMBER := 1000;
6235 l_event_type_name VARCHAR2(80) := 'Direct Loan Approved';
6236 l_event_class_name VARCHAR2(80) := 'Direct Loan';
6237 l_description VARCHAR2(4000);
6238 l_transaction_reversal NUMBER;
6239 l_ae_header_id NUMBER;
6240 l_array_extract_line_num xla_ae_journal_entry_pkg.t_array_Num;
6241 l_log_module VARCHAR2(240);
6242 --
6243 l_acct_reversal_source VARCHAR2(30);
6244 l_trx_reversal_source VARCHAR2(30);
6245
6246 l_continue_with_lines BOOLEAN := TRUE;
6247 --
6248 l_acc_rev_gl_date_source DATE; -- 4262811
6249 --
6250 type t_array_event_id is table of number index by binary_integer;
6251
6252 l_rec_array_event t_rec_array_event;
6253 l_null_rec_array_event t_rec_array_event;
6254 l_array_ae_header_id xla_number_array_type;
6255 l_actual_flag VARCHAR2(1) := NULL;
6256 l_actual_gain_loss_ref VARCHAR2(30) := '#####';
6257 l_balance_type_code VARCHAR2(1) :=NULL;
6258 l_gain_or_loss_ref VARCHAR2(30) :=NULL;
6259
6260 --
6261 TYPE t_array_lookup_meaning IS TABLE OF fnd_lookup_values.meaning%TYPE INDEX BY BINARY_INTEGER;
6262 --
6263
6264 TYPE t_array_source_1 IS TABLE OF LNS_LOAN_HEADERS_EXT_V.LOAN_CLASS_CODE%TYPE INDEX BY BINARY_INTEGER;
6265 TYPE t_array_source_2 IS TABLE OF LNS_LOAN_HEADERS_EXT_V.LOAN_TYPE%TYPE INDEX BY BINARY_INTEGER;
6266 TYPE t_array_source_3 IS TABLE OF LNS_LOAN_HEADERS_EXT_V.LOAN_NUMBER%TYPE INDEX BY BINARY_INTEGER;
6267 TYPE t_array_source_11 IS TABLE OF LNS_LOAN_HEADERS_EXT_V.FUNDS_RESERVED_FLAG%TYPE INDEX BY BINARY_INTEGER;
6268 TYPE t_array_source_15 IS TABLE OF LNS_LOAN_HEADERS_EXT_V.LOAN_CURRENCY%TYPE INDEX BY BINARY_INTEGER;
6269 TYPE t_array_source_16 IS TABLE OF LNS_LOAN_HEADERS_EXT_V.EXCHANGE_DATE%TYPE INDEX BY BINARY_INTEGER;
6270 TYPE t_array_source_17 IS TABLE OF LNS_LOAN_HEADERS_EXT_V.EXCHANGE_RATE%TYPE INDEX BY BINARY_INTEGER;
6271 TYPE t_array_source_18 IS TABLE OF LNS_LOAN_HEADERS_EXT_V.EXCHANGE_RATE_TYPE%TYPE INDEX BY BINARY_INTEGER;
6272 TYPE t_array_source_20 IS TABLE OF LNS_LOAN_HEADERS_EXT_V.GL_DATE%TYPE INDEX BY BINARY_INTEGER;
6273
6274 TYPE t_array_source_4 IS TABLE OF LNS_LOAN_DETAILS_EXT_V.ACCOUNT_NAME%TYPE INDEX BY BINARY_INTEGER;
6275 TYPE t_array_source_5 IS TABLE OF LNS_LOAN_DETAILS_EXT_V.DERIVED_PROGRAM_ACCOUNT_BSV%TYPE INDEX BY BINARY_INTEGER;
6276 TYPE t_array_source_6 IS TABLE OF LNS_LOAN_DETAILS_EXT_V.CODE_COMBINATION_ID%TYPE INDEX BY BINARY_INTEGER;
6277 TYPE t_array_source_7 IS TABLE OF LNS_LOAN_DETAILS_EXT_V.LINE_TYPE%TYPE INDEX BY BINARY_INTEGER;
6278 TYPE t_array_source_8 IS TABLE OF LNS_LOAN_DETAILS_EXT_V.ACCOUNT_TYPE%TYPE INDEX BY BINARY_INTEGER;
6279 TYPE t_array_source_9 IS TABLE OF LNS_LOAN_DETAILS_EXT_V.EVENT_TYPE%TYPE INDEX BY BINARY_INTEGER;
6280 TYPE t_array_source_10 IS TABLE OF LNS_LOAN_DETAILS_EXT_V.DISBURSEMENT_NUMBER%TYPE INDEX BY BINARY_INTEGER;
6281 TYPE t_array_source_12 IS TABLE OF LNS_LOAN_DETAILS_EXT_V.DISTRIBUTION_ID%TYPE INDEX BY BINARY_INTEGER;
6282 TYPE t_array_source_13 IS TABLE OF LNS_LOAN_DETAILS_EXT_V.DISTRIBUTION_TYPE%TYPE INDEX BY BINARY_INTEGER;
6283 TYPE t_array_source_14 IS TABLE OF LNS_LOAN_DETAILS_EXT_V.DISTRIBUTION_AMOUNT%TYPE INDEX BY BINARY_INTEGER;
6284
6285 l_array_source_1 t_array_source_1;
6286 l_array_source_1_meaning t_array_lookup_meaning;
6287 l_array_source_2 t_array_source_2;
6288 l_array_source_3 t_array_source_3;
6289 l_array_source_11 t_array_source_11;
6290 l_array_source_15 t_array_source_15;
6291 l_array_source_15_meaning t_array_lookup_meaning;
6292 l_array_source_16 t_array_source_16;
6296
6293 l_array_source_17 t_array_source_17;
6294 l_array_source_18 t_array_source_18;
6295 l_array_source_20 t_array_source_20;
6297 l_array_source_4 t_array_source_4;
6298 l_array_source_4_meaning t_array_lookup_meaning;
6299 l_array_source_5 t_array_source_5;
6300 l_array_source_6 t_array_source_6;
6301 l_array_source_7 t_array_source_7;
6302 l_array_source_8 t_array_source_8;
6303 l_array_source_8_meaning t_array_lookup_meaning;
6304 l_array_source_9 t_array_source_9;
6305 l_array_source_9_meaning t_array_lookup_meaning;
6306 l_array_source_10 t_array_source_10;
6307 l_array_source_12 t_array_source_12;
6308 l_array_source_13 t_array_source_13;
6309 l_array_source_13_meaning t_array_lookup_meaning;
6310 l_array_source_14 t_array_source_14;
6311
6312 --
6313 CURSOR header_cur
6314 IS
6315 SELECT /*+ leading(xet) cardinality(xet,1) */
6316 -- Event Type Code: DIRECT_LOAN_APPROVED
6317 -- Event Class Code: DIRECT
6318 xet.entity_id
6319 , xet.legal_entity_id
6320 , xet.entity_code
6321 , xet.transaction_number
6322 , xet.event_id
6323 , xet.event_class_code
6324 , xet.event_type_code
6325 , xet.event_number
6326 , xet.event_date
6327 , xet.transaction_date
6328 , xet.reference_num_1
6329 , xet.reference_num_2
6330 , xet.reference_num_3
6331 , xet.reference_num_4
6332 , xet.reference_char_1
6333 , xet.reference_char_2
6334 , xet.reference_char_3
6335 , xet.reference_char_4
6336 , xet.reference_date_1
6337 , xet.reference_date_2
6338 , xet.reference_date_3
6339 , xet.reference_date_4
6340 , xet.event_created_by
6341 , xet.budgetary_control_flag
6342 , h2.LOAN_CLASS_CODE source_1
6343 , fvl1.meaning source_1_meaning
6344 , h2.LOAN_TYPE source_2
6345 , h2.LOAN_NUMBER source_3
6346 , h2.FUNDS_RESERVED_FLAG source_11
6347 , h2.LOAN_CURRENCY source_15
6348 , fvl15.meaning source_15_meaning
6349 , h2.EXCHANGE_DATE source_16
6350 , h2.EXCHANGE_RATE source_17
6351 , h2.EXCHANGE_RATE_TYPE source_18
6352 , h2.GL_DATE source_20
6353 FROM xla_events_gt xet
6354 , LNS_LOAN_HEADERS_EXT_V h2
6355 , fnd_lookup_values fvl1
6356 , fnd_lookup_values fvl15
6357 WHERE xet.event_date between p_pad_start_date and p_pad_end_date
6358 and xet.event_type_code = C_EVENT_TYPE_CODE
6359 and xet.event_status_code <> 'N' AND h2.event_id = xet.event_id
6360 AND fvl1.lookup_type(+) = 'LOAN_CLASS'
6361 AND fvl1.lookup_code(+) = h2.LOAN_CLASS_CODE
6362 AND fvl1.view_application_id(+) = 206
6363 AND fvl1.language(+) = USERENV('LANG')
6364 AND fvl15.lookup_type(+) = 'CURRENCY_CODE'
6365 AND fvl15.lookup_code(+) = h2.LOAN_CURRENCY
6366 AND fvl15.view_application_id(+) = 101
6367 AND fvl15.language(+) = USERENV('LANG')
6368
6369 ORDER BY event_id
6370 ;
6371
6372
6373 --
6374 CURSOR line_cur (x_first_event_id in number, x_last_event_id in number)
6375 IS
6376 SELECT /*+ leading(xet) cardinality(xet,1) */
6377 -- Event Type Code: DIRECT_LOAN_APPROVED
6378 -- Event Class Code: DIRECT
6379 xet.entity_id
6380 ,xet.legal_entity_id
6381 ,xet.entity_code
6382 ,xet.transaction_number
6383 ,xet.event_id
6384 ,xet.event_class_code
6385 ,xet.event_type_code
6386 ,xet.event_number
6387 ,xet.event_date
6388 ,xet.transaction_date
6389 ,xet.reference_num_1
6390 ,xet.reference_num_2
6391 ,xet.reference_num_3
6392 ,xet.reference_num_4
6393 ,xet.reference_char_1
6394 ,xet.reference_char_2
6395 ,xet.reference_char_3
6396 ,xet.reference_char_4
6397 ,xet.reference_date_1
6398 ,xet.reference_date_2
6399 ,xet.reference_date_3
6400 ,xet.reference_date_4
6401 ,xet.event_created_by
6402 ,xet.budgetary_control_flag , l1.LINE_NUMBER
6403 , l1.ACCOUNT_NAME source_4
6404 , fvl4.meaning source_4_meaning
6405 , l1.DERIVED_PROGRAM_ACCOUNT_BSV source_5
6406 , l1.CODE_COMBINATION_ID source_6
6407 , l1.LINE_TYPE source_7
6408 , l1.ACCOUNT_TYPE source_8
6409 , fvl8.meaning source_8_meaning
6410 , l1.EVENT_TYPE source_9
6411 , fvl9.meaning source_9_meaning
6412 , l1.DISBURSEMENT_NUMBER source_10
6413 , l1.DISTRIBUTION_ID source_12
6414 , l1.DISTRIBUTION_TYPE source_13
6415 , fvl13.meaning source_13_meaning
6416 , l1.DISTRIBUTION_AMOUNT source_14
6417 FROM xla_events_gt xet
6418 , LNS_LOAN_DETAILS_EXT_V l1
6419 , fnd_lookup_values fvl4
6420 , fnd_lookup_values fvl8
6421 , fnd_lookup_values fvl9
6422 , fnd_lookup_values fvl13
6423 WHERE xet.event_id between x_first_event_id and x_last_event_id
6424 and xet.event_date between p_pad_start_date and p_pad_end_date
6425 and xet.event_type_code = C_EVENT_TYPE_CODE
6426 and xet.event_status_code <> 'N' AND l1.event_id = xet.event_id
6427 AND fvl4.lookup_type(+) = 'LOAN_DISTRIBUTION_ACCOUNTS'
6428 AND fvl4.lookup_code(+) = l1.ACCOUNT_NAME
6429 AND fvl4.view_application_id(+) = 206
6430 AND fvl4.language(+) = USERENV('LANG')
6431 AND fvl8.lookup_type(+) = 'LOAN_DISTRIBUTION_ACCOUNT_DRCR'
6435 AND fvl9.lookup_type(+) = 'LOAN_ACCOUNTING_EVENT'
6432 AND fvl8.lookup_code(+) = l1.ACCOUNT_TYPE
6433 AND fvl8.view_application_id(+) = 206
6434 AND fvl8.language(+) = USERENV('LANG')
6436 AND fvl9.lookup_code(+) = l1.EVENT_TYPE
6437 AND fvl9.view_application_id(+) = 206
6438 AND fvl9.language(+) = USERENV('LANG')
6439 AND fvl13.lookup_type(+) = 'LOAN_DISTRIBUTION_ACCOUNT_DRCR'
6440 AND fvl13.lookup_code(+) = l1.DISTRIBUTION_TYPE
6441 AND fvl13.view_application_id(+) = 206
6442 AND fvl13.language(+) = USERENV('LANG')
6443 ;
6444
6445 --
6446 BEGIN
6447 IF g_log_enabled THEN
6448 l_log_module := C_DEFAULT_MODULE||'.EventType_15';
6449 END IF;
6450 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6451 trace
6452 (p_msg => 'BEGIN of EventType_15'
6453 ,p_level => C_LEVEL_PROCEDURE
6454 ,p_module => l_log_module);
6455 END IF;
6456
6457 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6458 trace
6459 (p_msg => 'p_application_id = '||p_application_id||
6460 ' - p_base_ledger_id = '||p_base_ledger_id||
6461 ' - p_target_ledger_id = '||p_target_ledger_id||
6462 ' - p_language = '||p_language||
6463 ' - p_currency_code = '||p_currency_code||
6464 ' - p_sla_ledger_id = '||p_sla_ledger_id
6465 ,p_level => C_LEVEL_STATEMENT
6466 ,p_module => l_log_module);
6467 END IF;
6468 --
6469 -- initialze arrays
6470 --
6471 g_array_event.DELETE;
6472 l_rec_array_event := l_null_rec_array_event;
6473 --
6474 --------------------------------------
6475 -- 4262811 Initialze MPA Line Number
6476 --------------------------------------
6477 XLA_AE_HEADER_PKG.g_mpa_line_num := 0;
6478
6479 --
6480
6481 --
6482 OPEN header_cur;
6483 --
6484 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6485 trace
6486 (p_msg => 'SQL - FETCH header_cur'
6487 ,p_level => C_LEVEL_STATEMENT
6488 ,p_module => l_log_module);
6489 END IF;
6490 --
6491 LOOP
6492 FETCH header_cur BULK COLLECT INTO
6493 l_array_entity_id
6494 , l_array_legal_entity_id
6495 , l_array_entity_code
6496 , l_array_transaction_num
6497 , l_array_event_id
6498 , l_array_class_code
6499 , l_array_event_type
6500 , l_array_event_number
6501 , l_array_event_date
6502 , l_array_transaction_date
6503 , l_array_reference_num_1
6504 , l_array_reference_num_2
6505 , l_array_reference_num_3
6506 , l_array_reference_num_4
6507 , l_array_reference_char_1
6508 , l_array_reference_char_2
6509 , l_array_reference_char_3
6510 , l_array_reference_char_4
6511 , l_array_reference_date_1
6512 , l_array_reference_date_2
6513 , l_array_reference_date_3
6514 , l_array_reference_date_4
6515 , l_array_event_created_by
6516 , l_array_budgetary_control_flag
6517 , l_array_source_1
6518 , l_array_source_1_meaning
6519 , l_array_source_2
6520 , l_array_source_3
6521 , l_array_source_11
6522 , l_array_source_15
6523 , l_array_source_15_meaning
6524 , l_array_source_16
6525 , l_array_source_17
6526 , l_array_source_18
6527 , l_array_source_20
6528 LIMIT l_rows;
6529 --
6530 IF (C_LEVEL_EVENT >= g_log_level) THEN
6531 trace
6532 (p_msg => '# rows extracted from header extract objects = '||TO_CHAR(header_cur%ROWCOUNT)
6533 ,p_level => C_LEVEL_EVENT
6534 ,p_module => l_log_module);
6535 END IF;
6536 --
6537 EXIT WHEN l_array_entity_id.COUNT = 0;
6538
6539 -- initialize arrays
6540 XLA_AE_HEADER_PKG.g_rec_header_new := NULL;
6541 XLA_AE_LINES_PKG.g_rec_lines := NULL;
6542
6543 --
6544 -- Bug 4458708
6545 --
6546 XLA_AE_LINES_PKG.g_LineNumber := 0;
6547
6548
6549 -- 4262811 - when creating Accrual Reversal or MPA, use g_last_hdr_idx to increment for next header id
6550 g_last_hdr_idx := l_array_event_id.LAST;
6551 --
6552 -- loop for the headers. Each iteration is for each header extract row
6553 -- fetched in header cursor
6554 --
6555 FOR hdr_idx IN l_array_event_id.FIRST .. l_array_event_id.LAST LOOP
6556
6557 --
6558 -- set event info as cache for other routines to refer event attributes
6559 --
6560 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
6561 (p_application_id => p_application_id
6562 ,p_primary_ledger_id => p_primary_ledger_id
6563 ,p_base_ledger_id => p_base_ledger_id
6564 ,p_target_ledger_id => p_target_ledger_id
6565 ,p_entity_id => l_array_entity_id(hdr_idx)
6566 ,p_legal_entity_id => l_array_legal_entity_id(hdr_idx)
6567 ,p_entity_code => l_array_entity_code(hdr_idx)
6568 ,p_transaction_num => l_array_transaction_num(hdr_idx)
6569 ,p_event_id => l_array_event_id(hdr_idx)
6570 ,p_event_class_code => l_array_class_code(hdr_idx)
6571 ,p_event_type_code => l_array_event_type(hdr_idx)
6572 ,p_event_number => l_array_event_number(hdr_idx)
6573 ,p_event_date => l_array_event_date(hdr_idx)
6574 ,p_transaction_date => l_array_transaction_date(hdr_idx)
6578 ,p_reference_num_4 => l_array_reference_num_4(hdr_idx)
6575 ,p_reference_num_1 => l_array_reference_num_1(hdr_idx)
6576 ,p_reference_num_2 => l_array_reference_num_2(hdr_idx)
6577 ,p_reference_num_3 => l_array_reference_num_3(hdr_idx)
6579 ,p_reference_char_1 => l_array_reference_char_1(hdr_idx)
6580 ,p_reference_char_2 => l_array_reference_char_2(hdr_idx)
6581 ,p_reference_char_3 => l_array_reference_char_3(hdr_idx)
6582 ,p_reference_char_4 => l_array_reference_char_4(hdr_idx)
6583 ,p_reference_date_1 => l_array_reference_date_1(hdr_idx)
6584 ,p_reference_date_2 => l_array_reference_date_2(hdr_idx)
6585 ,p_reference_date_3 => l_array_reference_date_3(hdr_idx)
6586 ,p_reference_date_4 => l_array_reference_date_4(hdr_idx)
6587 ,p_event_created_by => l_array_event_created_by(hdr_idx)
6588 ,p_budgetary_control_flag => l_array_budgetary_control_flag(hdr_idx));
6589
6590 --
6591 -- set the status of entry to C_VALID (0)
6592 --
6593 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
6594
6595 --
6596 -- initialize a row for ae header
6597 --
6598 XLA_AE_HEADER_PKG.InitHeader(hdr_idx);
6599
6600 l_event_id := l_array_event_id(hdr_idx);
6601
6602 --
6603 -- storing the hdr_idx for event. May be used by line cursor.
6604 --
6605 g_array_event(l_event_id).array_value_num('header_index') := hdr_idx;
6606
6607 --
6608 -- store sources from header extract. This can be improved to
6609 -- store only those sources from header extract that may be used in lines
6610 --
6611
6612 g_array_event(l_event_id).array_value_char('source_1') := l_array_source_1(hdr_idx);
6613 g_array_event(l_event_id).array_value_char('source_1_meaning') := l_array_source_1_meaning(hdr_idx);
6614 g_array_event(l_event_id).array_value_char('source_2') := l_array_source_2(hdr_idx);
6615 g_array_event(l_event_id).array_value_char('source_3') := l_array_source_3(hdr_idx);
6616 g_array_event(l_event_id).array_value_char('source_11') := l_array_source_11(hdr_idx);
6617 g_array_event(l_event_id).array_value_char('source_15') := l_array_source_15(hdr_idx);
6618 g_array_event(l_event_id).array_value_char('source_15_meaning') := l_array_source_15_meaning(hdr_idx);
6619 g_array_event(l_event_id).array_value_date('source_16') := l_array_source_16(hdr_idx);
6620 g_array_event(l_event_id).array_value_num('source_17') := l_array_source_17(hdr_idx);
6621 g_array_event(l_event_id).array_value_char('source_18') := l_array_source_18(hdr_idx);
6622 g_array_event(l_event_id).array_value_date('source_20') := l_array_source_20(hdr_idx);
6623
6624 --
6625 -- initilaize the status of ae headers for diffrent balance types
6626 -- the status is initialised to C_NOT_CREATED (2)
6627 --
6628 --g_array_event(l_event_id).array_value_num('actual_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
6629 --g_array_event(l_event_id).array_value_num('budget_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
6630 --g_array_event(l_event_id).array_value_num('encumbrance_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
6631
6632 --
6633 -- call api to validate and store accounting attributes for header
6634 --
6635
6636 ------------------------------------------------------------
6637 -- Accrual Reversal : to get date for Standard Source (NONE)
6638 ------------------------------------------------------------
6639 l_acc_rev_gl_date_source := NULL;
6640
6641 l_rec_acct_attrs.array_acct_attr_code(1) := 'GL_DATE';
6642 l_rec_acct_attrs.array_date_value(1) := g_array_event(l_event_id).array_value_date('source_20');
6643
6644
6645 XLA_AE_HEADER_PKG.SetHdrAcctAttrs(l_rec_acct_attrs);
6646
6647 XLA_AE_HEADER_PKG.SetJeCategoryName;
6648
6649 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_type_code(hdr_idx) := l_array_event_type(hdr_idx);
6650 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_id(hdr_idx) := l_array_event_id(hdr_idx);
6651 XLA_AE_HEADER_PKG.g_rec_header_new.array_entity_id(hdr_idx) := l_array_entity_id(hdr_idx);
6652 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_number(hdr_idx) := l_array_event_number(hdr_idx);
6653 XLA_AE_HEADER_PKG.g_rec_header_new.array_target_ledger_id(hdr_idx) := p_target_ledger_id;
6654
6655
6656 --
6657 xla_ae_header_pkg.SetHdrDescription(
6658 p_description => Description_1 (
6659 p_application_id => p_application_id
6660 , p_source_1 => g_array_event(l_event_id).array_value_char('source_1')
6661 , p_source_1_meaning => g_array_event(l_event_id).array_value_char('source_1_meaning')
6662 , p_source_2 => g_array_event(l_event_id).array_value_char('source_2')
6663 , p_source_3 => g_array_event(l_event_id).array_value_char('source_3')
6664 )
6665 );
6666 --
6667
6668 -- No header level analytical criteria
6669
6670 --
6671 --accounting attribute enhancement, bug 3612931
6672 --
6673 l_trx_reversal_source := SUBSTR(NULL, 1,30);
6674
6675 IF NVL(l_trx_reversal_source, 'N') NOT IN ('N','Y') THEN
6676 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
6677
6678 xla_accounting_err_pkg.build_message
6679 (p_appli_s_name => 'XLA'
6680 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
6681 ,p_token_1 => 'ACCT_ATTR_NAME'
6682 ,p_value_1 => xla_ae_sources_pkg.GetAccountingSourceName('TRX_ACCT_REVERSAL_OPTION')
6683 ,p_token_2 => 'PRODUCT_NAME'
6684 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
6685 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
6689 ELSIF NVL(l_trx_reversal_source, 'N') = 'Y' THEN
6686 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
6687 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
6688
6690 --
6691 -- following sets the accounting attributes needed to reverse
6692 -- accounting for a distributeion
6693 --
6694 xla_ae_lines_pkg.SetTrxReversalAttrs
6695 (p_event_id => l_event_id
6696 ,p_gl_date => XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(hdr_idx)
6697 ,p_trx_reversal_source => l_trx_reversal_source);
6698
6699 END IF;
6700
6701
6702 ----------------------------------------------------------------
6703 -- 4262811 - update the header statuses to invalid in need be
6704 ----------------------------------------------------------------
6705 --
6706 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus (p_hdr_idx => hdr_idx);
6707
6708
6709 -----------------------------------------------
6710 -- No accrual reversal for the event class/type
6711 -----------------------------------------------
6712 ----------------------------------------------------------------
6713
6714 --
6715 -- this ends the header loop iteration for one bulk fetch
6716 --
6717 END LOOP;
6718
6719 l_first_event_id := l_array_event_id(l_array_event_id.FIRST);
6720 l_last_event_id := l_array_event_id(l_array_event_id.LAST);
6721
6722 --
6723 -- insert dummy rows into lines gt table that were created due to
6724 -- transaction reversals
6725 --
6726 IF XLA_AE_LINES_PKG.g_rec_lines.array_ae_header_id.COUNT > 0 THEN
6727 l_result := XLA_AE_LINES_PKG.InsertLines;
6728 END IF;
6729
6730 --
6731 -- reset the temp_line_num for each set of events fetched from header
6732 -- cursor rather than doing it for each new event in line cursor
6733 -- Bug 3939231
6734 --
6735 xla_ae_lines_pkg.g_temp_line_num := 0;
6736
6737
6738
6739 --
6740 OPEN line_cur(x_first_event_id => l_first_event_id, x_last_event_id => l_last_event_id);
6741 --
6742 --
6743 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6744
6745 trace
6746 (p_msg => 'SQL - FETCH line_cur'
6747 ,p_level => C_LEVEL_STATEMENT
6748 ,p_module => l_log_module);
6749
6750 END IF;
6751 --
6752 --
6753 LOOP
6754 --
6755 FETCH line_cur BULK COLLECT INTO
6756 l_array_entity_id
6757 , l_array_legal_entity_id
6758 , l_array_entity_code
6759 , l_array_transaction_num
6760 , l_array_event_id
6761 , l_array_class_code
6762 , l_array_event_type
6763 , l_array_event_number
6764 , l_array_event_date
6765 , l_array_transaction_date
6766 , l_array_reference_num_1
6767 , l_array_reference_num_2
6768 , l_array_reference_num_3
6769 , l_array_reference_num_4
6770 , l_array_reference_char_1
6771 , l_array_reference_char_2
6772 , l_array_reference_char_3
6773 , l_array_reference_char_4
6774 , l_array_reference_date_1
6775 , l_array_reference_date_2
6776 , l_array_reference_date_3
6777 , l_array_reference_date_4
6778 , l_array_event_created_by
6779 , l_array_budgetary_control_flag
6780 , l_array_extract_line_num
6781 , l_array_source_4
6782 , l_array_source_4_meaning
6783 , l_array_source_5
6784 , l_array_source_6
6785 , l_array_source_7
6786 , l_array_source_8
6787 , l_array_source_8_meaning
6788 , l_array_source_9
6789 , l_array_source_9_meaning
6790 , l_array_source_10
6791 , l_array_source_12
6792 , l_array_source_13
6793 , l_array_source_13_meaning
6794 , l_array_source_14
6795 LIMIT l_rows;
6796
6797 --
6798 IF (C_LEVEL_EVENT >= g_log_level) THEN
6799 trace
6800 (p_msg => '# rows extracted from line extract objects = '||TO_CHAR(line_cur%ROWCOUNT)
6801 ,p_level => C_LEVEL_EVENT
6802 ,p_module => l_log_module);
6803 END IF;
6804 --
6805 EXIT WHEN l_array_entity_id.count = 0;
6806
6807 XLA_AE_LINES_PKG.g_rec_lines := null;
6808
6809 --
6810 -- Bug 4458708
6811 --
6812 XLA_AE_LINES_PKG.g_LineNumber := 0;
6813 --
6814 --
6815
6816 FOR Idx IN 1..l_array_event_id.count LOOP
6817 --
6818 -- 5648433 (move l_event_id out of IF statement) set l_event_id to be used inside IF condition
6819 --
6820 l_event_id := l_array_event_id(idx); -- 5648433
6821
6822 --
6823 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
6824 --
6825
6826 IF NVL(xla_ae_header_pkg.g_rec_header_new.array_trx_acct_reversal_option
6827 (g_array_event(l_event_id).array_value_num('header_index'))
6828 ,'N'
6829 ) <> 'Y'
6830 THEN
6831 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6832 trace
6833 (p_msg => 'Trancaction revesal option is not Y '
6834 ,p_level => C_LEVEL_STATEMENT
6835 ,p_module => l_log_module);
6836 END IF;
6837
6838 --
6839 -- set the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
6840 --
6841 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
6842 --
6846 IF l_event_id <> NVL(l_previous_event_id, -1) THEN
6843 -- set event info as cache for other routines to refer event attributes
6844 --
6845
6847 l_previous_event_id := l_event_id;
6848
6849 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
6850 (p_application_id => p_application_id
6851 ,p_primary_ledger_id => p_primary_ledger_id
6852 ,p_base_ledger_id => p_base_ledger_id
6853 ,p_target_ledger_id => p_target_ledger_id
6854 ,p_entity_id => l_array_entity_id(Idx)
6855 ,p_legal_entity_id => l_array_legal_entity_id(Idx)
6856 ,p_entity_code => l_array_entity_code(Idx)
6857 ,p_transaction_num => l_array_transaction_num(Idx)
6858 ,p_event_id => l_array_event_id(Idx)
6859 ,p_event_class_code => l_array_class_code(Idx)
6860 ,p_event_type_code => l_array_event_type(Idx)
6861 ,p_event_number => l_array_event_number(Idx)
6862 ,p_event_date => l_array_event_date(Idx)
6863 ,p_transaction_date => l_array_transaction_date(Idx)
6864 ,p_reference_num_1 => l_array_reference_num_1(Idx)
6865 ,p_reference_num_2 => l_array_reference_num_2(Idx)
6866 ,p_reference_num_3 => l_array_reference_num_3(Idx)
6867 ,p_reference_num_4 => l_array_reference_num_4(Idx)
6868 ,p_reference_char_1 => l_array_reference_char_1(Idx)
6869 ,p_reference_char_2 => l_array_reference_char_2(Idx)
6870 ,p_reference_char_3 => l_array_reference_char_3(Idx)
6871 ,p_reference_char_4 => l_array_reference_char_4(Idx)
6872 ,p_reference_date_1 => l_array_reference_date_1(Idx)
6873 ,p_reference_date_2 => l_array_reference_date_2(Idx)
6874 ,p_reference_date_3 => l_array_reference_date_3(Idx)
6875 ,p_reference_date_4 => l_array_reference_date_4(Idx)
6876 ,p_event_created_by => l_array_event_created_by(Idx)
6877 ,p_budgetary_control_flag => l_array_budgetary_control_flag(Idx));
6878 --
6879 END IF;
6880
6881
6882
6883 --
6884 xla_ae_lines_pkg.SetExtractLine(p_extract_line => l_array_extract_line_num(Idx));
6885
6886 l_acct_reversal_source := SUBSTR(NULL, 1,30);
6887
6888 IF l_continue_with_lines THEN
6889 IF NVL(l_acct_reversal_source, 'N') NOT IN ('N','Y','B') THEN
6890 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
6891
6892 xla_accounting_err_pkg.build_message
6893 (p_appli_s_name => 'XLA'
6894 ,p_msg_name => 'XLA_AP_INVALID_REVERSAL_OPTION'
6895 ,p_token_1 => 'LINE_NUMBER'
6896 ,p_value_1 => l_array_extract_line_num(Idx)
6897 ,p_token_2 => 'PRODUCT_NAME'
6898 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
6899 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
6900 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
6901 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
6902
6903 ELSIF NVL(l_acct_reversal_source, 'N') IN ('Y','B') THEN
6904 --
6905 -- following sets the accounting attributes needed to reverse
6906 -- accounting for a distributeion
6907 --
6908
6909 --
6910 -- 5217187
6911 --
6912 l_rec_rev_acct_attrs.array_acct_attr_code(1):= 'GL_DATE';
6913 l_rec_rev_acct_attrs.array_date_value(1) := XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(
6914 g_array_event(l_event_id).array_value_num('header_index'));
6915 --
6916 --
6917
6918 -- No reversal code generated
6919
6920 xla_ae_lines_pkg.SetAcctReversalAttrs
6921 (p_event_id => l_event_id
6922 ,p_rec_acct_attrs => l_rec_rev_acct_attrs
6923 ,p_calculate_acctd_flag => l_calculate_acctd_flag
6924 ,p_calculate_g_l_flag => l_calculate_g_l_flag);
6925 END IF;
6926
6927 IF NVL(l_acct_reversal_source, 'N') IN ('N','B') THEN
6928 l_actual_flag := NULL; l_actual_gain_loss_ref := '#####';
6929
6930 --
6931 AcctLineType_7 (
6932 p_application_id => p_application_id
6933 ,p_event_id => l_event_id
6934 ,p_calculate_acctd_flag => l_calculate_acctd_flag
6935 ,p_calculate_g_l_flag => l_calculate_g_l_flag
6936 ,p_actual_flag => l_actual_flag
6937 ,p_balance_type_code => l_balance_type_code
6938 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
6939
6940 , p_source_4 => l_array_source_4(Idx)
6941 , p_source_4_meaning => l_array_source_4_meaning(Idx)
6942 , p_source_5 => l_array_source_5(Idx)
6943 , p_source_6 => l_array_source_6(Idx)
6944 , p_source_7 => l_array_source_7(Idx)
6945 , p_source_8 => l_array_source_8(Idx)
6946 , p_source_8_meaning => l_array_source_8_meaning(Idx)
6947 , p_source_9 => l_array_source_9(Idx)
6948 , p_source_9_meaning => l_array_source_9_meaning(Idx)
6949 , p_source_10 => l_array_source_10(Idx)
6950 , p_source_11 => g_array_event(l_event_id).array_value_char('source_11')
6951 , p_source_12 => l_array_source_12(Idx)
6952 , p_source_13 => l_array_source_13(Idx)
6953 , p_source_13_meaning => l_array_source_13_meaning(Idx)
6954 , p_source_14 => l_array_source_14(Idx)
6955 , p_source_15 => g_array_event(l_event_id).array_value_char('source_15')
6959 , p_source_18 => g_array_event(l_event_id).array_value_char('source_18')
6956 , p_source_15_meaning => g_array_event(l_event_id).array_value_char('source_15_meaning')
6957 , p_source_16 => g_array_event(l_event_id).array_value_date('source_16')
6958 , p_source_17 => g_array_event(l_event_id).array_value_num('source_17')
6960 );
6961 If(l_balance_type_code = 'A') THEN
6962 l_actual_gain_loss_ref := l_gain_or_loss_ref;
6963 END IF;
6964
6965 --
6966
6967
6968 --
6969 AcctLineType_9 (
6970 p_application_id => p_application_id
6971 ,p_event_id => l_event_id
6972 ,p_calculate_acctd_flag => l_calculate_acctd_flag
6973 ,p_calculate_g_l_flag => l_calculate_g_l_flag
6974 ,p_actual_flag => l_actual_flag
6975 ,p_balance_type_code => l_balance_type_code
6976 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
6977
6978 , p_source_4 => l_array_source_4(Idx)
6979 , p_source_4_meaning => l_array_source_4_meaning(Idx)
6980 , p_source_5 => l_array_source_5(Idx)
6981 , p_source_6 => l_array_source_6(Idx)
6982 , p_source_7 => l_array_source_7(Idx)
6983 , p_source_8 => l_array_source_8(Idx)
6984 , p_source_8_meaning => l_array_source_8_meaning(Idx)
6985 , p_source_9 => l_array_source_9(Idx)
6986 , p_source_9_meaning => l_array_source_9_meaning(Idx)
6987 , p_source_10 => l_array_source_10(Idx)
6988 , p_source_11 => g_array_event(l_event_id).array_value_char('source_11')
6989 , p_source_12 => l_array_source_12(Idx)
6990 , p_source_13 => l_array_source_13(Idx)
6991 , p_source_13_meaning => l_array_source_13_meaning(Idx)
6992 , p_source_14 => l_array_source_14(Idx)
6993 , p_source_15 => g_array_event(l_event_id).array_value_char('source_15')
6994 , p_source_15_meaning => g_array_event(l_event_id).array_value_char('source_15_meaning')
6995 , p_source_16 => g_array_event(l_event_id).array_value_date('source_16')
6996 , p_source_17 => g_array_event(l_event_id).array_value_num('source_17')
6997 , p_source_18 => g_array_event(l_event_id).array_value_char('source_18')
6998 );
6999 If(l_balance_type_code = 'A') THEN
7000 l_actual_gain_loss_ref := l_gain_or_loss_ref;
7001 END IF;
7002
7003 --
7004
7005
7006 --
7007 AcctLineType_11 (
7008 p_application_id => p_application_id
7009 ,p_event_id => l_event_id
7010 ,p_calculate_acctd_flag => l_calculate_acctd_flag
7011 ,p_calculate_g_l_flag => l_calculate_g_l_flag
7012 ,p_actual_flag => l_actual_flag
7013 ,p_balance_type_code => l_balance_type_code
7014 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
7015
7016 , p_source_4 => l_array_source_4(Idx)
7017 , p_source_4_meaning => l_array_source_4_meaning(Idx)
7018 , p_source_6 => l_array_source_6(Idx)
7019 , p_source_7 => l_array_source_7(Idx)
7020 , p_source_8 => l_array_source_8(Idx)
7021 , p_source_8_meaning => l_array_source_8_meaning(Idx)
7022 , p_source_9 => l_array_source_9(Idx)
7023 , p_source_9_meaning => l_array_source_9_meaning(Idx)
7024 , p_source_10 => l_array_source_10(Idx)
7025 , p_source_11 => g_array_event(l_event_id).array_value_char('source_11')
7026 , p_source_12 => l_array_source_12(Idx)
7030 , p_source_15 => g_array_event(l_event_id).array_value_char('source_15')
7027 , p_source_13 => l_array_source_13(Idx)
7028 , p_source_13_meaning => l_array_source_13_meaning(Idx)
7029 , p_source_14 => l_array_source_14(Idx)
7031 , p_source_15_meaning => g_array_event(l_event_id).array_value_char('source_15_meaning')
7032 , p_source_16 => g_array_event(l_event_id).array_value_date('source_16')
7033 , p_source_17 => g_array_event(l_event_id).array_value_num('source_17')
7034 , p_source_18 => g_array_event(l_event_id).array_value_char('source_18')
7035 );
7036 If(l_balance_type_code = 'A') THEN
7037 l_actual_gain_loss_ref := l_gain_or_loss_ref;
7038 END IF;
7039
7040 --
7041
7042
7043 --
7044 AcctLineType_13 (
7045 p_application_id => p_application_id
7046 ,p_event_id => l_event_id
7047 ,p_calculate_acctd_flag => l_calculate_acctd_flag
7048 ,p_calculate_g_l_flag => l_calculate_g_l_flag
7049 ,p_actual_flag => l_actual_flag
7050 ,p_balance_type_code => l_balance_type_code
7051 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
7052
7053 , p_source_4 => l_array_source_4(Idx)
7054 , p_source_4_meaning => l_array_source_4_meaning(Idx)
7055 , p_source_6 => l_array_source_6(Idx)
7056 , p_source_7 => l_array_source_7(Idx)
7057 , p_source_8 => l_array_source_8(Idx)
7058 , p_source_8_meaning => l_array_source_8_meaning(Idx)
7059 , p_source_9 => l_array_source_9(Idx)
7060 , p_source_9_meaning => l_array_source_9_meaning(Idx)
7061 , p_source_10 => l_array_source_10(Idx)
7062 , p_source_11 => g_array_event(l_event_id).array_value_char('source_11')
7063 , p_source_12 => l_array_source_12(Idx)
7064 , p_source_13 => l_array_source_13(Idx)
7065 , p_source_13_meaning => l_array_source_13_meaning(Idx)
7066 , p_source_14 => l_array_source_14(Idx)
7067 , p_source_15 => g_array_event(l_event_id).array_value_char('source_15')
7068 , p_source_15_meaning => g_array_event(l_event_id).array_value_char('source_15_meaning')
7069 , p_source_16 => g_array_event(l_event_id).array_value_date('source_16')
7070 , p_source_17 => g_array_event(l_event_id).array_value_num('source_17')
7071 , p_source_18 => g_array_event(l_event_id).array_value_char('source_18')
7072 );
7073 If(l_balance_type_code = 'A') THEN
7074 l_actual_gain_loss_ref := l_gain_or_loss_ref;
7075 END IF;
7076
7077 --
7078
7079 -- only execute it if calculate g/l flag is yes, and primary or secondary ledger
7080 -- or secondary ledger that has different currency with primary
7081 -- or alc that is calculated by sla
7082 IF (((l_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
7083 (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code in ('ALC', 'SECONDARY') AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.calculate_amts_flag='Y'))
7084
7085 -- IF((l_calculate_g_l_flag='Y' or XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id <>
7086 -- XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id)
7087 AND (l_actual_flag = 'A')) THEN
7088 XLA_AE_LINES_PKG.CreateGainOrLossLines(
7089 p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
7090 ,p_application_id => p_application_id
7091 ,p_amb_context_code => 'DEFAULT'
7092 ,p_entity_code => xla_ae_journal_entry_pkg.g_cache_event.entity_code
7093 ,p_event_class_code => C_EVENT_CLASS_CODE
7094 ,p_event_type_code => C_EVENT_TYPE_CODE
7095
7096 ,p_gain_ccid => -1
7097 ,p_loss_ccid => -1
7098
7099 ,p_actual_flag => l_actual_flag
7100 ,p_enc_flag => null
7101 ,p_actual_g_l_ref => l_actual_gain_loss_ref
7102 ,p_enc_g_l_ref => null
7103 );
7104 END IF;
7105 END IF;
7106 END IF;
7107
7108 ELSE
7109 --
7110 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
7111 --
7112 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
7113 trace
7114 (p_msg => 'Trancaction revesal option is Y'
7115 ,p_level => C_LEVEL_STATEMENT
7116 ,p_module => l_log_module);
7117 END IF;
7118 END IF;
7119
7120 END LOOP;
7121 l_result := XLA_AE_LINES_PKG.InsertLines ;
7122 end loop;
7123 close line_cur;
7124
7125
7126 --
7127 -- insert headers into xla_ae_headers_gt table
7128 --
7129 l_result := XLA_AE_HEADER_PKG.InsertHeaders ;
7130
7131 -- insert into errors table here.
7132
7133 END LOOP;
7134
7135 --
7136 -- 4865292
7137 --
7138 -- Compare g_hdr_extract_count with event count in
7139 -- CreateHeadersAndLines.
7140 --
7141 g_hdr_extract_count := g_hdr_extract_count + header_cur%ROWCOUNT;
7142
7143 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
7144 trace (p_msg => '# rows extracted from header extract objects '
7145 || ' (running total): '
7146 || g_hdr_extract_count
7147 ,p_level => C_LEVEL_STATEMENT
7148 ,p_module => l_log_module);
7149 END IF;
7150
7151 CLOSE header_cur;
7152 --
7153
7154 --
7155 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7156 trace
7157 (p_msg => 'END of EventType_15'
7158 ,p_level => C_LEVEL_PROCEDURE
7159 ,p_module => l_log_module);
7163 EXCEPTION
7160 END IF;
7161 --
7162 RETURN l_result;
7164 WHEN xla_exceptions_pkg.application_exception THEN
7165
7166 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
7167
7168
7169 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
7170
7171 RAISE;
7172 WHEN OTHERS THEN
7173 xla_exceptions_pkg.raise_message
7174 (p_location => 'XLA_00206_AAD_S_000004_BC_PKG.EventType_15');
7175 END EventType_15;
7176 --
7177
7178 ---------------------------------------
7179 --
7180 -- PRIVATE PROCEDURE
7181 -- insert_sources_16
7182 --
7183 ----------------------------------------
7184 --
7185 PROCEDURE insert_sources_16(
7186 p_target_ledger_id IN NUMBER
7187 , p_language IN VARCHAR2
7188 , p_sla_ledger_id IN NUMBER
7189 , p_pad_start_date IN DATE
7190 , p_pad_end_date IN DATE
7191 )
7192 IS
7193
7194 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'FUTURE_DISBURSEMENT_CANCELLED';
7195 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'DIRECT';
7196 p_apps_owner VARCHAR2(30);
7197 l_log_module VARCHAR2(240);
7198 BEGIN
7199 IF g_log_enabled THEN
7200 l_log_module := C_DEFAULT_MODULE||'.insert_sources_16';
7201 END IF;
7202 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7203
7204 trace
7205 (p_msg => 'BEGIN of insert_sources_16'
7206 ,p_level => C_LEVEL_PROCEDURE
7207 ,p_module => l_log_module);
7208
7209 END IF;
7210
7211 -- select APPS owner
7212 SELECT oracle_username
7213 INTO p_apps_owner
7214 FROM fnd_oracle_userid
7215 WHERE read_only_flag = 'U'
7216 ;
7217
7218 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
7219 trace
7220 (p_msg => 'p_target_ledger_id = '||p_target_ledger_id||
7221 ' - p_language = '||p_language||
7222 ' - p_sla_ledger_id = '||p_sla_ledger_id ||
7223 ' - p_pad_start_date = '||TO_CHAR(p_pad_start_date)||
7224 ' - p_pad_end_date = '||TO_CHAR(p_pad_end_date)||
7225 ' - p_apps_owner = '||TO_CHAR(p_apps_owner)
7226 ,p_level => C_LEVEL_STATEMENT
7227 ,p_module => l_log_module);
7228 END IF;
7229
7230
7231 --
7232 INSERT INTO xla_diag_sources --hdr1
7233 (
7234 event_id
7235 , ledger_id
7236 , sla_ledger_id
7237 , description_language
7238 , object_name
7239 , object_type_code
7240 , line_number
7241 , source_application_id
7242 , source_type_code
7243 , source_code
7244 , source_value
7245 , source_meaning
7246 , created_by
7247 , creation_date
7248 , last_update_date
7249 , last_updated_by
7250 , last_update_login
7251 , program_update_date
7252 , program_application_id
7253 , program_id
7254 , request_id
7255 )
7256 SELECT
7257 event_id
7258 , p_target_ledger_id
7259 , p_sla_ledger_id
7260 , p_language
7261 , object_name
7262 , object_type_code
7263 , line_number
7264 , source_application_id
7265 , source_type_code
7266 , source_code
7267 , SUBSTR(source_value ,1,1996)
7268 , SUBSTR(source_meaning,1,200)
7269 , xla_environment_pkg.g_Usr_Id
7270 , TRUNC(SYSDATE)
7271 , TRUNC(SYSDATE)
7272 , xla_environment_pkg.g_Usr_Id
7273 , xla_environment_pkg.g_Login_Id
7274 , TRUNC(SYSDATE)
7275 , xla_environment_pkg.g_Prog_Appl_Id
7276 , xla_environment_pkg.g_Prog_Id
7277 , xla_environment_pkg.g_Req_Id
7278 FROM (
7279 SELECT xet.event_id event_id
7280 , 0 line_number
7281 , CASE r
7282 WHEN 1 THEN 'LNS_LOAN_HEADERS_EXT_V'
7283 WHEN 2 THEN 'LNS_LOAN_HEADERS_EXT_V'
7284 WHEN 3 THEN 'LNS_LOAN_HEADERS_EXT_V'
7285 WHEN 4 THEN 'LNS_LOAN_HEADERS_EXT_V'
7286 WHEN 5 THEN 'LNS_LOAN_HEADERS_EXT_V'
7287 WHEN 6 THEN 'LNS_LOAN_HEADERS_EXT_V'
7288 WHEN 7 THEN 'LNS_LOAN_HEADERS_EXT_V'
7289 WHEN 8 THEN 'LNS_LOAN_HEADERS_EXT_V'
7290 WHEN 9 THEN 'LNS_LOAN_HEADERS_EXT_V'
7291
7292 ELSE null
7293 END object_name
7294 , CASE r
7295 WHEN 1 THEN 'HEADER'
7296 WHEN 2 THEN 'HEADER'
7297 WHEN 3 THEN 'HEADER'
7298 WHEN 4 THEN 'HEADER'
7299 WHEN 5 THEN 'HEADER'
7300 WHEN 6 THEN 'HEADER'
7301 WHEN 7 THEN 'HEADER'
7302 WHEN 8 THEN 'HEADER'
7303 WHEN 9 THEN 'HEADER'
7304
7305 ELSE null
7306 END object_type_code
7307 , CASE r
7308 WHEN 1 THEN '206'
7312 WHEN 5 THEN '206'
7309 WHEN 2 THEN '206'
7310 WHEN 3 THEN '206'
7311 WHEN 4 THEN '206'
7313 WHEN 6 THEN '206'
7314 WHEN 7 THEN '206'
7315 WHEN 8 THEN '206'
7316 WHEN 9 THEN '206'
7317
7318 ELSE null
7319 END source_application_id
7320 , 'S' source_type_code
7321 , CASE r
7322 WHEN 1 THEN 'LOAN_CLASS_CODE'
7323 WHEN 2 THEN 'LOAN_TYPE'
7324 WHEN 3 THEN 'LOAN_NUMBER'
7325 WHEN 4 THEN 'LOAN_CURRENCY'
7326 WHEN 5 THEN 'EXCHANGE_DATE'
7327 WHEN 6 THEN 'EXCHANGE_RATE'
7328 WHEN 7 THEN 'EXCHANGE_RATE_TYPE'
7329 WHEN 8 THEN 'SUBSIDY_COST'
7330 WHEN 9 THEN 'GL_DATE'
7331
7332 ELSE null
7333 END source_code
7334 , CASE r
7335 WHEN 1 THEN TO_CHAR(h2.LOAN_CLASS_CODE)
7336 WHEN 2 THEN TO_CHAR(h2.LOAN_TYPE)
7337 WHEN 3 THEN TO_CHAR(h2.LOAN_NUMBER)
7338 WHEN 4 THEN TO_CHAR(h2.LOAN_CURRENCY)
7339 WHEN 5 THEN TO_CHAR(h2.EXCHANGE_DATE)
7340 WHEN 6 THEN TO_CHAR(h2.EXCHANGE_RATE)
7341 WHEN 7 THEN TO_CHAR(h2.EXCHANGE_RATE_TYPE)
7342 WHEN 8 THEN TO_CHAR(h2.SUBSIDY_COST)
7343 WHEN 9 THEN TO_CHAR(h2.GL_DATE)
7344
7345 ELSE null
7346 END source_value
7347 , CASE r
7348 WHEN 1 THEN fvl1.meaning
7349 WHEN 4 THEN fvl15.meaning
7350
7351 ELSE null
7352 END source_meaning
7353 FROM xla_events_gt xet
7354 , LNS_LOAN_HEADERS_EXT_V h2
7355 , fnd_lookup_values fvl1
7356 , fnd_lookup_values fvl15
7357 ,(select rownum r from all_objects where rownum <= 9 and owner = p_apps_owner)
7358 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
7359 AND xet.event_type_code = C_EVENT_TYPE_CODE
7360 AND h2.event_id = xet.event_id
7361 AND fvl1.lookup_type(+) = 'LOAN_CLASS'
7362 AND fvl1.lookup_code(+) = h2.LOAN_CLASS_CODE
7363 AND fvl1.view_application_id(+) = 206
7364 AND fvl1.language(+) = USERENV('LANG')
7365 AND fvl15.lookup_type(+) = 'CURRENCY_CODE'
7366 AND fvl15.lookup_code(+) = h2.LOAN_CURRENCY
7367 AND fvl15.view_application_id(+) = 101
7368 AND fvl15.language(+) = USERENV('LANG')
7369
7370 )
7371 ;
7372 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
7373
7374 trace
7375 (p_msg => 'number of header sources inserted = '||SQL%ROWCOUNT
7376 ,p_level => C_LEVEL_STATEMENT
7377 ,p_module => l_log_module);
7378
7379 END IF;
7380 --
7381
7382
7383
7384 --
7385 INSERT INTO xla_diag_sources --line1
7386 (
7387 event_id
7388 , ledger_id
7389 , sla_ledger_id
7390 , description_language
7391 , object_name
7392 , object_type_code
7393 , line_number
7394 , source_application_id
7395 , source_type_code
7396 , source_code
7397 , source_value
7398 , source_meaning
7399 , created_by
7400 , creation_date
7401 , last_update_date
7402 , last_updated_by
7403 , last_update_login
7404 , program_update_date
7405 , program_application_id
7406 , program_id
7407 , request_id
7408 )
7409 SELECT event_id
7410 , p_target_ledger_id
7411 , p_sla_ledger_id
7412 , p_language
7413 , object_name
7414 , object_type_code
7415 , line_number
7416 , source_application_id
7417 , source_type_code
7418 , source_code
7419 , SUBSTR(source_value,1,1996)
7420 , SUBSTR(source_meaning,1,200)
7424 , xla_environment_pkg.g_Usr_Id
7421 , xla_environment_pkg.g_Usr_Id
7422 , TRUNC(SYSDATE)
7423 , TRUNC(SYSDATE)
7425 , xla_environment_pkg.g_Login_Id
7426 , TRUNC(SYSDATE)
7427 , xla_environment_pkg.g_Prog_Appl_Id
7428 , xla_environment_pkg.g_Prog_Id
7429 , xla_environment_pkg.g_Req_Id
7430 FROM (
7431 SELECT xet.event_id event_id
7432 , l1.line_number line_number
7433 , CASE r
7434 WHEN 1 THEN 'LNS_LOAN_DETAILS_EXT_V'
7435 WHEN 2 THEN 'LNS_LOAN_DETAILS_EXT_V'
7436 WHEN 3 THEN 'LNS_LOAN_DETAILS_EXT_V'
7437 WHEN 4 THEN 'LNS_LOAN_DETAILS_EXT_V'
7438 WHEN 5 THEN 'LNS_LOAN_DETAILS_EXT_V'
7439 WHEN 6 THEN 'LNS_LOAN_DETAILS_EXT_V'
7440 WHEN 7 THEN 'LNS_LOAN_DETAILS_EXT_V'
7441 WHEN 8 THEN 'LNS_LOAN_DETAILS_EXT_V'
7442 WHEN 9 THEN 'LNS_LOAN_DETAILS_EXT_V'
7443
7444 ELSE null
7445 END object_name
7446 , CASE r
7447 WHEN 1 THEN 'LINE'
7448 WHEN 2 THEN 'LINE'
7449 WHEN 3 THEN 'LINE'
7450 WHEN 4 THEN 'LINE'
7451 WHEN 5 THEN 'LINE'
7452 WHEN 6 THEN 'LINE'
7453 WHEN 7 THEN 'LINE'
7454 WHEN 8 THEN 'LINE'
7455 WHEN 9 THEN 'LINE'
7456
7457 ELSE null
7458 END object_type_code
7459 , CASE r
7460 WHEN 1 THEN '206'
7461 WHEN 2 THEN '206'
7462 WHEN 3 THEN '206'
7463 WHEN 4 THEN '206'
7464 WHEN 5 THEN '206'
7465 WHEN 6 THEN '206'
7466 WHEN 7 THEN '206'
7467 WHEN 8 THEN '206'
7468 WHEN 9 THEN '206'
7469
7470 ELSE null
7471 END source_application_id
7472 , 'S' source_type_code
7473 , CASE r
7474 WHEN 1 THEN 'ACCOUNT_NAME'
7475 WHEN 2 THEN 'DERIVED_PROGRAM_ACCOUNT_BSV'
7476 WHEN 3 THEN 'CODE_COMBINATION_ID'
7477 WHEN 4 THEN 'LINE_TYPE'
7478 WHEN 5 THEN 'ACCOUNT_TYPE'
7479 WHEN 6 THEN 'EVENT_TYPE'
7480 WHEN 7 THEN 'DISTRIBUTION_ID'
7481 WHEN 8 THEN 'DISTRIBUTION_TYPE'
7482 WHEN 9 THEN 'DISTRIBUTION_AMOUNT'
7483
7484 ELSE null
7485 END source_code
7486 , CASE r
7487 WHEN 1 THEN TO_CHAR(l1.ACCOUNT_NAME)
7488 WHEN 2 THEN TO_CHAR(l1.DERIVED_PROGRAM_ACCOUNT_BSV)
7489 WHEN 3 THEN TO_CHAR(l1.CODE_COMBINATION_ID)
7490 WHEN 4 THEN TO_CHAR(l1.LINE_TYPE)
7491 WHEN 5 THEN TO_CHAR(l1.ACCOUNT_TYPE)
7492 WHEN 6 THEN TO_CHAR(l1.EVENT_TYPE)
7493 WHEN 7 THEN TO_CHAR(l1.DISTRIBUTION_ID)
7494 WHEN 8 THEN TO_CHAR(l1.DISTRIBUTION_TYPE)
7495 WHEN 9 THEN TO_CHAR(l1.DISTRIBUTION_AMOUNT)
7496
7497 ELSE null
7498 END source_value
7499 , CASE r
7500 WHEN 1 THEN fvl4.meaning
7501 WHEN 5 THEN fvl8.meaning
7502 WHEN 6 THEN fvl9.meaning
7503 WHEN 8 THEN fvl13.meaning
7504
7505 ELSE null
7506 END source_meaning
7507 FROM xla_events_gt xet
7508 , LNS_LOAN_DETAILS_EXT_V l1
7509 , fnd_lookup_values fvl4
7510 , fnd_lookup_values fvl8
7511 , fnd_lookup_values fvl9
7512 , fnd_lookup_values fvl13
7513 ,(select rownum r from all_objects where rownum <= 9 and owner = p_apps_owner)
7514 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
7515 AND xet.event_type_code = C_EVENT_TYPE_CODE
7516 AND l1.event_id = xet.event_id
7517 AND fvl4.lookup_type(+) = 'LOAN_DISTRIBUTION_ACCOUNTS'
7518 AND fvl4.lookup_code(+) = l1.ACCOUNT_NAME
7519 AND fvl4.view_application_id(+) = 206
7520 AND fvl4.language(+) = USERENV('LANG')
7521 AND fvl8.lookup_type(+) = 'LOAN_DISTRIBUTION_ACCOUNT_DRCR'
7522 AND fvl8.lookup_code(+) = l1.ACCOUNT_TYPE
7523 AND fvl8.view_application_id(+) = 206
7524 AND fvl8.language(+) = USERENV('LANG')
7525 AND fvl9.lookup_type(+) = 'LOAN_ACCOUNTING_EVENT'
7526 AND fvl9.lookup_code(+) = l1.EVENT_TYPE
7527 AND fvl9.view_application_id(+) = 206
7528 AND fvl9.language(+) = USERENV('LANG')
7529 AND fvl13.lookup_type(+) = 'LOAN_DISTRIBUTION_ACCOUNT_DRCR'
7530 AND fvl13.lookup_code(+) = l1.DISTRIBUTION_TYPE
7531 AND fvl13.view_application_id(+) = 206
7532 AND fvl13.language(+) = USERENV('LANG')
7533
7534 )
7535 ;
7536 --
7537 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
7538
7539 trace
7540 (p_msg => 'number of line sources inserted = '||SQL%ROWCOUNT
7541 ,p_level => C_LEVEL_STATEMENT
7542 ,p_module => l_log_module);
7543
7544 END IF;
7545
7546
7550 ,p_level => C_LEVEL_PROCEDURE
7547 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7548 trace
7549 (p_msg => 'END of insert_sources_16'
7551 ,p_module => l_log_module);
7552 END IF;
7553 EXCEPTION
7554 WHEN xla_exceptions_pkg.application_exception THEN
7555 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
7556 trace
7557 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
7558 ,p_level => C_LEVEL_EXCEPTION
7559 ,p_module => l_log_module);
7560 END IF;
7561 RAISE;
7562 WHEN OTHERS THEN
7563 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
7564 trace
7565 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
7566 ,p_level => C_LEVEL_EXCEPTION
7567 ,p_module => l_log_module);
7568 END IF;
7569 xla_exceptions_pkg.raise_message
7570 (p_location => 'XLA_00206_AAD_S_000004_BC_PKG.insert_sources_16');
7571 END insert_sources_16;
7572 --
7573
7574 ---------------------------------------
7575 --
7576 -- PRIVATE FUNCTION
7577 -- EventType_16
7578 --
7579 ----------------------------------------
7580 --
7581 FUNCTION EventType_16
7582 (p_application_id IN NUMBER
7583 ,p_base_ledger_id IN NUMBER
7584 ,p_target_ledger_id IN NUMBER
7585 ,p_language IN VARCHAR2
7586 ,p_currency_code IN VARCHAR2
7587 ,p_sla_ledger_id IN NUMBER
7588 ,p_pad_start_date IN DATE
7589 ,p_pad_end_date IN DATE
7590 ,p_primary_ledger_id IN NUMBER)
7591 RETURN BOOLEAN IS
7592 --
7593 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'FUTURE_DISBURSEMENT_CANCELLED';
7594 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'DIRECT';
7595
7596 l_calculate_acctd_flag VARCHAR2(1) :='Y';
7597 l_calculate_g_l_flag VARCHAR2(1) :='Y';
7598 --
7599 l_array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
7600 l_array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
7601 l_array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
7602 l_array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
7603 l_array_event_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
7604 l_array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
7605 l_array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
7606 l_array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
7607 l_array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
7608 l_array_transaction_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
7609 l_array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
7610 l_array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
7611 l_array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
7612 l_array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
7613 l_array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
7614 l_array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
7615 l_array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
7616 l_array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
7617 l_array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
7618 l_array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
7619 l_array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
7620 l_array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
7621 l_array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L;
7622 l_array_budgetary_control_flag XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
7623
7624 l_event_id NUMBER;
7625 l_previous_event_id NUMBER;
7626 l_first_event_id NUMBER;
7627 l_last_event_id NUMBER;
7628
7629 l_rec_acct_attrs XLA_AE_HEADER_PKG.t_rec_acct_attrs;
7630 l_rec_rev_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
7631 --
7632 --
7633 l_result BOOLEAN := TRUE;
7634 l_rows NUMBER := 1000;
7635 l_event_type_name VARCHAR2(80) := 'Future Disbursement Cancelled';
7636 l_event_class_name VARCHAR2(80) := 'Direct Loan';
7637 l_description VARCHAR2(4000);
7638 l_transaction_reversal NUMBER;
7639 l_ae_header_id NUMBER;
7640 l_array_extract_line_num xla_ae_journal_entry_pkg.t_array_Num;
7641 l_log_module VARCHAR2(240);
7642 --
7643 l_acct_reversal_source VARCHAR2(30);
7644 l_trx_reversal_source VARCHAR2(30);
7645
7646 l_continue_with_lines BOOLEAN := TRUE;
7647 --
7648 l_acc_rev_gl_date_source DATE; -- 4262811
7649 --
7650 type t_array_event_id is table of number index by binary_integer;
7651
7652 l_rec_array_event t_rec_array_event;
7653 l_null_rec_array_event t_rec_array_event;
7654 l_array_ae_header_id xla_number_array_type;
7655 l_actual_flag VARCHAR2(1) := NULL;
7656 l_actual_gain_loss_ref VARCHAR2(30) := '#####';
7657 l_balance_type_code VARCHAR2(1) :=NULL;
7658 l_gain_or_loss_ref VARCHAR2(30) :=NULL;
7659
7660 --
7664 TYPE t_array_source_1 IS TABLE OF LNS_LOAN_HEADERS_EXT_V.LOAN_CLASS_CODE%TYPE INDEX BY BINARY_INTEGER;
7661 TYPE t_array_lookup_meaning IS TABLE OF fnd_lookup_values.meaning%TYPE INDEX BY BINARY_INTEGER;
7662 --
7663
7665 TYPE t_array_source_2 IS TABLE OF LNS_LOAN_HEADERS_EXT_V.LOAN_TYPE%TYPE INDEX BY BINARY_INTEGER;
7666 TYPE t_array_source_3 IS TABLE OF LNS_LOAN_HEADERS_EXT_V.LOAN_NUMBER%TYPE INDEX BY BINARY_INTEGER;
7667 TYPE t_array_source_15 IS TABLE OF LNS_LOAN_HEADERS_EXT_V.LOAN_CURRENCY%TYPE INDEX BY BINARY_INTEGER;
7668 TYPE t_array_source_16 IS TABLE OF LNS_LOAN_HEADERS_EXT_V.EXCHANGE_DATE%TYPE INDEX BY BINARY_INTEGER;
7669 TYPE t_array_source_17 IS TABLE OF LNS_LOAN_HEADERS_EXT_V.EXCHANGE_RATE%TYPE INDEX BY BINARY_INTEGER;
7670 TYPE t_array_source_18 IS TABLE OF LNS_LOAN_HEADERS_EXT_V.EXCHANGE_RATE_TYPE%TYPE INDEX BY BINARY_INTEGER;
7671 TYPE t_array_source_19 IS TABLE OF LNS_LOAN_HEADERS_EXT_V.SUBSIDY_COST%TYPE INDEX BY BINARY_INTEGER;
7672 TYPE t_array_source_20 IS TABLE OF LNS_LOAN_HEADERS_EXT_V.GL_DATE%TYPE INDEX BY BINARY_INTEGER;
7673
7674 TYPE t_array_source_4 IS TABLE OF LNS_LOAN_DETAILS_EXT_V.ACCOUNT_NAME%TYPE INDEX BY BINARY_INTEGER;
7675 TYPE t_array_source_5 IS TABLE OF LNS_LOAN_DETAILS_EXT_V.DERIVED_PROGRAM_ACCOUNT_BSV%TYPE INDEX BY BINARY_INTEGER;
7676 TYPE t_array_source_6 IS TABLE OF LNS_LOAN_DETAILS_EXT_V.CODE_COMBINATION_ID%TYPE INDEX BY BINARY_INTEGER;
7677 TYPE t_array_source_7 IS TABLE OF LNS_LOAN_DETAILS_EXT_V.LINE_TYPE%TYPE INDEX BY BINARY_INTEGER;
7678 TYPE t_array_source_8 IS TABLE OF LNS_LOAN_DETAILS_EXT_V.ACCOUNT_TYPE%TYPE INDEX BY BINARY_INTEGER;
7679 TYPE t_array_source_9 IS TABLE OF LNS_LOAN_DETAILS_EXT_V.EVENT_TYPE%TYPE INDEX BY BINARY_INTEGER;
7680 TYPE t_array_source_12 IS TABLE OF LNS_LOAN_DETAILS_EXT_V.DISTRIBUTION_ID%TYPE INDEX BY BINARY_INTEGER;
7681 TYPE t_array_source_13 IS TABLE OF LNS_LOAN_DETAILS_EXT_V.DISTRIBUTION_TYPE%TYPE INDEX BY BINARY_INTEGER;
7682 TYPE t_array_source_14 IS TABLE OF LNS_LOAN_DETAILS_EXT_V.DISTRIBUTION_AMOUNT%TYPE INDEX BY BINARY_INTEGER;
7683
7684 l_array_source_1 t_array_source_1;
7685 l_array_source_1_meaning t_array_lookup_meaning;
7686 l_array_source_2 t_array_source_2;
7687 l_array_source_3 t_array_source_3;
7688 l_array_source_15 t_array_source_15;
7689 l_array_source_15_meaning t_array_lookup_meaning;
7690 l_array_source_16 t_array_source_16;
7691 l_array_source_17 t_array_source_17;
7692 l_array_source_18 t_array_source_18;
7693 l_array_source_19 t_array_source_19;
7694 l_array_source_20 t_array_source_20;
7695
7696 l_array_source_4 t_array_source_4;
7697 l_array_source_4_meaning t_array_lookup_meaning;
7698 l_array_source_5 t_array_source_5;
7699 l_array_source_6 t_array_source_6;
7700 l_array_source_7 t_array_source_7;
7701 l_array_source_8 t_array_source_8;
7702 l_array_source_8_meaning t_array_lookup_meaning;
7703 l_array_source_9 t_array_source_9;
7704 l_array_source_9_meaning t_array_lookup_meaning;
7705 l_array_source_12 t_array_source_12;
7706 l_array_source_13 t_array_source_13;
7707 l_array_source_13_meaning t_array_lookup_meaning;
7708 l_array_source_14 t_array_source_14;
7709
7710 --
7711 CURSOR header_cur
7712 IS
7713 SELECT /*+ leading(xet) cardinality(xet,1) */
7714 -- Event Type Code: FUTURE_DISBURSEMENT_CANCELLED
7715 -- Event Class Code: DIRECT
7716 xet.entity_id
7717 , xet.legal_entity_id
7718 , xet.entity_code
7719 , xet.transaction_number
7720 , xet.event_id
7721 , xet.event_class_code
7722 , xet.event_type_code
7723 , xet.event_number
7724 , xet.event_date
7725 , xet.transaction_date
7726 , xet.reference_num_1
7727 , xet.reference_num_2
7728 , xet.reference_num_3
7729 , xet.reference_num_4
7730 , xet.reference_char_1
7731 , xet.reference_char_2
7732 , xet.reference_char_3
7733 , xet.reference_char_4
7734 , xet.reference_date_1
7735 , xet.reference_date_2
7736 , xet.reference_date_3
7737 , xet.reference_date_4
7738 , xet.event_created_by
7739 , xet.budgetary_control_flag
7740 , h2.LOAN_CLASS_CODE source_1
7741 , fvl1.meaning source_1_meaning
7742 , h2.LOAN_TYPE source_2
7743 , h2.LOAN_NUMBER source_3
7744 , h2.LOAN_CURRENCY source_15
7745 , fvl15.meaning source_15_meaning
7746 , h2.EXCHANGE_DATE source_16
7747 , h2.EXCHANGE_RATE source_17
7748 , h2.EXCHANGE_RATE_TYPE source_18
7749 , h2.SUBSIDY_COST source_19
7750 , h2.GL_DATE source_20
7751 FROM xla_events_gt xet
7752 , LNS_LOAN_HEADERS_EXT_V h2
7753 , fnd_lookup_values fvl1
7754 , fnd_lookup_values fvl15
7755 WHERE xet.event_date between p_pad_start_date and p_pad_end_date
7756 and xet.event_type_code = C_EVENT_TYPE_CODE
7757 and xet.event_status_code <> 'N' AND h2.event_id = xet.event_id
7758 AND fvl1.lookup_type(+) = 'LOAN_CLASS'
7759 AND fvl1.lookup_code(+) = h2.LOAN_CLASS_CODE
7760 AND fvl1.view_application_id(+) = 206
7761 AND fvl1.language(+) = USERENV('LANG')
7762 AND fvl15.lookup_type(+) = 'CURRENCY_CODE'
7763 AND fvl15.lookup_code(+) = h2.LOAN_CURRENCY
7764 AND fvl15.view_application_id(+) = 101
7765 AND fvl15.language(+) = USERENV('LANG')
7766
7767 ORDER BY event_id
7768 ;
7769
7770
7771 --
7772 CURSOR line_cur (x_first_event_id in number, x_last_event_id in number)
7773 IS
7774 SELECT /*+ leading(xet) cardinality(xet,1) */
7778 ,xet.legal_entity_id
7775 -- Event Type Code: FUTURE_DISBURSEMENT_CANCELLED
7776 -- Event Class Code: DIRECT
7777 xet.entity_id
7779 ,xet.entity_code
7780 ,xet.transaction_number
7781 ,xet.event_id
7782 ,xet.event_class_code
7783 ,xet.event_type_code
7784 ,xet.event_number
7785 ,xet.event_date
7786 ,xet.transaction_date
7787 ,xet.reference_num_1
7788 ,xet.reference_num_2
7789 ,xet.reference_num_3
7790 ,xet.reference_num_4
7791 ,xet.reference_char_1
7792 ,xet.reference_char_2
7793 ,xet.reference_char_3
7794 ,xet.reference_char_4
7795 ,xet.reference_date_1
7796 ,xet.reference_date_2
7797 ,xet.reference_date_3
7798 ,xet.reference_date_4
7799 ,xet.event_created_by
7800 ,xet.budgetary_control_flag , l1.LINE_NUMBER
7801 , l1.ACCOUNT_NAME source_4
7802 , fvl4.meaning source_4_meaning
7803 , l1.DERIVED_PROGRAM_ACCOUNT_BSV source_5
7804 , l1.CODE_COMBINATION_ID source_6
7805 , l1.LINE_TYPE source_7
7806 , l1.ACCOUNT_TYPE source_8
7807 , fvl8.meaning source_8_meaning
7808 , l1.EVENT_TYPE source_9
7809 , fvl9.meaning source_9_meaning
7810 , l1.DISTRIBUTION_ID source_12
7811 , l1.DISTRIBUTION_TYPE source_13
7812 , fvl13.meaning source_13_meaning
7813 , l1.DISTRIBUTION_AMOUNT source_14
7814 FROM xla_events_gt xet
7815 , LNS_LOAN_DETAILS_EXT_V l1
7816 , fnd_lookup_values fvl4
7817 , fnd_lookup_values fvl8
7818 , fnd_lookup_values fvl9
7819 , fnd_lookup_values fvl13
7820 WHERE xet.event_id between x_first_event_id and x_last_event_id
7821 and xet.event_date between p_pad_start_date and p_pad_end_date
7822 and xet.event_type_code = C_EVENT_TYPE_CODE
7823 and xet.event_status_code <> 'N' AND l1.event_id = xet.event_id
7824 AND fvl4.lookup_type(+) = 'LOAN_DISTRIBUTION_ACCOUNTS'
7825 AND fvl4.lookup_code(+) = l1.ACCOUNT_NAME
7826 AND fvl4.view_application_id(+) = 206
7827 AND fvl4.language(+) = USERENV('LANG')
7828 AND fvl8.lookup_type(+) = 'LOAN_DISTRIBUTION_ACCOUNT_DRCR'
7829 AND fvl8.lookup_code(+) = l1.ACCOUNT_TYPE
7830 AND fvl8.view_application_id(+) = 206
7831 AND fvl8.language(+) = USERENV('LANG')
7832 AND fvl9.lookup_type(+) = 'LOAN_ACCOUNTING_EVENT'
7833 AND fvl9.lookup_code(+) = l1.EVENT_TYPE
7834 AND fvl9.view_application_id(+) = 206
7835 AND fvl9.language(+) = USERENV('LANG')
7836 AND fvl13.lookup_type(+) = 'LOAN_DISTRIBUTION_ACCOUNT_DRCR'
7837 AND fvl13.lookup_code(+) = l1.DISTRIBUTION_TYPE
7838 AND fvl13.view_application_id(+) = 206
7839 AND fvl13.language(+) = USERENV('LANG')
7840 ;
7841
7842 --
7843 BEGIN
7844 IF g_log_enabled THEN
7845 l_log_module := C_DEFAULT_MODULE||'.EventType_16';
7846 END IF;
7847 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7848 trace
7849 (p_msg => 'BEGIN of EventType_16'
7850 ,p_level => C_LEVEL_PROCEDURE
7851 ,p_module => l_log_module);
7852 END IF;
7853
7854 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
7855 trace
7856 (p_msg => 'p_application_id = '||p_application_id||
7857 ' - p_base_ledger_id = '||p_base_ledger_id||
7858 ' - p_target_ledger_id = '||p_target_ledger_id||
7859 ' - p_language = '||p_language||
7860 ' - p_currency_code = '||p_currency_code||
7861 ' - p_sla_ledger_id = '||p_sla_ledger_id
7862 ,p_level => C_LEVEL_STATEMENT
7863 ,p_module => l_log_module);
7864 END IF;
7865 --
7866 -- initialze arrays
7867 --
7868 g_array_event.DELETE;
7869 l_rec_array_event := l_null_rec_array_event;
7870 --
7871 --------------------------------------
7872 -- 4262811 Initialze MPA Line Number
7873 --------------------------------------
7874 XLA_AE_HEADER_PKG.g_mpa_line_num := 0;
7875
7876 --
7877
7878 --
7879 OPEN header_cur;
7880 --
7881 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
7882 trace
7883 (p_msg => 'SQL - FETCH header_cur'
7884 ,p_level => C_LEVEL_STATEMENT
7885 ,p_module => l_log_module);
7886 END IF;
7887 --
7888 LOOP
7889 FETCH header_cur BULK COLLECT INTO
7890 l_array_entity_id
7891 , l_array_legal_entity_id
7892 , l_array_entity_code
7893 , l_array_transaction_num
7894 , l_array_event_id
7895 , l_array_class_code
7896 , l_array_event_type
7897 , l_array_event_number
7898 , l_array_event_date
7899 , l_array_transaction_date
7900 , l_array_reference_num_1
7901 , l_array_reference_num_2
7902 , l_array_reference_num_3
7903 , l_array_reference_num_4
7904 , l_array_reference_char_1
7905 , l_array_reference_char_2
7906 , l_array_reference_char_3
7907 , l_array_reference_char_4
7908 , l_array_reference_date_1
7909 , l_array_reference_date_2
7910 , l_array_reference_date_3
7911 , l_array_reference_date_4
7912 , l_array_event_created_by
7913 , l_array_budgetary_control_flag
7914 , l_array_source_1
7915 , l_array_source_1_meaning
7916 , l_array_source_2
7917 , l_array_source_3
7921 , l_array_source_17
7918 , l_array_source_15
7919 , l_array_source_15_meaning
7920 , l_array_source_16
7922 , l_array_source_18
7923 , l_array_source_19
7924 , l_array_source_20
7925 LIMIT l_rows;
7926 --
7927 IF (C_LEVEL_EVENT >= g_log_level) THEN
7928 trace
7929 (p_msg => '# rows extracted from header extract objects = '||TO_CHAR(header_cur%ROWCOUNT)
7930 ,p_level => C_LEVEL_EVENT
7931 ,p_module => l_log_module);
7932 END IF;
7933 --
7934 EXIT WHEN l_array_entity_id.COUNT = 0;
7935
7936 -- initialize arrays
7937 XLA_AE_HEADER_PKG.g_rec_header_new := NULL;
7938 XLA_AE_LINES_PKG.g_rec_lines := NULL;
7939
7940 --
7941 -- Bug 4458708
7942 --
7943 XLA_AE_LINES_PKG.g_LineNumber := 0;
7944
7945
7946 -- 4262811 - when creating Accrual Reversal or MPA, use g_last_hdr_idx to increment for next header id
7947 g_last_hdr_idx := l_array_event_id.LAST;
7948 --
7949 -- loop for the headers. Each iteration is for each header extract row
7950 -- fetched in header cursor
7951 --
7952 FOR hdr_idx IN l_array_event_id.FIRST .. l_array_event_id.LAST LOOP
7953
7954 --
7955 -- set event info as cache for other routines to refer event attributes
7956 --
7957 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
7958 (p_application_id => p_application_id
7959 ,p_primary_ledger_id => p_primary_ledger_id
7960 ,p_base_ledger_id => p_base_ledger_id
7961 ,p_target_ledger_id => p_target_ledger_id
7962 ,p_entity_id => l_array_entity_id(hdr_idx)
7963 ,p_legal_entity_id => l_array_legal_entity_id(hdr_idx)
7964 ,p_entity_code => l_array_entity_code(hdr_idx)
7965 ,p_transaction_num => l_array_transaction_num(hdr_idx)
7966 ,p_event_id => l_array_event_id(hdr_idx)
7967 ,p_event_class_code => l_array_class_code(hdr_idx)
7968 ,p_event_type_code => l_array_event_type(hdr_idx)
7969 ,p_event_number => l_array_event_number(hdr_idx)
7970 ,p_event_date => l_array_event_date(hdr_idx)
7971 ,p_transaction_date => l_array_transaction_date(hdr_idx)
7972 ,p_reference_num_1 => l_array_reference_num_1(hdr_idx)
7973 ,p_reference_num_2 => l_array_reference_num_2(hdr_idx)
7974 ,p_reference_num_3 => l_array_reference_num_3(hdr_idx)
7975 ,p_reference_num_4 => l_array_reference_num_4(hdr_idx)
7976 ,p_reference_char_1 => l_array_reference_char_1(hdr_idx)
7977 ,p_reference_char_2 => l_array_reference_char_2(hdr_idx)
7978 ,p_reference_char_3 => l_array_reference_char_3(hdr_idx)
7979 ,p_reference_char_4 => l_array_reference_char_4(hdr_idx)
7980 ,p_reference_date_1 => l_array_reference_date_1(hdr_idx)
7981 ,p_reference_date_2 => l_array_reference_date_2(hdr_idx)
7982 ,p_reference_date_3 => l_array_reference_date_3(hdr_idx)
7983 ,p_reference_date_4 => l_array_reference_date_4(hdr_idx)
7984 ,p_event_created_by => l_array_event_created_by(hdr_idx)
7985 ,p_budgetary_control_flag => l_array_budgetary_control_flag(hdr_idx));
7986
7987 --
7988 -- set the status of entry to C_VALID (0)
7989 --
7990 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
7991
7992 --
7993 -- initialize a row for ae header
7994 --
7995 XLA_AE_HEADER_PKG.InitHeader(hdr_idx);
7996
7997 l_event_id := l_array_event_id(hdr_idx);
7998
7999 --
8000 -- storing the hdr_idx for event. May be used by line cursor.
8001 --
8002 g_array_event(l_event_id).array_value_num('header_index') := hdr_idx;
8003
8004 --
8005 -- store sources from header extract. This can be improved to
8006 -- store only those sources from header extract that may be used in lines
8007 --
8008
8009 g_array_event(l_event_id).array_value_char('source_1') := l_array_source_1(hdr_idx);
8010 g_array_event(l_event_id).array_value_char('source_1_meaning') := l_array_source_1_meaning(hdr_idx);
8011 g_array_event(l_event_id).array_value_char('source_2') := l_array_source_2(hdr_idx);
8012 g_array_event(l_event_id).array_value_char('source_3') := l_array_source_3(hdr_idx);
8013 g_array_event(l_event_id).array_value_char('source_15') := l_array_source_15(hdr_idx);
8014 g_array_event(l_event_id).array_value_char('source_15_meaning') := l_array_source_15_meaning(hdr_idx);
8015 g_array_event(l_event_id).array_value_date('source_16') := l_array_source_16(hdr_idx);
8016 g_array_event(l_event_id).array_value_num('source_17') := l_array_source_17(hdr_idx);
8017 g_array_event(l_event_id).array_value_char('source_18') := l_array_source_18(hdr_idx);
8018 g_array_event(l_event_id).array_value_num('source_19') := l_array_source_19(hdr_idx);
8019 g_array_event(l_event_id).array_value_date('source_20') := l_array_source_20(hdr_idx);
8020
8021 --
8022 -- initilaize the status of ae headers for diffrent balance types
8023 -- the status is initialised to C_NOT_CREATED (2)
8024 --
8025 --g_array_event(l_event_id).array_value_num('actual_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
8026 --g_array_event(l_event_id).array_value_num('budget_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
8027 --g_array_event(l_event_id).array_value_num('encumbrance_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
8028
8029 --
8030 -- call api to validate and store accounting attributes for header
8031 --
8032
8033 ------------------------------------------------------------
8037
8034 -- Accrual Reversal : to get date for Standard Source (NONE)
8035 ------------------------------------------------------------
8036 l_acc_rev_gl_date_source := NULL;
8038 l_rec_acct_attrs.array_acct_attr_code(1) := 'GL_DATE';
8039 l_rec_acct_attrs.array_date_value(1) := g_array_event(l_event_id).array_value_date('source_20');
8040
8041
8042 XLA_AE_HEADER_PKG.SetHdrAcctAttrs(l_rec_acct_attrs);
8043
8044 XLA_AE_HEADER_PKG.SetJeCategoryName;
8045
8046 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_type_code(hdr_idx) := l_array_event_type(hdr_idx);
8047 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_id(hdr_idx) := l_array_event_id(hdr_idx);
8048 XLA_AE_HEADER_PKG.g_rec_header_new.array_entity_id(hdr_idx) := l_array_entity_id(hdr_idx);
8049 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_number(hdr_idx) := l_array_event_number(hdr_idx);
8050 XLA_AE_HEADER_PKG.g_rec_header_new.array_target_ledger_id(hdr_idx) := p_target_ledger_id;
8051
8052
8053 --
8054 xla_ae_header_pkg.SetHdrDescription(
8055 p_description => Description_1 (
8056 p_application_id => p_application_id
8057 , p_source_1 => g_array_event(l_event_id).array_value_char('source_1')
8058 , p_source_1_meaning => g_array_event(l_event_id).array_value_char('source_1_meaning')
8059 , p_source_2 => g_array_event(l_event_id).array_value_char('source_2')
8060 , p_source_3 => g_array_event(l_event_id).array_value_char('source_3')
8061 )
8062 );
8063 --
8064
8065 -- No header level analytical criteria
8066
8067 --
8068 --accounting attribute enhancement, bug 3612931
8069 --
8070 l_trx_reversal_source := SUBSTR(NULL, 1,30);
8071
8072 IF NVL(l_trx_reversal_source, 'N') NOT IN ('N','Y') THEN
8073 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
8074
8075 xla_accounting_err_pkg.build_message
8076 (p_appli_s_name => 'XLA'
8077 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
8078 ,p_token_1 => 'ACCT_ATTR_NAME'
8079 ,p_value_1 => xla_ae_sources_pkg.GetAccountingSourceName('TRX_ACCT_REVERSAL_OPTION')
8080 ,p_token_2 => 'PRODUCT_NAME'
8081 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
8082 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
8083 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
8084 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
8085
8086 ELSIF NVL(l_trx_reversal_source, 'N') = 'Y' THEN
8087 --
8088 -- following sets the accounting attributes needed to reverse
8089 -- accounting for a distributeion
8090 --
8091 xla_ae_lines_pkg.SetTrxReversalAttrs
8092 (p_event_id => l_event_id
8093 ,p_gl_date => XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(hdr_idx)
8094 ,p_trx_reversal_source => l_trx_reversal_source);
8095
8096 END IF;
8097
8098
8099 ----------------------------------------------------------------
8100 -- 4262811 - update the header statuses to invalid in need be
8101 ----------------------------------------------------------------
8102 --
8103 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus (p_hdr_idx => hdr_idx);
8104
8105
8106 -----------------------------------------------
8107 -- No accrual reversal for the event class/type
8108 -----------------------------------------------
8109 ----------------------------------------------------------------
8110
8111 --
8112 -- this ends the header loop iteration for one bulk fetch
8113 --
8114 END LOOP;
8115
8116 l_first_event_id := l_array_event_id(l_array_event_id.FIRST);
8117 l_last_event_id := l_array_event_id(l_array_event_id.LAST);
8118
8119 --
8120 -- insert dummy rows into lines gt table that were created due to
8121 -- transaction reversals
8122 --
8123 IF XLA_AE_LINES_PKG.g_rec_lines.array_ae_header_id.COUNT > 0 THEN
8124 l_result := XLA_AE_LINES_PKG.InsertLines;
8125 END IF;
8126
8127 --
8128 -- reset the temp_line_num for each set of events fetched from header
8129 -- cursor rather than doing it for each new event in line cursor
8130 -- Bug 3939231
8131 --
8132 xla_ae_lines_pkg.g_temp_line_num := 0;
8133
8134
8135
8136 --
8137 OPEN line_cur(x_first_event_id => l_first_event_id, x_last_event_id => l_last_event_id);
8138 --
8139 --
8140 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
8141
8142 trace
8143 (p_msg => 'SQL - FETCH line_cur'
8144 ,p_level => C_LEVEL_STATEMENT
8145 ,p_module => l_log_module);
8146
8147 END IF;
8148 --
8149 --
8150 LOOP
8151 --
8152 FETCH line_cur BULK COLLECT INTO
8153 l_array_entity_id
8154 , l_array_legal_entity_id
8155 , l_array_entity_code
8156 , l_array_transaction_num
8157 , l_array_event_id
8158 , l_array_class_code
8159 , l_array_event_type
8160 , l_array_event_number
8161 , l_array_event_date
8162 , l_array_transaction_date
8163 , l_array_reference_num_1
8164 , l_array_reference_num_2
8165 , l_array_reference_num_3
8166 , l_array_reference_num_4
8167 , l_array_reference_char_1
8168 , l_array_reference_char_2
8169 , l_array_reference_char_3
8170 , l_array_reference_char_4
8171 , l_array_reference_date_1
8172 , l_array_reference_date_2
8173 , l_array_reference_date_3
8177 , l_array_extract_line_num
8174 , l_array_reference_date_4
8175 , l_array_event_created_by
8176 , l_array_budgetary_control_flag
8178 , l_array_source_4
8179 , l_array_source_4_meaning
8180 , l_array_source_5
8181 , l_array_source_6
8182 , l_array_source_7
8183 , l_array_source_8
8184 , l_array_source_8_meaning
8185 , l_array_source_9
8186 , l_array_source_9_meaning
8187 , l_array_source_12
8188 , l_array_source_13
8189 , l_array_source_13_meaning
8190 , l_array_source_14
8191 LIMIT l_rows;
8192
8193 --
8194 IF (C_LEVEL_EVENT >= g_log_level) THEN
8195 trace
8196 (p_msg => '# rows extracted from line extract objects = '||TO_CHAR(line_cur%ROWCOUNT)
8197 ,p_level => C_LEVEL_EVENT
8198 ,p_module => l_log_module);
8199 END IF;
8200 --
8201 EXIT WHEN l_array_entity_id.count = 0;
8202
8203 XLA_AE_LINES_PKG.g_rec_lines := null;
8204
8205 --
8206 -- Bug 4458708
8207 --
8208 XLA_AE_LINES_PKG.g_LineNumber := 0;
8209 --
8210 --
8211
8212 FOR Idx IN 1..l_array_event_id.count LOOP
8213 --
8214 -- 5648433 (move l_event_id out of IF statement) set l_event_id to be used inside IF condition
8215 --
8216 l_event_id := l_array_event_id(idx); -- 5648433
8217
8218 --
8219 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
8220 --
8221
8222 IF NVL(xla_ae_header_pkg.g_rec_header_new.array_trx_acct_reversal_option
8223 (g_array_event(l_event_id).array_value_num('header_index'))
8224 ,'N'
8225 ) <> 'Y'
8226 THEN
8227 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
8228 trace
8229 (p_msg => 'Trancaction revesal option is not Y '
8230 ,p_level => C_LEVEL_STATEMENT
8231 ,p_module => l_log_module);
8232 END IF;
8233
8234 --
8235 -- set the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
8236 --
8237 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
8238 --
8239 -- set event info as cache for other routines to refer event attributes
8240 --
8241
8242 IF l_event_id <> NVL(l_previous_event_id, -1) THEN
8243 l_previous_event_id := l_event_id;
8244
8245 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
8246 (p_application_id => p_application_id
8247 ,p_primary_ledger_id => p_primary_ledger_id
8248 ,p_base_ledger_id => p_base_ledger_id
8249 ,p_target_ledger_id => p_target_ledger_id
8250 ,p_entity_id => l_array_entity_id(Idx)
8251 ,p_legal_entity_id => l_array_legal_entity_id(Idx)
8252 ,p_entity_code => l_array_entity_code(Idx)
8253 ,p_transaction_num => l_array_transaction_num(Idx)
8254 ,p_event_id => l_array_event_id(Idx)
8255 ,p_event_class_code => l_array_class_code(Idx)
8256 ,p_event_type_code => l_array_event_type(Idx)
8257 ,p_event_number => l_array_event_number(Idx)
8258 ,p_event_date => l_array_event_date(Idx)
8259 ,p_transaction_date => l_array_transaction_date(Idx)
8260 ,p_reference_num_1 => l_array_reference_num_1(Idx)
8261 ,p_reference_num_2 => l_array_reference_num_2(Idx)
8262 ,p_reference_num_3 => l_array_reference_num_3(Idx)
8263 ,p_reference_num_4 => l_array_reference_num_4(Idx)
8264 ,p_reference_char_1 => l_array_reference_char_1(Idx)
8265 ,p_reference_char_2 => l_array_reference_char_2(Idx)
8266 ,p_reference_char_3 => l_array_reference_char_3(Idx)
8267 ,p_reference_char_4 => l_array_reference_char_4(Idx)
8268 ,p_reference_date_1 => l_array_reference_date_1(Idx)
8269 ,p_reference_date_2 => l_array_reference_date_2(Idx)
8270 ,p_reference_date_3 => l_array_reference_date_3(Idx)
8271 ,p_reference_date_4 => l_array_reference_date_4(Idx)
8272 ,p_event_created_by => l_array_event_created_by(Idx)
8273 ,p_budgetary_control_flag => l_array_budgetary_control_flag(Idx));
8274 --
8275 END IF;
8276
8277
8278
8279 --
8280 xla_ae_lines_pkg.SetExtractLine(p_extract_line => l_array_extract_line_num(Idx));
8281
8282 l_acct_reversal_source := SUBSTR(NULL, 1,30);
8283
8284 IF l_continue_with_lines THEN
8285 IF NVL(l_acct_reversal_source, 'N') NOT IN ('N','Y','B') THEN
8286 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
8287
8288 xla_accounting_err_pkg.build_message
8289 (p_appli_s_name => 'XLA'
8290 ,p_msg_name => 'XLA_AP_INVALID_REVERSAL_OPTION'
8291 ,p_token_1 => 'LINE_NUMBER'
8292 ,p_value_1 => l_array_extract_line_num(Idx)
8293 ,p_token_2 => 'PRODUCT_NAME'
8294 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
8295 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
8296 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
8297 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
8298
8302 -- accounting for a distributeion
8299 ELSIF NVL(l_acct_reversal_source, 'N') IN ('Y','B') THEN
8300 --
8301 -- following sets the accounting attributes needed to reverse
8303 --
8304
8305 --
8306 -- 5217187
8307 --
8308 l_rec_rev_acct_attrs.array_acct_attr_code(1):= 'GL_DATE';
8309 l_rec_rev_acct_attrs.array_date_value(1) := XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(
8310 g_array_event(l_event_id).array_value_num('header_index'));
8311 --
8312 --
8313
8314 -- No reversal code generated
8315
8316 xla_ae_lines_pkg.SetAcctReversalAttrs
8317 (p_event_id => l_event_id
8318 ,p_rec_acct_attrs => l_rec_rev_acct_attrs
8319 ,p_calculate_acctd_flag => l_calculate_acctd_flag
8320 ,p_calculate_g_l_flag => l_calculate_g_l_flag);
8321 END IF;
8322
8323 IF NVL(l_acct_reversal_source, 'N') IN ('N','B') THEN
8324 l_actual_flag := NULL; l_actual_gain_loss_ref := '#####';
8325
8326 --
8327 AcctLineType_8 (
8328 p_application_id => p_application_id
8329 ,p_event_id => l_event_id
8330 ,p_calculate_acctd_flag => l_calculate_acctd_flag
8331 ,p_calculate_g_l_flag => l_calculate_g_l_flag
8332 ,p_actual_flag => l_actual_flag
8333 ,p_balance_type_code => l_balance_type_code
8334 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
8335
8336 , p_source_4 => l_array_source_4(Idx)
8337 , p_source_4_meaning => l_array_source_4_meaning(Idx)
8338 , p_source_5 => l_array_source_5(Idx)
8339 , p_source_6 => l_array_source_6(Idx)
8340 , p_source_7 => l_array_source_7(Idx)
8341 , p_source_8 => l_array_source_8(Idx)
8342 , p_source_8_meaning => l_array_source_8_meaning(Idx)
8343 , p_source_9 => l_array_source_9(Idx)
8344 , p_source_9_meaning => l_array_source_9_meaning(Idx)
8345 , p_source_12 => l_array_source_12(Idx)
8346 , p_source_13 => l_array_source_13(Idx)
8347 , p_source_13_meaning => l_array_source_13_meaning(Idx)
8348 , p_source_14 => l_array_source_14(Idx)
8349 , p_source_15 => g_array_event(l_event_id).array_value_char('source_15')
8350 , p_source_15_meaning => g_array_event(l_event_id).array_value_char('source_15_meaning')
8351 , p_source_16 => g_array_event(l_event_id).array_value_date('source_16')
8352 , p_source_17 => g_array_event(l_event_id).array_value_num('source_17')
8353 , p_source_18 => g_array_event(l_event_id).array_value_char('source_18')
8354 , p_source_19 => g_array_event(l_event_id).array_value_num('source_19')
8355 );
8356 If(l_balance_type_code = 'A') THEN
8357 l_actual_gain_loss_ref := l_gain_or_loss_ref;
8358 END IF;
8359
8360 --
8361
8362
8363 --
8364 AcctLineType_10 (
8365 p_application_id => p_application_id
8366 ,p_event_id => l_event_id
8367 ,p_calculate_acctd_flag => l_calculate_acctd_flag
8368 ,p_calculate_g_l_flag => l_calculate_g_l_flag
8369 ,p_actual_flag => l_actual_flag
8370 ,p_balance_type_code => l_balance_type_code
8371 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
8372
8373 , p_source_4 => l_array_source_4(Idx)
8374 , p_source_4_meaning => l_array_source_4_meaning(Idx)
8375 , p_source_5 => l_array_source_5(Idx)
8376 , p_source_6 => l_array_source_6(Idx)
8377 , p_source_7 => l_array_source_7(Idx)
8378 , p_source_8 => l_array_source_8(Idx)
8379 , p_source_8_meaning => l_array_source_8_meaning(Idx)
8380 , p_source_9 => l_array_source_9(Idx)
8381 , p_source_9_meaning => l_array_source_9_meaning(Idx)
8382 , p_source_12 => l_array_source_12(Idx)
8383 , p_source_13 => l_array_source_13(Idx)
8384 , p_source_13_meaning => l_array_source_13_meaning(Idx)
8385 , p_source_14 => l_array_source_14(Idx)
8386 , p_source_15 => g_array_event(l_event_id).array_value_char('source_15')
8387 , p_source_15_meaning => g_array_event(l_event_id).array_value_char('source_15_meaning')
8388 , p_source_16 => g_array_event(l_event_id).array_value_date('source_16')
8389 , p_source_17 => g_array_event(l_event_id).array_value_num('source_17')
8390 , p_source_18 => g_array_event(l_event_id).array_value_char('source_18')
8391 , p_source_19 => g_array_event(l_event_id).array_value_num('source_19')
8392 );
8393 If(l_balance_type_code = 'A') THEN
8394 l_actual_gain_loss_ref := l_gain_or_loss_ref;
8395 END IF;
8396
8397 --
8398
8399
8400 --
8401 AcctLineType_12 (
8402 p_application_id => p_application_id
8403 ,p_event_id => l_event_id
8404 ,p_calculate_acctd_flag => l_calculate_acctd_flag
8405 ,p_calculate_g_l_flag => l_calculate_g_l_flag
8406 ,p_actual_flag => l_actual_flag
8407 ,p_balance_type_code => l_balance_type_code
8408 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
8409
8410 , p_source_4 => l_array_source_4(Idx)
8411 , p_source_4_meaning => l_array_source_4_meaning(Idx)
8412 , p_source_6 => l_array_source_6(Idx)
8413 , p_source_7 => l_array_source_7(Idx)
8414 , p_source_8 => l_array_source_8(Idx)
8415 , p_source_8_meaning => l_array_source_8_meaning(Idx)
8416 , p_source_9 => l_array_source_9(Idx)
8417 , p_source_9_meaning => l_array_source_9_meaning(Idx)
8418 , p_source_12 => l_array_source_12(Idx)
8419 , p_source_13 => l_array_source_13(Idx)
8420 , p_source_13_meaning => l_array_source_13_meaning(Idx)
8421 , p_source_14 => l_array_source_14(Idx)
8422 , p_source_15 => g_array_event(l_event_id).array_value_char('source_15')
8423 , p_source_15_meaning => g_array_event(l_event_id).array_value_char('source_15_meaning')
8427 , p_source_19 => g_array_event(l_event_id).array_value_num('source_19')
8424 , p_source_16 => g_array_event(l_event_id).array_value_date('source_16')
8425 , p_source_17 => g_array_event(l_event_id).array_value_num('source_17')
8426 , p_source_18 => g_array_event(l_event_id).array_value_char('source_18')
8428 );
8429 If(l_balance_type_code = 'A') THEN
8430 l_actual_gain_loss_ref := l_gain_or_loss_ref;
8431 END IF;
8432
8433 --
8434
8435
8436 --
8437 AcctLineType_14 (
8438 p_application_id => p_application_id
8439 ,p_event_id => l_event_id
8440 ,p_calculate_acctd_flag => l_calculate_acctd_flag
8441 ,p_calculate_g_l_flag => l_calculate_g_l_flag
8442 ,p_actual_flag => l_actual_flag
8443 ,p_balance_type_code => l_balance_type_code
8444 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
8445
8446 , p_source_4 => l_array_source_4(Idx)
8447 , p_source_4_meaning => l_array_source_4_meaning(Idx)
8448 , p_source_6 => l_array_source_6(Idx)
8449 , p_source_7 => l_array_source_7(Idx)
8450 , p_source_8 => l_array_source_8(Idx)
8451 , p_source_8_meaning => l_array_source_8_meaning(Idx)
8452 , p_source_9 => l_array_source_9(Idx)
8453 , p_source_9_meaning => l_array_source_9_meaning(Idx)
8454 , p_source_12 => l_array_source_12(Idx)
8455 , p_source_13 => l_array_source_13(Idx)
8456 , p_source_13_meaning => l_array_source_13_meaning(Idx)
8457 , p_source_14 => l_array_source_14(Idx)
8458 , p_source_15 => g_array_event(l_event_id).array_value_char('source_15')
8459 , p_source_15_meaning => g_array_event(l_event_id).array_value_char('source_15_meaning')
8460 , p_source_16 => g_array_event(l_event_id).array_value_date('source_16')
8461 , p_source_17 => g_array_event(l_event_id).array_value_num('source_17')
8462 , p_source_18 => g_array_event(l_event_id).array_value_char('source_18')
8463 , p_source_19 => g_array_event(l_event_id).array_value_num('source_19')
8464 );
8465 If(l_balance_type_code = 'A') THEN
8466 l_actual_gain_loss_ref := l_gain_or_loss_ref;
8467 END IF;
8468
8469 --
8470
8471 -- only execute it if calculate g/l flag is yes, and primary or secondary ledger
8472 -- or secondary ledger that has different currency with primary
8473 -- or alc that is calculated by sla
8474 IF (((l_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
8475 (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code in ('ALC', 'SECONDARY') AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.calculate_amts_flag='Y'))
8476
8477 -- IF((l_calculate_g_l_flag='Y' or XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id <>
8478 -- XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id)
8479 AND (l_actual_flag = 'A')) THEN
8480 XLA_AE_LINES_PKG.CreateGainOrLossLines(
8481 p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
8482 ,p_application_id => p_application_id
8483 ,p_amb_context_code => 'DEFAULT'
8484 ,p_entity_code => xla_ae_journal_entry_pkg.g_cache_event.entity_code
8485 ,p_event_class_code => C_EVENT_CLASS_CODE
8486 ,p_event_type_code => C_EVENT_TYPE_CODE
8487
8488 ,p_gain_ccid => -1
8489 ,p_loss_ccid => -1
8490
8491 ,p_actual_flag => l_actual_flag
8492 ,p_enc_flag => null
8493 ,p_actual_g_l_ref => l_actual_gain_loss_ref
8494 ,p_enc_g_l_ref => null
8495 );
8496 END IF;
8497 END IF;
8498 END IF;
8499
8500 ELSE
8501 --
8502 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
8503 --
8504 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
8505 trace
8506 (p_msg => 'Trancaction revesal option is Y'
8507 ,p_level => C_LEVEL_STATEMENT
8508 ,p_module => l_log_module);
8509 END IF;
8510 END IF;
8511
8512 END LOOP;
8513 l_result := XLA_AE_LINES_PKG.InsertLines ;
8514 end loop;
8515 close line_cur;
8516
8517
8518 --
8519 -- insert headers into xla_ae_headers_gt table
8520 --
8521 l_result := XLA_AE_HEADER_PKG.InsertHeaders ;
8522
8523 -- insert into errors table here.
8524
8525 END LOOP;
8526
8527 --
8528 -- 4865292
8529 --
8530 -- Compare g_hdr_extract_count with event count in
8531 -- CreateHeadersAndLines.
8532 --
8533 g_hdr_extract_count := g_hdr_extract_count + header_cur%ROWCOUNT;
8534
8535 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
8536 trace (p_msg => '# rows extracted from header extract objects '
8537 || ' (running total): '
8538 || g_hdr_extract_count
8539 ,p_level => C_LEVEL_STATEMENT
8540 ,p_module => l_log_module);
8541 END IF;
8542
8543 CLOSE header_cur;
8544 --
8545
8546 --
8547 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8548 trace
8549 (p_msg => 'END of EventType_16'
8550 ,p_level => C_LEVEL_PROCEDURE
8551 ,p_module => l_log_module);
8552 END IF;
8553 --
8554 RETURN l_result;
8555 EXCEPTION
8556 WHEN xla_exceptions_pkg.application_exception THEN
8557
8558 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
8559
8560
8561 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
8565 xla_exceptions_pkg.raise_message
8562
8563 RAISE;
8564 WHEN OTHERS THEN
8566 (p_location => 'XLA_00206_AAD_S_000004_BC_PKG.EventType_16');
8567 END EventType_16;
8568 --
8569
8570 --
8571 --+============================================+
8572 --| |
8573 --| PRIVATE FUNCTION |
8574 --| |
8575 --+============================================+
8576 --
8577 FUNCTION CreateHeadersAndLines
8578 (p_application_id IN NUMBER
8579 ,p_base_ledger_id IN NUMBER
8580 ,p_target_ledger_id IN NUMBER
8581 ,p_pad_start_date IN DATE
8582 ,p_pad_end_date IN DATE
8583 ,p_primary_ledger_id IN NUMBER)
8584 RETURN BOOLEAN IS
8585 l_created BOOLEAN:=FALSE;
8586 l_event_id NUMBER;
8587 l_event_date DATE;
8588 l_language VARCHAR2(30);
8589 l_currency_code VARCHAR2(30);
8590 l_sla_ledger_id NUMBER;
8591 l_log_module VARCHAR2(240);
8592
8593 BEGIN
8594 --
8595 IF g_log_enabled THEN
8596 l_log_module := C_DEFAULT_MODULE||'.CreateHeadersAndLines';
8597 END IF;
8598 --
8599 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8600 trace
8601 (p_msg => 'BEGIN of CreateHeadersAndLines'
8602 ,p_level => C_LEVEL_PROCEDURE
8603 ,p_module => l_log_module);
8604 END IF;
8605
8606 l_language := xla_ae_journal_entry_pkg.g_cache_ledgers_info.description_language;
8607 l_currency_code := xla_ae_journal_entry_pkg.g_cache_ledgers_info.currency_code;
8608 l_sla_ledger_id := xla_ae_journal_entry_pkg.g_cache_ledgers_info.sla_ledger_id;
8609
8610 --
8611 -- initialize array of lines with NULL
8612 --
8613 xla_ae_lines_pkg.SetNullLine;
8614
8615 --
8616 -- initialize header extract count -- Bug 4865292
8617 --
8618 g_hdr_extract_count:= 0;
8619
8620
8621 l_created := EventType_15(
8622 p_application_id => p_application_id
8623 , p_base_ledger_id => p_base_ledger_id
8624 , p_target_ledger_id => p_target_ledger_id
8625 , p_language => l_language
8626 , p_currency_code => l_currency_code
8627 , p_sla_ledger_id => l_sla_ledger_id
8628 , p_pad_start_date => p_pad_start_date
8629 , p_pad_end_date => p_pad_end_date
8630 , p_primary_ledger_id => p_primary_ledger_id
8631 );
8632
8633
8634
8635 IF ( g_diagnostics_mode ='Y' ) THEN
8636
8637 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
8638 trace
8639 (p_msg => 'CALL Transaction Objects Diagnostics'
8640 ,p_level => C_LEVEL_STATEMENT
8641 ,p_module => l_log_module);
8642
8643 END IF;
8644
8645 insert_sources_15(
8646 p_target_ledger_id => p_target_ledger_id
8647 , p_language => l_language
8648 , p_sla_ledger_id => l_sla_ledger_id
8649 , p_pad_start_date => p_pad_start_date
8650 , p_pad_end_date => p_pad_end_date
8651 );
8652
8653 END IF;
8654
8655 l_created := EventType_16(
8656 p_application_id => p_application_id
8657 , p_base_ledger_id => p_base_ledger_id
8658 , p_target_ledger_id => p_target_ledger_id
8659 , p_language => l_language
8660 , p_currency_code => l_currency_code
8661 , p_sla_ledger_id => l_sla_ledger_id
8662 , p_pad_start_date => p_pad_start_date
8663 , p_pad_end_date => p_pad_end_date
8664 , p_primary_ledger_id => p_primary_ledger_id
8665 );
8666
8667
8668
8669 IF ( g_diagnostics_mode ='Y' ) THEN
8670
8671 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
8672 trace
8673 (p_msg => 'CALL Transaction Objects Diagnostics'
8674 ,p_level => C_LEVEL_STATEMENT
8675 ,p_module => l_log_module);
8676
8677 END IF;
8678
8679 insert_sources_16(
8680 p_target_ledger_id => p_target_ledger_id
8681 , p_language => l_language
8682 , p_sla_ledger_id => l_sla_ledger_id
8683 , p_pad_start_date => p_pad_start_date
8684 , p_pad_end_date => p_pad_end_date
8685 );
8686
8687 END IF;
8688
8689
8690 --
8691 -- Bug 4865292
8692 -- When the number of events and that of header extract do not match,
8693 -- set the no header extract flag to indicate there are some issues
8694 -- in header extract.
8695 --
8696 -- Event count context is set in xla_accounting_pkg.unit_processor.
8697 -- Build_Message for this error is called in xla_accounting_pkg.post_accounting
8698 -- to report it as a general error.
8699 --
8700 IF xla_context_pkg.get_event_count_context <> g_hdr_extract_count
8701 AND xla_context_pkg.get_event_nohdr_context <> 'Y' THEN
8702
8703 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
8704 trace
8708
8705 (p_msg => '# of extracted headers and events does not match'
8706 ,p_level => C_LEVEL_STATEMENT
8707 ,p_module => l_log_module);
8709 trace
8710 (p_msg => '# of extracted headers: '
8711 ||g_hdr_extract_count
8712 ,p_level => C_LEVEL_STATEMENT
8713 ,p_module => l_log_module);
8714
8715 trace
8716 (p_msg => '# of events in xla_events_gt: '
8717 ||xla_context_pkg.get_event_count_context
8718 ,p_level => C_LEVEL_STATEMENT
8719 ,p_module => l_log_module);
8720
8721 trace
8722 (p_msg => 'Event No Header Extract Context: '
8723 ||xla_context_pkg.get_event_nohdr_context
8724 ,p_level => C_LEVEL_STATEMENT
8725 ,p_module => l_log_module);
8726
8727 END IF;
8728
8729
8730 xla_context_pkg.set_event_nohdr_context
8731 (p_nohdr_extract_flag => 'Y'
8732 ,p_client_id => sys_context('USERENV','CLIENT_IDENTIFIER'));
8733
8734 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
8735 trace
8736 (p_msg => 'No Header Extract Flag is set to Y'
8737 ,p_level => C_LEVEL_STATEMENT
8738 ,p_module => l_log_module);
8739 END IF;
8740
8741 END IF;
8742
8743 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8744 trace
8745 (p_msg => 'END of CreateHeadersAndLines'
8746 ,p_level => C_LEVEL_PROCEDURE
8747 ,p_module => l_log_module);
8748 END IF;
8749
8750 RETURN l_created;
8751 EXCEPTION
8752 WHEN xla_exceptions_pkg.application_exception THEN
8753 RAISE;
8754 WHEN OTHERS THEN
8755 xla_exceptions_pkg.raise_message
8756 (p_location => 'XLA_00206_AAD_S_000004_BC_PKG.CreateHeadersAndLines');
8757 END CreateHeadersAndLines;
8758 --
8759 --
8760
8761 --
8762 --+============================================+
8763 --| |
8764 --| PUBLIC FUNCTION |
8765 --| |
8766 --+============================================+
8767 --
8768 FUNCTION CreateJournalEntries
8769 (p_application_id IN NUMBER
8770 ,p_base_ledger_id IN NUMBER
8771 ,p_pad_start_date IN DATE
8772 ,p_pad_end_date IN DATE
8773 ,p_primary_ledger_id IN NUMBER)
8774 RETURN NUMBER IS
8775 l_log_module VARCHAR2(240);
8776 l_array_ledgers xla_accounting_cache_pkg.t_array_ledger_id;
8777 l_temp_result BOOLEAN;
8778 l_result NUMBER;
8779 BEGIN
8780 --
8781 IF g_log_enabled THEN
8782 l_log_module := C_DEFAULT_MODULE||'.CreateJournalEntries';
8783 END IF;
8784 --
8785 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8786 trace
8787 (p_msg => 'BEGIN of CreateJournalEntries'||
8788 ' - p_base_ledger_id = '||TO_CHAR(p_base_ledger_id)
8789 ,p_level => C_LEVEL_PROCEDURE
8790 ,p_module => l_log_module);
8791
8792 END IF;
8793
8794 --
8795 g_diagnostics_mode:= xla_accounting_engine_pkg.g_diagnostics_mode;
8796
8797 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
8798 trace
8799 (p_msg => 'g_diagnostics_mode = '||g_diagnostics_mode
8800 ,p_level => C_LEVEL_STATEMENT
8801 ,p_module => l_log_module);
8802 END IF;
8803 --
8804 xla_ae_journal_entry_pkg.SetProductAcctDefinition
8805 (p_product_rule_code => 'LNS_US_FEDERAL'
8806 ,p_product_rule_type_code => 'S'
8807 ,p_product_rule_version => ''
8808 ,p_product_rule_name => 'Loans US Federal'
8809 ,p_amb_context_code => 'DEFAULT'
8810 );
8811
8812 l_array_ledgers :=
8813 xla_ae_journal_entry_pkg.GetAlternateCurrencyLedger
8814 (p_base_ledger_id => p_base_ledger_id);
8815
8816 FOR Idx IN 1 .. l_array_ledgers.COUNT LOOP
8817 l_temp_result :=
8818 XLA_AE_JOURNAL_ENTRY_PKG.GetLedgersInfo
8819 (p_application_id => p_application_id
8820 ,p_base_ledger_id => p_base_ledger_id
8821 ,p_target_ledger_id => l_array_ledgers(Idx)
8822 ,p_primary_ledger_id => p_primary_ledger_id
8823 ,p_pad_start_date => p_pad_start_date
8824 ,p_pad_end_date => p_pad_end_date);
8825
8826 l_temp_result :=
8827 l_temp_result AND
8828 CreateHeadersAndLines
8829 (p_application_id => p_application_id
8830 ,p_base_ledger_id => p_base_ledger_id
8831 ,p_target_ledger_id => l_array_ledgers(Idx)
8832 ,p_pad_start_date => p_pad_start_date
8833 ,p_pad_end_date => p_pad_end_date
8834 ,p_primary_ledger_id => p_primary_ledger_id
8835 );
8836 END LOOP;
8837
8838
8839 IF (g_diagnostics_mode = 'Y' AND
8840 C_LEVEL_UNEXPECTED >= g_log_level AND
8841 xla_environment_pkg.g_Req_Id IS NOT NULL ) THEN
8842
8843 xla_accounting_dump_pkg.acctg_event_extract_log(
8844 p_application_id => p_application_id
8845 ,p_request_id => xla_environment_pkg.g_Req_Id
8846 );
8847
8848 END IF;
8849
8850 CASE l_temp_result
8851 WHEN TRUE THEN l_result := 0;
8852 ELSE l_result := 2;
8853 END CASE;
8854
8855 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8856 trace
8857 (p_msg => 'return value. = '||TO_CHAR(l_result)
8858 ,p_level => C_LEVEL_PROCEDURE
8859 ,p_module => l_log_module);
8860 trace
8861 (p_msg => 'END of CreateJournalEntries '
8862 ,p_level => C_LEVEL_PROCEDURE
8863 ,p_module => l_log_module);
8864 END IF;
8865
8866 RETURN l_result;
8867 EXCEPTION
8868 WHEN xla_exceptions_pkg.application_exception THEN
8869 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8870 trace
8871 (p_msg => 'ERROR. = '||sqlerrm
8872 ,p_level => C_LEVEL_PROCEDURE
8873 ,p_module => l_log_module);
8874 END IF;
8875 RAISE;
8876 WHEN OTHERS THEN
8877 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8878 trace
8879 (p_msg => 'ERROR. = '||sqlerrm
8880 ,p_level => C_LEVEL_PROCEDURE
8881 ,p_module => l_log_module);
8882 END IF;
8883 xla_exceptions_pkg.raise_message
8884 (p_location => 'XLA_00206_AAD_S_000004_BC_PKG.CreateJournalEntries');
8885 END CreateJournalEntries;
8886 --
8887 --=============================================================================
8888 --
8889 --
8890 --
8891 --
8892 --
8893 --
8894 --
8895 --
8896 --
8897 --
8898 --
8899 --
8900 --
8901 --
8902 --
8903 --
8904 --
8905 --
8906 --
8907 --
8908 --
8909 --
8910 --=============================================================================
8911 --=============================================================================
8912 -- *********** Initialization routine **********
8913 --=============================================================================
8914
8915 BEGIN
8916 g_log_level := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
8917 g_log_enabled := fnd_log.test
8918 (log_level => g_log_level
8919 ,module => C_DEFAULT_MODULE);
8920
8921 IF NOT g_log_enabled THEN
8922 g_log_level := C_LEVEL_LOG_DISABLED;
8923 END IF;
8924 --
8925 END XLA_00206_AAD_S_000004_BC_PKG;
8926 --