[Home] [Help]
PACKAGE BODY: APPS.ARP_PROCESS_CHARGEBACK
Source
1 PACKAGE BODY ARP_PROCESS_CHARGEBACK AS
2 /* $Header: ARCECBB.pls 120.17.12020000.6 2012/10/08 11:36:47 ankuagar ship $*/
3 PG_DEBUG varchar2(1) := NVL(FND_PROFILE.value('AFLOG_ENABLED'), 'N');
4
5 NULL_VAR ar_payment_schedules%ROWTYPE; /* Added for Bug 460966 - Oracle 8 */
6 PROCEDURE validate_args_revcb(
7 p_cb_ct_id IN ra_customer_trx.customer_trx_id%TYPE,
8 p_reversal_gl_date IN DATE,
9 p_reversal_date IN DATE );
10
11 PROCEDURE validate_args_cbrev_ct (
12 p_ct_id IN ra_customer_trx.customer_trx_id%TYPE );
13
14 PROCEDURE validate_args_cbrev_group(
15 p_ps_id IN ar_payment_schedules.payment_schedule_id%TYPE,
16 p_ass_cr_id IN ar_adjustments.associated_cash_receipt_id%TYPE,
17 p_ct_count IN NUMBER );
18 G_MSG_HIGH CONSTANT NUMBER := FND_MSG_PUB.G_MSG_LVL_DEBUG_HIGH ;
19
20 /*===========================================================================+
21 | FUNCTION
22 | revision
23 | |
24 | DESCRIPTION |
25 | This function returns the revision number of this package.
26 | |
27 | SCOPE - PUBLIC |
28 | |
29 | RETURNS : Revision number of this package
30 | |
31 | MODIFICATION HISTORY
32 | 6/25/1996 Harri Kaukovuo Created
33 +===========================================================================*/
34
35 FUNCTION revision RETURN VARCHAR2 IS
36 BEGIN
37 RETURN '$Revision: 120.17.12020000.6 $';
38 END revision;
39
40 /*===========================================================================+
41 | PROCEDURE |
42 | reverse_chargeback - Reverse a charge back |
43 | |
44 | DESCRIPTION |
45 | This function reverses a charge back after checking that it can be done|
46 | |
47 | SCOPE - PUBLIC |
48 | |
49 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED |
50 | arp_process_adjustment.insert_reverse_actions |
51 | Setup to reverse an adjustment as part of chargeback reversal|
52 | arp_ps_util.update_reverse_actions |
53 | Setup to reverse the payment schedule associated with the |
54 | chargeback |
55 | |
56 | ARGUMENTS : IN: |
57 | p_cb_ct_id - Charge back Customer transaction Id |
58 | p_reversal_gl_date - Reversal GL date |
59 | p_reversal_date - Reversal Date |
60 | p_module_name - Module that called this procedure |
61 | p_module_version - Version of the module that called this |
62 | procedure |
63 | OUT: |
64 | |
65 | RETURNS : NONE |
66 | |
67 | NOTES |
68 | This procedure is originally converted from C -procedure armrcb
69 | which is in file armcb.lpc.
70 | |
71 | MODIFICATION HISTORY - 04/25/95 - Created by Ganesh Vaidee |
72 | 05/02/95 - Removed the comment on p_created_from |
73 | variable |
74 | 05/02/95 - Assigned 'REVERSE_CHARGEBACK' to |
75 | l_adj_rec.created_from variable |
76 | S.Nambiar 03/23/2001 Modified reverse_chargeback procedure to incorporate |
77 | the new functionality to create Chargeback aganist |
78 | receipts. |
79 | In case of receipt CB, p_type will be "RECEIPT" |
80 | in all other cases it will be defaulted to "TRANSACTION"
81 +===========================================================================*/
82 PROCEDURE reverse_chargeback(
83 p_cb_ct_id IN ra_customer_trx.customer_trx_id%TYPE,
84 p_reversal_gl_date IN DATE,
85 p_reversal_date IN DATE,
86 p_module_name IN VARCHAR2,
87 p_module_version IN VARCHAR2,
88 p_type IN VARCHAR2 DEFAULT 'TRANSACTION' ) IS
89 l_amount NUMBER;
90 l_acctd_amount NUMBER;
91 l_ps_id NUMBER;
92 --
93 l_adj_rec ar_adjustments%ROWTYPE;
94 --
95 l_return_code VARCHAR2(20);
96 l_app_rec arp_global.app_rec_type;
97 --
98 l_msg_count number;
99 l_msg_data varchar2(250);
100 l_return_status varchar2(10);
101 l_new_adjustment_number ar_adjustments.adjustment_number%TYPE;
102 l_new_adjustment_id ar_adjustments.adjustment_id%TYPE;
103 l_mesg varchar2(250);
104 adj_api_failure exception;
105 --
106 BEGIN
107 IF PG_DEBUG in ('Y', 'C') THEN
108 arp_standard.debug( 'arp_process_chargeback.reverse_chargeback()+');
109 arp_standard.debug('reverse_chargeback: ' || to_char( p_cb_ct_id ) );
110 END IF;
111
112 IF ( p_module_name IS NOT NULL AND p_module_version IS NOT NULL ) THEN
113 validate_args_revcb( p_cb_ct_id, p_reversal_gl_date,
114 p_reversal_date );
115 END IF;
116 --
117 SELECT ps.amount_due_remaining,
118 -ps.amount_due_remaining,
119 ps.acctd_amount_due_remaining,
120 -ps.acctd_amount_due_remaining,
121 ps.payment_schedule_id,
122 ps.associated_cash_receipt_id,
123 NVL( -ps.amount_line_items_remaining, 0 ),
124 NVL( -ps.freight_remaining, 0 ),
125 NVL( -ps.tax_remaining, 0 ),
126 NVL( -ps.receivables_charges_remaining, 0 )
127 INTO l_amount,
128 l_adj_rec.amount,
129 l_acctd_amount,
130 l_adj_rec.acctd_amount,
131 l_ps_id,
132 l_adj_rec.associated_cash_receipt_id,
133 l_adj_rec.line_adjusted,
134 l_adj_rec.freight_adjusted,
135 l_adj_rec.tax_adjusted,
136 l_adj_rec.receivables_charges_adjusted
137 FROM ar_payment_schedules ps
138 WHERE ps.customer_trx_id = p_cb_ct_id
139 AND ps.class = 'CB';
140
141 SELECT dist.code_combination_id
142 INTO l_adj_rec.code_combination_id
143 FROM ra_cust_trx_line_gl_dist dist,
144 ra_customer_trx ct
145 WHERE ct.customer_trx_id = p_cb_ct_id
146 AND ct.customer_trx_id = dist.customer_trx_id
147 AND dist.account_class = 'REV';
148
149 --snambiar - while creating receipt chargebacks,there is no adjustment
150 --created. So while reversing,there is no adjustment to reverse. Instead,
151 --we need to create an adjustment to adjust the actual chargeback.
152
153 IF p_type <> 'TRANSACTION' THEN
154 BEGIN
155 --snambiar. For receipt chargeback,we will pass p_type as "RECEIPT"
156 --and in all other cases,p_type is defaulted to "TRANSACTION"
157 --Here we need to create the adjustment aganist the chargeback.
158
159 l_adj_rec.apply_date := p_reversal_date;
160 l_adj_rec.gl_date := p_reversal_gl_date;
161 --
162 l_adj_rec.customer_trx_id := p_cb_ct_id;
163 --
164 l_adj_rec.payment_schedule_id := l_ps_id;
165 l_adj_rec.receivables_trx_id := -12;
166 l_adj_rec.POSTABLE := 'Y';
167 l_adj_rec.type := 'INVOICE';
168 l_adj_rec.adjustment_type := 'M';
169 --
170 l_adj_rec.created_from := 'REVERSE_CHARGEBACK';
171 --
172 ar_adjust_pub.Create_Adjustment (
173 p_api_name => 'AR_ADJUST_PUB',
174 p_api_version => '1',
175 p_init_msg_list => FND_API.G_TRUE,
176 p_commit_flag => FND_API.G_FALSE,
177 p_validation_level => FND_API.G_VALID_LEVEL_FULL,
178 p_msg_count => l_msg_count,
179 p_msg_data => l_msg_data,
180 p_return_status => l_return_status,
181 p_adj_rec => l_adj_rec,
182 p_new_adjust_number => l_new_adjustment_number,
183 p_new_adjust_id => l_new_adjustment_id);
184
185 IF l_return_status <> 'S'
186 THEN
187 IF l_msg_count > 1
188 THEN
189 fnd_msg_pub.reset ;
190 l_mesg := fnd_msg_pub.get(p_encoded=>FND_API.G_FALSE);
191 WHILE l_mesg IS NOT NULL
192 LOOP
193 IF PG_DEBUG in ('Y', 'C') THEN
194 arp_util.debug ('reverse_chargeback: ' || l_mesg,G_MSG_HIGH);
195 END IF;
196 l_mesg := fnd_msg_pub.get(p_encoded=>FND_API.G_FALSE);
197 END LOOP ;
198 ELSE
199 l_mesg := l_msg_data ;
200 END IF;
201
202 raise adj_api_failure;
203
204 END IF;
205
206 RETURN;
207 EXCEPTION
208 WHEN adj_api_failure THEN
209 IF PG_DEBUG in ('Y', 'C') THEN
210 arp_standard.debug('EXCEPTION: arp_process_chargeback.reverse_chargeback
211 receipt CB adjustment API failed' );
212 END IF;
213 RAISE;
214 WHEN OTHERS THEN
215 IF PG_DEBUG in ('Y', 'C') THEN
216 arp_standard.debug('EXCEPTION: arp_process_chargeback.reverse_chargeback
217 receipt CB adjustment failed' );
218 END IF;
219 RAISE;
220
221 END;
222
223 ELSE
224 --
225 l_adj_rec.apply_date := p_reversal_date;
226 l_adj_rec.gl_date := p_reversal_gl_date;
227 --
228 l_adj_rec.customer_trx_id := p_cb_ct_id;
229 --
230 l_adj_rec.payment_schedule_id := l_ps_id;
231 l_adj_rec.receivables_trx_id := arp_global.G_CB_REV_RT_ID;
232 l_adj_rec.POSTABLE := 'Y';
233 l_adj_rec.type := 'INVOICE';
234 l_adj_rec.adjustment_type := 'M';
235 --
236 l_adj_rec.created_from := 'REVERSE_CHARGEBACK';
237 --
238 arp_process_adjustment.insert_reverse_actions( l_adj_rec, NULL, NULL );
239 --
240 -- Populate the payment schedule data structure
241 --
242 l_app_rec.amount_applied := l_amount;
243 l_app_rec.line_applied := l_amount;
244 l_app_rec.acctd_amount_applied := l_acctd_amount;
245 --
246 -- Get closed dates
247 --
248 arp_ps_util.get_closed_dates( l_ps_id, p_reversal_gl_date,
249 p_reversal_date, l_app_rec.gl_date_closed,
250 l_app_rec.actual_date_closed, 'PMT' );
251 --
252 l_app_rec.ps_id := l_ps_id;
253 l_app_rec.trx_type := 'AR_ADJ';
254 l_app_rec.user_id := FND_GLOBAL.user_id;
255 --
256 arp_ps_util.update_reverse_actions( l_app_rec, NULL, NULL);
257 END IF;
258
259 IF PG_DEBUG in ('Y', 'C') THEN
260 arp_standard.debug( 'arp_process_chargeback.reverse_chargeback()-');
261 END IF;
262
263 EXCEPTION
264 WHEN OTHERS THEN
265 IF PG_DEBUG in ('Y', 'C') THEN
266 arp_standard.debug('reverse_chargeback: ' ||
267 'EXCEPTION: arp_process_chargeback.reverse_chargeback' );
268 END IF;
269 RAISE;
270 END reverse_chargeback;
271 --
272 /*===========================================================================+
273 | PROCEDURE |
274 | validate_args_revcb |
275 | |
276 | DESCRIPTION |
277 | Validate arguments passed to reverse_chargeback procedure |
278 | |
279 | SCOPE - PRIVATE |
280 | |
281 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED - NONE |
282 | |
283 | ARGUMENTS : IN: |
284 | p_cb_ct_id - Charge back Customer transaction Id |
285 | p_reversal_gl_date - Reversal GL date |
286 | p_reversal_date - Reversal Date |
287 | OUT: |
288 | |
289 | RETURNS : NONE |
290 | |
291 | NOTES |
292 | |
293 | MODIFICATION HISTORY - Created by Ganesh Vaidee - 04/25/95 |
294 | |
295 +===========================================================================*/
296 PROCEDURE validate_args_revcb(
297 p_cb_ct_id IN ra_customer_trx.customer_trx_id%TYPE,
298 p_reversal_gl_date IN DATE,
299 p_reversal_date IN DATE ) IS
300 BEGIN
301 IF PG_DEBUG in ('Y', 'C') THEN
302 arp_standard.debug( '>>>>>>>> arp_process_chargeback.validate_args_revcb' );
303 END IF;
304 --
305 IF ( p_cb_ct_id is NULL OR p_reversal_gl_date is NULL OR
306 p_reversal_date is NULL ) THEN
307 FND_MESSAGE.set_name ('AR', 'AR_ARGUEMENTS_FAIL' );
308 APP_EXCEPTION.raise_exception;
309 END IF;
310 IF PG_DEBUG in ('Y', 'C') THEN
311 arp_standard.debug( '<<<<<<<< arp_process_chargeback.validate_args_revcb' );
312 END IF;
313 --
314 EXCEPTION
315 WHEN OTHERS THEN
316 IF PG_DEBUG in ('Y', 'C') THEN
317 arp_standard.debug('validate_args_revcb: ' ||
318 'EXCEPTION: arp_process_chargeback.validate_args_revcb' );
319 END IF;
320 RAISE;
321 END validate_args_revcb;
322 --
323 /*===========================================================================+
324 | PROCEDURE |
325 | validate_cb_reversal |
326 | |
327 | DESCRIPTION |
328 | Validate if a charge back can be reversed |
329 | |
330 | SCOPE - PUBLIC |
331 | |
332 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED - NONE |
333 | |
334 | ARGUMENTS : IN: |
335 | p_ps_id - Payment Schedule Id assocaited with a charge |
336 | back |
337 | p_ass_cr_id - Cash receipt Id associated with a charge |
338 | back |
339 | p_ct_count - ???????????? |
340 | p_module_version - version of module that called the |
341 | procedure |
342 | p_module_name - Name of the module that called the proc. |
343 | OUT: |
344 | |
345 | RETURNS : BOOLEAN |
346 | |
347 | NOTES |
348 | This is an ovreloaded procedure |
349 | MODIFICATION HISTORY - Created by Ganesh Vaidee - 04/25/95 |
350 | |
351 +===========================================================================*/
352 FUNCTION validate_cb_reversal (
353 p_ps_id IN ar_payment_schedules.payment_schedule_id%TYPE,
354 p_ass_cr_id IN ar_adjustments.associated_cash_receipt_id%TYPE,
355 p_ct_count IN NUMBER, p_module_name IN VARCHAR2,
356 p_module_version IN VARCHAR2 ) RETURN BOOLEAN IS
357 l_sum NUMBER DEFAULT 0;
358 --
359 l_test_failed BOOLEAN DEFAULT TRUE;
360 l_count NUMBER;
361 BEGIN
362 IF PG_DEBUG in ('Y', 'C') THEN
363 arp_standard.debug( 'arp_process_chargeback.validate_cb_reversal()+' );
364 arp_standard.debug( to_char( p_ps_id ) );
365 arp_standard.debug( to_char( p_ass_cr_id ) );
366 END IF;
367 --
368 IF ( p_module_name IS NOT NULL AND p_module_version IS NOT NULL ) THEN
369 validate_args_cbrev_group( p_ps_id, p_ass_cr_id, p_ct_count );
370 END IF;
371 --
372 -- Validate that the net of applications to the chargeback is zero.
373 --
374 IF PG_DEBUG in ('Y', 'C') THEN
375 arp_standard.debug('before BEGIN SELECT NVL in app_delete' );
376 END IF;
377 SELECT NVL( sum( ra.amount_applied), 0 )
378 INTO l_sum
379 FROM ar_receivable_applications ra
380 WHERE ra.applied_customer_trx_id in (
381 SELECT a.chargeback_customer_trx_id
382 FROM ar_adjustments b,
383 ar_adjustments a
384 WHERE a.receivables_trx_id = arp_global.G_CB_RT_ID
385 AND a.associated_cash_receipt_id = p_ass_cr_id
386 AND a.payment_schedule_id = p_ps_id
387 AND b.receivables_trx_id(+) =
388 arp_global.G_CB_REV_RT_ID
389 AND b.customer_trx_id(+) = a.chargeback_customer_trx_id
390 AND b.customer_trx_id is NULL );
391 --
392 IF PG_DEBUG in ('Y', 'C') THEN
393 arp_standard.debug( 'before 1st sum' );
394 arp_standard.debug( to_char( l_sum ) );
395 END IF;
396 IF ( l_sum <> 0 ) THEN
397 IF PG_DEBUG in ('Y', 'C') THEN
398 arp_standard.debug( 'Sum of Charge back applications is non-zero');
399 END IF;
400 l_test_failed := FALSE;
401 END IF;
402 --
403 l_sum := 0;
404 --
405 -- Validate that the net of adjustments to the chargeback is zero.
406 --
407 IF PG_DEBUG in ('Y', 'C') THEN
408 arp_standard.debug( 'inside SELECT nvl 2nd in app_delete' );
409 END IF;
410 SELECT NVL( sum( amount ), 0 )
411 INTO l_sum
412 FROM ar_adjustments
413 WHERE customer_trx_id in (
414 SELECT a.chargeback_customer_trx_id
415 FROM ar_adjustments a,
416 ar_adjustments b
417 WHERE a.receivables_trx_id = arp_global.G_CB_RT_ID
418 AND a.associated_cash_receipt_id = p_ass_cr_id
419 AND a.payment_schedule_id = p_ps_id
420 AND b.receivables_trx_id(+) =
421 arp_global.G_CB_REV_RT_ID
422 AND b.customer_trx_id(+) = a.chargeback_customer_trx_id
423 AND b.customer_trx_id is NULL )
424 AND NVL( postable, 'Y') = 'Y';
425 --
426 IF PG_DEBUG in ('Y', 'C') THEN
427 arp_standard.debug( 'before 2nd sum' );
428 arp_standard.debug( to_char( l_sum ) );
429 END IF;
430 --
431 IF ( l_sum <> 0 ) THEN
432 IF PG_DEBUG in ('Y', 'C') THEN
433 arp_standard.debug( 'Sum of Charge back applications is non-zero');
434 END IF;
435 l_test_failed := FALSE;
436 END IF;
437 --
438 IF ( l_test_failed = FALSE ) THEN
439 RETURN FALSE;
440 END IF;
441 --
442 -- Check if specified chargeback exist
443 --
444 IF PG_DEBUG in ('Y', 'C') THEN
445 arp_standard.debug( 'before SELECT COUNT(*) in app_delete' );
446 END IF;
447 --
448 SELECT count( distinct ct.customer_trx_id )
449 INTO l_count
450 FROM ra_customer_trx ct,
451 ar_payment_schedules ps
452 WHERE ct.customer_trx_id in (
453 SELECT a.chargeback_customer_trx_id
454 FROM ar_adjustments b,
455 ar_adjustments a
456 WHERE a.receivables_trx_id = arp_global.G_CB_RT_ID
457 AND a.associated_cash_receipt_id = p_ass_cr_id
458 AND a.payment_schedule_id = p_ps_id
459 AND b.receivables_trx_id(+) =
460 arp_global.G_CB_REV_RT_ID
461 AND b.customer_trx_id(+) =
462 a.chargeback_customer_trx_id
463 AND b.customer_trx_id is NULL )
464 AND ps.customer_trx_id = ct.customer_trx_id
465 AND ps.class = 'CB';
466
467 IF ( l_count <> p_ct_count ) THEN
468 IF PG_DEBUG in ('Y', 'C') THEN
469 arp_standard.debug( 'passed in count does not match selected count' );
470 END IF;
471 RETURN FALSE;
472 END IF;
473
474 IF PG_DEBUG in ('Y', 'C') THEN
475 arp_standard.debug( 'arp_process_chargeback.validate_cb_reversal()-');
476 END IF;
477 RETURN TRUE;
478
479 EXCEPTION
480 WHEN OTHERS THEN
481 IF PG_DEBUG in ('Y', 'C') THEN
482 arp_standard.debug(
483 'EXCEPTION: arp_process_chargeback.validate_cb_reversal' );
484 END IF;
485 RAISE;
486 END validate_cb_reversal;
487 --
488 /*===========================================================================+
489 | PROCEDURE |
490 | validate_cb_reversal |
491 | |
492 | DESCRIPTION |
493 | Validate if a charge back can be reversed |
494 | |
495 | SCOPE - PUBLIC |
496 | |
497 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED - NONE |
498 | |
499 | ARGUMENTS : IN: |
500 | p_ct_id - Customer Trx ID associated with the charge back|
501 | p_ct_count - ???????????? |
502 | p_module_version - version of module that called the |
503 | procedure |
504 | p_module_name - Name of the module that called the proc. |
505 | OUT: |
506 | |
507 | RETURNS : BOOLEAN |
508 | |
509 | NOTES |
510 | This is an ovreloaded procedure |
511 | MODIFICATION HISTORY - Created by Ganesh Vaidee - 04/25/95 |
512 | |
513 +===========================================================================*/
514 FUNCTION validate_cb_reversal ( p_ct_id IN ra_customer_trx.customer_trx_id%TYPE,
515 p_module_name IN VARCHAR2,
516 p_module_version IN VARCHAR2 ) RETURN BOOLEAN IS
517 l_sum NUMBER DEFAULT 0;
518 --
519 l_test_failed BOOLEAN DEFAULT TRUE;
520 l_count NUMBER;
521 BEGIN
522 IF PG_DEBUG in ('Y', 'C') THEN
523 arp_standard.debug( '>>>>>>>> arp_process_chargeback.validate_cb_reversal' );
524 arp_standard.debug( to_char( p_ct_id ) );
525 END IF;
526 --
527 IF ( p_module_name IS NOT NULL AND p_module_version IS NOT NULL ) THEN
528 validate_args_cbrev_ct( p_ct_id );
529 END IF;
530 --
531 BEGIN
532 --
533 -- Validate that the net of applications to the chargeback is zero.
534 --
535 IF PG_DEBUG in ('Y', 'C') THEN
536 arp_standard.debug( 'inside BEGIN SELECT NVL in app_delete' );
537 END IF;
538 SELECT NVL( sum( amount_applied), 0 )
539 INTO l_sum
540 FROM ar_receivable_applications
541 WHERE applied_customer_trx_id = p_ct_id;
542 --
543 EXCEPTION
544 WHEN NO_DATA_FOUND THEN
545 IF PG_DEBUG in ('Y', 'C') THEN
546 arp_standard.debug(
547 'arp_process_chargeback.validate_cb_reversal - NO_DATA_FOUND' );
548 END IF;
549 END;
550 --
551 IF PG_DEBUG in ('Y', 'C') THEN
552 arp_standard.debug( 'before 1st sum' );
553 arp_standard.debug( to_char( l_sum ) );
554 END IF;
555 --
556 IF ( l_sum <> 0 ) THEN
557 IF PG_DEBUG in ('Y', 'C') THEN
558 arp_standard.debug( 'Sum of Charge back applications is non-zero');
559 END IF;
560 l_test_failed := FALSE;
561 END IF;
562 --
563 l_sum := 0;
564 --
565 -- Validate that the net of adjustments to the chargeback is zero.
566 --
567 BEGIN
568 IF PG_DEBUG in ('Y', 'C') THEN
569 arp_standard.debug( 'inside SELECT nvl 2nd in app_delete' );
570 END IF;
571 SELECT NVL( sum( amount ), 0 )
572 INTO l_sum
573 FROM ar_adjustments
574 WHERE customer_trx_id = p_ct_id
575 AND NVL( postable, 'Y') = 'Y';
576 --
577 EXCEPTION
578 WHEN NO_DATA_FOUND THEN
579 IF PG_DEBUG in ('Y', 'C') THEN
580 arp_standard.debug(
581 'No data found in RA table - validate_cb_reversal ' );
582 END IF;
583 END;
584 --
585 IF PG_DEBUG in ('Y', 'C') THEN
586 arp_standard.debug( 'before 2nd sum' );
587 arp_standard.debug( to_char( l_sum ) );
588 END IF;
589 --
590 IF ( l_sum <> 0 ) THEN
591 IF PG_DEBUG in ('Y', 'C') THEN
592 arp_standard.debug( 'Sum of Charge back applications is non-zero');
593 END IF;
594 l_test_failed := FALSE;
595 END IF;
596 --
597 IF ( l_test_failed = FALSE ) THEN
598 RETURN FALSE;
599 END IF;
600 --
601 -- Check if specified chargeback exist
602 --
603 IF PG_DEBUG in ('Y', 'C') THEN
604 arp_standard.debug( 'before SELECT COUNT(*) in app_delete' );
605 END IF;
606 BEGIN
607 SELECT count(*)
608 INTO l_count
609 FROM ra_customer_trx ct,
610 ar_payment_schedules ps
611 WHERE ct.customer_trx_id = p_ct_id
612 AND ps.customer_trx_id = ct.customer_trx_id
613 AND ps.class = 'CB';
614 EXCEPTION
615 WHEN NO_DATA_FOUND THEN
616 IF PG_DEBUG in ('Y', 'C') THEN
617 arp_standard.debug(
618 'arp_process_chargeback.validate_cb_reversa - NO_DATA_FOUND' );
619 END IF;
620 RETURN FALSE;
621 END;
622 --
623 -- At this point, validation is successful. Lock payment schedule recor
624 -- and return AR_M_SUCCESS. However, this should be done at a different
625 -- level.
626
627 --
628 IF PG_DEBUG in ('Y', 'C') THEN
629 arp_standard.debug( '<<<<<<<< arp_process_chargeback.validate_cb_reversal' );
630 END IF;
631 RETURN TRUE;
632 --
633 EXCEPTION
634 WHEN OTHERS THEN
635 IF PG_DEBUG in ('Y', 'C') THEN
636 arp_standard.debug(
637 'EXCEPTION: arp_process_chargeback.validate_cb_reversal' );
638 END IF;
639 RAISE;
640 END validate_cb_reversal;
641 /*===========================================================================+
642 | PROCEDURE |
643 | validate_args_cbrev_ct |
644 | |
645 | DESCRIPTION |
646 | This procedure validates input to validate_cb_reversal procedure |
647 | |
648 | SCOPE - PRIVATE |
649 | |
650 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED - NONE |
651 | |
652 | ARGUMENTS : IN: |
653 | p_ct_id - Customer Trx ID associated with the charge back |
654 | OUT: |
655 | |
656 | RETURNS : NONE |
657 | |
658 | NOTES |
659 | |
660 | MODIFICATION HISTORY - Created by Ganesh Vaidee - 04/25/95 |
661 | |
662 +===========================================================================*/
663 PROCEDURE validate_args_cbrev_ct (
664 p_ct_id IN ra_customer_trx.customer_trx_id%TYPE ) IS
665 BEGIN
666 arp_standard.debug( '>>>>>>>> arp_process_chargeback.validate_args_cbrev_ct' );
667 IF ( p_ct_id is NULL ) THEN
668 FND_MESSAGE.set_name ('AR', 'AR_ARGUEMENTS_FAIL' );
669 APP_EXCEPTION.raise_exception;
670 END IF;
671 --
672 arp_standard.debug( '<<<<<<<< arp_process_chargeback.validate_args_cbrev_ct' );
673 EXCEPTION
674 WHEN OTHERS THEN
675 arp_standard.debug(
676 'EXCEPTION: arp_process_chargeback.validate_args_cbrev_ct' );
677 RAISE;
678 END;
679 /*===========================================================================+
680 | PROCEDURE |
681 | validate_args_cbrev_group |
682 | |
683 | DESCRIPTION |
684 | This procedure validates input to validate_cb_reversal procedure |
685 | |
686 | SCOPE - PRIVATE |
687 | |
688 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED - NONE |
689 | |
690 | ARGUMENTS : IN: |
691 | p_ps_id - Payment Schedule Id assocaited with a charge |
692 | back |
693 | p_ass_cr_id - Cash receipt Id associated with a charge |
694 | back |
695 | p_ct_count - ???????????? |
696 | OUT: |
697 | |
698 | RETURNS : NONE |
699 | |
700 | NOTES |
701 | |
702 | MODIFICATION HISTORY - Created by Ganesh Vaidee - 04/25/95 |
703 | |
704 +===========================================================================*/
705 PROCEDURE validate_args_cbrev_group(
706 p_ps_id IN ar_payment_schedules.payment_schedule_id%TYPE,
707 p_ass_cr_id IN ar_adjustments.associated_cash_receipt_id%TYPE,
708 p_ct_count IN NUMBER ) IS
709 BEGIN
710 IF PG_DEBUG in ('Y', 'C') THEN
711 arp_standard.debug( '>>>>>>>> arp_process_chargeback.validate_args_cbrev_group' );
712 END IF;
713 IF ( p_ps_id is NULL OR p_ass_cr_id is NULL OR p_ct_count is NULL ) THEN
714 FND_MESSAGE.set_name ('AR', 'AR_ARGUEMENTS_FAIL' );
715 APP_EXCEPTION.raise_exception;
716 END IF;
717 --
718 IF PG_DEBUG in ('Y', 'C') THEN
719 arp_standard.debug( '<<<<<<<< arp_process_chargeback.validate_args_cbrev_group' );
720 END IF;
721 EXCEPTION
722 WHEN OTHERS THEN
723 IF PG_DEBUG in ('Y', 'C') THEN
724 arp_standard.debug('validate_args_cbrev_group: ' ||
725 'EXCEPTION: arp_process_chargeback.validate_args_cbrev_group' );
726 END IF;
727 RAISE;
728 END validate_args_cbrev_group;
729
730 /*===========================================================================+
731 PROCEDURE
732 validate_args_create_cb()
733
734 DESCRIPTION
735 This procedure validates all important parameters that are needed
736 in creation of chargebacks.
737
738 SCOPE
739 Private
740
741 EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
742 arp_util.validate_gl_date() Validates GL date
743
744 ARGUMENTS
745 IN
746 p_gl_date
747 p_cust_trx_type_id
748 p_inv_customer_trx_id
749 p_due_date
750 OUT
751
752 RETURNS
753 Nothing
754
755 NOTES
756
757 MODIFICATION HISTORY
758 10/10/1995 H.Kaukovuo Created
759 +===========================================================================*/
760 PROCEDURE validate_args_create_cb(
761 p_gl_date IN DATE
762 , p_cust_trx_type_id IN NUMBER
763 , p_inv_customer_trx_id IN NUMBER
764 , p_due_date IN DATE
765 )
766 IS
767 l_parameter_tokens VARCHAR2(100);
768
769 BEGIN
770 arp_standard.debug('arp_process_chargeback.validate_args_create_cb(+)' );
771
772 l_parameter_tokens := '';
773
774 -- ---------------------------------------------------
775 -- Search for invalid parameter. Stop immediately after
776 -- invalid parameter value. Display error message.
777 -- ---------------------------------------------------
778
779 IF (p_gl_date IS NULL) THEN
780 l_parameter_tokens := 'p_gl_date';
781 ELSIF (p_cust_trx_type_id IS NULL) THEN
782 l_parameter_tokens := 'p_cust_trx_type_id';
783 ELSIF (p_inv_customer_trx_id IS NULL) THEN
784 l_parameter_tokens := 'p_inv_customer_trx_id';
785 ELSIF (p_due_date IS NULL) THEN
786 l_parameter_tokens := 'p_due_date';
787 END IF;
788
789 -- ---------------------------------------------------
790 -- If one ore more variables were invalid, display the error
791 -- ---------------------------------------------------
792 IF (l_parameter_tokens <> '') THEN
793 fnd_message.set_name('AR','AR_PROCEDURE_VALID_ARGS_FAIL');
794 fnd_message.set_token('PARAMETER',l_parameter_tokens);
795 fnd_message.set_token('PROCEDURE','ARP_PROCESS_CHARGEBACK.CREATE_CHARGEBACK');
796 app_exception.raise_exception;
797 END IF;
798
799 arp_standard.debug('arp_process_chargeback.validate_args_create_cb(-)' );
800
801 EXCEPTION
802 WHEN OTHERS THEN
803 arp_standard.debug('-- Exception: Others: validate.args_create_cb');
804 app_exception.raise_exception;
805 END;
806
807 /*
808 ===========================================================================
809 PROCEDURE
810 init_adj_struct
811
812 DESCRIPTION
813 Initializes all adjustment variables.
814 All numeric variables are set to zero and all text variables are
815 set to NULL
816
817 NOTE
818 Strict conversion from C-code function armnadj() in armadj.lpc.
819
820 HISTORY
821 4/2/1996 Harri Kaukovuo Created
822 ===========================================================================
823 */
824 PROCEDURE init_adj_struct (
825 p_adj_rec IN OUT NOCOPY AR_ADJUSTMENTS%ROWTYPE) IS
826 BEGIN
827 IF PG_DEBUG in ('Y', 'C') THEN
828 arp_standard.debug ('arp_process_chargeback.init_adj_struct()+');
829 END IF;
830 p_adj_rec.adjustment_id := NULL;
831 p_adj_rec.amount := 0;
832 p_adj_rec.acctd_amount := 0;
833 p_adj_rec.apply_date := NULL;
834 p_adj_rec.gl_date := NULL;
835 p_adj_rec.code_combination_id := 0;
836 p_adj_rec.customer_trx_id := NULL;
837 p_adj_rec.customer_trx_line_id:= NULL;
838 p_adj_rec.subsequent_trx_id := NULL;
839 p_adj_rec.payment_schedule_id := NULL;
840 p_adj_rec.receivables_trx_id := NULL;
841 p_adj_rec.reason_code := NULL;
842 p_adj_rec.postable := NULL;
843 p_adj_rec.type := NULL;
844 p_adj_rec.adjustment_type := NULL;
845 p_adj_rec.associated_cash_receipt_id := NULL;
846 p_adj_rec.line_adjusted := NULL;
847 p_adj_rec.freight_adjusted := NULL;
848 p_adj_rec.tax_adjusted := NULL;
849 p_adj_rec.receivables_charges_adjusted := NULL;
850 p_adj_rec.chargeback_customer_trx_id := NULL;
851 p_adj_rec.created_from := NULL;
852 p_adj_rec.status := NULL;
853 p_adj_rec.request_id := NULL;
854 p_adj_rec.program_update_date := NULL;
855 p_adj_rec.program_id := NULL;
856 p_adj_rec.program_application_id := NULL;
857 IF PG_DEBUG in ('Y', 'C') THEN
858 arp_standard.debug ('arp_process_chargeback.init_adj_struct()-');
859 END IF;
860
861 END init_adj_struct;
862
863 /*
864 ===========================================================================
865 PROCEDURE
866 init_ps_struct
867
868 DESCRIPTION
869 Initializes all payment schedules variables.
870 All numeric variables are set to zero and all text variables are
871 set to NULL
872
873 NOTE
874 Strict conversion from C-code function armnps() in armps.lpc.
875 Payment_schedule_id is left NULL because table handler is going to
876 populate that value with sequence value.
877
878 HISTORY
879 4/2/1996 Harri Kaukovuo Created
880 ===========================================================================
881 */
882 PROCEDURE init_ps_struct (
883 p_ps_rec IN OUT NOCOPY AR_PAYMENT_SCHEDULES%ROWTYPE) IS
884 BEGIN
885 IF PG_DEBUG in ('Y', 'C') THEN
886 arp_standard.debug ('arp_process_chargeback.init_ps_struct()+');
887 END IF;
888 p_ps_rec.payment_schedule_id := NULL;
889 p_ps_rec.due_date := NULL;
890 p_ps_rec.amount_due_original := NULL;
891 p_ps_rec.amount_due_remaining := NULL;
892 p_ps_rec.acctd_amount_due_remaining := NULL;
893 p_ps_rec.number_of_due_dates := 0;
894 p_ps_rec.status := NULL;
895 p_ps_rec.invoice_currency_code := NULL;
896 -- p_ps_rec.payment_currency_code := NULL;
897 p_ps_rec.class := NULL;
898 p_ps_rec.cust_trx_type_id := NULL;
899 p_ps_rec.customer_id := NULL;
900 p_ps_rec.customer_site_use_id := NULL;
901 p_ps_rec.customer_trx_id := NULL;
902 p_ps_rec.cash_receipt_id := NULL;
903 p_ps_rec.associated_cash_receipt_id := NULL;
904 p_ps_rec.term_id := NULL;
905 p_ps_rec.terms_sequence_number := NULL;
906 p_ps_rec.gl_date_closed := NULL;
907 p_ps_rec.actual_date_closed := NULL;
908 p_ps_rec.discount_date := NULL;
909 p_ps_rec.amount_line_items_original := NULL;
910 p_ps_rec.amount_line_items_remaining := NULL;
911 p_ps_rec.amount_applied := NULL;
912 p_ps_rec.amount_adjusted := NULL;
913 p_ps_rec.amount_adjusted_pending := NULL;
914 p_ps_rec.amount_in_dispute := NULL;
915 p_ps_rec.amount_credited := NULL;
916 p_ps_rec.receivables_charges_remaining:= NULL;
917 p_ps_rec.freight_original := NULL;
918 p_ps_rec.freight_remaining := NULL;
919 p_ps_rec.tax_original := NULL;
920 p_ps_rec.tax_remaining := NULL;
921 p_ps_rec.discount_original := NULL;
922 p_ps_rec.discount_remaining := NULL;
923 p_ps_rec.discount_taken_earned := NULL;
924 p_ps_rec.discount_taken_unearned := NULL;
925 p_ps_rec.in_collection := NULL;
926 p_ps_rec.reversed_cash_receipt_id := NULL;
927 p_ps_rec.cash_applied_id_last := NULL;
928 p_ps_rec.cash_applied_date_last := NULL;
929 p_ps_rec.cash_applied_amount_last := NULL;
930 p_ps_rec.cash_applied_status_last := NULL;
931 p_ps_rec.cash_gl_date_last := NULL;
932 p_ps_rec.cash_receipt_id_last := NULL;
933 p_ps_rec.cash_receipt_date_last := NULL;
934 p_ps_rec.cash_receipt_amount_last := NULL;
935 p_ps_rec.cash_receipt_status_last := NULL;
936 p_ps_rec.exchange_rate_type := NULL;
937 p_ps_rec.exchange_date := NULL;
938 p_ps_rec.exchange_rate := NULL;
939 p_ps_rec.adjustment_id_last := NULL;
940 p_ps_rec.adjustment_date_last := NULL;
941 p_ps_rec.adjustment_gl_date_last := NULL;
942 p_ps_rec.adjustment_amount_last := NULL;
943 p_ps_rec.follow_up_date_last := NULL;
944 p_ps_rec.follow_up_code_last := NULL;
945 p_ps_rec.promise_date_last := NULL;
946 p_ps_rec.promise_amount_last := NULL;
947 p_ps_rec.collector_last := NULL;
948 p_ps_rec.call_date_last := NULL;
949 p_ps_rec.trx_number := NULL;
950 p_ps_rec.trx_date := NULL;
951 IF PG_DEBUG in ('Y', 'C') THEN
952 arp_standard.debug ('arp_process_chargeback.init_ps_struct()-');
953 END IF;
954
955 END init_ps_struct;
956 /*
957 ===========================================================================
958 PROCEDURE
959 init_app_struct
960
961 DESCRIPTION
962 Initializes all receivable application variables.
963 All numeric variables are set to zero and all text variables are
964 set to NULL
965
966 NOTE
967 Strict conversion from C-code function armnapp() in armapp.lpc.
968 receivable_application_id is left NULL because table handler is going to
969 populate that value with sequence value.
970
971 HISTORY
972 4/2/1996 Harri Kaukovuo Created
973 ===========================================================================
974 */
975 PROCEDURE init_app_struct (
976 p_app_rec IN OUT NOCOPY AR_RECEIVABLE_APPLICATIONS%ROWTYPE) IS
977 BEGIN
978 IF PG_DEBUG in ('Y', 'C') THEN
979 arp_standard.debug ('arp_process_chargeback.init_app_struct()+');
980 END IF;
981
982 p_app_rec.receivable_application_id := NULL;
983 p_app_rec.amount_applied := NULL;
984 -- p_app_rec.acctd_amount_applied := NULL;
985 p_app_rec.gl_date := NULL;
986 p_app_rec.code_combination_id := 0;
987 p_app_rec.display := NULL;
988 p_app_rec.apply_date := NULL;
989 p_app_rec.application_type := NULL;
990 p_app_rec.status := NULL;
991 p_app_rec.payment_schedule_id := 0;
992 -- p_app_rec.associated_cash_receipt_id := NULL;
993 p_app_rec.cash_receipt_id := NULL;
994 p_app_rec.applied_customer_trx_id := NULL;
995 p_app_rec.applied_customer_trx_line_id:= NULL;
996 p_app_rec.applied_payment_schedule_id := NULL;
997 p_app_rec.customer_trx_id := NULL;
998 p_app_rec.line_applied := NULL;
999 p_app_rec.tax_applied := NULL;
1000 p_app_rec.freight_applied := NULL;
1001 p_app_rec.receivables_charges_applied := NULL;
1002 p_app_rec.on_account_customer := NULL;
1003 p_app_rec.receivables_trx_id := NULL;
1004 p_app_rec.earned_discount_ccid := 0;
1005 p_app_rec.unearned_discount_ccid := 0;
1006 p_app_rec.earned_discount_taken := NULL;
1007 p_app_rec.acctd_earned_discount_taken := NULL;
1008 p_app_rec.unearned_discount_taken := NULL;
1009 p_app_rec.acctd_unearned_discount_taken := NULL;
1010 p_app_rec.days_late := NULL;
1011 p_app_rec.application_rule := NULL;
1012 p_app_rec.gl_posted_date := NULL;
1013
1014 IF PG_DEBUG in ('Y', 'C') THEN
1015 arp_standard.debug ('init_app_struct: ' || 'arp_process_chargeback.init_ps_struct()-');
1016 END IF;
1017
1018 END init_app_struct;
1019
1020 /*
1021 ===========================================================================+
1022 PROCEDURE
1023 create_chargeback()
1024
1025 DESCRIPTION
1026 This procedure will create a chargeback entry for given
1027 receipt/invoice pair.
1028 Procedure will create one default invoice line for quantity
1029 of 1 and amount of chargeback amount.
1030
1031 Assumptions
1032 - Overapplications and application creation signs
1033 should have been checked in client site with
1034 ARP_NON_DB_PKG.check_natural_application and
1035 ARP_NON_DB_PKG.check_creation_sign procedures.
1036
1037 The algorithm for creating chargebacks:
1038 1. Instantiate variables with default values
1039 2. Insert header RA_CUSTOMER_TRX
1040 3. Insert one line into RA_CUSTOMER_TRX_LINES
1041 4. Insert revenue account GL distribution
1042 into RA_CUST_TRX_LINE_GL_DIST
1043 5. Insert receivables account GL distribution
1044 into RA_CUST_TRX_LINE_GL_DIST
1045 6. Insert into AR_PAYMENT_SCHEDULES
1046 - Call event handler
1047
1048 7. Initialize, then populate app_struct and ps_struct
1049
1050 8. Update AR_PAYMENT_SCHEDULES
1051 9. Initialize variables for inserting a row into AR_ADJUSTMENTS
1052 10. Insert into AR_ADJUSTMENTS by calling armiadj
1053
1054 SCOPE
1055 Public
1056
1057 EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
1058 ARTUGBLB.pls
1059 - arp_trx_global.system_info.base_currency
1060 - arp_trx_global.system_info.base_precision
1061 - arp_trx_global.system_info.base_min_acc_unit
1062 ARCUTILB.pls
1063 - validate_gl_date
1064 ARTITRXB.pls Table handler for ra_customer_trx
1065 - insert_p
1066 ARTICTLB.pls Table handler for ra_customer_trx_lines
1067 - insert_p
1068 ARTILGDB.pls Table handler ra_cust_trx_line_gl_dist
1069 - insert_p
1070 ARTEADJS.pls Adjustment procedures
1071 - insert_adjustment
1072
1073 ARGUMENTS
1074 IN
1075 p_amount Chargeback amount
1076 p_acctd_amount Chargeback amount in base currency
1077 p_cr_trx_number Cash receipt number
1078 p_cash_receipt_id Cash receipt id
1079 p_inv_trx_number Invoice number to which chargeback
1080 is applied against
1081 p_inv_customer_trx_id Invoice ID to which chargeback is
1082 applied
1083 p_gl_id_ar_trade Receivables account code combination
1084 id
1085
1086 p_apply_date AI.APPLY_DATE
1087
1088 OUT
1089
1090 RETURNS
1091
1092 NOTES
1093
1094 MODIFICATION HISTORY
1095 10/09/1995 H.Kaukovuo Created
1096 7/29/1996 Harri Kaukovuo Bug 386242, term_id was not populated when
1097 ra_customer_trx row was created.
1098 7/30/1996 Harri Kaukovuo Bug fix 386662 document numbering was missing
1099 from the chargeback adjustment.
1100 11/17/1997 Genneva Wang Bug fix 412726 - (1) Creation of Chargeback
1101 should give message if GL Account assignment
1102 is missing. (2) Returns message if a document
1103 sequence has not been created for the
1104 Chargeback Adjustment activity.
1105 09/01/1999 Genneva Wang Bug fix: 976730 Redefault Chargeback GL Date
1106 if passed in chargeback GL date is invalid
1107 03/22/2001 S.Nambiar Program has been modified to create chargeback
1108 aganist receipt,which is a new functionality
1109 introduced for iClaim-deduction project. In this
1110 case, there won't be any adjustment created.
1111 3/26/2001 S.Nambiar Modified create_chargeback parameter list |
1112 and added p_remit_to_address_id and |
1113 p_bill_to_site_use_id for receipt chargeback |
1114 09/10/2002 S.Nambiar Bug 2444737 - Added transaction referece flex
1115 fields to create chargeback routine.
1116 01/15/2003 J.Beckett Bug 2751910 - added p_internal_notes
1117 09/23/2004 J.Beckett Bug 3879127 - p_acctd_amount is ignored and
1118 the chargeback acctd_amount is recalculated
1119 with respect to amount_due_remaining of
1120 originating invoice to ensure the sum of all
1121 chargebacks does not exceed the original
1122 invoice and to ensure the chargeback balances
1123 with the corresponding adjustment.
1124 05/25/2005 J.Beckett R12 LE uptake : Added legal_entity_id
1125 03/02/2011 ABBANSA Bug 13788971 - Added code to default the Paying
1126 Customer and Payment Information
1127 +===========================================================================
1128 */
1129
1130 procedure create_chargeback(
1131 p_amount IN NUMBER
1132 , p_acctd_amount IN NUMBER
1133 , p_trx_date IN DATE
1134 , p_gl_id_ar_trade IN NUMBER
1135 , p_gl_date IN DATE
1136
1137 , p_attribute_category IN VARCHAR2
1138 , p_attribute1 IN VARCHAR2
1139 , p_attribute2 IN VARCHAR2
1140 , p_attribute3 IN VARCHAR2
1141 , p_attribute4 IN VARCHAR2
1142 , p_attribute5 IN VARCHAR2
1143 , p_attribute6 IN VARCHAR2
1144 , p_attribute7 IN VARCHAR2
1145 , p_attribute8 IN VARCHAR2
1146 , p_attribute9 IN VARCHAR2
1147 , p_attribute10 IN VARCHAR2
1148 , p_attribute11 IN VARCHAR2
1149 , p_attribute12 IN VARCHAR2
1150 , p_attribute13 IN VARCHAR2
1151 , p_attribute14 IN VARCHAR2
1152 , p_attribute15 IN VARCHAR2
1153 , p_cust_trx_type_id IN NUMBER
1154 , p_set_of_books_id IN NUMBER
1155 , p_reason_code IN VARCHAR2
1156 , p_comments IN VARCHAR2
1157 , p_def_ussgl_trx_code_context IN VARCHAR2
1158 , p_def_ussgl_transaction_code IN VARCHAR2
1159
1160 -- For AR_PAYMENT_SCHEDULES
1161 , p_due_date IN DATE
1162 , p_customer_id IN NUMBER
1163 , p_cr_trx_number IN VARCHAR2
1164 , p_cash_receipt_id IN NUMBER
1165 , p_inv_trx_number IN VARCHAR2
1166 , p_apply_date IN DATE
1167 , p_receipt_gl_date IN DATE
1168
1169 -- We get rest of the TRX info with this ID
1170 , p_app_customer_trx_id IN NUMBER
1171 , p_app_terms_sequence_number IN NUMBER
1172
1173 , p_form_name IN VARCHAR2
1174
1175 , p_out_trx_number OUT NOCOPY VARCHAR2
1176 , p_out_customer_trx_id OUT NOCOPY NUMBER
1177 , p_doc_sequence_value IN OUT NOCOPY NUMBER
1178 , p_doc_sequence_id IN OUT NOCOPY NUMBER
1179 , p_exchange_rate_type IN VARCHAR2
1180 , p_exchange_date IN DATE
1181 , p_exchange_rate IN NUMBER
1182 , p_currency_code IN VARCHAR2
1183 , p_remit_to_address_id IN NUMBER DEFAULT 0
1184 , p_bill_to_site_use_id IN NUMBER DEFAULT 0
1185 --Bug 2444737
1186 , p_interface_header_context IN VARCHAR2
1187 , p_interface_header_attribute1 IN VARCHAR2
1188 , p_interface_header_attribute2 IN VARCHAR2
1189 , p_interface_header_attribute3 IN VARCHAR2
1190 , p_interface_header_attribute4 IN VARCHAR2
1191 , p_interface_header_attribute5 IN VARCHAR2
1192 , p_interface_header_attribute6 IN VARCHAR2
1193 , p_interface_header_attribute7 IN VARCHAR2
1194 , p_interface_header_attribute8 IN VARCHAR2
1195 , p_interface_header_attribute9 IN VARCHAR2
1196 , p_interface_header_attribute10 IN VARCHAR2
1197 , p_interface_header_attribute11 IN VARCHAR2
1198 , p_interface_header_attribute12 IN VARCHAR2
1199 , p_interface_header_attribute13 IN VARCHAR2
1200 , p_interface_header_attribute14 IN VARCHAR2
1201 , p_interface_header_attribute15 IN VARCHAR2
1202 , p_internal_notes IN VARCHAR2 -- bug 2751910
1203 , p_customer_reference IN VARCHAR2 -- bug 2751910
1204 , p_legal_entity_id IN NUMBER /* R12 LE uptake */
1205 )
1206 IS
1207
1208 l_ct_row ra_customer_trx%ROWTYPE;
1209 l_ctl_row ra_customer_trx_lines%ROWTYPE;
1210 l_ctlgd_row ra_cust_trx_line_gl_dist%ROWTYPE;
1211 l_ps_row ar_payment_schedules%ROWTYPE;
1212 l_adj_row ar_adjustments%ROWTYPE;
1213
1214 ln_app_payment_schedule_id NUMBER;
1215
1216 ln_line_applied NUMBER;
1217 ln_tax_applied NUMBER;
1218 ln_freight_applied NUMBER;
1219 ln_charges_applied NUMBER;
1220
1221 ln_acctd_amount_applied NUMBER;
1222 ln_acctd_earned_discount_taken NUMBER;
1223 ln_acctd_unearned_disc_taken NUMBER;
1224
1225 -- This stuff is for sequence numbering
1226 L_REC_NAME VARCHAR2(50);
1227 l_sequence_name VARCHAR2(500);
1228 l_sequence_id NUMBER;
1229 l_sequence_value NUMBER;
1230 l_sequence_assignment_id NUMBER;
1231
1232 l_receivable_activity_acct NUMBER;
1233 --
1234 l_chargeback_gl_date DATE;
1235 l_error_message VARCHAR2(128);
1236 l_defaulting_rule_used VARCHAR2(50);
1237 l_default_gl_date DATE;
1238 error_defaulting_gl_date EXCEPTION;
1239 l_receivables_trx_id ar_receivables_trx.receivables_trx_id%TYPE;
1240 l_receipt_method_id ar_cash_receipts.receipt_method_id%TYPE;
1241 l_remit_bank_acct_use_id ar_cash_receipts.remit_bank_acct_use_id%TYPE;
1242 l_cr_unapp_ccid ar_receivable_applications.code_combination_id%TYPE;
1243 l_inv_rec_ccid ra_cust_trx_line_gl_dist.code_combination_id%TYPE;
1244 l_id_dummy ar_receivable_applications.code_combination_id%TYPE;
1245 l_bill_to_customer_id ar_cash_receipts.pay_from_customer%TYPE;
1246 l_cb_activity_ccid ra_cust_trx_line_gl_dist.code_combination_id%TYPE;
1247 l_actual_ccid ra_cust_trx_line_gl_dist.code_combination_id%TYPE;
1248 --Bug2979254
1249 l_ev_rec arp_xla_events.xla_events_type;
1250 /* Bug 3879127 */
1251 ln_amount_due_remaining NUMBER;
1252 ln_acctd_amount_due_remaining NUMBER;
1253 ln_adr_tmp NUMBER;
1254 ln_acctd_adr_tmp NUMBER;
1255 l_acctd_amount NUMBER;
1256 l_term_end_date DATE; /*5084781*/
1257 l_rct_le_id ar_cash_receipts.legal_entity_id%TYPE; /* R12 LE uptake */
1258 ln_trx_number VARCHAR2(20);/*bug 5550153*/
1259 /*Bug 13788971 - initialization of variables for Paying Customer details population - Start*/
1260 l_payment_method_name ar_receipt_methods.name%type;
1261 l_creation_method_code ar_receipt_classes.creation_method_code%type;
1262 l_payment_channel_code ar_receipt_methods.payment_channel_code%type;
1263 l_instrument_type iby_trxn_extensions_v.instrument_type%type;
1264 l_instr_assignment_id iby_trxn_extensions_v.instr_assignment_id%type;
1265 l_org_id ra_customer_trx.org_id%type;
1266 l_create_msg_count NUMBER;
1267 l_create_msg_data VARCHAR2(2000);
1268 l_create_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
1269 l_payment_trxn_extension_id ar_cash_receipts.payment_trxn_extension_id%TYPE;
1270 /*Bug 13788971 - initialization of variables for Paying Customer details population - END*/
1271 --Ajay : raising the business event for chargeback creation
1272
1273 CURSOR get_parent_ps (p_cust_trx_id IN NUMBER) IS
1274 SELECT customer_trx_id,
1275 payment_schedule_id,
1276 invoice_currency_code,
1277 due_date,
1278 amount_in_dispute,
1279 amount_due_original,
1280 amount_due_remaining,
1281 amount_adjusted,
1282 customer_id,
1283 customer_site_use_id,
1284 trx_date,
1285 amount_credited,
1286 status
1287 FROM ar_payment_schedules
1288 WHERE customer_trx_id = p_cust_trx_id;
1289
1290 l_prev_cust_old_state AR_BUS_EVENT_COVER.prev_cust_old_state_tab;
1291
1292 BEGIN
1293 IF PG_DEBUG in ('Y', 'C') THEN
1294 arp_standard.debug('arp_process_chargeback.create_chargeback()+');
1295 END IF;
1296
1297 l_chargeback_gl_date := p_gl_date;
1298 -- ----------------------------------------------------------
1299 -- Redefault Chargeback GL date if it is in a invalid period
1300 -- ----------------------------------------------------------
1301 IF (arp_util.is_gl_date_valid(l_chargeback_gl_date) ) THEN
1302 null;
1303 ELSE
1304 IF (arp_util.validate_and_default_gl_date(
1305 l_chargeback_gl_date,
1306 NULL,
1307 NULL,
1308 NULL,
1309 NULL,
1310 NULL,
1311 NULL,
1312 NULL,
1313 'N',
1314 NULL,
1315 arp_global.set_of_books_id,
1316 222,
1317 l_default_gl_date,
1318 l_defaulting_rule_used,
1319 l_error_message) = TRUE) THEN
1320 l_chargeback_gl_date := l_default_gl_date;
1321 ELSE
1322 RAISE error_defaulting_gl_date;
1323 END IF;
1324 END IF;
1325 --
1326 -- ---------------------------------------------------
1327 -- Validate parameters
1328 -- ---------------------------------------------------
1329
1330 arp_process_chargeback.validate_args_create_cb(
1331 l_chargeback_gl_date
1332 , p_cust_trx_type_id
1333 , p_app_customer_trx_id
1334 , p_due_date
1335 );
1336
1337 -- ---------------------------------------------------
1338 -- Set chargeback defaults
1339 -- ---------------------------------------------------
1340
1341 -- Initialize records
1342 init_adj_struct (l_adj_row);
1343 init_ps_struct (l_ps_row);
1344 -- init_app_struct (l_app_row);
1345
1346 -- First initialize chargeback header
1347 -- NOTE that old Forms 2.3 program did the initial insert into
1348 -- RA_CUSTOMER_TRX already in form level. In client/server model
1349 -- inserting into RA_CUSTOMER_TRX is done here.
1350
1351 -- Copy values from the applied transaction
1352
1353 -- snambiar - p_app_customer_trx_id -4 is used for receipt chargeback
1354 -- if p_app_customer_trx_id is -4, then fetch the details from
1355 -- for receipt PS insted of invoice PS
1356
1357 IF p_app_customer_trx_id <> -4 THEN
1358
1359 BEGIN
1360 SELECT
1361 ct.exchange_rate_type
1362 , ct.exchange_date
1363 , ct.exchange_rate
1364 , ct.bill_to_customer_id
1365 , ct.ship_to_customer_id
1366 , ct.sold_to_customer_id
1367 , ct.remit_to_address_id
1368 , ct.bill_to_site_use_id
1369 , ct.ship_to_site_use_id
1370 , ct.sold_to_site_use_id
1371 , ps.PAYMENT_SCHEDULE_ID
1372 , ct.invoice_currency_code
1373 , ct.primary_salesrep_id
1374 , ct.territory_id
1375 , ctlgd.code_combination_id
1376 /* Bug 3879127 new values needed for acctd_amount calculation */
1377 , ps.amount_due_remaining
1378 , ps.acctd_amount_due_remaining
1379 , NVL(p_legal_entity_id,ct.legal_entity_id)
1380 , ct.trx_number /*added for bug 5550153*/
1381 INTO
1382 l_ct_row.exchange_rate_type
1383 , l_ct_row.exchange_date
1384 , l_ct_row.exchange_rate
1385 , l_ct_row.bill_to_customer_id
1386 , l_ct_row.ship_to_customer_id
1387 , l_ct_row.sold_to_customer_id
1388 , l_ct_row.remit_to_address_id
1389 , l_ct_row.bill_to_site_use_id
1390 , l_ct_row.ship_to_site_use_id
1391 , l_ct_row.sold_to_site_use_id
1392 , ln_app_payment_schedule_id
1393 , l_ct_row.invoice_currency_code
1394 , l_ct_row.primary_salesrep_id
1395 , l_ct_row.territory_id
1396 , l_inv_rec_ccid
1397 /* Bug 3879127 */
1398 , ln_amount_due_remaining
1399 , ln_acctd_amount_due_remaining
1400 , l_ct_row.legal_entity_id /* R12 LE uptake */
1401 , ln_trx_number /*bug 5550153*/
1402 FROM
1403 ar_payment_schedules ps
1404 , ra_cust_trx_line_gl_dist ctlgd
1405 , ra_customer_trx ct
1406 WHERE
1407 ct.customer_trx_id = p_app_customer_trx_id
1408 AND ct.customer_trx_id = ps.customer_trx_id
1409 AND ct.customer_trx_id = ctlgd.customer_trx_id(+)
1410 AND ctlgd.account_class = 'REC'
1411 AND ctlgd.latest_rec_flag = 'Y'
1412 AND ps.terms_sequence_number = p_app_terms_sequence_number;
1413
1414 --Ajay : chargeback creation business event related stuff
1415 FOR i in get_parent_ps(p_app_customer_trx_id) LOOP
1416 l_prev_cust_old_state(i.payment_schedule_id).amount_due_remaining := i.amount_due_remaining;
1417 l_prev_cust_old_state(i.payment_schedule_id).status := i.status;
1418 l_prev_cust_old_state(i.payment_schedule_id).amount_credited := i.amount_credited;
1419
1420 END LOOP;
1421
1422 EXCEPTION
1423 WHEN OTHERS THEN
1424 IF PG_DEBUG in ('Y', 'C') THEN
1425 arp_standard.debug( '-- Exception: Select default values from old invoice');
1426 arp_standard.debug( '-- p_app_customer_trx_id='||
1427 TO_CHAR(p_app_customer_trx_id));
1428 END IF;
1429 RAISE;
1430 END;
1431 END IF;
1432
1433 BEGIN
1434 SELECT
1435 cr.pay_from_customer
1436 , cr.receipt_method_id
1437 , cr.remit_bank_acct_use_id
1438 , cr.legal_entity_id
1439 INTO
1440 l_bill_to_customer_id
1441 , l_receipt_method_id
1442 , l_remit_bank_acct_use_id
1443 , l_rct_le_id /* R12 LE uptake */
1444 FROM
1445 ar_cash_receipts cr
1446 WHERE
1447 cr.cash_receipt_id = p_cash_receipt_id;
1448 EXCEPTION
1449 WHEN OTHERS THEN
1450 IF PG_DEBUG in ('Y', 'C') THEN
1451 arp_standard.debug( '-- Exception: Select default values from the receipt');
1452 arp_standard.debug( '-- p_cash_receipt_id='|| TO_CHAR(p_cash_receipt_id));
1453 END IF;
1454 RAISE;
1455 END;
1456 --app_customer_trx_id -4 is passed only in case of chargeback
1457 IF p_app_customer_trx_id = -4 THEN
1458
1459 l_ct_row.bill_to_customer_id := l_bill_to_customer_id;
1460 l_ct_row.remit_to_address_id := p_remit_to_address_id;
1461 l_ct_row.bill_to_site_use_id := p_bill_to_site_use_id;
1462 l_ct_row.exchange_rate_type := p_exchange_rate_type;
1463 l_ct_row.exchange_date := p_exchange_date;
1464 l_ct_row.exchange_rate := p_exchange_rate;
1465 l_ct_row.invoice_currency_code:= p_currency_code;
1466
1467 l_ct_row.primary_salesrep_id := NULL;
1468 l_ct_row.territory_id := NULL;
1469 l_ct_row.ship_to_customer_id := NULL;
1470 l_ct_row.sold_to_customer_id := NULL;
1471 l_ct_row.ship_to_site_use_id := NULL;
1472 l_ct_row.sold_to_site_use_id := NULL;
1473 /* R12 LE uptake */
1474 l_ct_row.legal_entity_id := NVL(p_legal_entity_id,l_rct_le_id);
1475 END IF;
1476
1477 l_ct_row.customer_trx_id := NULL; -- This will be populated when header is inserted
1478 l_ct_row.trx_date := p_trx_date;
1479 l_ct_row.complete_flag := 'Y';
1480 l_ct_row.status_trx := 'OP';
1481 l_ct_row.batch_source_id := 12;
1482 l_ct_row.cust_trx_type_id := p_cust_trx_type_id;
1483 l_ct_row.created_from := p_form_name;
1484 l_ct_row.batch_id := NULL;
1485 l_ct_row.reason_code := p_reason_code;
1486 l_ct_row.attribute_category := p_attribute_category;
1487 l_ct_row.attribute1 := p_attribute1;
1488 l_ct_row.attribute2 := p_attribute2;
1489 l_ct_row.attribute3 := p_attribute3;
1490 l_ct_row.attribute4 := p_attribute4;
1491 l_ct_row.attribute5 := p_attribute5;
1492 l_ct_row.attribute6 := p_attribute6;
1493 l_ct_row.attribute7 := p_attribute7;
1494 l_ct_row.attribute8 := p_attribute8;
1495 l_ct_row.attribute9 := p_attribute9;
1496 l_ct_row.attribute10 := p_attribute10;
1497 l_ct_row.attribute11 := p_attribute11;
1498 l_ct_row.attribute12 := p_attribute12;
1499 l_ct_row.attribute13 := p_attribute13;
1500 l_ct_row.attribute14 := p_attribute14;
1501 l_ct_row.attribute15 := p_attribute15;
1502 l_ct_row.default_ussgl_trx_code_context := p_def_ussgl_trx_code_context;
1503 l_ct_row.default_ussgl_transaction_code :=
1504 p_def_ussgl_transaction_code;
1505 l_ct_row.doc_sequence_id := p_doc_sequence_id;
1506 l_ct_row.doc_sequence_value := p_doc_sequence_value;
1507 l_ct_row.comments := p_comments;
1508 l_ct_row.internal_notes := p_internal_notes; --Bug 2751910
1509 l_ct_row.customer_reference := p_customer_reference; --Bug 2751910
1510
1511 --Bug 2444737
1512 l_ct_row.interface_header_context := p_interface_header_context;
1513 l_ct_row.interface_header_attribute1 := p_interface_header_attribute1;
1514 l_ct_row.interface_header_attribute2 := p_interface_header_attribute2;
1515 l_ct_row.interface_header_attribute3 := p_interface_header_attribute3;
1516 l_ct_row.interface_header_attribute4 := p_interface_header_attribute4;
1517 l_ct_row.interface_header_attribute5 := p_interface_header_attribute5;
1518 l_ct_row.interface_header_attribute6 := p_interface_header_attribute6;
1519 l_ct_row.interface_header_attribute7 := p_interface_header_attribute7;
1520 l_ct_row.interface_header_attribute8 := p_interface_header_attribute8;
1521 l_ct_row.interface_header_attribute9 := p_interface_header_attribute9;
1522 l_ct_row.interface_header_attribute10 := p_interface_header_attribute10;
1523 l_ct_row.interface_header_attribute11 := p_interface_header_attribute11;
1524 l_ct_row.interface_header_attribute12 := p_interface_header_attribute12;
1525 l_ct_row.interface_header_attribute13 := p_interface_header_attribute13;
1526 l_ct_row.interface_header_attribute14 := p_interface_header_attribute14;
1527 l_ct_row.interface_header_attribute15 := p_interface_header_attribute15;
1528
1529 /*Bug 13788971 - Paying Customer details population - Start*/
1530 IF p_app_customer_trx_id <> -4 THEN
1531 l_ct_row.paying_customer_id := l_ct_row.bill_to_customer_id;
1532
1533 IF l_ct_row.paying_customer_id IS NOT NULL THEN
1534 BEGIN
1535 select su.site_use_id
1536 into l_ct_row.paying_site_use_id
1537 from hz_cust_acct_sites acct_site,
1538 hz_party_sites party_site,
1539 hz_locations loc,
1540 hz_cust_site_uses su,
1541 fnd_territories_vl t
1542 where acct_site.cust_acct_site_id = su.cust_acct_site_id
1543 and acct_site.party_site_id = party_site.party_site_id
1544 and loc.location_id = party_site.location_id
1545 and loc.country = t.territory_code
1546 and acct_site.cust_account_id = l_ct_row.paying_customer_id
1547 and su.site_use_id = su.site_use_id
1548 and su.site_use_code = 'BILL_TO'
1549 and su.status = 'A'
1550 and acct_site.status = 'A'
1551 and su.primary_flag = 'Y';
1552 EXCEPTION
1553 WHEN OTHERS THEN
1554 IF PG_DEBUG in ('Y', 'C') THEN
1555 arp_standard.debug('-- Exception: Setting Paying Site use Id');
1556 END IF;
1557 RAISE;
1558 END;
1559
1560 arp_trx_defaults_3.get_payment_method_default(l_ct_row.trx_date,
1561 l_ct_row.invoice_currency_code,
1562 l_ct_row.paying_customer_id,
1563 l_ct_row.paying_site_use_id,
1564 l_ct_row.bill_to_customer_id,
1565 l_ct_row.bill_to_site_use_id,
1566 l_payment_method_name,
1567 l_receipt_method_id,
1568 l_creation_method_code,
1569 'Y');
1570
1571 l_ct_row.receipt_method_id := l_receipt_method_id;
1572 END IF;
1573 END IF;
1574
1575 /*Bug 13788971 - Paying Customer details population - End*/
1576
1577 -- ---------------------------------------------------
1578 -- Insert the customer trx header with the term_id of
1579 -- of '5' which refers to the 'IMMEDIATE' payment
1580 -- term of 100% with 0 due dates
1581 -- ---------------------------------------------------
1582 l_ct_row.term_id := 5;
1583
1584 -- ---------------------------------------------------
1585 -- Select the default printing option according to the
1586 -- transaction type that was passed to the entity handler
1587 -- --------------------------------------------------
1588
1589 BEGIN -- Select printing option
1590 IF PG_DEBUG in ('Y', 'C') THEN
1591 arp_standard.debug( '-- Select printing option');
1592 END IF;
1593
1594 SELECT NVL(ctt.default_printing_option,'PRI')
1595 , DECODE(ctt.default_printing_option
1596 , 'NOT','N'
1597 , 'Y')
1598 INTO l_ct_row.printing_option,
1599 l_ct_row.printing_pending
1600 FROM ra_cust_trx_types ctt
1601 WHERE ctt.cust_trx_type_id = p_cust_trx_type_id;
1602
1603 /* 5084781 Begin*/
1604 select end_date_active
1605 into l_term_end_date
1606 from ra_terms where term_id = 5;
1607
1608 IF (NVL(l_term_end_date, to_date('31-12-4712','DD-MM-YYYY')) < p_trx_date ) THEN
1609 FND_MESSAGE.SET_NAME('AR','AR_RW_PAYMENT_TERM_END_DATED');
1610 APP_EXCEPTION.raise_exception;
1611 END IF;
1612 /*5084781 End*/
1613
1614 EXCEPTION
1615 WHEN OTHERS THEN
1616 IF PG_DEBUG in ('Y', 'C') THEN
1617 arp_standard.debug( '-- Exception: Select printing option from DB');
1618 arp_standard.debug( '-- ctt.cust_trx_type_id='||
1619 TO_CHAR(p_cust_trx_type_id));
1620 END IF;
1621 RAISE;
1622 END; -- Select printing option
1623
1624 -- ---------------------------------------------------
1625 -- Insert header into RA_CUSTOMER_TRX table
1626 -- ---------------------------------------------------
1627
1628 -- Call table handler, get trx_number and customer_trx_id back
1629 -- The main procedure will return trx_number and customer_trx_id
1630 -- back to calling Form or procedure.
1631 arp_ct_pkg.insert_p(
1632 -- IN
1633 p_trx_rec => l_ct_row
1634 -- OUT
1635 , p_trx_number => l_ct_row.trx_number
1636 , p_customer_trx_id => l_ct_row.customer_trx_id
1637 );
1638
1639 p_out_trx_number := l_ct_row.trx_number;
1640 p_out_customer_trx_id := l_ct_row.customer_trx_id;
1641
1642 IF PG_DEBUG in ('Y', 'C') THEN
1643 arp_standard.debug ( '-- Transaction number and internal id values returned from');
1644 arp_standard.debug ( '-- table handler arp_ct_pkg.insert_p:');
1645 arp_standard.debug ( 'trx_number = '||l_ct_row.trx_number);
1646 arp_standard.debug ( 'customer_trx_id = '|| to_char(l_ct_row.customer_trx_id));
1647 arp_standard.debug ( '');
1648 END IF;
1649
1650 /*Bug 13788971 - Payment Intrument details population - Start*/
1651 IF p_app_customer_trx_id <> -4 AND l_ct_row.receipt_method_id is not null THEN
1652 BEGIN
1653 SELECT payment_channel_code,
1654 decode(payment_channel_code,
1655 'BANK_ACCT_XFER',
1656 'BANKACCOUNT',
1657 'BILLS_RECEIVABLE',
1658 'BANKACCOUNT',
1659 'CREDIT_CARD',
1660 'CREDITCARD',
1661 'BANKACCOUNT')
1662 INTO l_payment_channel_code, l_instrument_type
1663 FROM ar_receipt_methods
1664 WHERE receipt_method_id = l_ct_row.receipt_method_id;
1665
1666 SELECT org_id
1667 INTO l_org_id
1668 FROM RA_CUSTOMER_TRX
1669 WHERE customer_trx_id = l_ct_row.customer_trx_id;
1670 EXCEPTION
1671 WHEN NO_DATA_FOUND THEN
1672 IF PG_DEBUG in ('Y', 'C') THEN
1673 arp_standard.debug( '-- Exception: no data found ');
1674 END IF;
1675 WHEN OTHERS THEN
1676 IF PG_DEBUG in ('Y', 'C') THEN
1677 arp_standard.debug('-- Exception: Error getting Payment instrument details for chargeback');
1678 END IF;
1679 RAISE;
1680 END;
1681
1682 IF l_receipt_method_id is NOT NULL and
1683 l_ct_row.invoice_currency_code is not null and
1684 l_payment_channel_code is not null then
1685
1686 arp_trx_defaults_3.get_instr_defaults(l_org_id,
1687 l_ct_row.paying_customer_id,
1688 l_ct_row.paying_site_use_id,
1689 l_instrument_type,
1690 l_ct_row.invoice_currency_code,
1691 l_instr_assignment_id);
1692
1693 create_payment_extension(l_instr_assignment_id,
1694 l_ct_row.paying_customer_id,
1695 l_ct_row.receipt_method_id,
1696 l_org_id,
1697 l_ct_row.paying_site_use_id,
1698 p_out_trx_number,
1699 p_out_customer_trx_id,
1700 l_create_msg_count,
1701 l_create_msg_data,
1702 l_create_return_status,
1703 l_payment_trxn_extension_id,
1704 l_ct_row.trx_date);
1705
1706 UPDATE ra_customer_trx
1707 SET payment_trxn_extension_id = l_payment_trxn_extension_id
1708 WHERE customer_trx_id = p_out_customer_trx_id;
1709
1710 END IF;
1711
1712 END IF;
1713 /*Bug 13788971 - Payment Intrument details population - End*/
1714
1715 -- ---------------------------------------------------
1716 -- Get line type info for RA_CUSTOMER_TRX_LINES columns
1717 -- - memo_line_id = 1 means chargeback memo line
1718 -- ---------------------------------------------------
1719 IF p_app_customer_trx_id <> -4 THEN
1720 BEGIN
1721 IF PG_DEBUG in ('Y', 'C') THEN
1722 arp_standard.debug( '-- Get line type info');
1723 END IF;
1724 SELECT ml.memo_line_id
1725 , ml.line_type
1726 , REPLACE(REPLACE(REPLACE(
1727 REPLACE(ml.description,'&'||'invoice_number'||'&',ln_trx_number), ---bug 5550153
1728 '&'||'INVOICE_NUMBER'||'&',
1729 ln_trx_number), --- bug 5550153
1730 '&'||'receipt_number'||'&',
1731 p_cr_trx_number),
1732 '&'||'RECEIPT_NUMBER'||'&',
1733 p_cr_trx_number)
1734 , ml.uom_code
1735 INTO
1736 l_ctl_row.memo_line_id
1737 , l_ctl_row.line_type
1738 , l_ctl_row.description
1739 , l_ctl_row.uom_code
1740 FROM ar_memo_lines ml
1741 WHERE ml.memo_line_id = 1;
1742
1743 EXCEPTION
1744 WHEN OTHERS THEN
1745 IF PG_DEBUG in ('Y', 'C') THEN
1746 arp_standard.debug( '-- Exception: SELECT FROM AR_MEMO_LINES');
1747 END IF;
1748 app_exception.raise_exception;
1749 END;
1750 ELSE
1751 IF PG_DEBUG in ('Y', 'C') THEN
1752 arp_standard.debug( '-- Get line type info');
1753 END IF;
1754 --snambiar in receipt chargeback case,put the receipt details in
1755 --the description instead of invoice details
1756 BEGIN
1757 SELECT ml.memo_line_id
1758 , ml.line_type
1759 , REPLACE(REPLACE(ml.description,'invoice','Receipt number'),'&'||'INVOICE_NUMBER'||'&',p_cr_trx_number)
1760 , ml.uom_code
1761 INTO
1762 l_ctl_row.memo_line_id
1763 , l_ctl_row.line_type
1764 , l_ctl_row.description
1765 , l_ctl_row.uom_code
1766 FROM ar_memo_lines ml
1767 WHERE ml.memo_line_id = 1;
1768
1769 EXCEPTION
1770 WHEN OTHERS THEN
1771 IF PG_DEBUG in ('Y', 'C') THEN
1772 arp_standard.debug( '-- Exception: SELECT FROM AR_MEMO_LINES');
1773 END IF;
1774 app_exception.raise_exception;
1775 END;
1776 END IF;
1777
1778 -- ---------------------------------------------------
1779 -- Set values for RA_CUSTOMER_TRX_LINES columns
1780 -- ---------------------------------------------------
1781
1782 l_ctl_row.customer_trx_id := l_ct_row.customer_trx_id;
1783 l_ctl_row.line_number := 1;
1784 l_ctl_row.taxable_flag := 'N';
1785 l_ctl_row.unit_selling_price := p_amount;
1786 l_ctl_row.quantity_invoiced := 1;
1787 l_ctl_row.extended_amount := p_amount;
1788 l_ctl_row.reason_code := p_reason_code;
1789 l_ctl_row.revenue_amount := p_amount;
1790 -- Copy the default USSGL values to chargeback lines
1791 l_ctl_row.default_ussgl_transaction_code :=
1792 l_ct_row.default_ussgl_transaction_code;
1793 l_ctl_row.default_ussgl_trx_code_context :=
1794 l_ct_row.default_ussgl_trx_code_context;
1795 l_ctl_row.set_of_books_id := p_set_of_books_id;
1796
1797 -- ---------------------------------------------------
1798 -- Insert line into RA_CUSTOMER_TRX_LINES table
1799 -- ---------------------------------------------------
1800
1801 arp_ctl_pkg.insert_p(
1802 -- IN
1803 p_line_rec => l_ctl_row
1804 -- OUT
1805 , p_customer_trx_line_id => l_ctl_row.customer_trx_line_id
1806 );
1807
1808 -- ---------------------------------------------------
1809 -- Insert revenue account distribution
1810 -- ---------------------------------------------------
1811
1812 -- ---------------------------------------------------
1813 -- Set values for RA_CUST_TRX_LINE_GL_DIST table columns
1814 -- The revenue distributions should have an account class
1815 -- of 'REV'
1816 -- ---------------------------------------------------
1817
1818 l_ctlgd_row.customer_trx_line_id := l_ctl_row.customer_trx_line_id;
1819 l_ctlgd_row.customer_trx_id := l_ct_row.customer_trx_id;
1820 l_ctlgd_row.posting_control_id := -3;
1821 l_ctlgd_row.gl_date := l_chargeback_gl_date;
1822 l_ctlgd_row.original_gl_date := l_chargeback_gl_date;
1823 l_ctlgd_row.account_class := 'REV';
1824 l_ctlgd_row.account_set_flag := 'N';
1825 l_ctlgd_row.latest_rec_flag := NULL;
1826 l_ctlgd_row.amount := p_amount;
1827 /* Bug 3879127 - acctd_amount is calculated using amount_due_remaining
1828 of original invoice instead of allowing it to default */
1829 IF p_app_customer_trx_id = -4
1830 THEN
1831 l_acctd_amount := p_acctd_amount;
1832 /* bug 4126057 set to passed acctd amt instead of null */
1833 ELSE
1834 arp_util.calc_acctd_amount(
1835 NULL
1836 , NULL
1837 , NULL
1838 , NVL(l_ct_row.exchange_rate,1) -- Exchange rate
1839 , '-' -- amount_applied must be subtracted from ADR
1840 , ln_amount_due_remaining -- Current ADR
1841 , ln_acctd_amount_due_remaining -- Current Acctd. ADR
1842 , p_amount -- Chargeback amount
1843 , ln_adr_tmp -- New ADR (OUT)
1844 , ln_acctd_adr_tmp -- New Acctd. ADR (OUT)
1845 , l_acctd_amount); -- Acct. amount
1846 -- (OUT)
1847 END IF;
1848 l_ctlgd_row.acctd_amount := l_acctd_amount;
1849 l_ctlgd_row.percent := 100;
1850 -- Copy the default values to distribution lines
1851 l_ctlgd_row.ussgl_transaction_code :=
1852 l_ct_row.default_ussgl_transaction_code;
1853 l_ctlgd_row.ussgl_transaction_code_context :=
1854 l_ct_row.default_ussgl_trx_code_context;
1855
1856 -- ---------------------------------------------------
1857 -- Get CB_ADJ activity accounting code combination
1858 -- ---------------------------------------------------
1859 BEGIN
1860 IF PG_DEBUG in ('Y', 'C') THEN
1861 arp_standard.debug( '-- Get CB_ADJ activity accounting code combination');
1862 END IF;
1863 SELECT rt.code_combination_id
1864 INTO l_cb_activity_ccid
1865 FROM ar_receivables_trx rt
1866 WHERE rt.receivables_trx_id = arp_global.G_CB_RT_ID
1867 AND rt.code_combination_id IS NOT NULL;
1868 EXCEPTION
1869 WHEN NO_DATA_FOUND THEN
1870 FND_MESSAGE.set_name('AR', 'AR_RW_NO_GL_ACCT' );
1871 app_exception.raise_exception;
1872 WHEN OTHERS THEN
1873 IF PG_DEBUG in ('Y', 'C') THEN
1874 arp_standard.debug( '-- Exception: select from ar_receivables_trx');
1875 END IF;
1876 END;
1877
1878 l_ctlgd_row.code_combination_id := l_cb_activity_ccid;
1879
1880 IF p_app_customer_trx_id = -4 THEN
1881 --Get CCID for receipt UNAPP
1882 arp_proc_rct_util.get_ccids(
1883 l_receipt_method_id,
1884 l_remit_bank_acct_use_id,
1885 l_id_dummy,
1886 l_cr_unapp_ccid,
1887 l_id_dummy,
1888 l_id_dummy,
1889 l_id_dummy,
1890 l_id_dummy,
1891 l_id_dummy,
1892 l_id_dummy,
1893 l_id_dummy,
1894 l_id_dummy);
1895
1896
1897 /* -------------------------------------------------------------------+
1898 | Balancing segment of chargeback application should be replaced with|
1899 | that of Receipt's UNAPP record |
1900 +--------------------------------------------------------------------*/
1901 -- Bugfix 1948917.
1902 IF NVL(FND_PROFILE.value('AR_DISABLE_REC_ACTIVITY_BALSEG_SUBSTITUTION'), 'N') = 'N' THEN
1903 arp_util.Substitute_Ccid(p_coa_id => arp_global.chart_of_accounts_id ,
1904 p_original_ccid => l_ctlgd_row.code_combination_id ,
1905 p_subs_ccid => l_cr_unapp_ccid ,
1906 p_actual_ccid => l_actual_ccid );
1907 ELSE
1908 l_actual_ccid := l_ctlgd_row.code_combination_id;
1909 END IF;
1910 ELSE
1911 -- Regular chargeback should replace the balancing segment of the invoice REC
1912 -- Bugfix 1948917.
1913 IF NVL(FND_PROFILE.value('AR_DISABLE_REC_ACTIVITY_BALSEG_SUBSTITUTION'), 'N') = 'N' THEN
1914 arp_util.Substitute_Ccid(p_coa_id => arp_global.chart_of_accounts_id ,
1915 p_original_ccid => l_ctlgd_row.code_combination_id ,
1916 p_subs_ccid => l_inv_rec_ccid ,
1917 p_actual_ccid => l_actual_ccid );
1918 ELSE
1919 l_actual_ccid := l_ctlgd_row.code_combination_id;
1920 END IF;
1921
1922
1923 END IF;
1924 l_ctlgd_row.code_combination_id := l_actual_ccid;
1925 -- ---------------------------------------------------
1926 -- Insert line into RA_CUST_TRX_LINE_GL_DIST table
1927 -- ---------------------------------------------------
1928
1929 arp_ctlgd_pkg.insert_p(
1930 -- IN
1931 p_dist_rec => l_ctlgd_row
1932 , p_exchange_rate => l_ct_row.exchange_rate
1933 , p_currency_code => arp_trx_global.system_info.base_currency
1934 , p_precision => arp_trx_global.system_info.base_precision
1935 , p_mau => arp_trx_global.system_info.base_min_acc_unit
1936 -- OUT
1937 , p_cust_trx_line_gl_dist_id
1938 => l_ctlgd_row.cust_trx_line_gl_dist_id
1939 );
1940
1941 -- ---------------------------------------------------
1942 -- Insert receivables account distribution
1943 -- ---------------------------------------------------
1944
1945 -- ---------------------------------------------------
1946 -- Set values for RA_CUST_TRX_LINE_GL_DIST table columns
1947 -- The receivables distributions should have an account class
1948 -- of 'REC'.
1949 -- The receivable account distributions records should
1950 -- not have a value in CUSTOMER_TRX_LINE_ID
1951 -- ---------------------------------------------------
1952
1953 l_ctlgd_row.customer_trx_line_id := NULL;
1954 l_ctlgd_row.customer_trx_id := l_ct_row.customer_trx_id;
1955 l_ctlgd_row.posting_control_id := -3;
1956 l_ctlgd_row.gl_date := l_chargeback_gl_date;
1957 l_ctlgd_row.original_gl_date := l_chargeback_gl_date;
1958 l_ctlgd_row.account_class := 'REC';
1959 l_ctlgd_row.account_set_flag := 'N';
1960 l_ctlgd_row.latest_rec_flag := 'Y';
1961 l_ctlgd_row.code_combination_id := p_gl_id_ar_trade;
1962 l_ctlgd_row.amount := p_amount;
1963 l_ctlgd_row.percent := 100;
1964 -- Copy the default values to distribution lines
1965 l_ctlgd_row.ussgl_transaction_code :=
1966 l_ct_row.default_ussgl_transaction_code;
1967 l_ctlgd_row.ussgl_transaction_code_context :=
1968 l_ct_row.default_ussgl_trx_code_context;
1969
1970 -- ---------------------------------------------------
1971 -- Insert line into RA_CUST_TRX_LINE_GL_DIST table
1972 -- ---------------------------------------------------
1973 arp_ctlgd_pkg.insert_p(
1974 -- IN
1975 p_dist_rec => l_ctlgd_row
1976 , p_exchange_rate => l_ct_row.exchange_rate
1977 , p_currency_code => arp_trx_global.system_info.base_currency
1978 , p_precision => arp_trx_global.system_info.base_precision
1979 , p_mau => arp_trx_global.system_info.base_min_acc_unit
1980 -- OUT
1981 , p_cust_trx_line_gl_dist_id
1982 => l_ctlgd_row.cust_trx_line_gl_dist_id
1983 );
1984
1985 -- ---------------------------------------------------
1986 -- Set values form AR_PAYMENT_SCHEDULES row.
1987 --
1988 -- Insert the payment schedule with the term_id of
1989 -- of '5' which refers to the 'IMMEDIATE' payment
1990 -- term of 100% with 0 due dates
1991 -- ---------------------------------------------------
1992
1993 l_ps_row.number_of_due_dates := 1;
1994 l_ps_row.status := 'OP';
1995 l_ps_row.class := 'CB';
1996 l_ps_row.cash_receipt_id := NULL;
1997 l_ps_row.term_id := 5;
1998 l_ps_row.terms_sequence_number := 1;
1999 l_ps_row.gl_date_closed := NULL;
2000 l_ps_row.actual_date_closed := NULL;
2001 l_ps_row.discount_date := NULL;
2002
2003 l_ps_row.due_date := p_due_date;
2004 l_ps_row.amount_due_original := p_amount;
2005 l_ps_row.amount_due_remaining := p_amount;
2006 l_ps_row.acctd_amount_due_remaining := l_acctd_amount; -- bug 3879127
2007 l_ps_row.invoice_currency_code := l_ct_row.invoice_currency_code;
2008 l_ps_row.gl_date := l_chargeback_gl_date;
2009 l_ps_row.cust_trx_type_id := p_cust_trx_type_id;
2010 l_ps_row.customer_id := p_customer_id;
2011 l_ps_row.customer_site_use_id := l_ct_row.bill_to_site_use_id;
2012 l_ps_row.customer_trx_id := l_ct_row.customer_trx_id;
2013 l_ps_row.associated_cash_receipt_id := p_cash_receipt_id;
2014 l_ps_row.amount_line_items_original := p_amount;
2015 l_ps_row.amount_line_items_remaining := p_amount;
2016 l_ps_row.exchange_rate_type := l_ct_row.exchange_rate_type;
2017 l_ps_row.exchange_date := l_ct_row.exchange_date;
2018 l_ps_row.exchange_rate := l_ct_row.exchange_rate;
2019 l_ps_row.trx_number := l_ct_row.trx_number;
2020 l_ps_row.trx_date := TRUNC(l_ct_row.trx_date); /* Bug 5758906 */
2021
2022 -- ---------------------------------------------------
2023 -- Insert row into AR_PAYMENT_SCHEDULES table
2024 -- ---------------------------------------------------
2025 arp_ps_pkg.insert_p(
2026 p_ps_rec => l_ps_row -- IN
2027 , p_ps_id => l_ps_row.payment_schedule_id -- OUT
2028 );
2029
2030 -- Clear out l_ps_row.payment_schedule_id, because it would
2031 -- cause chargeback PS row to be updated in
2032 -- arp_ps_util.update_invoice_related_columms
2033 l_ps_row.payment_schedule_id := NULL;
2034
2035 ln_line_applied := p_amount;
2036 ln_tax_applied := 0;
2037 ln_freight_applied := 0;
2038 ln_charges_applied := 0;
2039 ln_acctd_amount_applied := 0;
2040 ln_acctd_earned_discount_taken := 0;
2041 ln_acctd_unearned_disc_taken := 0;
2042
2043
2044 /*----------------------------------------------
2045 Calling ARP_XLA_EVENTS to create the CB_CREATE
2046 ----------------------------------------------*/
2047 -- BUG#2750340 : Call AR_XLA_EVENTS
2048 l_ev_rec.xla_from_doc_id := l_ct_row.customer_trx_id;
2049 l_ev_rec.xla_to_doc_id := l_ct_row.customer_trx_id;
2050 l_ev_rec.xla_req_id := NULL;
2051 l_ev_rec.xla_dist_id := NULL;
2052 l_ev_rec.xla_doc_table := 'CT';
2053 l_ev_rec.xla_doc_event := NULL;
2054 l_ev_rec.xla_mode := 'O';
2055 l_ev_rec.xla_call := 'B';
2056 arp_xla_events.create_events(p_xla_ev_rec => l_ev_rec );
2057
2058 /*
2059 -- ---------------------------------------------------
2060 -- Updates ar_payment_schedules
2061 -- ---------------------------------------------------
2062 arp_ps_util.update_invoice_related_columns(
2063 -- IN
2064 p_app_type => 'CB'
2065 , p_ps_id => p_app_customer_trx_id
2066 , p_amount_applied => p_amount
2067 , p_discount_taken_earned => 0
2068 , p_discount_taken_unearned => 0
2069 , p_apply_date => p_apply_date
2070 , p_gl_date => l_chargeback_gl_date
2071 -- OUT
2072 , p_acctd_amount_applied => ln_acctd_amount_applied
2073 , p_acctd_earned_discount_taken => ln_acctd_earned_discount_taken
2074 , p_acctd_unearned_disc_taken => ln_acctd_unearned_disc_taken
2075 , p_line_applied => ln_line_applied
2076 , p_tax_applied => ln_tax_applied
2077 , p_freight_applied => ln_freight_applied
2078 , p_charges_applied => ln_charges_applied
2079 , p_ps_rec => l_ps_row);
2080 */
2081
2082
2083 -- ---------------------------------------------------
2084 -- Set values for AR_ADJUSTMENTS columns
2085 -- ---------------------------------------------------
2086
2087 -- Caroline M Clyde December 23, 1997
2088 -- Log 597194
2089 --
2090 -- Added the SELECT statement below to retrieve the Receivables Activity
2091 -- Account. The adjustment should be created with this account and not
2092 -- the Receivables Account defined on the Transaction Type.
2093 --
2094 -- The Receivables Activity for id -11 is the 'Chargeback Adjustment'
2095 -- activity.
2096
2097 --snambiar - for receipt chargeback,there is no need to create any
2098 --adjustments. Hence making adjustment creation conditional for
2099 --p_app_customer_trx_id -4
2100
2101 IF (p_app_customer_trx_id <> -4) THEN
2102
2103 -- Identifier of customer transaction associated with this adjustment
2104 -- Store the adjusted invoice ID
2105 l_adj_row.code_combination_id := l_actual_ccid;
2106 l_adj_row.customer_trx_id := p_app_customer_trx_id;
2107 l_adj_row.payment_schedule_id := ln_app_payment_schedule_id;
2108 l_adj_row.receivables_trx_id := arp_global.G_CB_RT_ID;
2109 l_adj_row.postable := 'Y';
2110
2111 -- This type is just temporary 'CB' type in order to get
2112 -- update_adj_related_columns procedure work properly with
2113 -- chargebacks. If this were 'INVOICE', it would not work because
2114 -- line adjustment is hard coded to be the full amount of
2115 -- line_items_amount_due_remaining.
2116 l_adj_row.type := 'CB';
2117
2118 l_adj_row.adjustment_type := 'M';
2119 l_adj_row.associated_cash_receipt_id := p_cash_receipt_id;
2120
2121 -- Identifier of chargeback transaction associated with this adjustment
2122 -- Store the corresponding Chargeback ID
2123 l_adj_row.chargeback_customer_trx_id := l_ct_row.customer_trx_id;
2124 l_adj_row.created_from := p_form_name;
2125 l_adj_row.line_adjusted := (ln_line_applied * -1);
2126 l_adj_row.tax_adjusted := (ln_tax_applied * -1);
2127 l_adj_row.freight_adjusted := (ln_freight_applied * -1);
2128 l_adj_row.receivables_charges_adjusted:= (ln_charges_applied * -1);
2129
2130 l_adj_row.gl_date := TRUNC(l_chargeback_gl_date);
2131 l_adj_row.apply_date := TRUNC(p_apply_date);
2132 l_adj_row.amount := (p_amount * -1);
2133 l_adj_row.acctd_amount := (p_acctd_amount * -1);
2134
2135 -- Use the old information from Chargeback to populate rest of columns
2136 l_adj_row.subsequent_trx_id := 0;
2137 l_adj_row.customer_trx_line_id := 0;
2138 l_adj_row.status := 'A';
2139 l_adj_row.automatically_generated := 'A';
2140 l_adj_row.posting_control_id := -3;
2141 l_adj_row.ussgl_transaction_code :=
2142 l_ct_row.default_ussgl_transaction_code;
2143 l_adj_row.ussgl_transaction_code_context :=
2144 l_ct_row.default_ussgl_trx_code_context;
2145 l_adj_row.reason_code := p_reason_code;
2146 l_adj_row.comments := p_comments;
2147
2148 -- -----------------------------------------------------------------
2149 -- Get document numbers only if customer is using document numbering
2150 -- -----------------------------------------------------------------
2151 -- Profile option values:
2152 -- 'A' = always used
2153 -- 'P' = Partially Used
2154 -- 'N' = not used
2155 IF (NVL(fnd_profile.value('UNIQUE:SEQ_NUMBERS'),'N') <> 'N')
2156 THEN
2157 -- Set up sequential numbering stuff
2158 SELECT rt.name
2159 INTO l_rec_name
2160 FROM ar_receivables_trx rt
2161 WHERE rt.receivables_trx_id = arp_global.G_CB_RT_ID;
2162
2163
2164 -- Bug 686025/694300: instead of calling GET_SEQ_NAME, use
2165 -- proper AOL API GET_NEXT_SEQUENCE to get sequence number.
2166
2167 /*
2168 FND_SEQNUM.GET_SEQ_NAME(
2169 arp_standard.application_id
2170 , l_rec_name -- category code
2171 , arp_global.set_of_books_id
2172 , 'A'
2173 , l_adj_row.apply_date
2174 , l_sequence_name
2175 , l_sequence_id
2176 , l_sequence_assignment_id);
2177
2178 l_adj_row.doc_sequence_value :=
2179 fnd_seqnum.get_next_auto_seq(l_sequence_name);
2180 l_adj_row.doc_sequence_id := l_sequence_id;
2181
2182 */
2183
2184 BEGIN
2185
2186 l_adj_row.doc_sequence_value :=
2187 FND_SEQNUM.GET_NEXT_SEQUENCE(
2188 appid => arp_standard.application_id,
2189 cat_code => l_rec_name,
2190 sobid => arp_global.set_of_books_id,
2191 met_code => 'A',
2192 trx_date => l_adj_row.apply_date,
2193 dbseqnm => l_sequence_name,
2194 dbseqid => l_adj_row.doc_sequence_id);
2195
2196 IF PG_DEBUG in ('Y', 'C') THEN
2197 arp_standard.debug( 'doc sequence name = ' || l_sequence_name);
2198 arp_standard.debug( 'doc sequence id = ' || l_adj_row.doc_sequence_id);
2199 arp_standard.debug( 'doc sequence value = ' || l_adj_row.doc_sequence_value);
2200 END IF;
2201 EXCEPTION
2202 WHEN OTHERS THEN
2203 --Fix for Bug 1421614: For 'Partial' we should not raise the exception.
2204 IF NVL(fnd_profile.value('UNIQUE:SEQ_NUMBERS'),'N') = 'A' THEN
2205 FND_MESSAGE.set_name ('AR', 'AR_RW_NO_DOC_SEQ' );
2206 APP_EXCEPTION.raise_exception;
2207 END IF;
2208 END;
2209
2210 ELSE
2211 l_adj_row.doc_sequence_value := NULL;
2212 l_adj_row.doc_sequence_id := NULL;
2213 END IF;
2214
2215 -- ---------------------------------------------------
2216 -- Create adjustment against old invoice
2217 -- ---------------------------------------------------
2218 arp_process_adjustment.insert_adjustment(
2219 -- IN
2220 p_form_name => p_form_name
2221 , p_form_version => 1
2222 , p_adj_rec => l_adj_row
2223 -- OUT
2224 , p_adjustment_number => l_adj_row.adjustment_number
2225 , p_adjustment_id => l_adj_row.adjustment_id
2226 );
2227
2228 -- ---------------------------------------------------
2229 -- ---------------------------------------------------
2230 END IF; --for transaction adjustments not required for p_app_customer_trx_id -4
2231 --Ajay : chargeback creation business event related stuff
2232 AR_BUS_EVENT_COVER.Raise_Trx_Creation_Event
2233 ('CB',
2234 l_ct_row.customer_trx_id,
2235 l_prev_cust_old_state);
2236 /* bug 10349867 PT ER */
2237 IF jg_zz_ar_trx_pkg.is_reg_loc_enabled THEN
2238 arp_standard.debug('calling: jg_zz_ar_trx_pkg.is_reg_loc_enabled');
2239 DECLARE
2240 p_return_flag boolean;
2241 p_return_code number;
2242 p_return_message varchar2(1024);
2243 BEGIN
2244
2245
2246 jg_zz_ar_trx_pkg.do_trx_complete(null,l_ct_row.customer_trx_id,'CHARGEBACK',p_return_flag, p_return_code,p_return_message);
2247
2248 IF (p_return_flag = FALSE) THEN
2249 arp_standard.debug('Creating the Credit memo in Complete Status ');
2250 arp_standard.debug('Issue at the time of signature generation for localization');
2251 arp_standard.debug('Message : '||p_return_message);
2252
2253 END IF;
2254 EXCEPTION
2255 WHEN OTHERS THEN
2256 arp_standard.debug(' error from jg_zz_ar_trx_pkg.is_reg_loc_enabled Call');
2257
2258 END;
2259 arp_standard.debug(' Exiting from PT Code Hook');
2260 END IF;
2261
2262 EXCEPTION
2263 WHEN OTHERS THEN
2264 IF PG_DEBUG in ('Y', 'C') THEN
2265 arp_standard.debug ('ARP_PROCESS_CHARGEBACK.CREATE_CHARGEBACK: Exception');
2266 arp_standard.debug ( 'Printing the contents of procedure parameters:');
2267 END IF;
2268 -- Print debug info
2269 IF PG_DEBUG in ('Y', 'C') THEN
2270 arp_standard.debug ( ' p_amount = '||TO_CHAR( p_amount ));
2271 arp_standard.debug ( ' p_acctd_amount = '||TO_CHAR( p_acctd_amount ));
2272 arp_standard.debug ( ' p_trx_date = '||TO_CHAR( p_trx_date ));
2273 arp_standard.debug ( ' p_gl_id_ar_trade = '||TO_CHAR( p_gl_id_ar_trade ));
2274 arp_standard.debug ( ' p_gl_date = '||TO_CHAR( l_chargeback_gl_date ));
2275 arp_standard.debug ( ' p_attribute_category = '||p_attribute_category );
2276 arp_standard.debug ( ' p_attribute1 = '||p_attribute1 );
2277 arp_standard.debug ( ' p_attribute2 = '||p_attribute2 );
2278 arp_standard.debug ( ' p_attribute3 = '||p_attribute3 );
2279 arp_standard.debug ( ' p_attribute4 = '||p_attribute4 );
2280 arp_standard.debug ( ' p_attribute5 = '||p_attribute5 );
2281 arp_standard.debug ( ' p_attribute6 = '||p_attribute6 );
2282 arp_standard.debug ( ' p_attribute7 = '||p_attribute7 );
2283 arp_standard.debug ( ' p_attribute8 = '||p_attribute8 );
2284 arp_standard.debug ( ' p_attribute9 = '||p_attribute9 );
2285 arp_standard.debug ( ' p_attribute10 = '||p_attribute10 );
2286 arp_standard.debug ( ' p_attribute11 = '||p_attribute11 );
2287 arp_standard.debug ( ' p_attribute12 = '||p_attribute12 );
2288 arp_standard.debug ( ' p_attribute13 = '||p_attribute13 );
2289 arp_standard.debug ( ' p_attribute14 = '||p_attribute14 );
2290 arp_standard.debug ( ' p_attribute15 = '||p_attribute15 );
2291 arp_standard.debug ( ' p_cust_trx_type_id = '||TO_CHAR( p_cust_trx_type_id ));
2292 arp_standard.debug ( ' p_set_of_books_id = '||TO_CHAR( p_set_of_books_id ));
2293 arp_standard.debug ( ' p_reason_code = '||p_reason_code );
2294 arp_standard.debug ( ' p_comments = '||p_comments );
2295 arp_standard.debug ( ' p_def_ussgl_trx_code_contex = '||p_def_ussgl_trx_code_context);
2296 arp_standard.debug ( ' p_def_ussgl_transaction_cod = '||p_def_ussgl_transaction_code);
2297 arp_standard.debug ( ' p_due_date = '||TO_CHAR( p_due_date ));
2298 arp_standard.debug ( ' p_customer_id = '||TO_CHAR( p_customer_id ));
2299 arp_standard.debug ( ' p_cr_trx_number = '||p_cr_trx_number );
2300 arp_standard.debug ( ' p_cash_receipt_id = '||TO_CHAR( p_cash_receipt_id ));
2301 arp_standard.debug ( ' p_inv_trx_number = '||p_inv_trx_number );
2302 arp_standard.debug ( ' p_apply_date = '||TO_CHAR( p_apply_date ));
2303 arp_standard.debug ( ' p_receipt_gl_date = '||TO_CHAR( p_receipt_gl_date ));
2304 arp_standard.debug ( ' p_app_customer_trx_id = '||TO_CHAR( p_app_customer_trx_id ));
2305 arp_standard.debug ( ' p_app_terms_sequence_number = '||TO_CHAR( p_app_terms_sequence_number ));
2306 arp_standard.debug ( ' p_form_name = '||p_form_name );
2307 arp_standard.debug ( ' p_doc_sequence_value = '||TO_CHAR( p_doc_sequence_value));
2308 arp_standard.debug ( ' p_doc_sequence_id = '||TO_CHAR( p_doc_sequence_id));
2309 END IF;
2310
2311 RAISE;
2312
2313 IF PG_DEBUG in ('Y', 'C') THEN
2314 arp_standard.debug('arp_process_chargeback.create_chargeback()-');
2315 END IF;
2316
2317 END create_chargeback;
2318
2319
2320 /*
2321 ===========================================================================+
2322 PROCEDURE
2323 update_chargeback()
2324
2325 DESCRIPTION
2326 This procedure will update chargeback comments and reason code.
2327 These are the only allowed updateable columns.
2328
2329 SCOPE
2330 Public
2331
2332 EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
2333
2334 ARGUMENTS
2335 IN
2336 p_customer_trx_id
2337 p_comments
2338 p_reason_code
2339
2340 OUT
2341 NONE
2342
2343 RETURNS
2344
2345 NOTES
2346
2347 MODIFICATION HISTORY
2348 4/15/1996 Harri Kaukovuo Created
2349 +===========================================================================
2350 */
2351
2352 PROCEDURE update_chargeback (
2353 p_customer_trx_id IN NUMBER
2354 , p_comments IN VARCHAR2
2355 , p_DEFAULT_USSGL_TRX_CODE IN VARCHAR2
2356 , p_reason_code IN VARCHAR2
2357 , p_ATTRIBUTE_CATEGORY IN VARCHAR2
2358 , p_attribute1 IN VARCHAR2
2359 , p_attribute2 IN VARCHAR2
2360 , p_attribute3 IN VARCHAR2
2361 , p_attribute4 IN VARCHAR2
2362 , p_attribute5 IN VARCHAR2
2363 , p_attribute6 IN VARCHAR2
2364 , p_attribute7 IN VARCHAR2
2365 , p_attribute8 IN VARCHAR2
2366 , p_attribute9 IN VARCHAR2
2367 , p_attribute10 IN VARCHAR2
2368 , p_attribute11 IN VARCHAR2
2369 , p_attribute12 IN VARCHAR2
2370 , p_attribute13 IN VARCHAR2
2371 , p_attribute14 IN VARCHAR2
2372 , p_attribute15 IN VARCHAR2) IS
2373
2374 l_trx_rec RA_CUSTOMER_TRX%ROWTYPE;
2375
2376 BEGIN
2377
2378 IF PG_DEBUG in ('Y', 'C') THEN
2379 arp_standard.debug ('arp_process_chargeback.update_chargeback()+');
2380 END IF;
2381
2382 -- ---------------------------------------------------
2383 -- First set all record parameters to dummy
2384 -- ---------------------------------------------------
2385 arp_ct_pkg.set_to_dummy (
2386 l_trx_rec);
2387
2388 l_trx_rec.customer_trx_id := p_customer_trx_id;
2389 l_trx_rec.comments := p_comments;
2390 l_trx_rec.reason_code := p_reason_code;
2391 l_trx_rec.DEFAULT_USSGL_TRANSACTION_CODE := p_DEFAULT_USSGL_TRX_CODE;
2392 l_trx_rec.attribute_category := p_attribute_category;
2393 l_trx_rec.attribute1 := p_attribute1;
2394 l_trx_rec.attribute2 := p_attribute2;
2395 l_trx_rec.attribute3 := p_attribute3;
2396 l_trx_rec.attribute4 := p_attribute4;
2397 l_trx_rec.attribute5 := p_attribute5;
2398 l_trx_rec.attribute6 := p_attribute6;
2399 l_trx_rec.attribute7 := p_attribute7;
2400 l_trx_rec.attribute8 := p_attribute8;
2401 l_trx_rec.attribute9 := p_attribute9;
2402 l_trx_rec.attribute10 := p_attribute10;
2403 l_trx_rec.attribute11 := p_attribute11;
2404 l_trx_rec.attribute12 := p_attribute12;
2405 l_trx_rec.attribute13 := p_attribute13;
2406 l_trx_rec.attribute14 := p_attribute14;
2407 l_trx_rec.attribute15 := p_attribute15;
2408
2409 -- ---------------------------------------------------
2410 -- Update
2411 -- ---------------------------------------------------
2412 arp_ct_pkg.update_p (
2413 l_trx_rec
2414 , p_customer_trx_id);
2415
2416 IF PG_DEBUG in ('Y', 'C') THEN
2417 arp_standard.debug ('arp_process_chargeback.update_chargeback()-');
2418 END IF;
2419
2420 EXCEPTION
2421 WHEN OTHERS THEN
2422 IF PG_DEBUG in ('Y', 'C') THEN
2423 arp_standard.debug ('EXCEPTION: arp_process_chargeback.update_chargeback()');
2424 arp_standard.debug ( 'ERROR in the program! Dump of parameter values:');
2425 arp_standard.debug ( ' p_customer_trx_id = '||TO_CHAR(p_customer_trx_id));
2426 arp_standard.debug ( ' p_comments = '||p_comments);
2427 arp_standard.debug ( ' p_DEFAULT_USSGL_TRX_CODE = '||p_DEFAULT_USSGL_TRX_CODE);
2428 arp_standard.debug ( ' p_reason_code = '||p_reason_code);
2429 END IF;
2430 RAISE;
2431 END update_chargeback;
2432
2433 /*===========================================================================+
2434 | PROCEDURE
2435 | delete_chargeback
2436 |
2437 | DESCRIPTION
2438 | This procedure deletes chargeback from database.
2439 |
2440 | SCOPE - PUBLIC
2441 |
2442 | EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
2443 |
2444 | ARGUMENTS : IN:
2445 | OUT:
2446 |
2447 | RETURNS : NONE
2448 |
2449 | NOTES
2450 | This procedure is originally converted from C -procedure arxdcb
2451 | which is in file arxdcb.lpc
2452 |
2453 | Algorithm:
2454 | 1. Process parameters
2455 | 2. Call reverse_chargeback to insert adj and update payment schedule
2456 | of CB
2457 | 3. Call arp_process_adjustment.reverse_adjustment to insert
2458 | an opposing adjustment for the CB-ADJ
2459 | 4. Call xxxx to get max GL date and apply date
2460 | 5. Call xxx to update payment schedule of the debit item.
2461 |
2462 | MODIFICATION HISTORY
2463 | 4/15/1996 Harri Kaukovuo Created
2464 | 03/23/2001 S.Nambiar Modified delete_chargeback procedure
2465 | to incorporate the new functionality
2466 | to create Chargeback aganist receipts.
2467 | In case of receipt CB, p_type will be
2468 | "RECEIPT" in all other cases it will be
2469 | defaulted to "TRANSACTION"
2470 +===========================================================================*/
2471
2472 PROCEDURE delete_chargeback (
2473 p_customer_trx_id IN NUMBER
2474 , p_apply_date IN DATE
2475 , p_gl_date IN DATE
2476 , p_module_name IN VARCHAR2
2477 , p_module_version IN VARCHAR2
2478 , p_type IN VARCHAR2) IS
2479
2480 ln_adj_id NUMBER;
2481 ln_adj_amt NUMBER;
2482 ln_acctd_adj_amt NUMBER;
2483 ln_line_adj NUMBER;
2484 ln_tax_adj NUMBER;
2485 ln_frt_adj NUMBER;
2486 ln_chrg_adj NUMBER;
2487 lc_status VARCHAR2(40);
2488 l_ps_rec ar_payment_schedules%ROWTYPE;
2489
2490 l_out_line_adjusted NUMBER;
2491 l_out_tax_adjusted NUMBER;
2492 l_out_freight_adjusted NUMBER;
2493 l_out_charges_adjusted NUMBER;
2494 l_out_acctd_amount_adjusted NUMBER;
2495 /* New variables defined for bug 2399863 */
2496 l_line_adjusted NUMBER;
2497 l_tax_adjusted NUMBER;
2498 l_frt_adjusted NUMBER;
2499 l_charges_adjusted NUMBER;
2500
2501 BEGIN
2502
2503 arp_process_chargeback.reverse_chargeback (
2504 p_cb_ct_id => p_customer_trx_id
2505 , p_reversal_gl_date => p_gl_date
2506 , p_reversal_date => p_apply_date
2507 , p_module_name => p_module_name
2508 , p_module_version => p_module_version
2509 , p_type => p_type
2510 );
2511
2512 arp_ps_pkg.set_to_dummy (l_ps_rec);
2513
2514 IF p_type <> 'TRANSACTION' THEN
2515 --snambiar. For receipt chargeback,we will pass p_type as "RECEIPT"
2516 --and in all other cases,p_type is defaulted to "TRANSACTION"
2517 --Since we do not have an adjustment created for receipt chargeback,
2518 --we do not need to reverse the adjustment.
2519 NULL;
2520 ELSE
2521 --chargeback aganist Invoice,CM
2522 BEGIN
2523 SELECT
2524 adj.adjustment_id
2525 , adj.payment_schedule_id
2526 , adj.amount
2527 , adj.acctd_amount
2528 , NVL(adj.line_adjusted,0)
2529 , NVL(adj.tax_adjusted,0)
2530 , NVL(adj.freight_adjusted,0)
2531 , NVL(adj.receivables_charges_adjusted,0)
2532 , adj.status
2533 INTO
2534 ln_adj_id
2535 , l_ps_rec.payment_schedule_id
2536 , ln_adj_amt
2537 , ln_acctd_adj_amt
2538 , ln_line_adj
2539 , ln_tax_adj
2540 , ln_frt_adj
2541 , ln_chrg_adj
2542 , lc_status
2543 FROM ar_adjustments adj
2544 WHERE adj.chargeback_customer_trx_id = p_customer_trx_id
2545 AND adj.receivables_trx_id = -11;
2546
2547 EXCEPTION
2548 WHEN OTHERS THEN
2549 RAISE;
2550 END;
2551
2552 arp_process_adjustment.reverse_adjustment (
2553 P_ADJ_ID => ln_adj_id
2554 , P_REVERSAL_GL_DATE => p_gl_date
2555 , P_REVERSAL_DATE => p_apply_date
2556 , P_MODULE_NAME => p_module_name
2557 , P_MODULE_VERSION => p_module_version);
2558
2559 arp_ps_util.get_closed_dates(
2560 p_ps_id => l_ps_rec.payment_schedule_id
2561 , p_gl_reversal_date => p_gl_date
2562 , p_reversal_date => p_apply_date
2563 , p_gl_date_closed => l_ps_rec.gl_date_closed -- OUT
2564 , p_actual_date_closed => l_ps_rec.actual_date_closed -- OUT
2565 , p_app_type => 'ADJ');
2566
2567 /* Bug 2399863
2568 For reversing the chargeback, pass the p_type as CBREV and
2569 pass the values for line, tax, frt and charges adjusted */
2570 l_line_adjusted := -ln_line_adj;
2571 l_tax_adjusted := -ln_tax_adj;
2572 l_frt_adjusted := -ln_frt_adj;
2573 l_charges_adjusted := -ln_chrg_adj;
2574 arp_ps_util.update_adj_related_columns (
2575 -- IN
2576 p_ps_id => l_ps_rec.payment_schedule_id
2577 , p_type => 'CBREV'
2578 , p_amount_adjusted => -ln_adj_amt
2579 , p_amount_adjusted_pending => 0
2580 , p_apply_date => p_apply_date
2581 , p_gl_date => p_gl_date
2582 , p_ps_rec => NULL_VAR /*Bug 460966 - Oracle 8 */
2583 -- OUT
2584 , p_line_adjusted => l_line_adjusted
2585 , p_tax_adjusted => l_tax_adjusted
2586 , p_freight_adjusted => l_frt_adjusted
2587 , p_charges_adjusted => l_charges_adjusted
2588 , p_acctd_amount_adjusted => l_out_acctd_amount_adjusted
2589 );
2590 l_out_line_adjusted := l_line_adjusted;
2591 l_out_tax_adjusted := l_tax_adjusted;
2592 l_out_freight_adjusted := l_frt_adjusted;
2593 l_out_charges_adjusted := l_charges_adjusted;
2594 END IF;
2595 EXCEPTION
2596 WHEN OTHERS THEN
2597 IF PG_DEBUG in ('Y', 'C') THEN
2598 arp_standard.debug ('EXCEPTION: arp_process_chargeback.delete_chargeback()');
2599 arp_standard.debug ('delete_chargeback: ' || 'ERROR in the program! Dump of parameter values:');
2600 arp_standard.debug ('delete_chargeback: ' || ' p_customer_trx_id = '|| TO_CHAR(p_customer_trx_id));
2601 arp_standard.debug ('delete_chargeback: ' || ' p_gl_date = '|| TO_CHAR(p_gl_date));
2602 arp_standard.debug ('delete_chargeback: ' || ' p_apply_date = '|| TO_CHAR(p_apply_date));
2603 arp_standard.debug ('delete_chargeback: ' || ' p_module_name = '|| p_module_name);
2604 arp_standard.debug ('delete_chargeback: ' || ' p_module_version = '|| p_module_version);
2605 END IF;
2606 RAISE;
2607
2608 END delete_chargeback;
2609
2610 /*===========================================================================+
2611 | PROCEDURE
2612 | create_payment_extension
2613 |
2614 | DESCRIPTION
2615 | This procedure creates payment transaction extension for a chargeback.
2616 |
2617 | SCOPE - PUBLIC
2618 |
2619 | EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
2620 |
2621 | ARGUMENTS : IN:
2622 | OUT:
2623 |
2624 | RETURNS : NONE
2625 |
2626 | NOTES
2627 |
2628 |
2629 | MODIFICATION HISTORY
2630 | 03/08/2012 ABBANSA Created
2631 +===========================================================================*/
2632 PROCEDURE create_payment_extension(p_assignment_id IN NUMBER,
2633 p_customer_id IN NUMBER,
2634 p_receipt_method_id IN NUMBER,
2635 p_org_id IN NUMBER,
2636 p_customer_site_use_id IN NUMBER,
2637 p_chargeback_number IN VARCHAR2,
2638 p_customer_trx_id IN NUMBER,
2639 x_msg_count OUT NOCOPY NUMBER,
2640 x_msg_data OUT NOCOPY VARCHAR2,
2641 x_return_status OUT NOCOPY VARCHAR2,
2642 o_payment_trxn_extension_id OUT NOCOPY NUMBER,
2643 p_chargeback_date IN DATE DEFAULT NULL) IS
2644
2645 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
2646 l_msg_count NUMBER;
2647 l_msg_data VARCHAR2(2000);
2648
2649 l_payer_rec IBY_FNDCPT_COMMON_PUB.PayerContext_rec_type;
2650 l_assignment_id NUMBER;
2651 l_trxn_attribs_rec IBY_FNDCPT_TRXN_PUB.TrxnExtension_rec_type;
2652 l_extension_id NUMBER;
2653 l_init_extension_id NUMBER;
2654 l_result_rec IBY_FNDCPT_COMMON_PUB.Result_rec_type;
2655
2656 l_customer_id ra_customer_trx.paying_customer_id%type;
2657 l_customer_site_use_id ra_customer_trx.paying_site_use_id%type;
2658 l_org_id ra_customer_trx.org_id%type;
2659 l_party_id hz_parties.party_id%type;
2660 l_trx_number ra_customer_trx.trx_number%type;
2661 l_payment_channel_code ar_receipt_methods.payment_channel_code%type;
2662 l_customer_trx_id ra_customer_trx.customer_trx_id%type;
2663
2664 l_start_date DATE;
2665 l_end_date DATE;
2666
2667 BEGIN
2668
2669 arp_standard.debug('arp_process_chargeback.create_payment_extension(+)');
2670 arp_standard.debug('p_assignment_id: ' ||p_assignment_id);
2671 arp_standard.debug('p_customer_id: '|| p_customer_id);
2672 arp_standard.debug('p_receipt_method_id: '|| p_receipt_method_id);
2673 arp_standard.debug('p_org_id: '|| p_org_id);
2674 arp_standard.debug('p_customer_site_use_id: '|| p_customer_site_use_id);
2675 arp_standard.debug('p_chargeback_number: '|| p_chargeback_number);
2676 arp_standard.debug('p_customer_trx_id: '|| p_customer_trx_id);
2677 arp_standard.debug('p_chargeback_date: '|| p_chargeback_date);
2678
2679 l_customer_id := p_customer_id;
2680
2681 SELECT party.party_id
2682 INTO l_party_id
2683 FROM hz_cust_accounts hca, hz_parties party
2684 WHERE hca.party_id = party.party_id
2685 AND hca.cust_account_id = l_customer_id;
2686
2687 arp_standard.debug('l_party_id: '|| l_party_id);
2688
2689 SELECT payment_channel_code
2690 INTO l_payment_channel_code
2691 from ar_receipt_methods
2692 where receipt_method_id = p_receipt_method_id;
2693
2694 arp_standard.debug('l_payment_channel_code: '|| l_payment_channel_code);
2695
2696 /* pouplate values into the variables */
2697
2698 l_payer_rec.Payment_Function := 'CUSTOMER_PAYMENT';
2699 l_payer_rec.Party_Id := l_party_id; -- customer party id mandatory
2700 l_payer_rec.org_id := p_org_id;
2701 l_payer_rec.org_type := 'OPERATING_UNIT';
2702 l_payer_rec.Cust_Account_Id := p_customer_id; -- paying customer account_id
2703 l_payer_rec.Account_Site_Id := p_customer_site_use_id; --paying customer site use id
2704
2705 if p_customer_site_use_id is NULL THEN
2706
2707 l_payer_rec.org_id := NULL;
2708 l_payer_rec.org_type := NULL;
2709
2710 end if;
2711 l_trxn_attribs_rec.Originating_Application_Id := arp_standard.application_id;
2712 l_trxn_attribs_rec.order_id := p_chargeback_number;
2713 l_trxn_attribs_rec.Trxn_Ref_Number1 := 'TRANSACTION';
2714 l_trxn_attribs_rec.Trxn_Ref_Number2 := p_customer_trx_id;
2715 l_assignment_id := p_assignment_id;
2716
2717 IBY_FNDCPT_TRXN_PUB.Create_Transaction_Extension(p_api_version => 1.0,
2718 p_init_msg_list => FND_API.G_TRUE,
2719 p_commit => FND_API.G_FALSE,
2720 x_return_status => l_return_status,
2721 x_msg_count => l_msg_count,
2722 x_msg_data => l_msg_data,
2723 p_payer => l_payer_rec,
2724 p_payer_equivalency => IBY_FNDCPT_COMMON_PUB.G_PAYER_EQUIV_UPWARD,
2725 p_pmt_channel => l_payment_channel_code,
2726 p_instr_assignment => l_assignment_id,
2727 p_trxn_attribs => l_trxn_attribs_rec,
2728 x_entity_id => l_extension_id,
2729 x_response => l_result_rec);
2730
2731 IF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
2732
2733 o_payment_trxn_extension_id := l_extension_id;
2734 arp_standard.debug('Payment Transaction Extension Id: '|| o_payment_trxn_extension_id);
2735
2736 arp_standard.debug(to_char(SQL%ROWCOUNT) ||
2737 'PMT_EXTN_ID row(s) updated.');
2738
2739 END IF;
2740
2741 FOR i IN 1 .. l_msg_count LOOP
2742 arp_standard.debug('x_msg #' || TO_CHAR(i) || ' = <' ||
2743 SUBSTR(fnd_msg_pub.get(p_msg_index => i,
2744 p_encoded => FND_API.G_FALSE),
2745 1,
2746 150) || '>');
2747 END LOOP;
2748
2749 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2750 arp_standard.debug('FAILED: ' || l_result_rec.result_code);
2751 arp_standard.debug('PARM-l_payer_rec.Payment_Function ' ||
2752 l_payer_rec.Payment_Function);
2753 arp_standard.debug('PARM-l_payer_rec.party_id ' ||
2754 l_payer_rec.Party_Id);
2755 arp_standard.debug('PARM-l_payer_rec.org_id ' || l_payer_rec.org_id);
2756 arp_standard.debug('PARM-l_payer_rec.org_type ' ||
2757 l_payer_rec.org_type);
2758 arp_standard.debug('PARM-l_payer_rec.customer_id ' ||
2759 l_payer_rec.Cust_Account_Id);
2760 arp_standard.debug('PARM-l_payer_rec.customer_site_id ' ||
2761 l_payer_rec.Account_Site_Id);
2762 arp_standard.debug('PARM-l_trxn_attribs_rec.Originating_Application_Id ' ||
2763 l_trxn_attribs_rec.Originating_Application_Id);
2764 arp_standard.debug('PARM- l_trxn_attribs_rec.order_id ' ||
2765 l_trxn_attribs_rec.order_id);
2766 arp_standard.debug('PARM-l_trxn_attribs_rec.Trxn_Ref_Number1 ' ||
2767 l_trxn_attribs_rec.Trxn_Ref_Number1);
2768 arp_standard.debug('PARM-l_assignment_id ' || l_assignment_id);
2769
2770 FND_MSG_PUB.Count_And_Get(p_encoded => FND_API.G_FALSE,
2771 p_count => x_msg_count,
2772 p_data => x_msg_data);
2773
2774 x_return_status := l_return_status;
2775 arp_standard.debug('arp_process_chargeback.create_payment_extension(-)');
2776 RETURN;
2777
2778 END IF;
2779
2780 EXCEPTION
2781 WHEN OTHERS THEN
2782 arp_standard.debug('arp_process_chargeback.create_payment_extension - ERROR IN CREATION ');
2783 RAISE;
2784 END Create_payment_extension;
2785
2786
2787 END ARP_PROCESS_CHARGEBACK;