[Home] [Help]
PACKAGE BODY: APPS.ARP_PROC_RECEIPTS2
Source
1 PACKAGE BODY ARP_PROC_RECEIPTS2 AS
2 /* $Header: ARRERG2B.pls 120.21 2010/06/19 08:26:55 vpusulur ship $ */
3
4 /* =======================================================================
5 | Global Data Types
6 * ======================================================================*/
7 SUBTYPE ae_doc_rec_type IS arp_acct_main.ae_doc_rec_type;
8 PG_DEBUG varchar2(1) := NVL(FND_PROFILE.value('AFLOG_ENABLED'), 'N');
9
10 /* ---------------------- Public functions -------------------------------- */
11
12
13 FUNCTION revision RETURN VARCHAR2 IS
14 BEGIN
15
16 RETURN '$Revision: 120.21 $';
17
18 END revision;
19
20
21 /*===========================================================================+
22 | PROCEDURE |
23 | insert_cash_receipt |
24 | |
25 | DESCRIPTION |
26 | Function inserts a cash receipt into the database. This entity |
27 | handler is called from the Receipts Gateway form and creates records |
28 | in the following tables: |
29 | AR_CASH_RECEIPTS |
30 | AR_CASH_RECEIPT_HISTORY |
31 | AR_DISTRIBUTIONS |
32 | AR_RECEIVABLE_APPLICATIONS |
33 | AR_PAYMENT_SCHEDULES |
34 | |
35 | SCOPE - PUBLIC |
36 | |
37 | EXTERNAL PROCEDURES/FUNCTIONS ACCESSED |
38 | |
39 | ARGUMENTS |
40 | IN: |
41 | OUT: |
42 | |
43 | RETURNS |
44 | |
45 | NOTES |
46 | |
47 | MODIFICATION HISTORY |
48 | |
49 | 08-SEP-95 OSTEINME created |
50 | 01-NOV-96 OSTEINME added parameter anticipated_clearing_date |
51 | for CashBook enhancement (float support) |
52 | Added parameters for Japan enhancements: |
53 | - customer_bank_branch_id |
54 | as well as logic to handle these properly |
55 | 04-NOV-96 OSTEINME changed call to get_ra_ccid to take new |
56 | parameters. Also changed procedure name |
57 | to get_ccids to better reflect purpose of |
58 | of procedure. |
59 | 30-DEC-96 OSTEINME added global flexfield parameters |
60 | 04-DEC-97 KLAWRANC Bug #590256. Modified calls to |
61 | calc_acctd_amount. Now passes NULL for the |
62 | currency code parameter, therefore the acctd |
63 | amount will be calculated based on the |
64 | functional currency. |
65 | 21-MAY-98 KTANG For all calls to calc_acctd_amount which |
66 | calculates header accounted amounts, if the |
67 | exchange_rate_type is not user, call |
68 | gl_currency_api.convert_amount instead. This |
69 | is for triangulation. |
70 | 29-JUL-98 K.Murphy Bug #667450. Modified calculation of the |
71 | accounted factor discount amount. |
72 | |
73 | 14-APR-2000 Jani Rautiainen Added parameter p_called_from. This is needed|
74 | inthe logic to decide whether first UNAPP row|
75 | is postable or not. In BR scenario when an |
76 | Activity Application of Short Term Debt is |
77 | created the UNAPP rows are not postable. |
78 | This is an user requirement for BR. |
79 | The parameter is defaulted to NULL so no |
80 | impact for the existing functionality. |
81 | Also added logic to prevent accounting |
82 | creation if the row is not postable. |
83 | 01-May-2002 Debbie Jancis Modified for Enhancement 2074220. Added |
84 | application_notes. |
85 | 05-May-2005 Debbie Jancis Added Legal Entity Id for LE R12 project |
86 | |
87 +===========================================================================*/
88
89
90 PROCEDURE insert_cash_receipt(
91 p_currency_code IN VARCHAR2,
92 p_amount IN NUMBER,
93 p_pay_from_customer IN NUMBER,
94 p_receipt_number IN VARCHAR2,
95 p_receipt_date IN DATE,
96 p_gl_date IN DATE,
97 p_maturity_date IN DATE,
98 p_comments IN VARCHAR2,
99 p_exchange_rate_type IN VARCHAR2,
100 p_exchange_rate IN NUMBER,
101 p_exchange_date IN DATE,
102 p_batch_id IN NUMBER,
103 p_attribute_category IN VARCHAR2,
104 p_attribute1 IN VARCHAR2,
105 p_attribute2 IN VARCHAR2,
106 p_attribute3 IN VARCHAR2,
107 p_attribute4 IN VARCHAR2,
108 p_attribute5 IN VARCHAR2,
109 p_attribute6 IN VARCHAR2,
110 p_attribute7 IN VARCHAR2,
111 p_attribute8 IN VARCHAR2,
112 p_attribute9 IN VARCHAR2,
113 p_attribute10 IN VARCHAR2,
114 p_attribute11 IN VARCHAR2,
115 p_attribute12 IN VARCHAR2,
116 p_attribute13 IN VARCHAR2,
117 p_attribute14 IN VARCHAR2,
118 p_attribute15 IN VARCHAR2,
119 p_override_remit_account_flag IN VARCHAR2,
120 p_remittance_bank_account_id IN NUMBER,
121 p_customer_bank_account_id IN NUMBER,
122 p_customer_site_use_id IN NUMBER,
123 p_customer_receipt_reference IN VARCHAR2,
124 p_factor_discount_amount IN NUMBER,
125 p_deposit_date IN DATE,
126 p_receipt_method_id IN NUMBER,
127 p_doc_sequence_value IN NUMBER,
128 p_doc_sequence_id IN NUMBER,
129 p_ussgl_transaction_code IN VARCHAR2,
130 p_vat_tax_id IN NUMBER,
131 p_anticipated_clearing_date IN DATE,
132 p_customer_bank_branch_id IN NUMBER,
133 -- ARTA Changes
134 p_postmark_date IN DATE,
135 --
136 -- ******* Global Flexfield parameters *******
137 --
138 p_global_attribute1 IN VARCHAR2,
139 p_global_attribute2 IN VARCHAR2,
140 p_global_attribute3 IN VARCHAR2,
141 p_global_attribute4 IN VARCHAR2,
142 p_global_attribute5 IN VARCHAR2,
143 p_global_attribute6 IN VARCHAR2,
144 p_global_attribute7 IN VARCHAR2,
145 p_global_attribute8 IN VARCHAR2,
146 p_global_attribute9 IN VARCHAR2,
147 p_global_attribute10 IN VARCHAR2,
148 p_global_attribute11 IN VARCHAR2,
149 p_global_attribute12 IN VARCHAR2,
150 p_global_attribute13 IN VARCHAR2,
151 p_global_attribute14 IN VARCHAR2,
152 p_global_attribute15 IN VARCHAR2,
153 p_global_attribute16 IN VARCHAR2,
154 p_global_attribute17 IN VARCHAR2,
155 p_global_attribute18 IN VARCHAR2,
156 p_global_attribute19 IN VARCHAR2,
157 p_global_attribute20 IN VARCHAR2,
158 p_global_attribute_category IN VARCHAR2,
159 --
160 -- *** Notes Receivable Additional Information
161 --
162 p_issuer_name IN VARCHAR2,
163 p_issue_date IN DATE,
164 p_issuer_bank_branch_id IN NUMBER,
165 --
166 -- *** enhancement 2074220 ***
167 p_application_notes IN VARCHAR2,
168 --
169 p_cr_id OUT NOCOPY NUMBER,
170 p_ps_id OUT NOCOPY NUMBER,
171 p_row_id OUT NOCOPY VARCHAR2,
172 --
173 p_form_name IN varchar2,
174 p_form_version IN varchar2,
175 p_called_from IN VARCHAR2 DEFAULT NULL, /* BR */
176 p_le_id IN NUMBER DEFAULT NULL, /* LE */
177 p_payment_trxn_extension_id IN NUMBER DEFAULT NULL, /* payment uptake */
178 p_automatch_set_id IN NUMBER DEFAULT NULL, /* ER Automatch Application */
179 p_autoapply_flag IN VARCHAR2 DEFAULT NULL
180
181 ) IS
182 l_cr_rec ar_cash_receipts%ROWTYPE;
183 l_crh_rec ar_cash_receipt_history%ROWTYPE;
184 l_cr_id ar_cash_receipts.cash_receipt_id%TYPE;
185 l_ps_id ar_payment_schedules.payment_schedule_id%TYPE;
186 l_ccid ar_cash_receipt_history.account_code_combination_id%TYPE;
187 l_ra_ccid ar_receivable_applications.code_combination_id%TYPE;
188 l_ra_unid_ccid ar_receivable_applications.code_combination_id%TYPE;
189 l_ra_unapp_ccid ar_receivable_applications.code_combination_id%TYPE;
190 l_source_type ar_distributions.source_type%TYPE;
191 l_override_dummy
192 ar_receipt_method_accounts.override_remit_account_flag%TYPE;
193 l_creation_status ar_cash_receipt_history.status%TYPE;
194 l_status ar_cash_receipts.status%TYPE;
195 l_crh_amount ar_cash_receipt_history.amount%TYPE;
196 l_cr_acctd_amount ar_payment_schedules.acctd_amount_due_remaining%TYPE;
197 l_crh_acctd_amount ar_cash_receipt_history.amount%TYPE;
198 l_acctd_factor_discount_amount ar_cash_receipt_history.acctd_factor_discount_amount%TYPE;
199 l_bank_charges_ccid ar_cash_receipt_history.bank_charge_account_ccid%TYPE;
200 l_application_rule ar_receivable_applications.application_rule%TYPE;
201 l_called_from_api varchar2(1);
202
203 l_dummy NUMBER;
204 l_id_dummy NUMBER;
205 l_ra_id ar_receivable_applications.receivable_application_id%TYPE;
206 l_ae_doc_rec ae_doc_rec_type;
207
208 BEGIN
209
210
211 IF PG_DEBUG in ('Y', 'C') THEN
212 arp_standard.debug('arp_process_receipts.insert_cash_receipt()+');
213 END IF;
214
215 -- determine creation state (approved, confirmed, remitted, cleared)
216 -- of receipt based on payment method, as well as code combination
217 -- id.
218
219 arp_cr_util.get_creation_info(p_receipt_method_id,
220 p_remittance_bank_account_id,
221 l_creation_status,
222 l_source_type,
223 l_ccid,
224 l_override_dummy);
225
226 IF PG_DEBUG in ('Y', 'C') THEN
227 arp_standard.debug('insert_cash_receipt: ' || 'Creation status = ' || l_creation_status);
228 arp_standard.debug('insert_cash_receipt: ' || 'Source Type = ' || l_source_type);
229 arp_standard.debug('insert_cash_receipt: ' || 'ccid = ' || l_ccid);
230 END IF;
231
232 -- create ar_cash_receipt record:
233
234 -- first determine if receipt is unidentified or unapplied
235
236 IF (p_pay_from_customer IS NULL) THEN
237 l_status := 'UNID';
238 ELSE
239 l_status := 'UNAPP';
240 END IF;
241
242 -- determine receivable application ccid:
243
244 arp_proc_rct_util.get_ccids(
245 p_receipt_method_id,
246 p_remittance_bank_account_id,
247 l_ra_unid_ccid,
248 l_ra_unapp_ccid,
249 l_id_dummy,
250 l_id_dummy,
251 l_id_dummy,
252 l_bank_charges_ccid,
253 l_id_dummy,
254 l_id_dummy,
255 l_id_dummy,
256 l_id_dummy);
257
258 IF PG_DEBUG in ('Y', 'C') THEN
259 arp_standard.debug('insert_cash_receipt: ' || 'status = ' || l_status);
260 arp_standard.debug('insert_cash_receipt: ' || 'l_ra_unid_ccid = ' || l_ra_unid_ccid);
261 arp_standard.debug('insert_cash_receipt: ' || 'l_ra_unapp_ccid = ' || l_ra_unapp_ccid);
262 arp_standard.debug('insert_cash_receipt: ' || 'l_bank_charges_ccid = ' || l_bank_charges_ccid);
263 END IF;
264
265 l_cr_rec.amount := p_amount;
266 l_cr_rec.currency_code := p_currency_code;
267 l_cr_rec.pay_from_customer := p_pay_from_customer;
268 l_cr_rec.status := l_status;
269 l_cr_rec.type := 'CASH';
270 l_cr_rec.receipt_number := p_receipt_number;
271 l_cr_rec.receipt_date := p_receipt_date;
272 l_cr_rec.comments := p_comments;
273 l_cr_rec.exchange_rate_type := p_exchange_rate_type;
274 l_cr_rec.exchange_rate := p_exchange_rate;
275 l_cr_rec.exchange_date := p_exchange_date;
276 l_cr_rec.attribute_category := p_attribute_category;
277 l_cr_rec.attribute1 := p_attribute1;
278 l_cr_rec.attribute2 := p_attribute2;
279 l_cr_rec.attribute3 := p_attribute3;
280 l_cr_rec.attribute4 := p_attribute4;
281 l_cr_rec.attribute5 := p_attribute5;
282 l_cr_rec.attribute6 := p_attribute6;
283 l_cr_rec.attribute7 := p_attribute7;
284 l_cr_rec.attribute8 := p_attribute8;
285 l_cr_rec.attribute9 := p_attribute9;
286 l_cr_rec.attribute10 := p_attribute10;
287 l_cr_rec.attribute11 := p_attribute11;
288 l_cr_rec.attribute12 := p_attribute12;
289 l_cr_rec.attribute13 := p_attribute13;
290 l_cr_rec.attribute14 := p_attribute14;
291 l_cr_rec.attribute15 := p_attribute15;
292 l_cr_rec.override_remit_account_flag := p_override_remit_account_flag;
293 l_cr_rec.remit_bank_acct_use_id := p_remittance_bank_account_id;
294 l_cr_rec.confirmed_flag := 'Y';
295 l_cr_rec.customer_bank_account_id := p_customer_bank_account_id;
296 l_cr_rec.customer_site_use_id := p_customer_site_use_id;
297 l_cr_rec.deposit_date := p_deposit_date;
298 l_cr_rec.receipt_method_id := p_receipt_method_id;
299 l_cr_rec.doc_sequence_value := p_doc_sequence_value;
300 l_cr_rec.doc_sequence_id := p_doc_sequence_id;
301 l_cr_rec.ussgl_transaction_code := p_ussgl_transaction_code;
302 l_cr_rec.factor_discount_amount := 0;
303 l_cr_rec.customer_receipt_reference := p_customer_receipt_reference;
304 l_cr_rec.vat_tax_id := p_vat_tax_id;
305 l_cr_rec.anticipated_clearing_date := p_anticipated_clearing_date;
306 l_cr_rec.customer_bank_branch_id := p_customer_bank_branch_id;
307
308 l_cr_rec.global_attribute1 := p_global_attribute1;
309 l_cr_rec.global_attribute2 := p_global_attribute2;
310 l_cr_rec.global_attribute3 := p_global_attribute3;
311 l_cr_rec.global_attribute4 := p_global_attribute4;
312 l_cr_rec.global_attribute5 := p_global_attribute5;
313 l_cr_rec.global_attribute6 := p_global_attribute6;
314 l_cr_rec.global_attribute7 := p_global_attribute7;
315 l_cr_rec.global_attribute8 := p_global_attribute8;
316 l_cr_rec.global_attribute9 := p_global_attribute9;
317 l_cr_rec.global_attribute10 := p_global_attribute10;
318 l_cr_rec.global_attribute11 := p_global_attribute11;
319 l_cr_rec.global_attribute12 := p_global_attribute12;
320 l_cr_rec.global_attribute13 := p_global_attribute13;
321 l_cr_rec.global_attribute14 := p_global_attribute14;
322 l_cr_rec.global_attribute15 := p_global_attribute15;
323 l_cr_rec.global_attribute16 := p_global_attribute16;
324 l_cr_rec.global_attribute17 := p_global_attribute17;
325 l_cr_rec.global_attribute18 := p_global_attribute18;
326 l_cr_rec.global_attribute19 := p_global_attribute19;
327 l_cr_rec.global_attribute20 := p_global_attribute20;
328 l_cr_rec.global_attribute_category := p_global_attribute_category;
329
330 --
331 -- Notes Receivable Additional Information
332 --
333
334 l_cr_rec.issuer_name := p_issuer_name;
335 l_cr_rec.issue_date := p_issue_date;
336 l_cr_rec.issuer_bank_branch_id := p_issuer_bank_branch_id;
337
338 -- ARTA Changes
339 l_cr_rec.postmark_date := p_postmark_date;
340
341 -- enhancment 2074220
342 l_cr_rec.application_notes := p_application_notes;
343
344 -- Legal Entity project
345 l_cr_rec.legal_entity_id := p_le_id;
346
347 l_cr_rec.payment_trxn_extension_id := p_payment_trxn_extension_id; /* bichatte payment uptake */
348 l_cr_rec.automatch_set_id := p_automatch_set_id; /* ER Automatch Application */
349 l_cr_rec.autoapply_flag := p_autoapply_flag;
350 arp_cash_receipts_pkg.insert_p(l_cr_rec);
351
352 -- determine the amount for the cash receipt history record:
353 --
354 -- crh.amount := cr.amount - p_factor_discount_amount
355
356 l_crh_amount := l_cr_rec.amount - NVL(p_factor_discount_amount,0);
357
358 -- determine accounted amount for history record:
359 -- Changes for triangulation: If exchange rate type is not user, call
360 -- GL API to calculate accounted amount
361 IF (p_exchange_rate_type = 'User') THEN
362 arp_util.calc_acctd_amount( NULL,
363 NULL,
364 NULL,
365 l_cr_rec.exchange_rate,
366 '+',
367 l_crh_amount,
368 l_crh_acctd_amount,
369 0,
370 l_dummy,
371 l_dummy,
372 l_dummy);
373 ELSE
374 l_crh_acctd_amount := gl_currency_api.convert_amount(
375 arp_global.set_of_books_id,
376 l_cr_rec.currency_code,
377 l_cr_rec.exchange_date,
378 l_cr_rec.exchange_rate_type,
379 l_crh_amount);
380 END IF;
381
382 -- Need to work out NOCOPY acctd factor discount amount value.
383 --
384 -- The correct definition for the acctd factor discount amount is:
385 --
386 -- acctd factor discount amount := acctd cr amount -
387 -- acctd crh amount
388 --
389 -- Firstly, need to calculate the acctd cr amount. If the rate type
390 -- is not "User", call the GL API to get the triangulated value.
391
392 IF (p_exchange_rate_type = 'User') THEN
393
394 arp_util.calc_acctd_amount( NULL,
395 NULL,
396 NULL,
397 l_cr_rec.exchange_rate,
398 '+',
399 l_cr_rec.amount,
400 l_cr_acctd_amount,
401 0,
402 l_dummy,
403 l_dummy,
404 l_dummy);
405
406 ELSE
407
408 l_cr_acctd_amount := gl_currency_api.convert_amount(
409 arp_global.set_of_books_id,
410 l_cr_rec.currency_code,
411 l_cr_rec.exchange_date,
412 l_cr_rec.exchange_rate_type,
413 l_cr_rec.amount);
414 END IF;
415
416 -- Now calculate the acctd fda amount. Note that for the
417 -- cases where the rate type is not "User", this is
418 -- calculated using all triangulated values, i.e. both
419 -- l_cr_acctd_amount and l_crh_acctd_amount are
420 -- triangulated values.
421
422 l_acctd_factor_discount_amount := l_cr_acctd_amount -
423 l_crh_acctd_amount;
424
425 -- create related cash receipt history record
426
427 arp_proc_rct_util.insert_crh_rec(
428 l_cr_rec,
429 l_crh_amount,
430 l_crh_acctd_amount,
431 p_factor_discount_amount,
432 l_acctd_factor_discount_amount,
433 p_gl_date,
434 l_creation_status,
435 p_batch_id,
436 l_ccid,
437 l_bank_charges_ccid,
438 l_crh_rec,
439 p_called_from);
440
441
442 -- create related payment schedule record
443
444 arp_proc_rct_util.insert_ps_rec_cash(
445 l_cr_rec,
446 p_gl_date,
447 nvl(p_maturity_date, p_deposit_date),
448 l_cr_acctd_amount,
449 l_ps_id);
450
451 --apandit
452 --Bug 2641517 : Raise the Receipt Creation business event.
453 -- Bug 4147586, Raising BE always.
454 AR_BUS_EVENT_COVER.Raise_Rcpt_Creation_Event(l_ps_id);
455
456
457 -- create related receivable applications record
458
459 IF (l_cr_rec.status = 'UNID') THEN
460 l_application_rule := '60.1';
461 l_ra_ccid := l_ra_unid_ccid;
462 ELSE
463 l_application_rule := '60.2';
464 l_ra_ccid := l_ra_unapp_ccid;
465 END IF;
466
467 arp_proc_rct_util.insert_ra_rec_cash(
468 l_cr_rec.cash_receipt_id,
469 l_cr_rec.amount,
470 l_cr_rec.receipt_date,
471 l_cr_rec.status,
472 l_cr_acctd_amount,
473 p_gl_date,
474 l_ra_ccid,
475 l_ps_id,
476 l_application_rule,
477 '',
478 l_ra_id,
479 p_called_from); -- jrautiai BR project
480
481 /* 14-APR-2000
482 * In this BR specific situation the first UNAPP row created is not POSTABLE so no accounting created.
483 * See procedure description for more information */
484
485
486 IF nvl(p_called_from,'NONE') NOT IN ('BR_FACTORED_WITH_RECOURSE', 'AUTORECAPI') THEN --
487 --
488 --Release 11.5 VAT changes, create UNID receivable application accounting
489 --in ar_distributions
490 --
491 l_ae_doc_rec.document_type := 'RECEIPT';
492 l_ae_doc_rec.document_id := l_cr_rec.cash_receipt_id;
493 l_ae_doc_rec.accounting_entity_level := 'ONE';
494 l_ae_doc_rec.source_table := 'RA';
495 l_ae_doc_rec.source_id := l_ra_id;
496 l_ae_doc_rec.source_id_old := '';
497 l_ae_doc_rec.other_flag := '';
498
499 arp_acct_main.Create_Acct_Entry(p_ae_doc_rec => l_ae_doc_rec ,
500 p_called_from => p_called_from);
501
502 END IF;
503
504 -- create distributions record(s)
505
506 IF nvl(p_called_from,'NONE') <> 'AUTORECAPI' THEN -- bichatte autorecapi changes
507 arp_proc_rct_util.insert_dist_rec(
508 l_crh_rec.amount,
509 l_crh_acctd_amount,
510 l_crh_rec.cash_receipt_history_id,
511 l_source_type,
512 l_ccid,
513 p_called_from);
514 END IF; -- bichatte autorecapi
515
516 IF (NVL(p_factor_discount_amount,0) > 0 ) THEN
517
518 -- if bank charges exist, create distribution record
519 -- for them:
520
521 IF PG_DEBUG in ('Y', 'C') THEN
522 arp_standard.debug('insert_cash_receipt: ' || 'Before creating distribution for bank charges:');
523 arp_standard.debug('insert_cash_receipt: ' || 'p_factor_discount_amount = ' ||
524 to_char(p_factor_discount_amount));
525 arp_standard.debug('insert_cash_receipt: ' || 'l_acctd_factor_discount_amount = ' ||
526 to_char(l_acctd_factor_discount_amount));
527 arp_standard.debug('insert_cash_receipt: ' || 'l_crh_rec.cash_receipt_history_id = ' ||
528 to_char(l_crh_rec.cash_receipt_history_id));
529 arp_standard.debug('insert_cash_receipt: ' || 'l_bank_charges_ccid = ' ||
530 to_char(l_bank_charges_ccid));
531 END IF;
532
533 arp_proc_rct_util.insert_dist_rec(
534 p_factor_discount_amount,
535 l_acctd_factor_discount_amount,
536 l_crh_rec.cash_receipt_history_id,
537 'BANK_CHARGES',
538 l_bank_charges_ccid,
539 p_called_from);
540 END IF;
541
542 /* Bug 4910860: Check if the journals are balanced */
543 IF p_form_name = 'RAPI' THEN
544 l_called_from_api := 'Y';
545 ELSE
546 l_called_from_api := 'N';
547 END IF;
548
549 /*Bug 5017553 check for balance if the call is not from BR*/
550 IF NVL(p_called_from,'NONE') not in ('BR_REMITTED','BR_FACTORED_WITH_RECOURSE','BR_FACTORED_WITHOUT_RECOURSE', 'AUTORECAPI','AUTORECAPI2') THEN
551 arp_balance_check.Check_Recp_Balance(l_cr_rec.cash_receipt_id,NULL,l_called_from_api);
552 END IF;
553
554 -- copy cash_receipt_id into return variable:
555
556 p_cr_id := l_cr_rec.cash_receipt_id;
557 p_ps_id := l_ps_id;
558
559 -- update batch status
560
561 IF (p_batch_id IS NOT NULL) THEN
562 arp_rw_batches_check_pkg.update_batch_status(
563 p_batch_id);
564 END IF;
565
566 -- get the ROWID out NOCOPY parameter:
567
568 SELECT rowid
569 INTO p_row_id
570 FROM ar_cash_receipts
571 WHERE cash_receipt_id = l_cr_rec.cash_receipt_id;
572
573 IF PG_DEBUG in ('Y', 'C') THEN
574 arp_standard.debug('arp_process_receipts.insert_cash_receipt()-');
575 END IF;
576
577 EXCEPTION
578 WHEN OTHERS THEN
579 IF PG_DEBUG in ('Y', 'C') THEN
580 arp_standard.debug('Exception in insert_cash_receipt');
581 END IF;
582 RAISE;
583
584 END insert_cash_receipt;
585
586 /*===========================================================================+
587 | PROCEDURE |
588 | remit_cash_receipt |
589 | |
590 | DESCRIPTION |
591 | This entity handler is created for remitting a confirmed receipt. |
592 | Review this routine if you are planing to use it for anyother purpose |
593 | AR_CASH_RECEIPT_HISTORY |
594 | AR_DISTRIBUTIONS |
595 | |
596 | SCOPE - PUBLIC |
597 | |
598 | EXTERNAL PROCEDURES/FUNCTIONS ACCESSED |
599 | |
600 | ARGUMENTS |
601 | IN: |
602 | OUT: |
603 | |
604 | RETURNS |
605 | |
606 | NOTES |
607 | |
608 | MODIFICATION HISTORY |
609 | |
610 | 19-Mar-02 S.Nambiar created |
611 | |
612 +===========================================================================*/
613 PROCEDURE remit_cash_receipt(
614 p_cash_receipt_id IN NUMBER,
615 x_return_status OUT NOCOPY VARCHAR2
616 ) IS
617
618 l_cr_rec ar_cash_receipts%ROWTYPE;
619 l_crh_rec ar_cash_receipt_history%ROWTYPE;
620 l_new_crh_rec ar_cash_receipt_history%ROWTYPE;
621
622 l_cr_id ar_cash_receipts.cash_receipt_id%TYPE;
623 l_prev_crh_id ar_cash_receipt_history.cash_receipt_history_id%TYPE;
624 l_new_crh_id ar_cash_receipt_history.cash_receipt_history_id%TYPE;
625 l_confirmation_ccid ar_cash_receipt_history.account_code_combination_id%TYPE;
626 l_remittance_ccid ar_cash_receipt_history.account_code_combination_id%TYPE;
627
628 l_ra_ccid ar_receivable_applications.code_combination_id%TYPE;
629 l_ra_unid_ccid ar_receivable_applications.code_combination_id%TYPE;
630 l_ra_unapp_ccid ar_receivable_applications.code_combination_id%TYPE;
631
632 l_crh_amount ar_cash_receipt_history.amount%TYPE;
633 l_cr_acctd_amount ar_payment_schedules.acctd_amount_due_remaining%TYPE;
634 l_crh_acctd_amount ar_cash_receipt_history.amount%TYPE;
635 l_bank_charges_ccid ar_cash_receipt_history.bank_charge_account_ccid%TYPE;
636
637 l_dummy NUMBER;
638 l_id_dummy NUMBER;
639
640 BEGIN
641
642 IF PG_DEBUG in ('Y', 'C') THEN
643 arp_standard.debug('arp_process_receipts.remit_cash_receipt()+');
644 END IF;
645 x_return_status := FND_API.G_RET_STS_SUCCESS;
646
647 l_cr_rec.cash_receipt_id := p_cash_receipt_id;
648
649 --fetch cash receipt record
650 arp_cash_receipts_pkg.fetch_p(l_cr_rec);
651
652 --fetch cash receipt history record
653 arp_cr_history_pkg.fetch_f_crid(l_cr_rec.cash_receipt_id, l_crh_rec );
654
655 IF l_crh_rec.status <> 'CONFIRMED' then
656 IF PG_DEBUG in ('Y', 'C') THEN
657 arp_standard.debug('remit_cash_receipt: ' || 'This receipt is in '||l_crh_rec.status||
658 ' status. Does not require Remittance ');
659 END IF;
660 x_return_status := FND_API.G_RET_STS_ERROR;
661 RETURN;
662 END IF;
663
664 l_prev_crh_id := l_crh_rec.cash_receipt_history_id;
665 l_new_crh_rec := l_crh_rec;
666 l_new_crh_rec.current_record_flag := 'Y';
667 l_new_crh_rec.first_posted_record_flag := 'N';
668 l_new_crh_rec.status := 'REMITTED';
669
670 --Insert a new cash receipt history record
671 arp_cr_history_pkg.insert_p(l_new_crh_rec,l_new_crh_id );
672
673 l_crh_rec.reversal_cash_receipt_hist_id := l_new_crh_id;
674 l_crh_rec.reversal_created_from := 'PREPAY';
675 l_crh_rec.current_record_flag := null;
676
677 --Update the previous cash receipt history record
678 arp_cr_history_pkg.update_p(l_crh_rec,l_prev_crh_id );
679
680 --Get the ccids
681 arp_proc_rct_util.get_ccids(
682 l_cr_rec.receipt_method_id,
683 l_cr_rec.remit_bank_acct_use_id,
684 l_ra_unid_ccid,
685 l_ra_unapp_ccid,
686 l_id_dummy,
687 l_id_dummy,
688 l_id_dummy,
689 l_bank_charges_ccid,
690 l_id_dummy,
691 l_confirmation_ccid,
692 l_remittance_ccid,
693 l_id_dummy);
694
695 --create distributions record(s)
696 --Debit remittance
697 arp_proc_rct_util.insert_dist_rec(
698 l_new_crh_rec.amount,
699 l_new_crh_rec.acctd_amount,
700 l_new_crh_id,
701 'REMITTANCE',
702 l_remittance_ccid);
703
704 --Credit confirmation
705 arp_proc_rct_util.insert_dist_rec(
706 (l_new_crh_rec.amount * -1),
707 (l_new_crh_rec.acctd_amount * -1),
708 l_new_crh_id,
709 'CONFIRMATION',
710 l_confirmation_ccid);
711
712 IF PG_DEBUG in ('Y', 'C') THEN
713 arp_standard.debug('arp_process_receipts.remit_cash_receipt()-');
714 END IF;
715
716 EXCEPTION
717 WHEN OTHERS THEN
718 x_return_status := FND_API.G_RET_STS_ERROR;
719 IF PG_DEBUG in ('Y', 'C') THEN
720 arp_standard.debug('Exception in remit_cash_receipt '||SQLERRM);
721 END IF;
722 RAISE;
723
724 END remit_cash_receipt;
725
726 END ARP_PROC_RECEIPTS2;