[Home] [Help]
PACKAGE BODY: APPS.ARP_PROCESS_APPLICATION2
Source
1 PACKAGE BODY ARP_PROCESS_APPLICATION2 AS
2 /* $Header: ARCEAP2B.pls 120.12 2006/09/18 12:48:01 balkumar ship $ */
3
4 /* =======================================================================
5 | Global Data Types
6 * ======================================================================*/
7 SUBTYPE ae_doc_rec_type IS arp_acct_main.ae_doc_rec_type;
8
9 PG_DEBUG varchar2(1) := NVL(FND_PROFILE.value('AFLOG_ENABLED'), 'N');
10 FUNCTION revision RETURN VARCHAR2 IS
11 BEGIN
12 RETURN '$Revision: 120.12 $';
13 END revision;
14
15 /*===========================================================================+
16 | PROCEDURE |
17 | update_application |
18 | |
19 | DESCRIPTION |
20 | This procedure is used to update an application, e.g. USSGL |
21 | Transaction Code, Cross Currency Rate etc. Columns that can be |
22 | modified without having to reverse the original rows and create |
23 | new ones. We simply update the APP row with the new value. |
24 | |
25 | SCOPE - PUBLIC |
26 | |
27 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED - NONE |
28 | |
29 | ARGUMENTS : IN: |
30 | |
31 | OUT: |
32 | |
33 | RETURNS : NONE |
34 | |
35 | NOTES |
36 | |
37 | MODIFICATION HISTORY |
38 | |
39 | 07/29/1997 Karen Lawrance Release 11. |
40 | Added trans_to_receipt_rate to update call |
41 | for cross currency. |
42 | Also included acctd amount applied to and |
43 | from as OUT NOCOPY parameters. These are used to |
44 | update the form with accurate values. |
45 | 08/21/1997 Tasman Tang Added global_attribute_category, |
46 | global_attribute[1-20] for global |
47 | descriptive flexfield |
48 | 05/24/1999 Debbie Jancis Bug fix 874714 |
49 | update_application should not update anything|
50 | having to do with amount columns because |
51 | amount columns affect posting. Also, |
52 | apply_date or gl_date |
53 | 06/06/2001 S.Nambiar Bug 1815528 - Added claim related parameters |
54 | 07/31/2001 jbeckett Bug 1905659 - For invoice related claim, pass|
55 | trx info to create_claim |
56 | 08/03/2001 jbeckett Bug 1905659 - Added parameter |
57 | p_amount_due_remaining |
58 | 08/10/2001 S.Nambiar Migrated chargeback_customer_trx_id to |
59 | secondary_application_ref_id
60 | 03/15/2002 jbeckett Added new parameters p_application_ref_reason|
61 | and p_customer_reference (bug 2254777). |
62 | 05/09/2002 jbeckett Passes primary_salesrep_id to create_claim |
63 | for invoice related deductions |
64 | 02/20/2002 jbeckett Bug 2751910 - Added p_customer_reason and |
65 | p_applied_rec_app_id to update_application |
66 | 10/25/2005 jbeckett Bug 4565758 - legal_entity_id passed to |
67 | create_claim.
68 +===========================================================================*/
69
70 PROCEDURE update_application(
71 p_ra_id IN NUMBER,
72 p_receipt_ps_id IN NUMBER,
73 p_invoice_ps_id IN NUMBER,
74 p_ussgl_transaction_code IN VARCHAR2,
75 p_application_ref_type IN
76 ar_receivable_applications.application_ref_type%TYPE,
77 p_application_ref_id IN
78 ar_receivable_applications.application_ref_id%TYPE,
79 p_application_ref_num IN
80 ar_receivable_applications.application_ref_num%TYPE,
81 p_secondary_application_ref_id IN
82 ar_receivable_applications.secondary_application_ref_id%TYPE,
83 p_receivable_trx_id IN ar_receivable_applications.receivables_trx_id%TYPE,
84 p_attribute_category IN VARCHAR2,
85 p_attribute1 IN VARCHAR2,
86 p_attribute2 IN VARCHAR2,
87 p_attribute3 IN VARCHAR2,
88 p_attribute4 IN VARCHAR2,
89 p_attribute5 IN VARCHAR2,
90 p_attribute6 IN VARCHAR2,
91 p_attribute7 IN VARCHAR2,
92 p_attribute8 IN VARCHAR2,
93 p_attribute9 IN VARCHAR2,
94 p_attribute10 IN VARCHAR2,
95 p_attribute11 IN VARCHAR2,
96 p_attribute12 IN VARCHAR2,
97 p_attribute13 IN VARCHAR2,
98 p_attribute14 IN VARCHAR2,
99 p_attribute15 IN VARCHAR2,
100 p_global_attribute_category IN VARCHAR2,
101 p_global_attribute1 IN VARCHAR2,
102 p_global_attribute2 IN VARCHAR2,
103 p_global_attribute3 IN VARCHAR2,
104 p_global_attribute4 IN VARCHAR2,
105 p_global_attribute5 IN VARCHAR2,
106 p_global_attribute6 IN VARCHAR2,
107 p_global_attribute7 IN VARCHAR2,
108 p_global_attribute8 IN VARCHAR2,
109 p_global_attribute9 IN VARCHAR2,
110 p_global_attribute10 IN VARCHAR2,
111 p_global_attribute11 IN VARCHAR2,
112 p_global_attribute12 IN VARCHAR2,
113 p_global_attribute13 IN VARCHAR2,
114 p_global_attribute14 IN VARCHAR2,
115 p_global_attribute15 IN VARCHAR2,
116 p_global_attribute16 IN VARCHAR2,
117 p_global_attribute17 IN VARCHAR2,
118 p_global_attribute18 IN VARCHAR2,
119 p_global_attribute19 IN VARCHAR2,
120 p_global_attribute20 IN VARCHAR2,
121 p_comments IN VARCHAR2, -- Added for bug 1839744
122 p_gl_date OUT NOCOPY DATE,
123 p_customer_trx_line_id IN NUMBER,
124 p_module_name IN VARCHAR2,
125 p_module_version IN VARCHAR2,
126 x_application_ref_id OUT NOCOPY
127 ar_receivable_applications.application_ref_id%TYPE,
128 x_application_ref_num OUT NOCOPY
129 ar_receivable_applications.application_ref_num%TYPE,
130 x_return_status OUT NOCOPY VARCHAR2,
131 x_msg_count OUT NOCOPY NUMBER,
132 x_msg_data OUT NOCOPY VARCHAR2,
133 p_acctd_amount_applied_to OUT NOCOPY NUMBER,
134 p_acctd_amount_applied_from OUT NOCOPY NUMBER,
135 p_amount_due_remaining IN ar_payment_schedules.amount_due_remaining%TYPE,
136 p_application_ref_reason IN ar_receivable_applications.application_ref_reason%TYPE,
137 p_customer_reference IN ar_receivable_applications.customer_reference%TYPE,
138 p_customer_reason IN ar_receivable_applications.customer_reason%TYPE,
139 p_applied_rec_app_id IN ar_receivable_applications.applied_rec_app_id%TYPE,
140 x_claim_reason_name OUT NOCOPY VARCHAR2) IS
141
142 l_rec_ra_rec ar_receivable_applications%ROWTYPE;
143 l_currency_code ar_cash_receipts.currency_code%TYPE;
144 l_exchange_rate_type ar_cash_receipts.exchange_rate_type%TYPE;
145 l_exchange_rate_date ar_cash_receipts.exchange_date%TYPE;
146 l_exchange_rate ar_cash_receipts.exchange_rate%TYPE;
147 l_customer_id ar_cash_receipts.pay_from_customer%TYPE;
148 l_bill_to_site_use_id ar_cash_receipts.customer_site_use_id%TYPE;
149 l_ship_to_site_use_id ar_cash_receipts.customer_site_use_id%TYPE;
150 l_receipt_number ar_cash_receipts.receipt_number%TYPE;
151 l_amount_due_remaining NUMBER;
152 l_claim_amount NUMBER;
153 l_customer_trx_id ra_customer_trx.customer_trx_id%TYPE;
154 l_trx_number ra_customer_trx.trx_number%TYPE;
155 l_cust_trx_type_id ra_cust_trx_types.cust_trx_type_id%TYPE;
156 l_salesrep_id ra_customer_trx.primary_salesrep_id%TYPE;
157 --BUG#2750340
158 l_xla_ev_rec arp_xla_events.xla_events_type;
159 l_legal_entity_id ar_cash_receipts.legal_entity_id%TYPE;
160
161 BEGIN
162 IF PG_DEBUG in ('Y', 'C') THEN
163 arp_standard.debug( 'arp_process_application.update_application()+');
164 END IF;
165
166 IF (p_ra_id IS NULL)
167 THEN
168 APP_EXCEPTION.INVALID_ARGUMENT(
169 'ARP_PROCESS_APPLICATION.UPDATE_APPLICATION'
170 , 'P_RA_ID'
171 , 'NULL');
172
173 ELSIF (p_invoice_ps_id IS NULL)
174 THEN
175 APP_EXCEPTION.INVALID_ARGUMENT(
176 'ARP_PROCESS_APPLICATION.UPDATE_APPLICATION'
177 , 'p_invoice_ps_id'
178 , 'NULL');
179
180 END IF;
181
182 -- First get the old values
183 arp_app_pkg.fetch_p(p_ra_id, l_rec_ra_rec);
184
185 p_acctd_amount_applied_to := l_rec_ra_rec.acctd_amount_applied_to;
186 p_acctd_amount_applied_from := l_rec_ra_rec.acctd_amount_applied_from;
187
188 -- The assign the passed values
189
190 -- KML 12/04/1996
191 -- Added if restriction, as p_receipt_ps_id will be null for
192 -- Credit Memo Applications.
193
194 if p_receipt_ps_id is not null then
195 l_rec_ra_rec.payment_schedule_id := p_receipt_ps_id;
196 end if;
197
198 l_rec_ra_rec.applied_payment_schedule_id := p_invoice_ps_id;
199 l_rec_ra_rec.applied_customer_trx_line_id := p_customer_trx_line_id;
200 l_rec_ra_rec.ussgl_transaction_code := p_ussgl_transaction_code;
201 l_rec_ra_rec.attribute_category := p_attribute_category;
202 l_rec_ra_rec.attribute1 := p_attribute1;
203 l_rec_ra_rec.attribute2 := p_attribute2;
204 l_rec_ra_rec.attribute3 := p_attribute3;
205 l_rec_ra_rec.attribute4 := p_attribute4;
206 l_rec_ra_rec.attribute5 := p_attribute5;
207 l_rec_ra_rec.attribute6 := p_attribute6;
208 l_rec_ra_rec.attribute7 := p_attribute7;
209 l_rec_ra_rec.attribute8 := p_attribute8;
210 l_rec_ra_rec.attribute9 := p_attribute9;
211 l_rec_ra_rec.attribute10 := p_attribute10;
212 l_rec_ra_rec.attribute11 := p_attribute11;
213 l_rec_ra_rec.attribute12 := p_attribute12;
214 l_rec_ra_rec.attribute13 := p_attribute13;
215 l_rec_ra_rec.attribute14 := p_attribute14;
216 l_rec_ra_rec.attribute15 := p_attribute15;
217 l_rec_ra_rec.global_attribute_category := p_global_attribute_category;
218 l_rec_ra_rec.global_attribute1 := p_global_attribute1;
219 l_rec_ra_rec.global_attribute2 := p_global_attribute2;
220 l_rec_ra_rec.global_attribute3 := p_global_attribute3;
221 l_rec_ra_rec.global_attribute4 := p_global_attribute4;
222 l_rec_ra_rec.global_attribute5 := p_global_attribute5;
223 l_rec_ra_rec.global_attribute6 := p_global_attribute6;
224 l_rec_ra_rec.global_attribute7 := p_global_attribute7;
225 l_rec_ra_rec.global_attribute8 := p_global_attribute8;
226 l_rec_ra_rec.global_attribute9 := p_global_attribute9;
227 l_rec_ra_rec.global_attribute10 := p_global_attribute10;
228 l_rec_ra_rec.global_attribute11 := p_global_attribute11;
229 l_rec_ra_rec.global_attribute12 := p_global_attribute12;
230 l_rec_ra_rec.global_attribute13 := p_global_attribute13;
231 l_rec_ra_rec.global_attribute14 := p_global_attribute14;
232 l_rec_ra_rec.global_attribute15 := p_global_attribute15;
233 l_rec_ra_rec.global_attribute16 := p_global_attribute16;
234 l_rec_ra_rec.global_attribute17 := p_global_attribute17;
235 l_rec_ra_rec.global_attribute18 := p_global_attribute18;
236 l_rec_ra_rec.global_attribute19 := p_global_attribute19;
237 l_rec_ra_rec.global_attribute20 := p_global_attribute20;
238 l_rec_ra_rec.comments := p_comments; -- Added for bug 1839744
239 l_rec_ra_rec.application_ref_type := p_application_ref_type;
240 l_rec_ra_rec.application_ref_num := p_application_ref_num;
241 l_rec_ra_rec.application_ref_id := p_application_ref_id;
242 l_rec_ra_rec.secondary_application_ref_id := p_secondary_application_ref_id;
243 l_rec_ra_rec.application_ref_reason := p_application_ref_reason;
244 l_rec_ra_rec.customer_reference := p_customer_reference;
245 l_rec_ra_rec.applied_rec_app_id := p_applied_rec_app_id;
246 l_rec_ra_rec.customer_reason := p_customer_reason;
247
248 --Bug 4131243 - set the out parameters for application_ref_num/id so
249 --they are passed back correctly if claim is not created.
250 x_application_ref_num := p_application_ref_num;
251 x_application_ref_id := p_secondary_application_ref_id;
252
253 --Bug 1815528 If claim type is CLAIM, then create claim
254
255 IF PG_DEBUG in ('Y', 'C') THEN
256 arp_standard.debug( 'p_application_ref_type = '||p_application_ref_type);
257 arp_standard.debug( 'p_application_ref_num = '||nvl(p_application_ref_num,'NULL'));
258 END IF;
259 IF (p_application_ref_type = 'CLAIM' AND
260 p_application_ref_num IS NULL)
261 THEN
262 IF p_invoice_ps_id = -4
263 -- its a non trx related claim, get all details from receipt
264 THEN
265 --fetch the receipt details
266 SELECT ps.cash_receipt_id
267 , cr.currency_code
268 , cr.exchange_rate_type
269 , cr.exchange_date
270 , cr.exchange_rate
271 , cr.pay_from_customer
272 , cr.customer_site_use_id
273 , NULL
274 , cr.receipt_number
275 , cr.legal_entity_id
276 INTO l_rec_ra_rec.cash_receipt_id
277 , l_currency_code
278 , l_exchange_rate_type
279 , l_exchange_rate_date
280 , l_exchange_rate
281 , l_customer_id
282 , l_bill_to_site_use_id
283 , l_ship_to_site_use_id
284 , l_receipt_number
285 , l_legal_entity_id
286 FROM ar_payment_schedules ps
287 , ar_cash_receipts cr
288 , ar_cash_receipt_history crh
289 , ar_receipt_methods rm
290 , ce_bank_acct_uses ba
291 , ar_receipt_method_accounts rma
292 WHERE ps.payment_schedule_id = p_receipt_ps_id
293 AND cr.cash_receipt_id = ps.cash_receipt_id
294 AND crh.cash_receipt_id = cr.cash_receipt_id
295 AND crh.current_record_flag = 'Y'
296 AND rm.receipt_method_id = cr.receipt_method_id
297 AND ba.bank_acct_use_id = cr.remit_bank_acct_use_id
298 AND rma.remit_bank_acct_use_id = ba.bank_acct_use_id
299 AND rma.receipt_method_id = rm.receipt_method_id;
300
301 l_customer_trx_id := NULL;
302 l_trx_number := NULL;
303 l_cust_trx_type_id := NULL;
304 l_salesrep_id := NULL; -- bug 2361331
305
306 ELSE
307 -- claim is trx related, fetch invoice details
308 SELECT t.invoice_currency_code
309 , t.exchange_rate_type
310 , t.exchange_date
311 , t.exchange_rate
312 , t.customer_trx_id
313 , t.trx_number
314 , t.cust_trx_type_id
315 , t.bill_to_customer_id
316 , t.bill_to_site_use_id
317 , t.ship_to_site_use_id
318 , p.amount_due_remaining
319 , t.primary_salesrep_id
320 , t.legal_entity_id
321 INTO l_currency_code
322 , l_exchange_rate_type
323 , l_exchange_rate_date
324 , l_exchange_rate
325 , l_customer_trx_id
326 , l_trx_number
327 , l_cust_trx_type_id
328 , l_customer_id
329 , l_bill_to_site_use_id
330 , l_ship_to_site_use_id
331 , l_amount_due_remaining
332 , l_salesrep_id -- bug 2361331
333 , l_legal_entity_id
334 FROM ra_customer_trx t
335 , ar_payment_schedules p
336 WHERE t.customer_trx_id = p.customer_trx_id
337 AND p.payment_schedule_id = p_invoice_ps_id;
338
339 SELECT cr.cash_receipt_id, cr.receipt_number
340 INTO l_rec_ra_rec.cash_receipt_id
341 , l_receipt_number
342 FROM ar_cash_receipts cr,
343 ar_payment_schedules ps
344 WHERE ps.payment_schedule_id = p_receipt_ps_id
345 AND cr.cash_receipt_id = ps.cash_receipt_id;
346 END IF;
347
348 IF p_invoice_ps_id = -4
349 THEN
350 l_claim_amount := l_rec_ra_rec.amount_applied;
351 ELSIF
352 p_amount_due_remaining IS NULL
353 THEN
354 l_claim_amount := l_amount_due_remaining;
355 ELSE
356 l_claim_amount := p_amount_due_remaining;
357 END IF;
358
359 arp_process_application.create_claim(
360 p_amount => l_claim_amount
361 , p_amount_applied => l_rec_ra_rec.amount_applied
362 , p_currency_code => l_currency_code
363 , p_exchange_rate_type => l_exchange_rate_type
364 , p_exchange_rate_date => l_exchange_rate_date
365 , p_exchange_rate => l_exchange_rate
366 , p_customer_trx_id => l_customer_trx_id
367 , p_invoice_ps_id => p_invoice_ps_id
368 , p_cust_trx_type_id => l_cust_trx_type_id
369 , p_trx_number => l_trx_number
370 , p_cust_account_id => l_customer_id
371 , p_bill_to_site_id => l_bill_to_site_use_id
372 , p_ship_to_site_id => l_ship_to_site_use_id
373 , p_salesrep_id => l_salesrep_id -- bug 2361331
374 , p_customer_ref_date => NULL
375 , p_customer_ref_number => p_customer_reference
376 , p_cash_receipt_id => l_rec_ra_rec.cash_receipt_id
377 , p_receipt_number => l_receipt_number
378 , p_customer_reason => p_customer_reason
379 , p_reason_id => TO_NUMBER(p_application_ref_reason)
380 , p_comments => l_rec_ra_rec.comments
381 , p_apply_date => l_rec_ra_rec.apply_date --Bug5495310
382 , p_attribute_category => p_attribute_category
383 , p_attribute1 => p_attribute1
384 , p_attribute2 => p_attribute2
385 , p_attribute3 => p_attribute3
386 , p_attribute4 => p_attribute4
387 , p_attribute5 => p_attribute5
388 , p_attribute6 => p_attribute6
389 , p_attribute7 => p_attribute7
390 , p_attribute8 => p_attribute8
391 , p_attribute9 => p_attribute9
392 , p_attribute10 => p_attribute10
393 , p_attribute11 => p_attribute11
394 , p_attribute12 => p_attribute12
395 , p_attribute13 => p_attribute13
396 , p_attribute14 => p_attribute14
397 , p_attribute15 => p_attribute15
398 , x_return_status => x_return_status
399 , x_msg_count => x_msg_count
400 , x_msg_data => x_msg_data
401 , x_claim_id => l_rec_ra_rec.secondary_application_ref_id
402 , x_claim_number => l_rec_ra_rec.application_ref_num
403 , x_claim_reason_name => x_claim_reason_name
404 , p_legal_entity_id => l_legal_entity_id);
405
406 x_application_ref_id := l_rec_ra_rec.secondary_application_ref_id;
407 x_application_ref_num := l_rec_ra_rec.application_ref_num;
408
409 END IF;
410
411 -- Dump the data into database
412 arp_app_pkg.update_p(l_rec_ra_rec);
413 p_gl_date := l_rec_ra_rec.gl_date;
414
415 --BUG#2750340
416 l_xla_ev_rec.xla_from_doc_id := p_ra_id;
417 l_xla_ev_rec.xla_to_doc_id := p_ra_id;
418 l_xla_ev_rec.xla_doc_table := 'APP';
419 l_xla_ev_rec.xla_mode := 'O';
420 l_xla_ev_rec.xla_call := 'B';
421 ARP_XLA_EVENTS.create_events(p_xla_ev_rec => l_xla_ev_rec);
422
423 IF PG_DEBUG in ('Y', 'C') THEN
424 arp_standard.debug( 'arp_process_application.update_application()-');
425 END IF;
426
427 EXCEPTION
428 when others then
429 raise;
430
431 END update_application;
432
433 /*===========================================================================+
434 | PROCEDURE
435 | delete_selected_transaction
436 |
437 | DESCRIPTION
438 | This procedure is used to delete an application that has been
439 | created through the automatic receipt creation process.
440 |
441 | SCOPE - PUBLIC
442 |
443 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED - NONE
444 |
445 | ARGUMENTS : IN:
446 | p_ra_id Id of application to be deleted.
447 | p_app_ps_id Payment Schedule Id of the applied
448 | Transaction.
449 |
450 | OUT:
451 |
452 | RETURNS : NONE
453 |
454 | NOTES
455 |
456 | MODIFICATION HISTORY
457 | 12/06/1996 Karen Lawrance Created
458 | 10/22/1997 Karen Murphy Bug #567872. Added code to update the
459 | UNAPP row in receivable applications
460 | when an APP row is deleted.
461 12/04/1997 Karen Murphy Bug fix #567872. Added the setting of the
462 acctd_amount_applied_from for the UNAPP row.
463 | 24/03/1998 Vikram Ahluwalia Plugin calls one delete for the APP record
464 | and a combination of delete followed by
465 | create for the UNAPP record accounting.
466 | Though this appears to be specifically
467 | written for Unconfirmed Autoreceipts (APP
468 | and UNAPP combination it patched for
469 | completeness - notice the confirmed flag
470 | check in delete cursor and create call
471 +===========================================================================*/
472 PROCEDURE delete_selected_transaction (
473 p_ra_id IN NUMBER
474 , p_app_ps_id IN NUMBER
475 ) IS
476
477 CURSOR get_app_C(l_app_id NUMBER) IS
478 select app.receivable_application_id app_id,
479 app.cash_receipt_id cr_id
480 from ar_receivable_applications app
481 where app.receivable_application_id = l_app_id
482 and nvl(app.confirmed_flag,'Y') = 'Y' --confirmed records have accounting only
483 and exists (select 'x'
484 from ar_distributions ard
485 where ard.source_table = 'RA'
486 and ard.source_id = app.receivable_application_id);
487
488 lr_ps_rec ar_payment_schedules%ROWTYPE;
489 lr_ra_rec ar_receivable_applications%ROWTYPE;
490
491 ln_amount_applied NUMBER;
492 ln_acctd_amount_applied_from NUMBER;
493 ln_cash_receipt_id NUMBER;
494 ln_unapp_ra_id NUMBER;
495 l_ae_doc_rec ae_doc_rec_type;
496
497 BEGIN
498 IF PG_DEBUG in ('Y', 'C') THEN
499 arp_standard.debug( 'arp_process_application.delete_selected_transaction()+');
500 END IF;
501
502 -- Check that the Application Id, and the Applied Payment Schedule Id
503 -- have been provided.
504 IF (p_ra_id IS NULL)
505 THEN
506 APP_EXCEPTION.INVALID_ARGUMENT(
507 'ARP_PROCESS_APPLICATION.DELETE_AUTOMATIC_APPLICATION'
508 , 'P_RA_ID'
509 , 'NULL');
510 ELSIF (p_app_ps_id IS NULL)
511 THEN
512 APP_EXCEPTION.INVALID_ARGUMENT(
513 'ARP_PROCESS_APPLICATION.DELETE_AUTOMATIC_APPLICATION'
514 , 'P_APP_PS_ID'
515 , 'NULL');
516 END IF;
517
518 -- Before we delete it, get the cash receipt id and amount applied
519 -- for the application.
520 select ra.cash_receipt_id,
521 ra.amount_applied,
522 ra.acctd_amount_applied_from
523 into ln_cash_receipt_id,
524 ln_amount_applied,
525 ln_acctd_amount_applied_from
526 from ar_receivable_applications ra
527 where ra.receivable_application_id = p_ra_id;
528
529 --
530 --Release 11.5 delete child accounting records associated with
531 --parent applications for APP
532 --
533 FOR l_get_app_rec IN get_app_C(p_ra_id) LOOP
534
535 l_ae_doc_rec.document_type := 'RECEIPT';
536 l_ae_doc_rec.document_id := l_get_app_rec.cr_id;
537 l_ae_doc_rec.accounting_entity_level := 'ONE';
538 l_ae_doc_rec.source_table := 'RA';
539 l_ae_doc_rec.source_id := l_get_app_rec.app_id; --same as p_ra_id
540 l_ae_doc_rec.source_id_old := '';
541 l_ae_doc_rec.other_flag := '';
542 arp_acct_main.Delete_Acct_Entry(l_ae_doc_rec);
543
544 END LOOP;
545
546 -- Delete Receivable Application record.
547 arp_app_pkg.delete_p(p_ra_id);
548
549 /*---------------------------------+
550 | Calling central MRC library |
551 | for MRC Integration |
552 +---------------------------------*/
553
554 ar_mrc_engine.maintain_mrc_data(
555 p_event_mode => 'DELETE',
556 p_table_name => 'AR_RECEIVABLE_APPLICATIONS',
557 p_mode => 'SINGLE',
558 p_key_value => p_ra_id);
559
560 --Bug#2750340
561 ARP_XLA_EVENTS.delete_event
562 ( p_document_id => p_ra_id,
563 p_doc_table => 'APP');
564
565 -- Populate the Payment Schedule record from ar_payment_schedules,
566 -- based on the provided Applied_Payment_Schedule_Id.
567 arp_ps_pkg.fetch_p( p_app_ps_id, lr_ps_rec );
568
569 -- Update the Transaction's Payment Schedule, set flag "Selected for
570 -- Receipt Batch Id" to null, allowing it to be selected again for
571 -- automatic payment.
572 lr_ps_rec.selected_for_receipt_batch_id := null;
573
574 arp_ps_pkg.update_p(lr_ps_rec, p_app_ps_id);
575
576 ----------------------------------------------------------------
577 -- Now that we have deleted the application and updated the
578 -- payment schedule, update the UNAPP row for the cash receipt.
579 -- Amount applied needs to be reduced by the amount that was
580 -- deleted.
581 ----------------------------------------------------------------
582
583 IF PG_DEBUG in ('Y', 'C') THEN
584 arp_standard.debug('delete_selected_transaction: ' || 'Getting the Receivable Application Id for the UNAPP row');
585 END IF;
586 -- Get the receivable application id for the UNAPP row.
587 select ra.receivable_application_id
588 into ln_unapp_ra_id
589 from ar_receivable_applications ra
590 where ra.cash_receipt_id = ln_cash_receipt_id
591 and ra.status = 'UNAPP';
592
593 IF PG_DEBUG in ('Y', 'C') THEN
594 arp_standard.debug('delete_selected_transaction: ' || 'Fetch the UNAPP row');
595 END IF;
596 -- Fetch the UNAPP row.
597 arp_app_pkg.fetch_p( ln_unapp_ra_id, lr_ra_rec );
598
599 -- Set the amount with the new value.
600 lr_ra_rec.amount_applied := lr_ra_rec.amount_applied - ln_amount_applied;
601
602 IF PG_DEBUG in ('Y', 'C') THEN
603 arp_standard.debug('delete_selected_transaction: ' || 'New UNAPP amount: ' || to_char(lr_ra_rec.amount_applied));
604 END IF;
605
606 -- Set the acctd amount with the new value.
607 lr_ra_rec.acctd_amount_applied_from := lr_ra_rec.acctd_amount_applied_from - ln_acctd_amount_applied_from;
608 IF PG_DEBUG in ('Y', 'C') THEN
609 arp_standard.debug('delete_selected_transaction: ' || 'Update the UNAPP row');
610 END IF;
611 --
612 --Release 11.5 delete child accounting records associated with
613 --parent applications UNAPP record as update is a combination
614 --of delete for by create
615 --
616 FOR l_get_app_rec IN get_app_C(lr_ra_rec.receivable_application_id) LOOP
617
618 l_ae_doc_rec.document_type := 'RECEIPT';
619 l_ae_doc_rec.document_id := l_get_app_rec.cr_id;
620 l_ae_doc_rec.accounting_entity_level := 'ONE';
621 l_ae_doc_rec.source_table := 'RA';
622 l_ae_doc_rec.source_id := l_get_app_rec.app_id;
623 l_ae_doc_rec.source_id_old := '';
624 l_ae_doc_rec.other_flag := '';
625 arp_acct_main.Delete_Acct_Entry(l_ae_doc_rec);
626
627 END LOOP;
628
629 -- Update the UNAPP row.
630 arp_app_pkg.update_p(lr_ra_rec);
631
632 --
633 --Release 11.5 create accounting associated with UNAPP row
634 --This is standalone and not paired with an APP
635 --
636 IF NVL(lr_ra_rec.confirmed_flag,'Y') = 'Y' THEN
637 l_ae_doc_rec.document_type := 'RECEIPT';
638 l_ae_doc_rec.document_id := lr_ra_rec.cash_receipt_id;
639 l_ae_doc_rec.accounting_entity_level := 'ONE';
640 l_ae_doc_rec.source_table := 'RA';
641 l_ae_doc_rec.source_id := lr_ra_rec.receivable_application_id;
642 l_ae_doc_rec.source_id_old := '';
643 l_ae_doc_rec.other_flag := '';
644 arp_acct_main.Create_Acct_Entry(l_ae_doc_rec);
645 END IF;
646
647 IF PG_DEBUG in ('Y', 'C') THEN
648 arp_standard.debug('delete_selected_transaction: ' || 'arp_process_application.delete_receivable_application()-');
649 END IF;
650
651 EXCEPTION
652 WHEN OTHERS THEN
653 IF PG_DEBUG in ('Y', 'C') THEN
654 arp_standard.debug('delete_selected_transaction: ' || '-- EXCEPTION:');
655 arp_standard.debug('delete_selected_transaction: ' || 'Printing procedure parameter values:');
656 arp_standard.debug('delete_selected_transaction: ' || '-- p_ra_id = '||TO_CHAR(p_ra_id));
657 arp_standard.debug('delete_selected_transaction: ' || '-- p_app_ps_id = '||TO_CHAR(p_app_ps_id));
658 END IF;
659 app_exception.raise_exception;
660 END delete_selected_transaction;
661
662 END arp_process_application2;