DBA Data[Home] [Help]

PACKAGE BODY: APPS.AR_OM_PREPAY_REFUND_PVT

Source


1 PACKAGE BODY AR_OM_PREPAY_REFUND_PVT AS
2 /* $Header: AROMRFNB.pls 115.3 2004/05/03 19:49:26 jypandey noship $ */
3 
4 /*=======================================================================+
5  |  Package Global Constants
6  +=======================================================================*/
7 G_PKG_NAME      CONSTANT VARCHAR2(30)   := 'AR_OM_PREPAY_REFUND_PVT';
8 G_MSG_UERROR    CONSTANT NUMBER         := FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR;
9 G_MSG_ERROR     CONSTANT NUMBER         := FND_MSG_PUB.G_MSG_LVL_ERROR;
10 G_MSG_SUCCESS   CONSTANT NUMBER         := FND_MSG_PUB.G_MSG_LVL_SUCCESS;
11 G_MSG_HIGH      CONSTANT NUMBER         := FND_MSG_PUB.G_MSG_LVL_DEBUG_HIGH;
12 G_MSG_MEDIUM    CONSTANT NUMBER         := FND_MSG_PUB.G_MSG_LVL_DEBUG_MEDIUM;
13 G_MSG_LOW       CONSTANT NUMBER         := FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW;
14 
15 /*========================================================================
16  | Prototype Declarations Procedures
17  *=======================================================================*/
18 
19  PG_DEBUG varchar2(1) := NVL(FND_PROFILE.value('AFLOG_ENABLED'), 'N');
20 
21 /*========================================================================
22  | Prototype Declarations Functions
23  *=======================================================================*/
24 /*=======================================================================
25  | PUBLIC Procedure refund_prepayment_wrapper
26  |
27  | DESCRIPTION
28  |      This wrapper is same as ar_prepayments except this accepts 1 additional
29  |      parameter p_bank_account_id  : This paramter along with p_receipt_method_id
30  |       if having a value populate the global  variables in
31  |       AR_PREPAYMENTS.Refund_Prepayment
32  |      ----------------------------------------
33  |
34  | PSEUDO CODE/LOGIC
35  |
36  | PARAMETERS
37  |
38  |
39  | RETURNS
40  |      nothing
41  |
42  | KNOWN ISSUES
43  |
44  |
45  |
46  | NOTES
47  |
48  |
49  |
50  | MODIFICATION HISTORY
51  | Date                  Author         Description of Changes
52  | Aug-13-2003         Jyoti Pandey    Created
53  | May-03-2004         Jyoti Pandey    Bug:3605509 Global variables for
54  |                                     receipt methos and bank account ID
55  |                                     not getting defaulted properly.
56  *=======================================================================*/
57  PROCEDURE Refund_Prepayment_Wrapper(
58     -- Standard API parameters.
59       p_api_version                IN  NUMBER,
60       p_init_msg_list              IN  VARCHAR2 := FND_API.G_FALSE,
61       p_commit                     IN  VARCHAR2 := FND_API.G_FALSE,
62       p_validation_level           IN  NUMBER   := FND_API.G_VALID_LEVEL_FULL,
63       x_return_status              OUT NOCOPY VARCHAR2,
64       x_msg_count                  OUT NOCOPY NUMBER,
65       x_msg_data                   OUT NOCOPY VARCHAR2,
66       p_prepay_application_id      OUT NOCOPY ar_receivable_applications.receivable_application_id%TYPE,
67       p_number_of_refund_receipts  OUT NOCOPY NUMBER,
68     -------Multiple prepayments projecti Additional parameter for credit card
69     -------refunds to be populated as global variables
70       p_bank_account_id   IN NUMBER,
71       p_receipt_method_id IN NUMBER,
72 
73       p_receipt_number             IN ar_cash_receipts.receipt_number%TYPE DEFAULT NULL,
74       p_cash_receipt_id            IN ar_cash_receipts.cash_receipt_id%TYPE DEFAULT NULL,
75       p_receivable_application_id  IN  ar_receivable_applications.receivable_application_id%TYPE DEFAULT NULL,
76       p_receivables_trx_id         IN ar_receivable_applications.receivables_trx_id%TYPE DEFAULT NULL,
77       p_refund_amount              IN ar_receivable_applications.amount_applied%TYPE DEFAULT NULL,
78       p_refund_date                IN ar_receivable_applications.apply_date%TYPE DEFAULT NULL,
79       p_refund_gl_date             IN ar_receivable_applications.gl_date%TYPE DEFAULT NULL,
80       p_ussgl_transaction_code     IN ar_receivable_applications.ussgl_transaction_code%TYPE DEFAULT NULL,
81       p_attribute_rec              IN ar_receipt_api_pub.attribute_rec_type
82                                       DEFAULT ar_receipt_api_pub.attribute_rec_const,
83     -- ******* Global Flexfield parameters *******
84       p_global_attribute_rec       IN ar_receipt_api_pub.global_attribute_rec_type
85                                       DEFAULT ar_receipt_api_pub.global_attribute_rec_const,
86       p_comments                   IN ar_receivable_applications.comments%TYPE DEFAULT NULL,
87       p_payment_set_id             IN NUMBER DEFAULT NULL
88     ) IS
89 
90 BEGIN
91       IF PG_DEBUG in ('Y', 'C') THEN
92          arp_standard.debug('AR_OM_PREPAY_REFUND_PVT.refund_prepayment_wrapper ()+');
93       END IF;
94 
95       -- first reinitialize ARP_GLOBAL
96         arp_global.init_global;
97 
98 
99       /*-----------------------------------------+
100         |   Initialize return status to SUCCESS   |
101         +-----------------------------------------*/
102 
103         x_return_status := FND_API.G_RET_STS_SUCCESS;
104 
105 
106        /*--------------------------------------------------------------+
107         |   Initialize message list if p_init_msg_list is set to TRUE  |
108         +--------------------------------------------------------------*/
109 
110         IF FND_API.to_Boolean( p_init_msg_list )
111           THEN
112               FND_MSG_PUB.initialize;
113         END IF;
114 
115        /*-------------------------------------------------+
116         | Initialize SOB/org dependent variables          |
117         +-------------------------------------------------*/
118         arp_global.init_global;
119         arp_standard.init_standard;
120 
121 
122        -----------------------------------------------+
123        -- Multiple Prepay project, Check if p_receipt_method_id and p_bank_account_id
124        -- are passed. If one is passed then other must be passed to. This is the
125        -- desired by the OM for Credit card refunds to a particular Credit card
126        -- based on the receipt method
127 
128 
129 
130        if p_bank_account_id is not NULL then
131 
132           --make sure the receipt_method_id is passed
133           if p_receipt_method_id is NULL then
134              FND_MESSAGE.SET_NAME('AR','AR_MAND_PARAMETER_NULL');
135              FND_MESSAGE.SET_TOKEN('PARAM','p_receipt_method_id');
136              FND_MSG_PUB.Add;
137              x_return_status := FND_API.G_RET_STS_ERROR;
138              RETURN;
139           end if;
140 
141          --make sure the payment_set_id is passed
142           if p_payment_set_id is NULL then
143              FND_MESSAGE.SET_NAME('AR','AR_MAND_PARAMETER_NULL');
144              FND_MESSAGE.SET_TOKEN('PARAM','p_payment_set_id');
145              FND_MSG_PUB.Add;
146              x_return_status := FND_API.G_RET_STS_ERROR;
147              RETURN;
148           end if;
149 
150        end if;
151 
152         ---Bug 3605509 The global variables for Prepayments API should
153         --- be initialized even if the passed parameters p_receipt_method_id
154         --- and p_bank_account_id are null
155 
156          AR_PREPAYMENTS.G_REFUND_RECEIPT_METHOD_ID := p_receipt_method_id;
157          AR_PREPAYMENTS.G_REFUND_BANK_ACCOUNT_ID   := p_bank_account_id;
158 
159 
160         ---Make a callout the AR_PREPAYMENTS.REFUND_PREPYMENTS
161        AR_PREPAYMENTS.Refund_Prepayments(
162         -- Standard API parameters.
163            p_api_version    ,
164            p_init_msg_list  ,
165            p_commit         ,
166            p_validation_level ,
167            x_return_status ,
168            x_msg_count     ,
169            x_msg_data      ,
170            p_prepay_application_id ,
171            p_number_of_refund_receipts ,
172            p_receipt_number            ,
173            p_cash_receipt_id           ,
174            p_receivable_application_id ,
175            p_receivables_trx_id        ,
176            p_refund_amount             ,
177            p_refund_date               ,
178            p_refund_gl_date            ,
179            p_ussgl_transaction_code    ,
180            p_attribute_rec             ,
181          -- ******* Global Flexfield parameters *******
182            p_global_attribute_rec      ,
183            p_comments                  ,
184            p_payment_set_id            );
185 
186 
187 
188         FND_MSG_PUB.Count_And_Get(p_encoded => FND_API.G_FALSE,
189                                   p_count => x_msg_count,
190                                   p_data  => x_msg_data);
191 
192             IF PG_DEBUG in ('Y', 'C') THEN
193                arp_util.debug('ar_prepayments_pub.Create_Prepayment ()-');
194             END IF;
195 
196 EXCEPTION
197 WHEN OTHERS THEN
198    IF (SQLCODE = -20001) THEN
199        ROLLBACK TO Create_Prepayment_PVT;
200 
201        --  Display_Parameters;
202        x_return_status := FND_API.G_RET_STS_ERROR ;
203        FND_MESSAGE.SET_NAME ('AR','GENERIC_MESSAGE');
204        FND_MESSAGE.SET_TOKEN('GENERIC_TEXT','REFUND_PREPAYMENTS : '||SQLERRM);
205        FND_MSG_PUB.Add;
206 
207        FND_MSG_PUB.Count_And_Get( p_encoded => FND_API.G_FALSE,
208                                   p_count  =>  x_msg_count,
209                                   p_data   => x_msg_data
210                                                 );
211        RETURN;
212    ELSE
213          x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
214          FND_MESSAGE.SET_NAME ('AR','GENERIC_MESSAGE');
215          FND_MESSAGE.SET_TOKEN('GENERIC_TEXT','REFUND_PREPAYMENTS : '||SQLERRM);
216          FND_MSG_PUB.Add;
217    END IF;
218 
219    IF PG_DEBUG in ('Y', 'C') THEN
220        arp_util.debug('REFUND_PREPAYMENTS: ' || SQLCODE, G_MSG_ERROR);
221       arp_util.debug('REFUND_PREPAYMENTS: ' || SQLERRM, G_MSG_ERROR);
222    END IF;
223 
224 
225 
226 
227     --   Display_Parameters;
228     FND_MSG_PUB.Count_And_Get(p_encoded => FND_API.G_FALSE,
229                               p_count       =>      x_msg_count,
230                               p_data        =>      x_msg_data);
231 
232 
233     IF PG_DEBUG in ('Y', 'C') THEN
234        arp_standard.debug('AR_OM_PREPAY_REFUND_PVT.refund_prepayment_wrapper ()-');
235     END IF;
236 
237 END Refund_Prepayment_Wrapper;
238 
239 END AR_OM_PREPAY_REFUND_PVT;