[Home] [Help]
PACKAGE BODY: APPS.ARP_ACCT_MAIN
Source
1 PACKAGE BODY ARP_ACCT_MAIN AS
2 /* $Header: ARTACCMB.pls 120.26.12020000.2 2012/07/25 13:52:50 kkikkise ship $ */
3
4 /*========================================================================
5 | Prototype Declarations
6 *=======================================================================*/
7 PG_DEBUG varchar2(1) := NVL(FND_PROFILE.value('AFLOG_ENABLED'), 'N');
8
9 PROCEDURE Insert_Ae_Lines(p_ae_line_tbl IN ae_line_tbl_type);
10
11 PROCEDURE Init_Curr_Details(p_accounting_method IN OUT NOCOPY ar_system_parameters.accounting_method%TYPE);
12
13 PROCEDURE Dump_Dist_Amts(p_ae_line_rec ar_distributions%ROWTYPE);
14
15 /*========================================================================
16 | Public Functions/Procedures
17 *=======================================================================*/
18
19 /*========================================================================
20 | PUBLIC PROCEDURE Create_Acct_Entry
21 |
22 | DESCRIPTION
23 | Create accounting entries for a document
24 | ----------------------------------------
25 | This procedure calls the document main packages to create accounting
26 | for Receipts, Credit Memos and Adjustments.
27 |
28 | PARAMETERS
29 | p_mode IN Document or Accounting Event mode
30 | p_ae_doc_rec IN Document Record
31 | p_ae_event_rec IN Event Record
32 | p_client_server IN A value indicates that a call is made
33 | from C code hence raise exception.
34 | KNOWN ISSUES
35 | 6-24-02 We are consciously not doing any modification to the
36 | arp_acct_hook for the mrc trigger replacment.
37 *=======================================================================*/
38 PROCEDURE Create_Acct_Entry(
39 p_mode IN VARCHAR2, -- DOCUMENT or ACCT_EVENT
40 p_ae_doc_rec IN ae_doc_rec_type,
41 p_ae_event_rec IN ae_event_rec_type,
42 p_client_server IN VARCHAR2 DEFAULT NULL,
43 --{HYUDETUPT
44 p_from_llca_call IN VARCHAR2 DEFAULT 'N',
45 p_gt_id IN NUMBER DEFAULT NULL,
46 --}
47 p_called_from IN VARCHAR2 DEFAULT NULL
48 ) IS
49
50 CURSOR get_miss_rec_app IS
51 SELECT ra.cash_receipt_id, ra.receivable_application_id
52 FROM ar_receivable_applications ra
53 WHERE ra.receivable_application_id = p_ae_doc_rec.source_id_old
54 AND ra.status = 'APP'
55 AND ra.application_type = 'CASH'
56 AND ra.posting_control_id <> -3
57 AND ra.event_id is NULL
58 AND p_ae_doc_rec.source_table = 'RA'
59 AND p_ae_doc_rec.other_flag = 'REVERSE'
60 AND exists (select 1
61 from XLA_TRANSACTION_ENTITIES xte
62 where xte.source_id_int_1 = ra.cash_receipt_id
63 AND xte.upg_batch_id IS NOT NULL)
64 AND NOT EXISTS
65 ( SELECT *
66 FROM ar_distributions
67 WHERE source_table = 'RA'
68 AND source_id = ra.receivable_application_id
69 )
70 AND EXISTS (SELECT 1
71 FROM AR_CASH_BASIS_DISTS_ALL
72 WHERE receivable_application_id = ra.receivable_application_id)
73 order by ra.cash_receipt_id, ra.receivable_application_id;
74
75 l_replace_default_processing BOOLEAN := FALSE;
76 l_ae_created BOOLEAN := FALSE;
77 l_ae_line_tbl ae_line_tbl_type;
78 l_summarize BOOLEAN := FALSE;
79 l_sob_id NUMBER;
80 l_accounting_method ar_system_parameters.accounting_method%TYPE;
81 l_create_acct VARCHAR2(1) := 'Y';
82
83 --Bug#2750340
84 l_xla_ev_rec arp_xla_events.xla_events_type;
85 l_xla_doc_table VARCHAR2(20);
86 l_amount_flag NUMBER := 0;
87 INVALID_AMOUNT_EROR EXCEPTION;
88
89 BEGIN
90
91 IF PG_DEBUG in ('Y', 'C') THEN
92 arp_standard.debug( 'ARP_ACCT_MAIN.Create_Acct_Entry()+');
93 END IF;
94
95 /*-----------------------------------------------------------------------+
96 |Dump the document record details usefull for debugging purposes. |
97 +-----------------------------------------------------------------------*/
98 IF PG_DEBUG in ('Y', 'C') THEN
99 arp_standard.debug( ' Document Type :' || p_ae_doc_rec.document_type);
100 arp_standard.debug( ' Document Id :' || p_ae_doc_rec.document_id);
101 arp_standard.debug( ' Accounting Entity Level :' || p_ae_doc_rec.accounting_entity_level);
102 arp_standard.debug( ' Source Table :' || p_ae_doc_rec.source_table);
103 arp_standard.debug( ' Source Id :' || p_ae_doc_rec.source_id);
104 arp_standard.debug( ' Source Id Old :' || p_ae_doc_rec.source_id_old);
105 arp_standard.debug( ' Other Flag :' || p_ae_doc_rec.other_flag);
106 arp_standard.debug( ' Miscel1 :' || p_ae_doc_rec.miscel1);
107 arp_standard.debug( ' Miscel2 :' || p_ae_doc_rec.miscel2);
108 arp_standard.debug( ' Miscel3 :' || p_ae_doc_rec.miscel3);
109 arp_standard.debug( ' Miscel4 :' || p_ae_doc_rec.miscel4);
110 arp_standard.debug( ' Miscel5 :' || p_ae_doc_rec.miscel5);
111 arp_standard.debug( ' Miscel6 :' || p_ae_doc_rec.miscel6);
112 arp_standard.debug( ' Miscel7 :' || p_ae_doc_rec.miscel7);
113 arp_standard.debug( ' Miscel8 :' || p_ae_doc_rec.miscel8);
114 arp_standard.debug( ' Event :' || p_ae_doc_rec.event);
115 arp_standard.debug( ' Deferred Tax :' || p_ae_doc_rec.deferred_tax);
116 arp_standard.debug( ' Called_from :' || p_ae_doc_rec.called_from);
117 arp_standard.debug( ' Tax account id :' || p_ae_doc_rec.gl_tax_acct);
118 --{HYUDETUPT
119 arp_standard.debug( ' p_from_llca_call :' || p_from_llca_call);
120 arp_standard.debug( ' p_gt_id :' || p_gt_id);
121 arp_standard.debug( ' p_called_from :' || p_called_from);
122 --}
123 END IF;
124 /* Bug fix 2300268 : Added debug message*/
125 /* Bug 13625713, Creating missing distribution for APP row of application. */
126 FOR l_miss_rec_app IN get_miss_rec_app LOOP
127 --This cursor will return only one row.
128 IF PG_DEBUG in ('Y', 'C') THEN
129 arp_standard.debug('Creating missing distribution corresponding to APP row of application.');
130 arp_standard.debug('Only if: ');
131 arp_standard.debug(' 1. Receipt is upgraded from 11i.');
132 arp_standard.debug(' 2. Application done in 11i');
133 arp_standard.debug(' 3. Receipt posted in 11i using cash basis accounting.');
134 arp_standard.debug(' 4. Doing Unapplication in R12.');
135 END IF;
136 arp_acct_main.create_Acct_entry('RECEIPT',
137 l_miss_rec_app.cash_receipt_id,
138 'ONE',
139 'RA',
140 l_miss_rec_app.receivable_application_id,
141 null,
142 null,
143 'Y',
144 'C',
145 'N',
146 null);
147
148 IF PG_DEBUG in ('Y', 'C') THEN
149 arp_standard.debug('Matching the amount of the newly created REC row in ARD');
150 END IF;
151
152 Select count(*)
153 INTO l_amount_flag
154 FROM
155 (SELECT sum(nvl(amount, 0)) amount
156 FROM AR_CASH_BASIS_DISTS_ALL
157 WHERE receivable_application_id = l_miss_rec_app.receivable_application_id) a,
158 (Select sum(nvl(AMOUNT_CR, 0) - nvl(AMOUNT_DR, 0)) amount
159 FROM ar_distributions
160 WHERE source_table = 'RA'
161 AND source_id = l_miss_rec_app.receivable_application_id) b
162 WHERE a.amount = b.amount;
163
164 IF l_amount_flag = 0 THEN
165 IF PG_DEBUG in ('Y', 'C') THEN
166 arp_standard.debug('Amounts in ARD is not matching with AR_CASH_BASIS_DISTS.');
167 END IF;
168 RAISE INVALID_AMOUNT_EROR;
169 END IF;
170
171 IF PG_DEBUG in ('Y', 'C') THEN
172 arp_standard.debug('Updating CCID of newly created row in ARD');
173 END IF;
174 END LOOP;
175
176 Init_Curr_Details(p_accounting_method => l_accounting_method);
177
178
179 IF PG_DEBUG in ('Y', 'C') THEN
180 arp_standard.debug( 'ARP_ACCT_MAIN - Accounting Method ' || l_accounting_method);
181 END IF;
182
183 -- bug5655154, commented accounting_method = 'ACCRUAL' check
184 -- IF l_accounting_method = 'ACCRUAL' THEN
185
186 IF PG_DEBUG in ('Y', 'C') THEN
187 arp_standard.debug( 'Create_Acct_Entry - Processing Accounting Method ' || l_accounting_method);
188 END IF;
189
190 /*---------------------------------------------------------------------------+
191 |Determine whether we really need to create accounting, in the case of MCD |
192 |as the drive is using the document id against source id we dont need to |
193 |check whether its accounting exists.The check below is a security mechanism|
194 +---------------------------------------------------------------------------*/
195 --Check is not required if the call is from auto receipts BUG 6660834
196 IF NVL( p_called_from, 'NONE' ) NOT IN ('AUTORECAPI','AUTORECAPI2') THEN
197 IF ((p_ae_doc_rec.accounting_entity_level = 'ONE')
198 AND (p_ae_doc_rec.source_table <> 'MCD')) THEN
199 BEGIN
200
201 IF PG_DEBUG in ('Y', 'C') THEN
202 arp_standard.debug( 'ARP_ACCT_MAIN.Create_Acct_Entry - check whether accounting required ');
203 END IF;
204
205 select 'N'
206 into l_create_acct
207 from dual
208 where exists (select 'X'
209 from ar_distributions dist
210 where dist.source_id = p_ae_doc_rec.source_id
211 and dist.source_table = p_ae_doc_rec.source_table);
212
213 IF PG_DEBUG in ('Y', 'C') THEN
214 arp_standard.debug( 'ARP_ACCT_MAIN.Create_Acct_Entry - accounting already exists');
215 END IF;
216
217 EXCEPTION
218 WHEN NO_DATA_FOUND THEN
219 IF PG_DEBUG in ('Y', 'C') THEN
220 arp_standard.debug( 'ARP_ACCT_MAIN.Create_Acct_Entry - creating accounting ');
221 END IF;
222 l_create_acct := 'Y';
223 END;
224
225 END IF; --end if check accounting required
226 END IF;
227
228 IF PG_DEBUG in ('Y', 'C') THEN
229 arp_standard.debug( 'l_create_acct = ' || l_create_acct);
230 END IF;
231
232 IF (l_create_acct = 'N') THEN
233 IF PG_DEBUG in ('Y', 'C') THEN
234 arp_standard.debug( 'Ending Processing for l_create_acct = ' || l_create_acct);
235 END IF;
236 GOTO end_process_lbl;
237 END IF;
238
239 /*------------------------------------------------------+
240 | Get Summarization Rules |
241 +------------------------------------------------------*/
242 l_summarize := FALSE;
243
244 /*------------------------------------------------------+
245 | Call Hook to Override Accounting Entry |
246 +------------------------------------------------------*/
247
248 ARP_ACCT_HOOK.Override_Ae_Lines(
249 p_mode => p_mode
250 ,p_ae_doc_rec => p_ae_doc_rec
251 ,p_ae_event_rec => p_ae_event_rec
252 ,p_ae_line_tbl => l_ae_line_tbl
253 ,p_ae_created => l_ae_created
254 ,p_replace_default_processing => l_replace_default_processing
255 );
256
257 IF ( NOT l_replace_default_processing ) THEN
258
259 /*------------------------------------------------------+
260 | Accounting Entry Derivation |
261 +------------------------------------------------------*/
262 IF (( p_ae_doc_rec.document_type = 'RECEIPT') OR
263 ((p_ae_doc_rec.document_type = 'CREDIT_MEMO') AND
264 (p_ae_doc_rec.source_table = 'RA'))) THEN
265
266 ARP_RECEIPTS_MAIN.Execute(
267 p_mode => p_mode,
268 p_ae_doc_rec => p_ae_doc_rec,
269 p_ae_event_rec => p_ae_event_rec,
270 p_ae_line_tbl => l_ae_line_tbl,
271 p_ae_created => l_ae_created,
272 --{HYUDETUPT
273 p_from_llca_call => p_from_llca_call,
274 p_gt_id => p_gt_id
275 --}
276 );
277
278 ELSIF p_ae_doc_rec.document_type = 'ADJUSTMENT' OR
279 p_ae_doc_rec.document_type = 'FINANCE_CHARGES' THEN
280
281 -- Added parameter for Line level adjustment
282 ARP_ADJUSTMENTS_MAIN.Execute(
283 p_mode,
284 p_ae_doc_rec,
285 p_ae_event_rec,
286 l_ae_line_tbl,
287 l_ae_created,
288 p_from_llca_call => p_from_llca_call,
289 p_gt_id => p_gt_id
290 );
291
292 ELSIF p_ae_doc_rec.document_type = 'BILLS_RECEIVABLE' THEN
293
294 ARP_BILLS_RECEIVABLE_MAIN.Execute(
295 p_mode,
296 p_ae_doc_rec,
297 p_ae_event_rec,
298 l_ae_line_tbl,
299 l_ae_created
300 );
301
302 END IF; -- Document type
303
304 END IF; -- Replace Default Processing?
305
306 /*------------------------------------------------------+
307 | Optionally Summarize Accounting Entry Lines created |
308 +------------------------------------------------------*/
309 IF l_ae_created AND l_summarize THEN
310
311 NULL;
312
313 END IF;
314
315
316 /*------------------------------------------------------+
317 | Insert Accounting Entry Lines into AEL table |
318 +------------------------------------------------------*/
319 IF l_ae_created THEN
320
321 Insert_Ae_Lines(l_ae_line_tbl);
322
323 END IF;
324
325 --{ Bug#2750340 : Call ARP_XLA_EVENT
326 IF arp_global.request_id IS NULL AND
327 NVL( p_called_from, 'NONE' ) NOT IN ('AUTORECAPI','AUTORECAPI2','CUSTRECAPIBULK') THEN
328
329 l_xla_ev_rec.xla_from_doc_id := p_ae_doc_rec.document_id;
330 l_xla_ev_rec.xla_to_doc_id := p_ae_doc_rec.document_id;
331 l_xla_ev_rec.xla_mode := 'O';
332 l_xla_ev_rec.xla_call := 'B';
333
334 IF p_ae_doc_rec.source_table = 'MCD' AND p_ae_doc_rec.document_type = 'RECEIPT' THEN
335 l_xla_ev_rec.xla_doc_table := 'MCD';
336 l_xla_ev_rec.xla_call := 'D';
337 ARP_XLA_EVENTS.create_events(p_xla_ev_rec => l_xla_ev_rec);
338 ELSIF p_ae_doc_rec.source_table = 'RA' AND p_ae_doc_rec.document_type = 'RECEIPT' THEN
339 l_xla_ev_rec.xla_doc_table := 'APP';
340 l_xla_ev_rec.xla_from_doc_id := p_ae_doc_rec.source_id;
341 l_xla_ev_rec.xla_to_doc_id := p_ae_doc_rec.source_id;
342 ARP_XLA_EVENTS.create_events(p_xla_ev_rec => l_xla_ev_rec);
343 ELSIF p_ae_doc_rec.source_table = 'RA' AND p_ae_doc_rec.document_type = 'CREDIT_MEMO' THEN
344 l_xla_ev_rec.xla_doc_table := 'CMAPP';
345 l_xla_ev_rec.xla_from_doc_id := p_ae_doc_rec.source_id;
346 l_xla_ev_rec.xla_to_doc_id := p_ae_doc_rec.source_id;
347 ARP_XLA_EVENTS.create_events(p_xla_ev_rec => l_xla_ev_rec);
348 ELSIF p_ae_doc_rec.source_table = 'ADJ' AND p_ae_doc_rec.document_type = 'ADJUSTMENT' THEN
349 l_xla_ev_rec.xla_doc_table := 'ADJ';
350 ARP_XLA_EVENTS.create_events(p_xla_ev_rec => l_xla_ev_rec);
351 ELSIF p_ae_doc_rec.source_table = 'ADJ' AND p_ae_doc_rec.document_type = 'FINANCE_CHARGES' THEN
352 l_xla_ev_rec.xla_doc_table := 'ADJ';
353 ARP_XLA_EVENTS.create_events(p_xla_ev_rec => l_xla_ev_rec);
354 ELSIF p_ae_doc_rec.source_table = 'TH' AND p_ae_doc_rec.document_type = 'BILLS_RECEIVABLE' THEN
355 l_xla_ev_rec.xla_doc_table := 'TRH';
356 ARP_XLA_EVENTS.create_events(p_xla_ev_rec => l_xla_ev_rec);
357 END IF;
358
359 END IF;
360 --}
361
362 -- bug5655154, commented the end if condition
363 -- END IF; --end if ACCRUAL method of accounting
364
365 <<end_process_lbl>>
366 IF PG_DEBUG in ('Y', 'C') THEN
367 arp_standard.debug( 'ARP_ACCT_MAIN.Create_Acct_Entry()-');
368 END IF;
369
370 EXCEPTION
371 WHEN INVALID_AMOUNT_EROR THEN
372 fnd_message.set_name('AR','AR_AMOUNTS_NO_MATCH');
373 RAISE;
374 WHEN OTHERS THEN
375 IF PG_DEBUG in ('Y', 'C') THEN
376 arp_standard.debug( 'EXCEPTION: ARP_ACCT_MAIN.Create_Acct_Entry');
377 END IF;
378 IF p_client_server IS NULL THEN
379 app_exception.raise_exception;
380 ELSE
381 RAISE;
382 END IF;
383
384 END Create_Acct_Entry;
385
386 /*========================================================================
387 | PUBLIC PROCEDURE Create_Acct_Entry
388 |
389 | DESCRIPTION
390 | Create accounting entries for a document
391 | ----------------------------------------
392 | This is an overloaded procedure to which is passed the document
393 | information, to create accounting entries for Receipts, Credit Memos
394 | or Adjustments.
395 |
396 | PARAMETERS
397 | p_mode IN Document or Accounting Event mode
398 | p_ae_doc_rec IN Document Record
399 | p_ae_event_rec IN Event Record
400 *=======================================================================*/
401 PROCEDURE Create_Acct_Entry(
402 p_ae_doc_rec IN ae_doc_rec_type,
403 p_client_server IN VARCHAR2 DEFAULT NULL,
404 --{HYUDETUPT
405 p_from_llca_call IN VARCHAR2 DEFAULT 'N',
406 p_gt_id IN NUMBER DEFAULT NULL,
407 --}
408 p_called_from IN VARCHAR2 DEFAULT NULL
409 ) IS
410
411 l_mode VARCHAR2(1);
412 l_ae_event_rec ae_event_rec_type ;
413
414 BEGIN
415 IF PG_DEBUG in ('Y', 'C') THEN
416 arp_standard.debug( 'Overloaded ARP_ACCT_MAIN.Create_Acct_Entry()+');
417 END IF;
418
419 Create_Acct_Entry(p_mode => l_mode,
420 p_ae_doc_rec => p_ae_doc_rec,
421 p_ae_event_rec => l_ae_event_rec,
422 p_client_server => p_client_server,
423 p_from_llca_call => p_from_llca_call,
424 p_gt_id => p_gt_id,
425 p_called_from => p_called_from );
426
427 IF PG_DEBUG in ('Y', 'C') THEN
428 arp_standard.debug( 'Overloaded ARP_ACCT_MAIN.Create_Acct_Entry()-');
429 END IF;
430
431 EXCEPTION
432 WHEN OTHERS THEN
433 IF PG_DEBUG in ('Y', 'C') THEN
434 arp_standard.debug( 'EXCEPTION: Overloaded ARP_ACCT_MAIN.Create_Acct_Entry');
435 END IF;
436 RAISE;
437 END Create_Acct_Entry;
438
439 /*========================================================================
440 | PUBLIC PROCEDURE Create_Acct_Entry
441 |
442 | DESCRIPTION
443 | Create accounting entries for a document
444 | ----------------------------------------
445 | This is an overloaded procedure to which is passed the document
446 | information, to create accounting entries for Receipts, Credit Memos
447 | or Adjustments.
448 |
449 | PARAMETERS
450 | document_type IN Document Type
451 | document_id IN Document Id
452 | accounting_entity_level IN Entitity Level accounting
453 | source_table IN Source table
454 | source_id IN Source Id
455 | source_id_old IN Source Id Old
456 | other_flag IN Other Flag
457 *=======================================================================*/
458 PROCEDURE Create_Acct_Entry(
459 p_document_type IN VARCHAR2,
460 p_document_id IN NUMBER ,
461 p_accounting_entity_level IN VARCHAR2,
462 p_source_table IN VARCHAR2,
463 p_source_id IN NUMBER ,
464 p_source_id_old IN NUMBER ,
465 p_other_flag IN VARCHAR2,
466 p_client_server IN VARCHAR2 DEFAULT NULL,
467 --{HYUDETUPT
468 p_from_llca_call IN VARCHAR2 DEFAULT 'N',
469 p_gt_id IN NUMBER DEFAULT NULL
470 --}
471 ) IS
472
473 l_mode VARCHAR2(1);
474 l_ae_event_rec ae_event_rec_type ;
475 l_ae_doc_rec ae_doc_rec_type;
476
477 BEGIN
478
479 IF PG_DEBUG in ('Y', 'C') THEN
480 arp_standard.debug( 'Overloaded1 ARP_ACCT_MAIN.Create_Acct_Entry()+');
481 END IF;
482
483 l_ae_doc_rec.document_type := p_document_type ;
484 l_ae_doc_rec.document_id := p_document_id ;
485 l_ae_doc_rec.accounting_entity_level := p_accounting_entity_level ;
486 l_ae_doc_rec.source_table := p_source_table ;
487 l_ae_doc_rec.source_id := p_source_id ;
488 l_ae_doc_rec.source_id_old := p_source_id_old ;
489 l_ae_doc_rec.other_flag := p_other_flag ;
490
491 Create_Acct_Entry(p_mode => l_mode,
492 p_ae_doc_rec => l_ae_doc_rec,
493 p_ae_event_rec => l_ae_event_rec,
494 p_client_server => p_client_server,
495 p_from_llca_call=> p_from_llca_call,
496 p_gt_id => p_gt_id);
497
498 IF PG_DEBUG in ('Y', 'C') THEN
499 arp_standard.debug( 'Overloaded1 ARP_ACCT_MAIN.Create_Acct_Entry()-');
500 END IF;
501
502 EXCEPTION
503 WHEN OTHERS THEN
504 IF PG_DEBUG in ('Y', 'C') THEN
505 arp_standard.debug( 'EXCEPTION: Overloaded1 ARP_ACCT_MAIN.Create_Acct_Entry');
506 END IF;
507 RAISE;
508
509 END Create_Acct_Entry;
510
511 /*========================================================================
512 | PUBLIC PROCEDURE Create_Acct_Entry
513 |
514 | DESCRIPTION
515 | Create accounting entries for a document
516 | ----------------------------------------
517 | This is an overloaded procedure to which is passed the document
518 | information, to create accounting entries for Receipts, Credit Memos
519 | or Adjustments. This is used by C code and it was necessary to overload
520 | this to pass the pay_sched_upd_yn, for Bills Receivable reconciliation
521 | on closure, required by autoadjustments, and postbatch, this avoided having
522 | to change other C routines.
523 |
524 | PARAMETERS
525 | document_type IN Document Type
526 | document_id IN Document Id
527 | accounting_entity_level IN Entitity Level accounting
528 | source_table IN Source table
529 | source_id IN Source Id
530 | source_id_old IN Source Id Old
531 | other_flag IN Other Flag
532 *=======================================================================*/
533 PROCEDURE Create_Acct_Entry(
534 p_document_type IN VARCHAR2,
535 p_document_id IN NUMBER ,
536 p_accounting_entity_level IN VARCHAR2,
537 p_source_table IN VARCHAR2,
538 p_source_id IN NUMBER ,
539 p_source_id_old IN NUMBER ,
540 p_other_flag IN VARCHAR2,
541 p_pay_sched_upd_yn IN VARCHAR2,
542 p_client_server IN VARCHAR2,
543 --{HYUDETUPT
544 p_from_llca_call IN VARCHAR2 DEFAULT 'N',
545 p_gt_id IN NUMBER DEFAULT NULL
546 --}
547 ) IS
548
549 l_mode VARCHAR2(1);
550 l_ae_event_rec ae_event_rec_type ;
551 l_ae_doc_rec ae_doc_rec_type;
552
553 BEGIN
554
555 IF PG_DEBUG in ('Y', 'C') THEN
556 arp_standard.debug( 'Overloaded1 ARP_ACCT_MAIN.Create_Acct_Entry()+');
557 END IF;
558
559 l_ae_doc_rec.document_type := p_document_type ;
560 l_ae_doc_rec.document_id := p_document_id ;
561 l_ae_doc_rec.accounting_entity_level := p_accounting_entity_level ;
562 l_ae_doc_rec.source_table := p_source_table ;
563 l_ae_doc_rec.source_id := p_source_id ;
564 l_ae_doc_rec.source_id_old := p_source_id_old ;
565 l_ae_doc_rec.other_flag := p_other_flag ;
566 l_ae_doc_rec.pay_sched_upd_yn := p_pay_sched_upd_yn ;
567
568 Create_Acct_Entry(p_mode => l_mode,
569 p_ae_doc_rec => l_ae_doc_rec,
570 p_ae_event_rec => l_ae_event_rec,
571 p_client_server => p_client_server,
572 p_from_llca_call => p_from_llca_call,
573 p_gt_id => p_gt_id);
574
575 IF PG_DEBUG in ('Y', 'C') THEN
576 arp_standard.debug( 'Overloaded1 ARP_ACCT_MAIN.Create_Acct_Entry()-');
577 END IF;
578
579 EXCEPTION
580 WHEN OTHERS THEN
581 IF PG_DEBUG in ('Y', 'C') THEN
582 arp_standard.debug( 'EXCEPTION: Overloaded1 ARP_ACCT_MAIN.Create_Acct_Entry');
583 END IF;
584 RAISE;
585
586 END Create_Acct_Entry;
587
588
589 /*================================================================================*
590 | PUBLIC PROCEDURE Insert_Ai_Exceptions |
591 | |
592 | DESCRIPTION |
593 | Insert Autoinvoice Exceptions For Accounting Failures |
594 | ----------------------------------------------------- |
595 | This procedure is called from the Autoinvoice Accounting call |
596 | if any exception occurs during accounting of the commitment |
597 | adjustments or CM applications in an Autoinvoice Batch. |
598 | |
599 | PARAMETERS |
600 | p_request_id IN Request_id |
601 | p_document_id IN Document_id ( Adjustment id or Customer trx id ) |
602 | p_document_type IN 'ADJUSTMENT' or 'CREDIT_MEMO' |
603 | p_message_code IN Error message code to be inserted |
604 *================================================================================*/
605 PROCEDURE Insert_Ai_Exceptions(
606 p_request_id IN NUMBER,
607 p_document_id IN NUMBER,
608 p_document_type IN VARCHAR,
609 p_message_code IN VARCHAR
610 ) IS
611 BEGIN
612
613 IF PG_DEBUG in ('Y', 'C') THEN
614 arp_standard.debug( 'ARP_ACCT_MAIN.Insert_Ai_Exceptions()+');
615 END IF;
616
617 IF p_document_type = 'ADJUSTMENT' THEN
618
619 INSERT INTO RA_INTERFACE_ERRORS(
620 INTERFACE_LINE_ID,
621 MESSAGE_TEXT,
622 INVALID_VALUE,
623 ORG_ID )
624 SELECT il.interface_line_id,
625 arp_standard.fnd_message(p_message_code),
626 trx.customer_trx_id,
627 il.org_id
628 FROM RA_INTERFACE_LINES_GT il,
629 AR_ADJUSTMENTS adj,
630 RA_CUSTOMER_TRX trx
631 WHERE il.request_id = p_request_id
632 AND nvl(il.interface_status, '~') <> 'P'
633 AND il.customer_trx_id = trx.customer_trx_id
634 AND nvl(adj.subsequent_trx_id, adj.customer_trx_id) = trx.customer_trx_id
635 AND adj.adjustment_id = p_document_id;
636
637 ELSIF p_document_type = 'CREDIT_MEMO' THEN
638
639 INSERT INTO RA_INTERFACE_ERRORS(
640 INTERFACE_LINE_ID,
641 MESSAGE_TEXT,
642 INVALID_VALUE,
643 ORG_ID )
644 SELECT il.interface_line_id,
645 arp_standard.fnd_message(p_message_code),
646 trx.customer_trx_id,
647 il.org_id
648 FROM RA_INTERFACE_LINES_GT il,
649 RA_CUSTOMER_TRX trx
650 WHERE il.request_id = p_request_id
651 AND nvl(il.interface_status, '~') <> 'P'
652 AND il.customer_trx_id = trx.customer_trx_id
653 AND trx.customer_trx_id = p_document_id;
654
655 END IF;
656
657 IF PG_DEBUG in ('Y', 'C') THEN
658 arp_standard.debug( 'ARP_ACCT_MAIN.Insert_Ai_Exceptions()-');
659 END IF;
660
661 END;
662
663
664 /*========================================================================
665 | PUBLIC PROCEDURE Create_Acct_Entry
666 |
667 | DESCRIPTION
668 | Create accounting entries for a document
669 | ----------------------------------------
670 | This is an overloaded procedure to which is passed a request_id
671 | from AUTORECEIPTS for processing the Receivable APPLICATION Rows
672 |
673 | PARAMETERS
674 | p_request_id IN Request_id
675 | p_called_from IN Either AUTOREC or AUTOINV
676 *=======================================================================*/
677 PROCEDURE Create_Acct_Entry(
678 p_request_id IN NUMBER,
679 p_called_from IN VARCHAR
680 ) IS
681
682 l_ae_event_rec ae_event_rec_type ;
683 l_ae_doc_rec ae_doc_rec_type;
684
685 CURSOR get_receipt_info(p_request_id IN number) IS
686 SELECT cash_receipt_id from ar_cash_receipts
687 where request_id = p_request_id;
688
689 CURSOR get_app_info(p_cash_receipt_id IN NUMBER) IS
690 SELECT receivable_application_id,
691 status
692 FROM ar_receivable_applications
693 where cash_Receipt_id = p_cash_receipt_id;
694
695 CURSOR get_cm_info (p_request_id IN number) IS
696 select rec.customer_trx_id customer_trx_id,
697 rec.receivable_application_id rec_app_id
698 from AR_RECEIVABLE_APPLICATIONS rec,
699 RA_CUSTOMER_TRX trx
700 where trx.customer_trx_id = rec.customer_trx_id
701 and trx.request_id = p_request_id;
702
703 CURSOR get_adj_info (p_request_id IN number) IS
704 SELECT adjustment_id, code_combination_id
705 FROM ar_adjustments
706 WHERE request_id = p_request_id;
707
708 old_rec_app_id ar_receivable_applications.receivable_application_id%TYPE;
709 --Bug#2750340
710 l_xla_ev_rec arp_xla_events.xla_events_type;
711 l_xla_doc_table VARCHAR2(20);
712
713 adj_exist boolean := FALSE;
714 cm_exist boolean := FALSE;
715
716 BEGIN
717
718 IF PG_DEBUG in ('Y', 'C') THEN
719 arp_standard.debug( 'Overloaded2 ARP_ACCT_MAIN.Create_Acct_Entry()+');
720 END IF;
721
722 IF (p_called_from = 'AUTOREC' ) THEN
723 IF PG_DEBUG in ('Y', 'C') THEN
724 arp_standard.debug( 'calling for AUTO RECEIPTS');
725 END IF;
726
727 l_ae_doc_rec.document_type := 'RECEIPT';
728 l_ae_doc_rec.accounting_entity_level := 'ONE';
729 l_ae_doc_rec.source_table := 'RA';
730
731 FOR receipt_info IN get_receipt_info(p_request_id) LOOP
732 l_ae_doc_rec.document_id := receipt_info.cash_receipt_id;
733 old_rec_app_id := NULL;
734
735 FOR app_info IN get_app_info(receipt_info.cash_receipt_id) LOOP
736
737 l_ae_doc_rec.source_id := app_info.receivable_application_id;
738
739 IF (app_info.status = 'APP') THEN
740 old_rec_app_id := app_info.receivable_application_id;
741 l_ae_doc_rec.source_id_old := NULL;
742 l_ae_doc_rec.other_flag := NULL;
743
744 ELSE
745 /* check to see if this is the final unapp or
746 the paired unapp */
747
748 IF (old_rec_app_id is not null ) THEN
749 /* we have a pairing.. */
750 l_ae_doc_rec.source_id_old := old_rec_app_id;
751 l_ae_doc_rec.other_flag := 'PAIR';
752
753 /* reset old rec app id */
754 old_rec_app_id := NULL;
755 ELSE
756 l_ae_doc_rec.source_id_old := NULL;
757 l_ae_doc_rec.other_flag := NULL;
758 END IF;
759 END IF;
760
761 /* call Accting engine */
762 arp_acct_main.Create_Acct_Entry(l_ae_doc_rec);
763
764 END LOOP;
765 END LOOP;
766
767 /*-- Commented this out based on Ramakant inputs autoreceipt will no longer be called
768 -- from ARZCAR -- but it will call ar_receipt_api_pub
769 -- XLA should be uptake in ar_receipt_api_pub
770 -- Bug#2750340 {
771 l_xla_ev_rec.xla_req_id := p_request_id;
772 l_xla_ev_rec.xla_mode := 'B';
773 l_xla_ev_rec.xla_call := 'B';
774
775 l_xla_ev_rec.xla_doc_table := 'CR';
776 ARP_XLA_EVENTS.create_events(p_xla_ev_rec => l_xla_ev_rec);
777
778 l_xla_ev_rec.xla_doc_table := 'APP';
779 ARP_XLA_EVENTS.create_events(p_xla_ev_rec => l_xla_ev_rec);
780 -- }
781 */
782 ELSE
783
784 -- 1st Adjustment and 2 CM APP
785
786 /* create adjustment entries */
787 FOR adj_info in get_adj_info(p_request_id) LOOP
788
789 adj_exist := TRUE; -- 4457617: call sla
790
791 SAVEPOINT Adj_Accounting_Call_Point;
792
793 BEGIN
794 arp_acct_main.Create_Acct_Entry('ADJUSTMENT',
795 adj_info.adjustment_id,
796 'ONE',
797 'ADJ',
798 adj_info.adjustment_id,
799 adj_info.code_combination_id,
800 'COMMITMENT');
801 EXCEPTION
802 WHEN ARP_ALLOCATION_PKG.flex_subs_ccid_error THEN
803 IF p_called_from = 'AUTOINV' THEN
804 ROLLBACK TO Adj_Accounting_Call_Point;
805 Insert_Ai_Exceptions(
806 p_request_id,
807 adj_info.adjustment_id,
808 'ADJUSTMENT',
809 'AR_RAXTRX-1822');
810 ELSE
811 RAISE;
812 END IF;
813 WHEN ARP_ALLOCATION_PKG.invalid_ccid_error THEN
814 IF p_called_from = 'AUTOINV' THEN
815 ROLLBACK TO Adj_Accounting_Call_Point;
816 Insert_Ai_Exceptions(
817 p_request_id,
818 adj_info.adjustment_id,
819 'ADJUSTMENT',
820 'AR_RAXTRX-1823');
821 ELSE
822 RAISE;
823 END IF;
824 WHEN ARP_ALLOCATION_PKG.rounding_error THEN
825 IF p_called_from = 'AUTOINV' THEN
826 ROLLBACK TO Adj_Accounting_Call_Point;
827 Insert_Ai_Exceptions(
828 p_request_id,
829 adj_info.adjustment_id,
830 'ADJUSTMENT',
831 'AR_RAXTRX-1824');
832
833 ELSE
834 RAISE;
835 END IF;
836 WHEN ARP_ALLOCATION_PKG.invalid_allocation_base THEN
837 IF p_called_from = 'AUTOINV' THEN
838 ROLLBACK TO Adj_Accounting_Call_Point;
839 Insert_Ai_Exceptions(
840 p_request_id,
841 adj_info.adjustment_id,
842 'ADJUSTMENT',
843 'AR_RAXTRX-1825');
844
845 ELSE
846 RAISE;
847 END IF;
848 WHEN NO_DATA_FOUND THEN
849 IF p_called_from = 'AUTOINV' THEN
850 ROLLBACK TO Adj_Accounting_Call_Point;
851 Insert_Ai_Exceptions(
852 p_request_id,
853 adj_info.adjustment_id,
854 'ADJUSTMENT',
855 'AR_RAXTRX-1826');
856
857 ELSE
858 RAISE;
859 END IF;
860 WHEN OTHERS THEN
861 IF p_called_from = 'AUTOINV' THEN
862 ROLLBACK TO Adj_Accounting_Call_Point;
863 Insert_Ai_Exceptions(
864 p_request_id,
865 adj_info.adjustment_id,
866 'ADJUSTMENT',
867 'AR_RAXTRX-1827');
868
869 ELSE
870 RAISE;
871 END IF;
872 END;
873 END LOOP;
874
875
876 /* create credit memo entries */
877 FOR cm_info IN get_cm_info(p_request_id) LOOP
878
879 cm_exist := TRUE; -- 4457617: call sla
880
881 SAVEPOINT RA_Accounting_Call_Point;
882
883 BEGIN
884 arp_acct_main.Create_Acct_Entry('CREDIT_MEMO',
885 cm_info.customer_trx_id,
886 'ONE',
887 'RA',
888 cm_info.rec_app_id,
889 NULL,
890 NULL);
891 EXCEPTION
892 WHEN ARP_ALLOCATION_PKG.flex_subs_ccid_error THEN
893 IF p_called_from = 'AUTOINV' THEN
894 ROLLBACK TO RA_Accounting_Call_Point;
895 Insert_Ai_Exceptions(
896 p_request_id,
897 cm_info.customer_trx_id,
898 'CREDIT_MEMO',
899 'AR_RAXTRX-1822');
900 ELSE
901 RAISE;
902 END IF;
903 WHEN ARP_ALLOCATION_PKG.invalid_ccid_error THEN
904 IF p_called_from = 'AUTOINV' THEN
905 ROLLBACK TO RA_Accounting_Call_Point;
906 Insert_Ai_Exceptions(
907 p_request_id,
908 cm_info.customer_trx_id,
909 'CREDIT_MEMO',
910 'AR_RAXTRX-1823');
911 ELSE
912 RAISE;
913 END IF;
914 WHEN ARP_ALLOCATION_PKG.rounding_error THEN
915 IF p_called_from = 'AUTOINV' THEN
916 ROLLBACK TO RA_Accounting_Call_Point;
917 Insert_Ai_Exceptions(
918 p_request_id,
919 cm_info.customer_trx_id,
920 'CREDIT_MEMO',
921 'AR_RAXTRX-1824');
922
923 ELSE
924 RAISE;
925 END IF;
926 WHEN ARP_ALLOCATION_PKG.invalid_allocation_base THEN
927 IF p_called_from = 'AUTOINV' THEN
928 ROLLBACK TO RA_Accounting_Call_Point;
929 Insert_Ai_Exceptions(
930 p_request_id,
931 cm_info.customer_trx_id,
932 'CREDIT_MEMO',
933 'AR_RAXTRX-1825');
934
935 ELSE
936 RAISE;
937 END IF;
938 WHEN NO_DATA_FOUND THEN
939 IF p_called_from = 'AUTOINV' THEN
940 ROLLBACK TO RA_Accounting_Call_Point;
941 Insert_Ai_Exceptions(
942 p_request_id,
943 cm_info.customer_trx_id,
944 'CREDIT_MEMO',
945 'AR_RAXTRX-1826');
946
947 ELSE
948 RAISE;
949 END IF;
950 WHEN OTHERS THEN
951 IF p_called_from = 'AUTOINV' THEN
952 ROLLBACK TO RA_Accounting_Call_Point;
953 Insert_Ai_Exceptions(
954 p_request_id,
955 cm_info.customer_trx_id,
956 'CREDIT_MEMO',
957 'AR_RAXTRX-1827');
958
959 ELSE
960 RAISE;
961 END IF;
962 END;
963 END LOOP;
964
965 -- Bug#2750340
966 l_xla_ev_rec.xla_req_id := p_request_id;
967 l_xla_ev_rec.xla_mode := 'B';
968 l_xla_ev_rec.xla_call := 'B';
969
970 /* 4457617: only call sla if CMAPP or ADJ exists. Was raising a
971 generic error in autoinvoice (raacae) */
972
973 /* Auto inv will use wrapper to control XLA event creation
974 --
975 IF adj_exist
976 THEN
977 l_xla_ev_rec.xla_doc_table := 'ADJ';
978 ARP_XLA_EVENTS.create_events(p_xla_ev_rec => l_xla_ev_rec);
979 END IF;
980
981 IF cm_exist
982 THEN
983 l_xla_ev_rec.xla_doc_table := 'CMAPP';
984 ARP_XLA_EVENTS.create_events(p_xla_ev_rec => l_xla_ev_rec);
985 END IF;
986 --
987 */
988 END IF;
989 IF PG_DEBUG in ('Y', 'C') THEN
990 arp_standard.debug( 'Overloaded2 ARP_ACCT_MAIN.Create_Acct_Entry()-');
991 END IF;
992
993 END Create_Acct_Entry;
994
995
996 /*========================================================================
997 | PUBLIC PROCEDURE Delete_Acct_Entry
998 |
999 | DESCRIPTION
1000 | Delete accounting entries for a document
1001 | ----------------------------------------
1002 | This procedure is the standard delete routine which calls packages
1003 | for Receipts, Credit Memos and Adjustments to delete the accounting
1004 | associated with the document for a source id
1005 |
1006 | PARAMETERS
1007 | p_mode IN Document or Accounting Event mode
1008 | p_ae_doc_rec IN Document Record
1009 | p_ae_event_rec IN Event Record
1010 *=======================================================================*/
1011 PROCEDURE Delete_Acct_Entry(
1012 p_mode IN VARCHAR2, -- DOCUMENT or ACCT_EVENT
1013 p_ae_doc_rec IN OUT NOCOPY ae_doc_rec_type,
1014 p_ae_event_rec IN ae_event_rec_type
1015 ) IS
1016 l_ae_deleted BOOLEAN := FALSE;
1017 l_paired_id ar_receivable_applications.receivable_application_id%TYPE;
1018 l_accounting_method ar_system_parameters.accounting_method%TYPE;
1019
1020 BEGIN
1021 IF PG_DEBUG in ('Y', 'C') THEN
1022 arp_standard.debug( 'ARP_ACCT_MAIN.Delete_Acct_Entry()+');
1023 END IF;
1024
1025 Init_Curr_Details(p_accounting_method => l_accounting_method);
1026
1027 IF PG_DEBUG in ('Y', 'C') THEN
1028 arp_standard.debug( 'ARP_ACCT_MAIN - Accounting Method ' || l_accounting_method);
1029 END IF;
1030
1031 --begin 5655154, commented the accounting_method = 'ACCRUAL' check
1032 -- IF l_accounting_method = 'ACCRUAL' THEN
1033 --end 5655154
1034 IF PG_DEBUG in ('Y', 'C') THEN
1035 arp_standard.debug( 'Delete_Acct_Entry - Processing Accounting Method ' || l_accounting_method);
1036 END IF;
1037 /*------------------------------------------------------+
1038 | Delete Accounting for Document |
1039 +------------------------------------------------------*/
1040 IF ( p_ae_doc_rec.document_type = 'RECEIPT' ) OR
1041 (p_ae_doc_rec.document_type = 'CREDIT_MEMO') THEN
1042
1043 ARP_RECEIPTS_MAIN.Delete_Acct( p_mode,
1044 p_ae_doc_rec,
1045 p_ae_event_rec,
1046 l_ae_deleted
1047 );
1048
1049 ELSIF p_ae_doc_rec.document_type = 'ADJUSTMENT' OR
1050 p_ae_doc_rec.document_type = 'FINANCE_CHARGES' THEN
1051
1052 ARP_ADJUSTMENTS_MAIN.Delete_Acct( p_mode,
1053 p_ae_doc_rec,
1054 p_ae_event_rec,
1055 l_ae_deleted
1056 );
1057
1058 ELSIF p_ae_doc_rec.document_type = 'BILLS_RECEIVABLE' THEN
1059
1060 ARP_BILLS_RECEIVABLE_MAIN.Delete_Acct( p_mode,
1061 p_ae_doc_rec,
1062 p_ae_event_rec,
1063 l_ae_deleted
1064 );
1065
1066 END IF; -- Document type
1067 --begin 5655154, commented the endif condition
1068 -- END IF; --end if Accounting method is accrual
1069 --end 5655154
1070
1071 IF PG_DEBUG in ('Y', 'C') THEN
1072 arp_standard.debug( 'ARP_ACCT_MAIN.Delete_Acct_Entry()-');
1073 END IF;
1074
1075 EXCEPTION
1076 WHEN OTHERS THEN
1077 IF PG_DEBUG in ('Y', 'C') THEN
1078 arp_standard.debug( 'EXCEPTION: ARP_ACCT_MAIN.Delete_Acct_Entry');
1079 END IF;
1080 RAISE;
1081
1082 END Delete_Acct_Entry;
1083
1084 /*========================================================================
1085 | PUBLIC PROCEDURE Delete_Acct_Entry
1086 |
1087 | DESCRIPTION
1088 | Delete accounting entries for a document
1089 | ----------------------------------------
1090 | This is an overloaded procedure which calls packages associated
1091 | with a Receipt, Credit Memo or Adjustment document to delete the
1092 | accounting for a source id.
1093 |
1094 | PARAMETERS
1095 | p_ae_doc_rec IN Document Record
1096 *=======================================================================*/
1097 PROCEDURE Delete_Acct_Entry(
1098 p_ae_doc_rec IN OUT NOCOPY ae_doc_rec_type
1099 ) IS
1100
1101 l_mode VARCHAR2(1);
1102 l_ae_event_rec ae_event_rec_type ;
1103
1104 BEGIN
1105 IF PG_DEBUG in ('Y', 'C') THEN
1106 arp_standard.debug( 'Overloaded ARP_ACCT_MAIN.Delete_Acct_Entry()+');
1107 END IF;
1108
1109 Delete_Acct_Entry(l_mode, p_ae_doc_rec, l_ae_event_rec);
1110
1111 IF PG_DEBUG in ('Y', 'C') THEN
1112 arp_standard.debug( 'Overloaded ARP_ACCT_MAIN.Delete_Acct_Entry()-');
1113 END IF;
1114
1115 EXCEPTION
1116 WHEN OTHERS THEN
1117 IF PG_DEBUG in ('Y', 'C') THEN
1118 arp_standard.debug( 'EXCEPTION: Overloaded ARP_ACCT_MAIN.Delete_Acct_Entry');
1119 END IF;
1120 RAISE;
1121
1122 END Delete_Acct_Entry;
1123
1124 /*========================================================================
1125 | PUBLIC PROCEDURE Delete_Acct_Entry
1126 |
1127 | DESCRIPTION
1128 | Delete accounting entries for a document
1129 | ----------------------------------------
1130 | This is an overloaded procedure which calls packages associated
1131 | with a Receipt, Credit Memo or Adjustment document to delete the
1132 | accounting for a source id. Required for C code delete calls.
1133 |
1134 | PARAMETERS
1135 | p_ae_doc_rec IN Document Record
1136 *=======================================================================*/
1137 PROCEDURE Delete_Acct_Entry(
1138 p_document_type IN VARCHAR2,
1139 p_document_id IN NUMBER ,
1140 p_accounting_entity_level IN VARCHAR2,
1141 p_source_table IN VARCHAR2,
1142 p_source_id IN NUMBER ,
1143 p_source_id_old IN OUT NOCOPY NUMBER ,
1144 p_other_flag IN VARCHAR2
1145 ) IS
1146
1147 l_mode VARCHAR2(1);
1148 l_ae_event_rec ae_event_rec_type;
1149 l_ae_doc_rec ae_doc_rec_type;
1150
1151 BEGIN
1152 IF PG_DEBUG in ('Y', 'C') THEN
1153 arp_standard.debug( 'Overloaded ARP_ACCT_MAIN.Delete_Acct_Entry()+');
1154 END IF;
1155
1156 l_ae_doc_rec.document_type := p_document_type ;
1157 l_ae_doc_rec.document_id := p_document_id ;
1158 l_ae_doc_rec.accounting_entity_level := p_accounting_entity_level ;
1159 l_ae_doc_rec.source_table := p_source_table ;
1160 l_ae_doc_rec.source_id := p_source_id ;
1161 l_ae_doc_rec.source_id_old := p_source_id_old ;
1162 l_ae_doc_rec.other_flag := p_other_flag ;
1163
1164 Delete_Acct_Entry(l_mode, l_ae_doc_rec, l_ae_event_rec);
1165
1166 p_source_id_old := l_ae_doc_rec.source_id_old;
1167
1168 IF PG_DEBUG in ('Y', 'C') THEN
1169 arp_standard.debug( 'Overloaded ARP_ACCT_MAIN.Delete_Acct_Entry()-');
1170 END IF;
1171
1172 EXCEPTION
1173 WHEN OTHERS THEN
1174 IF PG_DEBUG in ('Y', 'C') THEN
1175 arp_standard.debug( 'EXCEPTION: Overloaded ARP_ACCT_MAIN.Delete_Acct_Entry');
1176 END IF;
1177 RAISE;
1178
1179 END Delete_Acct_Entry;
1180
1181 /*========================================================================
1182 | PRIVATE PROCEDURE Insert_Ae_Lines
1183 |
1184 | DESCRIPTION
1185 | Inserts into AR_DISTRIBUTIONS accounting lines
1186 | ----------------------------------------------
1187 | Calls the table handler for AR_DISTRIBUTIONS to insert accounting
1188 | for a given document into the underlying table.
1189 |
1190 | PARAMETERS
1191 | p_ae_line_tbl IN Accounting lines table
1192 *=======================================================================*/
1193 PROCEDURE Insert_Ae_Lines(p_ae_line_tbl IN ae_line_tbl_type) IS
1194
1195 l_ae_line_rec ar_distributions%ROWTYPE;
1196 l_ae_line_rec_empty ar_distributions%ROWTYPE;
1197 l_dummy ar_distributions.line_id%TYPE;
1198
1199 i BINARY_INTEGER := 1;
1200
1201 BEGIN
1202
1203 IF PG_DEBUG in ('Y', 'C') THEN
1204 arp_standard.debug( 'ARP_ACCT_MAIN.Insert_Ae_Lines()+');
1205 END IF;
1206
1207
1208 -- Insert AE Lines
1209 FOR i IN p_ae_line_tbl.FIRST .. p_ae_line_tbl.LAST LOOP
1210
1211 -- Initialize
1212 l_ae_line_rec := l_ae_line_rec_empty;
1213
1214 -- Assign AE Line elements
1215
1216 l_ae_line_rec.source_type := p_ae_line_tbl(i).ae_line_type;
1217 l_ae_line_rec.source_type_secondary := p_ae_line_tbl(i).ae_line_type_secondary;
1218 l_ae_line_rec.source_id := p_ae_line_tbl(i).source_id;
1219 l_ae_line_rec.source_table := p_ae_line_tbl(i).source_table;
1220 l_ae_line_rec.code_combination_id := p_ae_line_tbl(i).account;
1221 l_ae_line_rec.amount_dr := p_ae_line_tbl(i).entered_dr;
1222 l_ae_line_rec.amount_cr := p_ae_line_tbl(i).entered_cr;
1223 l_ae_line_rec.acctd_amount_dr := p_ae_line_tbl(i).accounted_dr;
1224 l_ae_line_rec.acctd_amount_cr := p_ae_line_tbl(i).accounted_cr;
1225 l_ae_line_rec.source_id_secondary := p_ae_line_tbl(i).source_id_secondary;
1226 l_ae_line_rec.source_table_secondary := p_ae_line_tbl(i).source_table_secondary;
1227 l_ae_line_rec.currency_code := p_ae_line_tbl(i).currency_code;
1228 l_ae_line_rec.currency_conversion_rate := p_ae_line_tbl(i).currency_conversion_rate;
1229 l_ae_line_rec.currency_conversion_type := p_ae_line_tbl(i).currency_conversion_type;
1230 l_ae_line_rec.currency_conversion_date := p_ae_line_tbl(i).currency_conversion_date;
1231 l_ae_line_rec.third_party_id := p_ae_line_tbl(i).third_party_id;
1232 l_ae_line_rec.third_party_sub_id := p_ae_line_tbl(i).third_party_sub_id;
1233 l_ae_line_rec.tax_group_code_id := p_ae_line_tbl(i).tax_group_code_id;
1234 l_ae_line_rec.tax_code_id := p_ae_line_tbl(i).tax_code_id;
1235 l_ae_line_rec.location_segment_id := p_ae_line_tbl(i).location_segment_id;
1236 l_ae_line_rec.taxable_entered_dr := p_ae_line_tbl(i).taxable_entered_dr;
1237 l_ae_line_rec.taxable_entered_cr := p_ae_line_tbl(i).taxable_entered_cr;
1238 l_ae_line_rec.taxable_accounted_dr := p_ae_line_tbl(i).taxable_accounted_dr;
1239 l_ae_line_rec.taxable_accounted_cr := p_ae_line_tbl(i).taxable_accounted_cr;
1240 l_ae_line_rec.tax_link_id := p_ae_line_tbl(i).tax_link_id;
1241 l_ae_line_rec.reversed_source_id := p_ae_line_tbl(i).reversed_source_id;
1242 --{2979254
1243 l_ae_line_rec.ref_customer_trx_line_id := p_ae_line_tbl(i).ref_customer_trx_line_id;
1244 l_ae_line_rec.ref_prev_cust_trx_line_id := p_ae_line_tbl(i).ref_prev_cust_trx_line_id;
1245 l_ae_line_rec.ref_cust_trx_line_gl_dist_id := p_ae_line_tbl(i).ref_cust_trx_line_gl_dist_id;
1246 l_ae_line_rec.ref_line_id := p_ae_line_tbl(i).ref_line_id;
1247 l_ae_line_rec.from_amount_dr := p_ae_line_tbl(i).from_amount_dr;
1248 l_ae_line_rec.from_amount_cr := p_ae_line_tbl(i).from_amount_cr;
1249 l_ae_line_rec.from_acctd_amount_dr := p_ae_line_tbl(i).from_acctd_amount_dr;
1250 l_ae_line_rec.from_acctd_amount_cr := p_ae_line_tbl(i).from_acctd_amount_cr;
1251 l_ae_line_rec.ref_account_class := p_ae_line_tbl(i).ref_account_class;
1252 l_ae_line_rec.activity_bucket := p_ae_line_tbl(i).activity_bucket;
1253 l_ae_line_rec.ref_mf_dist_flag := p_ae_line_tbl(i).ref_mf_dist_flag;
1254 l_ae_line_rec.ref_dist_ccid := p_ae_line_tbl(i).ref_dist_ccid;
1255 --}
1256
1257 Dump_Dist_Amts(l_ae_line_rec);
1258
1259
1260 IF PG_DEBUG in ('Y', 'C') THEN
1261 arp_standard.debug( 'sob type = ' || ARP_ACCT_MAIN.ae_sys_rec.sob_type);
1262 END IF;
1263
1264 IF (NVL(ARP_ACCT_MAIN.ae_sys_rec.sob_type,'P') = 'P') THEN
1265 arp_distributions_pkg.insert_p(l_ae_line_rec, l_dummy);
1266 END IF;
1267 END LOOP;
1268
1269 IF PG_DEBUG in ('Y', 'C') THEN
1270 arp_standard.debug( 'ARP_ACCT_MAIN.Insert_Ae_Lines()-');
1271 END IF;
1272
1273 EXCEPTION
1274 WHEN OTHERS THEN
1275 IF PG_DEBUG in ('Y', 'C') THEN
1276 arp_standard.debug('EXCEPTION: ARP_ACCT_MAIN.Insert_Ae_Lines');
1277 END IF;
1278 RAISE;
1279
1280 END Insert_Ae_Lines;
1281
1282 /* ==========================================================================
1283 | PROCEDURE Dump_Dist_Amts
1284 |
1285 | DESCRIPTION
1286 | Dumps data accounting line data
1287 |
1288 | SCOPE - PRIVATE
1289 |
1290 | PARAMETERS
1291 | p_ae_line_rec IN Accounting lines record
1292 *==========================================================================*/
1293 PROCEDURE Dump_Dist_Amts(p_ae_line_rec IN ar_distributions%ROWTYPE) IS
1294 BEGIN
1295
1296 IF PG_DEBUG in ('Y', 'C') THEN
1297 arp_standard.debug('ARP_ACCT_MAIN.Dump_Dist_Amts()+');
1298 END IF;
1299
1300 IF PG_DEBUG in ('Y', 'C') THEN
1301 arp_standard.debug( 'set_of_books_id = ' || ARP_ACCT_MAIN.ae_sys_rec.set_of_books_id);
1302 arp_standard.debug( 'source_type = ' || p_ae_line_rec.source_type);
1303 arp_standard.debug( 'source_type_secondary = ' || p_ae_line_rec.source_type_secondary);
1304 arp_standard.debug( 'source_id = ' || p_ae_line_rec.source_id);
1305 arp_standard.debug( 'source_table = ' || p_ae_line_rec.source_table);
1306 arp_standard.debug( 'code_combination_id = ' || p_ae_line_rec.code_combination_id);
1307 arp_standard.debug( 'amount_dr = ' || p_ae_line_rec.amount_dr);
1308 arp_standard.debug( 'amount_cr = ' || p_ae_line_rec.amount_cr);
1309 arp_standard.debug( 'acctd_amount_dr = ' || p_ae_line_rec.acctd_amount_dr);
1310 arp_standard.debug( 'acctd_amount_cr = ' || p_ae_line_rec.acctd_amount_cr);
1311 arp_standard.debug( 'source_id_secondary = ' || p_ae_line_rec.source_id_secondary);
1312 arp_standard.debug( 'source_table_secondary = ' || p_ae_line_rec.source_table_secondary);
1313 arp_standard.debug( 'source_table_secondary = ' || p_ae_line_rec.source_table_secondary);
1314 arp_standard.debug( 'currency_code = ' || p_ae_line_rec.currency_code);
1315 arp_standard.debug( 'currency_conversion_rate = ' || p_ae_line_rec.currency_conversion_rate);
1316 arp_standard.debug( 'currency_conversion_type = ' || p_ae_line_rec.currency_conversion_type);
1317 arp_standard.debug( 'currency_conversion_date = ' || p_ae_line_rec.currency_conversion_date);
1318 arp_standard.debug( 'third_party_id = ' || p_ae_line_rec.third_party_id);
1319 arp_standard.debug( 'third_party_sub_id = ' || p_ae_line_rec.third_party_sub_id);
1320 arp_standard.debug( 'tax_group_code_id = ' || p_ae_line_rec.tax_group_code_id);
1321 arp_standard.debug( 'tax_code_id = ' || p_ae_line_rec.tax_code_id);
1322 arp_standard.debug( 'location_segment_id = ' || p_ae_line_rec.location_segment_id);
1323 arp_standard.debug( 'taxable_entered_dr = ' || p_ae_line_rec.taxable_entered_dr);
1324 arp_standard.debug( 'taxable_entered_cr = ' || p_ae_line_rec.taxable_entered_cr);
1325 arp_standard.debug( 'taxable_accounted_dr = ' || p_ae_line_rec.taxable_accounted_dr);
1326 arp_standard.debug( 'taxable_accounted_cr = ' || p_ae_line_rec.taxable_accounted_cr);
1327 arp_standard.debug( 'tax_link_id = ' || p_ae_line_rec.tax_link_id);
1328 arp_standard.debug( 'reversed_source_id = ' || p_ae_line_rec.reversed_source_id);
1329 --{2979254
1330 arp_standard.debug( 'ref_customer_trx_line_id = ' || p_ae_line_rec.ref_customer_trx_line_id);
1331 arp_standard.debug( 'ref_prev_cust_trx_line_id = ' || p_ae_line_rec.ref_prev_cust_trx_line_id);
1332 arp_standard.debug( 'ref_cust_trx_line_gl_dist_id = '
1333 || p_ae_line_rec.ref_cust_trx_line_gl_dist_id);
1334 arp_standard.debug( 'ref_line_id = ' || p_ae_line_rec.ref_line_id);
1335 arp_standard.debug( 'from_amount_dr = ' || p_ae_line_rec.from_amount_dr);
1336 arp_standard.debug( 'from_amount_cr = ' || p_ae_line_rec.from_amount_cr);
1337 arp_standard.debug( 'from_acctd_amount_dr = ' || p_ae_line_rec.from_acctd_amount_dr);
1338 arp_standard.debug( 'from_acctd_amount_cr = ' || p_ae_line_rec.from_acctd_amount_cr);
1339 arp_standard.debug( 'ref_account_class = ' || p_ae_line_rec.ref_account_class);
1340 arp_standard.debug( 'activity_bucket = ' || p_ae_line_rec.activity_bucket);
1341 arp_standard.debug( 'ref_dist_ccid = ' || p_ae_line_rec.ref_dist_ccid);
1342 --}
1343
1344 arp_standard.debug('ARP_ACCT_MAIN.Dump_Dist_Amts()-');
1345 END IF;
1346
1347 EXCEPTION
1348 WHEN OTHERS THEN
1349 IF PG_DEBUG in ('Y', 'C') THEN
1350 arp_standard.debug('EXCEPTION: ARP_ACCT_MAIN.Dump_Dist_Amts');
1351 END IF;
1352 RAISE;
1353
1354 END Dump_Dist_Amts;
1355
1356 /*========================================================================
1357 | PRIVATE PROCEDURE Init_Curr_Details
1358 |
1359 | DESCRIPTION
1360 | Retrieves Currency, precision and gain loss account details
1361 | -----------------------------------------------------------
1362 |
1363 | PARAMETERS
1364 | NONE
1365 *=======================================================================*/
1366 PROCEDURE Init_Curr_Details(p_accounting_method IN OUT NOCOPY ar_system_parameters.accounting_method%TYPE) IS
1367
1368 BEGIN
1369
1370 IF PG_DEBUG in ('Y', 'C') THEN
1371 arp_standard.debug('ARP_ACCT_MAIN.Init_Curr_Details(+)');
1372 END IF;
1373
1374 SELECT sob.set_of_books_id,
1375 sob.chart_of_accounts_id,
1376 sob.currency_code,
1377 c.precision,
1378 c.minimum_accountable_unit,
1379 sysp.code_combination_id_gain,
1380 sysp.code_combination_id_loss,
1381 sysp.code_combination_id_round,
1382 sysp.accounting_method
1383 INTO ae_sys_rec.set_of_books_id,
1384 ae_sys_rec.coa_id,
1385 ae_sys_rec.base_currency,
1386 ae_sys_rec.base_precision,
1387 ae_sys_rec.base_min_acc_unit,
1388 ae_sys_rec.gain_cc_id,
1389 ae_sys_rec.loss_cc_id,
1390 ae_sys_rec.round_cc_id,
1391 p_accounting_method
1392 FROM ar_system_parameters sysp,
1393 gl_sets_of_books sob,
1394 fnd_currencies c
1395 WHERE sob.set_of_books_id = sysp.set_of_books_id --would be the row returned from multi org view
1396 AND sob.currency_code = c.currency_code;
1397
1398 --{BUG4301323: The sob_type needs to be defaulted to 'P' Primary
1399 ae_sys_rec.sob_type := 'P';
1400 --}
1401
1402 IF PG_DEBUG in ('Y', 'C') THEN
1403 arp_standard.debug('ARP_ACCT_MAIN.Init_Curr_Details(-)');
1404 END IF;
1405
1406 EXCEPTION
1407 WHEN NO_DATA_FOUND THEN
1408 IF PG_DEBUG in ('Y', 'C') THEN
1409 arp_standard.debug('ARP_ACCT_MAIN.Init_Curr_Details - NO_DATA_FOUND' );
1410 END IF;
1411 RAISE;
1412
1413 WHEN OTHERS THEN
1414 IF PG_DEBUG in ('Y', 'C') THEN
1415 arp_standard.debug('EXCEPTION: ARP_ACCT_MAIN.constructor(-)');
1416 arp_standard.debug(SQLERRM);
1417 END IF;
1418 RAISE;
1419
1420 END Init_Curr_Details;
1421
1422 END ARP_ACCT_MAIN;