DBA Data[Home] [Help]

PACKAGE BODY: APPS.ARP_TRX_UTIL

Source


1 PACKAGE BODY ARP_TRX_UTIL AS
2 /* $Header: ARTUTILB.pls 120.7.12010000.2 2008/11/13 15:43:17 rmanikan ship $ */
3 
4 pg_base_curr_code     gl_sets_of_books.currency_code%type;
5 pg_base_precision     fnd_currencies.precision%type;
6 pg_base_min_acc_unit  fnd_currencies.minimum_accountable_unit%type;
7 
8 /*===========================================================================+
9  | PROCEDURE                                                                 |
10  |    delete_transaction                                                     |
11  |                                                                           |
12  | DESCRIPTION                                                               |
13  |    Deletes all records in all tables associated with a particular         |
14  |    transcation.                                                           |
15  |                                                                           |
16  | SCOPE - PRIVATE                                                           |
17  |                                                                           |
18  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
19  |    dbms_sql.bind_variable                                                 |
20  |    arp_util.debug                                                         |
21  |                                                                           |
22  | ARGUMENTS  : IN:                                                          |
23  |                    p_form_name                                            |
24  |                    p_form_version                                         |
25  |                    p_customer_trx_is                                      |
26  |              OUT:                                                         |
27  |                    None                                                   |
28  |                                                                           |
29  | RETURNS    : NONE                                                         |
30  |                                                                           |
31  | NOTES                                                                     |
32  |                                                                           |
33  | MODIFICATION HISTORY                                                      |
34  |     05-JUL-95  Charlie Tomberg     Created                                |
35  |     21-AUG-97  OSTEINME	      Bug 514459: Delete Payment Schedules   |
36  |					when transaction is deleted          |
37  |     24-JUL-02  VERAO               Bug 2217253: Delete RA record of a CM  |
38  |                                      when transaction is deleted          |
39  |     11-APR-03  MRAYMOND        Bug 2868648 - remove CMA rows when
40  |                                    transaction is deleted.
41  +===========================================================================*/
42 PG_DEBUG varchar2(1) := NVL(FND_PROFILE.value('AFLOG_ENABLED'), 'N');
43 
44 PROCEDURE delete_transaction(p_form_name         IN varchar2,
45                              p_form_version      IN number,
46                              p_customer_trx_id   IN NUMBER) IS
47 
48 
49 BEGIN
50 
51    arp_util.debug('arp_process_header.delete_transaction()+');
52 
53    -- check form version to determine if it is compatible with the
54    -- entity handler.
55    --   arp_trx_validate.ar_entity_version_check(p_form_name, p_form_version);
56 
57    -- MRC trigger replacement:
58    -- Delete sales credit first because it requires an update to
59    -- the gl_dist / lines tables
60 
61    arp_ctls_pkg.delete_f_ct_id(p_customer_trx_id);
62 
63    arp_ct_pkg.delete_p(p_customer_trx_id);
64 
65    /* Bug 2868648 - remove CMA rows, too! */
66    arp_cma_pkg.delete_f_ct_id(p_customer_trx_id);
67 
68    arp_ctl_pkg.delete_f_ct_id(p_customer_trx_id);
69    arp_ctlgd_pkg.delete_f_ct_id(p_customer_trx_id, '', '');
70    arp_ps_pkg.delete_f_ct_id(p_customer_trx_id);
71 
72 -- Bugfix 2217253. Uncommented the line below
73    arp_app_pkg.delete_f_ct_id(p_customer_trx_id);
74 
75 
76    arp_util.debug('arp_process_header.delete_transaction()-');
77 
78 EXCEPTION
79     WHEN OTHERS THEN
80         arp_util.debug('EXCEPTION:  arp_process_header.delete_transaction()');
81         rollback to savepoint ar_delete_transaction_1;
82         RAISE;
83 
84 END;
85 
86 /*===========================================================================+
87  | PROCEDURE                                                                 |
88  |    lock_transaction			                                     |
89  |                                                                           |
90  | DESCRIPTION                                                               |
91  |    Locks all records in all tables associated with a particular           |
92  |    transcation.							     |
93  |                                                                           |
94  | SCOPE - PRIVATE                                                           |
95  |                                                                           |
96  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
97  |    dbms_sql.bind_variable                                                 |
98  |    arp_util.debug                                                         |
99  |                                                                           |
100  | ARGUMENTS  : IN:                                                          |
101  |		      p_form_name					     |
102  |		      p_form_version					     |
103  |		      p_customer_trx_id 				     |
104  |              OUT:                                                         |
105  |                    None                                                   |
106  |                                                                           |
107  | RETURNS    : NONE                                                         |
108  |                                                                           |
109  | NOTES                                                                     |
110  |                                                                           |
111  | MODIFICATION HISTORY                                                      |
112  |     05-JUL-95  Charlie Tomberg     Created                                |
113  |                                                                           |
114  +===========================================================================*/
115 
116 
117 PROCEDURE lock_transaction(p_customer_trx_id   IN NUMBER) IS
118 
119 
120 BEGIN
121 
122    arp_util.debug('arp_trx_util.lock_transaction()+');
123 
124    -- check form version to determine if it is compatible with the
125    -- entity handler.
126    --   arp_trx_validate.ar_entity_version_check(p_form_name, p_form_version);
127 
128 
129    savepoint ar_lock_transaction_1;
130 
131    arp_ct_pkg.lock_p(p_customer_trx_id);
132    arp_ctl_pkg.lock_f_ct_id(p_customer_trx_id);
133    arp_ctls_pkg.lock_f_ct_id(p_customer_trx_id);
134    arp_ctlgd_pkg.lock_f_ct_id(p_customer_trx_id, '', '');
135    arp_ps_pkg.lock_f_ct_id(p_customer_trx_id);
136    arp_adjustments_pkg.lock_f_ct_id(p_customer_trx_id);
137 
138 
139    arp_util.debug('arp_trx_util.lock_transaction()-');
140 
141 EXCEPTION
142     WHEN OTHERS THEN
143         arp_util.debug('EXCEPTION:  arp_trx_util.delete_lock()');
144         rollback to savepoint ar_lock_transaction_1;
145         RAISE;
146 
147 END;
148 
149 
150 /*===========================================================================+
151  | PROCEDURE                                                                 |
152  |    set_term_in_use_flag		                                     |
153  |                                                                           |
154  | DESCRIPTION                                                               |
155  |    Sets the ra_terms.in_use flag if necessary.			     |
156  |                                                                           |
157  | SCOPE - PRIVATE                                                           |
158  |                                                                           |
159  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
160  |    dbms_sql.bind_variable                                                 |
161  |    arp_util.debug                                                         |
162  |                                                                           |
163  | ARGUMENTS  : IN:                                                          |
164  |		      p_form_name					     |
165  |		      p_form_version					     |
166  |		      p_term_id						     |
167  |		      p_term_in_use_flag 				     |
168  |              OUT:                                                         |
169  |                    None                                                   |
170  |                                                                           |
171  | RETURNS    : NONE                                                         |
172  |                                                                           |
173  | NOTES                                                                     |
174  |                                                                           |
175  | MODIFICATION HISTORY                                                      |
176  |     05-JUL-95  Charlie Tomberg     Created                                |
177  |     22-DEC-98  Victoria Smith      Changes RA_TERMS to RA_TERMS_B, so that|
178  |                                    update will be done on base MLS table  |
179  |                                                                           |
180  +===========================================================================*/
181 
182 
183 PROCEDURE set_term_in_use_flag(p_form_name         IN varchar2,
184                                p_form_version      IN number,
185                                p_term_id           IN number,
186                                p_term_in_use_flag  IN varchar2) IS
187 
188 
189 BEGIN
190 
191    arp_util.debug('arp_trx_util.set_term_in_use_flag()+');
192 
193    -- check form version to determine if it is compatible with the
194    -- entity handler.
195    --   arp_trx_validate.ar_entity_version_check(p_form_name, p_form_version);
196 
197    -- Set term in use flag to Yes unless it already is in use.
198 
199 
200    IF (NVL(p_term_in_use_flag, 'N') = 'N')
201    THEN
202        arp_util.debug('setting the in_use flag for term ' || p_term_id ||
203                       ' to  Y.');
204 
205         UPDATE ra_terms_b
206            SET in_use   = 'Y'
207          WHERE term_id  = p_term_id
208            AND in_use   = 'N';
209    END IF;
210 
211    arp_util.debug('arp_trx_util.set_term_in_use_flag()-');
212 
213 EXCEPTION
214     WHEN NO_DATA_FOUND THEN
215         null;
216     WHEN OTHERS THEN
217         arp_util.debug('EXCEPTION:  arp_trx_util.set_term_in_use_flag()');
218         RAISE;
219 
220 END;
221 
222 
223 /*===========================================================================+
224  | PROCEDURE                                                                 |
225  |    set_posted_flag			                                     |
226  |                                                                           |
227  | DESCRIPTION                                                               |
228  |    Determines if a transaction has been posted.			     |
229  |                                                                           |
230  | SCOPE - PRIVATE                                                           |
231  |                                                                           |
232  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
233  |    arp_util.debug                                                         |
234  |                                                                           |
235  | ARGUMENTS  : IN:                                                          |
236  |		      p_customer_trx_id 				     |
237  |              OUT:                                                         |
238  |                    p_posted_flag                                          |
239  |                                                                           |
240  | RETURNS    : NONE                                                         |
241  |                                                                           |
242  | NOTES                                                                     |
243  |                                                                           |
244  | MODIFICATION HISTORY                                                      |
245  |     17-JUL-95  Charlie Tomberg     Created                                |
246  |                                                                           |
247  +===========================================================================*/
248 
249 
250 PROCEDURE set_posted_flag(p_customer_trx_id   IN NUMBER,
251                           p_posted_flag      OUT NOCOPY BOOLEAN) IS
252 
253    l_posted_flag varchar2(2);
254 
255 BEGIN
256 
257    arp_util.debug('arp_trx_util.set_posted_flag()+');
258 
259    SELECT decode(max(dummy),
260                  NULL, 'N',
261                      'Y')
262 
263    INTO   l_posted_flag
264    FROM   dual
265    WHERE  EXISTS
266                  (SELECT 'posted distribution exists'
267                   FROM   ra_cust_trx_line_gl_dist
268                   WHERE  customer_trx_id  = p_customer_trx_id
269                   AND    account_set_flag = 'N'
270                   AND    gl_posted_date   IS NOT NULL
271                  );
272 
273    IF      (l_posted_flag = 'Y')
274    THEN    p_posted_flag := TRUE;
275    ELSE    p_posted_flag := FALSE;
276    END IF;
277 
278    arp_util.debug('arp_trx_util.set_posted_flag()-');
279 
280 EXCEPTION
281     WHEN OTHERS THEN
282         arp_util.debug('EXCEPTION:  arp_trx_util.set_posted_flag()');
283         RAISE;
284 
285 END;
286 
287 /*===========================================================================+
288  | FUNCTION                                                                  |
289  |    boolean_to_varchar2		                                     |
290  |                                                                           |
291  | DESCRIPTION                                                               |
292  |    Converts a boolean value to a varchar2				     |
293  |                                                                           |
294  | SCOPE - PRIVATE                                                           |
295  |                                                                           |
296  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
297  |    arp_util.debug                                                         |
298  |                                                                           |
299  | ARGUMENTS  : IN:                                                          |
300  |		      p_boolean	 					     |
301  |              OUT:                                                         |
302  |		      None						     |
303  |                                                                           |
304  | RETURNS    : varchar2 value                                               |
305  |                                                                           |
306  | NOTES                                                                     |
307  |                                                                           |
308  | MODIFICATION HISTORY                                                      |
309  |     18-JUL-95  Charlie Tomberg     Created                                |
310  |                                                                           |
311  +===========================================================================*/
312 
313 
314 FUNCTION boolean_to_varchar2(p_boolean IN boolean) RETURN varchar2 IS
315 
316    l_result varchar2(6);
317 
318 BEGIN
319 
320    IF    (p_boolean = TRUE)
321    THEN  l_result := 'TRUE';
322    ELSE  l_result := 'FALSE';
323    END IF;
324 
325    return(l_result);
326 
327 EXCEPTION
328     WHEN OTHERS THEN
329         arp_util.debug('EXCEPTION:  arp_trx_util.boolean_to_varchar2()');
330         RAISE;
331 
332 END;
333 
334 /*===========================================================================+
335  | FUNCTION                                                                  |
336  |    detect_freight_only_rules_case	                                     |
337  |                                                                           |
338  | DESCRIPTION                                                               |
339  |    Returns TRUE if the specified transaction is a header freight only     |
340  |    transaction with rules.						     |
341  |                                                                           |
342  |    If the case is detected, the function returns TRUE and puts a warning  |
343  |    message on the message stack.					     |
344  |									     |
345  | SCOPE - PUBLIC                                                            |
346  |                                                                           |
347  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
348  |    arp_util.debug                                                         |
349  |                                                                           |
350  | ARGUMENTS  : IN:                                                          |
351  |		      p_customer_trx_id					     |
352  |              OUT:                                                         |
353  |		      None						     |
354  |                                                                           |
355  | RETURNS    :       TRUE if the specified transaction is a freight only    |
356  |                         transaction with rules.                           |
357  |		      FALSE otherwise.					     |
358  |                                                                           |
359  | NOTES                                                                     |
360  |                                                                           |
361  | MODIFICATION HISTORY                                                      |
362  |     25-JUL-95  Charlie Tomberg     Created                                |
363  |                                                                           |
364  +===========================================================================*/
365 
366 
367 FUNCTION detect_freight_only_rules_case( p_customer_trx_id IN
368                                          ra_customer_trx.customer_trx_id%type )
369                       RETURN BOOLEAN IS
370 
371    l_result  varchar2(2);
372 
373 BEGIN
374    arp_util.debug('arp_trx_util.detect_freight_only_rules_case()+');
375 
376 
377    SELECT DECODE( MAX(t.customer_trx_id),
378                   NULL, 'N',
379                       'Y')
380    INTO   l_result
381    FROM   ra_customer_trx t,
382           ra_customer_trx_lines l,
383           ra_customeR_trx_lines frt
384    WHERE  t.customer_trx_id              = p_customer_trx_id
385    AND    t.customer_trx_id              = frt.customer_trx_id
386    AND    frt.line_type                  = 'FREIGHT'
387    AND    frt.link_to_cust_trx_line_id  IS NULL
388    AND    t.customer_trx_id              = l.customer_trx_id(+)
389    AND    'FREIGHT'                     <> l.line_type(+)
390    AND    t.invoicing_rule_id           IS NOT NULL
391    AND    l.customer_trx_line_id        IS NULL;
392 
393    IF      ( l_result = 'Y' )
394    THEN    fnd_message.set_name('AR', 'AR_INV_RULE_CLEARED');
395            RETURN(TRUE);
396    ELSE    RETURN FALSE;
397    END IF;
398 
399    arp_util.debug('arp_trx_util.detect_freight_only_rules_case()-');
400 
401 EXCEPTION
402  WHEN OTHERS THEN
403    arp_util.debug('EXCEPTION:  arp_trx_util.detect_freight_only_rules_case()');
404    RAISE;
405 
406 END;
407 
408 
409 /*===========================================================================+
410  | PROCEDURE                                                                 |
411  |    transaction_balances						     |
412  |                                                                           |
413  | DESCRIPTION                                                               |
414  |    Determines the balances for a transaction				     |
415  |                                                                           |
416  | SCOPE - PUBLIC                                                            |
417  |                                                                           |
418  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
419  |    arp_util.debug                                                         |
420  |                                                                           |
421  | ARGUMENTS  : IN:                                                          |
422  |                    p_customer_trx_id         - identifies the transaction |
423  |                    p_open_receivables_flag                                |
424  |                    p_exchange_rate                                        |
425  |                    p_mode           - Can be 'ALL'  or 'SUMMARY'          |
426  |                                     - All balances are returned in ALL    |
427  |                                       mode. Only the Txn. original and    |
428  |                                       remaining balances are returned     |
429  |                                       in SUMMARY mode.                    |
430  |                                                                           |
431  |                    p_currency_mode  - Can be 'E'(ntered) or 'A'(ll)       |
432  |                                     - The base currency amounts are only  |
433  |                                       calculated and returned in 'A' mode.|
434  |              OUT:                                                         |
435  |                    < entered currency balances >                          |
436  |                    < base currency balances >                             |
437  |                                                                           |
438  | NOTES                                                                     |
439  |     Rounding errors for the base amounts are corrected in this procedure  |
440  |     by putting the rounding error on the line balances. This may not be   |
441  |     the same as how the rounding errors are corrected on the actual       |
442  |     transaction. Therefore, the base line, tax and freight balances may   |
443  |     not be accurate. The totals are always accurate, however.             |
444  |                                                                           |
445  | MODIFICATION HISTORY                                                      |
446  |     31-AUG-95  Charlie Tomberg     Created                                |
447  |                                                                           |
448  +===========================================================================*/
449 
450 
451 PROCEDURE transaction_balances(
452                               p_customer_trx_id             IN
453                                         ra_customer_trx.customer_trx_id%type,
454                               p_open_receivables_flag       IN
455                                  ra_cust_trx_types.accounting_affect_flag%type,
456                               p_exchange_rate               IN
457                                  ra_customer_trx.exchange_rate%type,
458                               p_mode                        IN VARCHAR2,
459                               p_currency_mode               IN VARCHAR2,
460                               p_line_original              OUT NOCOPY NUMBER,
461                               p_line_remaining             OUT NOCOPY NUMBER,
462                               p_tax_original               OUT NOCOPY NUMBER,
463                               p_tax_remaining              OUT NOCOPY NUMBER,
464                               p_freight_original           OUT NOCOPY NUMBER,
465                               p_freight_remaining          OUT NOCOPY NUMBER,
466                               p_charges_original           OUT NOCOPY NUMBER,
467                               p_charges_remaining          OUT NOCOPY NUMBER,
468                               p_line_discount              OUT NOCOPY NUMBER,
469                               p_tax_discount               OUT NOCOPY NUMBER,
470                               p_freight_discount           OUT NOCOPY NUMBER,
471                               p_charges_discount           OUT NOCOPY NUMBER,
472                               p_total_discount             OUT NOCOPY NUMBER,
473                               p_total_original             OUT NOCOPY NUMBER,
474                               p_total_remaining            OUT NOCOPY NUMBER,
475                               p_line_receipts              OUT NOCOPY NUMBER,
476                               p_tax_receipts               OUT NOCOPY NUMBER,
477                               p_freight_receipts           OUT NOCOPY NUMBER,
478                               p_charges_receipts           OUT NOCOPY NUMBER,
479                               p_total_receipts             OUT NOCOPY NUMBER,
480                               p_line_credits               OUT NOCOPY NUMBER,
481                               p_tax_credits                OUT NOCOPY NUMBER,
482                               p_freight_credits            OUT NOCOPY NUMBER,
483                               p_total_credits              OUT NOCOPY NUMBER,
484                               p_line_adjustments           OUT NOCOPY NUMBER,
485                               p_tax_adjustments            OUT NOCOPY NUMBER,
486                               p_freight_adjustments        OUT NOCOPY NUMBER,
487                               p_charges_adjustments        OUT NOCOPY NUMBER,
488                               p_total_adjustments          OUT NOCOPY NUMBER,
489                               p_aline_adjustments          OUT NOCOPY NUMBER,
490                               p_atax_adjustments           OUT NOCOPY NUMBER,
491                               p_afreight_adjustments       OUT NOCOPY NUMBER,
492                               p_acharges_adjustments       OUT NOCOPY NUMBER,
493                               p_atotal_adjustments         OUT NOCOPY NUMBER,
494                               p_base_line_original         OUT NOCOPY NUMBER,
495                               p_base_line_remaining        OUT NOCOPY NUMBER,
496                               p_base_tax_original          OUT NOCOPY NUMBER,
497                               p_base_tax_remaining         OUT NOCOPY NUMBER,
498                               p_base_freight_original      OUT NOCOPY NUMBER,
499                               p_base_freight_remaining     OUT NOCOPY NUMBER,
500                               p_base_charges_original      OUT NOCOPY NUMBER,
501                               p_base_charges_remaining     OUT NOCOPY NUMBER,
502                               p_base_line_discount         OUT NOCOPY NUMBER,
503                               p_base_tax_discount          OUT NOCOPY NUMBER,
504                               p_base_freight_discount      OUT NOCOPY NUMBER,
505                               p_base_total_discount        OUT NOCOPY NUMBER,
506                               p_base_total_original        OUT NOCOPY NUMBER,
507                               p_base_total_remaining       OUT NOCOPY NUMBER,
508                               p_base_line_receipts         OUT NOCOPY NUMBER,
509                               p_base_tax_receipts          OUT NOCOPY NUMBER,
510                               p_base_freight_receipts      OUT NOCOPY NUMBER,
511                               p_base_charges_receipts      OUT NOCOPY NUMBER,
512                               p_base_total_receipts        OUT NOCOPY NUMBER,
513                               p_base_line_credits          OUT NOCOPY NUMBER,
514                               p_base_tax_credits           OUT NOCOPY NUMBER,
515                               p_base_freight_credits       OUT NOCOPY NUMBER,
516                               p_base_total_credits         OUT NOCOPY NUMBER,
517                               p_base_line_adjustments      OUT NOCOPY NUMBER,
518                               p_base_tax_adjustments       OUT NOCOPY NUMBER,
519                               p_base_freight_adjustments   OUT NOCOPY NUMBER,
520                               p_base_charges_adjustments   OUT NOCOPY NUMBER,
521                               p_base_total_adjustments     OUT NOCOPY NUMBER,
522                               p_base_aline_adjustments     OUT NOCOPY NUMBER,
523                               p_base_atax_adjustments      OUT NOCOPY NUMBER,
524                               p_base_afreight_adjustments  OUT NOCOPY NUMBER,
525                               p_base_acharges_adjustments  OUT NOCOPY NUMBER,
526                               p_base_atotal_adjustments    OUT NOCOPY NUMBER
527                              ) IS
528 
529 
530 BEGIN
531    arp_util.debug('arp_trx_util.transaction_balances()+');
532 
533    arp_bal_util.transaction_balances(
534                               p_customer_trx_id,
535                               p_open_receivables_flag,
536                               p_exchange_rate,
537                               p_mode,
538                               p_currency_mode,
539                               p_line_original,
540                               p_line_remaining,
541                               p_tax_original,
542                               p_tax_remaining,
543                               p_freight_original,
544                               p_freight_remaining,
545                               p_charges_original,
546                               p_charges_remaining,
547                               p_line_discount,
548                               p_tax_discount,
549                               p_freight_discount,
550                               p_charges_discount,
551                               p_total_discount,
552                               p_total_original,
553                               p_total_remaining,
554                               p_line_receipts,
555                               p_tax_receipts,
556                               p_freight_receipts,
557                               p_charges_receipts,
558                               p_total_receipts,
559                               p_line_credits,
560                               p_tax_credits,
561                               p_freight_credits,
562                               p_total_credits,
563                               p_line_adjustments,
564                               p_tax_adjustments,
565                               p_freight_adjustments,
566                               p_charges_adjustments,
567                               p_total_adjustments,
568                               p_aline_adjustments,
569                               p_atax_adjustments,
570                               p_afreight_adjustments,
571                               p_acharges_adjustments,
572                               p_atotal_adjustments,
573                               p_base_line_original,
574                               p_base_line_remaining,
575                               p_base_tax_original,
576                               p_base_tax_remaining,
577                               p_base_freight_original,
578                               p_base_freight_remaining,
579                               p_base_charges_original,
580                               p_base_charges_remaining,
581                               p_base_line_discount,
582                               p_base_tax_discount,
583                               p_base_freight_discount,
584                               p_base_total_discount,
585                               p_base_total_original,
586                               p_base_total_remaining,
587                               p_base_line_receipts,
588                               p_base_tax_receipts,
589                               p_base_freight_receipts,
590                               p_base_charges_receipts,
591                               p_base_total_receipts,
592                               p_base_line_credits,
593                               p_base_tax_credits,
594                               p_base_freight_credits,
595                               p_base_total_credits,
596                               p_base_line_adjustments,
597                               p_base_tax_adjustments,
598                               p_base_freight_adjustments,
599                               p_base_charges_adjustments,
600                               p_base_total_adjustments,
601                               p_base_aline_adjustments,
602                               p_base_atax_adjustments,
603                               p_base_afreight_adjustments,
604                               p_base_acharges_adjustments,
605                               p_base_atotal_adjustments
606                              );
607 
608 
609 
610    arp_util.debug('arp_trx_util.transaction_balances()-');
611 
612 EXCEPTION
613  WHEN OTHERS THEN
614    arp_util.debug('EXCEPTION:  arp_trx_util.transaction_balances()');
615    RAISE;
616 
617 END;
618 
619 /*===========================================================================+
620  | FUNCTION                                                                  |
621  |    get_summary_trx_balances      	                                     |
622  |                                                                           |
623  | DESCRIPTION                                                               |
624  |    Returns the original and remaining balances for a transaction.         |
625  |    This procedure does not provide the line type breakdown for credits,   |
626  |    adjustments, receipts or discounts. It also does not provide base      |
627  |    currency amounts.                                                      |
628  |									     |
629  | SCOPE - PUBLIC                                                            |
630  |                                                                           |
631  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
632  |    arp_util.debug                                                         |
633  |                                                                           |
634  | ARGUMENTS  : IN:                                                          |
635  |		      p_customer_trx_id					     |
636  |                    p_open_receivables_flag                                |
637  |                    p_exchange_rate                                        |
638  |              OUT:                                                         |
639  |                    p_line_original                                        |
640  |                    p_line_remaining                                       |
641  |                    p_tax_original                                         |
642  |                    p_tax_remaining                                        |
643  |                    p_freight_original                                     |
644  |                    p_freight_remaining                                    |
645  |                    p_charges_original                                     |
646  |                    p_charges_remaining                                    |
647  |                    p_total_original                                       |
648  |                    p_total_remaining                                      |
649  |                                                                           |
650  |                                                                           |
651  | NOTES                                                                     |
652  |                                                                           |
653  | MODIFICATION HISTORY                                                      |
654  |     05-SEP-95  Charlie Tomberg     Created                                |
655  |                                                                           |
656  +===========================================================================*/
657 
658 
659 PROCEDURE get_summary_trx_balances( p_customer_trx_id       IN
660                                         ra_customer_trx.customer_trx_id%type,
661                               p_open_receivables_flag       IN
662                                  ra_cust_trx_types.accounting_affect_flag%type,
663                               p_line_original              OUT NOCOPY NUMBER,
664                               p_line_remaining             OUT NOCOPY NUMBER,
665                               p_tax_original               OUT NOCOPY NUMBER,
666                               p_tax_remaining              OUT NOCOPY NUMBER,
667                               p_freight_original           OUT NOCOPY NUMBER,
668                               p_freight_remaining          OUT NOCOPY NUMBER,
669                               p_charges_original           OUT NOCOPY NUMBER,
670                               p_charges_remaining          OUT NOCOPY NUMBER,
671                               p_total_original             OUT NOCOPY NUMBER,
672                               p_total_remaining            OUT NOCOPY NUMBER )
673                       IS
674    l_dummy  NUMBER;
675 
676 
677 BEGIN
678    arp_util.debug('arp_trx_util.get_summary_trx_balances()+');
679 
680    arp_bal_util.get_summary_trx_balances( p_customer_trx_id,
681                                           p_open_receivables_flag,
682                                           p_line_original,
683                                           p_line_remaining,
684                                           p_tax_original,
685                                           p_tax_remaining,
686                                           p_freight_original,
687                                           p_freight_remaining,
688                                           p_charges_original,
689                                           p_charges_remaining,
690                                           p_total_original,
691                                           p_total_remaining );
692 
693    arp_util.debug('arp_trx_util.get_summary_trx_balances()-');
694 
695 EXCEPTION
696  WHEN OTHERS THEN
697    arp_util.debug('EXCEPTION:  arp_trx_util.get_summary_trx_balances()');
698    RAISE;
699 
700 END;
701 
702 /*===========================================================================+
703  | FUNTION                                                                   |
704  |    IS_FV_ENABLED                                                          |
705  |                                                                           |
706  | DESCRIPTION                                                               |
707  |    Checks whether the Federal is enabled or not using                     |
708  |    Federal Financial api fv_install.enabled.                              |
709  |                                                                           |
710  | SCOPE - PRIVATE                                                           |
711  |                                                                           |
712  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
713  |         arp_standard.debug                                                |
714  |                                                                           |
715  | ARGUMENTS  : IN:                                                          |
716  |                                                                           |
717  |             OUT:                                                          |
718  |                                                                           |
719  | RETURNS    : T - True, F - False                                          |
720  |                                                                           |
721  | NOTES                                                                     |
722  |                                                                           |
723  | MODIFICATION HISTORY                                                      |
724  |     23-Jun-08	      Thirumalaisamy      	Created                        |
725  +===========================================================================*/
726 FUNCTION IS_FV_ENABLED RETURN VARCHAR2
727   IS
728 BEGIN
729   IF PG_DEBUG in ('Y', 'C') THEN
730       arp_standard.debug ('inside IS_FV_ENABLED');
731    END IF;
732 
733   IF(fv_install.enabled) THEN
734     RETURN 'T';
735   ELSE
736     RETURN 'F';
737   END IF;
738 
739 EXCEPTION
740     WHEN OTHERS THEN
741       arp_standard.debug ('Exception occurred in IS_FV_ENABLED :'||SQLERRM);
742       RETURN 'F';
743 END;
744 
745 /*===========================================================================+
746  | FUNTION                                                                   |
747  |    IS_CCR_SUPPLIER                                                        |
748  |                                                                           |
749  | DESCRIPTION                                                               |
750  |    Checks the given party/site is CCR supplier/Site                       |
751  |                                                                           |
752  | SCOPE - PRIVATE                                                           |
753  |                                                                           |
754  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
755  |         arp_standard.debug                                                |
756  |                                                                           |
757  | ARGUMENTS  : IN:                                                          |
758  |                   p_object_type - CUST - Customer, ADDR - Address         |
759  |             OUT:                                                          |
760  |                                                                           |
761  | RETURNS    : T - True, F - False                                          |
762  |                                                                           |
763  | NOTES                                                                     |
764  |                                                                           |
765  | MODIFICATION HISTORY                                                      |
766  |     23-Jun-08	      Thirumalaisamy      	Created                        |
767  +===========================================================================*/
768 
769 FUNCTION IS_CCR_SUPPLIER(
770  p_object_type           IN      VARCHAR2 ,
771  p_object_id             IN      NUMBER
772  )RETURN VARCHAR2
773 IS
774 l_api_version           NUMBER        := 1.0;
775 l_init_msg_list         VARCHAR2(1)   := FND_API.G_TRUE;
776 l_out_status            VARCHAR2(1);
777 is_enabled              VARCHAR2(1);
778 l_return_status         VARCHAR2(1);
779 l_msg_count             NUMBER;
780 l_msg_data              VARCHAR2(3000);
781 l_error_code            NUMBER;
782 l_ccr_id                NUMBER;
783 l_vendor_id             NUMBER;
784 
785 cursor l_addr_site_cur is
786 select vendor_site_id from ap_supplier_sites_all
787 WHERE party_site_id = p_object_id;
788 
789 BEGIN
790 
791     IF PG_DEBUG in ('Y', 'C') THEN
792         arp_standard.debug ('p_object_type = '||p_object_type || ', p_object_id = '||p_object_id);
793     END IF;
794 
795     l_out_status := 'F';
796     is_enabled := ARP_TRX_UTIL.IS_FV_ENABLED();
797 
798     IF PG_DEBUG in ('Y', 'C') THEN
799         arp_standard.debug ('is_enabled = '||is_enabled);
800     END IF;
801 
802     IF is_enabled <> 'T' THEN
803         RETURN l_out_status;
804     ELSIF (p_object_type = 'CUST') THEN
805         SELECT vendor_id INTO l_vendor_id FROM po_vendors WHERE party_id = p_object_id;
806         FV_CCR_GRP.FV_IS_CCR(
807             		  l_api_version,
808             		  l_init_msg_list,
809             		  l_vendor_id,
810             		  'S',
811             		  l_return_status,
812             		  l_msg_count,
813             		  l_msg_data,
814             		  l_ccr_id,
815             		  l_out_status,
816             		  l_error_code
817             		);
818         IF PG_DEBUG in ('Y', 'C') THEN
819             arp_standard.debug ('l_return_status = '||l_return_status);
820             arp_standard.debug ('l_msg_count = '||l_msg_count);
821             arp_standard.debug ('l_msg_data = '||l_msg_data);
822             arp_standard.debug ('l_ccr_id = '||l_ccr_id);
823             arp_standard.debug ('l_out_status = '||l_out_status);
824             arp_standard.debug ('l_error_code = '||l_error_code);
825 
826         END IF;
827     ELSIF (p_object_type = 'ADDR') THEN
828           for  i in l_addr_site_cur  loop
829               IF PG_DEBUG in ('Y', 'C') THEN
830                   arp_standard.debug ('i.vendor_site_id  = '||i.vendor_site_id);
831               END IF;
832       	      FV_CCR_GRP.FV_IS_CCR(
833       			  l_api_version,
834       			  l_init_msg_list,
835       			  i.vendor_site_id,
836       			  'T',
837       			  l_return_status,
838       			  l_msg_count,
839       			  l_msg_data,
840       			  l_ccr_id,
841       			  l_out_status,
842       			  l_error_code
843       			);
844       	      IF PG_DEBUG in ('Y', 'C') THEN
845                   arp_standard.debug ('l_return_status = '||l_return_status);
846                   arp_standard.debug ('l_msg_count = '||l_msg_count);
847                   arp_standard.debug ('l_msg_data = '||l_msg_data);
848                   arp_standard.debug ('l_ccr_id = '||l_ccr_id);
849                   arp_standard.debug ('l_out_status = '||l_out_status);
850                   arp_standard.debug ('l_error_code = '||l_error_code);
851               END IF;
852 
853       	      IF l_out_status <> 'F' THEN
854       	  	return l_out_status;
855       	       END IF;
856     	 END LOOP;
857     END IF;
858 RETURN l_out_status;
859 EXCEPTION
860     WHEN OTHERS THEN
861       arp_standard.debug ('Exception occurred in IS_CCR_SUPPLIER: '||SQLERRM);
862       RETURN 'F';
863 END ;
864 
865   /*---------------------------------------------+
866    |   Package initialization section.           |
867    +---------------------------------------------*/
868 PROCEDURE init IS
869 BEGIN
870 
871   pg_base_curr_code    := arp_global.functional_currency;
872   pg_base_precision    := arp_global.base_precision;
873   pg_base_min_acc_unit := arp_global.base_min_acc_unit;
874 
875 END init;
876 
877 BEGIN
878    init;
879 END ARP_TRX_UTIL;