DBA Data[Home] [Help]

PACKAGE BODY: APPS.ARP_RW_ICR_PKG

Source


1 PACKAGE BODY ARP_RW_ICR_PKG AS
2 /* $Header: ARERICRB.pls 120.7.12010000.2 2008/08/22 09:55:05 rvelidi ship $ */
3 --
4 PG_DEBUG varchar2(1) := NVL(FND_PROFILE.value('AFLOG_ENABLED'), 'N');
5 
6 PROCEDURE validate_args_insert_row(
7             p_row_id  IN VARCHAR2,
8             p_cr_id  IN ar_interim_cash_receipts.cash_receipt_id%TYPE,
9             p_special_type IN ar_interim_cash_receipts.special_type%TYPE,
10             p_receipt_number IN ar_interim_cash_receipts.receipt_number%TYPE,
11             p_receipt_date IN ar_interim_cash_receipts.receipt_date%TYPE,
12             p_gl_date IN ar_interim_cash_receipts.gl_date%TYPE,
13             p_batch_id IN ar_interim_cash_receipts.batch_id%TYPE,
14             p_pay_from_customer IN
15                  ar_interim_cash_receipts.pay_from_customer%TYPE,
16             p_site_use_id IN
17                  ar_interim_cash_receipts.site_use_id%TYPE,
18             p_customer_trx_id IN ar_interim_cash_receipts.customer_trx_id%TYPE,
19             p_payment_schedule_id IN
20                           ar_payment_schedules.payment_schedule_id%TYPE,
21             p_currency_code IN ar_interim_cash_receipts.currency_code%TYPE,
22             p_receipt_amount IN ar_interim_cash_receipts.amount%TYPE,
23             p_receipt_method_id IN
24                  ar_interim_cash_receipts.receipt_method_id%TYPE,
25             p_remittance_bank_account_id IN
26                  ar_interim_cash_receipts.remit_bank_acct_use_id%TYPE );
27 --
28 PROCEDURE validate_args_update_row(
29             p_row_id   IN VARCHAR2,
30             p_cr_id IN ar_interim_cash_receipts.cash_receipt_id%TYPE,
31             p_special_type IN ar_interim_cash_receipts.special_type%TYPE,
32             p_receipt_number IN ar_interim_cash_receipts.receipt_number%TYPE,
33             p_batch_id IN ar_interim_cash_receipts.batch_id%TYPE,
34             p_pay_from_customer IN
35                  ar_interim_cash_receipts.pay_from_customer%TYPE,
36             p_site_use_id IN
37                  ar_interim_cash_receipts.site_use_id%TYPE,
38             p_customer_trx_id IN ar_interim_cash_receipts.customer_trx_id%TYPE,
39             p_payment_schedule_id IN
40                           ar_payment_schedules.payment_schedule_id%TYPE,
41             p_receipt_amount IN ar_interim_cash_receipts.amount%TYPE,
42             p_receipt_method_id IN
43                  ar_interim_cash_receipts.receipt_method_id%TYPE,
44             p_remittance_bank_account_id IN
45                  ar_interim_cash_receipts.remit_bank_acct_use_id%TYPE );
46 --
47 PROCEDURE validate_special_type(
48             p_special_type IN ar_interim_cash_receipts.special_type%TYPE,
49             p_pay_from_customer IN
50                  ar_interim_cash_receipts.pay_from_customer%TYPE,
51             p_site_use_id IN
52                  ar_interim_cash_receipts.site_use_id%TYPE,
53             p_customer_trx_id IN ar_interim_cash_receipts.customer_trx_id%TYPE,
54             p_payment_schedule_id IN
55                           ar_payment_schedules.payment_schedule_id%TYPE );
56 --
57 PROCEDURE val_args_applied_amount_total(
58                  p_cr_id IN ar_interim_cash_receipts.cash_receipt_id%TYPE );
59 PROCEDURE val_args_check_unique_receipt(
60             p_special_type IN ar_interim_cash_receipts.special_type%TYPE,
61             p_receipt_number IN ar_interim_cash_receipts.receipt_number%TYPE,
62             p_customer_id IN hz_cust_accounts.cust_account_id%TYPE,
63             p_receipt_amount IN ar_interim_cash_receipts.amount%TYPE );
64 --
65 PROCEDURE update_bank_account_uses(
66             p_customer_id IN hz_cust_accounts.cust_account_id%TYPE,
67             p_bank_account_id IN ar_batches.remit_bank_acct_use_id%TYPE );
68 --
69 /*===========================================================================+
70  | PROCEDURE                                                                 |
71  |    update_row   -  Update a row in the AR_ICR     table after checking for|
72  |                    uniqueness                                             |
73  |                                                                           |
74  | DESCRIPTION                                                               |
75  |    This function updates a row in AR_ICR     table after checking for     |
76  |    uniqueness for items of the receipt                                    |
77  |									     |
78  | SCOPE - PUBLIC                                                            |
79  |									     |
80  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
81  |      arp_util.debug - debug procedure                                     |
82  |                                                                           |
83  | ARGUMENTS  : IN:                     				     |
84  |                 p_row_id - Row ID                                         |
85  |                 p_cr_id  - Cash receipt Id                                |
86  |                 p_receipt_number - Receipt Number                         |
87  |                 p_gl_date - GL Date                                       |
88  |                 p_customer_id - Customer ID                               |
89  |                 p_receipt_amount - Receipt Amount                         |
90  |                 p_module_name - Module that called this procedure         |
91  |                 p_module_version - Version of the module that called this |
92  |                                    procedure                              |
93  |              OUT:                                                         |
94  |                                                                           |
95  | RETURNS    : NONE                    				     |
96  |                                                                           |
97  | NOTES - This procedure calls the check_unique_receipt procedure           |
98  |                                                                           |
99  | MODIFICATION HISTORY -  08/08/95 - Created by Ganesh Vaidee	     	     |
100  |                                                                           |
101  | 10-21-96	OSTEINME	Added new parameters p_factor_discount_amount|
102  |				and p_customer_bank_account_id for Japan     |
103  |				project.				     |
104  |				Also added new parameter		     |
105  |				p_anticipated_clearing_date for bug 371373   |
106  | 10-28-96	OSTEINME	added new parameter customer_bank_branch_id  |
107  | 08-25-97     KLAWRANC	Bug fix #462056.                             |
108  |                       Uncommented out NOCOPY call to update_bank_uses.    |
109  |                              Changed call to pass                         |
110  |                              p_customer_bank_account_id.                  |
111  | 10-28-98     K.Murphy  Cross Currency Lockbox.  Added amount_applied      |
112  |                        and trans_to_receipt_rate as parameters and updated|
113  |                        columns.                                           |
114  | 12-24-98     D.Jancis        Bug 750400: Added GL_DATE as it was not      |
115  |                              being passed in thus not getting updated     |
116  | 05-01-02	D.Jancis	Enh 2074220: added application notes         |
117  |                              procedures.                                  |
118  | 12-24-02   K.Dhaliwal          Bug 2707190 Added                          |
119  |                                application_ref_type,customer_reference and|
120  |                                customer_reason to update and insert       |
121  |                                procedures.                                |
122  +===========================================================================*/
123 
124 -- Bug fix: 597519  	12/18/97
125 -- Problem: rate information is not being passed to server on commit
126 -- Changes: passing parameters exchange date, exchange rate and
127 --          exchange rate type to PROCEDURE update_row
128 --
129 
130 PROCEDURE update_row(
131             p_row_id   IN VARCHAR2,
132             p_cr_id   IN ar_interim_cash_receipts.cash_receipt_id%TYPE,
133             p_special_type IN ar_interim_cash_receipts.special_type%TYPE,
134             p_receipt_number IN ar_interim_cash_receipts.receipt_number%TYPE,
135             p_receipt_amount IN ar_interim_cash_receipts.amount%TYPE,
136             p_amount_applied IN
137                        ar_interim_cash_receipts.amount_applied%TYPE,
138             p_trans_to_receipt_rate IN
139                        ar_interim_cash_receipts.trans_to_receipt_rate%TYPE,
140 	    p_factor_discount_amount IN
141 			ar_interim_cash_receipts.factor_discount_amount%TYPE,
142             p_receipt_method_id IN
143                    ar_interim_cash_receipts.receipt_method_id%TYPE,
144             p_remittance_bank_account_id IN
145                    ar_interim_cash_receipts.remit_bank_acct_use_id%TYPE,
146             p_batch_id IN ar_interim_cash_receipts.batch_id%TYPE,
147             p_customer_trx_id IN ar_interim_cash_receipts.customer_trx_id%TYPE,
148             p_payment_schedule_id IN
149                         ar_payment_schedules.payment_schedule_id%TYPE,
150             p_pay_from_customer IN
151                    ar_interim_cash_receipts.pay_from_customer%TYPE,
152 	    p_customer_bank_account_id IN
153 		   ar_interim_cash_receipts.customer_bank_account_id%TYPE,
154 	    p_customer_bank_branch_id IN
155 		   ar_interim_cash_receipts.customer_bank_branch_id%TYPE,
156             p_site_use_id IN ar_interim_cash_receipts.site_use_id%TYPE,
157             p_ussgl_transaction_code IN
158                    ar_interim_cash_receipts.ussgl_transaction_code%TYPE,
159             p_doc_sequence_id IN ar_interim_cash_receipts.doc_sequence_id%TYPE,
160             p_doc_sequence_value IN
161                            ar_interim_cash_receipts.doc_sequence_value%TYPE,
162 	    p_anticipated_clearing_date IN
163 		   ar_interim_cash_receipts.anticipated_clearing_date%TYPE,
164             p_attribute_category IN
165                            ar_interim_cash_receipts.attribute_category%TYPE,
166             p_attribute1 IN ar_interim_cash_receipts.attribute1%TYPE,
167             p_attribute2 IN ar_interim_cash_receipts.attribute2%TYPE,
168             p_attribute3 IN ar_interim_cash_receipts.attribute3%TYPE,
169             p_attribute4 IN ar_interim_cash_receipts.attribute4%TYPE,
170             p_attribute5 IN ar_interim_cash_receipts.attribute5%TYPE,
171             p_attribute6 IN ar_interim_cash_receipts.attribute6%TYPE,
172             p_attribute7 IN ar_interim_cash_receipts.attribute7%TYPE,
173             p_attribute8 IN ar_interim_cash_receipts.attribute8%TYPE,
174             p_attribute9 IN ar_interim_cash_receipts.attribute9%TYPE,
175             p_attribute10 IN ar_interim_cash_receipts.attribute10%TYPE,
176             p_attribute11 IN ar_interim_cash_receipts.attribute11%TYPE,
177             p_attribute12 IN ar_interim_cash_receipts.attribute12%TYPE,
178             p_attribute13 IN ar_interim_cash_receipts.attribute13%TYPE,
179             p_attribute14 IN ar_interim_cash_receipts.attribute14%TYPE,
180             p_attribute15 IN ar_interim_cash_receipts.attribute15%TYPE,
181 -- Bug fix: 597519  	12/18/97
182             p_exchange_date IN ar_interim_cash_receipts.exchange_date%TYPE,
183             p_exchange_rate IN ar_interim_cash_receipts.exchange_rate%TYPE,
184             p_exchange_rate_type IN
185                    ar_interim_cash_receipts.exchange_rate_type%TYPE,
186 -- Bug fix: 750400      12/24/98
187             p_gl_date  IN ar_interim_cash_receipts.gl_date%TYPE,
188 -- enh 2074220
189             p_application_notes IN
190                      ar_interim_cash_receipts.application_notes%TYPE,
191             p_application_ref_type IN
192                      ar_interim_cash_receipts.application_ref_type%TYPE,
193             p_customer_reference IN
194                      ar_interim_cash_receipts.customer_reference%TYPE,
195             p_customer_reason IN ar_interim_cash_receipts.customer_reason%TYPE,
196             p_module_name  IN VARCHAR2,
197             p_module_version IN VARCHAR2 ) IS
198 --
199 l_icr_rec   ar_interim_cash_receipts%ROWTYPE;
200 BEGIN
201     IF PG_DEBUG in ('Y', 'C') THEN
202        arp_util.debug(  'arp_rw_icr_pkg.update_row()+' );
203        arp_util.debug(  'Special Type      : '||p_special_type );
204        arp_util.debug(  'Receipt Id        : '||p_cr_id );
205        arp_util.debug(  'Row Id            : '||p_row_id );
206        arp_util.debug(  'Receipt Number    : '||p_receipt_number );
207        arp_util.debug(  'Received Amount   : '||TO_CHAR( p_receipt_amount ) );
208        arp_util.debug(  'Amount Applied    : '||TO_CHAR( p_amount_applied ) );
209        arp_util.debug(  'Cross Currency Rate: '||TO_CHAR( p_trans_to_receipt_rate) );
210        arp_util.debug(  'Bank Charges      : '||TO_CHAR( p_factor_discount_amount ) );
211     END IF;
212     arp_util.debug( 'Receipt Amount   : ' ||TO_CHAR( p_receipt_amount +
213 					p_factor_discount_amount) );
214     IF PG_DEBUG in ('Y', 'C') THEN
215        arp_util.debug(  'Method Id         : '||p_receipt_method_id );
216        arp_util.debug(  'Bank Account Use Id : '||p_remittance_bank_account_id );
217        arp_util.debug(  'Receipt Amount    : '||p_receipt_amount );
218        arp_util.debug(  'Batch Id          : '||p_batch_id );
219        arp_util.debug(  'Pay From Customer : '||p_pay_from_customer );
220        arp_util.debug(  'Cust. Bank Acct. ID: ' || p_customer_bank_account_id );
221        arp_util.debug(  'Cust. Bank Branch ID: ' || p_customer_bank_branch_id);
222        arp_util.debug(  'Site Use ID       : '||p_site_use_id );
223        arp_util.debug(  'Anticipated Clearing Date: ' || p_anticipated_clearing_date);
224     END IF;
225     --
226     arp_cr_icr_pkg.set_to_dummy( l_icr_rec );
227     --
228     -- Populate ICR record structure
229     --
230     l_icr_rec.cash_receipt_id := p_cr_id;
231     l_icr_rec.amount := p_receipt_amount;
232     l_icr_rec.amount_applied := p_amount_applied;
233     l_icr_rec.trans_to_receipt_rate := p_trans_to_receipt_rate;
234     l_icr_rec.factor_discount_amount := p_factor_discount_amount;
235     l_icr_rec.receipt_method_id := p_receipt_method_id;
236     l_icr_rec.remit_bank_acct_use_id := p_remittance_bank_account_id;
237     l_icr_rec.batch_id := p_batch_id;
238     l_icr_rec.customer_trx_id := p_customer_trx_id;
239     l_icr_rec.payment_schedule_id := p_payment_schedule_id;
240 -- Bug fix: 597519 	12/18/97
241     l_icr_rec.exchange_date := p_exchange_date;
242     l_icr_rec.exchange_rate := p_exchange_rate;
243     l_icr_rec.exchange_rate_type := p_exchange_rate_type;
244 -- Bug fix: 750400      12/24/98
245     l_icr_rec.gl_date := p_gl_date;
246 --
247     l_icr_rec.pay_from_customer := p_pay_from_customer;
248     l_icr_rec.customer_bank_account_id := p_customer_bank_account_id;
249     l_icr_rec.customer_bank_branch_id := p_customer_bank_branch_id;
250     l_icr_rec.receipt_number := p_receipt_number;
251     l_icr_rec.site_use_id := p_site_use_id;
252     l_icr_rec.special_type := p_special_type;
253     l_icr_rec.anticipated_clearing_date := p_anticipated_clearing_date;
254     --
255     l_icr_rec.status := 'UNAPP';
256     l_icr_rec.type := 'CASH';
257     --
258     l_icr_rec.ussgl_transaction_code := p_ussgl_transaction_code;
259     l_icr_rec.attribute_category := p_attribute_category;
260     l_icr_rec.attribute1 := p_attribute1;
261     l_icr_rec.attribute2 := p_attribute2;
262     l_icr_rec.attribute3 := p_attribute3;
263     l_icr_rec.attribute4 := p_attribute4;
264     l_icr_rec.attribute5 := p_attribute5;
265     l_icr_rec.attribute6 := p_attribute6;
266     l_icr_rec.attribute7 := p_attribute7;
267     l_icr_rec.attribute8 := p_attribute8;
268     l_icr_rec.attribute9 := p_attribute9;
269     l_icr_rec.attribute10 := p_attribute10;
270     l_icr_rec.attribute11 := p_attribute11;
271     l_icr_rec.attribute12 := p_attribute12;
272     l_icr_rec.attribute13 := p_attribute13;
273     l_icr_rec.attribute14 := p_attribute14;
274     l_icr_rec.attribute15 := p_attribute15;
275     l_icr_rec.doc_sequence_id := p_doc_sequence_id;
276     l_icr_rec.doc_sequence_value := p_doc_sequence_value;
277     l_icr_rec.application_notes := p_application_notes;
278 --  Bug 2707190 additions
279     l_icr_rec.application_ref_type := p_application_ref_type;
280     l_icr_rec.customer_reference := p_customer_reference;
281     l_icr_rec.customer_reason := p_customer_reason;
282     --
283     -- Validate arguments
284     --
285     IF ( p_module_name IS NOT NULL AND p_module_version IS NOT NULL ) THEN
286          validate_args_update_row( p_row_id, l_icr_rec.cash_receipt_id,
287 				   l_icr_rec.special_type,
288                                    l_icr_rec.receipt_number,
289                                    l_icr_rec.batch_id,
290                                    l_icr_rec.pay_from_customer,
291                                    l_icr_rec.site_use_id,
292  				   l_icr_rec.customer_trx_id,
293  				   l_icr_rec.payment_schedule_id,
294                                    l_icr_rec.amount,
295                                    l_icr_rec.receipt_method_id,
296                                    l_icr_rec.remit_bank_acct_use_id );
297     END IF;
298     --
299     -- Call Check Unique Batch Name procedure
300     --
301     arp_rw_icr_pkg.check_unique_receipt( p_row_id, l_icr_rec.cash_receipt_id,
302                                          l_icr_rec.special_type,
303                                          l_icr_rec.receipt_number,
304                                          l_icr_rec.pay_from_customer,
305                                          l_icr_rec.amount,
306 					 l_icr_rec.factor_discount_amount,
307                                          NULL, NULL );
308     --
309     -- Call update table handler
310     --
311     arp_cr_icr_pkg.update_p( l_icr_rec, l_icr_rec.cash_receipt_id );
312     --
313     -- Update batch table to set status
314     --
315     IF ( p_batch_id IS NOT NULL ) THEN
316         arp_rw_batches_check_pkg.update_batch_status( p_batch_id );
317     END IF;
318 
319     IF PG_DEBUG in ('Y', 'C') THEN
320        arp_util.debug(  'arp_rw_icr_pkg.update_row()-' );
321     END IF;
322     --
323     EXCEPTION
324         WHEN OTHERS THEN
325              IF PG_DEBUG in ('Y', 'C') THEN
326                 arp_util.debug(  'EXCEPTION: arp_rw_icr_pkg.update_row' );
327              END IF;
328              RAISE;
329 END update_row;
330 --
331 /*===========================================================================+
332  | PROCEDURE                                                                 |
333  |    validate_args_update_row                                               |
334  |                                                                           |
335  | DESCRIPTION                                                               |
336  |    Validate arguments passed to update_row   procedure                    |
337  |									     |
338  | SCOPE - PRIVATE                                                           |
339  |									     |
340  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED - NONE                            |
341  |      arp_util.debug - debug procedure                                     |
342  |                                                                           |
343  | ARGUMENTS  : IN:                     				     |
344  |                 p_receipt_number - Receipt Number                         |
345  |                 p_gl_date - GL Date                                       |
346  |                 p_customer_id - Customer ID                               |
347  |                 p_receipt_amount - Receipt Amount                         |
348  |              OUT:                                                         |
349  |                                                                           |
350  | RETURNS    : NONE                    				     |
351  |                                                                           |
352  | NOTES -                                                                   |
353  |                                                                           |
354  | MODIFICATION HISTORY - Created by Ganesh Vaidee - 08/08/95		     |
355  |                                                                           |
356  +===========================================================================*/
357 PROCEDURE validate_args_update_row(
358             p_row_id   IN VARCHAR2,
359             p_cr_id IN ar_interim_cash_receipts.cash_receipt_id%TYPE,
360             p_special_type IN ar_interim_cash_receipts.special_type%TYPE,
361             p_receipt_number IN ar_interim_cash_receipts.receipt_number%TYPE,
362             p_batch_id IN ar_interim_cash_receipts.batch_id%TYPE,
363             p_pay_from_customer IN
364                  ar_interim_cash_receipts.pay_from_customer%TYPE,
365             p_site_use_id IN
366                  ar_interim_cash_receipts.site_use_id%TYPE,
367             p_customer_trx_id IN ar_interim_cash_receipts.customer_trx_id%TYPE,
368             p_payment_schedule_id IN
369                           ar_payment_schedules.payment_schedule_id%TYPE,
370             p_receipt_amount IN ar_interim_cash_receipts.amount%TYPE,
371             p_receipt_method_id IN
372                  ar_interim_cash_receipts.receipt_method_id%TYPE,
373             p_remittance_bank_account_id IN
374                  ar_interim_cash_receipts.remit_bank_acct_use_id%TYPE ) IS
375 BEGIN
376     IF PG_DEBUG in ('Y', 'C') THEN
377        arp_util.debug(  'arp_rw_icr_pkg.validate_args_update_row()+' );
378     END IF;
379     --
380     IF ( p_row_id IS NULL OR p_cr_id IS NULL OR
381          p_receipt_number IS NULL OR p_receipt_amount IS NULL OR
382          p_batch_id IS NULL OR p_remittance_bank_account_id IS NULL OR
383          p_receipt_method_id IS NULL ) THEN
384         FND_MESSAGE.set_name ('AR', 'AR_ARGUEMENTS_FAIL' );
385         APP_EXCEPTION.raise_exception;
386     END IF;
387     --
388     validate_special_type( p_special_type, p_pay_from_customer,
389                            p_site_use_id, p_customer_trx_id,
390 			   p_payment_schedule_id );
391     --
392     IF PG_DEBUG in ('Y', 'C') THEN
393        arp_util.debug(  'arp_rw_icr_pkg.validate_args_update_row()-' );
394     END IF;
395     --
396     EXCEPTION
397          WHEN OTHERS THEN
398               IF PG_DEBUG in ('Y', 'C') THEN
399                  arp_util.debug(
400 		     'EXCEPTION: arp_rw_icr_pkg.validate_args_update_row' );
401               END IF;
402               RAISE;
403 END validate_args_update_row;
404 --
405 /*===========================================================================+
406  | PROCEDURE                                                                 |
407  |    insert_row   -  Inserts a row into the QRC_ICR table after checking for|
408  |                    uniqueness                                             |
409  |                                                                           |
410  | DESCRIPTION                                                               |
411  |    This function Inserts a row into the QRC_ICR table after checking for  |
412  |    uniqueness for items such of the receipt number                        |
413  |									     |
414  | SCOPE - PUBLIC                                                            |
415  |									     |
416  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
417  |      arp_util.debug - debug procedure                                     |
418  |                                                                           |
419  | ARGUMENTS  : IN:                     				     |
420  |                 p_receipt_number - Receipt Number                         |
421  |                 p_gl_date - GL Date                                       |
422  |                 p_customer_id - Customer ID                               |
423  |                 p_receipt_amount - Receipt Amount                         |
424  |                 p_module_name - Module that called this procedure         |
425  |                 p_module_version - Version of the module that called this |
426  |                                    procedure                              |
427  |              OUT:                                                         |
428  |                 p_row_id - Row ID                                         |
429  |                 p_cr_id  - Cash receipt Id                                |
430  |                                                                           |
431  | RETURNS    : NONE                    				     |
432  |                                                                           |
433  | NOTES - This procedure calls the check_unique_receipt procedure           |
434  |                                                                           |
435  | MODIFICATION HISTORY -  08/08/95 - Created by Ganesh Vaidee	     	     |
436  | 10-21-96	OSTEINME	Added new parameters p_factor_discount_amount|
437  |				and p_customer_bank_account_id for Japan     |
438  |				project.				     |
439  |				Also added new parameter		     |
440  |				p_anticipated_clearing_date for bug 371373   |
441  | 10-28-96	OSTEINME	added parameter customer_bank_branch_id	     |
442  | 10-28-98     K.Murphy  Cross Currency Lockbox.  Added amount_applied      |
443  |                        and trans_to_receipt_rate as parameters and created|
444  |                        columns.                                           |
445  | 05-01-02     D.Jancis   	Enh 2074220: added application notes         |
446  | 12-24-02   K.Dhaliwal          Bug 2707190 Added                          |
447  |                                application_ref_type,customer_reference and|
448  |                                customer_reason to update and insert       |
449  |                                procedures.                                |
450  +===========================================================================*/
451 PROCEDURE insert_row(
452             p_row_id   IN OUT NOCOPY VARCHAR2,
453             p_cr_id   IN OUT NOCOPY ar_interim_cash_receipts.cash_receipt_id%TYPE,
454             p_special_type IN ar_interim_cash_receipts.special_type%TYPE,
455             p_receipt_number IN ar_interim_cash_receipts.receipt_number%TYPE,
456             p_currency_code IN ar_interim_cash_receipts.currency_code%TYPE,
457             p_receipt_amount IN ar_interim_cash_receipts.amount%TYPE,
458             p_amount_applied IN
459                        ar_interim_cash_receipts.amount_applied%TYPE,
460             p_trans_to_receipt_rate IN
461                        ar_interim_cash_receipts.trans_to_receipt_rate%TYPE,
462 	    p_factor_discount_amount
463 		IN ar_interim_cash_receipts.factor_discount_amount%TYPE,
464             p_receipt_method_id IN
465                    ar_interim_cash_receipts.receipt_method_id%TYPE,
466             p_remittance_bank_account_id IN
467                    ar_interim_cash_receipts.remit_bank_acct_use_id%TYPE,
468             p_batch_id IN ar_interim_cash_receipts.batch_id%TYPE,
469             p_customer_trx_id IN ar_interim_cash_receipts.customer_trx_id%TYPE,
470             p_payment_schedule_id IN
471                         ar_payment_schedules.payment_schedule_id%TYPE,
472             p_exchange_date IN ar_interim_cash_receipts.exchange_date%TYPE,
473             p_exchange_rate IN ar_interim_cash_receipts.exchange_rate%TYPE,
474             p_exchange_rate_type IN
475                    ar_interim_cash_receipts.exchange_rate_type%TYPE,
476             p_gl_date IN ar_interim_cash_receipts.gl_date%TYPE,
477 	    p_anticipated_clearing_date IN
478 		   ar_interim_cash_receipts.anticipated_clearing_date%TYPE,
479             p_pay_from_customer IN
480                    ar_interim_cash_receipts.pay_from_customer%TYPE,
481 	    p_customer_bank_account_id IN
482 		   ar_interim_cash_receipts.customer_bank_account_id%TYPE,
483 	    p_customer_bank_branch_id IN
484 		   ar_interim_cash_receipts.customer_bank_branch_id%TYPE,
485             p_receipt_date IN ar_interim_cash_receipts.receipt_date%TYPE,
486             p_site_use_id IN ar_interim_cash_receipts.site_use_id%TYPE,
487             p_ussgl_transaction_code IN
488                    ar_interim_cash_receipts.ussgl_transaction_code%TYPE,
489             p_doc_sequence_id IN ar_interim_cash_receipts.doc_sequence_id%TYPE,
490             p_doc_sequence_value IN
491                            ar_interim_cash_receipts.doc_sequence_value%TYPE,
492             p_attribute_category IN
493                            ar_interim_cash_receipts.attribute_category%TYPE,
494             p_attribute1 IN ar_interim_cash_receipts.attribute1%TYPE,
495             p_attribute2 IN ar_interim_cash_receipts.attribute2%TYPE,
496             p_attribute3 IN ar_interim_cash_receipts.attribute3%TYPE,
497             p_attribute4 IN ar_interim_cash_receipts.attribute4%TYPE,
498             p_attribute5 IN ar_interim_cash_receipts.attribute5%TYPE,
499             p_attribute6 IN ar_interim_cash_receipts.attribute6%TYPE,
500             p_attribute7 IN ar_interim_cash_receipts.attribute7%TYPE,
501             p_attribute8 IN ar_interim_cash_receipts.attribute8%TYPE,
502             p_attribute9 IN ar_interim_cash_receipts.attribute9%TYPE,
503             p_attribute10 IN ar_interim_cash_receipts.attribute10%TYPE,
504             p_attribute11 IN ar_interim_cash_receipts.attribute11%TYPE,
505             p_attribute12 IN ar_interim_cash_receipts.attribute12%TYPE,
506             p_attribute13 IN ar_interim_cash_receipts.attribute13%TYPE,
507             p_attribute14 IN ar_interim_cash_receipts.attribute14%TYPE,
508             p_attribute15 IN ar_interim_cash_receipts.attribute15%TYPE,
509             p_application_notes IN
510                   ar_interim_cash_receipts.application_notes%TYPE,
511             p_application_ref_type IN
512                      ar_interim_cash_receipts.application_ref_type%TYPE,
513             p_customer_reference IN
514                      ar_interim_cash_receipts.customer_reference%TYPE,
515             p_customer_reason IN ar_interim_cash_receipts.customer_reason%TYPE,
516             p_module_name  IN VARCHAR2,
517             p_module_version IN VARCHAR2 ) IS
518 --
519 l_row_id    VARCHAR2(30);
520 l_cr_id     ar_interim_cash_receipts.cash_receipt_id%TYPE;
521 l_icr_rec   ar_interim_cash_receipts%ROWTYPE;
522 --
523 BEGIN
524     IF PG_DEBUG in ('Y', 'C') THEN
525        arp_util.debug(  'arp_rw_icr_pkg.insert_row()+' );
526        arp_util.debug(  'Special Type      : '||p_special_type );
527        arp_util.debug(  'Receipt Number    : '||p_receipt_number );
528        arp_util.debug(  'Receipt Date      : '||TO_CHAR( p_receipt_date ) );
529        arp_util.debug(  'GL Date           : '||TO_CHAR( p_gl_date ) );
530        arp_util.debug(  'Received Amount   : '||TO_CHAR( p_receipt_amount ) );
531        arp_util.debug(  'Amount Applied    : '||TO_CHAR( p_amount_applied ) );
532        arp_util.debug(  'Cross Currency Rate: '||TO_CHAR( p_trans_to_receipt_rate) );
533        arp_util.debug(  'Bank Charges      : '||TO_CHAR( p_factor_discount_amount ));
534        arp_util.debug(  'currency_code     : '||p_currency_code );
535        arp_util.debug(  'Method Id         : '||p_receipt_method_id );
536        arp_util.debug(  'Bank Account Id   : '||p_remittance_bank_account_id );
537        arp_util.debug(  'Receipt Amount    : '||p_receipt_amount );
538        arp_util.debug(  'Batch Id          : '||p_batch_id );
539        arp_util.debug(  'Pay From Customer : '||p_pay_from_customer );
540        arp_util.debug(  'Cust Bank Acct ID : '||p_customer_bank_account_id );
541        arp_util.debug(  'Cust Bank Branch ID : '||p_customer_bank_branch_id );
542        arp_util.debug(  'Site Use ID       : '||p_site_use_id );
543     END IF;
544     --
545     l_icr_rec.amount := p_receipt_amount;
546     l_icr_rec.amount_applied := p_amount_applied;
547     l_icr_rec.trans_to_receipt_rate := p_trans_to_receipt_rate;
548     l_icr_rec.factor_discount_amount := p_factor_discount_amount;
549     l_icr_rec.currency_code := p_currency_code;
550     l_icr_rec.receipt_method_id := p_receipt_method_id;
551     l_icr_rec.remit_bank_acct_use_id := p_remittance_bank_account_id;
552     l_icr_rec.batch_id := p_batch_id;
553     l_icr_rec.customer_trx_id := p_customer_trx_id;
554     l_icr_rec.exchange_date := p_exchange_date;
555     l_icr_rec.exchange_rate := p_exchange_rate;
556     l_icr_rec.exchange_rate_type := p_exchange_rate_type;
557     l_icr_rec.gl_date := p_gl_date;
558     l_icr_rec.payment_schedule_id := p_payment_schedule_id;
559     l_icr_rec.pay_from_customer := p_pay_from_customer;
560     l_icr_rec.customer_bank_account_id := p_customer_bank_account_id;
561     l_icr_rec.customer_bank_branch_id := p_customer_bank_branch_id;
562     l_icr_rec.receipt_date := p_receipt_date;
563     l_icr_rec.anticipated_clearing_date := p_anticipated_clearing_date;
564     l_icr_rec.receipt_number := p_receipt_number;
565     l_icr_rec.site_use_id := p_site_use_id;
566     l_icr_rec.special_type := p_special_type;
567     --
568     l_icr_rec.status := 'UNAPP';
569     l_icr_rec.type := 'CASH';
570     --
571     l_icr_rec.ussgl_transaction_code := p_ussgl_transaction_code;
572     l_icr_rec.attribute_category := p_attribute_category;
573     l_icr_rec.attribute1 := p_attribute1;
574     l_icr_rec.attribute2 := p_attribute2;
575     l_icr_rec.attribute3 := p_attribute3;
576     l_icr_rec.attribute4 := p_attribute4;
577     l_icr_rec.attribute5 := p_attribute5;
578     l_icr_rec.attribute6 := p_attribute6;
579     l_icr_rec.attribute7 := p_attribute7;
580     l_icr_rec.attribute8 := p_attribute8;
581     l_icr_rec.attribute9 := p_attribute9;
582     l_icr_rec.attribute10 := p_attribute10;
583     l_icr_rec.attribute11 := p_attribute11;
584     l_icr_rec.attribute12 := p_attribute12;
585     l_icr_rec.attribute13 := p_attribute13;
586     l_icr_rec.attribute14 := p_attribute14;
587     l_icr_rec.attribute15 := p_attribute15;
588     l_icr_rec.doc_sequence_id := p_doc_sequence_id;
589     l_icr_rec.doc_sequence_value := p_doc_sequence_value;
590 
591     --
592     --  enh 2074220
593     --
594     l_icr_rec.application_notes := p_application_notes;
595 
596     --
597     --  Bug 2707190 Deductions Enhancement
598     --
599 
600     l_icr_rec.application_ref_type := p_application_ref_type;
601     l_icr_rec.customer_reference := p_customer_reference;
602     l_icr_rec.customer_reason := p_customer_reason;
603 
604     --
605     -- Validate arguments
606     --
607     IF ( p_module_name IS NOT NULL AND p_module_version IS NOT NULL ) THEN
608          validate_args_insert_row( p_row_id, p_cr_id,
609                                    l_icr_rec.special_type,
610                                    l_icr_rec.receipt_number,
611                                    l_icr_rec.receipt_date,
612                                    l_icr_rec.gl_date,
613                                    l_icr_rec.batch_id,
614                                    l_icr_rec.pay_from_customer,
615                                    l_icr_rec.site_use_id,
616  				   l_icr_rec.customer_trx_id,
617  				   l_icr_rec.payment_schedule_id,
618                                    l_icr_rec.currency_code,
619                                    l_icr_rec.amount,
620                                    l_icr_rec.receipt_method_id,
621                                    l_icr_rec.remit_bank_acct_use_id );
622     END IF;
623     --
624     --
625     -- Call Check Unique Batch Name procedure
626     --
627     arp_rw_icr_pkg.check_unique_receipt( l_row_id, l_cr_id,
628                                          l_icr_rec.special_type,
629                                          l_icr_rec.receipt_number,
630                                          l_icr_rec.pay_from_customer,
631 				         l_icr_rec.amount,
632 					 l_icr_rec.factor_discount_amount,
633                                          NULL, NULL );
634     --
635     -- Check for valid GL date
636     --
637     arp_util.validate_gl_date( l_icr_rec.gl_date, NULL,
638                                NULL );
639 
640 
641     -- Do the actual Insertion
642     --
643     arp_cr_icr_pkg.insert_p( l_row_id, l_cr_id, l_icr_rec );
644     --
645     p_row_id := l_row_id;
646     p_cr_id := l_cr_id;
647 
648     --
649     -- Update batch table to set status
650     --
651 
652     IF PG_DEBUG in ('Y', 'C') THEN
653        arp_util.debug(  'Batch ID is     : '|| l_icr_rec.batch_id );
654     END IF;
655 
656     arp_rw_batches_check_pkg.update_batch_status( l_icr_rec.batch_id );
657 
658 
659     --
660     IF PG_DEBUG in ('Y', 'C') THEN
661        arp_util.debug(  'arp_rw_icr_pkg.insert_row()-' );
662     END IF;
663     --
664     EXCEPTION
665         WHEN OTHERS THEN
666              IF PG_DEBUG in ('Y', 'C') THEN
667                 arp_util.debug(  'EXCEPTION: arp_rw_icr_pkg.insert_row' );
668              END IF;
669              RAISE;
670 END insert_row;
671 --
672 /*===========================================================================+
673  | PROCEDURE                                                                 |
674  |    validate_args_insert_row                                               |
675  |                                                                           |
676  | DESCRIPTION                                                               |
677  |    Validate arguments passed to insert_row   procedure                    |
678  |									     |
679  | SCOPE - PRIVATE                                                           |
680  |									     |
681  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED - NONE                            |
682  |      arp_util.debug - debug procedure                                     |
683  |                                                                           |
684  | ARGUMENTS  : IN:                     				     |
685  |                 p_receipt_number - Receipt Number                         |
686  |                 p_gl_date - GL Date                                       |
687  |                 p_pay_from_customer - Customer ID                         |
688  |                 p_receipt_amount - Receipt Amount                         |
689  |              OUT:                                                         |
690  |                                                                           |
691  | RETURNS    : NONE                    				     |
692  |                                                                           |
693  | NOTES -                                                                   |
694  |                                                                           |
695  | MODIFICATION HISTORY - Created by Ganesh Vaidee - 08/08/95		     |
696  |                                                                           |
697  +===========================================================================*/
698 PROCEDURE validate_args_insert_row(
699             p_row_id  IN VARCHAR2,
700             p_cr_id  IN ar_interim_cash_receipts.cash_receipt_id%TYPE,
701             p_special_type IN ar_interim_cash_receipts.special_type%TYPE,
702 	    p_receipt_number IN ar_interim_cash_receipts.receipt_number%TYPE,
703 	    p_receipt_date IN ar_interim_cash_receipts.receipt_date%TYPE,
704 	    p_gl_date IN ar_interim_cash_receipts.gl_date%TYPE,
705 	    p_batch_id IN ar_interim_cash_receipts.batch_id%TYPE,
706             p_pay_from_customer IN
707                  ar_interim_cash_receipts.pay_from_customer%TYPE,
708             p_site_use_id IN
709                  ar_interim_cash_receipts.site_use_id%TYPE,
710             p_customer_trx_id IN ar_interim_cash_receipts.customer_trx_id%TYPE,
711             p_payment_schedule_id IN
712                           ar_payment_schedules.payment_schedule_id%TYPE,
713             p_currency_code IN ar_interim_cash_receipts.currency_code%TYPE,
714             p_receipt_amount IN ar_interim_cash_receipts.amount%TYPE,
715             p_receipt_method_id IN
716                  ar_interim_cash_receipts.receipt_method_id%TYPE,
717             p_remittance_bank_account_id IN
718                  ar_interim_cash_receipts.remit_bank_acct_use_id%TYPE ) IS
719 BEGIN
720     IF PG_DEBUG in ('Y', 'C') THEN
721        arp_util.debug( 'arp_rw_icr_pkg.validate_args_insert_row()+' );
722     END IF;
723     --
724     IF ( p_row_id IS NOT NULL OR p_cr_id IS NOT NULL ) THEN
725         FND_MESSAGE.set_name ('AR', 'AR_ARGUEMENTS_FAIL' );
726         APP_EXCEPTION.raise_exception;
727     END IF;
728     --
729     IF ( p_receipt_date IS NULL OR p_gl_date IS NULL OR
730          p_receipt_number IS NULL OR p_receipt_amount IS NULL OR
731          p_batch_id IS NULL OR p_currency_code IS NULL OR
732          p_remittance_bank_account_id IS NULL OR
733          p_receipt_method_id IS NULL ) THEN
734         FND_MESSAGE.set_name ('AR', 'AR_ARGUEMENTS_FAIL' );
735         APP_EXCEPTION.raise_exception;
736     END IF;
737     --
738     validate_special_type( p_special_type, p_pay_from_customer,
739                            p_site_use_id, p_customer_trx_id,
740 			   p_payment_schedule_id );
741     --
742     IF PG_DEBUG in ('Y', 'C') THEN
743        arp_util.debug( 'arp_rw_icr_pkg.validate_args_insert_row()-' );
744     END IF;
745     --
746     EXCEPTION
747          WHEN OTHERS THEN
748               IF PG_DEBUG in ('Y', 'C') THEN
749                  arp_util.debug(
750 		     'EXCEPTION: arp_rw_icr_pkg.validate_args_insert_row' );
751               END IF;
752               RAISE;
753 END validate_args_insert_row;
754 --
755 /*===========================================================================+
756  | PROCEDURE                                                                 |
757  |    validate_special_type                                                  |
758  |                                                                           |
759  | DESCRIPTION                                                               |
760  |    Validate special type and related fields                               |
761  |									     |
762  | SCOPE - PRIVATE                                                           |
763  |									     |
764  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED - NONE                            |
765  |      arp_util.debug - debug procedure                                     |
766  |                                                                           |
767  | ARGUMENTS  : IN:                     				     |
768  |                 p_special_type - Type of the receipt                      |
769  |                 pay_from_custmer - Customer Id                            |
770  |                 Site_use_id - Billing lication Id                         |
771  |                 Customer_trx_id - Transaction Id                          |
772  |                 Payment_schedule_id - PS ID                               |
773  |              OUT:                                                         |
774  |                                                                           |
775  | RETURNS    : NONE                    				     |
776  |                                                                           |
777  | NOTES -                                                                   |
778  |                                                                           |
779  | MODIFICATION HISTORY - Created by Ganesh Vaidee - 08/08/95		     |
780  |                        Modified by Shintaro Okuda - 07/23/97              |
781  |                          Bug fix for 510395:                              |
782  |                          Evaluation of site_required_flag is added        |
783  |                          in p_site_use_id validation.                     |
784  |                                                                           |
785  +===========================================================================*/
786 PROCEDURE validate_special_type(
787             p_special_type IN ar_interim_cash_receipts.special_type%TYPE,
788             p_pay_from_customer IN
789                  ar_interim_cash_receipts.pay_from_customer%TYPE,
790             p_site_use_id IN
791                  ar_interim_cash_receipts.site_use_id%TYPE,
792             p_customer_trx_id IN ar_interim_cash_receipts.customer_trx_id%TYPE,
793             p_payment_schedule_id IN
794                           ar_payment_schedules.payment_schedule_id%TYPE ) IS
795 BEGIN
796     --
797     -- If no special type entered, then transaction details should exist
798     --
799     IF ( p_special_type IS NULL ) THEN
800         IF (  p_customer_trx_id IS NULL OR p_pay_from_customer IS NULL OR
801            p_site_use_id IS NULL OR p_payment_schedule_id IS NULL ) THEN
802             FND_MESSAGE.set_name ('AR', 'AR_ARGUEMENTS_FAIL' );
803             APP_EXCEPTION.raise_exception;
804         END IF;
805     ELSIF ( p_special_type = 'UNIDENTIFIED' ) THEN
806         IF ( p_pay_from_customer IS NOT NULL OR p_site_use_id IS NOT NULL ) THEN
807             FND_MESSAGE.set_name ('AR', 'AR_ARGUEMENTS_FAIL' );
808             APP_EXCEPTION.raise_exception;
809         END IF;
810     ELSE
811         IF ( p_pay_from_customer IS NULL OR
812              (arp_global.sysparam.site_required_flag = 'Y' AND
813               p_site_use_id IS NULL )) THEN
814             FND_MESSAGE.set_name ('AR', 'AR_ARGUEMENTS_FAIL' );
815             APP_EXCEPTION.raise_exception;
816         END IF;
817     END IF;
818 END validate_special_type;
819 
820 /*===========================================================================+
821  | PROCEDURE                                                                 |
822  |    get_applied_amount_total - Get the total of applied amounts from       |
823  |                               ICR_LINES                                   |
824  |                                                                           |
825  | DESCRIPTION                                                               |
826  |     Get the total of applied amounts if the special type of the Quick     |
827  |     Receipt is 'MULTIPLE'                                                 |
828  |									     |
829  | SCOPE - PUBLIC                                                            |
830  |									     |
831  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
832  |      arp_util.debug - debug procedure                                     |
833  |                                                                           |
834  | ARGUMENTS  : IN:                     				     |
835  |                 p_cr_id - Interim Cash reveipt ID                         |
836  |                 p_module_name - Module that called this procedure         |
837  |                 p_module_version - Version of the module that called this |
838  |                                    procedure                              |
839  |              OUT:                                                         |
840  |                 p_applied_amount_total - Output applied amount total      |
841  |                                                                           |
842  | RETURNS    : NONE                    				     |
843  |                                                                           |
844  | NOTES -                                                                   |
845  |                                                                           |
846  | MODIFICATION HISTORY -  07/12/95 - Created by Ganesh Vaidee	     	     |
847  | 10/14/1998	K.Murphy	Cross Currency Lockbox.                      |
848  |                              Modified selection of the total applied      |
849  |				amount.  This needs to consider the amount   |
850  |				applied from which will hold the amount in   |
851  |				receipt currency for cross currency apps.    |
852  +===========================================================================*/
853 PROCEDURE get_applied_amount_total(
854             p_cr_id IN ar_interim_cash_receipts.cash_receipt_id%TYPE,
855             p_applied_amount_total OUT NOCOPY ar_interim_cash_receipts.amount%TYPE,
856             p_applied_count_total OUT NOCOPY NUMBER,
857             p_module_name  IN VARCHAR2,
858             p_module_version IN VARCHAR2 ) IS
859 BEGIN
860     IF PG_DEBUG in ('Y', 'C') THEN
861        arp_util.debug( 'arp_rw_icr_pkg.get_applied_amount_total()+' );
862        arp_util.debug('get_applied_amount_total: ' ||  'Icr Id            : '||p_cr_id );
863     END IF;
864     --
865     -- Validate args.
866     --
867     IF ( p_module_name IS NOT NULL AND p_module_version IS NOT NULL ) THEN
868          val_args_applied_amount_total( p_cr_id );
869     END IF;
870     --
871     SELECT sum(nvl(amount_applied_from, nvl(payment_amount,0))), count(*)
872     INTO   p_applied_amount_total,
873            p_applied_count_total
874     FROM   ar_interim_cash_receipt_lines
875     WHERE  cash_receipt_id = p_cr_id;
876     --
877     IF PG_DEBUG in ('Y', 'C') THEN
878        arp_util.debug( 'arp_rw_icr_pkg.get_applied_amount_total()-' );
879     END IF;
880     --
881     EXCEPTION
882         WHEN OTHERS THEN
883              IF PG_DEBUG in ('Y', 'C') THEN
884                 arp_util.debug('get_applied_amount_total: ' ||
885                  'EXCEPTION: arp_rw_icr_pkg.get_applied_amount_total' );
886              END IF;
887              RAISE;
888 END get_applied_amount_total;
889 --
890 /*===========================================================================+
891  | PROCEDURE                                                                 |
892  |    val_args_applied_amount_total                                          |
893  |                                                                           |
894  | DESCRIPTION                                                               |
895  |    Validate arguments passed to get_applied_amount_total procedure        |
896  |									     |
897  | SCOPE - PRIVATE                                                           |
898  |									     |
899  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED - NONE                            |
900  |      arp_util.debug - debug procedure                                     |
901  |                                                                           |
902  | ARGUMENTS  : IN:                     				     |
903  |                 p_cr_id - ICR_ID                                          |
904  |              OUT:                                                         |
905  |                                                                           |
906  | RETURNS    : NONE                    				     |
907  |                                                                           |
908  | NOTES -                                                                   |
909  |                                                                           |
910  | MODIFICATION HISTORY - Created by Ganesh Vaidee - 08/08/95		     |
911  |                                                                           |
912  +===========================================================================*/
913 PROCEDURE val_args_applied_amount_total(
914                p_cr_id IN ar_interim_cash_receipts.cash_receipt_id%TYPE ) IS
915 BEGIN
916     IF PG_DEBUG in ('Y', 'C') THEN
917        arp_util.debug( 'arp_rw_icr_pkg.val_args_applied_amount_total()+' );
918     END IF;
919     --
920     IF ( p_cr_id is NULL ) THEN
921          FND_MESSAGE.set_name ('AR', 'AR_ARGUEMENTS_FAIL' );
922          APP_EXCEPTION.raise_exception;
923     END IF;
924     --
925     IF PG_DEBUG in ('Y', 'C') THEN
926        arp_util.debug( 'arp_rw_icr_pkg.val_args_applied_amount_total()-' );
927     END IF;
928     --
929     EXCEPTION
930          WHEN OTHERS THEN
931               IF PG_DEBUG in ('Y', 'C') THEN
932                  arp_util.debug('val_args_applied_amount_total: ' ||
933 		   'EXCEPTION: arp_rw_icr_pkg.val_args_applied_amount_total' );
934               END IF;
935               RAISE;
936 END val_args_applied_amount_total;
937 --
938 /*===========================================================================+
939  | PROCEDURE                                                                 |
940  |       check_unique_receipt - Check that the entered receipt is unique     |
941  |                                                                           |
942  | DESCRIPTION                                                               |
943  |       Check that the entered receipt is unique     			     |
944  |									     |
945  | SCOPE - PUBLIC                                                            |
946  |									     |
947  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
948  |      arp_util.debug - debug procedure                                     |
949  |                                                                           |
950  | ARGUMENTS  : IN:                     				     |
951  |                 p_cr_id - Cash receipt Id                                 |
952  |                 p_receipt_number - Receipt Number                         |
953  |                 p_customer_id - Customer ID                               |
954  |                 p_receipt_amount - Receipt Amount                         |
955  |                 p_module_name - Module that called this procedure         |
956  |                 p_module_version - Version of the module that called this |
957  |                                    procedure                              |
958  |                                                                           |
959  | RETURNS    : NONE                    				     |
960  |                                                                           |
961  | NOTES -                                                                   |
962  |                                                                           |
963  | MODIFICATION HISTORY -  08/08/95 - Created by Ganesh Vaidee	     	     |
964  |                                                                           |
965  +===========================================================================*/
966 PROCEDURE check_unique_receipt(
967 	    p_row_id IN VARCHAR2,
968 	    p_cr_id IN ar_interim_cash_receipts.cash_receipt_id%TYPE,
969             p_special_type IN ar_interim_cash_receipts.special_type%TYPE,
970 	    p_receipt_number IN ar_interim_cash_receipts.receipt_number%TYPE,
971             p_customer_id IN hz_cust_accounts.cust_account_id%TYPE,
972             p_receipt_amount IN ar_interim_cash_receipts.amount%TYPE,
973 	    p_factor_discount_amount
974 		IN ar_interim_cash_receipts.factor_discount_amount%TYPE,
975             p_module_name  IN VARCHAR2,
976             p_module_version IN VARCHAR2 ) IS
977 l_count     NUMBER := 0;
978 BEGIN
979     IF PG_DEBUG in ('Y', 'C') THEN
980        arp_util.debug( 'arp_rw_icr_pkg.check_unique_receipt()+' );
981        arp_util.debug(  'Row Id            : '||p_row_id );
982        arp_util.debug(  'Icr Id            : '||p_cr_id );
983        arp_util.debug(  'Receipt Number    : '||p_receipt_number );
984        arp_util.debug(  'Customer ID       : '||p_customer_id );
985        arp_util.debug(  'Receipt Amount    : '||p_receipt_amount );
986     END IF;
987     --
988     -- Validate args. Note: Cash Receipt Id can be null
989     --
990     IF ( p_module_name IS NOT NULL AND p_module_version IS NOT NULL ) THEN
991          val_args_check_unique_receipt( p_special_type,
992                                         p_receipt_number, p_customer_id,
993                                         p_receipt_amount );
994     END IF;
995     --
996     -- Check ICR table to see if the receipt exists
997     --
998     SELECT COUNT(*)
999     INTO   l_count
1000     FROM   ar_interim_cash_receipts icr
1001     WHERE     (     p_row_id IS NULL
1002               OR  icr.rowid <> p_row_id )
1003     AND    ( p_cr_id IS NULL
1004              OR  icr.cash_receipt_id <> p_cr_id  )
1005     AND    icr.receipt_number = p_receipt_number
1006     AND    icr.pay_from_customer = p_customer_id
1007     AND    icr.amount = p_receipt_amount
1008     AND    icr.factor_discount_amount = p_factor_discount_amount;
1009     --
1010     IF ( l_count <> 0 ) THEN
1011         FND_MESSAGE.set_name( 'AR', 'AR_DUP_PYMNT' );
1012         APP_EXCEPTION.raise_exception;
1013     END IF;
1014     l_count := 0;
1015     --
1016     -- Check Cash Receipts table to see if the receipt exists
1017     --
1018     SELECT COUNT(*)
1019     INTO   l_count
1020     FROM   ar_cash_receipts cr
1021     WHERE  (    p_cr_id IS NULL
1022              OR cr.cash_receipt_id <> p_cr_id  )
1023     AND    cr.receipt_number = p_receipt_number
1024     AND    cr.pay_from_customer = p_customer_id
1025     AND    cr.amount = p_receipt_amount+p_factor_discount_amount
1026     AND    cr.reversal_category IS NULL;
1027     IF ( l_count <> 0 ) THEN
1028         FND_MESSAGE.set_name( 'AR', 'AR_DUP_PYMNT' );
1029         APP_EXCEPTION.raise_exception;
1030     END IF;
1031     --
1032     IF PG_DEBUG in ('Y', 'C') THEN
1033        arp_util.debug( 'arp_rw_icr_pkg.check_unique_receipt()-' );
1034     END IF;
1035     --
1036     EXCEPTION
1037         WHEN OTHERS THEN
1038               IF PG_DEBUG in ('Y', 'C') THEN
1039                  arp_util.debug(
1040 		   'EXCEPTION: arp_rw_icr_pkg.check_unique_receipt' );
1041               END IF;
1042         RAISE;
1043 END  check_unique_receipt;
1044 --
1045 /*===========================================================================+
1046  | PROCEDURE                                                                 |
1047  |    val_args_check_unique_receipt                                          |
1048  |                                                                           |
1049  | DESCRIPTION                                                               |
1050  |    Validate arguments passed to check_unique_receipt procedure            |
1051  |									     |
1052  | SCOPE - PRIVATE                                                           |
1053  |									     |
1054  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED - NONE                            |
1055  |      arp_util.debug - debug procedure                                     |
1056  |                                                                           |
1057  | ARGUMENTS  : IN:                     				     |
1058  |                 p_receipt_number - Receipt Number                         |
1059  |                 p_customer_id - Customer ID                               |
1060  |                 p_receipt_amount - Receipt Amount                         |
1061  |              OUT:                                                         |
1062  |                                                                           |
1063  | RETURNS    : NONE                    				     |
1064  |                                                                           |
1065  | NOTES -                                                                   |
1066  |                                                                           |
1067  | MODIFICATION HISTORY - Created by Ganesh Vaidee - 08/08/95		     |
1068  |                                                                           |
1069  +===========================================================================*/
1070 PROCEDURE val_args_check_unique_receipt(
1071             p_special_type IN ar_interim_cash_receipts.special_type%TYPE,
1072 	    p_receipt_number IN ar_interim_cash_receipts.receipt_number%TYPE,
1073             p_customer_id IN hz_cust_accounts.cust_account_id%TYPE,
1074             p_receipt_amount IN ar_interim_cash_receipts.amount%TYPE ) IS
1075 BEGIN
1076     IF PG_DEBUG in ('Y', 'C') THEN
1077        arp_util.debug( 'arp_rw_icr_pkg.val_args_check_unique_receipt()+' );
1078     END IF;
1079     --
1080     --
1081     -- Note: Special type can be NULL
1082     --
1083     IF ( p_receipt_number is NULL OR p_receipt_amount IS NULL ) THEN
1084          FND_MESSAGE.set_name ('AR', 'AR_ARGUEMENTS_FAIL' );
1085          APP_EXCEPTION.raise_exception;
1086     END IF;
1087     --
1088     IF( ( p_special_type <> 'UNIDENTIFIED' ) AND
1089         ( p_customer_id IS NULL ) ) THEN
1090          FND_MESSAGE.set_name ('AR', 'AR_ARGUEMENTS_FAIL' );
1091          APP_EXCEPTION.raise_exception;
1092     END IF;
1093     IF PG_DEBUG in ('Y', 'C') THEN
1094        arp_util.debug( 'arp_rw_icr_pkg.val_args_check_unique_receipt()-' );
1095     END IF;
1096     --
1097     EXCEPTION
1098          WHEN OTHERS THEN
1099               IF PG_DEBUG in ('Y', 'C') THEN
1100                  arp_util.debug('val_args_check_unique_receipt: ' ||
1101                    'EXCEPTION: arp_rw_icr_pkg.val_args_check_unique_receipt' );
1102               END IF;
1103               RAISE;
1104 END val_args_check_unique_receipt;
1105 --
1106 /*===========================================================================+
1107  | FUNCTION                                                                  |
1108  |       lines_exists -    - Check if lines exist for the given Cash Receipt |
1109  |                           ID.                                             |
1110  |                                                                           |
1111  | DESCRIPTION                                                               |
1112  |       Check if rows exists in ICR table for the given cash receipt id
1113  |									     |
1114  | SCOPE - PUBLIC                                                            |
1115  |									     |
1116  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
1117  |      arp_util.debug - debug procedure                                     |
1118  |                                                                           |
1119  | ARGUMENTS  : IN:                     				     |
1120  |                 p_cr_id - Cash receipt Id                                 |
1121  |                 p_module_name - Module that called this procedure         |
1122  |                 p_module_version - Version of the module that called this |
1123  |                                    procedure                              |
1124  |                                                                           |
1125  | RETURNS    : BOOLEAN - True If lines exists, else false
1126  |                                                                           |
1127  | NOTES -                                                                   |
1128  |                                                                           |
1129  | MODIFICATION HISTORY -  08/09/95 - Created by Ganesh Vaidee	     	     |
1130  |                                                                           |
1131  +===========================================================================*/
1132 FUNCTION lines_exists(
1133             p_cr_id IN ar_interim_cash_receipts.cash_receipt_id%TYPE,
1134             p_module_name  IN VARCHAR2,
1135             p_module_version IN VARCHAR2 ) RETURN BOOLEAN IS
1136 l_count   NUMBER;
1137 BEGIN
1138     --
1139     IF PG_DEBUG in ('Y', 'C') THEN
1140        arp_util.debug( 'arp_rw_icr_pkg.lines_exists()+' );
1141     END IF;
1142     --
1143     -- Do argument validation, Note: No separate procedure used
1144     --
1145     IF ( p_module_name IS NOT NULL AND p_module_version IS NOT NULL ) THEN
1146         IF ( p_cr_id is NULL ) THEN
1147             FND_MESSAGE.set_name ('AR', 'AR_ARGUEMENTS_FAIL' );
1148             APP_EXCEPTION.raise_exception;
1149         END IF;
1150     END IF;
1151     --
1152     SELECT count(*)
1153     INTO   l_count
1154     FROM   ar_interim_cash_receipt_lines icr
1155     WHERE  icr.cash_receipt_id = p_cr_id;
1156     --
1157     IF ( l_count = 0 ) THEN
1158         RETURN FALSE;
1159     ELSE
1160         RETURN TRUE;
1161     END IF;
1162     --
1163     IF PG_DEBUG in ('Y', 'C') THEN
1164        arp_util.debug( 'arp_rw_icr_pkg.lines_exists()-' );
1165     END IF;
1166     --
1167     EXCEPTION
1168         WHEN OTHERS THEN
1169               IF PG_DEBUG in ('Y', 'C') THEN
1170                  arp_util.debug('lines_exists: ' ||
1171                           'EXCEPTION: arp_rw_icr_pkg.lines_exists' );
1172               END IF;
1173               RAISE;
1174 END lines_exists;
1175 --
1176 /*===========================================================================+
1177  | PROCEDURE                                                                 |
1178  |    check_no_lines_exists- Check if lines exist for the given Cash Receipt |
1179  |                           ID.                                             |
1180  |                                                                           |
1181  | DESCRIPTION                                                               |
1182  |       Check if rows exists in ICR table for the given cash receipt id
1183  |									     |
1184  | SCOPE - PUBLIC                                                            |
1185  |									     |
1186  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
1187  |      arp_util.debug - debug procedure                                     |
1188  |                                                                           |
1189  | ARGUMENTS  : IN:                     				     |
1190  |                 p_cr_id - Cash receipt Id                                 |
1191  |                 p_module_name - Module that called this procedure         |
1192  |                 p_module_version - Version of the module that called this |
1193  |                                    procedure                              |
1194  |                                                                           |
1195  | RETURNS    : NONE
1196  |                                                                           |
1197  | NOTES -                                                                   |
1198  |                                                                           |
1199  | MODIFICATION HISTORY -  08/09/95 - Created by Ganesh Vaidee	     	     |
1200  |                                                                           |
1201  +===========================================================================*/
1202 PROCEDURE check_no_lines_exists (
1203             p_cr_id IN ar_interim_cash_receipts.cash_receipt_id%TYPE,
1204             p_module_name  IN VARCHAR2,
1205             p_module_version IN VARCHAR2 ) IS
1206 BEGIN
1207     IF PG_DEBUG in ('Y', 'C') THEN
1208        arp_util.debug( 'arp_rw_icr_pkg.check_no_lines_exists()-' );
1209     END IF;
1210     --
1211     -- Do argument validation, Note: No separate procedure used
1212     --
1213     IF ( p_module_name IS NOT NULL AND p_module_version IS NOT NULL ) THEN
1214         IF ( p_cr_id is NULL ) THEN
1215             FND_MESSAGE.set_name ('AR', 'AR_ARGUEMENTS_FAIL' );
1216             APP_EXCEPTION.raise_exception;
1217         END IF;
1218     END IF;
1219     --
1220     IF ( arp_rw_icr_pkg.lines_exists( p_cr_id, NULL, NULL ) = TRUE ) THEN
1221         FND_MESSAGE.set_name( 'AR', 'AR_UPDNA_APP_TYPE' );
1222         APP_EXCEPTION.raise_exception;
1223     END IF;
1224     --
1225     IF PG_DEBUG in ('Y', 'C') THEN
1226        arp_util.debug( 'arp_rw_icr_pkg.check_no_lines_exists()-' );
1227     END IF;
1228     --
1229     EXCEPTION
1230         WHEN OTHERS THEN
1231               IF PG_DEBUG in ('Y', 'C') THEN
1232                  arp_util.debug('check_no_lines_exists: ' ||
1233                           'EXCEPTION: arp_rw_icr_pkg.check_no_lines_exists' );
1234               END IF;
1235               RAISE;
1236 END check_no_lines_exists;
1237 --
1238 /*===========================================================================+
1239  | PROCEDURE                                                                 |
1240  |       update_bank_account_uses - Update ap_bank_account_uses table        |
1241  |                                                                           |
1242  | DESCRIPTION                                                               |
1243  |        Update ap_bank_account_uses table with passed in customer_id       |
1244  |									     |
1245  | SCOPE - PRIVATE                                                           |
1246  |									     |
1247  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
1248  |      arp_util.debug - debug procedure                                     |
1249  |                                                                           |
1250  | ARGUMENTS  : IN:                     				     |
1251  |                 p_customer_id - customer id                               |
1252  |                 p_bank_account_id - bank_account Id                       |
1253  |                                                                           |
1254  | RETURNS    : NONE                    				     |
1255  |                                                                           |
1256  | NOTES - This procedure will be called by update_row procedure             |
1257  |                                                                           |
1258  | MODIFICATION HISTORY -  08/09/95 - Created by Ganesh Vaidee	     	     |
1259  |                                                                           |
1260  +===========================================================================*/
1261 PROCEDURE update_bank_account_uses(
1262             p_customer_id IN hz_cust_accounts.cust_account_id%TYPE,
1263             p_bank_account_id IN ar_batches.remit_bank_acct_use_id%TYPE ) IS
1264 BEGIN
1265     IF PG_DEBUG in ('Y', 'C') THEN
1266        arp_util.debug( 'arp_rw_icr_pkg.update_bank_account_uses()+' );
1267        arp_util.debug('update_bank_account_uses: ' ||  'Customer ID       : '||p_customer_id );
1268        arp_util.debug('update_bank_account_uses: ' ||  'Bank Account Id   : '||p_bank_account_id );
1269     END IF;
1270     --
1271     IF PG_DEBUG in ('Y', 'C') THEN
1272        arp_util.debug( 'arp_rw_icr_pkg.update_bank_account_uses()-' );
1273     END IF;
1274     --
1275 END update_bank_account_uses;
1276 --
1277 /*===========================================================================+
1278  | PROCEDURE                                                                 |
1279  |    delete_row   -  Deletes a row from the QRC_ICR table		     |
1280  |  									     |
1281  |                                                                           |
1282  | DESCRIPTION                                                               |
1283  |    This function deletes a row from AR_INTERIM_CASH_RECEIPTS.	     |
1284  |   									     |
1285  |                                                                           |
1286  | SCOPE - PUBLIC                                                            |
1287  |                                                                           |
1288  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
1289  |      arp_util.debug - debug procedure                                     |
1290  |                                                                           |
1291  | ARGUMENTS  : IN:                                                          |
1292  |                 p_cr_id - Cash Receipt ID                                 |
1293  |                 p_row_id - Row Id                                         |
1294  |                 p_module_name - Module that called this procedure         |
1295  |                 p_module_version - Version of the module that called this |
1296  |                                    procedure                              |
1297  |              OUT:                                                         |
1298  |                                                                           |
1299  | RETURNS    : NONE                                                         |
1300  |                                                                           |
1301  | NOTES -                                                                   |
1302  |                                                                           |
1303  | MODIFICATION HISTORY -  08/08/95 - Created by Ganesh Vaidee               |
1304  | 10-21-96	OSTEINME	updated comments			     |
1305  +===========================================================================*/
1306 PROCEDURE delete_row(
1307             p_row_id   IN VARCHAR2,
1308             p_cr_id IN ar_interim_cash_receipts.cash_receipt_id%TYPE,
1309             p_module_name  IN VARCHAR2,
1310             p_module_version IN VARCHAR2 ) IS
1311 BEGIN
1312     IF PG_DEBUG in ('Y', 'C') THEN
1313        arp_util.debug( 'arp_rw_icr_pkg.delete_row()+' );
1314     END IF;
1315     --
1316     IF ( p_module_name IS NOT NULL AND p_module_version IS NOT NULL ) THEN
1317         IF ( p_cr_id is NULL OR p_row_id IS NULL ) THEN
1318             FND_MESSAGE.set_name ('AR', 'AR_ARGUEMENTS_FAIL' );
1319             APP_EXCEPTION.raise_exception;
1320         END IF;
1321     END IF;
1322     --
1323     -- Call delete table handler, first delete all lines
1324     --
1325     arp_cr_icr_lines_pkg.delete_fk( p_cr_id );
1326     arp_cr_icr_pkg.delete_p( p_cr_id );
1327     --
1328     IF PG_DEBUG in ('Y', 'C') THEN
1329        arp_util.debug( 'arp_rw_icr_pkg.delete_row()-' );
1330     END IF;
1331     --
1332     EXCEPTION
1333         WHEN OTHERS THEN
1334               IF PG_DEBUG in ('Y', 'C') THEN
1335                  arp_util.debug('delete_row: ' ||
1336                    'EXCEPTION: arp_rw_icr_pkg.delete_row' );
1337               END IF;
1338         RAISE;
1339 END delete_row;
1340 --
1341 /*===========================================================================+
1342  | PROCEDURE                                                                 |
1343  |    lock_row     -  Lock a row in the AR_ICR     table                     |
1344  |                                                                           |
1345  | DESCRIPTION                                                               |
1346  |                                                                           |
1347  | SCOPE - PUBLIC                                                            |
1348  |                                                                           |
1349  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
1350  |                                                                           |
1351  | ARGUMENTS  : IN:                                                          |
1352  |              OUT:                                                         |
1353  |                                                                           |
1354  | RETURNS    : NONE                                                         |
1355  |                                                                           |
1356  | NOTES - This procedure calls the check_unique_receipt procedure           |
1357  |                                                                           |
1358  | MODIFICATION HISTORY -  08/08/95 - Created by Ganesh Vaidee               |
1359  |                                                                           |
1360  | 10-21-96	OSTEINME	Added new parameters p_factor_discount_amount|
1361  |				and p_customer_bank_account_id for Japan     |
1362  |				project.				     |
1363  |				Also added new parameter		     |
1364  |				p_anticipated_clearing_date for bug 371373   |
1365  | 10-28-96	OSTEINME	added new parameter customer_bank_branch_id  |
1366  +===========================================================================*/
1367 PROCEDURE lock_row(
1368             p_row_id   VARCHAR2,
1369             p_cr_id   ar_interim_cash_receipts.cash_receipt_id%TYPE,
1370             p_special_type ar_interim_cash_receipts.special_type%TYPE,
1371             p_receipt_number ar_interim_cash_receipts.receipt_number%TYPE,
1372 	    p_currency_code ar_interim_cash_receipts.currency_code%TYPE,
1373             p_receipt_amount ar_interim_cash_receipts.amount%TYPE,
1374 	    p_factor_discount_amount IN
1375 		ar_interim_cash_receipts.factor_discount_amount%TYPE,
1376             p_receipt_method_id
1377                    ar_interim_cash_receipts.receipt_method_id%TYPE,
1378             p_remittance_bank_account_id
1379                    ar_interim_cash_receipts.remit_bank_acct_use_id%TYPE,
1380             p_batch_id ar_interim_cash_receipts.batch_id%TYPE,
1381             p_customer_trx_id ar_interim_cash_receipts.customer_trx_id%TYPE,
1382 	    p_payment_schedule_id
1383                         ar_payment_schedules.payment_schedule_id%TYPE,
1384             p_exchange_date ar_interim_cash_receipts.exchange_date%TYPE,
1385             p_exchange_rate ar_interim_cash_receipts.exchange_rate%TYPE,
1386             p_exchange_rate_type
1387                    ar_interim_cash_receipts.exchange_rate_type%TYPE,
1388             p_gl_date IN
1389 		   ar_interim_cash_receipts.gl_date%TYPE,
1390 	    p_anticipated_clearing_date IN
1391 		   ar_interim_cash_receipts.anticipated_clearing_date%TYPE,
1392             p_pay_from_customer
1393                    ar_interim_cash_receipts.pay_from_customer%TYPE,
1394 	    p_customer_bank_account_id IN
1395 		   ar_interim_cash_receipts.customer_bank_account_id%TYPE,
1396 	    p_customer_bank_branch_id IN
1397 		   ar_interim_cash_receipts.customer_bank_branch_id%TYPE,
1398             p_receipt_date ar_interim_cash_receipts.receipt_date%TYPE,
1399             p_site_use_id ar_interim_cash_receipts.site_use_id%TYPE,
1400             p_ussgl_transaction_code
1401                    ar_interim_cash_receipts.ussgl_transaction_code%TYPE,
1402             p_doc_sequence_id ar_interim_cash_receipts.doc_sequence_id%TYPE,
1403             p_doc_sequence_value
1404                            ar_interim_cash_receipts.doc_sequence_value%TYPE,
1405             p_attribute_category
1406                            ar_interim_cash_receipts.attribute_category%TYPE,
1407             p_attribute1 ar_interim_cash_receipts.attribute1%TYPE,
1408             p_attribute2 ar_interim_cash_receipts.attribute2%TYPE,
1409             p_attribute3 ar_interim_cash_receipts.attribute3%TYPE,
1410             p_attribute4 ar_interim_cash_receipts.attribute4%TYPE,
1411             p_attribute5 ar_interim_cash_receipts.attribute5%TYPE,
1412             p_attribute6 ar_interim_cash_receipts.attribute6%TYPE,
1413             p_attribute7 ar_interim_cash_receipts.attribute7%TYPE,
1414             p_attribute8 ar_interim_cash_receipts.attribute8%TYPE,
1415             p_attribute9 ar_interim_cash_receipts.attribute9%TYPE,
1416             p_attribute10 ar_interim_cash_receipts.attribute10%TYPE,
1417             p_attribute11 ar_interim_cash_receipts.attribute11%TYPE,
1418             p_attribute12 ar_interim_cash_receipts.attribute12%TYPE,
1419             p_attribute13 ar_interim_cash_receipts.attribute13%TYPE,
1420             p_attribute14 ar_interim_cash_receipts.attribute14%TYPE,
1421             p_attribute15 ar_interim_cash_receipts.attribute15%TYPE
1422           ) IS
1423     CURSOR C IS
1424 	SELECT *
1425 	FROM ar_interim_cash_receipts
1426 	WHERE rowid = p_row_id
1427 	FOR UPDATE of CASH_RECEIPT_ID NOWAIT;
1428     Recinfo C%ROWTYPE;
1429 --
1430 BEGIN
1431 
1432     IF PG_DEBUG in ('Y', 'C') THEN
1433        arp_util.debug('lock_row: ' ||  'Made it to lock row' );
1434     END IF;
1435 
1436     OPEN C;
1437     FETCH C INTO Recinfo;
1438     if (C%NOTFOUND) then
1439 	CLOSE C;
1440 	FND_MESSAGE.Set_Name( 'FND', 'FORM_RECORD_DELETED');
1441 	APP_EXCEPTION.Raise_Exception;
1442     end if;
1443     CLOSE C;
1444     if(
1445 		(Recinfo.cash_receipt_id = p_cr_id )
1446 	    AND	(   (NVL(Recinfo.special_type, 'SINGLE') = p_special_type)
1447 		OR  ( 	(Recinfo.special_type IS NULL)
1448 		    AND	(p_special_type IS NULL)))
1449 	    AND	(   (Recinfo.receipt_number = p_receipt_number)
1450 		OR  ( 	(Recinfo.receipt_number IS NULL)
1451 		    AND	(p_receipt_number IS NULL)))
1452 	    AND	(Recinfo.currency_code = p_currency_code)
1453 	    AND	(Recinfo.amount = p_receipt_amount)
1454 	    AND	(Recinfo.receipt_method_id = p_receipt_method_id)
1455 	    AND	(Recinfo.remit_bank_acct_use_id = p_remittance_bank_account_id)
1456 	    AND	(   (Recinfo.batch_id = p_batch_id)
1457 		OR  ( 	(Recinfo.batch_id IS NULL)
1458 		    AND	(p_batch_id IS NULL)))
1459 	    AND	(   (Recinfo.customer_trx_id = p_customer_trx_id)
1460 		OR  ( 	(Recinfo.customer_trx_id IS NULL)
1461 		    AND	(p_customer_trx_id IS NULL)))
1462 	    AND	(   (Recinfo.payment_schedule_id = p_payment_schedule_id)
1463 		OR  ( 	(Recinfo.payment_schedule_id IS NULL)
1464 		    AND	(p_payment_schedule_id IS NULL)))
1465 	    AND	(   (Recinfo.exchange_date = p_exchange_date)
1466 		OR  ( 	(Recinfo.exchange_date IS NULL)
1467 		    AND	(p_exchange_date IS NULL)))
1468 	    AND	(   (Recinfo.exchange_rate = p_exchange_rate)
1469 		OR  ( 	(Recinfo.exchange_rate IS NULL)
1470 		    AND	(p_exchange_rate IS NULL)))
1471 	    AND	(   (Recinfo.exchange_rate_type = p_exchange_rate_type)
1472 		OR  ( 	(Recinfo.exchange_rate_type IS NULL)
1473 		    AND	(p_exchange_rate_type IS NULL)))
1474 	    AND	(Recinfo.gl_date = p_gl_date)
1475 	    AND	(   (Recinfo.pay_from_customer = p_pay_from_customer)
1476 		OR  ( 	(Recinfo.pay_from_customer IS NULL)
1477 		    AND	(p_pay_from_customer IS NULL)))
1478 	    AND	(   (Recinfo.receipt_date = p_receipt_date)
1479 		OR  ( 	(Recinfo.receipt_date IS NULL)
1480 		    AND	(p_receipt_date IS NULL)))
1481 	    AND	(   (Recinfo.site_use_id = p_site_use_id)
1482 		OR  ( 	(Recinfo.site_use_id IS NULL)
1483 		    AND	(p_site_use_id IS NULL)))
1484 	    AND	(   (Recinfo.ussgl_transaction_code = p_ussgl_transaction_code)
1485 		OR  ( 	(Recinfo.ussgl_transaction_code IS NULL)
1486 		    AND	(p_ussgl_transaction_code IS NULL)))
1487 	    AND	(   (Recinfo.doc_sequence_id = p_doc_sequence_id)
1488 		OR  ( 	(Recinfo.doc_sequence_id IS NULL)
1489 		    AND	(p_doc_sequence_id IS NULL)))
1490 	    AND	(   (Recinfo.doc_sequence_value = p_doc_sequence_value)
1491 		OR  ( 	(Recinfo.doc_sequence_value IS NULL)
1492 		    AND	(p_doc_sequence_value IS NULL)))
1493 	    AND	(   (Recinfo.attribute_category = p_attribute_category)
1494 		OR  ( 	(Recinfo.attribute_category IS NULL)
1495 		    AND	(p_attribute_category IS NULL)))
1496 	    AND	(   (Recinfo.attribute1 = p_attribute1)
1497 		OR  ( 	(Recinfo.attribute1 IS NULL)
1498 		    AND	(p_attribute1 IS NULL)))
1499 	    AND	(   (Recinfo.attribute2 = p_attribute2)
1500 		OR  ( 	(Recinfo.attribute2 IS NULL)
1501 		    AND	(p_attribute2 IS NULL)))
1502 	    AND	(   (Recinfo.attribute3 = p_attribute3)
1503 		OR  ( 	(Recinfo.attribute3 IS NULL)
1504 		    AND	(p_attribute3 IS NULL)))
1505 	    AND	(   (Recinfo.attribute4 = p_attribute4)
1506 		OR  ( 	(Recinfo.attribute4 IS NULL)
1507 		    AND	(p_attribute4 IS NULL)))
1508 	    AND	(   (Recinfo.attribute5 = p_attribute5)
1509 		OR  ( 	(Recinfo.attribute5 IS NULL)
1510 		    AND	(p_attribute5 IS NULL)))
1511 	    AND	(   (Recinfo.attribute6 = p_attribute6)
1512 		OR  ( 	(Recinfo.attribute6 IS NULL)
1513 		    AND	(p_attribute6 IS NULL)))
1514 	    AND	(   (Recinfo.attribute7 = p_attribute7)
1515 		OR  ( 	(Recinfo.attribute7 IS NULL)
1516 		    AND	(p_attribute7 IS NULL)))
1517 	    AND	(   (Recinfo.attribute8 = p_attribute8)
1518 		OR  ( 	(Recinfo.attribute8 IS NULL)
1519 		    AND	(p_attribute8 IS NULL)))
1520 	    AND	(   (Recinfo.attribute9 = p_attribute9)
1521 		OR  ( 	(Recinfo.attribute9 IS NULL)
1522 		    AND	(p_attribute9 IS NULL)))
1523 	    AND	(   (Recinfo.attribute10 = p_attribute10)
1524 		OR  ( 	(Recinfo.attribute10 IS NULL)
1525 		    AND	(p_attribute10 IS NULL)))
1526 	    AND	(   (Recinfo.attribute11 = p_attribute11)
1527 		OR  ( 	(Recinfo.attribute11 IS NULL)
1528 		    AND	(p_attribute11 IS NULL)))
1529 	    AND	(   (Recinfo.attribute12 = p_attribute12)
1530 		OR  ( 	(Recinfo.attribute12 IS NULL)
1531 		    AND	(p_attribute12 IS NULL)))
1532 	    AND	(   (Recinfo.attribute13 = p_attribute13)
1533 		OR  ( 	(Recinfo.attribute13 IS NULL)
1534 		    AND	(p_attribute13 IS NULL)))
1535 	    AND	(   (Recinfo.attribute14 = p_attribute14)
1536 		OR  ( 	(Recinfo.attribute14 IS NULL)
1537 		    AND	(p_attribute14 IS NULL)))
1538 	    AND	(   (Recinfo.attribute15 = p_attribute15)
1539 		OR  ( 	(Recinfo.attribute15 IS NULL)
1540 		    AND	(p_attribute15 IS NULL)))
1541 	    AND	(   (Recinfo.factor_discount_amount
1542 					= p_factor_discount_amount)
1543 		OR  ( 	(Recinfo.factor_discount_amount IS NULL)
1544 		    AND	(p_factor_discount_amount IS NULL)))
1545 	    AND	(   (Recinfo.customer_bank_account_id =
1546 					p_customer_bank_account_id)
1547 		OR  ( 	(Recinfo.customer_bank_account_id IS NULL)
1548 		    AND	(p_customer_bank_account_id IS NULL)))
1549 	    AND	(   (Recinfo.customer_bank_branch_id =
1550 					p_customer_bank_branch_id)
1551 		OR  ( 	(Recinfo.customer_bank_branch_id IS NULL)
1552 		    AND	(p_customer_bank_branch_id IS NULL)))
1553 	    AND	(   (Recinfo.anticipated_clearing_date =
1554 					p_anticipated_clearing_date)
1555 		OR  ( 	(Recinfo.anticipated_clearing_date IS NULL)
1556 		    AND	(p_anticipated_clearing_date IS NULL)))
1557     ) then
1558         return;
1559     else
1560 	FND_MESSAGE.Set_Name('FND', 'FORM_RECORD_CHANGED');
1561  	APP_EXCEPTION.Raise_Exception;
1562     end if;
1563 END lock_row;
1564 --
1565 END ARP_RW_ICR_PKG;