DBA Data[Home] [Help]

PACKAGE BODY: APPS.AR_PREPAYMENTS_PUB

Source


1 PACKAGE BODY AR_PREPAYMENTS_PUB AS
2 /* $Header: ARPPAYAB.pls 120.12.12010000.2 2008/09/30 10:07:56 nemani ship $ */
3 
4 /*=======================================================================+
5  |  Package Global Constants
6  +=======================================================================*/
7 G_PKG_NAME      CONSTANT VARCHAR2(30)   := 'AR_PREPAYMENTS_PUB';
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 Create_Prepayment
26  |
27  | DESCRIPTION
28  |      Create prepayment receipt and put it on prepayment
29  |      ----------------------------------------
30  |
31  | PSEUDO CODE/LOGIC
32  |
33  | PARAMETERS
34  |
35  |
36  | RETURNS
37  |      nothing
38  |
39  | KNOWN ISSUES
40  |
41  |
42  |
43  | NOTES
44  |
45  |
46  |
47  | MODIFICATION HISTORY
48  | Date                  Author         Description of Changes
49  | 10-SEP-2001           S Nambiar      Created
50  | 10-MAR-2002           S Nambiar      Bug 2315864 - Validate customer
51  |                                      bank account id,raise error if
52  |                                      NULL is passed
53  | 09-DEC-2003           J Pandey       Bug3230122 forward port of 3220078
54  *=======================================================================*/
55  PROCEDURE Create_Prepayment(
56 -- Standard API parameters.
57       p_api_version      IN  NUMBER,
58       p_init_msg_list    IN  VARCHAR2 := FND_API.G_FALSE,
59       p_commit           IN  VARCHAR2 := FND_API.G_FALSE,
60       p_validation_level IN  NUMBER   := FND_API.G_VALID_LEVEL_FULL,
61       x_return_status    OUT NOCOPY VARCHAR2,
62       x_msg_count        OUT NOCOPY NUMBER,
63       x_msg_data         OUT NOCOPY VARCHAR2,
64  -- Receipt info. parameters
65       p_usr_currency_code IN  VARCHAR2 DEFAULT NULL, --the translated currency code
66       p_currency_code     IN  ar_cash_receipts.currency_code%TYPE DEFAULT NULL,
67       p_usr_exchange_rate_type  IN  VARCHAR2 DEFAULT NULL,
68       p_exchange_rate_type IN  ar_cash_receipts.exchange_rate_type%TYPE DEFAULT NULL,
69       p_exchange_rate      IN  ar_cash_receipts.exchange_rate%TYPE DEFAULT NULL,
70       p_exchange_rate_date IN  ar_cash_receipts.exchange_date%TYPE DEFAULT NULL,
71       p_amount                  IN  ar_cash_receipts.amount%TYPE,
72       p_factor_discount_amount  IN  ar_cash_receipts.factor_discount_amount%TYPE DEFAULT NULL,
73 
74      -------Multiple Prepay project: Receipt Number should be IN OUT
75       p_receipt_number   IN OUT NOCOPY  ar_cash_receipts.receipt_number%TYPE ,
76 
77       p_receipt_date     IN  ar_cash_receipts.receipt_date%TYPE DEFAULT NULL,
78       p_gl_date          IN  ar_cash_receipt_history.gl_date%TYPE DEFAULT NULL,
79       p_maturity_date    IN  DATE DEFAULT NULL,
80       p_postmark_date    IN  DATE DEFAULT NULL,
81       p_customer_id      IN  ar_cash_receipts.pay_from_customer%TYPE DEFAULT NULL,
82       p_customer_name    IN  hz_parties.party_name%TYPE DEFAULT NULL,
83       p_customer_number  IN  hz_cust_accounts.account_number%TYPE DEFAULT NULL,
84       p_customer_bank_account_id   IN  ar_cash_receipts.customer_bank_account_id%TYPE DEFAULT NULL,
85       p_customer_bank_account_num  IN  ap_bank_accounts.bank_account_num%TYPE DEFAULT NULL,
86       p_customer_bank_account_name IN  ap_bank_accounts.bank_account_name%TYPE DEFAULT NULL,
87       p_location               IN  hz_cust_site_uses.location%TYPE DEFAULT NULL,
88       p_customer_site_use_id   IN  hz_cust_site_uses.site_use_id%TYPE DEFAULT NULL,
89       p_customer_receipt_reference       IN  ar_cash_receipts.customer_receipt_reference%TYPE DEFAULT NULL,
90       p_override_remit_account_flag      IN  ar_cash_receipts.override_remit_account_flag%TYPE DEFAULT NULL,
91       p_remittance_bank_account_id       IN  ar_cash_receipts.remit_bank_acct_use_id%type DEFAULT NULL,
92       p_remittance_bank_account_num      IN  ce_bank_accounts.bank_account_num%TYPE DEFAULT NULL,
93       p_remittance_bank_account_name     IN  ce_bank_accounts.bank_account_name%TYPE DEFAULT NULL,
94       p_deposit_date                     IN  ar_cash_receipts.deposit_date%TYPE DEFAULT NULL,
95       p_receipt_method_id                IN  ar_cash_receipts.receipt_method_id%TYPE DEFAULT NULL,
96       p_receipt_method_name              IN  ar_receipt_methods.name%TYPE DEFAULT NULL,
97       p_doc_sequence_value               IN  NUMBER   DEFAULT NULL,
98       p_ussgl_transaction_code           IN  ar_cash_receipts.ussgl_transaction_code%TYPE DEFAULT NULL,
99       p_anticipated_clearing_date        IN  ar_cash_receipts.anticipated_clearing_date%TYPE DEFAULT NULL,
100       p_called_from                      IN VARCHAR2 DEFAULT NULL,
101       p_attribute_rec                    IN ar_receipt_api_pub.attribute_rec_type
102                                             DEFAULT ar_receipt_api_pub.attribute_rec_const,
103    -- ******* Global Flexfield parameters *******
104       p_global_attribute_rec  IN ar_receipt_api_pub.global_attribute_rec_type
105                                  DEFAULT ar_receipt_api_pub.global_attribute_rec_const,
106       p_receipt_comments      IN VARCHAR2 DEFAULT NULL,
107    -- ***  Notes Receivable Additional Information  ***
108       p_issuer_name           IN ar_cash_receipts.issuer_name%TYPE DEFAULT NULL,
109       p_issue_date            IN ar_cash_receipts.issue_date%TYPE DEFAULT NULL,
110       p_issuer_bank_branch_id IN ar_cash_receipts.issuer_bank_branch_id%TYPE DEFAULT NULL,
111    -- ** OUT NOCOPY variables for Creating receipt
112       p_cr_id                 OUT NOCOPY ar_cash_receipts.cash_receipt_id%TYPE,
113    -- Receipt application parameters
114       p_applied_payment_schedule_id     IN ar_payment_schedules.payment_schedule_id%TYPE DEFAULT NULL,
115       p_amount_applied          IN ar_receivable_applications.amount_applied%TYPE DEFAULT NULL,
116       p_application_ref_type IN VARCHAR2 DEFAULT NULL,
117       p_application_ref_id   IN OUT NOCOPY NUMBER ,
118       p_application_ref_num  IN OUT NOCOPY VARCHAR2 ,
119       p_secondary_application_ref_id IN OUT NOCOPY NUMBER ,
120       p_receivable_trx_id       IN ar_receivable_applications.receivables_trx_id%TYPE DEFAULT NULL,
121       p_amount_applied_from     IN ar_receivable_applications.amount_applied_from%TYPE DEFAULT NULL,
122       p_apply_date              IN ar_receivable_applications.apply_date%TYPE DEFAULT NULL,
123       p_apply_gl_date           IN ar_receivable_applications.gl_date%TYPE DEFAULT NULL,
124       app_ussgl_transaction_code  IN ar_receivable_applications.ussgl_transaction_code%TYPE DEFAULT NULL,
125       p_show_closed_invoices    IN VARCHAR2 DEFAULT 'FALSE',
126       p_move_deferred_tax       IN VARCHAR2 DEFAULT 'Y',
127       app_attribute_rec         IN ar_receipt_api_pub.attribute_rec_type
128                                    DEFAULT ar_receipt_api_pub.attribute_rec_const,
129    -- ******* Global Flexfield parameters *******
130       app_global_attribute_rec  IN ar_receipt_api_pub.global_attribute_rec_type
131                                    DEFAULT ar_receipt_api_pub.global_attribute_rec_const,
132       app_comments              IN ar_receivable_applications.comments%TYPE DEFAULT NULL,
133    -- processor such as iPayments
134       p_payment_server_order_num IN OUT NOCOPY ar_cash_receipts.payment_server_order_num%TYPE,
135       p_approval_code            IN OUT NOCOPY ar_cash_receipts.approval_code%TYPE,
136 
137       ---Bug 3220078 Change the parameter to TRUE
138       p_call_payment_processor  IN VARCHAR2 DEFAULT FND_API.G_TRUE,
139 
140       p_payment_response_error_code OUT NOCOPY VARCHAR2,
141    -- OUT NOCOPY parameter for the Application
142       p_receivable_application_id OUT NOCOPY ar_receivable_applications.receivable_application_id%TYPE,
143       p_payment_set_id            IN OUT NOCOPY NUMBER ,
144       p_org_id                    IN NUMBER DEFAULT NULL,
145       p_payment_trxn_extension_id IN ar_cash_receipts.payment_trxn_extension_id%TYPE
146       ) IS
147 
148 
149 l_cash_receipt_id  	NUMBER(15);
150 l_create_return_status  VARCHAR2(1);
151 l_remit_return_status   VARCHAR2(1);
152 l_payment_set_id   	NUMBER;
153 l_cc_return_status 	VARCHAR2(1);         -- credit card return status
154 l_activity_return_status VARCHAR2(1);        -- credit card return status
155 l_cc_check         	VARCHAR2(1);
156 l_receivables_trx_id 	NUMBER;
157 l_response_error_code  	VARCHAR2(80);
158 
159 --Bug 3220078 --
160 l_cash_receipt_status  ar_receipt_classes.creation_status%type;
161 l_payment_type         ar_receipt_methods.payment_type_code%type;
162 
163 l_api_name       CONSTANT VARCHAR2(20) := 'Create_Prepayment';
164 l_api_version    CONSTANT NUMBER       := 1.0;
165 l_org_return_status VARCHAR2(1);
166 l_org_id                           NUMBER;
167 
168 -- payment uptake
169    CURSOR rct_info_cur IS
170      SELECT cr.receipt_number,
171             cr.amount,
172             cr.currency_code,
173             rm.PAYMENT_CHANNEL_CODE,       /* NEW ADDED */
174             rc.creation_status,            /* AR USE */
175             cr.org_id,
176             cr.payment_trxn_extension_id,
177             party.party_id,
178             cr.pay_from_customer,
179             cr.customer_site_use_id
180      FROM   ar_cash_receipts_all cr,
181             ar_receipt_methods rm,
182             ar_receipt_classes rc,
183             hz_cust_accounts hca,
184             hz_parties    party
185      WHERE  cr.cash_receipt_id = l_cash_receipt_id
186      AND    hca.party_id = party.party_id
187      AND    hca.cust_account_id = cr.pay_from_customer
188      AND  cr.receipt_method_id = rm.receipt_method_id
189      and  rm.receipt_class_id = rc.receipt_class_id;
190 
191             rct_info    rct_info_cur%ROWTYPE;
192             l_cr_rec    ar_cash_receipts_all%ROWTYPE;
193             l_org_type  HR_ALL_ORGANIZATION_UNITS.TYPE%TYPE;
194             l_action VARCHAR2(80);
195             l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
196             l_msg_count NUMBER;
197             l_msg_data  VARCHAR2(2000);
198             l_iby_msg_data VARCHAR2(2000);
199             l_vend_msg_data VARCHAR2(2000);
200            l_payment_trxn_extension_id  ar_cash_receipts.payment_trxn_extension_id%TYPE;
201 
202 /* DECLARE the variables required for the payment engine (CPY ) all the REC TYPES */
203            p_trxn_entity_id    NUMBER;
204            lc_trxn_entity_id   IBY_FNDCPT_COMMON_PUB.Id_tbl_type;
205            l_auth_flag         VARCHAR2(1);
206            l_auth_id           NUMBER;
207 
208 /* END DECLARE the variables required for the payment engine (CPY ) all the REC TYPES */
209 /* DECLARE the variables required for the payment engine (CPY AND AUTH) all the REC TYPES */
210 
211             l_payer_rec             IBY_FNDCPT_COMMON_PUB.PayerContext_rec_type;
212             l_payee_rec             IBY_FNDCPT_TRXN_PUB.PayeeContext_rec_type;
213             l_trxn_entity_id        NUMBER;
214             l_auth_attribs_rec      IBY_FNDCPT_TRXN_PUB.AuthAttribs_rec_type;
215             l_trxn_attribs_rec      IBY_FNDCPT_TRXN_PUB.TrxnExtension_rec_type;
216             l_amount_rec            IBY_FNDCPT_TRXN_PUB.Amount_rec_type;
217             l_authresult_rec       IBY_FNDCPT_TRXN_PUB.AuthResult_rec_type; /* OUT AUTH RESULT STRUCTURE */
218             l_response_rec          IBY_FNDCPT_COMMON_PUB.Result_rec_type;   /* OUT RESPONSE STRUCTURE */
219             l_entity_id             NUMBER;  -- OUT FROM COPY
220 /* END DECLARE the variables required for the payment engine (AUTH) all the REC TYPES */
221 
222 
223 
224 BEGIN
225       IF PG_DEBUG in ('Y', 'C') THEN
226          arp_standard.debug('ar_prepayments_pub.Create_Prepayment ()+'|| p_org_id);
227          arp_util.debug('Create_Prepayment: payment_trxn_extension_id' || to_char(p_payment_trxn_extension_id) );
228          arp_util.debug('Create_Prepayment receipt method id' || to_char(p_receipt_method_id) );
229       END IF;
230 
231       -- first reinitialize ARP_GLOBAL
232         arp_global.init_global;
233 
234      /*------------------------------------+
235       |   Standard start of API savepoint  |
236       +------------------------------------*/
237       SAVEPOINT Create_Prepayment_PVT;
238 
239       /*-----------------------------------------+
240         |   Initialize return status to SUCCESS   |
241         +-----------------------------------------*/
242 
243         x_return_status := FND_API.G_RET_STS_SUCCESS;
244 
245       /*--------------------------------------------------+
246         |   Standard call to check for call compatibility  |
247         +--------------------------------------------------*/
248 
249         IF NOT FND_API.Compatible_API_Call(
250                                             l_api_version,
251                                             p_api_version,
252                                             l_api_name,
253                                             G_PKG_NAME
254                                           )
255         THEN
256               x_return_status := FND_API.G_RET_STS_ERROR;
257               RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
258         END IF;
259 
260        /*--------------------------------------------------------------+
261         |   Initialize message list if p_init_msg_list is set to TRUE  |
262         +--------------------------------------------------------------*/
263         IF FND_API.to_Boolean( p_init_msg_list )
264           THEN
265               FND_MSG_PUB.initialize;
266         END IF;
267 
268 
269 
270 
271 /* SSA change */
272        l_org_id            := p_org_id;
273        l_org_return_status := FND_API.G_RET_STS_SUCCESS;
274        ar_mo_cache_utils.set_org_context_in_api(p_org_id =>l_org_id,
275                                                 p_return_status =>l_org_return_status);
276  IF l_org_return_status <> FND_API.G_RET_STS_SUCCESS THEN
277        x_return_status := FND_API.G_RET_STS_ERROR;
278  ELSE
279       ----Multiple prepayments allow payment types other than credit card
280      /*--------------------------------------------------------------------
281       IF p_receipt_method_id is not null THEN
282          BEGIN
283              SELECT 'Y' into l_cc_check
284              FROM  ar_receipt_methods
285              WHERE receipt_method_id=p_receipt_method_id
286              AND   payment_type_code = 'CREDIT_CARD';
287          EXCEPTION
288             WHEN no_data_found THEN
289                IF PG_DEBUG in ('Y', 'C') THEN
290                   arp_util.debug('Create_Prepayment: ' || 'Prepayment only allowed for credit card');
291                END IF;
292                FND_MESSAGE.SET_NAME('AR','AR_RAPI_PREPAY_ONLYFOR_CC');
293                FND_MSG_PUB.Add;
294                x_return_status := FND_API.G_RET_STS_ERROR;
295                RETURN;
296          END;
297 
298       END IF;
299     ---------------------------------------------------------------------*/
300 /* PAYMENT UPTAKE COMMENTED BY BICHATTE
301      --Check whether customer bank account details are passed
302        IF ((p_customer_bank_account_id is null) AND
303            (p_customer_bank_account_num is null) AND
304            (p_customer_bank_account_name is null)) THEN
305 
306              IF PG_DEBUG in ('Y', 'C') THEN
307                 arp_util.debug('Create_Prepayment: ' || 'For Prepayment, customer banks account details must be passed');
308              END IF;
309              FND_MESSAGE.SET_NAME('AR','AR_RAPI_CUS_BK_AC_2_INVALID');
310              FND_MSG_PUB.Add;
311              x_return_status := FND_API.G_RET_STS_ERROR;
312              RETURN;
313        END IF;
314 
315 */
316      l_receivables_trx_id := p_receivable_trx_id;
317 
318                 arp_util.debug('Create_Prepayment: payment_trxn_extension_id' || to_char(p_payment_trxn_extension_id) );
319 
320 
321 --calling the internal create_cash routine
322      ar_receipt_api_pub.Create_Cash(
323                  p_api_version            => p_api_version,
324                  p_init_msg_list          => p_init_msg_list,
325                  p_commit                 => FND_API.G_FALSE,
326                  p_validation_level       => FND_API.G_VALID_LEVEL_FULL,
327                  x_return_status          => l_create_return_status,
328                  x_msg_count              => x_msg_count,
329                  x_msg_data               => x_msg_data,
330               -- Receipt info. parameters
331                  p_usr_currency_code      => p_usr_currency_code,
332                  p_currency_code          => p_currency_code,
333                  p_usr_exchange_rate_type => p_usr_exchange_rate_type,
334                  p_exchange_rate_type     => p_exchange_rate_type,
335                  p_exchange_rate          => p_exchange_rate,
336                  p_exchange_rate_date     => p_exchange_rate_date,
337                  p_amount                 => p_amount,
338                  p_factor_discount_amount => p_factor_discount_amount,
339                  p_receipt_number         => p_receipt_number,
340                  p_receipt_date           => p_receipt_date,
341                  p_gl_date                => p_gl_date,
342                  p_maturity_date          => p_maturity_date,
343                  p_postmark_date          => p_postmark_date,
344                  p_customer_id            => p_customer_id,
345                  p_customer_name          => p_customer_name,
346                  p_customer_number        => p_customer_number,
347                  p_customer_bank_account_id   => p_customer_bank_account_id,
348                  p_customer_bank_account_num  => p_customer_bank_account_num,
349                  p_customer_bank_account_name => p_customer_bank_account_name,
350                  p_payment_trxn_extension_id  => p_payment_trxn_extension_id,
351                  p_location                   => p_location,
352                  p_customer_site_use_id       => p_customer_site_use_id,
353                  p_customer_receipt_reference => p_customer_receipt_reference,
354                  p_override_remit_account_flag => p_override_remit_account_flag,
355                  p_remittance_bank_account_id  => p_remittance_bank_account_id,
356                  p_remittance_bank_account_num => p_remittance_bank_account_num,
357                  p_remittance_bank_account_name => p_remittance_bank_account_name,
358                  p_deposit_date                 => p_deposit_date,
359                  p_receipt_method_id            => p_receipt_method_id,
360                  p_receipt_method_name          => p_receipt_method_name,
361                  p_doc_sequence_value           => p_doc_sequence_value,
362                  p_ussgl_transaction_code       => p_ussgl_transaction_code,
363                  p_anticipated_clearing_date    => p_anticipated_clearing_date,
364                  p_called_from                  => p_called_from,
365                  p_attribute_rec                => p_attribute_rec,
366                  p_global_attribute_rec         => p_global_attribute_rec ,
367                  p_comments                     => p_receipt_comments,
368                  p_issuer_name                  => p_issuer_name,
369                  p_issue_date                   => p_issue_date,
370                  p_issuer_bank_branch_id        => p_issuer_bank_branch_id,
371                  p_org_id                       => p_org_id,
372                  p_cr_id                        => l_cash_receipt_id --out variable
373                  );
374 
375          IF PG_DEBUG in ('Y', 'C') THEN
376             arp_util.debug('Create_Prepayment: ' || 'Receipt create_return_status '||l_create_return_status);
377          END IF;
378 
379         --IF the receipt creation part returns no errors then
380         --call the application routine.
381 
382          IF l_create_return_status = FND_API.G_RET_STS_SUCCESS THEN
383 
384               IF x_msg_count = 1 THEN
385                 /* If one message, like warning, then put this back on stack as the
386                    Create routine must have removed it from the stack and put it on x_msg_data
387                  */
388                   FND_MESSAGE.SET_NAME ('AR','GENERIC_MESSAGE');
389                   FND_MESSAGE.SET_TOKEN('GENERIC_TEXT','Create_Prepayment : '||x_msg_data);
390                   FND_MSG_PUB.Add;
391               END IF;
392               --While applying to prepayment, generate payment_set_id from the
393               --sequence and pass to apply routine.
394               --IF payment set id is passed, then do not generate.
395              IF p_payment_set_id is null THEN
396               BEGIN
397                 SELECT ar_receivable_applications_s1.nextval
398                 INTO   l_payment_set_id
399                 FROM   dual;
400               EXCEPTION
401                 WHEN others THEN
402                      IF PG_DEBUG in ('Y', 'C') THEN
403                         arp_util.debug('Create_Prepayment: ' || 'Payment set id sequence generation failed'||sqlerrm);
404                      END IF;
405                      FND_MESSAGE.SET_NAME('AR','AR_RAPI_PREPAY_SEQ_FAILED');
406                      FND_MSG_PUB.Add;
407                      x_return_status := FND_API.G_RET_STS_ERROR;
408                      RETURN;
409               END;
410              ELSE
411                 l_payment_set_id := p_payment_set_id;
412              END IF;
413 
414           --Default receivable_trx_id for prepayment .
415 
416             ar_receipt_lib_pvt.Default_prepay_cc_activity(
417                          'PREPAYMENT',
418                          l_receivables_trx_id,
419                          l_activity_return_status);
420 
421             IF l_activity_return_status <> FND_API.G_RET_STS_SUCCESS THEN
422                           ROLLBACK TO Create_Prepayment_PVT;
423                           x_return_status := l_activity_return_status;
424 
425                           FND_MSG_PUB.Count_And_Get(p_encoded => FND_API.G_FALSE,
426                                       p_count => x_msg_count,
427                                       p_data  => x_msg_data);
428 
429                           RETURN; -- exit back to caller
430             END IF;
431 /* Notes -- bichatte we dont need the check for p_call_payment_processor */
432 
433 
434                    SELECT payment_channel_code
435                    INTO   l_payment_type
436                    FROM  ar_receipt_methods
437                    WHERE  receipt_method_id = p_receipt_method_id;
438 
439 
440     l_payment_trxn_extension_id := p_payment_trxn_extension_id;
441 
442                  IF ((l_payment_trxn_extension_id IS NULL) AND ( l_payment_type in ( 'CREDIT_CARD', 'BANK_ACCT_XFER')))  THEN
443 
444                      IF PG_DEBUG in ('Y', 'C') THEN
445                      arp_util.debug('ERROR: payment_trxn_extension is NULL ' ||nvl(l_payment_trxn_extension_id,-9999));
446                      END IF;
447 
448                     FND_MESSAGE.set_name('AR', 'AR_PAY_PROCESS_INVALID_STATUS');
449                     FND_MSG_PUB.Add;
450 
451                     x_return_status := FND_API.G_RET_STS_ERROR;  -- should never happen
452 
453                     RETURN;
454                  END IF;
455 
456 /* bichatte start */
457    -- Payment uptake
458    -- i) here we will check if the l_payment_trxn_extension_id is already authorised or not
459    --      accordingly call Auth
460    -- ii) pass the l_payment_trxn_extension_id to create_cash so that its gets copied and stamped
461    --     on the cash receipt.
462 
463 
464 
465    IF  l_payment_trxn_extension_id IS  NOT NULL  THEN
466                            IF PG_DEBUG in ('Y', 'C') THEN
467                             arp_util.debug('Process_Credit_Card: ' || 'COPY the trx_extension_id');
468                            END IF;
469   IF PG_DEBUG in ('Y', 'C') THEN
470      arp_standard.debug(  'Entering payment processing...');
471   END IF;
472 
473 
474   OPEN rct_info_cur;
475   FETCH rct_info_cur INTO rct_info;
476 
477  IF rct_info_cur%FOUND THEN
478 
479  -- Step 1: (always performed):
480 
481           -- set up payee record:
482           l_payee_rec.org_id   := rct_info.org_id;                            -- receipt's org_id
483           l_payee_rec.org_type := 'OPERATING_UNIT' ;                                -- ( HR_ORGANIZATION_UNITS )
484 
485 
486         -- set up payer (=customer) record:
487 
488         l_payer_rec.Payment_Function := 'CUSTOMER_PAYMENT';
489         l_payer_rec.Party_Id :=   rct_info.party_id;     -- receipt customer party id mandatory
490         l_payer_rec.org_id   := rct_info.org_id ;
491         l_payer_rec.org_type := 'OPERATING_UNIT';
492         l_payer_rec.Cust_Account_Id :=rct_info.pay_from_customer;  -- receipt customer account_id
493         l_payer_rec.Account_Site_Id :=rct_info.customer_site_use_id; -- receipt customer site_id
494 
495 
496 
497 
498         -- set up trx_entity record: /* NOTE HERE we have to call  Copy_Transaction_Extension */
499 
500 
501         -- set up auth_attribs record:
502             l_auth_attribs_rec.RiskEval_Enable_Flag := 'N';
503         -- set up trxn_attribs record:
504         l_trxn_attribs_rec.Originating_Application_Id := arp_standard.application_id;
505         l_trxn_attribs_rec.order_id :=  rct_info.receipt_number;
506         l_trxn_attribs_rec.Trxn_Ref_Number1 := 'RECEIPT';
507         l_trxn_attribs_rec.Trxn_Ref_Number2 := l_cash_receipt_id;
508 
509         -- set up amounts
510 
511         l_amount_rec.value := rct_info.amount;
512         l_amount_rec.currency_code   := rct_info.currency_code;
513 
514        IF PG_DEBUG in ('Y', 'C') THEN
515            arp_standard.debug(  'check and then call Auth');
516         END IF;
517 
518         -- determine whether to AUTHORIZE
519 
520         -- assign the value for payment_trxn_extension record the copied value
521 
522                  l_trxn_entity_id := rct_info.payment_trxn_extension_id;
523 
524         IF PG_DEBUG in ('Y', 'C') THEN
525            arp_standard.debug(  'Calling get auth for  pmt_trxn_extn_id ');
526            arp_standard.debug(  'l_trxn_entity_id  '             || to_char(l_trxn_entity_id ) );
527 
528        END IF;
529 
530              Begin
531                 SELECT decode(summ.status,   NULL,   'N',   'Y') AUTHORIZED_FLAG
532                    into l_auth_flag
533                  FROM iby_trxn_summaries_all summ,
534                       iby_fndcpt_tx_operations op
535                 WHERE summ.transactionid = op.transactionid
536                       AND reqtype = 'ORAPMTREQ'
537                       AND status IN(0,    100)
538                       AND trxntypeid IN(2,   3, 20)
539                       AND op.trxn_extension_id = l_trxn_entity_id
540                       AND summ.trxnmid =
541                            (SELECT MAX(trxnmid)
542                                 FROM iby_trxn_summaries_all
543                             WHERE transactionid = summ.transactionid
544                             AND reqtype = 'ORAPMTREQ'
545                             AND status IN(0, 100)
546                             AND trxntypeid IN(2,    3,   20));
547              Exception
548                when others then
549                  l_auth_flag := 'N';
550              End;
551 
552               arp_standard.debug ( 'the value of auth_flag is = ' || l_auth_flag);
553 
554                 If l_auth_flag = 'Y' then
555 
556                   select AUTHORIZATION_ID
557                    into l_auth_id
558                    from IBY_TRXN_EXT_AUTHS_V
559                    where TRXN_EXTENSION_ID = p_payment_trxn_extension_id;
560 
561                   arp_standard.debug ( 'the value of auth_id is = ' || l_auth_id);
562 
563                   ARP_CASH_RECEIPTS_PKG.set_to_dummy(l_cr_rec);
564 
565                   l_cr_rec.approval_code := 'AR'||to_char(l_auth_Id);
566 
567                   ARP_CASH_RECEIPTS_PKG.update_p(l_cr_rec, l_cash_receipt_id);
568 
569                arp_standard.debug('CR rec updated with auth_id and auth code ');
570                 end if;
571 
572 
573 
574 
575            IF  l_auth_flag <> 'Y'  then
576                  arp_standard.debug('auth needs to called');
577 
578                IF PG_DEBUG in ('Y', 'C') THEN
579                   arp_standard.debug(  'Calling get auth for  pmt_trxn_extn_id ');
580                   arp_standard.debug(  ' l_payee_rec.org_id '           || to_char(l_payee_rec.org_id) );
581                   arp_standard.debug(  ' l_payee_rec.org_type '         || to_char( l_payee_rec.org_type) );
582                   arp_standard.debug(  ' l_payer_rec.Payment_Function ' || to_char( l_payer_rec.Payment_Function) );
583                   arp_standard.debug(  ' l_payer_rec.Party_Id '         || to_char( l_payer_rec.Party_Id) );
584                   arp_standard.debug(  ' l_payer_rec.org_id '           || to_char(l_payer_rec.org_id) );
585                   arp_standard.debug(  ' l_payer_rec.org_type  '        || to_char( l_payer_rec.org_type) );
586                   arp_standard.debug(  'l_payer_rec.Cust_Account_Id '   || to_char(l_payer_rec.Cust_Account_Id) );
587                   arp_standard.debug(  'l_payer_rec.Account_Site_Id '   || to_char(l_payer_rec.Account_Site_Id) );
588                   arp_standard.debug(  'l_trxn_entity_id  '             || to_char(l_trxn_entity_id ) );
589                   arp_standard.debug(  'l_amount_rec.value: ' || to_char(l_amount_rec.value) );
590                   arp_standard.debug(  'l_amount_rec.currency_code: '   || l_amount_rec.currency_code );
591 
592                   arp_standard.debug(  'Calling get_auth for  pmt_trxn_extn_id ');
593                END IF;
594 
595                    IBY_FNDCPT_TRXN_PUB.Create_Authorization(
596                          p_api_version        => 1.0,
597                          p_init_msg_list      => FND_API.G_TRUE,
598                          x_return_status      => l_return_status,
599                          x_msg_count          => l_msg_count,
600                          x_msg_data           => l_msg_data,
601                          p_payer              => l_payer_rec,
602                          p_payer_equivalency  => IBY_FNDCPT_COMMON_PUB.G_PAYER_EQUIV_UPWARD,
603                          p_payee              => l_payee_rec,
604                          p_trxn_entity_id     => l_trxn_entity_id,
605                          p_auth_attribs       => l_auth_attribs_rec,
606                          p_amount             => l_amount_rec,
607                          x_auth_result        => l_authresult_rec, -- out auth result struct
608                          x_response           => l_response_rec );   -- out response struct
609 
610 
611                   x_msg_count           := l_msg_count;
612                   x_msg_data            := l_msg_data;
613 
614                         arp_standard.debug('x_return_status  :<' || l_return_status || '>');
615                         arp_standard.debug('x_msg_count      :<' || l_msg_count || '>');
616 
617                   FOR i IN 1..l_msg_count LOOP
618                       arp_standard.debug('x_msg #' || TO_CHAR(i) || ' = <' ||
619                       SUBSTR(fnd_msg_pub.get(p_msg_index => i,p_encoded => FND_API.G_FALSE),1,150) || '>');
620                   END LOOP;
621 
622                      IF PG_DEBUG in ('Y', 'C') THEN
623                         arp_standard.debug(  '-------------------------------------');
624                         arp_standard.debug(  'l_response_rec.Result_Code:     ' || l_response_rec.Result_Code);
625                         arp_standard.debug(  'l_response_rec.Result_Category: ' || l_response_rec.Result_Category);
626                         arp_standard.debug(  'l_response_rec.Result_message : ' || l_response_rec.Result_message );
627                         arp_standard.debug(  'l_authresult_rec.Auth_Id:     '       || l_authresult_rec.Auth_Id);
628                         arp_standard.debug(  'l_authresult_rec.Auth_Date: '         || l_authresult_rec.Auth_Date);
629                         arp_standard.debug(  'l_authresult_rec.Auth_Code:     '     || l_authresult_rec.Auth_Code);
630                         arp_standard.debug(  'l_authresult_rec.AVS_Code: '          || l_authresult_rec.AVS_Code);
631                         arp_standard.debug(  'l_authresult_rec.Instr_SecCode_Check:'|| l_authresult_rec.Instr_SecCode_Check);
632                         arp_standard.debug(  'l_authresult_rec.PaymentSys_Code: '   || l_authresult_rec.PaymentSys_Code);
633                         arp_standard.debug(  'l_authresult_rec.PaymentSys_Msg: '    || l_authresult_rec.PaymentSys_Msg);
634                      -- arp_standard.debug(  'l_authresult_rec.Risk_Result: '       || l_authresult_rec.Risk_Result);
635 
636                     END IF;
637 
638              IF (l_return_status = FND_API.G_RET_STS_SUCCESS) THEN
639               -- update cash receipt with authorization code and
640 
641                 ARP_CASH_RECEIPTS_PKG.set_to_dummy(l_cr_rec);
642                  l_cr_rec.approval_code := l_authresult_rec.Auth_code ||'AR'||to_char(l_authresult_rec.Auth_Id);
643 
644                ARP_CASH_RECEIPTS_PKG.update_p(l_cr_rec, l_cash_receipt_id);
645 
646                IF PG_DEBUG in ('Y', 'C') THEN
647                  arp_standard.debug('CR rec updated with auth_id and auth code ');
648                END IF;
649 
650              END IF;
651 
652                     -- check if call was successful
653                     --Add message to message stack only it it is called from iReceivables
654                     --if not pass the message stack received from iPayment
655 
656                     IF (NVL(p_called_from,'NONE') = 'IREC') THEN
657                       IF PG_DEBUG in ('Y', 'C') THEN
658                           arp_standard.debug(  'l_MSG_COUNT=>'||to_char(l_MSG_COUNT));
659                     END IF;
660                     fnd_msg_pub.dump_list;
661                     IF PG_DEBUG in ('Y', 'C') THEN
662                     arp_standard.debug(  'Errors: ');
663                     END IF;
664                       IF(l_MSG_COUNT=1) THEN
665                          IF PG_DEBUG in ('Y', 'C') THEN
666                           arp_standard.debug(  l_MSG_DATA);
667                          END IF;
668                       ELSIF(l_MSG_COUNT>1)THEN
669                            LOOP
670                            l_MSG_DATA:=FND_MSG_PUB.GET(p_encoded=>FND_API.G_FALSE);
671                                IF (l_MSG_DATA IS NULL)THEN
672                                EXIT;
673                                END IF;
674                               IF PG_DEBUG in ('Y', 'C') THEN
675                               arp_standard.debug(  l_MSG_DATA);
676                               END IF;
677                            END LOOP;
678                       END IF;
679                     END IF;
680 
681                  IF (l_return_status <> FND_API.G_RET_STS_SUCCESS)
682                  AND (NVL(p_called_from,'NONE') = 'IREC')  then
683 
684                   FND_MESSAGE.set_name('AR', 'AR_PAY_PROCESS_AUTHFAILURE');
685                   FND_MSG_PUB.Add;
686                   x_return_status := l_return_status;
687                   RETURN;
688 
689                 ELSIF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
690 
691                  arp_standard.debug('create_cash_126');
692                   FND_MESSAGE.set_name('AR', 'AR_CC_AUTH_FAILED');
693                   FND_MSG_PUB.Add;
694 
695                      IF  l_response_rec.Result_Code is NOT NULL THEN
696 
697                        ---Raise the PAYMENT error code concatenated with the message
698 
699                         l_iby_msg_data := substrb( l_response_rec.Result_Code || ': '||
700                                    l_response_rec.Result_Message , 1, 240);
701 
702                         arp_standard.debug(  'l_iby_msg_data: ' || l_iby_msg_data);
703                         FND_MESSAGE.SET_NAME ('AR','GENERIC_MESSAGE');
704                         FND_MESSAGE.SET_TOKEN('GENERIC_TEXT',l_iby_msg_data);
705 
706                         FND_MSG_PUB.Add;
707 
708                      END IF;
709 
710                      IF l_authresult_rec.PaymentSys_Code is not null THEN
711 
712                        ---Raise the VENDOR error code concatenated with the message
713 
714                         l_vend_msg_data := substrb(l_authresult_rec.PaymentSys_Code || ': '||
715                                    l_authresult_rec.PaymentSys_Msg , 1, 240 );
716 
717                         FND_MESSAGE.SET_NAME ('AR','GENERIC_MESSAGE');
718                         FND_MESSAGE.SET_TOKEN('GENERIC_TEXT',l_vend_msg_data);
719 
720                       FND_MSG_PUB.Add;
721 
722                     END IF;
723 
724 
725                     FND_MSG_PUB.Count_And_Get( p_encoded => FND_API.G_FALSE,
726                                p_count  =>  x_msg_count,
727                                p_data   => x_msg_data );
728 
729                     x_return_status := l_return_status;
730                     RETURN;
731 
732                   END IF; /* End the error handling CREATE */
733 
734           END IF;  /* END if of auth flag N  */
735 
736 
737        END IF; -- rct_info_cur%FOUND
738 
739                  END IF; --- l_payment_trxn_extension_id is not null.
740 
741 /* bichatte end */
742 
743 
744             ar_receipt_api_pub.Apply_other_account(
745                 -- Standard API parameters.
746                    p_api_version      => p_api_version,
747                    p_init_msg_list    => FND_API.G_FALSE, --message stack is not initialized
748                    p_commit           => p_commit,
749                    p_validation_level => FND_API.G_VALID_LEVEL_FULL,
750                    x_return_status    => l_create_return_status,
751                    x_msg_count        => x_msg_count,
752                    x_msg_data         => x_msg_data,
753                    p_receivable_application_id => p_receivable_application_id,
754                  --Receipt application parameters.
755                    p_cash_receipt_id           => l_cash_receipt_id,
756                    p_receipt_number            => p_receipt_number,
757                    p_amount_applied            => p_amount_applied,
758                    p_receivables_trx_id        => l_receivables_trx_id,
759                    p_applied_payment_schedule_id => p_applied_payment_schedule_id,
760                    p_apply_date                => p_apply_date,
761                    p_apply_gl_date             => p_apply_gl_date,
762                    p_ussgl_transaction_code    => app_ussgl_transaction_code,
763                    p_application_ref_type      => p_application_ref_type,
764                    p_application_ref_id        => p_application_ref_id,
765                    p_application_ref_num       => p_application_ref_num,
766                    p_secondary_application_ref_id => p_secondary_application_ref_id,
767                    p_org_id                       => p_org_id,
768                    p_payment_set_id               => l_payment_set_id,
769                    p_attribute_rec             => app_attribute_rec,
770                 -- ******* Global Flexfield parameters *******
771                    p_global_attribute_rec      => app_global_attribute_rec,
772                    p_comments                  => app_comments
773                  );
774 
775                  --If the application fails then we need to rollback all the changes
776                  --made in the create() routine also.
777                   IF l_create_return_status <> FND_API.G_RET_STS_SUCCESS THEN
778                      ROLLBACK TO Create_Prepayment_Pvt;
779                      FND_MSG_PUB.Count_And_Get(p_encoded => FND_API.G_FALSE,
780                                       p_count => x_msg_count,
781                                       p_data  => x_msg_data);
782                      x_return_status := l_create_return_status;
783                      RETURN;
784                   ELSE
785 
786                   ------Mult. Prepay remittance based on receipt class setup---
787                   --Prepayment Receipt needs to be remitted eventhough the receipt
788                   -- class status does not require remittance immediatly.
789 
790                   --Bug 3220078 no need to remit the receipts from 'CONFIRMED'
791                   --status but ipayment calls need to be made acc. to receipt
792                   --class setup
793 
794 
795                    ----get the status and payment method of of the receipt -----
796                    SELECT rc.creation_status ,  nvl(rm.payment_channel_code, 'CHECK')
797                    INTO   l_cash_receipt_status,  l_payment_type
798                    FROM  ar_cash_receipts cr, ar_receipt_classes rc,
799                          ar_receipt_methods rm
800                    WHERE cr.cash_receipt_id = l_cash_receipt_id
801                    AND   cr.receipt_method_id = rm.receipt_method_id
802                    AND   rm.receipt_class_id = rc.receipt_class_id;
803 
804 
805                     -- charge credit card if needed.  Note: this only
806                     -- happens if the receipt and application creation
807                     -- was successful.  All relevant information for the
808                     -- payment can be derived from the cash receipt.
809 
810                     --for CONFIRMED auth only
811                     --REMITTED,CLEARED  auth and capture
812 
813                    IF ( (l_payment_type = 'CREDIT_CARD')  AND
814                         l_cash_receipt_status IN ('CONFIRMED', 'REMITTED', 'CLEARED')
815                       )
816                    THEN
817 
818                      IF PG_DEBUG in ('Y', 'C') THEN
819                         arp_standard.debug('Create_Prepayment: ' || 'Checking p_call_payment_processor: ' || p_call_payment_processor);
820                      END IF;
821                    /*  if (p_call_payment_processor = FND_API.G_TRUE) then
822 
823                          Process_Credit_Card(
824                                p_cash_receipt_id          => l_cash_receipt_id,
825                                p_payment_server_order_num =>
826                                                   p_payment_server_order_num,
827                                p_auth_code               => p_approval_code,
828                                p_response_error_code     => l_response_error_code,
829                                x_msg_count               => x_msg_count,
830                                x_msg_data                => x_msg_data,
831                                x_return_status           => l_cc_return_status);
832 
833 
834                        -- If the payment processor call fails, then we
835                        -- need to rollback all the changes
836                        -- made in the create() and apply() routines also.
837 
838                        IF l_cc_return_status <> FND_API.G_RET_STS_SUCCESS THEN
839                           x_return_status := l_cc_return_status;
840                           p_payment_response_error_code := l_response_error_code;
841 
842                           ROLLBACK TO Create_Prepayment_PVT;
843                           FND_MSG_PUB.Count_And_Get(p_encoded => FND_API.G_FALSE,
844                                       p_count => x_msg_count,
845                                       p_data  => x_msg_data);
846 
847                           RETURN; -- exit back to caller
848                        END IF;
849 
850                     end if;  -- if p_call_payment_processor = fnd_api.g_true */
851                   END IF; --l_payment_type
852 
853                      -- need to pass back cr_id
854                      p_cr_id := l_cash_receipt_id;
855                      p_payment_set_id := l_payment_set_id;
856 
857                   END IF;
858             ELSE  --after create_cash success status
859              x_return_status := l_create_return_status;
860             END IF;
861 END IF;
862 
863        /*--------------------------------+
864         |   Standard check of p_commit   |
865         +--------------------------------*/
866 
867         IF FND_API.To_Boolean( p_commit )
868         THEN
869             IF PG_DEBUG in ('Y', 'C') THEN
870                arp_util.debug('Create_Prepayments: ' || 'committing');
871             END IF;
872               Commit;
873         END IF;
874 
875         FND_MSG_PUB.Count_And_Get(p_encoded => FND_API.G_FALSE,
876                                   p_count => x_msg_count,
877                                   p_data  => x_msg_data);
878 
879             IF PG_DEBUG in ('Y', 'C') THEN
880                arp_util.debug('ar_prepayments_pub.Create_Prepayment ()-');
881             END IF;
882 
883 EXCEPTION
884 WHEN OTHERS THEN
885    IF (SQLCODE = -20001) THEN
886        ROLLBACK TO Create_Prepayment_PVT;
887 
888        --  Display_Parameters;
889        x_return_status := FND_API.G_RET_STS_ERROR ;
890        FND_MESSAGE.SET_NAME ('AR','GENERIC_MESSAGE');
891        FND_MESSAGE.SET_TOKEN('GENERIC_TEXT','CREATE_PREPAYMENT : '||SQLERRM);
892        FND_MSG_PUB.Add;
893 
894        FND_MSG_PUB.Count_And_Get( p_encoded => FND_API.G_FALSE,
895                                   p_count  =>  x_msg_count,
896                                   p_data   => x_msg_data
897                                                 );
898        RETURN;
899    ELSE
900          x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
901          FND_MESSAGE.SET_NAME ('AR','GENERIC_MESSAGE');
902          FND_MESSAGE.SET_TOKEN('GENERIC_TEXT','CREATE_PREPAYMENT : '||SQLERRM);
903          FND_MSG_PUB.Add;
904    END IF;
905 
906    IF PG_DEBUG in ('Y', 'C') THEN
907        arp_util.debug('Create_Prepayment: ' || SQLCODE, G_MSG_ERROR);
908       arp_util.debug('Create_Prepayment: ' || SQLERRM, G_MSG_ERROR);
909    END IF;
910 
911    ROLLBACK TO Create_Prepayment_PVT;
912 
913    IF      FND_MSG_PUB.Check_Msg_Level THEN
914            FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME,
915                                    l_api_name
916                                    );
917    END IF;
918 
919     --   Display_Parameters;
920     FND_MSG_PUB.Count_And_Get(p_encoded => FND_API.G_FALSE,
921                               p_count       =>      x_msg_count,
922                               p_data        =>      x_msg_data);
923 
924 
925     IF PG_DEBUG in ('Y', 'C') THEN
926        arp_util.debug('ar_prepayments_pub.Create_Prepayment ()-');
927     END IF;
928 
929 END Create_Prepayment;
930 
931 /*=======================================================================
932  | PUBLIC Procedure Get_Installment
933  |
934  | DESCRIPTION
935  |      Gets the installment number and amount for a payment term
936  |      ----------------------------------------------------------
937  |
938  | PSEUDO CODE/LOGIC
939  |
940  | PARAMETERS
941  |
942  |
943  | RETURNS
944  |      nothing
945  |
946  | KNOWN ISSUES
947  |
948  |
949  |
950  | NOTES
951  |
952  |
953  |
954  | MODIFICATION HISTORY
955  | Date                  Author         Description of Changes
956  | 12-DEC-2003           Jyoti Pandey   Bug 3248093 Add get_installment
957  |                                      procedure in this package
958  *=======================================================================*/
959 
960 PROCEDURE get_installment(
961       p_term_id         IN  NUMBER,
962       p_amount          IN  NUMBER,
963       p_currency_code   IN  VARCHAR2,
964       p_org_id          IN NUMBER DEFAULT NULL,
965       p_installment_tbl OUT NOCOPY ar_prepayments_pub.installment_tbl,
966       x_return_status   OUT NOCOPY VARCHAR2,
967       x_msg_count       OUT NOCOPY NUMBER,
968       x_msg_data        OUT NOCOPY VARCHAR2) IS
969 
970  l_installment_tbl installment_tbl;
971  l_return_status   VARCHAR2(1);
972  l_msg_count       NUMBER;
973  l_msg_data        VARCHAR2(255);
974  l_org_return_status VARCHAR2(1);
975  l_org_id                           NUMBER;
976 
977  BEGIN
978 
979 /* SSA change */
980        l_org_id            := p_org_id;
981        l_org_return_status := FND_API.G_RET_STS_SUCCESS;
982        ar_mo_cache_utils.set_org_context_in_api(p_org_id =>l_org_id,
983                                                 p_return_status =>l_org_return_status);
984  IF l_org_return_status <> FND_API.G_RET_STS_SUCCESS THEN
985        x_return_status := FND_API.G_RET_STS_ERROR;
986  ELSE
987 
988   AR_PREPAYMENTS.get_installment(
989               p_term_id,
990               p_amount,
991               p_currency_code,
992               p_installment_tbl,
993               x_return_status,
994               x_msg_count,
995               x_msg_data);
996   END IF;
997 
998  END get_installment;
999 
1000 
1001 END AR_PREPAYMENTS_PUB;