[Home] [Help]
PACKAGE BODY: APPS.ARP_PROCESS_SALESCREDIT
Source
1 PACKAGE BODY ARP_PROCESS_SALESCREDIT AS
2 /* $Header: ARTETLSB.pls 120.9 2005/09/06 20:18:02 mraymond arrt008.sql $ */
3 PG_DEBUG varchar2(1) := NVL(FND_PROFILE.value('AFLOG_ENABLED'), 'N');
4
5 pg_number_dummy number;
6
7 /* Bug 3607146 */
8 pg_base_precision fnd_currencies.precision%type;
9 pg_base_min_acc_unit fnd_currencies.minimum_accountable_unit%type;
10 pg_trx_header_level_rounding ar_system_parameters.trx_header_level_rounding%type;
11
12 /*===========================================================================+
13 | PROCEDURE |
14 | val_insert_salescredit |
15 | |
16 | DESCRIPTION |
17 | Does validation necessary when a new salescredit is inserted. |
18 | |
19 | SCOPE - PRIVATE |
20 | |
21 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED |
22 | arp_util.debug |
23 | |
24 | ARGUMENTS : IN: |
25 | p_srep_rec |
26 | OUT: |
27 | None |
28 | |
29 | RETURNS : NONE |
30 | |
31 | NOTES |
32 | |
33 | MODIFICATION HISTORY |
34 | 19-JUL-95 Charlie Tomberg Created |
35 | |
36 +===========================================================================*/
37
38
39 PROCEDURE val_insert_salescredit ( p_srep_rec IN
40 ra_cust_trx_line_salesreps%rowtype ) IS
41
42
43 BEGIN
44
45 arp_util.debug('arp_process_salescredit.val_insert_salescredit()+');
46
47
48 arp_util.debug('arp_process_salescredit.val_val_insert_salescredit()-');
49
50 EXCEPTION
51 WHEN OTHERS THEN
52
53 /*---------------------------------------------+
54 | Display parameters and raise the exception |
55 +---------------------------------------------*/
56
57 arp_util.debug(
58 'EXCEPTION: arp_process_salescredit.val_insert_salescredit()');
59
60 arp_util.debug('');
61 arp_util.debug('---------- val_insert_salescredit() ---------');
62 arp_util.debug('');
63 arp_ctls_pkg.display_salescredit_rec(p_srep_rec);
64
65 RAISE;
66
67 END;
68
69 /*===========================================================================+
70 | PROCEDURE |
71 | val_update_salescredit |
72 | |
73 | DESCRIPTION |
74 | Does validation that is required when a salescredit is updated. |
75 | |
76 | SCOPE - PRIVATE |
77 | |
78 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED |
79 | arp_util.debug |
80 | |
81 | ARGUMENTS : IN: |
82 | p_srep_rec |
83 | OUT: |
84 | None |
85 | |
86 | RETURNS : NONE |
87 | |
88 | NOTES |
89 | |
90 | MODIFICATION HISTORY |
91 | 19-JUL-95 Charlie Tomberg Created |
92 | |
93 +===========================================================================*/
94
95 PROCEDURE val_update_salescredit ( p_srep_rec IN
96 ra_cust_trx_line_salesreps%rowtype ) IS
97
98
99 BEGIN
100
101 arp_util.debug('arp_process_salescredit.val_update_salescredit()+');
102
103
104 arp_util.debug('arp_process_salescredit.val_val_update_salescredit()-');
105
106 EXCEPTION
107 WHEN OTHERS THEN
108
109 /*---------------------------------------------+
110 | Display parameters and raise the exception |
111 +---------------------------------------------*/
112
113 arp_util.debug(
114 'EXCEPTION: arp_process_salescredit.val_update_salescredit()');
115
116
117 arp_util.debug('');
118 arp_util.debug('---------- val_update_salescredit() ---------');
119 arp_util.debug('');
120 arp_ctls_pkg.display_salescredit_rec(p_srep_rec);
121
122 RAISE;
123
124 END;
125
126 /*===========================================================================+
127 | PROCEDURE |
128 | val_delete_salescredit |
129 | |
130 | DESCRIPTION |
131 | Does validation that is required when a salescredit is deleted. |
132 | |
133 | SCOPE - PRIVATE |
134 | |
135 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED |
136 | arp_util.debug |
137 | |
138 | ARGUMENTS : IN: |
139 | p_srep_rec |
140 | OUT: |
141 | None |
142 | |
143 | RETURNS : NONE |
144 | |
145 | NOTES |
146 | |
147 | MODIFICATION HISTORY |
148 | 19-JUL-95 Charlie Tomberg Created |
149 | |
150 +===========================================================================*/
151
152 PROCEDURE val_delete_salescredit ( p_srep_rec IN
153 ra_cust_trx_line_salesreps%rowtype ) IS
154
155
156 BEGIN
157
158 arp_util.debug('arp_process_salescredit.val_delete_salescredit()+');
159
160
161 arp_util.debug('arp_process_salescredit.val_delete_salescredit()-');
162
163 EXCEPTION
164 WHEN OTHERS THEN
165
166 /*---------------------------------------------+
167 | Display parameters and raise the exception |
168 +---------------------------------------------*/
169
170 arp_util.debug(
171 'EXCEPTION: arp_process_salescredit.val_delete_salescredit()');
172
173
174 arp_util.debug('');
175 arp_util.debug('---------- val_update_salescredit() ---------');
176 arp_util.debug('');
177 arp_ctls_pkg.display_salescredit_rec(p_srep_rec);
178
179 RAISE;
180
181 END;
182
183 /*===========================================================================+
184 | PROCEDURE |
185 | set_flags |
186 | |
187 | DESCRIPTION |
188 | Sets various change and status flags for the current record. |
189 | |
190 | SCOPE - PRIVATE |
191 | |
192 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED |
193 | arp_util.debug |
194 | |
195 | ARGUMENTS : IN: |
196 | p_cust_trx_line_salesrep_id |
197 | p_new_srep_rec |
198 | p_backout_flag |
199 | p_delete_flag |
200 | OUT: |
201 | p_posted_flag |
202 | p_salesrep_changed_flag |
203 | p_amount_percent_changed_flag |
204 | p_rev_amt_percent_changed_flag |
205 | p_default_record_flag |
206 | p_revised_backout_flag |
207 | IN/ OUT: |
208 | None |
209 | |
210 | RETURNS : NONE |
211 | |
212 | NOTES |
213 | |
214 | MODIFICATION HISTORY |
215 | 17-JUL-95 Charlie Tomberg Created |
216 | |
217 +===========================================================================*/
218
219 PROCEDURE set_flags(p_cust_trx_line_salesrep_id IN
220 ra_cust_trx_line_salesreps.cust_trx_line_salesrep_id%type,
221 p_new_srep_rec IN ra_cust_trx_line_salesreps%rowtype,
222 p_backout_flag IN boolean,
223 p_delete_flag IN boolean,
224 p_posted_flag OUT NOCOPY boolean,
225 p_salesrep_changed_flag OUT NOCOPY boolean,
226 p_amount_percent_changed_flag OUT NOCOPY boolean,
227 p_rev_amt_percent_changed_flag OUT NOCOPY boolean,
228 p_default_record_flag OUT NOCOPY boolean,
229 p_revised_backout_flag OUT NOCOPY boolean) IS
230
231 l_old_srep_rec ra_cust_trx_line_salesreps%rowtype;
232 l_posted_flag boolean;
233 l_salesrep_changed_flag boolean;
234 l_amount_percent_changed_flag boolean;
235 l_rev_amt_percent_changed_flag boolean;
236 l_default_record_flag boolean;
237 l_revised_backout_flag boolean;
238
239 BEGIN
240
241 arp_util.debug('arp_process_salescredit.set_flags()+');
242
243 arp_ctls_pkg.fetch_p(l_old_srep_rec,
244 p_cust_trx_line_salesrep_id);
245
246 IF (l_old_srep_rec.customer_trx_line_id IS NULL )
247 THEN l_default_record_flag := TRUE;
248 ELSE l_default_record_flag := FALSE;
249 END IF;
250
251 IF (
252 l_old_srep_rec.salesrep_id <> p_new_srep_rec.salesrep_id AND
253 p_new_srep_rec.salesrep_id <> pg_number_dummy
254 )
255 THEN l_salesrep_changed_flag := TRUE;
256 ELSE l_salesrep_changed_flag := FALSE;
257 END IF;
258
259 IF (
260 (
261 nvl(l_old_srep_rec.revenue_amount_split, 0) <>
262 nvl(p_new_srep_rec.revenue_amount_split, 0) AND
263 p_new_srep_rec.revenue_amount_split <> pg_number_dummy
264 ) OR
265 (
266 nvl(l_old_srep_rec.revenue_percent_split, 0) <>
267 nvl(p_new_srep_rec.revenue_percent_split, 0) AND
268 p_new_srep_rec.revenue_percent_split <> pg_number_dummy
269 ) OR
270 (
271 nvl(l_old_srep_rec.non_revenue_amount_split, 0) <>
272 nvl(p_new_srep_rec.non_revenue_amount_split, 0) AND
273 p_new_srep_rec.non_revenue_amount_split <> pg_number_dummy
274 ) OR
275 (
276 nvl(l_old_srep_rec.non_revenue_percent_split, 0) <>
277 nvl(p_new_srep_rec.non_revenue_percent_split, 0) AND
278 p_new_srep_rec.non_revenue_percent_split <> pg_number_dummy
279 )
280 )
281 THEN l_amount_percent_changed_flag := TRUE;
282 ELSE l_amount_percent_changed_flag := FALSE;
283 END IF;
284
285 IF (
286 (
287 nvl(l_old_srep_rec.revenue_amount_split, 0) <>
288 nvl(p_new_srep_rec.revenue_amount_split, 0) AND
289 p_new_srep_rec.revenue_amount_split <> pg_number_dummy
290 ) OR
291 (
292 nvl(l_old_srep_rec.revenue_percent_split, 0) <>
293 nvl(p_new_srep_rec.revenue_percent_split, 0) AND
294 p_new_srep_rec.revenue_percent_split <> pg_number_dummy
295 )
296 )
297 THEN l_rev_amt_percent_changed_flag := TRUE;
298 ELSE l_rev_amt_percent_changed_flag := FALSE;
299 END IF;
300
301 arp_trx_util.set_posted_flag(l_old_srep_rec.customer_trx_id,
302 l_posted_flag);
303
304 /*------------------------------------------------------------------+
305 | Set the backout flag to true if the transaction has been posted |
306 | and the amounts or the salesrep name has changed. |
307 +------------------------------------------------------------------*/
308
309 IF ( l_posted_flag = TRUE AND
310 l_default_record_flag = FALSE AND
311 (
312 l_salesrep_changed_flag = TRUE OR
313 l_amount_percent_changed_flag = TRUE OR
314 p_delete_flag = TRUE
315 )
316 )
317 THEN l_revised_backout_flag := TRUE;
318 arp_util.debug('revised backout flag: TRUE');
319 ELSE
320 IF ( l_default_record_flag = FALSE )
321 THEN l_revised_backout_flag := p_backout_flag;
322 ELSE l_revised_backout_flag := FALSE;
323 END IF;
324
325 arp_util.debug('revised backout flag: ' ||
326 arp_trx_util.boolean_to_varchar2(l_revised_backout_flag ));
327
328 END IF;
329
330
331 p_posted_flag := l_posted_flag;
332 p_salesrep_changed_flag := l_salesrep_changed_flag;
333 p_amount_percent_changed_flag := l_amount_percent_changed_flag;
334 p_rev_amt_percent_changed_flag := l_rev_amt_percent_changed_flag;
335 p_default_record_flag := l_default_record_flag;
336 p_revised_backout_flag := l_revised_backout_flag;
337
338 arp_util.debug('p_posted_flag = ' ||
339 arp_trx_util.boolean_to_varchar2(l_posted_flag));
340
341 arp_util.debug('p_salesrep_changed_flag = ' ||
342 arp_trx_util.boolean_to_varchar2( l_salesrep_changed_flag));
343
344 arp_util.debug('p_amount_percent_changed_flag = ' ||
345 arp_trx_util.boolean_to_varchar2(
346 l_amount_percent_changed_flag));
347
348 arp_util.debug('p_rev_amt_percent_changed_flag = ' ||
349 arp_trx_util.boolean_to_varchar2(
350 l_rev_amt_percent_changed_flag));
351
352 arp_util.debug('p_default_record_flag = ' ||
353 arp_trx_util.boolean_to_varchar2(
354 l_default_record_flag));
355
356 arp_util.debug('p_revised_backout_flag = ' ||
357 arp_trx_util.boolean_to_varchar2(
358 l_revised_backout_flag));
359
360 arp_util.debug('arp_process_salescredit.set_flags()-');
361
362 EXCEPTION
363 WHEN OTHERS THEN
364
365 /*---------------------------------------------+
366 | Display parameters and raise the exception |
367 +---------------------------------------------*/
368
369 arp_util.debug('EXCEPTION: arp_process_salescredit.set_flags()');
370
371 arp_util.debug('');
372 arp_util.debug('---------- parameters for set_flags() ---------');
373
374 arp_util.debug('p_cust_trx_line_salesrep_id = ' ||
375 p_cust_trx_line_salesrep_id);
376
377 arp_util.debug('p_backout_flag = ' ||
378 arp_trx_util.boolean_to_varchar2(p_backout_flag));
379
380 arp_util.debug('p_delete_flag = ' ||
381 arp_trx_util.boolean_to_varchar2(p_delete_flag));
382
383 arp_util.debug('');
384
385 arp_util.debug('---------- new salescredit record ----------');
386 arp_ctls_pkg.display_salescredit_rec( p_new_srep_rec );
387 arp_util.debug('');
388
389 RAISE;
390
391 END;
392
393 /*===========================================================================+
394 | PROCEDURE |
395 | run_autoacc_for_scredits |
396 | |
397 | DESCRIPTION |
398 | Sets various change and status flags for the current record. |
399 | |
400 | SCOPE - PRIVATE |
401 | |
402 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED |
403 | arp_util.debug |
404 | |
405 | ARGUMENTS : IN: |
406 | p_customer_trx_id |
407 | p_customer_trx_line_id |
408 | p_cust_trx_line_salesrep_id |
409 | OUT: |
410 | p_status |
411 | IN/ OUT: |
412 | None |
413 | |
414 | RETURNS : NONE |
415 | |
416 | NOTES |
417 | |
418 | MODIFICATION HISTORY |
419 | 02-OCT-95 Charlie Tomberg Created |
420 | |
421 +===========================================================================*/
422
423 PROCEDURE run_autoacc_for_scredits( p_customer_trx_id IN
424 ra_customer_trx.customer_trx_id%type,
425 p_customer_trx_line_id IN
426 ra_customer_trx_lines.customer_trx_line_id%type,
427 p_cust_trx_line_salesrep_id IN
428 ra_cust_trx_line_salesreps.cust_trx_line_salesrep_id%type
429 DEFAULT NULL,
430 p_status OUT NOCOPY varchar2 ) IS
431
432 l_concat_segments ra_cust_trx_line_gl_dist.concatenated_segments%type;
433 l_ccid ra_cust_trx_line_gl_dist.code_combination_id%type;
434 l_result number;
435 l_num_failed_dist_rows number;
436 l_errorbuf varchar2(200);
437
438 /* bug 3607146 */
439 l_error_message VARCHAR2(128) := '';
440 l_dist_count NUMBER;
441
442 BEGIN
443
444 arp_util.debug('arp_process_salescredit.run_autoacc_for_scredits()+');
445
446 arp_util.debug('p_customer_trx_id = ' ||
447 to_char( p_customer_trx_id ));
448 arp_util.debug('p_customer_trx_line_id = ' ||
449 to_char( p_customer_trx_line_id ));
450 arp_util.debug('p_cust_trx_line_salesrep_id = ' ||
451 to_char( p_cust_trx_line_salesrep_id ));
452
453 BEGIN
454
455 p_status := 'OK';
456
457 arp_auto_accounting.do_autoaccounting
458 (
459 'U',
460 'REV',
461 p_customer_trx_id,
462 p_customer_trx_line_id,
463 p_cust_trx_line_salesrep_id,
464 null,
465 null,
466 null,
467 null,
468 null,
469 null,
470 null,
471 null,
472 null,
473 null,
474 l_ccid,
475 l_concat_segments,
476 l_num_failed_dist_rows
477 );
478 EXCEPTION
479 WHEN arp_auto_accounting.no_ccid THEN
480 p_status := 'ARP_AUTO_ACCOUNTING.NO_CCID';
481
482 WHEN NO_DATA_FOUND THEN
483 null;
484 WHEN OTHERS THEN
485 RAISE;
486 END;
487
488
489 BEGIN
490 arp_auto_accounting.do_autoaccounting
491 (
492 'U',
493 'CHARGES',
494 p_customer_trx_id,
495 p_customer_trx_line_id,
496 p_cust_trx_line_salesrep_id,
497 null,
498 null,
499 null,
500 null,
501 null,
502 null,
503 null,
504 null,
505 null,
506 null,
507 l_ccid,
508 l_concat_segments,
509 l_num_failed_dist_rows
510 );
511 EXCEPTION
512 WHEN arp_auto_accounting.no_ccid THEN
513 p_status := 'ARP_AUTO_ACCOUNTING.NO_CCID';
514
515 WHEN NO_DATA_FOUND THEN
516 null;
517 WHEN OTHERS THEN
518 RAISE;
519 END;
520
521
522 BEGIN
523 arp_auto_accounting.do_autoaccounting
524 (
525 'U',
526 'UNBILL',
527 p_customer_trx_id,
528 p_customer_trx_line_id,
529 p_cust_trx_line_salesrep_id,
530 null,
531 null,
532 null,
533 null,
534 null,
535 null,
536 null,
537 null,
538 null,
539 null,
540 l_ccid,
541 l_concat_segments,
542 l_num_failed_dist_rows
543 );
544 EXCEPTION
545 WHEN arp_auto_accounting.no_ccid THEN
546 p_status := 'ARP_AUTO_ACCOUNTING.NO_CCID';
547
548 WHEN NO_DATA_FOUND THEN
549 null;
550 WHEN OTHERS THEN
551 RAISE;
552 END;
553
554
555 BEGIN
556 arp_auto_accounting.do_autoaccounting
557 (
558 'U',
559 'UNEARN',
560 p_customer_trx_id,
561 p_customer_trx_line_id,
562 p_cust_trx_line_salesrep_id,
563 null,
564 null,
565 null,
566 null,
567 null,
568 null,
569 null,
570 null,
571 null,
572 null,
573 l_ccid,
574 l_concat_segments,
575 l_num_failed_dist_rows
576 );
577 EXCEPTION
578 WHEN arp_auto_accounting.no_ccid THEN
579 p_status := 'ARP_AUTO_ACCOUNTING.NO_CCID';
580
581 WHEN NO_DATA_FOUND THEN
582 null;
583 WHEN OTHERS THEN
584 RAISE;
585 END;
586
587
588 BEGIN
589 arp_auto_accounting.do_autoaccounting
590 (
591 'U',
592 'SUSPENSE',
593 p_customer_trx_id,
594 p_customer_trx_line_id,
595 p_cust_trx_line_salesrep_id,
596 null,
597 null,
598 null,
599 null,
600 null,
601 null,
602 null,
603 null,
604 null,
605 null,
606 l_ccid,
607 l_concat_segments,
608 l_num_failed_dist_rows
609 );
610 EXCEPTION
611 WHEN arp_auto_accounting.no_ccid THEN
612 p_status := 'ARP_AUTO_ACCOUNTING.NO_CCID';
613
614 WHEN NO_DATA_FOUND THEN
615 null;
616 WHEN OTHERS THEN
617 RAISE;
618 END;
619
620
621 BEGIN
622 arp_auto_accounting.do_autoaccounting
623 (
624 'U',
625 'TAX',
626 p_customer_trx_id,
627 p_customer_trx_line_id,
628 p_cust_trx_line_salesrep_id,
629 null,
630 null,
631 null,
632 null,
633 null,
634 null,
635 null,
636 null,
637 null,
638 null,
639 l_ccid,
640 l_concat_segments,
641 l_num_failed_dist_rows
642 );
643 EXCEPTION
644 WHEN arp_auto_accounting.no_ccid THEN
645 p_status := 'ARP_AUTO_ACCOUNTING.NO_CCID';
646
647 WHEN NO_DATA_FOUND THEN
648 null;
649 WHEN OTHERS THEN
650 RAISE;
651 END;
652
653
654 /*----------------------------------+
655 | Raise AutoAccounting exception |
656 +----------------------------------*/
657
658 IF (l_errorbuf is not null)
659 THEN arp_util.debug('AutoAccounting error: ' || l_errorbuf);
660
661 FND_MESSAGE.set_name('AR', 'GENERIC_MESSAGE');
662 FND_MESSAGE.set_token( 'GENERIC_TEXT', l_errorbuf);
663 APP_EXCEPTION.raise_exception;
664
665 END IF;
666
667 /* bug 3607146 */
668 IF arp_rounding.correct_dist_rounding_errors(
669 NULL,
670 p_customer_trx_id,
671 p_customer_trx_line_id ,
672 l_dist_count,
673 l_error_message ,
674 pg_base_precision ,
675 pg_base_min_acc_unit ,
676 'ALL' ,
677 'N' ,
678 'N' ,
679 pg_trx_header_level_rounding ,
680 'N',
681 'N') = 0 -- FALSE
682 THEN
683 arp_util.debug('EXCEPTION: arp_process_salescredit.run_autoacc_for_scredits');
684 arp_util.debug(l_error_message);
685 fnd_message.set_name('AR', 'AR_PLCRE_FHLR_CCID');
686 APP_EXCEPTION.raise_exception;
687 END IF;
688
689 arp_util.debug('arp_process_salescredit.run_autoacc_for_scredits()-');
690
691 EXCEPTION
692 WHEN OTHERS THEN
693
694 /*---------------------------------------------+
695 | Display parameters and raise the exception |
696 +---------------------------------------------*/
697
698 arp_util.debug(
699 'EXCEPTION: arp_process_salescredit.run_autoacc_for_scredits');
700
701 IF (l_errorbuf is not null)
702 THEN arp_util.debug('AutoAccounting error: ' || l_errorbuf);
703 END IF;
704
705 arp_util.debug('');
706 arp_util.debug('---------- parameters for run_autoacc_for_scredits () ' ||
707 '---------');
708
709 arp_util.debug('p_customer_trx_id = ' || TO_CHAR( p_customer_trx_id));
710 arp_util.debug('p_customer_trx_line_id = ' ||
711 TO_CHAR( p_customer_trx_line_id));
712 arp_util.debug('p_cust_trx_line_salesrep_id = ' ||
713 TO_CHAR( p_cust_trx_line_salesrep_id));
714
715 RAISE;
716
717 END;
718
719
720 /*===========================================================================+
721 | PROCEDURE |
722 | backout_salesrep |
723 | |
724 | DESCRIPTION |
725 | Inserts two records to backout the existing salescredit record. |
726 | This procedure is called if backout is required and the salescredit's |
727 | salesrep name or number has changed. |
728 | |
729 | SCOPE - PRIVATE |
730 | |
731 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED |
732 | arp_util.debug |
733 | |
734 | ARGUMENTS : IN: |
735 | p_old_srep_rec |
736 | p_new_srep_rec |
737 | p_run_auto_accounting_flag |
738 | OUT: |
739 | p_status |
740 | IN/ OUT: |
741 | None |
742 | |
743 | RETURNS : NONE |
744 | |
745 | NOTES |
746 | |
747 | MODIFICATION HISTORY |
748 | 12-JUL-95 Charlie Tomberg Created |
749 | |
750 +===========================================================================*/
751
752 PROCEDURE backout_salesrep(
753 p_old_srep_rec IN ra_cust_trx_line_salesreps%rowtype,
754 p_new_srep_rec IN ra_cust_trx_line_salesreps%rowtype,
755 p_run_auto_accounting_flag IN boolean,
756 p_status OUT NOCOPY varchar2 )
757 IS
758
759 l_cust_trx_line_salesrep_id
760 ra_cust_trx_line_salesreps.cust_trx_line_salesrep_id%type;
761
762 l_old_srep_rec ra_cust_trx_line_salesreps%rowtype;
763 l_new_srep_rec ra_cust_trx_line_salesreps%rowtype;
764
765 l_status1 varchar2(100);
766 l_status2 varchar2(100);
767
768 BEGIN
769
770 arp_util.debug('arp_process_salescredit.backout_salesrep()+');
771
772 l_old_srep_rec := p_old_srep_rec;
773 l_new_srep_rec := p_new_srep_rec;
774
775
776 /*--------------------------+
777 | insert the new row |
778 +--------------------------*/
779
780
781 /*---------------------------------------------------------------+
782 | If a new value was specified in the srep rec passed into |
783 | update_salescredit(). use that value. Otherwise, use the |
784 | value from the original salescredit line. |
785 +---------------------------------------------------------------*/
786
787 arp_ctls_pkg.merge_srep_recs(l_old_srep_rec,
788 l_new_srep_rec,
789 l_new_srep_rec);
790
791 /*-------------------------------------------------------------+
792 | Call the table handler to insert the new salesrep record |
793 +-------------------------------------------------------------*/
794
795 arp_ctls_pkg.insert_p( l_new_srep_rec,
796 l_cust_trx_line_salesrep_id);
797
798 IF ( p_run_auto_accounting_flag = TRUE )
799 THEN
800 run_autoacc_for_scredits( l_new_srep_rec.customer_trx_id,
801 l_new_srep_rec.customer_trx_line_id,
802 l_cust_trx_line_salesrep_id,
803 l_status1 );
804 END IF;
805
806 /*--------------------------------------------+
807 | backout the original salescredit row |
808 +--------------------------------------------*/
809
810 l_old_srep_rec.revenue_amount_split :=
811 -1 * l_old_srep_rec.revenue_amount_split;
812
813 l_old_srep_rec.revenue_percent_split :=
814 -1 * l_old_srep_rec.revenue_percent_split;
815
816 l_old_srep_rec.non_revenue_amount_split :=
817 -1 * l_old_srep_rec.non_revenue_amount_split;
818
819 l_old_srep_rec.non_revenue_percent_split :=
820 -1 * l_old_srep_rec.non_revenue_percent_split;
821
822 arp_ctls_pkg.insert_p( l_old_srep_rec,
823 l_cust_trx_line_salesrep_id);
824
825 IF ( p_run_auto_accounting_flag = TRUE )
826 THEN
827 run_autoacc_for_scredits( l_new_srep_rec.customer_trx_id,
828 l_new_srep_rec.customer_trx_line_id,
829 l_cust_trx_line_salesrep_id,
830 l_status2 );
831 END IF;
832
833 arp_util.debug('l_status1 = ' || l_status1);
834 arp_util.debug('l_status2 = ' || l_status2);
835
836 IF ( NVL(l_status1, 'OK') <> 'OK')
837 THEN p_status := l_status1;
838 ELSE IF ( NVL(l_status2, 'OK') <> 'OK' )
839 THEN p_status := l_status2;
840 ELSE p_status := 'OK';
841 END IF;
842 END IF;
843
844 arp_util.debug('arp_process_salescredit.backout_salesrep()-');
845
846 EXCEPTION
847 WHEN OTHERS THEN
848 arp_util.debug('EXCEPTION: arp_process_salescredit.backout_salesrep()');
849 RAISE;
850
851 END;
852
853 /*===========================================================================+
854 | PROCEDURE |
855 | backout_amount |
856 | |
857 | DESCRIPTION |
858 | Inserts one record to backout the existing salescredit record. |
859 | This procedure is called if backout is required and the amount or |
860 | percent of a salescredit record has changed. |
861 | |
862 | SCOPE - PRIVATE |
863 | |
864 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED |
865 | arp_util.debug |
866 | |
867 | ARGUMENTS : IN: |
868 | p_old_srep_rec |
869 | p_new_srep_rec |
870 | p_run_auto_accounting_flag |
871 | OUT: |
872 | p_status |
873 | IN/ OUT: |
874 | None |
875 | |
876 | RETURNS : NONE |
877 | |
878 | NOTES |
879 | |
880 | MODIFICATION HISTORY |
881 | 12-JUL-95 Charlie Tomberg Created |
882 | |
883 +===========================================================================*/
884
885
886 PROCEDURE backout_amount(
887 p_old_srep_rec IN ra_cust_trx_line_salesreps%rowtype,
888 p_new_srep_rec IN ra_cust_trx_line_salesreps%rowtype,
889 p_run_auto_accounting_flag IN boolean,
890 p_status OUT NOCOPY varchar2 )
891 IS
892
893 l_cust_trx_line_salesrep_id
894 ra_cust_trx_line_salesreps.cust_trx_line_salesrep_id%type;
895
896 l_old_srep_rec ra_cust_trx_line_salesreps%rowtype;
897 l_new_srep_rec ra_cust_trx_line_salesreps%rowtype;
898
899 BEGIN
900
901 arp_util.debug('arp_process_salescredit.backout_amount()+');
902
903 l_old_srep_rec := p_old_srep_rec;
904 l_new_srep_rec := p_new_srep_rec;
905
906 /*---------------------------------------------------------------+
907 | create an offsetting record to preserve the audit trail |
908 +---------------------------------------------------------------*/
909
910
911 l_new_srep_rec.revenue_amount_split :=
912 l_new_srep_rec.revenue_amount_split -
913 l_old_srep_rec.revenue_amount_split;
914
915 l_new_srep_rec.revenue_percent_split :=
916 l_new_srep_rec.revenue_percent_split -
917 l_old_srep_rec.revenue_percent_split;
918
919 l_new_srep_rec.non_revenue_amount_split :=
920 NVL(l_new_srep_rec.non_revenue_amount_split, 0) -
921 NVL(l_old_srep_rec.non_revenue_amount_split, 0);
922
923 l_new_srep_rec.non_revenue_percent_split :=
924 NVL(l_new_srep_rec.non_revenue_percent_split, 0) -
925 NVL(l_old_srep_rec.non_revenue_percent_split, 0);
926
927
928 /*---------------------------------------------------------------+
929 | If a new value was specified in the srep rec passed into |
930 | update_salescredit(). use that value. Otherwise, use the |
931 | value from the original salescredit line. |
932 +---------------------------------------------------------------*/
933
934 arp_ctls_pkg.merge_srep_recs(l_old_srep_rec,
935 l_new_srep_rec,
936 l_old_srep_rec);
937
938 arp_ctls_pkg.insert_p( l_old_srep_rec,
939 l_cust_trx_line_salesrep_id);
940
941 IF ( p_run_auto_accounting_flag = TRUE )
942 THEN
943 run_autoacc_for_scredits( l_new_srep_rec.customer_trx_id,
944 l_new_srep_rec.customer_trx_line_id,
945 l_cust_trx_line_salesrep_id,
946 p_status );
947 END IF;
948
949 arp_util.debug('arp_process_salescredit.backout_amount()-');
950
951 EXCEPTION
952 WHEN OTHERS THEN
953 arp_util.debug('EXCEPTION: arp_process_salescredit.backout_amount()');
954 RAISE;
955
956 END;
957
958
959 /*===========================================================================+
960 | PROCEDURE |
961 | val_tax_from_revenue |
962 | |
963 | DESCRIPTION |
964 | If Autoaccounting is rerun due to a change in the Sales Credit, |
965 | Validate Revenue Account tax code is used at the Transaction line |
966 | if the system option Enforces tax code from GL for a Completed |
967 | transaction. Validation will be performed during completion for |
968 | incomplete transactions. |
969 | |
970 | Perform this validation if the transaction is set to complete for |
971 | On-Account Credit Memos, Debit Memos and Invoices only. |
972 | |
973 | SCOPE - PRIVATE |
974 | |
975 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED |
976 | arp_util.debug |
977 | arp_process_tax.validate_tax_enforcement |
978 | |
979 | ARGUMENTS : IN: |
980 | p_customer_trx_id |
981 | p_customer_trx_line_id |
982 | p_run_auto_accounting_flag |
983 | OUT: |
984 | p_status |
985 | |
986 | RETURNS : NONE |
987 | |
988 | NOTES |
989 | |
990 | MODIFICATION HISTORY |
991 | 02-Oct-97 Mahesh Sabapathy Created |
992 | 06-SEP-05 M Raymond Obsolete by etax.
993 +===========================================================================*/
994
995
996 PROCEDURE val_tax_from_revenue (
997 p_customer_trx_id IN ra_customer_trx.customer_trx_id%type,
998 p_customer_trx_line_id IN ra_customer_trx_lines.customer_trx_line_id%type,
999 p_run_auto_accounting_flag IN BOOLEAN,
1000 p_status OUT NOCOPY VARCHAR2 ) IS
1001
1002 BEGIN
1003
1004 IF PG_DEBUG in ('Y', 'C') THEN
1005 arp_util.debug('arp_process_salescredit.val_tax_from_revenue()+');
1006 END IF;
1007
1008 p_status := 'OK';
1009
1010 IF PG_DEBUG in ('Y', 'C') THEN
1011 arp_util.debug('arp_process_salescredit.val_tax_from_revenue()-');
1012 END IF;
1013
1014 END val_tax_from_revenue;
1015
1016 /*===========================================================================+
1017 | PROCEDURE |
1018 | insert_salescredit |
1019 | |
1020 | DESCRIPTION |
1021 | Inserts a record into ra_cust_trx_line_salesreps |
1022 | |
1023 | SCOPE - PUBLIC |
1024 | |
1025 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED |
1026 | arp_util.debug |
1027 | |
1028 | ARGUMENTS : IN: |
1029 | p_form_name |
1030 | p_form_version |
1031 | p_run_auto_accounting_flag |
1032 | p_srep_rec |
1033 | p_cust_trx_line_salesrep_id |
1034 | OUT: |
1035 | p_status |
1036 | IN/ OUT: |
1037 | None |
1038 | |
1039 | RETURNS : NONE |
1040 | |
1041 | NOTES |
1042 | |
1043 | MODIFICATION HISTORY |
1044 | 12-JUL-95 Charlie Tomberg Created |
1045 | |
1046 +===========================================================================*/
1047
1048
1049 PROCEDURE insert_salescredit(
1050 p_form_name IN varchar2,
1051 p_form_version IN number,
1052 p_run_auto_accounting_flag IN boolean,
1053 p_srep_rec IN ra_cust_trx_line_salesreps%rowtype,
1054 p_cust_trx_line_salesrep_id OUT NOCOPY
1055 ra_cust_trx_line_salesreps.cust_trx_line_salesrep_id%type,
1056 p_status OUT NOCOPY varchar2)
1057 IS
1058
1059
1060 l_cust_trx_line_salesrep_id
1061 ra_cust_trx_line_salesreps.cust_trx_line_salesrep_id%type;
1062 l_status1 VARCHAR2(100);
1063 l_status2 VARCHAR2(100);
1064
1065 BEGIN
1066
1067 arp_util.debug('arp_process_salescredit.insert_salescredit()+');
1068
1069 /*----------------------------------------------+
1070 | Check the form version to determine if it |
1071 | is compatible with the entity handler. |
1072 +----------------------------------------------*/
1073
1074 arp_trx_validate.ar_entity_version_check(p_form_name, p_form_version);
1075
1076 /*-------------------------+
1077 | Do required validation |
1078 +-------------------------*/
1079
1080 arp_process_salescredit.val_insert_salescredit(p_srep_rec);
1081
1082 /*----------------------------------------------------------------+
1083 | Lock rows in other tables that reference this customer_trx_id |
1084 +----------------------------------------------------------------*/
1085
1086 arp_trx_util.lock_transaction(p_srep_rec.customer_trx_id);
1087
1088
1089 arp_ctls_pkg.insert_p( p_srep_rec,
1090 l_cust_trx_line_salesrep_id);
1091
1092 p_cust_trx_line_salesrep_id := l_cust_trx_line_salesrep_id;
1093
1094
1095 /*----------------------------------------------------------------+
1096 | Rerun AutoAccounting if the p_run_auto_accounting_flag = TRUE |
1097 +----------------------------------------------------------------*/
1098
1099 IF ( p_run_auto_accounting_flag = TRUE )
1100 THEN
1101
1102 run_autoacc_for_scredits( p_srep_rec.customer_trx_id,
1103 p_srep_rec.customer_trx_line_id,
1104 l_cust_trx_line_salesrep_id,
1105 l_status1 );
1106
1107 END IF;
1108
1109
1110 /*----------------------------------------------------------------+
1111 | Validate Tax from Revenue Account if Auto Accounting was rerun |
1112 +----------------------------------------------------------------*/
1113
1114 IF ( p_run_auto_accounting_flag = TRUE ) THEN
1115
1116 val_tax_from_revenue( p_srep_rec.customer_trx_id,
1117 p_srep_rec.customer_trx_line_id,
1118 p_run_auto_accounting_flag,
1119 l_status2 );
1120
1121 END IF;
1122
1123 arp_util.debug('l_status1 = ' || l_status1);
1124 arp_util.debug('l_status2 = ' || l_status2);
1125
1126 IF ( NVL(l_status1, 'OK') <> 'OK' )
1127 THEN p_status := l_status1;
1128 ELSIF ( NVL(l_status2, 'OK') <> 'OK' )
1129 THEN p_status := l_status2;
1130 ELSE p_status := 'OK';
1131 END IF;
1132
1133
1134 arp_util.debug('arp_process_salescredit.insert_salescredit()-');
1135
1136 EXCEPTION
1137 WHEN OTHERS THEN
1138
1139 arp_util.debug('EXCEPTION: arp_process_salescredit.insert_salescredit()');
1140
1141 /*---------------------------------------------+
1142 | Display parameters and raise the exception |
1143 +---------------------------------------------*/
1144
1145 arp_util.debug('EXCEPTION: arp_process_salescredit.insert_salescredit()');
1146
1147 arp_util.debug('');
1148 arp_util.debug('---------- insert_salescredit() ---------');
1149
1150 arp_util.debug('p_form_name = ' || p_form_name);
1151 arp_util.debug('p_form_version = ' || p_form_version);
1152
1153 arp_util.debug('p_run_auto_accounting_flag = ' ||
1154 arp_trx_util.boolean_to_varchar2(p_run_auto_accounting_flag));
1155
1156 arp_util.debug('');
1157 arp_ctls_pkg.display_salescredit_rec( p_srep_rec );
1158 arp_util.debug('');
1159
1160 RAISE;
1161
1162 END;
1163
1164 /*===========================================================================+
1165 | PROCEDURE |
1166 | update_salescredit |
1167 | |
1168 | DESCRIPTION |
1169 | Updates a record in ra_cust_trx_line_salesreps |
1170 | |
1171 | SCOPE - PUBLIC |
1172 | |
1173 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED |
1174 | arp_util.debug |
1175 | |
1176 | ARGUMENTS : IN: |
1177 | p_form_name |
1178 | p_form_version |
1179 | p_run_auto_accounting_flag |
1180 | p_backout_flag |
1181 | p_posted_flag |
1182 | p_salesrep_changed_flag |
1183 | p_amount_percent_changed_flag |
1184 | p_cust_trx_line_salesrep_id |
1185 | p_customer_trx_id |
1186 | p_srep_rec |
1187 | OUT: |
1188 | p_backout_done_flag |
1189 | p_status |
1190 | IN/ OUT: |
1191 | None |
1192 | |
1193 | RETURNS : NONE |
1194 | |
1195 | NOTES |
1196 | |
1197 | MODIFICATION HISTORY |
1198 | 12-JUL-95 Charlie Tomberg Created |
1199 | |
1200 +===========================================================================*/
1201
1202
1203 PROCEDURE update_salescredit(
1204 p_form_name IN varchar2,
1205 p_form_version IN number,
1206 p_run_auto_accounting_flag IN boolean,
1207 p_backout_flag IN boolean,
1208 p_cust_trx_line_salesrep_id IN
1209 ra_cust_trx_line_salesreps.cust_trx_line_salesrep_id%type,
1210 p_customer_trx_id IN
1211 ra_customer_trx.customer_trx_id%type,
1212 p_customer_trx_line_id IN
1213 ra_customer_trx_lines.customer_trx_line_id%type,
1214 p_srep_rec IN ra_cust_trx_line_salesreps%rowtype,
1215 p_backout_done_flag OUT NOCOPY boolean,
1216 p_status OUT NOCOPY varchar2)
1217 IS
1218
1219
1220 l_cust_trx_line_salesrep_id
1221 ra_cust_trx_line_salesreps.cust_trx_line_salesrep_id%type;
1222 l_old_srep_rec ra_cust_trx_line_salesreps%rowtype;
1223 l_dist_rec ra_cust_trx_line_gl_dist%rowtype;
1224 l_backout_flag boolean;
1225
1226 l_posted_flag boolean;
1227 l_salesrep_changed_flag boolean;
1228 l_amount_percent_changed_flag boolean;
1229 l_rev_amt_percent_changed_flag boolean;
1230 l_default_records_flag boolean;
1231 l_status1 varchar2(100);
1232 l_status2 varchar2(100);
1233 l_status3 varchar2(100);
1234 l_status4 varchar2(100);
1235
1236 BEGIN
1237
1238 arp_util.debug('arp_process_salescredit.update_salescredit()+');
1239
1240 /*----------------------------------------------+
1241 | Check the form version to determine if it |
1242 | is compatible with the entity handler. |
1243 +----------------------------------------------*/
1244
1245 arp_trx_validate.ar_entity_version_check(p_form_name, p_form_version);
1246
1247 set_flags(p_cust_trx_line_salesrep_id,
1248 p_srep_rec,
1249 p_backout_flag,
1250 FALSE, -- p_delete_flag
1251 l_posted_flag,
1252 l_salesrep_changed_flag,
1253 l_amount_percent_changed_flag,
1254 l_rev_amt_percent_changed_flag,
1255 l_default_records_flag,
1256 l_backout_flag);
1257
1258 p_backout_done_flag := l_backout_flag;
1259
1260 /*-------------------------+
1261 | Do required validation |
1262 +-------------------------*/
1263
1264 arp_process_salescredit.val_update_salescredit(p_srep_rec);
1265
1266 /*----------------------------------------------------------------+
1267 | Lock rows in other tables that reference this customer_trx_id |
1268 +----------------------------------------------------------------*/
1269
1270 arp_trx_util.lock_transaction(p_customer_trx_id);
1271
1272
1273 /*------------------------------------------------------+
1274 | IF backout is not required |
1275 | THEN do a simple update |
1276 | ELSE IF the salesrep name has changed |
1277 | THEN create two offsetting records |
1278 | ELSE IF the amount or percent has changed |
1279 | THEN create one ofsetting record |
1280 | ELSE do a simple update |
1281 +------------------------------------------------------*/
1282
1283 IF (l_backout_flag = FALSE)
1284 THEN
1285 /*--------------------------------------+
1286 | Do a simple update with no backout. |
1287 +--------------------------------------*/
1288
1289 arp_util.debug('simple update - case 1');
1290 arp_ctls_pkg.update_p( p_srep_rec,
1291 p_cust_trx_line_salesrep_id);
1292
1293 ELSE
1294 arp_ctls_pkg.fetch_p(l_old_srep_rec, p_cust_trx_line_salesrep_id);
1295
1296
1297 IF ( l_salesrep_changed_flag = TRUE)
1298 THEN
1299
1300 /*------------------------------------------------+
1301 | Insert 2 rows into ra_cust_trx_line_salesreps |
1302 | 1. amount = -<db amount>, |
1303 | ccid = <db (old) ccid> |
1304 | 2. amount = <displayed amount>, |
1305 | ccid = <new salesrep> |
1306 +------------------------------------------------*/
1307
1308 backout_salesrep(l_old_srep_rec,
1309 p_srep_rec,
1310 p_run_auto_accounting_flag,
1311 l_status1 );
1312
1313 ELSE IF (l_amount_percent_changed_flag = TRUE)
1314 THEN
1315
1316 /*------------------------------------------------+
1317 | Insert one new row to backout the old amount. |
1318 | amount = <displayed amount> - <db amount> |
1319 +------------------------------------------------*/
1320
1321 backout_amount(l_old_srep_rec,
1322 p_srep_rec,
1323 p_run_auto_accounting_flag,
1324 l_status2 );
1325 ELSE
1326
1327 /*--------------------------------------+
1328 | Do a simple update with no backout. |
1329 | Nothing of consequence has changed. |
1330 +--------------------------------------*/
1331
1332 arp_util.debug('simple update - case 2');
1333
1334 arp_ctls_pkg.update_p(p_srep_rec,
1335 p_cust_trx_line_salesrep_id);
1336 END IF;
1337
1338 END IF;
1339 END IF;
1340
1341
1342 IF (
1343 p_run_auto_accounting_flag = TRUE
1344 AND l_backout_flag = FALSE
1345 )
1346 THEN
1347 /*----------------------------------------------------------------+
1348 | Rerun AutoAccounting if the p_run_auto_accounting_flag = TRUE |
1349 +----------------------------------------------------------------*/
1350
1351 run_autoacc_for_scredits( p_customer_trx_id,
1352 p_customer_trx_line_id,
1353 null,
1354 l_status3 );
1355
1356 ELSE
1357
1358 /*-------------------------------------------------------------------+
1359 | If autoaccounting is based on salesreps, and the user said No to |
1360 | the Rerun AutoAccounting question, then null out NOCOPY the cust_trx_ |
1361 | line_salesrep_id of all distributions that used to be linked to |
1362 | this salesrep line. Do this only if Salesrep name, number, |
1363 | revenue pct, or revenue amount were updated. |
1364 +-------------------------------------------------------------------*/
1365
1366 IF (
1367 (
1368 l_salesrep_changed_flag = TRUE OR
1369 l_rev_amt_percent_changed_flag = TRUE
1370 )
1371 AND l_backout_flag = FALSE
1372 )
1373 THEN
1374
1375 arp_ctls_pkg.erase_foreign_key_references(
1376 p_cust_trx_line_salesrep_id,
1377 NULL,
1378 NULL);
1379 END IF;
1380
1381 END IF;
1382
1383
1384 /*----------------------------------------------------------------+
1385 | Validate Tax from Revenue Account if Auto Accounting was rerun |
1386 +----------------------------------------------------------------*/
1387
1388 IF ( p_run_auto_accounting_flag = TRUE ) THEN
1389
1390 val_tax_from_revenue( p_customer_trx_id,
1391 p_customer_trx_line_id,
1392 p_run_auto_accounting_flag,
1393 l_status4 );
1394
1395 END IF;
1396
1397
1398 arp_util.debug('l_status1 = ' || l_status1);
1399 arp_util.debug('l_status2 = ' || l_status2);
1400 arp_util.debug('l_status3 = ' || l_status3);
1401 arp_util.debug('l_status4 = ' || l_status4);
1402
1403 IF ( NVL(l_status1, 'OK') <> 'OK' )
1404 THEN p_status := l_status1;
1405 ELSIF ( NVL(l_status2, 'OK') <> 'OK' )
1406 THEN p_status := l_status2;
1407 ELSIF ( NVL(l_status3, 'OK') <> 'OK' )
1408 THEN p_status := l_status3;
1409 ELSIF ( NVL(l_status4, 'OK') <> 'OK' )
1410 THEN p_status := l_status4;
1411 ELSE p_status := 'OK';
1412 END IF;
1413
1414 arp_util.debug('arp_process_salescredit.update_salescredit()-');
1415
1416 EXCEPTION
1417 WHEN OTHERS THEN
1418
1419
1420 /*---------------------------------------------+
1421 | Display parameters and raise the exception |
1422 +---------------------------------------------*/
1423
1424 arp_util.debug('EXCEPTION: arp_process_salescredit.update_salescredit()');
1425 arp_util.debug('');
1426 arp_util.debug('---------- parameters for update_salescredit() ---------');
1427 arp_util.debug('p_form_name = ' || p_form_name);
1428 arp_util.debug('p_form_version = ' || p_form_version);
1429
1430
1431 arp_util.debug('p_run_auto_accounting_flag = ' ||
1432 arp_trx_util.boolean_to_varchar2(p_run_auto_accounting_flag));
1433
1434 arp_util.debug('p_backout_flag = ' ||
1435 arp_trx_util.boolean_to_varchar2(p_backout_flag));
1436
1437 arp_util.debug('p_cust_trx_line_salesrep_id = ' ||
1438 p_cust_trx_line_salesrep_id);
1439 arp_util.debug('p_customer_trx_id = ' || p_customer_trx_id);
1440 arp_util.debug('p_customer_trx_line_id = ' || p_customer_trx_line_id);
1441
1442 arp_util.debug('');
1443 arp_ctls_pkg.display_salescredit_rec( p_srep_rec );
1444 arp_util.debug('');
1445
1446 RAISE;
1447
1448 END;
1449
1450 /*===========================================================================+
1451 | PROCEDURE |
1452 | delete_salescredit |
1453 | |
1454 | DESCRIPTION |
1455 | Deletes a record from ra_cust_trx_line_salesreps. |
1456 | |
1457 | SCOPE - PUBLIC |
1458 | |
1459 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED |
1460 | arp_util.debug |
1461 | |
1462 | ARGUMENTS : IN: |
1463 | p_form_name |
1464 | p_form_version |
1465 | p_run_auto_accounting_flag |
1466 | p_cust_trx_line_salesrep_id |
1467 | p_srep_rec |
1468 | p_backout_flag |
1469 | OUT: |
1470 | p_status |
1471 | IN/ OUT: |
1472 | None |
1473 | |
1474 | RETURNS : NONE |
1475 | |
1476 | NOTES |
1477 | |
1478 | MODIFICATION HISTORY |
1479 | 12-JUL-95 Charlie Tomberg Created |
1480 | |
1481 +===========================================================================*/
1482
1483
1484 PROCEDURE delete_salescredit(
1485 p_form_name IN varchar2,
1486 p_form_version IN number,
1487 p_run_auto_accounting_flag IN boolean,
1488 p_cust_trx_line_salesrep_id IN
1489 ra_cust_trx_line_salesreps.cust_trx_line_salesrep_id%type,
1490 p_customer_trx_id IN
1491 ra_customer_trx.customer_trx_id%type,
1492 p_customer_trx_line_id IN
1493 ra_customer_trx_lines.customer_trx_line_id%type,
1494 p_srep_rec IN ra_cust_trx_line_salesreps%rowtype,
1495 p_backout_flag IN boolean DEFAULT FALSE,
1496 p_backout_done_flag OUT NOCOPY boolean,
1497 p_status OUT NOCOPY varchar2)
1498 IS
1499
1500 l_backout_flag boolean;
1501 l_posted_flag boolean;
1502 l_salesrep_changed_flag boolean;
1503 l_amount_percent_changed_flag boolean;
1504 l_rev_amt_percent_changed_flag boolean;
1505 l_default_records_flag boolean;
1506 l_old_srep_rec ra_cust_trx_line_salesreps%rowtype;
1507 l_temp_srep_rec ra_cust_trx_line_salesreps%rowtype;
1508 l_status1 varchar2(100);
1509 l_status2 varchar2(100);
1510 l_status3 varchar2(100);
1511
1512 BEGIN
1513
1514 arp_util.debug('arp_process_salescredit.delete_salescredit()+');
1515
1516 /*----------------------------------------------+
1517 | Check the form version to determine if it |
1518 | is compatible with the entity handler. |
1519 +----------------------------------------------*/
1520
1521 arp_trx_validate.ar_entity_version_check(p_form_name, p_form_version);
1522
1523 /*-------------------------+
1524 | Do required validation |
1525 +-------------------------*/
1526
1527 arp_process_salescredit.val_delete_salescredit(p_srep_rec);
1528
1529 set_flags(p_cust_trx_line_salesrep_id,
1530 p_srep_rec,
1531 p_backout_flag,
1532 TRUE, -- delete_flag
1533 l_posted_flag,
1534 l_salesrep_changed_flag,
1535 l_amount_percent_changed_flag,
1536 l_rev_amt_percent_changed_flag,
1537 l_default_records_flag,
1538 l_backout_flag);
1539
1540 p_backout_done_flag := l_backout_flag;
1541
1542 /*----------------------------------------------------------------+
1543 | Lock rows in other tables that reference this customer_trx_id |
1544 +----------------------------------------------------------------*/
1545
1546 arp_trx_util.lock_transaction(p_customer_trx_id);
1547
1548
1549 /*---------------------------------------------------------------------+
1550 | If no backout is required, do a simple delete. |
1551 | Otherwise, create an offsetting salescredit record and optionally |
1552 | an ofsetting distribution record. |
1553 +---------------------------------------------------------------------*/
1554
1555 IF (l_backout_flag = FALSE)
1556 THEN
1557
1558 /*-----------------------------------------------------------+
1559 | call the table-handler to delete the salescredit record |
1560 +-----------------------------------------------------------*/
1561
1562 arp_ctls_pkg.delete_p(p_cust_trx_line_salesrep_id,
1563 p_customer_trx_line_id);
1564
1565 ELSE
1566 arp_ctls_pkg.fetch_p(l_old_srep_rec, p_cust_trx_line_salesrep_id);
1567
1568 l_temp_srep_rec := l_old_srep_rec;
1569 l_temp_srep_rec.revenue_amount_split := 0;
1570 l_temp_srep_rec.revenue_percent_split := 0;
1571 l_temp_srep_rec.non_revenue_amount_split := 0;
1572 l_temp_srep_rec.non_revenue_percent_split := 0;
1573
1574 backout_amount(l_old_srep_rec,
1575 l_temp_srep_rec,
1576 p_run_auto_accounting_flag,
1577 l_status1 );
1578
1579 END IF;
1580
1581
1582 /*----------------------------------------------------------------+
1583 | Rerun AutoAccounting if the p_run_auto_accounting_flag = TRUE |
1584 | and no backout was done. |
1585 +----------------------------------------------------------------*/
1586
1587 IF (
1588 p_run_auto_accounting_flag = TRUE
1589 AND l_backout_flag = FALSE
1590 )
1591
1592 THEN
1593
1594 run_autoacc_for_scredits( p_customer_trx_id,
1595 p_customer_trx_line_id,
1596 NULL,
1597 l_status2 );
1598
1599 END IF;
1600
1601 /*----------------------------------------------------------------+
1602 | Validate Tax from Revenue Account if Auto Accounting was rerun |
1603 +----------------------------------------------------------------*/
1604
1605 IF ( p_run_auto_accounting_flag = TRUE ) THEN
1606
1607 val_tax_from_revenue( p_customer_trx_id,
1608 p_customer_trx_line_id,
1609 p_run_auto_accounting_flag,
1610 l_status3 );
1611
1612 END IF;
1613
1614 arp_util.debug('l_status1 = ' || l_status1);
1615 arp_util.debug('l_status2 = ' || l_status2);
1616 arp_util.debug('l_status3 = ' || l_status3);
1617
1618 IF ( NVL(l_status1, 'OK') <> 'OK' )
1619 THEN p_status := l_status1;
1620 ELSIF ( NVL(l_status2, 'OK') <> 'OK' )
1621 THEN p_status := l_status2;
1622 ELSIF ( NVL(l_status3, 'OK') <> 'OK' )
1623 THEN p_status := l_status3;
1624 ELSE p_status := 'OK';
1625 END IF;
1626
1627 arp_util.debug('arp_process_salescredit.delete_salescredit()-');
1628
1629 EXCEPTION
1630 WHEN OTHERS THEN
1631
1632
1633 /*---------------------------------------------+
1634 | Display parameters and raise the exception |
1635 +---------------------------------------------*/
1636
1637 arp_util.debug('EXCEPTION: arp_process_salescredit.delete_salescredit()');
1638
1639 arp_util.debug('');
1640 arp_util.debug('---------- delete_salescredit() ---------');
1641
1642 arp_util.debug('p_form_name = ' || p_form_name);
1643 arp_util.debug('p_form_version = ' || p_form_version);
1644
1645 arp_util.debug('p_cust_trx_line_salesrep_id = ' ||
1646 p_cust_trx_line_salesrep_id);
1647 arp_util.debug('p_customer_trx_id = ' || p_customer_trx_id);
1648 arp_util.debug('p_customer_trx_line_id = ' ||
1649 p_customer_trx_line_id);
1650
1651 arp_util.debug('p_run_auto_accounting_flag = ' ||
1652 arp_trx_util.boolean_to_varchar2(p_run_auto_accounting_flag));
1653
1654 arp_util.debug('p_backout_flag = ' ||
1655 arp_trx_util.boolean_to_varchar2(p_backout_flag));
1656
1657 arp_util.debug('');
1658 arp_ctls_pkg.display_salescredit_rec( p_srep_rec );
1659 arp_util.debug('');
1660
1661 RAISE;
1662
1663 END;
1664
1665
1666 /*===========================================================================+
1667 | PROCEDURE |
1668 | create_line_salescredits |
1669 | |
1670 | DESCRIPTION |
1671 | Creates the appropriate salescredits for the transaction line. |
1672 | |
1673 | SCOPE - PUBLIC |
1674 | |
1675 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED |
1676 | arp_util.debug |
1677 | |
1678 | ARGUMENTS : IN: |
1679 | p_customer_trx_id |
1680 | p_customer_trx_line_id |
1681 | p_memo_line_type |
1682 | p_delete_scredits_first_flag |
1683 | p_run_autoaccounting_flag |
1684 | OUT: |
1685 | p_status |
1686 | |
1687 | RETURNS : NONE |
1688 | |
1689 | NOTES |
1690 | |
1691 | MODIFICATION HISTORY |
1692 | 24-JUL-95 Charlie Tomberg Created |
1693 | 28-NOV-95 Martin Johnson nvl p_memo_line_type |
1694 | |
1695 +===========================================================================*/
1696
1697
1698 PROCEDURE create_line_salescredits(p_customer_trx_id IN
1699 ra_customer_trx_lines.customer_trx_id%type,
1700 p_customer_trx_line_id IN
1701 ra_customer_trx_lines.customer_trx_line_id%type,
1702 p_memo_line_type IN
1703 ar_memo_lines.line_type%type,
1704 p_delete_scredits_first_flag IN
1705 varchar2,
1706 p_run_autoaccounting_flag IN varchar2,
1707 p_status OUT NOCOPY varchar2)
1708 IS
1709
1710 l_status1 VARCHAR2(100);
1711 l_status2 VARCHAR2(100);
1712 prev_customer_trx_id ra_customer_trx.previous_customer_trx_id%type;
1713 p_salesrep_id ra_customer_trx.primary_salesrep_id%type;
1714
1715 BEGIN
1716
1717 arp_util.debug('arp_process_salescredit.create_line_salescredits()+');
1718
1719 /*-------------------------------------+
1720 |Checking whether its Credit Memo |
1721 +-------------------------------------*/
1722
1723 SELECT previous_customer_trx_id ,
1724 primary_salesrep_id
1725 into
1726 prev_customer_trx_id,
1727 p_salesrep_id
1728 FROM ra_customer_trx
1729 WHERE customer_trx_id = p_customer_trx_id;
1730
1731 /*--------------------------------------+
1732 | Charges do not have salescredits. |
1733 | If this is a charges memo line, |
1734 | then don't do any processing. |
1735 +--------------------------------------*/
1736
1737 IF ( nvl(p_memo_line_type, 'x') <> 'CHARGES' )
1738 THEN
1739
1740 /*----------------------------------------------------------------+
1741 | Lock rows in other tables that reference this customer_trx_id |
1742 +----------------------------------------------------------------*/
1743
1744 arp_trx_util.lock_transaction(p_customer_trx_id);
1745
1746 /*----------------------------------------+
1747 | Delete salescredits first if desired |
1748 +----------------------------------------*/
1749
1750
1751 IF ( p_delete_scredits_first_flag = 'Y' )
1752 THEN
1753 IF ( p_customer_trx_line_id IS NOT NULL )
1754 THEN
1755 arp_ctls_pkg.delete_f_ctl_id( p_customer_trx_line_id );
1756 ELSIF ( p_customer_trx_id IS NOT NULL )
1757 THEN arp_ctls_pkg.delete_f_ct_id( p_customer_trx_id, FALSE );
1758 END IF;
1759
1760 END IF;
1761
1762 /*-------------------------------------------------------+
1763 | If there are no default salescredits, |
1764 | insert a single salescredit record that corresponds |
1765 | to the header salesrep. |
1766 | Otherwise, create salescredits that correspond to |
1767 | the header default salescredits. |
1768 +-------------------------------------------------------*/
1769
1770 /*-------------------------------------------------+
1771 |Bug 1157776 If this is a Credit Memo, |
1772 |then call arp_ctls_pkg.insert_f_cmn_ct_ctl_id |
1773 +-------------------------------------------------*/
1774 /*------------------------------------------------------------------+
1775 | Bug 1485133. |
1776 | We need to check if the RA_CUSTOMER_TRX.PRIMARY_SALESREP_ID |
1777 | is not null before calling arp_ctls_pkg.insert_f_cmn_ct_ctl_id |
1778 +------------------------------------------------------------------*/
1779
1780 IF (prev_customer_trx_id is not null) then
1781
1782 IF (p_salesrep_id is not null) then
1783 arp_ctls_pkg.insert_f_cmn_ct_ctl_id( p_customer_trx_id,
1784 p_customer_trx_line_id );
1785 END IF;
1786 ELSE
1787 arp_ctls_pkg.insert_f_ct_ctl_id( p_customer_trx_id,
1788 p_customer_trx_line_id );
1789 END IF;
1790
1791 /*----------------------------------+
1792 | Rerun AutoAccounting if desired |
1793 +----------------------------------*/
1794
1795 IF ( p_run_autoaccounting_flag = 'Y' )
1796 THEN
1797 run_autoacc_for_scredits( p_customer_trx_id,
1798 p_customer_trx_line_id,
1799 NULL,
1800 l_status1 );
1801
1802 END IF;
1803
1804
1805 /*----------------------------------------------------------------+
1806 | Validate Tax from Revenue Account if Auto Accounting was rerun |
1807 +----------------------------------------------------------------*/
1808
1809 IF ( p_run_autoaccounting_flag = 'Y' ) THEN
1810
1811 val_tax_from_revenue( p_customer_trx_id,
1812 p_customer_trx_line_id,
1813 TRUE, -- p_run_auto_accounting_flag,
1814 l_status2 );
1815
1816 END IF;
1817
1818
1819 END IF;
1820
1821 arp_util.debug('l_status1 = ' || l_status1);
1822 arp_util.debug('l_status2 = ' || l_status2);
1823
1824 IF ( NVL(l_status1, 'OK') <> 'OK' )
1825 THEN p_status := l_status1;
1826 ELSIF ( NVL(l_status2, 'OK') <> 'OK' )
1827 THEN p_status := l_status2;
1828 ELSE p_status := 'OK';
1829 END IF;
1830
1831 arp_util.debug('arp_process_salescredit.create_line_salescredits()-');
1832
1833 EXCEPTION
1834 WHEN OTHERS THEN
1835 arp_util.debug(sqlerrm);
1836 arp_util.debug(
1837 'EXCEPTION: arp_process_salescredit.create_line_salescredits()');
1838
1839
1840 arp_util.debug('');
1841 arp_util.debug('---- parameters for create_line_salescredits() -----');
1842
1843 arp_util.debug('p_customer_trx_id = ' || p_customer_trx_id);
1844 arp_util.debug('p_customer_trx_line_id = ' || p_customer_trx_line_id);
1845 arp_util.debug('p_memo_line_type = ' || p_memo_line_type);
1846
1847
1848 RAISE;
1849
1850 END;
1851
1852 /*===========================================================================+
1853 | PROCEDURE |
1854 | insert_salescredit_cover |
1855 | |
1856 | DESCRIPTION |
1857 | Converts column parameters to a salescredit record and |
1858 | inserts a salescredit line. |
1859 | |
1860 | SCOPE - PUBLIC |
1861 | |
1862 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED |
1863 | arp_util.debug |
1864 | |
1865 | ARGUMENTS : IN: |
1866 | p_form_name |
1867 | p_form_version |
1868 | p_run_auto_accounting_flag |
1869 | p_customer_trx_id |
1870 | p_customer_trx_line_id |
1871 | p_salesrep_id |
1872 | p_revenue_amount_split |
1873 | p_non_revenue_amount_split |
1874 | p_non_revenue_percent_split |
1875 | p_revenue_percent_split |
1876 | p_prev_cust_trx_line_srep_id |
1877 | p_attribute_category |
1878 | p_attribute1 |
1879 | p_attribute2 |
1880 | p_attribute3 |
1881 | p_attribute4 |
1882 | p_attribute5 |
1883 | p_attribute6 |
1884 | p_attribute7 |
1885 | p_attribute8 |
1886 | p_attribute9 |
1887 | p_attribute10 |
1888 | p_attribute11 |
1889 | p_attribute12 |
1890 | p_attribute13 |
1891 | p_attribute14 |
1892 | p_attribute15 |
1893 | p_revenue_salesgroup_id |
1894 | p_non_revenue_salesgroup_id |
1895 | OUT: |
1896 | p_cust_trx_line_salesrep_id |
1897 | p_status |
1898 | IN/ OUT: |
1899 | None |
1900 | |
1901 | RETURNS : NONE |
1902 | |
1903 | NOTES |
1904 | |
1905 | MODIFICATION HISTORY |
1906 | 25-SEP-95 Charlie Tomberg Created |
1907 | |
1908 +===========================================================================*/
1909
1910
1911 PROCEDURE insert_salescredit_cover(
1912 p_form_name IN varchar2,
1913 p_form_version IN number,
1914 p_run_auto_accounting_flag IN boolean,
1915
1916 p_customer_trx_id IN
1917 ra_cust_trx_line_salesreps.customer_trx_id%type,
1918 p_customer_trx_line_id IN
1919 ra_cust_trx_line_salesreps.customer_trx_line_id%type,
1920 p_salesrep_id IN
1921 ra_cust_trx_line_salesreps.salesrep_id%type,
1922 p_revenue_amount_split IN
1923 ra_cust_trx_line_salesreps.revenue_amount_split%type,
1924 p_non_revenue_amount_split IN
1925 ra_cust_trx_line_salesreps.non_revenue_amount_split%type,
1926 p_non_revenue_percent_split IN
1927 ra_cust_trx_line_salesreps.non_revenue_percent_split%type,
1928 p_revenue_percent_split IN
1929 ra_cust_trx_line_salesreps.revenue_percent_split%type,
1930 p_prev_cust_trx_line_srep_id IN
1931 ra_cust_trx_line_salesreps.prev_cust_trx_line_salesrep_id%type,
1932 p_attribute_category IN
1933 ra_cust_trx_line_salesreps.attribute_category%type,
1934 p_attribute1 IN
1935 ra_cust_trx_line_salesreps.attribute1%type,
1936 p_attribute2 IN
1937 ra_cust_trx_line_salesreps.attribute2%type,
1938 p_attribute3 IN
1939 ra_cust_trx_line_salesreps.attribute3%type,
1940 p_attribute4 IN
1941 ra_cust_trx_line_salesreps.attribute4%type,
1942 p_attribute5 IN
1943 ra_cust_trx_line_salesreps.attribute5%type,
1944 p_attribute6 IN
1945 ra_cust_trx_line_salesreps.attribute6%type,
1946 p_attribute7 IN
1947 ra_cust_trx_line_salesreps.attribute7%type,
1948 p_attribute8 IN
1949 ra_cust_trx_line_salesreps.attribute8%type,
1950 p_attribute9 IN
1951 ra_cust_trx_line_salesreps.attribute9%type,
1952 p_attribute10 IN
1953 ra_cust_trx_line_salesreps.attribute10%type,
1954 p_attribute11 IN
1955 ra_cust_trx_line_salesreps.attribute11%type,
1956 p_attribute12 IN
1957 ra_cust_trx_line_salesreps.attribute12%type,
1958 p_attribute13 IN
1959 ra_cust_trx_line_salesreps.attribute13%type,
1960 p_attribute14 IN
1961 ra_cust_trx_line_salesreps.attribute14%type,
1962 p_attribute15 IN
1963 ra_cust_trx_line_salesreps.attribute15%type,
1964 p_cust_trx_line_salesrep_id OUT NOCOPY
1965 ra_cust_trx_line_salesreps.cust_trx_line_salesrep_id%type,
1966 p_status OUT NOCOPY varchar2,
1967 p_revenue_salesgroup_id IN
1968 ra_cust_trx_line_salesreps.revenue_salesgroup_id%type DEFAULT null,
1969 p_non_revenue_salesgroup_id IN
1970 ra_cust_trx_line_salesreps.non_revenue_salesgroup_id%type DEFAULT null)
1971
1972 IS
1973
1974 l_srep_rec ra_cust_trx_line_salesreps%rowtype;
1975
1976 /* bug 3607146 */
1977 l_scredit_count NUMBER;
1978 BEGIN
1979
1980 arp_util.debug('arp_process_salescredit.insert_salescredit_cover()+');
1981
1982 /*------------------------------------------------+
1983 | Populate the salescredit record group with |
1984 | the values passed in as parameters. |
1985 +------------------------------------------------*/
1986
1987 l_srep_rec.customer_trx_id := p_customer_trx_id;
1988 l_srep_rec.customer_trx_line_id := p_customer_trx_line_id;
1989 l_srep_rec.salesrep_id := p_salesrep_id;
1990 l_srep_rec.revenue_amount_split := p_revenue_amount_split;
1991 l_srep_rec.non_revenue_amount_split := p_non_revenue_amount_split;
1992 l_srep_rec.non_revenue_percent_split := p_non_revenue_percent_split;
1993 l_srep_rec.revenue_percent_split := p_revenue_percent_split;
1994 l_srep_rec.prev_cust_trx_line_salesrep_id
1995 := p_prev_cust_trx_line_srep_id;
1996 l_srep_rec.attribute_category := p_attribute_category;
1997 l_srep_rec.attribute1 := p_attribute1;
1998 l_srep_rec.attribute2 := p_attribute2;
1999 l_srep_rec.attribute3 := p_attribute3;
2000 l_srep_rec.attribute4 := p_attribute4;
2001 l_srep_rec.attribute5 := p_attribute5;
2002 l_srep_rec.attribute6 := p_attribute6;
2003 l_srep_rec.attribute7 := p_attribute7;
2004 l_srep_rec.attribute8 := p_attribute8;
2005 l_srep_rec.attribute9 := p_attribute9;
2006 l_srep_rec.attribute10 := p_attribute10;
2007 l_srep_rec.attribute11 := p_attribute11;
2008 l_srep_rec.attribute12 := p_attribute12;
2009 l_srep_rec.attribute13 := p_attribute13;
2010 l_srep_rec.attribute14 := p_attribute14;
2011 l_srep_rec.attribute15 := p_attribute15;
2012 l_srep_rec.revenue_salesgroup_id := p_revenue_salesgroup_id;
2013 l_srep_rec.non_revenue_salesgroup_id := p_non_revenue_salesgroup_id;
2014
2015 /*-----------------------------------------------+
2016 | Call the standard salescredit entity handler |
2017 +-----------------------------------------------*/
2018
2019 insert_salescredit(
2020 p_form_name,
2021 p_form_version,
2022 p_run_auto_accounting_flag,
2023 l_srep_rec,
2024 p_cust_trx_line_salesrep_id,
2025 p_status );
2026 /* bug 3607146 */
2027 arp_rounding.correct_scredit_rounding_errs( p_customer_trx_id,
2028 l_scredit_count);
2029
2030 arp_util.debug('arp_process_salescredit.insert_salescredit_cover()-');
2031
2032 EXCEPTION
2033 WHEN OTHERS THEN
2034
2035 arp_util.debug(
2036 'EXCEPTION: arp_process_salescredit.insert_salescredit_cover()');
2037
2038 arp_util.debug('------- parameters for insert_salescredit_cover() ' ||
2039 '---------');
2040 arp_util.debug('p_form_name = ' || p_form_name );
2041 arp_util.debug('p_form_version = ' || p_form_version );
2042 arp_util.debug('p_run_auto_accounting_flag = ' ||
2043 arp_trx_util.boolean_to_varchar2(p_run_auto_accounting_flag) );
2044 arp_util.debug('p_customer_trx_id = ' || p_customer_trx_id );
2045 arp_util.debug('p_customer_trx_line_id = ' ||
2046 p_customer_trx_line_id );
2047 arp_util.debug('p_salesrep_id = ' ||
2048 p_salesrep_id );
2049 arp_util.debug('p_revenue_amount_split = ' ||
2050 p_revenue_amount_split );
2051 arp_util.debug('p_non_revenue_amount_split = ' ||
2052 p_non_revenue_amount_split );
2053 arp_util.debug('p_non_revenue_percent_split = ' ||
2054 p_non_revenue_percent_split );
2055 arp_util.debug('p_revenue_percent_split = ' ||
2056 p_revenue_percent_split );
2057 arp_util.debug('p_prev_cust_trx_line_srep_id = ' ||
2058 p_prev_cust_trx_line_srep_id );
2059 arp_util.debug('p_attribute_category = ' ||
2060 p_attribute_category );
2061 arp_util.debug('p_attribute1 = ' || p_attribute1 );
2062 arp_util.debug('p_attribute2 = ' || p_attribute2 );
2063 arp_util.debug('p_attribute3 = ' || p_attribute3 );
2064 arp_util.debug('p_attribute4 = ' || p_attribute4 );
2065 arp_util.debug('p_attribute5 = ' || p_attribute5 );
2066 arp_util.debug('p_attribute6 = ' || p_attribute6 );
2067 arp_util.debug('p_attribute7 = ' || p_attribute7 );
2068 arp_util.debug('p_attribute8 = ' || p_attribute8 );
2069 arp_util.debug('p_attribute9 = ' || p_attribute9 );
2070 arp_util.debug('p_attribute10 = ' || p_attribute10 );
2071 arp_util.debug('p_attribute11 = ' || p_attribute11 );
2072 arp_util.debug('p_attribute12 = ' || p_attribute12 );
2073 arp_util.debug('p_attribute13 = ' || p_attribute13 );
2074 arp_util.debug('p_attribute14 = ' || p_attribute14 );
2075 arp_util.debug('p_attribute15 = ' || p_attribute15 );
2076 arp_util.debug('p_revenue_salesgroup_id = ' || p_revenue_salesgroup_id );
2077 arp_util.debug('p_non_revenue_salesgroup_id = ' || p_non_revenue_salesgroup_id );
2078
2079 RAISE;
2080
2081 END;
2082
2083
2084 /*===========================================================================+
2085 | PROCEDURE |
2086 | update_salescredit_cover |
2087 | |
2088 | DESCRIPTION |
2089 | Converts column parameters to a salescredit record and |
2090 | updates a salescredit line. |
2091 | |
2092 | SCOPE - PUBLIC |
2093 | |
2094 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED |
2095 | arp_util.debug |
2096 | |
2097 | ARGUMENTS : IN: |
2098 | p_form_name |
2099 | p_form_version |
2100 | p_run_auto_accounting_flag |
2101 | p_backout_flag |
2102 | p_cust_trx_line_salesrep_id |
2103 | p_customer_trx_id |
2104 | p_customer_trx_line_id |
2105 | p_salesrep_id |
2106 | p_revenue_amount_split |
2107 | p_non_revenue_amount_split |
2108 | p_non_revenue_percent_split |
2109 | p_revenue_percent_split |
2110 | p_prev_cust_trx_line_srep_id |
2111 | p_attribute_category |
2112 | p_attribute1 |
2113 | p_attribute2 |
2114 | p_attribute3 |
2115 | p_attribute4 |
2116 | p_attribute5 |
2117 | p_attribute6 |
2118 | p_attribute7 |
2119 | p_attribute8 |
2120 | p_attribute9 |
2121 | p_attribute10 |
2122 | p_attribute11 |
2123 | p_attribute12 |
2124 | p_attribute13 |
2125 | p_attribute14 |
2126 | p_attribute15 |
2127 | p_revenue_salesgroup_id |
2128 | p_non_revenue_salesgroup_id |
2129 | OUT: |
2130 | p_backout_done_flag |
2131 | p_status |
2132 | IN/ OUT: |
2133 | None |
2134 | |
2135 | RETURNS : NONE |
2136 | |
2137 | NOTES |
2138 | |
2139 | MODIFICATION HISTORY |
2140 | 25-SEP-95 Charlie Tomberg Created |
2141 | |
2142 +===========================================================================*/
2143
2144 PROCEDURE update_salescredit_cover(
2145 p_form_name IN varchar2,
2146 p_form_version IN number,
2147 p_run_auto_accounting_flag IN boolean,
2148 p_backout_flag IN boolean,
2149 p_cust_trx_line_salesrep_id IN
2150 ra_cust_trx_line_salesreps.cust_trx_line_salesrep_id%type,
2151 p_customer_trx_id IN
2152 ra_cust_trx_line_salesreps.customer_trx_id%type,
2153 p_customer_trx_line_id IN
2154 ra_cust_trx_line_salesreps.customer_trx_line_id%type,
2155 p_salesrep_id IN
2156 ra_cust_trx_line_salesreps.salesrep_id%type,
2157 p_revenue_amount_split IN
2158 ra_cust_trx_line_salesreps.revenue_amount_split%type,
2159 p_non_revenue_amount_split IN
2160 ra_cust_trx_line_salesreps.non_revenue_amount_split%type,
2161 p_non_revenue_percent_split IN
2162 ra_cust_trx_line_salesreps.non_revenue_percent_split%type,
2163 p_revenue_percent_split IN
2164 ra_cust_trx_line_salesreps.revenue_percent_split%type,
2165 p_prev_cust_trx_line_srep_id IN
2166 ra_cust_trx_line_salesreps.prev_cust_trx_line_salesrep_id%type,
2167 p_attribute_category IN
2168 ra_cust_trx_line_salesreps.attribute_category%type,
2169 p_attribute1 IN
2170 ra_cust_trx_line_salesreps.attribute1%type,
2171 p_attribute2 IN
2172 ra_cust_trx_line_salesreps.attribute2%type,
2173 p_attribute3 IN
2174 ra_cust_trx_line_salesreps.attribute3%type,
2175 p_attribute4 IN
2176 ra_cust_trx_line_salesreps.attribute4%type,
2177 p_attribute5 IN
2178 ra_cust_trx_line_salesreps.attribute5%type,
2179 p_attribute6 IN
2180 ra_cust_trx_line_salesreps.attribute6%type,
2181 p_attribute7 IN
2182 ra_cust_trx_line_salesreps.attribute7%type,
2183 p_attribute8 IN
2184 ra_cust_trx_line_salesreps.attribute8%type,
2185 p_attribute9 IN
2186 ra_cust_trx_line_salesreps.attribute9%type,
2187 p_attribute10 IN
2188 ra_cust_trx_line_salesreps.attribute10%type,
2189 p_attribute11 IN
2190 ra_cust_trx_line_salesreps.attribute11%type,
2191 p_attribute12 IN
2192 ra_cust_trx_line_salesreps.attribute12%type,
2193 p_attribute13 IN
2194 ra_cust_trx_line_salesreps.attribute13%type,
2195 p_attribute14 IN
2196 ra_cust_trx_line_salesreps.attribute14%type,
2197 p_attribute15 IN
2198 ra_cust_trx_line_salesreps.attribute15%type,
2199 p_backout_done_flag OUT NOCOPY boolean,
2200 p_status OUT NOCOPY varchar2,
2201 p_revenue_salesgroup_id IN
2202 ra_cust_trx_line_salesreps.revenue_salesgroup_id%type DEFAULT null,
2203 p_non_revenue_salesgroup_id IN
2204 ra_cust_trx_line_salesreps.non_revenue_salesgroup_id%type DEFAULT null)
2205 IS
2206
2207 l_srep_rec ra_cust_trx_line_salesreps%rowtype;
2208
2209 /* bug 3607146 */
2210 l_scredit_count NUMBER;
2211
2212 BEGIN
2213
2214 arp_util.debug('arp_process_salescredit.update_salescredit_cover()+');
2215
2216 /*------------------------------------------------+
2217 | Populate the salescredit record group with |
2218 | the values passed in as parameters. |
2219 +------------------------------------------------*/
2220
2221 arp_ctls_pkg.set_to_dummy(l_srep_rec);
2222
2223 l_srep_rec.customer_trx_id := p_customer_trx_id;
2224 l_srep_rec.customer_trx_line_id := p_customer_trx_line_id;
2225 l_srep_rec.salesrep_id := p_salesrep_id;
2226 l_srep_rec.revenue_amount_split := p_revenue_amount_split;
2227 l_srep_rec.non_revenue_amount_split := p_non_revenue_amount_split;
2228 l_srep_rec.non_revenue_percent_split := p_non_revenue_percent_split;
2229 l_srep_rec.revenue_percent_split := p_revenue_percent_split;
2230 l_srep_rec.prev_cust_trx_line_salesrep_id
2231 := p_prev_cust_trx_line_srep_id;
2232 l_srep_rec.attribute_category := p_attribute_category;
2233 l_srep_rec.attribute1 := p_attribute1;
2234 l_srep_rec.attribute2 := p_attribute2;
2235 l_srep_rec.attribute3 := p_attribute3;
2236 l_srep_rec.attribute4 := p_attribute4;
2237 l_srep_rec.attribute5 := p_attribute5;
2238 l_srep_rec.attribute6 := p_attribute6;
2239 l_srep_rec.attribute7 := p_attribute7;
2240 l_srep_rec.attribute8 := p_attribute8;
2241 l_srep_rec.attribute9 := p_attribute9;
2242 l_srep_rec.attribute10 := p_attribute10;
2243 l_srep_rec.attribute11 := p_attribute11;
2244 l_srep_rec.attribute12 := p_attribute12;
2245 l_srep_rec.attribute13 := p_attribute13;
2246 l_srep_rec.attribute14 := p_attribute14;
2247 l_srep_rec.attribute15 := p_attribute15;
2248 l_srep_rec.revenue_salesgroup_id := p_revenue_salesgroup_id;
2249 l_srep_rec.non_revenue_salesgroup_id := p_non_revenue_salesgroup_id;
2250
2251
2252 /*-----------------------------------------------+
2253 | Call the standard salescredit entity handler |
2254 +-----------------------------------------------*/
2255
2256 update_salescredit(
2257 p_form_name,
2258 p_form_version,
2259 p_run_auto_accounting_flag,
2260 p_backout_flag,
2261 p_cust_trx_line_salesrep_id,
2262 p_customer_trx_id,
2263 p_customer_trx_line_id,
2264 l_srep_rec,
2265 p_backout_done_flag,
2266 p_status );
2267
2268 /* bug 3607146 */
2269 arp_rounding.correct_scredit_rounding_errs( p_customer_trx_id,
2270 l_scredit_count);
2271
2272 arp_util.debug('arp_process_salescredit.update_salescredit_cover()-');
2273
2274 EXCEPTION
2275 WHEN OTHERS THEN
2276
2277 arp_util.debug(
2278 'EXCEPTION: arp_process_salescredit.update_salescredit_cover()');
2279
2280 arp_util.debug('------- parameters for update_salescredit_cover() ' ||
2281 '---------');
2282 arp_util.debug('p_form_name = ' || p_form_name );
2283 arp_util.debug('p_form_version = ' || p_form_version );
2284 arp_util.debug('p_run_auto_accounting_flag = ' ||
2285 arp_trx_util.boolean_to_varchar2(p_run_auto_accounting_flag) );
2286 arp_util.debug('p_backout_flag = ' ||
2287 arp_trx_util.boolean_to_varchar2(p_backout_flag) );
2288 arp_util.debug('p_customer_trx_id = ' || p_customer_trx_id );
2289 arp_util.debug('p_customer_trx_line_id = ' ||
2290 p_customer_trx_line_id );
2291 arp_util.debug('p_salesrep_id = ' ||
2292 p_salesrep_id );
2293 arp_util.debug('p_revenue_amount_split = ' ||
2294 p_revenue_amount_split );
2295 arp_util.debug('p_non_revenue_amount_split = ' ||
2296 p_non_revenue_amount_split );
2297 arp_util.debug('p_non_revenue_percent_split = ' ||
2298 p_non_revenue_percent_split );
2299 arp_util.debug('p_revenue_percent_split = ' ||
2300 p_revenue_percent_split );
2301 arp_util.debug('p_prev_cust_trx_line_srep_id = ' ||
2302 p_prev_cust_trx_line_srep_id );
2303 arp_util.debug('p_attribute_category = ' ||
2304 p_attribute_category );
2305 arp_util.debug('p_attribute1 = ' || p_attribute1 );
2306 arp_util.debug('p_attribute2 = ' || p_attribute2 );
2307 arp_util.debug('p_attribute3 = ' || p_attribute3 );
2308 arp_util.debug('p_attribute4 = ' || p_attribute4 );
2309 arp_util.debug('p_attribute5 = ' || p_attribute5 );
2310 arp_util.debug('p_attribute6 = ' || p_attribute6 );
2311 arp_util.debug('p_attribute7 = ' || p_attribute7 );
2312 arp_util.debug('p_attribute8 = ' || p_attribute8 );
2313 arp_util.debug('p_attribute9 = ' || p_attribute9 );
2314 arp_util.debug('p_attribute10 = ' || p_attribute10 );
2315 arp_util.debug('p_attribute11 = ' || p_attribute11 );
2316 arp_util.debug('p_attribute12 = ' || p_attribute12 );
2317 arp_util.debug('p_attribute13 = ' || p_attribute13 );
2318 arp_util.debug('p_attribute14 = ' || p_attribute14 );
2319 arp_util.debug('p_attribute15 = ' || p_attribute15 );
2320 arp_util.debug('p_revenue_salesgroup_id = ' || p_revenue_salesgroup_id );
2321 arp_util.debug('p_non_revenue_salesgroup_id = ' || p_non_revenue_salesgroup_id );
2322
2323 RAISE;
2324
2325 END;
2326
2327
2328 /*===========================================================================+
2329 | PROCEDURE |
2330 | delete_salescredit_cover |
2331 | |
2332 | DESCRIPTION |
2333 | Converts column parameters to a salescredit record and |
2334 | delete a salescredit line. |
2335 | |
2336 | SCOPE - PUBLIC |
2337 | |
2338 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED |
2339 | arp_util.debug |
2340 | |
2341 | ARGUMENTS : IN: |
2342 | p_form_name |
2343 | p_form_version |
2344 | p_run_auto_accounting_flag |
2345 | p_backout_flag |
2346 | p_cust_trx_line_salesrep_id |
2347 | p_customer_trx_id |
2348 | p_customer_trx_line_id |
2349 | p_salesrep_id |
2350 | p_revenue_amount_split |
2351 | p_non_revenue_amount_split |
2352 | p_non_revenue_percent_split |
2353 | p_revenue_percent_split |
2354 | p_prev_cust_trx_line_srep_id |
2355 | p_attribute_category |
2356 | p_attribute1 |
2357 | p_attribute2 |
2358 | p_attribute3 |
2359 | p_attribute4 |
2360 | p_attribute5 |
2361 | p_attribute6 |
2362 | p_attribute7 |
2363 | p_attribute8 |
2364 | p_attribute9 |
2365 | p_attribute10 |
2366 | p_attribute11 |
2367 | p_attribute12 |
2368 | p_attribute13 |
2369 | p_attribute14 |
2370 | p_attribute15 |
2371 | p_revenue_salesgroup_id |
2372 | p_non_revenue_salesgroup_id |
2373 | OUT: |
2374 | p_backout_done_flag |
2375 | p_status |
2376 | IN/ OUT: |
2377 | None |
2378 | |
2379 | RETURNS : NONE |
2380 | |
2381 | NOTES |
2382 | |
2383 | MODIFICATION HISTORY |
2384 | 25-SEP-95 Charlie Tomberg Created |
2385 | |
2386 +===========================================================================*/
2387
2388 PROCEDURE delete_salescredit_cover(
2389 p_form_name IN varchar2,
2390 p_form_version IN number,
2391 p_run_auto_accounting_flag IN boolean,
2392 p_backout_flag IN boolean,
2393 p_cust_trx_line_salesrep_id IN
2394 ra_cust_trx_line_salesreps.cust_trx_line_salesrep_id%type,
2395 p_customer_trx_id IN
2396 ra_cust_trx_line_salesreps.customer_trx_id%type,
2397 p_customer_trx_line_id IN
2398 ra_cust_trx_line_salesreps.customer_trx_line_id%type,
2399 p_salesrep_id IN
2400 ra_cust_trx_line_salesreps.salesrep_id%type,
2401 p_revenue_amount_split IN
2402 ra_cust_trx_line_salesreps.revenue_amount_split%type,
2403 p_non_revenue_amount_split IN
2404 ra_cust_trx_line_salesreps.non_revenue_amount_split%type,
2405 p_non_revenue_percent_split IN
2406 ra_cust_trx_line_salesreps.non_revenue_percent_split%type,
2407 p_revenue_percent_split IN
2408 ra_cust_trx_line_salesreps.revenue_percent_split%type,
2409 p_prev_cust_trx_line_srep_id IN
2410 ra_cust_trx_line_salesreps.prev_cust_trx_line_salesrep_id%type,
2411 p_attribute_category IN
2412 ra_cust_trx_line_salesreps.attribute_category%type,
2413 p_attribute1 IN
2414 ra_cust_trx_line_salesreps.attribute1%type,
2415 p_attribute2 IN
2416 ra_cust_trx_line_salesreps.attribute2%type,
2417 p_attribute3 IN
2418 ra_cust_trx_line_salesreps.attribute3%type,
2419 p_attribute4 IN
2420 ra_cust_trx_line_salesreps.attribute4%type,
2421 p_attribute5 IN
2422 ra_cust_trx_line_salesreps.attribute5%type,
2423 p_attribute6 IN
2424 ra_cust_trx_line_salesreps.attribute6%type,
2425 p_attribute7 IN
2426 ra_cust_trx_line_salesreps.attribute7%type,
2427 p_attribute8 IN
2428 ra_cust_trx_line_salesreps.attribute8%type,
2429 p_attribute9 IN
2430 ra_cust_trx_line_salesreps.attribute9%type,
2431 p_attribute10 IN
2432 ra_cust_trx_line_salesreps.attribute10%type,
2433 p_attribute11 IN
2434 ra_cust_trx_line_salesreps.attribute11%type,
2435 p_attribute12 IN
2436 ra_cust_trx_line_salesreps.attribute12%type,
2437 p_attribute13 IN
2438 ra_cust_trx_line_salesreps.attribute13%type,
2439 p_attribute14 IN
2440 ra_cust_trx_line_salesreps.attribute14%type,
2441 p_attribute15 IN
2442 ra_cust_trx_line_salesreps.attribute15%type,
2443 p_backout_done_flag OUT NOCOPY boolean,
2444 p_status OUT NOCOPY varchar2,
2445 p_revenue_salesgroup_id IN
2446 ra_cust_trx_line_salesreps.revenue_salesgroup_id%type DEFAULT null,
2447 p_non_revenue_salesgroup_id IN
2448 ra_cust_trx_line_salesreps.non_revenue_salesgroup_id%type DEFAULT null)
2449 IS
2450
2451 l_srep_rec ra_cust_trx_line_salesreps%rowtype;
2452
2453 /* bug 3607146 */
2454 l_scredit_count NUMBER;
2455
2456 BEGIN
2457
2458 arp_util.debug('arp_process_salescredit.delete_salescredit_cover()+');
2459
2460 /*------------------------------------------------+
2461 | Populate the salescredit record group with |
2462 | the values passed in as parameters. |
2463 +------------------------------------------------*/
2464
2465 arp_ctls_pkg.set_to_dummy(l_srep_rec);
2466
2467 l_srep_rec.customer_trx_id := p_customer_trx_id;
2468 l_srep_rec.customer_trx_line_id := p_customer_trx_line_id;
2469 l_srep_rec.salesrep_id := p_salesrep_id;
2470 l_srep_rec.revenue_amount_split := p_revenue_amount_split;
2471 l_srep_rec.non_revenue_amount_split := p_non_revenue_amount_split;
2472 l_srep_rec.non_revenue_percent_split := p_non_revenue_percent_split;
2473 l_srep_rec.revenue_percent_split := p_revenue_percent_split;
2474 l_srep_rec.prev_cust_trx_line_salesrep_id
2475 := p_prev_cust_trx_line_srep_id;
2476 l_srep_rec.attribute_category := p_attribute_category;
2477 l_srep_rec.attribute1 := p_attribute1;
2478 l_srep_rec.attribute2 := p_attribute2;
2479 l_srep_rec.attribute3 := p_attribute3;
2480 l_srep_rec.attribute4 := p_attribute4;
2481 l_srep_rec.attribute5 := p_attribute5;
2482 l_srep_rec.attribute6 := p_attribute6;
2483 l_srep_rec.attribute7 := p_attribute7;
2484 l_srep_rec.attribute8 := p_attribute8;
2485 l_srep_rec.attribute9 := p_attribute9;
2486 l_srep_rec.attribute10 := p_attribute10;
2487 l_srep_rec.attribute11 := p_attribute11;
2488 l_srep_rec.attribute12 := p_attribute12;
2489 l_srep_rec.attribute13 := p_attribute13;
2490 l_srep_rec.attribute14 := p_attribute14;
2491 l_srep_rec.attribute15 := p_attribute15;
2492 l_srep_rec.revenue_salesgroup_id := p_revenue_salesgroup_id;
2493 l_srep_rec.non_revenue_salesgroup_id := p_non_revenue_salesgroup_id;
2494
2495 /*-----------------------------------------------+
2496 | Call the standard salescredit entity handler |
2497 +-----------------------------------------------*/
2498
2499 delete_salescredit(
2500 p_form_name,
2501 p_form_version,
2502 p_run_auto_accounting_flag,
2503 p_cust_trx_line_salesrep_id,
2504 p_customer_trx_id,
2505 p_customer_trx_line_id,
2506 l_srep_rec,
2507 p_backout_flag,
2508 p_backout_done_flag,
2509 p_status);
2510
2511 /* bug 3607146 */
2512 arp_rounding.correct_scredit_rounding_errs( p_customer_trx_id,
2513 l_scredit_count);
2514
2515 arp_util.debug('arp_process_salescredit.delete_salescredit_cover()-');
2516
2517 EXCEPTION
2518 WHEN OTHERS THEN
2519
2520 arp_util.debug(
2521 'EXCEPTION: arp_process_salescredit.delete_salescredit_cover()');
2522
2523 arp_util.debug('------- parameters for delete_salescredit_cover() ' ||
2524 '---------');
2525 arp_util.debug('p_form_name = ' || p_form_name );
2526 arp_util.debug('p_form_version = ' || p_form_version );
2527 arp_util.debug('p_run_auto_accounting_flag = ' ||
2528 arp_trx_util.boolean_to_varchar2(p_run_auto_accounting_flag) );
2529 arp_util.debug('p_backout_flag = ' ||
2530 arp_trx_util.boolean_to_varchar2(p_backout_flag));
2531 arp_util.debug('p_customer_trx_id = ' || p_customer_trx_id );
2532 arp_util.debug('p_customer_trx_line_id = ' ||
2533 p_customer_trx_line_id );
2534 arp_util.debug('p_salesrep_id = ' ||
2535 p_salesrep_id );
2536 arp_util.debug('p_revenue_amount_split = ' ||
2537 p_revenue_amount_split );
2538 arp_util.debug('p_non_revenue_amount_split = ' ||
2539 p_non_revenue_amount_split );
2540 arp_util.debug('p_non_revenue_percent_split = ' ||
2541 p_non_revenue_percent_split );
2542 arp_util.debug('p_revenue_percent_split = ' ||
2543 p_revenue_percent_split );
2544 arp_util.debug('p_prev_cust_trx_line_srep_id = ' ||
2545 p_prev_cust_trx_line_srep_id );
2546 arp_util.debug('p_attribute_category = ' ||
2547 p_attribute_category );
2548 arp_util.debug('p_attribute1 = ' || p_attribute1 );
2549 arp_util.debug('p_attribute2 = ' || p_attribute2 );
2550 arp_util.debug('p_attribute3 = ' || p_attribute3 );
2551 arp_util.debug('p_attribute4 = ' || p_attribute4 );
2552 arp_util.debug('p_attribute5 = ' || p_attribute5 );
2553 arp_util.debug('p_attribute6 = ' || p_attribute6 );
2554 arp_util.debug('p_attribute7 = ' || p_attribute7 );
2555 arp_util.debug('p_attribute8 = ' || p_attribute8 );
2556 arp_util.debug('p_attribute9 = ' || p_attribute9 );
2557 arp_util.debug('p_attribute10 = ' || p_attribute10 );
2558 arp_util.debug('p_attribute11 = ' || p_attribute11 );
2559 arp_util.debug('p_attribute12 = ' || p_attribute12 );
2560 arp_util.debug('p_attribute13 = ' || p_attribute13 );
2561 arp_util.debug('p_attribute14 = ' || p_attribute14 );
2562 arp_util.debug('p_attribute15 = ' || p_attribute15 );
2563 arp_util.debug('p_revenue_salesgroup_id = ' || p_revenue_salesgroup_id );
2564 arp_util.debug('p_non_revenue_salesgroup_id = ' || p_non_revenue_salesgroup_id );
2565
2566 RAISE;
2567
2568 END;
2569
2570 /*---------------------------------------------+
2571 | Package initialization section. |
2572 +---------------------------------------------*/
2573
2574 BEGIN
2575
2576 pg_number_dummy := arp_ctls_pkg.get_number_dummy;
2577
2578 /* Bug 3607146 */
2579 pg_base_precision := arp_global.base_precision;
2580 pg_base_min_acc_unit := arp_global.base_min_acc_unit;
2581 pg_trx_header_level_rounding := arp_global.sysparam.trx_header_level_rounding;
2582
2583 END ARP_PROCESS_SALESCREDIT;