[Home] [Help]
PACKAGE BODY: APPS.ARP_PROCESS_LINE
Source
1 PACKAGE BODY ARP_PROCESS_LINE AS
2 /* $Header: ARTECTLB.pls 120.20.12020000.2 2012/11/14 11:35:52 dgaurab ship $ */
3
4
5 pg_base_curr_code fnd_currencies.currency_code%type;
6 pg_base_precision fnd_currencies.precision%type;
7 pg_base_min_acct_unit fnd_currencies.minimum_accountable_unit%type;
8 pg_earliest_date date;
9
10
11 AR_NUMBER_DUMMY CONSTANT NUMBER(15) := -999999999999999;
12
13 /*===========================================================================+
14 | PROCEDURE |
15 | make_incomplete |
16 | |
17 | DESCRIPTION |
18 | Sets complete_flag in ra_customer_trx to No. |
19 | |
20 | SCOPE - PRIVATE |
21 | |
22 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED |
23 | arp_util.debug |
24 | |
25 | ARGUMENTS : IN: |
26 | p_customer_trx_id |
27 | OUT: |
28 | IN/ OUT: |
29 | |
30 | RETURNS : NONE |
31 | |
32 | NOTES |
33 | |
34 | MODIFICATION HISTORY |
35 | 17-MAY-96 Martin Johnson Created |
36 | |
37 +===========================================================================*/
38
39 PG_DEBUG varchar2(1) := NVL(FND_PROFILE.value('AFLOG_ENABLED'), 'N');
40
41 PROCEDURE make_incomplete( p_customer_trx_id IN
42 ra_customer_trx.customer_trx_id%type )
43 IS
44
45 l_trx_rec ra_customer_trx%rowtype;
46
47 BEGIN
48
49 IF PG_DEBUG in ('Y', 'C') THEN
50 arp_util.debug('arp_process_line.make_incomplete()+');
51 END IF;
52
53 arp_ct_pkg.set_to_dummy( l_trx_rec );
54
55 l_trx_rec.complete_flag := 'N';
56
57 arp_ct_pkg.update_p( l_trx_rec,
58 p_customer_trx_id );
59
60 IF PG_DEBUG in ('Y', 'C') THEN
61 arp_util.debug('arp_process_line.make_incomplete()-');
62 END IF;
63
64 EXCEPTION
65 WHEN OTHERS THEN
66 IF PG_DEBUG in ('Y', 'C') THEN
67 arp_util.debug('EXCEPTION: arp_process_line.make_incomplete()');
68 arp_util.debug('make_incomplete: ' || '');
69 arp_util.debug('---------- parameters for make_incomplete() ---------');
70 arp_util.debug('make_incomplete: ' || 'p_customer_trx_id = ' || p_customer_trx_id );
71 END IF;
72
73 RAISE;
74
75 END make_incomplete;
76
77 /*===========================================================================+
78 | PROCEDURE |
79 | get_commitment_line_id |
80 | |
81 | DESCRIPTION |
82 | Returns the id for the commitment line |
83 | |
84 | SCOPE - PRIVATE |
85 | |
86 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED |
87 | arp_util.debug |
88 | |
89 | ARGUMENTS : IN: |
90 | p_customer_trx_id |
91 | OUT: |
92 | p_commitment_line_id |
93 | IN/ OUT: |
94 | |
95 | RETURNS : NONE |
96 | |
97 | NOTES |
98 | |
99 | MODIFICATION HISTORY |
100 | 17-MAY-96 Martin Johnson Created |
101 | |
102 +===========================================================================*/
103 PROCEDURE get_commitment_line_id(
104 p_customer_trx_id IN ra_customer_trx.customer_trx_id%type,
105 p_commitment_line_id OUT NOCOPY ra_customer_trx_lines.customer_trx_line_id%type )
106 IS
107 BEGIN
108
109 IF PG_DEBUG in ('Y', 'C') THEN
110 arp_util.debug('arp_process_line.get_commitment_line_id()+');
111 END IF;
112
113 BEGIN
114
115 SELECT customer_trx_line_id
116 INTO p_commitment_line_id
117 FROM ra_customer_trx_lines ctl,
118 ra_customer_trx ct
119 WHERE ct.customer_trx_id = p_customer_trx_id
120 AND ctl.customer_trx_id = ct.initial_customer_trx_id;
121 EXCEPTION
122 WHEN NO_DATA_FOUND THEN
123 null;
124 WHEN OTHERS THEN
125 RAISE;
126 END;
127
128 IF PG_DEBUG in ('Y', 'C') THEN
129 arp_util.debug('arp_process_line.get_commitment_line_id()-');
130 END IF;
131
132 EXCEPTION
133 WHEN OTHERS THEN
134 IF PG_DEBUG in ('Y', 'C') THEN
135 arp_util.debug('EXCEPTION: arp_process_line.get_commitment_line_id()');
136 arp_util.debug('------ parameters for get_commitment_line_id() -----');
137 arp_util.debug('p_customer_trx_id = ' || p_customer_trx_id );
138 END IF;
139
140 RAISE;
141
142 END get_commitment_line_id;
143
144
145 /*===========================================================================+
146 | PROCEDURE |
147 | set_flags |
148 | |
149 | DESCRIPTION |
150 | Sets various change and status flags for the current record. |
151 | |
152 | SCOPE - PRIVATE |
153 | |
154 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED |
155 | arp_util.debug |
156 | |
157 | ARGUMENTS : IN: |
158 | p_line_rec |
159 | p_customer_trx_line_id |
160 | p_old_line_rec |
161 | OUT: |
162 | p_derive_gldate_flag |
163 | p_amount_changed_flag |
164 | p_last_period_changed_flag |
165 | IN/ OUT: |
166 | None |
167 | |
168 | RETURNS : NONE |
169 | |
170 | NOTES |
171 | |
172 | MODIFICATION HISTORY |
173 | 17-JUL-95 Charlie Tomberg Created |
174 | 17-JAN-96 Martin Johnson Added parameter |
175 | p_last_period_changed_flag |
176 | 11-AUG-97 OSTEINME changed logic for Rel. 11 tax inclusive|
177 | feature to deal with gross amounts |
178 | 01-JAN-00 SNAMBIAR Bug 1158952 Modified set_flags() |
179 | procedure to add NVL() to |
180 | p_line_rec.gross_extended_amount |
181 | |
182 | 08-Jun-04 Naruhiko Yanagita Bug:3678009 |
183 | Added a condition for unit_selling_price|
184 +===========================================================================*/
185
186 PROCEDURE set_flags( p_line_rec IN ra_customer_trx_lines%rowtype,
187 p_old_line_rec IN ra_customer_trx_lines%rowtype,
188 p_customer_trx_line_id IN
189 ra_customer_trx_lines.customer_trx_line_id%type,
190 p_derive_gl_date_flag OUT NOCOPY boolean,
191 p_amount_changed_flag OUT NOCOPY boolean,
192 p_last_period_changed_flag OUT NOCOPY boolean) IS
193
194 l_derive_gl_date_flag boolean;
195 l_amount_changed_flag boolean;
196 l_last_period_changed_flag boolean;
197
198 BEGIN
199
200 arp_util.debug('arp_process_line.set_flags()+');
201
202
203 /*--------------------------------+
204 | Set the flags appropriately |
205 +--------------------------------*/
206
207 /* Rel. 10 code:
208 IF ( p_old_line_rec.extended_amount = p_line_rec.extended_amount )
209 THEN l_amount_changed_flag := FALSE;
210 ELSE l_amount_changed_flag := TRUE;
211 END IF;
212 */
213
214 /* Rel. 11 code: */
215 /* Bug 1158952. Added NVL() to p_line_rec.gross_extended_amount */
216
217 IF (NVL(p_old_line_rec.gross_extended_amount,
218 p_old_line_rec.extended_amount) =
219 NVL(p_line_rec.gross_extended_amount,
220 p_line_rec.extended_amount))
221 AND
222 NVL(p_old_line_rec.vat_tax_id,-123) =
223 NVL(p_line_rec.vat_tax_id, -123)
224 AND
225 NVL(p_old_line_rec.amount_includes_tax_flag, 'X') =
226 NVL(p_line_rec.amount_includes_tax_flag, 'X')
227 /* Bug:3678009 Added the condition for unit_selling_price */
228 AND
229 NVL(p_old_line_rec.gross_unit_selling_price,
230 nvl(p_old_line_rec.unit_selling_price,0.000000000000000001))=
231 NVL(p_line_rec.gross_unit_selling_price,
232 nvl(p_line_rec.unit_selling_price,0.000000000000000001))
233 THEN
234 l_amount_changed_flag := FALSE;
235 ELSE
236 l_amount_changed_flag := TRUE;
237 END IF;
238
239
240 IF (
241 nvl(p_old_line_rec.accounting_rule_id, 0) <>
242 nvl(p_line_rec.accounting_rule_id, 0)
243 OR
244 nvl(p_old_line_rec.accounting_rule_duration, -1) <>
245 nvl(p_line_rec.accounting_rule_duration, -1)
246 OR
247 nvl(p_old_line_rec.rule_start_date, pg_earliest_date) <>
248 nvl(p_line_rec.rule_start_date, pg_earliest_date)
249 )
250 THEN l_derive_gl_date_flag := TRUE;
251 ELSE l_derive_gl_date_flag := FALSE;
252 END IF;
253
254 IF ( nvl(p_old_line_rec.last_period_to_credit, -1) =
255 nvl(p_line_rec.last_period_to_credit, -1) )
256 THEN l_last_period_changed_flag := FALSE;
257 ELSE l_last_period_changed_flag := TRUE;
258 END IF;
259
260 p_derive_gl_date_flag := l_derive_gl_date_flag;
261 p_amount_changed_flag := l_amount_changed_flag;
262 p_last_period_changed_flag := l_last_period_changed_flag;
263
264 /*------------------------+
265 | Print out NOCOPY the results |
266 +------------------------*/
267
268 arp_util.debug('l_derive_gl_date_flag = ' ||
269 arp_trx_util.boolean_to_varchar2( l_derive_gl_date_flag ));
270 arp_util.debug('l_amount_changed_flag = ' ||
271 arp_trx_util.boolean_to_varchar2( l_amount_changed_flag ));
272 arp_util.debug('l_last_period_changed_flag = ' ||
273 arp_trx_util.boolean_to_varchar2(
274 l_last_period_changed_flag ));
275
276 arp_util.debug('arp_process_line.set_flags()-');
277
278
279 EXCEPTION
280 WHEN OTHERS THEN
281
282 /*---------------------------------------------+
283 | Display parameters and raise the exception |
284 +---------------------------------------------*/
285
286 arp_util.debug('EXCEPTION: arp_process_line.set_flags()');
287
288 arp_util.debug('');
289 arp_util.debug('---------- parameters for set_flags() ---------');
290
291 arp_util.debug('p_customer_trx_line_id = ' ||
292 p_customer_trx_line_id);
293
294 arp_util.debug('');
295
296 arp_util.debug('---------- old line record ----------');
297 arp_ctl_pkg.display_line_rec( p_old_line_rec );
298 arp_util.debug('');
299
300 arp_util.debug('---------- new line record ----------');
301 arp_ctl_pkg.display_line_rec( p_line_rec );
302 arp_util.debug('');
303
304 RAISE;
305
306 END;
307
308 /*===========================================================================+
309 | PROCEDURE |
310 | line_rerun_aa |
311 | |
312 | DESCRIPTION |
313 | Reruns AutoAccounting for Revenue and Charges. |
314 | |
315 | SCOPE - PRIVATE |
316 | |
317 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED |
318 | arp_util.debug |
319 | |
320 | ARGUMENTS : IN: |
321 | p_customer_trx_id |
322 | p_customer_trx_line_id |
323 | OUT: |
324 | None |
325 | IN/ OUT: |
326 | None |
327 | |
328 | RETURNS : NONE |
329 | |
330 | NOTES |
331 | |
332 | MODIFICATION HISTORY |
333 | 25-JUL-95 Charlie Tomberg Created |
334 | |
335 +===========================================================================*/
336
337 PROCEDURE line_rerun_aa(
338 p_customer_trx_id IN
339 ra_customer_trx.customer_trx_id%type,
340 p_customer_trx_line_id IN
341 ra_customer_trx_lines.customer_trx_line_id%type
342 ) IS
343
344 l_ccid binary_integer;
345 l_concat_segments varchar2(2000);
346 l_num_failed_dist_rows binary_integer;
347
348 BEGIN
349
350 arp_util.debug('arp_process_line.line_rerun_aa()+');
351
352 BEGIN
353 arp_auto_accounting.do_autoaccounting
354 (
355 'U',
356 'ALL',
357 p_customer_trx_id,
358 p_customer_trx_line_id,
359 null,
360 null,
361 null,
362 null,
363 null,
364 null,
365 null,
366 null,
367 null,
368 null,
369 null,
370 l_ccid,
371 l_concat_segments,
372 l_num_failed_dist_rows);
373 EXCEPTION
374 WHEN NO_DATA_FOUND THEN
375 null;
376 WHEN OTHERS THEN
377 RAISE;
378 END;
379
380 arp_util.debug('arp_process_line.line_rerun_aa()-');
381
382 EXCEPTION
383 WHEN OTHERS THEN
384
385 arp_util.debug('EXCEPTION: arp_process_line.line_rerun_aa()');
386
387
388 /*---------------------------------------------+
389 | Display parameters and raise the exception |
390 +---------------------------------------------*/
391
392 arp_util.debug('');
393 arp_util.debug('---------- parameters for line_rerun_aa() ---------');
394
395 arp_util.debug('p_customer_trx_id = ' ||
396 p_customer_trx_id);
397
398 arp_util.debug('p_customer_trx_line_id = ' ||
399 p_customer_trx_line_id);
400
401 arp_util.debug('');
402
403 RAISE;
404
405 END;
406
407
408 /*===========================================================================+
409 | PROCEDURE |
410 | header_fright_only_rules_case |
411 | |
412 | DESCRIPTION |
413 | Converts the transaction from a transaction with rules to one that does |
414 | not use rules. This happens in the case where the last line of type |
415 | line has been deleted and the transaction only contains a header |
416 | freight record. |
417 | |
418 | SCOPE - PRIVATE |
419 | |
420 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED |
421 | arp_util.debug |
422 | |
423 | ARGUMENTS : IN: |
424 | p_customer_trx_id |
425 | p_trx_amount |
426 | p_exchange_rate |
427 | p_gl_date |
428 | OUT: |
429 | None |
430 | |
431 | RETURNS : NONE |
432 | |
433 | NOTES |
434 | |
435 | MODIFICATION HISTORY |
436 | 25-JUL-95 Charlie Tomberg Created |
437 | |
438 +===========================================================================*/
439
440
441 PROCEDURE header_freight_only_rules_case(
442 p_customer_trx_id IN
443 ra_customer_trx.customer_trx_id%type,
444 p_trx_amount IN number,
445 p_exchange_rate IN
446 ra_customer_trx.exchange_rate%type,
447 p_gl_date IN
448 ra_cust_trx_line_gl_dist.gl_date%type
449 )
450 IS
451
452 l_trx_rec ra_customer_trx%rowtype;
453 l_dist_rec ra_cust_trx_line_gl_dist%rowtype;
454
455 BEGIN
456
457 arp_util.debug('arp_process_line.header_freight_only_rules_case()+');
458
459 IF (arp_trx_util.detect_freight_only_rules_case( p_customer_trx_id ) = TRUE)
460 THEN
461
462 /*-----------------------------------------------------+
463 | Null out NOCOPY the invoicing rule ID of the transaction |
464 +-----------------------------------------------------*/
465
466 arp_ct_pkg.set_to_dummy( l_trx_rec );
467 l_trx_rec.invoicing_rule_id := '';
468
469 arp_ct_pkg.update_p( l_trx_rec,
470 p_customer_trx_id );
471
472
473 /*---------------------------------------------------------+
474 | update the account sets to be real dists. |
475 | inv rule is cleared by the form at complete time |
476 | or when all 'line' lines are deleted |
477 | if rules and freight only invoice. |
478 | Reason is that the Revenue Recognition Program |
479 | cannot handle freight only transactions with rules. |
480 | |
481 | There are two dists in this case: |
482 | o The REC dist |
483 | o The FREIGHT dist |
484 +---------------------------------------------------------*/
485
486 arp_ctlgd_pkg.set_to_dummy(l_dist_rec);
487
488 l_dist_rec.account_set_flag := 'N';
489
490
491 l_dist_rec.acctd_amount := arpcurr.functional_amount(
492 p_trx_amount,
493 pg_base_curr_code,
494 p_exchange_rate,
495 pg_base_precision,
496 pg_base_min_acct_unit);
497
498 l_dist_rec.amount := p_trx_amount;
499 l_dist_rec.gl_date := p_gl_date;
500 l_dist_rec.original_gl_date := p_gl_date;
501
502 arp_ctlgd_pkg.update_f_ct_id(l_dist_rec,
503 p_customer_trx_id,
504 null,
505 null);
506
507 END IF;
508
509 arp_util.debug('arp_process_line.header_freight_only_rules_case()-');
510
511 EXCEPTION
512 WHEN OTHERS THEN
513 arp_util.debug(
514 'EXCEPTION: arp_process_line.header_freight_only_rules_case()');
515
516 arp_util.debug('');
517 arp_util.debug('-- parameters for header_freight_only_rules_case() --');
518
519 arp_util.debug('p_customer_trx_id = ' || p_customer_trx_id);
520 arp_util.debug('p_trx_amount = ' || p_trx_amount);
521 arp_util.debug('p_exchange_rate = ' || p_exchange_rate);
522 arp_util.debug('p_gl_date = ' || p_gl_date);
523
524 RAISE;
525
526 END;
527
528 /*===========================================================================+
529 | PROCEDURE |
530 | val_insert_line |
531 | |
532 | DESCRIPTION |
533 | Does validation that is required when a new line is inserted. |
534 | |
535 | SCOPE - PRIVATE |
536 | |
537 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED |
538 | arp_util.debug |
539 | |
540 | ARGUMENTS : IN: |
541 | p_line_rec |
542 | OUT: |
543 | None |
544 | |
545 | RETURNS : NONE |
546 | |
547 | NOTES |
548 | |
549 | MODIFICATION HISTORY |
550 | 24-JUL-95 Charlie Tomberg Created |
551 | 31-JAN-96 Martin Johnson Added call to |
552 | arp_dates.val_gl_periods_for_rules. |
553 | Changed l_line_rec.set_of_books_id to |
554 | arp_global.set_of_books_id. |
555 | 06-FEB-96 Martin Johnson Don't call val_gl_periods_for_rules |
556 | for CM's because CM module will |
557 | derive the correct values later |
558 | |
559 +===========================================================================*/
560
561
562 PROCEDURE val_insert_line ( p_line_rec IN ra_customer_trx_lines%rowtype ) IS
563
564
565 BEGIN
566
567 arp_util.debug('arp_process_line.val_insert_line()+');
568
569 arp_trx_validate.check_dup_line_number(p_line_rec.line_number,
570 p_line_rec.customer_trx_id,
571 null);
572
573 /*----------------------------------------------------------------------+
574 | Don't call val_gl_periods_for_rules for CM's because CM module will |
575 | derive correct accounting_rule_duration and rule_start_date later |
576 +----------------------------------------------------------------------*/
577
578 IF ( p_line_rec.previous_customer_trx_id IS NULL )
579 THEN
580 arp_dates.val_gl_periods_for_rules(
581 null, -- p_request_id
582 p_line_rec.accounting_rule_id,
583 p_line_rec.accounting_rule_duration,
584 p_line_rec.rule_start_date,
585 arp_global.set_of_books_id );
586 END IF;
587
588 arp_util.debug('arp_process_line.val_insert_line()-');
589
590 EXCEPTION
591 WHEN OTHERS THEN
592 arp_util.debug('EXCEPTION: arp_process_line.val_insert_line()');
593
594 arp_util.debug('');
595 arp_util.debug('------ parameters for val_insert_line() -------');
596
597 arp_ctl_pkg.display_line_rec(p_line_rec);
598
599 RAISE;
600
601 END;
602
603 /*===========================================================================+
604 | PROCEDURE |
605 | val_update_line |
606 | |
607 | DESCRIPTION |
608 | Does validation that is required when a line is updated. |
609 | |
610 | SCOPE - PRIVATE |
611 | |
612 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED |
613 | arp_util.debug |
614 | |
615 | ARGUMENTS : IN: |
616 | p_line_rec - The line rec with the changed colums |
617 | p_db_line_rec - The old line record |
618 | p_new_line_rec - Contains old rec + updated columns |
619 | OUT: |
620 | None |
621 | |
622 | RETURNS : NONE |
623 | |
624 | NOTES |
625 | |
626 | MODIFICATION HISTORY |
627 | 24-JUL-95 Charlie Tomberg Created |
628 | 31-JAN-96 Martin Johnson Changed l_line_rec.set_of_books_id to |
629 | arp_global.set_of_books_id. |
630 | 06-FEB-96 Martin Johnson Don't call val_gl_periods_for_rules |
631 | for CM's because CM module will |
632 | derive the correct values later |
633 | |
634 +===========================================================================*/
635
636
637 PROCEDURE val_update_line ( p_line_rec IN ra_customer_trx_lines%rowtype,
638 p_db_line_rec IN ra_customer_trx_lines%rowtype,
639 p_new_line_rec OUT NOCOPY ra_customer_trx_lines%rowtype )
640 IS
641
642 l_errorbuf varchar2(200);
643
644 l_line_rec ra_customer_trx_lines%rowtype;
645
646 BEGIN
647
648 arp_util.debug('arp_process_line.val_update_line()+');
649
650
651 arp_ctl_pkg.merge_line_recs( p_db_line_rec,
652 p_line_rec,
653 l_line_rec );
654
655 p_new_line_rec := l_line_rec;
656
657 /*------------------------------------------+
658 | Verify the line is of the correct type |
659 +------------------------------------------*/
660
661 IF (l_line_rec.line_type not in ('LINE', 'CHARGES', 'CB') )
662 THEN
663 arp_util.debug('EXCEPTION: arp_process_line.val_update_line()');
664 arp_util.debug(
665 'The specified line is not of type LINE, CHARGES or CB');
666 fnd_message.set_name('AR', 'C-1647');
667 app_exception.raise_exception;
668 END IF;
669
670 arp_trx_validate.check_dup_line_number(l_line_rec.line_number,
671 l_line_rec.customer_trx_id,
672 p_db_line_rec.customer_trx_line_id);
673
674 /*----------------------------------------------------------------------+
675 | Don't call val_gl_periods_for_rules for CM's because CM module will |
676 | derive correct accounting_rule_duration and rule_start_date later |
677 +----------------------------------------------------------------------*/
678
679 IF ( p_line_rec.previous_customer_trx_id IS NULL )
680 THEN
681 arp_dates.val_gl_periods_for_rules(
682 null, -- p_request_id
683 l_line_rec.accounting_rule_id,
684 l_line_rec.accounting_rule_duration,
685 l_line_rec.rule_start_date,
686 arp_global.set_of_books_id );
687 END IF;
688
689 arp_util.debug('arp_process_line.val_update_line()-');
690
691
692 EXCEPTION
693 WHEN OTHERS THEN
694 arp_util.debug('EXCEPTION: arp_process_line.val_update_line()');
695
696 arp_util.debug('');
697 arp_util.debug('------ parameters for val_update_line() -------');
698
699 arp_util.debug('');
700 arp_util.debug('------ new line record -------');
701 arp_ctl_pkg.display_line_rec(p_line_rec);
702
703 arp_util.debug('');
704 arp_util.debug('------ old line record -------');
705 arp_ctl_pkg.display_line_rec(p_db_line_rec);
706
707 arp_util.debug('');
708 arp_util.debug('------ merged line record -------');
709 arp_ctl_pkg.display_line_rec(l_line_rec);
710
711 RAISE;
712
713 END;
714
715 /*===========================================================================+
716 | PROCEDURE |
717 | val_delete_line |
718 | |
719 | DESCRIPTION |
720 | Does validation that is required when a line is deleted. |
721 | |
722 | SCOPE - PRIVATE |
723 | |
724 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED |
725 | arp_util.debug |
726 | |
727 | ARGUMENTS : IN: |
728 | p_line_rec |
729 | p_complete_flag |
730 | OUT: |
731 | None |
732 | |
733 | RETURNS : NONE |
734 | |
735 | NOTES |
736 | |
737 | MODIFICATION HISTORY |
738 | 24-JUL-95 Charlie Tomberg Created |
739 | |
740 +===========================================================================*/
741
742
743 PROCEDURE val_delete_line ( p_line_rec IN ra_customer_trx_lines%rowtype,
744 p_complete_flag IN
745 ra_customer_trx.complete_flag%type ) IS
746
747
748 BEGIN
749
750 arp_util.debug('arp_process_line.val_delete_line()+');
751
752 IF ( p_complete_flag = 'Y' )
753 THEN arp_trx_validate.check_has_one_line( p_line_rec.customer_trx_id );
754 END IF;
755
756
757 arp_util.debug('arp_process_line.val_delete_line()-');
758
759 EXCEPTION
760 WHEN OTHERS THEN
761 arp_util.debug('EXCEPTION: arp_process_line.val_delete_line()');
762
763 arp_util.debug('');
764 arp_util.debug('------ parameters for val_delete_line() -------');
765
766 arp_util.debug('p_complete_flag = ' || p_complete_flag);
767
768 arp_ctl_pkg.display_line_rec(p_line_rec);
769
770 RAISE;
771
772 END;
773
774 /*===========================================================================+
775 | PROCEDURE |
776 | insert_line |
777 | |
778 | DESCRIPTION |
779 | Inserts a record into ra_customer_trx_lines. |
780 | |
781 | SCOPE - PUBLIC |
782 | |
783 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED |
784 | arp_util.debug |
785 | |
786 | ARGUMENTS : IN: |
787 | p_form_name |
788 | p_form_version |
789 | p_line_rec |
790 | p_memo_line_type |
791 | p_currency_code |
792 | OUT: |
793 | p_customer_trx_line_id |
794 | p_rule_start_date |
795 | p_accounting_rule_duration |
796 | p_status |
797 | IN/ OUT: |
798 | p_gl_date |
799 | p_trx_date |
800 | |
801 | RETURNS : NONE |
802 | |
803 | NOTES |
804 | |
805 | MODIFICATION HISTORY |
806 | 24-JUL-95 Charlie Tomberg Created |
807 | 15-JAN-96 Martin Johnson Added call to credit memo module. |
808 | Added OUT NOCOPY parameters |
809 | p_rule_start_date |
810 | and p_accounting_rule_duration |
811 | 06-FEB-96 Martin Johnson Don't call tax engine if trx is a |
812 | debit memo reversal |
813 | 08-FEB-96 Martin Johnson Call arp_dates.derive_gl_trx_dates_ |
814 | from_rules() and added IN OUT NOCOPY |
815 | parameters p_gl_date and p_trx_date. |
816 | 15-MAY-96 Martin Johnson BugNo:356814. Added OUT NOCOPY param |
817 | p_status. Call calculate_tax_f_ctl_ |
818 | id in 'DEFERRED' mode so that |
819 | 'soft' exception will be raised. |
820 | 01-JUL-96 Simon Leung Do not call the tax engine if the |
821 | memo line type is TAX, FREIGHT or |
822 | CHARGES. |
823 | |
824 | Rel 11 Changes: |
825 | |
826 | 04-AUG-97 OSTEINME Added new parameters p_header_currency_code |
827 | p_header_exchange_rate |
828 | changed p_line_rec to IN OUT NOCOPY |
829 | |
830 +===========================================================================*/
831
832
833 PROCEDURE insert_line(
834 p_form_name IN varchar2,
835 p_form_version IN number,
836 p_line_rec IN OUT NOCOPY ra_customer_trx_lines%rowtype,
837 p_memo_line_type IN ar_memo_lines.line_type%type,
838 p_customer_trx_line_id OUT NOCOPY
839 ra_customer_trx_lines.customer_trx_line_id%type,
840 p_trx_class IN ra_cust_trx_types.type%type
841 DEFAULT NULL,
842 p_ccid1 IN
843 gl_code_combinations.code_combination_id%type
844 DEFAULT NULL,
845 p_ccid2 IN
846 gl_code_combinations.code_combination_id%type
847 DEFAULT NULL,
848 p_amount1 IN ra_cust_trx_line_gl_dist.amount%type
849 DEFAULT NULL,
850 p_amount2 IN ra_cust_trx_line_gl_dist.amount%type
851 DEFAULT NULL,
852 p_rule_start_date OUT NOCOPY
853 ra_customer_trx_lines.rule_start_date%type,
854 p_accounting_rule_duration OUT NOCOPY
855 ra_customer_trx_lines.accounting_rule_duration%type,
856 p_gl_date IN OUT NOCOPY
857 ra_cust_trx_line_gl_dist.gl_date%type,
858 p_trx_date IN OUT NOCOPY
859 ra_customer_trx.trx_date%type,
860 p_header_currency_code IN
861 ra_customer_trx.invoice_currency_code%type
862 DEFAULT NULL,
863 p_header_exchange_rate IN ra_customer_trx.exchange_rate%type
864 DEFAULT NULL,
865 p_status OUT NOCOPY varchar2,
866 p_run_autoacc_flag IN varchar2 DEFAULT 'Y',
867 p_run_tax_flag IN varchar2 DEFAULT 'Y',
868 p_create_salescredits_flag IN VARCHAR2 DEFAULT 'Y' )
869
870 IS
871
872 l_ccid number;
873 l_concat_segments varchar2(2000);
874 l_num_failed_dist_rows number;
875 l_errorbuf varchar2(200);
876 l_result number;
877
878 l_customer_trx_line_id ra_customer_trx_lines.customer_trx_line_id%type;
879 l_new_tax_amount NUMBER;
880
881 l_failure_count number;
882 l_rule_start_date ra_customer_trx_lines.rule_start_date%type;
883 l_accounting_rule_duration
884 ra_customer_trx_lines.accounting_rule_duration%type;
885
886 l_recalculate_tax_flag boolean;
887 l_status1 varchar2(100);
888 l_status2 varchar2(100);
889 l_status3 varchar2(100);
890 l_status4 varchar2(100);
891
892 l_commitment_line_id ra_customer_trx_lines.customer_trx_line_id%type;
893 l_line_rec ra_customer_trx_lines%rowtype;
894
895 l_extended_amount NUMBER;
896 l_unit_selling_price NUMBER;
897 l_gross_extended_amount NUMBER;
898 l_gross_unit_selling_price NUMBER;
899
900 --Bug#2750340
901 l_ev_rec arp_xla_events.xla_events_type;
902 /*Bug 3130851 and bug 3407389*/
903 l_dist_rec ra_cust_trx_line_gl_dist%rowtype;
904 l_dist_line ra_cust_trx_line_gl_dist.customer_trx_line_id%type;
905 l_tax_computed BOOLEAN;
906 l_action VARCHAR2(12);
907 l_count NUMBER;
908
909 l_mode VARCHAR2(50);
910 l_called_from VARCHAR2(20) := NULL;
911 BEGIN
912
913 arp_util.debug('arp_process_line.insert_line()+');
914
915 arp_util.debug('ARTECTLB: p_line_rec.amount_includes_tax_flag = ' || p_line_rec.amount_includes_tax_flag);
916
917 p_rule_start_date := p_line_rec.rule_start_date;
918 p_accounting_rule_duration := p_line_rec.accounting_rule_duration;
919
920 /*----------------------------------------------+
921 | Check the form version to determine if it |
922 | is compatible with the entity handler. |
923 +----------------------------------------------*/
924
925 arp_trx_validate.ar_entity_version_check(p_form_name, p_form_version);
926
927 /*-------------------------+
928 | Do required validation |
929 +-------------------------*/
930
931 arp_process_line.val_insert_line(p_line_rec);
932
933 /*----------------------------------------------------------------+
934 | Lock rows in other tables that reference this customer_trx_id |
935 +----------------------------------------------------------------*/
936
937 arp_trx_util.lock_transaction(p_line_rec.customer_trx_id);
938
939 l_line_rec := p_line_rec;
940
941 IF (l_line_rec.initial_customer_trx_line_id IS NULL) THEN
942 get_commitment_line_id(p_line_rec.customer_trx_id,
943 l_commitment_line_id);
944
945 l_line_rec.initial_customer_trx_line_id := l_commitment_line_id;
946 END IF;
947
948 /*----------------------------------------------+
949 | Call the table handler to insert the line |
950 +----------------------------------------------*/
951
952 arp_util.debug('ARTECTLB: l_line_rec.amount_includes_tax_flag = ' || l_line_rec.amount_includes_tax_flag);
953
954 arp_ctl_pkg.insert_p( l_line_rec,
955 l_customer_trx_line_id);
956
957
958 p_customer_trx_line_id := l_customer_trx_line_id;
959
960 /*---------------------------------------------+
961 | If trx is not a CM and there are rules, |
962 | derive the gl_date and trx_date |
963 +---------------------------------------------*/
964
965 IF ( ( p_trx_class <> 'CM' )
966 AND
967 ( p_line_rec.accounting_rule_id IS NOT NULL )
968 )
969 THEN
970
971 arp_dates.derive_gl_trx_dates_from_rules(
972 p_line_rec.customer_trx_id,
973 p_gl_date,
974 p_trx_date,
975 l_recalculate_tax_flag );
976 END IF;
977
978 IF (p_create_salescredits_flag = 'Y')
979 THEN
980 arp_process_salescredit.create_line_salescredits(
981 p_line_rec.customer_trx_id,
982 l_customer_trx_line_id,
983 p_memo_line_type,
984 'N',
985 'N',
986 l_status1 );
987 END IF;
988
989 /* ----------------------------------------------------------------
990 Bug 5054198 the condition needs to be modified so that
991 line_Det_Factors handler is also called for Freight and Charges
992
993 Bug 5197390 -- removed TAX from the excluded condition. memo
994 lines of type 'TAX' are tax-only transactions and need det factors
995
996 Bug 6346105 - Removed 'CHARGES' conditon. Now line_det_factors()
997 is called for 'CHARGES' memo line type also.
998 ------------------------------------------------------------------*/
999
1000 IF ( p_trx_class NOT IN ( 'CB', 'DM_REV' ) AND
1001 p_run_tax_flag = 'Y'
1002 )
1003 THEN
1004
1005 /*-----------------------------------------------------------------+
1006 | Call Tax Engine, calculating tax for this invoice line. |
1007 +-----------------------------------------------------------------*/
1008
1009 BEGIN
1010
1011 arp_util.debug(
1012 'arp_process_line.insert_line before create_tax_f_ctl_id');
1013
1014 -- Rel. 11: call to new tax engine procedure
1015 -- to handle tax-inclusive case:
1016
1017 l_extended_amount := p_line_rec.extended_amount;
1018 l_unit_selling_price := p_line_rec.unit_selling_price;
1019
1020 arp_util.debug('**** Before calling Calculate TAX ****');
1021 arp_util.debug(' Parameters:');
1022 arp_util.debug(' l_customer_trx_line_id = ' || l_customer_trx_line_id);
1023 arp_util.debug(' l_extended_amount = ' || l_extended_amount);
1024 arp_util.debug(' l_unit_selling_price = ' || l_unit_selling_price);
1025 arp_util.debug(' p_header_currency_code = ' || p_header_currency_code);
1026 arp_util.debug(' p_header_exchange_rate = ' || p_header_exchange_rate);
1027
1028
1029 /* 5197390 - Handle tax-type memo lines */
1030 IF p_memo_line_type = 'TAX'
1031 THEN
1032 l_mode := 'INSERT_NO_TAX';
1033 arp_util.debug('Overridding mode to INSERT_NO_TAX');
1034 ELSE
1035 l_mode := 'INSERT';
1036 END IF;
1037
1038 /* we need to call the line_Det_Factors table handler so
1039 tax can get the attributes for calculating tax */
1040 BEGIN
1041 SELECT 'CM_CREDIT_LINES'
1042 INTO l_called_from
1043 FROM ra_customer_trx
1044 WHERE customer_trx_id = l_line_rec.customer_trx_id
1045 AND previous_customer_trx_id IS NOT NULL
1046 AND p_form_name = 'ARXTWLIN';
1047 EXCEPTION
1048 WHEN NO_DATA_FOUND THEN
1049 l_called_from := NULL;
1050 END;
1051
1052 ARP_ETAX_SERVICES_PKG.line_det_factors(
1053 p_customer_trx_line_id => l_customer_trx_line_id,
1054 p_customer_trx_id => p_line_rec.customer_trx_id,
1055 p_mode => l_mode,
1056 p_called_from => l_called_from);
1057
1058 /*********************************************************
1059 ETAX: NOT SURE IF WE NEED THESE RETURN!!!
1060 p_line_rec.extended_amount := l_extended_amount;
1061 l_line_rec.extended_amount := l_extended_amount;
1062 p_line_rec.unit_selling_price := l_unit_selling_price;
1063 l_line_rec.unit_selling_price := l_unit_selling_price;
1064
1065 p_line_rec.gross_extended_amount := l_gross_extended_amount;
1066 l_line_rec.gross_extended_amount := l_gross_extended_amount;
1067 p_line_rec.gross_unit_selling_price := l_gross_unit_selling_price;
1068 l_line_rec.gross_unit_selling_price := l_gross_unit_selling_price;
1069
1070 ****************************************************************************/
1071
1072 arp_util.debug(
1073 'arp_process_line.insert_line after create_tax_f_ctl_id');
1074
1075 EXCEPTION
1076 WHEN OTHERS THEN
1077 l_status2 := 'AR_TAX_EXCEPTION';
1078 RAISE;
1079
1080 END;
1081
1082 END IF;
1083
1084 /*----------------------------------------------------------------+
1085 | IF this transaction is a debit memo reversal, |
1086 | THEN create two distributions based on the ccid and amount |
1087 | parameters. |
1088 | ELSIF the transaction is a credit memo against a transaction, |
1089 | call the credit memo module to create the distributions |
1090 | ELSE create the distributions by calling AutoAccounting |
1091 +----------------------------------------------------------------*/
1092
1093 IF ( p_trx_class = 'DM_REV' )
1094 THEN
1095 arp_process_debit_memo.line_post_insert(
1096 l_customer_trx_line_id,
1097 p_ccid1,
1098 p_ccid2,
1099 p_amount1,
1100 p_amount2
1101 );
1102
1103 ELSIF ( p_line_rec.previous_customer_trx_id IS NOT NULL )
1104 THEN
1105
1106 /*--------------------------------------------+
1107 | It's a credit memo against a transaction |
1108 +--------------------------------------------*/
1109
1110 BEGIN
1111
1112 -- arp_global.msg_level := 99;
1113
1114 arp_util.debug(
1115 'arp_process_line.insert_line before credit_transactions');
1116
1117 arp_credit_memo_module.credit_transactions(
1118 p_line_rec.customer_trx_id,
1119 l_customer_trx_line_id,
1120 p_line_rec.previous_customer_trx_id,
1121 p_line_rec.previous_customer_trx_line_id,
1122 null,
1123 l_failure_count,
1124 l_rule_start_date,
1125 l_accounting_rule_duration,
1126 p_run_autoaccounting_flag =>
1127 (p_run_autoacc_flag = 'Y'));
1128
1129 arp_util.debug(
1130 'arp_process_line.insert_line after credit_transactions');
1131
1132 p_rule_start_date := l_rule_start_date;
1133 p_accounting_rule_duration := l_accounting_rule_duration;
1134
1135 EXCEPTION
1136 WHEN arp_credit_memo_module.no_ccid THEN
1137
1138 l_status3 := 'ARP_CREDIT_MEMO_MODULE.NO_CCID';
1139
1140 WHEN OTHERS THEN
1141 RAISE;
1142
1143 END;
1144
1145 ELSE
1146 IF ( p_run_autoacc_flag = 'Y' )
1147 THEN
1148 BEGIN
1149 arp_auto_accounting.do_autoaccounting
1150 (
1151 'I',
1152 'ALL',
1153 p_line_rec.customer_trx_id,
1154 l_customer_trx_line_id,
1155 null,
1156 null,
1157 null,
1158 null,
1159 null,
1160 null,
1161 null,
1162 null,
1163 null,
1164 null,
1165 null,
1166 l_ccid,
1167 l_concat_segments,
1168 l_num_failed_dist_rows);
1169 EXCEPTION
1170 WHEN arp_auto_accounting.no_ccid THEN
1171
1172 l_status4 := 'ARP_AUTO_ACCOUNTING.NO_CCID';
1173
1174 WHEN NO_DATA_FOUND THEN
1175 null;
1176 WHEN OTHERS THEN
1177 RAISE;
1178 END;
1179
1180 END IF;
1181
1182 END IF;
1183
1184 arp_util.debug('l_status1 = ' || l_status1);
1185 arp_util.debug('l_status2 = ' || l_status2);
1186 arp_util.debug('l_status3 = ' || l_status3);
1187 arp_util.debug('l_status4 = ' || l_status4);
1188
1189 IF ( NVL(l_status1, 'OK') <> 'OK' )
1190 THEN p_status := l_status1;
1191 ELSIF ( NVL(l_status2, 'OK') <> 'OK' )
1192 THEN p_status := l_status2;
1193 ELSIF ( NVL(l_status3, 'OK') <> 'OK' )
1194 THEN p_status := l_status3;
1195 ELSIF ( NVL(l_status4, 'OK') <> 'OK' )
1196 THEN p_status := l_status4;
1197 ELSE p_status := 'OK';
1198 END IF;
1199
1200 /*Bug 3130851 and Bug 3407389*/
1201
1202 /* Check if any gl_dist rows are inserted for the current trx_line.*/
1203
1204 BEGIN
1205 SELECT customer_trx_line_id
1206 INTO l_dist_line
1207 FROM ra_cust_trx_line_gl_dist
1208 WHERE customer_trx_line_id = p_customer_trx_line_id
1209 AND account_set_flag = 'N'
1210 AND ROWNUM < 2;
1211 EXCEPTION
1212 WHEN NO_DATA_FOUND THEN
1213 l_dist_line := NULL;
1214 END;
1215
1216
1217 IF ( p_line_rec.previous_customer_trx_id IS NOT NULL AND l_dist_line IS NOT NULL)
1218
1219 THEN
1220 arp_util.debug('Stamping distributions with the transaction code when entered at line level');
1221 ARP_CTLGD_PKG.set_to_dummy(l_dist_rec);
1222 l_dist_rec.ussgl_transaction_code := p_line_rec.DEFAULT_USSGL_TRANSACTION_CODE;
1223 ARP_CTLGD_PKG.update_f_ctl_id(l_dist_rec,p_customer_trx_line_id,'N','');
1224
1225
1226 DECLARE
1227 cursor c1 is select customer_trx_line_id
1228 from ra_customer_trx_lines
1229 where link_to_cust_trx_line_id = p_customer_trx_line_id;
1230 l_id number;
1231 BEGIN
1232 open c1;
1233 LOOP
1234 fetch c1 into l_id;
1235 ARP_CTLGD_PKG.set_to_dummy(l_dist_rec);
1236 l_dist_rec.ussgl_transaction_code := p_line_rec.DEFAULT_USSGL_TRANSACTION_CODE;
1237 ARP_CTLGD_PKG.update_f_ctl_id(l_dist_rec,l_id,'N','');
1238 exit when c1%NOTFOUND;
1239 END LOOP;
1240 close c1;
1241 EXCEPTION
1242 when NO_DATA_FOUND then
1243 null;
1244 END;
1245 arp_util.debug('Completed stamping distributions with the transaction code when entered at line level');
1246 END IF;
1247
1248
1249 --Bug#2750340
1250 l_ev_rec.xla_from_doc_id := p_line_rec.customer_trx_id;
1251 l_ev_rec.xla_to_doc_id := p_line_rec.customer_trx_id;
1252 l_ev_rec.xla_req_id := NULL;
1253 l_ev_rec.xla_dist_id := NULL;
1254 l_ev_rec.xla_doc_table := 'CT';
1255 l_ev_rec.xla_doc_event := NULL;
1256 l_ev_rec.xla_mode := 'O';
1257 l_ev_rec.xla_call := 'B';
1258 l_ev_rec.xla_fetch_size := 999;
1259 arp_xla_events.create_events(p_xla_ev_rec => l_ev_rec );
1260
1261 arp_util.debug('arp_process_line.insert_line()-');
1262
1263 EXCEPTION
1264 WHEN OTHERS THEN
1265
1266 IF (l_errorbuf is not null)
1267 THEN arp_util.debug('AutoAccounting error: ' || l_errorbuf);
1268 END IF;
1269
1270 /*---------------------------------------------+
1271 | Display parameters and raise the exception |
1272 +---------------------------------------------*/
1273
1274 arp_util.debug('EXCEPTION: arp_process_line.insert_line()');
1275
1276 arp_util.debug('');
1277 arp_util.debug('---------- parameters for insert_line() ---------');
1278
1279 arp_util.debug('p_form_name = ' || p_form_name );
1280 arp_util.debug('p_form_version = ' || p_form_version);
1281 arp_util.debug('p_memo_line_type = ' || p_memo_line_type);
1282 arp_util.debug('');
1283
1284 arp_ctl_pkg.display_line_rec(p_line_rec);
1285
1286 RAISE;
1287
1288 END;
1289
1290
1291 /*===========================================================================+
1292 | PROCEDURE |
1293 | update_line |
1294 | |
1295 | DESCRIPTION |
1296 | Updates a ra_customer_trx_lines record |
1297 | |
1298 | SCOPE - PUBLIC |
1299 | |
1300 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED |
1301 | arp_util.debug |
1302 | |
1303 | ARGUMENTS : IN: |
1304 | p_form_name |
1305 | p_form_version |
1306 | p_customer_trx_line_id |
1307 | p_line_rec |
1308 | p_foreign_currency_code |
1309 | p_exchange_rate |
1310 | p_recalculate_tax_flag |
1311 | p_rerun_autoacc_flag |
1312 | OUT: |
1313 | p_rule_start_date |
1314 | p_accounting_rule_duration |
1315 | p_status |
1316 | IN OUT: |
1317 | p_gl_date |
1318 | p_trx_date |
1319 | |
1320 | RETURNS : NONE |
1321 | |
1322 | NOTES |
1323 | |
1324 | MODIFICATION HISTORY |
1325 | 24-JUL-95 Charlie Tomberg Created |
1326 | 17-JAN-96 Martin Johnson Added call to credit memo module. |
1327 | Added OUT NOCOPY parameters |
1328 | p_rule_start_date |
1329 | and p_accounting_rule_duration |
1330 | 13-FEB-96 Martin Johnson Added OUT NOCOPY parameters p_gl_date |
1331 | and p_trx_date |
1332 | 20-MAR-96 Martin Johnson Rewrote algorithm to figure out NOCOPY |
1333 | whether to call CM module, autoacc, or |
1334 | dist table handler to update |
1335 | distributions |
1336 | 20-MAY-96 Martin Johnson BugNo:356814. Added OUT NOCOPY |
1337 | parameter p_status. Call tax engine |
1338 | in 'DEFERRED' mode so that 'soft' |
1339 | excpetion will be raise. |
1340 | |
1341 +===========================================================================*/
1342
1343
1344 PROCEDURE update_line(
1345 p_form_name IN varchar2,
1346 p_form_version IN number,
1347 p_customer_trx_line_id IN
1348 ra_customer_trx_lines.customer_trx_line_id%type,
1349 p_line_rec IN OUT NOCOPY ra_customer_trx_lines%rowtype,
1350 p_foreign_currency_code IN fnd_currencies.currency_code%type,
1351 p_exchange_rate IN ra_customer_trx.exchange_rate%type,
1352 p_recalculate_tax_flag IN boolean,
1353 p_rerun_autoacc_flag IN boolean,
1354 p_rule_start_date OUT NOCOPY
1355 ra_customer_trx_lines.rule_start_date%type,
1356 p_accounting_rule_duration OUT NOCOPY
1357 ra_customer_trx_lines.accounting_rule_duration%type,
1358 p_gl_date IN OUT NOCOPY
1359 ra_cust_trx_line_gl_dist.gl_date%type,
1360 p_trx_date IN OUT NOCOPY
1361 ra_customer_trx.trx_date%type,
1362 p_status OUT NOCOPY varchar2 )
1363 IS
1364
1365 l_recalculate_tax_flag boolean;
1366 l_derive_gldate_flag boolean;
1367 l_amount_changed_flag boolean;
1368 l_last_period_changed_flag boolean;
1369
1370 l_db_line_rec ra_customer_trx_lines%rowtype;
1371 l_new_line_rec ra_customer_trx_lines%rowtype;
1372
1373 l_old_tax_amount NUMBER;
1374 l_new_tax_amount NUMBER;
1375 l_requery_tax_if_visible BOOLEAN;
1376
1377 l_failure_count number;
1378 l_rule_start_date ra_customer_trx_lines.rule_start_date%type;
1379 l_accounting_rule_duration
1380 ra_customer_trx_lines.accounting_rule_duration%type;
1381
1382 l_old_trx_date date;
1383 l_trx_date_changed boolean;
1384
1385 l_status1 varchar2(100);
1386 l_status2 varchar2(100);
1387 l_status3 varchar2(100);
1388 l_status4 varchar2(100);
1389
1390 l_extended_amount NUMBER;
1391 l_unit_selling_price NUMBER;
1392 l_gross_extended_amount NUMBER;
1393 l_gross_unit_selling_price NUMBER;
1394 --Bug#2750340
1395 l_ev_rec arp_xla_events.xla_events_type;
1396
1397 /*Bug 3130851 and bug 3407389*/
1398
1399 l_dist_rec ra_cust_trx_line_gl_dist%rowtype;
1400 l_dist_line ra_cust_trx_line_gl_dist.customer_trx_line_id%type;
1401 l_tax_computed BOOLEAN;
1402
1403
1404 --{BUG#5192414
1405 CURSOR cpost IS
1406 SELECT 'Y'
1407 FROM ra_customer_trx_lines l,
1408 ra_cust_trx_line_gl_dist d
1409 WHERE l.customer_trx_line_id = p_customer_trx_line_id
1410 AND l.customer_trx_id = d.customer_trx_id
1411 AND d.account_set_flag = 'N'
1412 AND d.posting_Control_id <> -3;
1413
1414 l_test VARCHAR2(1);
1415 --}
1416 BEGIN
1417
1418 arp_util.debug('arp_process_line.update_line()+');
1419
1420 p_rule_start_date := p_line_rec.rule_start_date;
1421 p_accounting_rule_duration := p_line_rec.accounting_rule_duration;
1422
1423 l_old_trx_date := p_trx_date;
1424 l_trx_date_changed := FALSE;
1425
1426 /*----------------------------------------------+
1427 | Check the form version to determine if it |
1428 | is compatible with the entity handler. |
1429 +----------------------------------------------*/
1430
1431 arp_trx_validate.ar_entity_version_check(p_form_name, p_form_version);
1432
1433 /*---------------------------------------------------------------+
1434 | Fetch the old record from the database for later comparisons |
1435 +---------------------------------------------------------------*/
1436
1437 arp_ctl_pkg.fetch_p( l_db_line_rec,
1438 p_customer_trx_line_id);
1439
1440
1441 /*-------------------------+
1442 | Do required validation |
1443 +-------------------------*/
1444
1445 arp_process_line.val_update_line(p_line_rec,
1446 l_db_line_rec,
1447 l_new_line_rec);
1448
1449
1450
1451 /*----------------------------------------------------------------+
1452 | Lock rows in other tables that reference this customer_trx_id |
1453 +----------------------------------------------------------------*/
1454
1455 arp_trx_util.lock_transaction(l_db_line_rec.customer_trx_id);
1456
1457
1458 set_flags( p_line_rec,
1459 l_db_line_rec,
1460 l_db_line_rec.customer_trx_line_id,
1461 l_derive_gldate_flag,
1462 l_amount_changed_flag,
1463 l_last_period_changed_flag);
1464
1465
1466 /*---------------------------------------------------------------------+
1467 | check if tax needs to be recalculated |
1468 +---------------------------------------------------------------------*/
1469
1470 BEGIN
1471
1472
1473 -- Check to see if any relevant columns have been updated which
1474 -- affect tax calculation. If there are columns which affect tax
1475 -- have been modified, we will delete the tax lines and the
1476 -- accounting from those lines before we will eventually call
1477 -- ETAX to recreate the tax lines.
1478
1479 arp_etax_services_pkg.before_update_line(
1480 l_db_line_rec.customer_trx_line_id,
1481 p_line_rec,
1482 l_recalculate_tax_flag);
1483
1484 l_recalculate_tax_flag := l_recalculate_tax_flag OR
1485 p_recalculate_tax_flag;
1486
1487 EXCEPTION
1488 WHEN OTHERS THEN
1489
1490 arp_util.debug(
1491 'arp_etax_services_pkg.before_update_line raised exception');
1492 RAISE;
1493 END;
1494
1495 /* Rel. 11: If amount changed or tax is recalculated, then
1496 NULL out NOCOPY gross amounts, otherwise make sure the l_line_rec
1497 amounts contain the right (original) values
1498 */
1499
1500 IF (l_amount_changed_flag = TRUE OR
1501 l_recalculate_tax_flag = TRUE) THEN
1502 p_line_rec.gross_extended_amount := NULL;
1503 p_line_rec.gross_unit_selling_price := NULL;
1504 ELSE
1505 -- Bug 2833554
1506 -- amounts have not changed, and tax engine is not called, so
1507 -- set net amounts and gross amounts to AR_NUMBER_DUMMY to avoid update
1508
1509 p_line_rec.extended_amount := AR_NUMBER_DUMMY;
1510 p_line_rec.unit_selling_price := AR_NUMBER_DUMMY;
1511
1512 p_line_rec.gross_extended_amount := AR_NUMBER_DUMMY;
1513 p_line_rec.gross_unit_selling_price := AR_NUMBER_DUMMY;
1514 END IF;
1515
1516 /*---------------------------------------------+
1517 | Call the table handler to update the line |
1518 +---------------------------------------------*/
1519
1520 arp_ctl_pkg.update_p( p_line_rec,
1521 p_customer_trx_line_id,
1522 p_foreign_currency_code );
1523
1524 /*--------------------------------------------------------------------+
1525 | If the rule schedule has changed, the trx_date and gl_date |
1526 | may now be invalid. This may cause the tax to be invalid as well. |
1527 | arp_dates.derive_gl_trx_dates_from_rules() rederives and |
1528 | resets the gl_date and trx date. |
1529 +--------------------------------------------------------------------*/
1530
1531 IF ( l_derive_gldate_flag = TRUE )
1532 THEN
1533 arp_dates.derive_gl_trx_dates_from_rules (
1534 l_db_line_rec.customer_trx_id,
1535 p_gl_date,
1536 p_trx_date,
1537 l_recalculate_tax_flag );
1538
1539 IF ( p_trx_date <> l_old_trx_date )
1540 THEN l_trx_date_changed := TRUE;
1541 END IF;
1542
1543 END IF;
1544
1545
1546 /*----------------------------------------------------------------+
1547 | recreate the tax lines associated with this transaction line |
1548 +----------------------------------------------------------------*/
1549
1550 IF ( l_recalculate_tax_flag = TRUE )
1551 THEN
1552 /*------------------------------------------------------------------+
1553 | Call Tax Engine, recalculating tax for this updated invoice line.|
1554 +------------------------------------------------------------------*/
1555
1556 BEGIN
1557
1558 -- Rel. 11 call to new tax engine:
1559
1560 -- copy entered amounts into parameters
1561
1562 l_extended_amount := p_line_rec.extended_amount;
1563 l_unit_selling_price := p_line_rec.unit_selling_price;
1564
1565 /* we need to call the line_Det_Factors table handler so
1566 tax can get the attributes for calculating tax */
1567 ARP_ETAX_SERVICES_PKG.line_det_factors(
1568 p_customer_trx_line_id => p_customer_trx_line_id,
1569 p_customer_trx_id => p_line_rec.customer_trx_id,
1570 p_mode => 'UPDATE');
1571
1572 /***************************************************************
1573 -- ETAX: CAll Calculate in update mode
1574
1575 l_tax_computed := ARP_ETAX_SERVICES_PKG.Calculate (
1576 p_customer_trx_id => p_line_rec.customer_trx_id,
1577 p_cust_trx_line_id => p_customer_trx_line_id,
1578 p_action => 'UPDATE',
1579 p_line_level_action => 'UPDATE');
1580
1581 IF (NOT l_tax_computed) THEN
1582 arp_util.debug('ERROR COMPUTING TAX ');
1583 app_exception.raise_exception;
1584 END IF;
1585 *****************************************************************/
1586
1587
1588 p_line_rec.extended_amount := l_extended_amount;
1589 l_new_line_rec.extended_amount := l_extended_amount;
1590 p_line_rec.unit_selling_price := l_unit_selling_price;
1591 l_new_line_rec.unit_selling_price := l_unit_selling_price;
1592
1593 p_line_rec.gross_extended_amount := l_gross_extended_amount;
1594 l_new_line_rec.gross_extended_amount := l_gross_extended_amount;
1595 p_line_rec.gross_unit_selling_price := l_gross_unit_selling_price;
1596 l_new_line_rec.gross_unit_selling_price := l_gross_unit_selling_price;
1597
1598
1599 EXCEPTION
1600 WHEN OTHERS THEN
1601 RAISE;
1602
1603 END;
1604
1605 END IF;
1606
1607 /*---------------------------------------------------------------------+
1608 | Update the salescredit lines associated with this transaction line |
1609 +---------------------------------------------------------------------*/
1610
1611 IF ( l_amount_changed_flag = TRUE )
1612 THEN arp_ctls_pkg.update_amounts_f_ctl_id(p_customer_trx_line_id,
1613 l_new_line_rec.extended_amount,
1614 p_foreign_currency_code );
1615 END IF;
1616
1617 /*-----------------------------------------------------------+
1618 | IF transaction is a credit memo against a transaction |
1619 | AND rerun_autoacc is TRUE |
1620 | OR CM has rules AND amount or last period changed |
1621 | THEN call CM module to update the distributions |
1622 | ELSIF rerun_autoacc is TRUE |
1623 | THEN call autoaccounting to update the distributions |
1624 | ELSIF amount changed |
1625 | THEN update the distribution amounts |
1626 +-----------------------------------------------------------*/
1627
1628 IF ( ( p_line_rec.previous_customer_trx_id IS NOT NULL )
1629 AND
1630 ( ( p_rerun_autoacc_flag )
1631 OR
1632 ( ( p_line_rec.accounting_rule_id IS NOT NULL )
1633 AND
1634 ( l_amount_changed_flag OR l_last_period_changed_flag )
1635 )
1636 )
1637 )
1638 THEN
1639 BEGIN
1640 arp_credit_memo_module.credit_transactions(
1641 p_line_rec.customer_trx_id,
1642 p_customer_trx_line_id,
1643 p_line_rec.previous_customer_trx_id,
1644 p_line_rec.previous_customer_trx_line_id,
1645 null,
1646 l_failure_count,
1647 l_rule_start_date,
1648 l_accounting_rule_duration,
1649 'U' );
1650
1651 p_rule_start_date := l_rule_start_date;
1652 p_accounting_rule_duration := l_accounting_rule_duration;
1653
1654 EXCEPTION
1655 WHEN arp_credit_memo_module.no_ccid THEN
1656
1657 l_status3 := 'ARP_CREDIT_MEMO_MODULE.NO_CCID';
1658
1659 WHEN OTHERS THEN
1660 RAISE;
1661 END;
1662
1663 ELSIF p_rerun_autoacc_flag
1664 THEN
1665
1666 BEGIN
1667
1668 line_rerun_aa( l_new_line_rec.customer_trx_id,
1669 p_customer_trx_line_id );
1670
1671 EXCEPTION
1672 WHEN arp_auto_accounting.no_ccid THEN
1673
1674 l_status4 := 'ARP_AUTO_ACCOUNTING.NO_CCID';
1675
1676 WHEN OTHERS THEN
1677 RAISE;
1678 END;
1679
1680 ELSIF l_amount_changed_flag
1681 THEN
1682 arp_ctlgd_pkg.update_amount_f_ctl_id(
1683 p_customer_trx_line_id,
1684 l_new_line_rec.extended_amount,
1685 p_foreign_currency_code,
1686 pg_base_curr_code,
1687 p_exchange_rate,
1688 pg_base_precision,
1689 pg_base_min_acct_unit );
1690 END IF;
1691
1692 arp_util.debug('l_status1 = ' || l_status1);
1693 arp_util.debug('l_status2 = ' || l_status2);
1694 arp_util.debug('l_status3 = ' || l_status3);
1695 arp_util.debug('l_status4 = ' || l_status4);
1696
1697 IF ( NVL(l_status1, 'OK') <> 'OK' )
1698 THEN p_status := l_status1;
1699 ELSIF ( NVL(l_status2, 'OK') <> 'OK' )
1700 THEN p_status := l_status2;
1701 ELSIF ( NVL(l_status3, 'OK') <> 'OK' )
1702 THEN p_status := l_status3;
1703 ELSIF ( NVL(l_status4, 'OK') <> 'OK' )
1704 THEN p_status := l_status4;
1705 ELSE p_status := 'OK';
1706 END IF;
1707
1708
1709 /* Bug 3407389 and bug 3130851*/
1710 /* Check if any gl_dist rows are inserted for the current trx_line.*/
1711
1712 BEGIN
1713 SELECT customer_trx_line_id
1714 INTO l_dist_line
1715 FROM ra_cust_trx_line_gl_dist
1716 WHERE customer_trx_line_id = p_customer_trx_line_id
1717 AND account_set_flag = 'N'
1718 AND ROWNUM < 2;
1719 EXCEPTION
1720 WHEN NO_DATA_FOUND THEN
1721 l_dist_line := NULL;
1722 END;
1723
1724 IF ( p_line_rec.previous_customer_trx_id IS NOT NULL AND l_dist_line IS NOT NULL)
1725
1726 THEN
1727 IF nvl(l_db_line_rec.DEFAULT_USSGL_TRANSACTION_CODE,0) <> nvl(p_line_rec.DEFAULT_USSGL_TRANSACTION_CODE,0)
1728 THEN
1729
1730 arp_util.debug('Updating distributions with the transaction code when changed at line level');
1731 ARP_CTLGD_PKG.set_to_dummy(l_dist_rec);
1732 l_dist_rec.ussgl_transaction_code := p_line_rec.DEFAULT_USSGL_TRANSACTION_CODE;
1733 ARP_CTLGD_PKG.update_f_ctl_id(l_dist_rec,p_customer_trx_line_id,'N','');
1734
1735 /* The logic below is mainly to hit the other rows in RA_CUST_TRX_LINE_GL_DIST which are
1736 linked to the line updated above apart from the REC row*/
1737 DECLARE
1738 cursor c1 is select customer_trx_line_id
1739 from ra_customer_trx_lines
1740 where link_to_cust_trx_line_id = p_customer_trx_line_id;
1741 l_id number;
1742 BEGIN
1743 open c1;
1744 LOOP
1745 fetch c1 into l_id;
1746 ARP_CTLGD_PKG.set_to_dummy(l_dist_rec);
1747 l_dist_rec.ussgl_transaction_code := p_line_rec.DEFAULT_USSGL_TRANSACTION_CODE;
1748 ARP_CTLGD_PKG.update_f_ctl_id(l_dist_rec,l_id,'N','');
1749 exit when c1%NOTFOUND;
1750 END LOOP;
1751 close c1;
1752 EXCEPTION
1753 when NO_DATA_FOUND then
1754 null;
1755 END;
1756 arp_util.debug('Completed updating distributions with the transaction code when changed at line level');
1757 END IF;
1758 END IF;
1759
1760 OPEN cpost;
1761 FETCH cpost INTO l_test;
1762 IF cpost%NOTFOUND THEN
1763 --BUG#2750340
1764 l_ev_rec.xla_from_doc_id := p_line_rec.customer_trx_id;
1765 l_ev_rec.xla_to_doc_id := p_line_rec.customer_trx_id;
1766 l_ev_rec.xla_req_id := NULL;
1767 l_ev_rec.xla_dist_id := NULL;
1768 l_ev_rec.xla_doc_table := 'CT';
1769 l_ev_rec.xla_doc_event := NULL;
1770 l_ev_rec.xla_mode := 'O';
1771 l_ev_rec.xla_call := 'B';
1772 l_ev_rec.xla_fetch_size := 999;
1773 arp_xla_events.create_events(p_xla_ev_rec => l_ev_rec );
1774 END IF;
1775 CLOSE cpost;
1776
1777 arp_util.debug('arp_process_line.update_line()-');
1778
1779 EXCEPTION
1780 WHEN OTHERS THEN
1781
1782 arp_util.debug('EXCEPTION: arp_process_line.update_line()');
1783
1784 arp_util.debug('');
1785 arp_util.debug('---------- parameters for update_line() ---------');
1786
1787 arp_util.debug('p_form_name = ' || p_form_name );
1788 arp_util.debug('p_form_version = ' || p_form_version);
1789 arp_util.debug('p_customer_trx_line_id = ' ||
1790 p_customer_trx_line_id);
1791 arp_util.debug('p_foreign_currency_code = ' ||p_foreign_currency_code);
1792 arp_util.debug('p_exchange_rate = ' || p_exchange_rate);
1793 arp_util.debug('p_recalculate_tax_flag = ' ||
1794 arp_trx_util.boolean_to_varchar2(p_recalculate_tax_flag));
1795 arp_util.debug('p_rerun_autoacc_flag = ' ||
1796 arp_trx_util.boolean_to_varchar2(p_rerun_autoacc_flag));
1797
1798 arp_util.debug('');
1799
1800 arp_ctl_pkg.display_line_rec(p_line_rec);
1801
1802 RAISE;
1803
1804 END;
1805
1806 /*===========================================================================+
1807 | PROCEDURE |
1808 | delete_line |
1809 | |
1810 | DESCRIPTION |
1811 | Deletes records from ra_customer_trx_lines |
1812 | |
1813 | SCOPE - PUBLIC |
1814 | |
1815 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED |
1816 | arp_util.debug |
1817 | |
1818 | ARGUMENTS : IN: |
1819 | p_form_name |
1820 | p_form_version |
1821 | p_customer_trx_line_id |
1822 | p_complete_flag |
1823 | p_recalculate_tax_flag |
1824 | p_trx_amount |
1825 | p_exchange_rate |
1826 | p_line_rec |
1827 | IN / OUT: |
1828 | p_gl_date |
1829 | p_trx_date |
1830 | OUT: |
1831 | p_status |
1832 | |
1833 | RETURNS : NONE |
1834 | |
1835 | NOTES |
1836 | |
1837 | MODIFICATION HISTORY |
1838 | 24-JUL-95 Charlie Tomberg Created |
1839 | 15-MAR-96 Martin Johnson Delete from ar_credit_memo_amounts if |
1840 | the transaction is a credit memo with |
1841 | rules. |
1842 | Do not derive gl and trx dates for CM's|
1843 | 20-MAY-96 Martin Johnson BugNo:356814. Added OUT NOCOPY parameter |
1844 | p_status. Call tax engine in |
1845 | 'DEFERRED' mode so that 'soft' |
1846 | excpetion will be raise. |
1847 | 21-OCT-1997 OSTEINME Bug 565566:
1848 | added call to procedure
1849 | arp_ctlgd_pkg.delete_f_ct_ltctl_id_type
1850 | |
1851 +===========================================================================*/
1852
1853
1854 PROCEDURE delete_line(p_form_name IN varchar2,
1855 p_form_version IN number,
1856 p_customer_trx_line_id IN
1857 ra_customer_trx_lines.customer_trx_line_id%type,
1858 p_complete_flag IN ra_customer_trx.complete_flag%type,
1859 p_recalculate_tax_flag IN boolean,
1860 p_trx_amount IN number,
1861 p_exchange_rate IN ra_customer_trx.exchange_rate%type,
1862 p_header_currency_code IN fnd_currencies.currency_code%type,
1863 p_gl_date IN OUT NOCOPY ra_cust_trx_line_gl_dist.gl_date%type,
1864 p_trx_date IN OUT NOCOPY ra_customer_trx.trx_date%type,
1865 p_line_rec IN ra_customer_trx_lines%rowtype,
1866 p_status OUT NOCOPY varchar2 ) IS
1867
1868 l_recalculate_tax_flag boolean;
1869 l_old_tax_amount NUMBER;
1870 l_new_tax_amount NUMBER;
1871 l_tax_computed BOOLEAN;
1872
1873 --added for bug 7478499
1874 CURSOR cont_cursor IS
1875 select alc.customer_trx_line_id
1876 from ra_customer_trx_lines ctl,
1877 ar_line_conts alc
1878 where
1879 ctl.customer_trx_line_id = p_customer_trx_line_id
1880 and ctl.customer_trx_line_id = alc.customer_trx_line_id
1881 and ctl.line_type = 'LINE'
1882 FOR UPDATE OF alc.customer_trx_line_id NOWAIT;
1883
1884 CURSOR deferred_cursor IS
1885 select customer_trx_line_id
1886 from ar_deferred_lines
1887 where customer_trx_line_id = p_customer_trx_line_id
1888 FOR UPDATE OF customer_trx_line_id NOWAIT;
1889 BEGIN
1890
1891 arp_util.debug('arp_process_line.delete_line()+');
1892
1893 p_status := 'OK';
1894
1895 /*----------------------------------------------+
1896 | Check the form version to determine if it |
1897 | is compatible with the entity handler. |
1898 +----------------------------------------------*/
1899
1900 arp_trx_validate.ar_entity_version_check(p_form_name, p_form_version);
1901
1902 /*-------------------------+
1903 | Do required validation |
1904 +-------------------------*/
1905
1906 arp_process_line.val_delete_line(p_line_rec,
1907 p_complete_flag);
1908
1909
1910 l_recalculate_tax_flag := p_recalculate_tax_flag;
1911
1912 /*----------------------------------------------------------------+
1913 | Lock rows in other tables that reference this customer_trx_id |
1914 +----------------------------------------------------------------*/
1915
1916 arp_trx_util.lock_transaction(p_line_rec.customer_trx_id);
1917
1918 /*---------------------------------------------------------------------+
1919 | Call Tax Engine, deleting any tax associated with this line. |
1920 +---------------------------------------------------------------------*/
1921
1922 arp_etax_services_pkg.before_delete_line(
1923 p_customer_trx_line_id => p_customer_trx_line_id,
1924 p_customer_trx_id => p_line_rec.customer_trx_id);
1925
1926
1927 /*---------------------------------------------------+
1928 | Delete the account assignments associated with |
1929 | the freight line. |
1930 +---------------------------------------------------*/
1931
1932 arp_ctlgd_pkg.delete_f_ct_ltctl_id_type(
1933 p_line_rec.customer_trx_id,
1934 p_customer_trx_line_id,
1935 'FREIGHT',
1936 NULL,
1937 NULL);
1938
1939 /*------------------------------------------------------------------+
1940 | Delete the tax and freight lines that are associated with this |
1941 | line of type LINE. |
1942 +------------------------------------------------------------------*/
1943
1944 arp_ctl_pkg.delete_f_ltctl_id( p_customer_trx_line_id );
1945
1946 /*------------------------------------------------------+
1947 | Delete the salescredits associated with this line. |
1948 +------------------------------------------------------*/
1949
1950 arp_ctls_pkg.delete_f_ctl_id( p_customer_trx_line_id );
1951
1952
1953 /*---------------------------------------------------+
1954 | Delete the account assignments and account sets |
1955 | associated with this line. |
1956 +---------------------------------------------------*/
1957
1958 arp_ctlgd_pkg.delete_f_ctl_id( p_customer_trx_line_id,
1959 null,
1960 null );
1961
1962 /*------------------------------------------------------------+
1963 | Delete from ar_credit_memo_amounts if the transaction is |
1964 | a credit memo with rules. |
1965 +------------------------------------------------------------*/
1966
1967 IF ( (p_line_rec.previous_customer_trx_line_id IS NOT NULL) AND
1968 (p_line_rec.accounting_rule_id IS NOT NULL ) )
1969 THEN
1970 arp_cma_pkg.delete_f_ctl_id( p_customer_trx_line_id );
1971 END IF;
1972
1973 --added for bug 7478499
1974 BEGIN
1975 FOR l_cont_rec IN cont_cursor LOOP
1976 delete from ar_line_conts
1977 where customer_trx_line_id = l_cont_rec.customer_trx_line_id;
1978 END LOOP;
1979
1980 FOR l_deferred_rec IN deferred_cursor LOOP
1981 delete from ar_deferred_lines
1982 WHERE customer_trx_line_id = l_deferred_rec.customer_trx_line_id;
1983 END LOOP;
1984
1985 EXCEPTION
1986 WHEN NO_DATA_FOUND THEN
1987 null;
1988 WHEN OTHERS THEN
1989 RAISE;
1990 END;
1991
1992 /*-----------------------------------------------------+
1993 | call the table-handler to delete the line record |
1994 +-----------------------------------------------------*/
1995
1996 arp_ctl_pkg.delete_p( p_customer_trx_line_id );
1997
1998 /*--------------------------------------------------------------------+
1999 | If the line had rules, the trx_date and gl_date may have to |
2000 | change if they were originally set to their current values because |
2001 | of the rule schedule of the line that has just been deleted. |
2002 | arp_dates.derive_gl_trx_dates_from_rules() rederives and resets |
2003 | the trx_date and gl_date. |
2004 | |
2005 | If the line that was deleted was the last line on a transaction |
2006 | that has header freight and rules, the transaction is no longer |
2007 | valid because header freight only transactions cannot have rules. |
2008 | header_freight_only_rules_case() converts the transaction to one |
2009 | without rules in this case. |
2010 +--------------------------------------------------------------------*/
2011
2012 IF (p_line_rec.accounting_rule_id IS NOT NULL )
2013 THEN
2014
2015 IF ( p_line_rec.previous_customer_trx_line_id IS NULL )
2016 THEN
2017 arp_dates.derive_gl_trx_dates_from_rules(
2018 p_line_rec.customer_trx_id,
2019 p_gl_date,
2020 p_trx_date,
2021 l_recalculate_tax_flag);
2022 END IF;
2023
2024 header_freight_only_rules_case( p_line_rec.customer_trx_id,
2025 p_trx_amount,
2026 p_exchange_rate,
2027 p_gl_date);
2028
2029
2030 END IF;
2031
2032 IF ( l_recalculate_tax_flag = TRUE )
2033 THEN -- salestax delete
2034 -- call header tax in update mode if the trx_date has changed
2035 -- (the tax may not be valid for the new trx_date)
2036 null;
2037 END IF;
2038
2039 arp_util.debug('arp_process_line.delete_line()-');
2040
2041 EXCEPTION
2042 WHEN OTHERS THEN
2043
2044 /*---------------------------------------------+
2045 | Display parameters and raise the exception |
2046 +---------------------------------------------*/
2047
2048 arp_util.debug('EXCEPTION: arp_process_line.delete_line()');
2049
2050 arp_util.debug('');
2051 arp_util.debug('---------- parameters for delete_line() ---------');
2052
2053 arp_util.debug('p_form_name = ' || p_form_name );
2054 arp_util.debug('p_form_version = ' || p_form_version);
2055 arp_util.debug('p_customer_trx_line_id = ' ||
2056 p_customer_trx_line_id);
2057 arp_util.debug('p_complete_flag = ' || p_complete_flag);
2058 arp_util.debug('p_recalculate_tax_flag = ' ||
2059 arp_trx_util.boolean_to_varchar2(p_recalculate_tax_flag));
2060 arp_util.debug('p_trx_amount = ' || p_trx_amount);
2061 arp_util.debug('p_exchange_rate = ' || p_exchange_rate);
2062 arp_util.debug('p_gl_date = ' || p_gl_date);
2063 arp_util.debug('p_trx_date = ' || p_trx_date);
2064 arp_util.debug('');
2065
2066 arp_ctl_pkg.display_line_rec(p_line_rec);
2067
2068 RAISE;
2069
2070 END;
2071
2072
2073 /*---------------------------------------------+
2074 | Package initialization section. |
2075 +---------------------------------------------*/
2076
2077 BEGIN
2078
2079 pg_base_curr_code := arp_trx_global.system_info.base_currency;
2080 pg_base_precision := arp_trx_global.system_info.base_precision;
2081 pg_base_min_acct_unit := arp_trx_global.system_info.base_min_acc_unit;
2082 pg_earliest_date := to_date('01/01/1901', 'DD/MM/YYYY');
2083
2084 EXCEPTION
2085 WHEN OTHERS THEN
2086 arp_util.debug('EXCEPTION: arp_process_line.initialization');
2087 RAISE;
2088
2089
2090 END ARP_PROCESS_LINE;