1 Package Body AR_BILLS_MAINTAIN_VAL_PVT AS
2 /* $Header: ARBRMAVB.pls 115.10 2003/11/04 16:43:33 mraymond ship $ */
3
4
5 --Validation procedures are contained in this package
6
7 /* =======================================================================
8 | Bills Receivable status constants
9 * ======================================================================*/
10
11 C_INCOMPLETE CONSTANT VARCHAR2(30) := 'INCOMPLETE';
12 C_PENDING_REMITTANCE CONSTANT VARCHAR2(30) := 'PENDING_REMITTANCE';
13 C_PENDING_ACCEPTANCE CONSTANT VARCHAR2(30) := 'PENDING_ACCEPTANCE';
14 C_MATURED_PEND_RISK_ELIM CONSTANT VARCHAR2(30) := 'MATURED_PEND_RISK_ELIMINATION';
15 C_CLOSED CONSTANT VARCHAR2(30) := 'CLOSED';
16 C_REMITTED CONSTANT VARCHAR2(30) := 'REMITTED';
17 C_PROTESTED CONSTANT VARCHAR2(30) := 'PROTESTED';
18 C_FACTORED CONSTANT VARCHAR2(30) := 'FACTORED';
19 C_ENDORSED CONSTANT VARCHAR2(30) := 'ENDORSED';
20
21
22 /* =======================================================================
23 | Bills Receivable event constants
24 * ======================================================================*/
25
26 C_MATURITY_DATE CONSTANT VARCHAR2(30) := 'MATURITY_DATE';
27 C_MATURITY_DATE_UPDATED CONSTANT VARCHAR2(30) := 'MATURITY_DATE_UPDATED';
28 C_FORMATTED CONSTANT VARCHAR2(30) := 'FORMATTED';
29 C_COMPLETED CONSTANT VARCHAR2(30) := 'COMPLETED';
30 C_ACCEPTED CONSTANT VARCHAR2(30) := 'ACCEPTED';
31 C_SELECTED_REMITTANCE CONSTANT VARCHAR2(30) := 'SELECTED_REMITTANCE';
32 C_DESELECTED_REMITTANCE CONSTANT VARCHAR2(30) := 'DESELECTED_REMITTANCE';
33 C_CANCELLED CONSTANT VARCHAR2(30) := 'CANCELLED';
34 C_RISK_ELIMINATED CONSTANT VARCHAR2(30) := 'RISK_ELIMINATED';
35 C_RISK_UNELIMINATED CONSTANT VARCHAR2(30) := 'RISK_UNELIMINATED';
36 C_RECALLED CONSTANT VARCHAR2(30) := 'RECALLED';
37 C_EXCHANGED CONSTANT VARCHAR2(30) := 'EXCHANGED';
38 C_RELEASE_HOLD CONSTANT VARCHAR2(30) := 'RELEASE_HOLD';
39
40
41 /* =======================================================================
42 | Bills Receivable action constants
43 * ======================================================================*/
44
45
46 C_COMPLETE CONSTANT VARCHAR2(30) := 'COMPLETE';
47 C_ACCEPT CONSTANT VARCHAR2(30) := 'ACCEPT';
48 C_COMPLETE_ACC CONSTANT VARCHAR2(30) := 'COMPLETE_ACC';
49 C_UNCOMPLETE CONSTANT VARCHAR2(30) := 'UNCOMPLETE';
50 C_HOLD CONSTANT VARCHAR2(30) := 'HOLD';
51 C_UNHOLD CONSTANT VARCHAR2(30) := 'RELEASE HOLD';
52 C_SELECT_REMIT CONSTANT VARCHAR2(30) := 'SELECT_REMIT';
53 C_DESELECT_REMIT CONSTANT VARCHAR2(30) := 'DESELECT_REMIT';
54 C_CANCEL CONSTANT VARCHAR2(30) := 'CANCEL';
55 C_UNPAID CONSTANT VARCHAR2(30) := 'UNPAID';
56 C_REMIT_STANDARD CONSTANT VARCHAR2(30) := 'REMIT_STANDARD';
57 C_FACTORE CONSTANT VARCHAR2(30) := 'FACTORE';
58 C_FACTORE_RECOURSE CONSTANT VARCHAR2(30) := 'FACTORE_RECOURSE';
59 C_RECALL CONSTANT VARCHAR2(30) := 'RECALL';
60 C_ELIMINATE_RISK CONSTANT VARCHAR2(30) := 'RISK ELIMINATION';
61 C_UNELIMINATE_RISK CONSTANT VARCHAR2(30) := 'REESTABLISH RISK';
62 C_PROTEST CONSTANT VARCHAR2(30) := 'PROTEST';
63 C_ENDORSE CONSTANT VARCHAR2(30) := 'ENDORSE';
64 C_ENDORSE_RECOURSE CONSTANT VARCHAR2(30) := 'ENDORSE_RECOURSE';
65 C_RESTATE CONSTANT VARCHAR2(30) := 'RESTATE';
66 C_EXCHANGE CONSTANT VARCHAR2(30) := 'EXCHANGE';
67 C_EXCHANGE_COMPLETE CONSTANT VARCHAR2(30) := 'EXCHANGE_COMPLETE';
68 C_EXCHANGE_UNCOMPLETE CONSTANT VARCHAR2(30) := 'EXCHANGE_UNCOMPLETE';
69 C_DELETE CONSTANT VARCHAR2(30) := 'DELETE';
70 C_APPROVE_REMIT CONSTANT VARCHAR2(30) := 'REMITTANCE APPROVAL';
71
72
73 /* =======================================================================
74 | Bills Receivable remittance method code constants
75 * ======================================================================*/
76
77 C_STANDARD CONSTANT VARCHAR2(30) := 'STANDARD';
78 C_FACTORING CONSTANT VARCHAR2(30) := 'FACTORING';
79
80
81 /*==============================================================================+
82 | PROCEDURE |
83 | Drawee_Is_Related |
84 | |
85 | DESCRIPTION |
86 | Test if the Drawee Identifier is related to the Bill To Customer Identifier |
87 | |
88 +===============================================================================*/
89
90
91 PG_DEBUG varchar2(1) := NVL(FND_PROFILE.value('AFLOG_ENABLED'), 'N');
92
93 FUNCTION Drawee_Is_Related ( p_customer_trx_id IN NUMBER ,
94 p_drawee_id IN NUMBER ,
95 p_br_trx_date IN DATE ) RETURN BOOLEAN
96 IS
97
98 l_count NUMBER;
99
100 BEGIN
101
102 IF PG_DEBUG in ('Y', 'C') THEN
103 arp_util.debug('AR_BILLS_MAINTAIN_VAL_PVT.Drawee_Is_Related()+');
104 END IF;
105
106 SELECT count(*)
107 INTO l_count
108 FROM ra_customer_trx trx
109 WHERE customer_trx_id=p_customer_trx_id
110 AND trx.bill_to_customer_id IN
111 (
112 SELECT arel.related_cust_account_id
113 FROM hz_cust_acct_relate arel
114 WHERE arel.cust_account_id = p_drawee_id
115 AND arel.bill_to_flag = 'Y'
116 UNION
117 SELECT rel.related_cust_account_id
118 FROM ar_paying_relationships_v rel,
119 hz_cust_accounts acc
120 WHERE rel.party_id = acc.party_id
121 AND acc.cust_account_id = p_drawee_id
122 AND p_br_trx_date BETWEEN effective_start_date
123 AND effective_end_date
124 );
125
126 IF (l_count = 0)
127 THEN
128 IF PG_DEBUG in ('Y', 'C') THEN
129 arp_util.debug('Drawee_Is_Related: ' || 'The drawee is not related to the bill to customer of the transaction');
130 END IF;
131 RETURN (FALSE);
132 ELSE
133 RETURN (TRUE);
134 END IF;
135
136 IF PG_DEBUG in ('Y', 'C') THEN
137 arp_util.debug('AR_BILLS_MAINTAIN_VAL_PVT.Drawee_Is_Related()-');
138 END IF;
139
140 EXCEPTION
141 WHEN OTHERS THEN
142 IF PG_DEBUG in ('Y', 'C') THEN
143 arp_util.debug('>>>>>>>>>> EXCEPTION : AR_BILLS_MAINTAIN_VAL_PVT.Drawee_Is_Related () ');
144 arp_util.debug('Drawee_Is_Related: ' || 'p_customer_trx_id = ' || p_customer_trx_id);
145 arp_util.debug('Drawee_Is_Related: ' || 'p_drawee_id = ' || p_drawee_id);
146 END IF;
147 RAISE;
148
149 END Drawee_Is_Related;
150
151
152 /*======================================================================================+
153 | PROCEDURE |
154 | Drawee_Is_Identical |
155 | |
156 | DESCRIPTION |
157 | Test if the Drawee Identifier is the same as the Bill To Customer Identifier |
158 | | |
159 +=======================================================================================*/
160
161 FUNCTION Drawee_Is_Identical(p_customer_trx_id IN NUMBER, p_drawee_id IN NUMBER) RETURN BOOLEAN
162 IS
163
164 l_bill_to_customer_id NUMBER;
165
166 BEGIN
167
168 IF PG_DEBUG in ('Y', 'C') THEN
169 arp_util.debug('AR_BILLS_MAINTAIN_VAL_PVT.Drawee_Is_Identical()+');
170 END IF;
171
172 SELECT bill_to_customer_id
173 INTO l_bill_to_customer_id
174 FROM ra_customer_trx
175 WHERE customer_trx_id=p_customer_trx_id;
176
177 IF (l_bill_to_customer_id <> p_drawee_id)
178 THEN
179 IF PG_DEBUG in ('Y', 'C') THEN
180 arp_util.debug('Drawee_Is_Identical: ' || 'p_customer_trx_id = ' || p_customer_trx_id);
181 arp_util.debug('Drawee_Is_Identical: ' || 'p_drawee_id = ' || p_drawee_id);
182 END IF;
183 RETURN (FALSE);
184 ELSE
185 RETURN (TRUE);
186 END IF;
187
188 IF PG_DEBUG in ('Y', 'C') THEN
189 arp_util.debug('AR_BILLS_MAINTAIN_VAL_PVT.Drawee_Is_Identical()-');
190 END IF;
191
192 EXCEPTION
193 WHEN NO_DATA_FOUND THEN
194 IF PG_DEBUG in ('Y', 'C') THEN
195 arp_util.debug('>>>>>>>>>> EXCEPTION : AR_BILLS_MAINTAIN_VAL_PVT.Drawee_Is_Identical () ');
196 arp_util.debug('Drawee_Is_Identical: ' || '>>>>>>>>>> Invalid BR ID');
197 arp_util.debug('Drawee_Is_Identical: ' || ' Customer Trx ID : ' || p_customer_trx_id);
198 END IF;
199 FND_MESSAGE.SET_NAME ('AR', 'AR_BR_INVALID_BR_ID');
200 app_exception.raise_exception;
201
202 WHEN OTHERS THEN
203 IF PG_DEBUG in ('Y', 'C') THEN
204 arp_util.debug('>>>>>>>>>> EXCEPTION : AR_BILLS_MAINTAIN_VAL_PVT.Drawee_Is_Identical () ');
205 arp_util.debug('Drawee_Is_Identical: ' || 'p_customer_trx_id = ' || p_customer_trx_id);
206 arp_util.debug('Drawee_Is_Identical: ' || 'p_drawee_id = ' || p_drawee_id);
207 END IF;
208 RAISE;
209
210 END Drawee_Is_Identical;
211
212
213
214
215 /*==============================================================================+
216 | PROCEDURE |
217 | Validate_Drawee |
218 | |
219 | DESCRIPTION |
220 | Validates that : |
221 | The Drawee is the same as or is related to the bill-to-customer |
222 | on the exchanged transaction |
223 | |
224 +==============================================================================*/
225
226 FUNCTION Validate_Drawee ( p_customer_trx_id IN NUMBER ,
227 p_drawee_id IN NUMBER ,
228 p_trx_number IN VARCHAR2 ,
229 p_br_trx_date IN DATE ) RETURN BOOLEAN
230 IS
231
232 BEGIN
233 IF PG_DEBUG in ('Y', 'C') THEN
234 arp_util.debug('Validate_Drawee: ' || 'AR_BILLS_MAINTAIN_VAL_PVT.Validate_Relation()+');
235 arp_util.debug('Validate_Drawee: ' || 'Pay Unrelated Invoices Flag : ' || arp_global.sysparam.pay_unrelated_invoices_flag);
236 END IF;
237
238
239 IF (arp_global.sysparam.pay_unrelated_invoices_flag='Y')
240 THEN
241 RETURN (TRUE);
242 ELSE
243 IF (Drawee_Is_Identical(p_customer_trx_id, p_drawee_id))
244 THEN
245 IF PG_DEBUG in ('Y', 'C') THEN
246 arp_util.debug('Validate_Drawee: ' || '>>>>>>>>>> Drawee is the same as the Bill-to Customer');
247 END IF;
248 RETURN (TRUE);
249
250 ELSIF (Drawee_Is_Related(p_customer_trx_id, p_drawee_id, p_br_trx_date))
251 THEN
252 IF PG_DEBUG in ('Y', 'C') THEN
253 arp_util.debug('Validate_Drawee: ' || '>>>>>>>>>> Drawee is related to the Bill-to Customer');
254 END IF;
255 FND_MESSAGE.set_name ( 'AR', 'AR_BR_RELATED_CUSTOMER' );
256 FND_MESSAGE.set_token ( 'TRXNUM', p_trx_number);
257 RETURN (TRUE);
258 ELSE
259 RETURN (FALSE);
260 END IF;
261 END IF;
262
263 IF PG_DEBUG in ('Y', 'C') THEN
264 arp_util.debug('Validate_Drawee: ' || 'AR_BILLS_MAINTAIN_VAL_PVT.Validate_Relation()-');
265 END IF;
266
267 EXCEPTION
268 WHEN OTHERS THEN
269 IF PG_DEBUG in ('Y', 'C') THEN
270 arp_util.debug('>>>>>>>>>> EXCEPTION : AR_BILLS_MAINTAIN_VAL_PVT.Validate_Drawee () ');
271 arp_util.debug('Validate_Drawee: ' || 'p_customer_trx_id = ' || p_customer_trx_id);
272 arp_util.debug('Validate_Drawee: ' || 'p_drawee_id = ' || p_drawee_id);
273 END IF;
274 RAISE;
275
276 END Validate_Drawee;
277
278
279
280 /*==============================================================================+
281 | PROCEDURE |
282 | Validate_Assignment |
283 | |
284 | DESCRIPTION |
285 | Validates that |
286 | All transactions have the same currency as the BR Header |
287 | All transactions have the same exchange rate |
288 | The total of the assignments match the BR Total Amount |
289 | |
290 +==============================================================================*/
291
292 PROCEDURE Validate_Assignment (p_trx_rec IN OUT NOCOPY ra_customer_trx%ROWTYPE) IS
293
294 /*-------------------------------------------+
295 | Cursor to fetch the assignments of the BR |
296 +-------------------------------------------*/
297
298 CURSOR assignment_cur IS
299 SELECT br_ref_customer_trx_id, extended_amount, br_ref_payment_schedule_id
300 FROM ra_customer_trx_lines
301 WHERE customer_trx_id = p_trx_rec.customer_trx_id;
302
303 assignment_rec assignment_cur%ROWTYPE;
304
305
306 l_functional_currency VARCHAR2(15);
307 l_reference_rate NUMBER;
308 l_total NUMBER;
309 l_ps_rec AR_PAYMENT_SCHEDULES%ROWTYPE;
310 l_trx_rec RA_CUSTOMER_TRX%ROWTYPE;
311
312 BEGIN
313
314 IF PG_DEBUG in ('Y', 'C') THEN
315 arp_util.debug('AR_BILLS_MAINTAIN_VAL_PVT.Validate_Assignment()+');
316 END IF;
317
318 l_reference_rate := -3;
319 l_total := 0;
320
321 /*---------------------------------------+
322 | LOOP on the BR assignments |
323 +----------------------------------------*/
324
325 FOR assignment_rec IN assignment_cur LOOP
326
327
328 /*---------------------------------------+
329 | Sum the assignement amounts |
330 +----------------------------------------*/
331
332 l_total := l_total + assignment_rec.extended_amount;
333
334
335 /*--------------------------------------+
336 | Fetch the Payment Schedule of the |
337 | assignment |
338 +---------------------------------------*/
339
340 arp_ps_pkg.fetch_p(assignment_rec.br_ref_payment_schedule_id, l_ps_rec);
341
342
343 /*--------------------------------------+
344 | Fetch the assignment information |
345 +---------------------------------------*/
346
347 arp_ct_pkg.fetch_p (l_trx_rec, assignment_rec.br_ref_customer_trx_id);
348
349
350 /*--------------------------------------+
351 | Validate that the assignment is |
352 | not reserved |
353 +---------------------------------------*/
354
355 IF AR_BILLS_MAINTAIN_STATUS_PUB.Is_BR_Reserved (l_ps_rec)
356 THEN
357 IF PG_DEBUG in ('Y', 'C') THEN
358 arp_util.debug ('Validate_Assignment: ' || 'The transaction ' || l_trx_rec.trx_number || ' is reserved, it cannot be assigned');
359 END IF;
360 FND_MESSAGE.SET_NAME ('AR', 'AR_BR_TRX_ALREADY_ASSIGN');
361 FND_MESSAGE.SET_TOKEN ('TRXNUM', l_trx_rec.trx_number);
362 app_exception.raise_exception;
363 END IF;
364
365 /*--------------------------------------+
366 | If the assignment is a BR, check |
367 | the status of the BR |
368 +---------------------------------------*/
369
370 IF (AR_BILLS_CREATION_VAL_PVT.Is_Transaction_BR (l_trx_rec.cust_trx_type_id))
371 THEN
372 AR_BILLS_CREATION_VAL_PVT.Validate_Assignment_Status (l_trx_rec.customer_trx_id, l_trx_rec.trx_number);
373 END IF;
374
375
376 /*--------------------------------------+
377 | Check that there is no |
378 | overapplication |
379 +---------------------------------------*/
380
381 IF ABS(assignment_rec.extended_amount) > ABS(l_ps_rec.amount_due_remaining)
382 THEN
383 IF PG_DEBUG in ('Y', 'C') THEN
384 arp_util.debug('Validate_Assignment: ' || '>>>>>>>>>> Amount Exchanged Exceed PS');
385 arp_util.debug('Validate_Assignment: ' || '>>>>>>>>>> Overapplication not allowed');
386 arp_util.debug('Validate_Assignment: ' || 'Invoice concerned : ' || assignment_rec.br_ref_customer_trx_id);
387 arp_util.debug('Validate_Assignment: ' || 'PS concerned : ' || assignment_rec.br_ref_payment_schedule_id);
388 arp_util.debug('Validate_Assignment: ' || 'Amount assigned : ' || assignment_rec.extended_amount);
389 arp_util.debug('Validate_Assignment: ' || 'PS Remaining : ' || l_ps_rec.amount_due_remaining);
390 END IF;
391 FND_MESSAGE.SET_NAME ('AR', 'AR_BR_OVERAPPLY');
392 FND_MESSAGE.SET_TOKEN ('TRXNUM', l_trx_rec.trx_number);
393 app_exception.raise_exception;
394 END IF;
395
396
397 /*--------------------------------------+
398 | Check that the assignment has the |
399 | same currency as the BR Header |
400 +---------------------------------------*/
401
402 IF (l_trx_rec.invoice_currency_code <> p_trx_rec.invoice_currency_code) THEN
403 IF PG_DEBUG in ('Y', 'C') THEN
404 arp_util.debug('Validate_Assignment: ' || '>>>>>>>>>> All transactions must have the same currency as the BR Header');
405 arp_util.debug('Validate_Assignment: ' || 'Header Currency : ' || p_trx_rec.invoice_currency_code);
406 arp_util.debug('Validate_Assignment: ' || 'Line Currency : ' || l_trx_rec.invoice_currency_code);
407 END IF;
408 FND_MESSAGE.set_name ( 'AR', 'AR_BR_BAD_ASSIGN_CURRENCY' );
409 app_exception.raise_exception;
410 END IF;
411
412
413 /*--------------------------------------+
414 | Check that all assignments have the |
415 | same exchange rate |
416 +---------------------------------------*/
417
418 IF (l_reference_rate = -3 ) THEN
419 l_reference_rate := l_trx_rec.exchange_rate;
420 END IF;
421
422 IF (l_trx_rec.exchange_rate <> l_reference_rate) THEN
423 IF PG_DEBUG in ('Y', 'C') THEN
424 arp_util.debug('Validate_Assignment: ' || '>>>>>>>>>> All transactions must have the same exchange rate');
425 arp_util.debug('Validate_Assignment: ' || 'Reference Rate : ' || l_reference_rate);
426 arp_util.debug('Validate_Assignment: ' || 'Line Rate : ' || l_trx_rec.exchange_rate);
427 END IF;
428 FND_MESSAGE.set_name ( 'AR', 'AR_BR_BAD_ASSIGN_RATE' );
429 app_exception.raise_exception;
430 END IF;
431
432
433 /*--------------------------------------+
434 | Check that the drawee is equal or |
435 | related to the bill-to customer of |
436 | the assignment |
437 +---------------------------------------*/
438
439 IF (NOT validate_drawee(assignment_rec.br_ref_customer_trx_id, p_trx_rec.drawee_id, l_trx_rec.trx_number, p_trx_rec.trx_date))
440 THEN
441 IF PG_DEBUG in ('Y', 'C') THEN
442 arp_util.debug('Validate_Assignment: ' || '>>>>>>>>>> The drawee is not related to the bill to customer');
443 END IF;
444 FND_MESSAGE.set_name ('AR', 'AR_BR_UNRELATED_CUSTOMER' );
445 FND_MESSAGE.set_token('TRXNUM', l_trx_rec.trx_number);
446 app_exception.raise_exception;
447 END IF;
448
449
450 END LOOP;
451
452
453 /*--------------------------------------+
454 | Check that the BR Total Amount is |
455 | positive |
456 +---------------------------------------*/
457
458 IF (l_total <= 0)
459 THEN
460 IF PG_DEBUG in ('Y', 'C') THEN
461 arp_util.debug('Validate_Assignment: ' || '>>>>>>>>>> The BR Total must be positibe');
462 END IF;
463 FND_MESSAGE.set_name ('AR', 'AR_BR_INVALID_AMOUNT' );
464 app_exception.raise_exception;
465
466 END IF;
467
468
469 /*--------------------------------------+
470 | Default the Total Amount in the |
471 | BR Header if it doesn't exist |
472 +---------------------------------------*/
473
474 IF (p_trx_rec.br_amount IS NULL) THEN
475 p_trx_rec.br_amount := l_total;
476 END IF;
477
478
479 /*--------------------------------------+
480 | Check that the sum of the assignment |
481 | amount equal to the BR total amount |
482 +---------------------------------------*/
483
484 IF (p_trx_rec.br_amount <> l_total) THEN
485 IF PG_DEBUG in ('Y', 'C') THEN
486 arp_util.debug('Validate_Assignment: ' || '>>>>>>>>>> The total of the assignments must match the BR Amount');
487 arp_util.debug('Validate_Assignment: ' || 'Header Total Amount : ' || p_trx_rec.br_amount);
488 arp_util.debug('Validate_Assignment: ' || 'Lines Total Amount : ' || l_total);
489 END IF;
490 FND_MESSAGE.set_name ( 'AR', 'AR_BR_BAD_TOTAL_AMOUNT' );
491 app_exception.raise_exception;
492 END IF;
493
494
495 /*--------------------------------------+
496 | Derive the exchange rate of the BR |
497 | from the assignments if necessary |
498 +---------------------------------------*/
499
500 l_functional_currency := arp_global.functional_currency;
501
502 IF PG_DEBUG in ('Y', 'C') THEN
503 arp_util.debug ('Validate_Assignment: ' || 'Functional Currency : ' || arp_global.functional_currency);
504 arp_util.debug ('Validate_Assignment: ' || 'BR Currency : ' || p_trx_rec.invoice_currency_code);
505 END IF;
506
507 IF (p_trx_rec.invoice_currency_code <> l_functional_currency)
508 THEN
509 p_trx_rec.exchange_rate := l_trx_rec.exchange_rate;
510 p_trx_rec.exchange_rate_type := nvl(l_trx_rec.exchange_rate_type, 'User');
511 /* Bug 2649369 : use exchanged invoice's exchange date instead of trx_date */
512 p_trx_rec.exchange_date := l_trx_rec.exchange_date;
513 END IF;
514
515 IF PG_DEBUG in ('Y', 'C') THEN
516 arp_util.debug('AR_BILLS_MAINTAIN_VAL_PVT.Validate_Assignment()-');
517 END IF;
518
519 EXCEPTION
520 WHEN OTHERS THEN
521 IF PG_DEBUG in ('Y', 'C') THEN
522 arp_util.debug('>>>>>>>>>> EXCEPTION : AR_BILLS_MAINTAIN_VAL_PVT.Validate_Assignment () ');
523 END IF;
524 IF (assignment_cur%ISOPEN)
525 THEN
526 CLOSE assignment_cur;
527 END IF;
528 RAISE;
529
530 END Validate_Assignment;
531
532
533 /*==============================================================================+
534 | PROCEDURE |
535 | Validate_Assignment_Exist |
536 | |
537 | DESCRIPTION |
538 | Validates that the exchanged transaction have not been purged |
539 | |
540 +==============================================================================*/
541
542 PROCEDURE Validate_Assignment_Exist (p_customer_trx_id IN ra_customer_trx.customer_trx_id%TYPE)
543 IS
544
545 /*-------------------------------------------+
546 | Cursor to fetch the assignments of the BR |
547 +-------------------------------------------*/
548
549 CURSOR assignment_cur IS
550 SELECT br_ref_customer_trx_id
551 FROM ra_customer_trx_lines
552 WHERE customer_trx_id = p_customer_trx_id;
553
554 assignment_rec assignment_cur%ROWTYPE;
555
556 l_assignment_exists VARCHAR2(1);
557
558 BEGIN
559
560 IF PG_DEBUG in ('Y', 'C') THEN
561 arp_util.debug('AR_BILLS_MAINTAIN_VAL_PVT.Validate_Assignment_Exist()+');
562 END IF;
563
564 FOR assignment_rec IN assignment_cur LOOP
565 SELECT 'Y'
566 INTO l_assignment_exists
567 FROM ra_customer_trx
568 WHERE customer_trx_id = assignment_rec.br_ref_customer_trx_id;
569
570 END LOOP;
571
572 IF PG_DEBUG in ('Y', 'C') THEN
573 arp_util.debug('AR_BILLS_MAINTAIN_VAL_PVT.Validate_Assignment_Exist()-');
574 END IF;
575
576 EXCEPTION
577 WHEN NO_DATA_FOUND THEN
578 IF PG_DEBUG in ('Y', 'C') THEN
579 arp_util.debug('>>>>>>>>>> EXCEPTION : AR_BILLS_MAINTAIN_VAL_PVT.Validate_Assignment_Exist () ');
580 arp_util.debug('Validate_Assignment: ' || '>>>>>>>>>> Exchanged Transaction has been purged : ' || assignment_rec.br_ref_customer_trx_id);
581 END IF;
582 IF (assignment_cur%ISOPEN)
583 THEN
584 CLOSE assignment_cur;
585 END IF;
586 FND_MESSAGE.set_name ( 'AR', 'AR_BR_TRX_PURGED' );
587 app_exception.raise_exception;
588
589 WHEN OTHERS THEN
590 IF PG_DEBUG in ('Y', 'C') THEN
591 arp_util.debug('>>>>>>>>>> EXCEPTION : AR_BILLS_MAINTAIN_VAL_PVT.Validate_Assignment_Exist () ');
592 END IF;
593 IF (assignment_cur%ISOPEN)
594 THEN
595 CLOSE assignment_cur;
596 END IF;
597 RAISE;
598
599 END Validate_Assignment_Exist;
600
601
602
603 /*==============================================================================+
604 | PROCEDURE |
605 | Validate_Remit_Batch_ID |
606 | |
607 | DESCRIPTION |
608 | Validates the Batch Identifier in AR_BATCHES |
609 | |
610 +==============================================================================*/
611
612 PROCEDURE Validate_Remit_Batch_ID (p_batch_id IN NUMBER) IS
613
614
615 l_batch_id_valid VARCHAR2(1);
616
617 BEGIN
618 IF PG_DEBUG in ('Y', 'C') THEN
619 arp_util.debug('AR_BILLS_MAINTAIN_VAL_PVT.Validate_Remit_Batch_ID()+');
620 END IF;
621
622 IF (p_batch_id IS NOT NULL) THEN
623 SELECT 'Y'
624 INTO l_batch_id_valid
625 FROM ar_BATCHES
626 WHERE batch_id = p_batch_id;
627 END IF;
628
629 IF PG_DEBUG in ('Y', 'C') THEN
630 arp_util.debug('AR_BILLS_MAINTAIN_VAL_PVT.Validate_Remit_Batch_ID()-');
631 END IF;
632
633 EXCEPTION
634 WHEN NO_DATA_FOUND THEN
635 IF PG_DEBUG in ('Y', 'C') THEN
636 arp_util.debug('>>>>>>>>>> EXCEPTION : AR_BILLS_MAINTAIN_VAL_PVT.Validate_Remit_Batch_ID () ');
637 arp_util.debug('Validate_Remit_Batch_ID: ' || '>>>>>>>>>> Invalid Batch ID');
638 arp_util.debug('Validate_Remit_Batch_ID: ' || 'Batch ID : ' || p_batch_id);
639 END IF;
640 FND_MESSAGE.SET_NAME ('AR', 'AR_BR_INVALID_BATCH_ID');
641 app_exception.raise_exception;
642
643 WHEN OTHERS THEN
644 IF PG_DEBUG in ('Y', 'C') THEN
645 arp_util.debug('>>>>>>>>>> EXCEPTION : AR_BILLS_MAINTAIN_VAL_PVT.Validate_Remit_Batch_ID () ');
646 END IF;
647 RAISE;
648
649
650 END Validate_Remit_Batch_ID;
651
652
653
654 /*==============================================================================+
655 | PROCEDURE |
656 | Validate_Payment_Schedule_ID |
657 | |
658 | DESCRIPTION |
659 | Validates the Payment Schedule Identifier |
660 | |
661 +==============================================================================*/
662
663 PROCEDURE Validate_Payment_Schedule_ID ( p_payment_schedule_id IN NUMBER) IS
664
665
666 l_payment_schedule_id_valid VARCHAR2(1);
667
668 BEGIN
669 IF PG_DEBUG in ('Y', 'C') THEN
670 arp_util.debug('AR_BILLS_MAINTAIN_VAL_PVT.Validate_Payment_Schedule_ID()+');
671 END IF;
672
673 SELECT 'Y'
674 INTO l_payment_schedule_id_valid
675 FROM AR_PAYMENT_SCHEDULES
676 WHERE payment_schedule_id = p_payment_schedule_id;
677
678 IF PG_DEBUG in ('Y', 'C') THEN
679 arp_util.debug('AR_BILLS_MAINTAIN_VAL_PVT.Validate_Payment_Schedule_ID()-');
680 END IF;
681
682 EXCEPTION
683 WHEN NO_DATA_FOUND THEN
684 IF PG_DEBUG in ('Y', 'C') THEN
685 arp_util.debug('>>>>>>>>>> EXCEPTION : AR_BILLS_MAINTAIN_VAL_PVT.Validate_Payment_Schedule_ID () ');
686 arp_util.debug('Validate_Payment_Schedule_ID: ' || '>>>>>>>>>> Invalid Payment Schedule ID');
687 arp_util.debug('Validate_Payment_Schedule_ID: ' || 'Payment Schedule ID : ' || p_payment_schedule_id);
688 END IF;
689 FND_MESSAGE.SET_NAME ('AR', 'AR_BR_INVALID_PS_ID');
690 app_exception.raise_exception;
691
692 WHEN OTHERS THEN
693 IF PG_DEBUG in ('Y', 'C') THEN
694 arp_util.debug('>>>>>>>>>> EXCEPTION : AR_BILLS_MAINTAIN_VAL_PVT.Validate_Payment_Schedule_ID () ');
695 END IF;
696 RAISE;
697
698 END Validate_Payment_Schedule_ID;
699
700
701 /*==============================================================================+
702 | PROCEDURE |
703 | Validate_Adj_Activity_ID |
704 | |
705 | DESCRIPTION |
706 | Validates the adjustment activity passed during BR Endorsement |
707 | |
708 +==============================================================================*/
709
710 PROCEDURE Validate_Adj_Activity_ID (p_adjustment_activity_id IN NUMBER) IS
711
712
713 l_adjustment_activity_valid VARCHAR2(1);
714
715 BEGIN
716 IF PG_DEBUG in ('Y', 'C') THEN
717 arp_util.debug('AR_BILLS_MAINTAIN_VAL_PVT.Validate_Adj_Activity_ID()+');
718 END IF;
719
720 IF (p_adjustment_activity_id IS NOT NULL)
721 THEN
722
723 SELECT 'Y'
724 INTO l_adjustment_activity_valid
725 FROM AR_RECEIVABLES_TRX
726 WHERE receivables_trx_id = p_adjustment_activity_id
727 AND status = 'A'
728 AND type = 'ENDORSEMENT';
729 ELSE
730 IF PG_DEBUG in ('Y', 'C') THEN
731 arp_util.debug ('Validate_Adj_Activity_ID: ' || 'The Adjustment Activity is missing');
732 END IF;
733 FND_MESSAGE.SET_NAME ('AR', 'AR_PROCEDURE_VALID_ARGS_FAIL');
734 FND_MESSAGE.SET_TOKEN ('PARAMETER', 'Adjustment Activity');
735 FND_MESSAGE.SET_TOKEN ('PROCEDURE', 'Endorse');
736 app_exception.raise_exception;
737 END IF;
738
739 IF PG_DEBUG in ('Y', 'C') THEN
740 arp_util.debug('AR_BILLS_MAINTAIN_VAL_PVT.Validate_Adj_Activity_ID()-');
741 END IF;
742
743 EXCEPTION
744 WHEN NO_DATA_FOUND THEN
745 IF PG_DEBUG in ('Y', 'C') THEN
746 arp_util.debug('>>>>>>>>>> EXCEPTION : AR_BILLS_MAINTAIN_VAL_PVT.Validate_Adj_Activity_ID () ');
747 arp_util.debug('Validate_Adj_Activity_ID: ' || '>>>>>>>>>> Invalid Adjustment Activity ID');
748 arp_util.debug('Validate_Adj_Activity_ID: ' || 'p_adjustment_activity_id : ' || p_adjustment_activity_id);
749 END IF;
750 FND_MESSAGE.SET_NAME ('AR', 'AR_AAPI_INVALID_RCVABLE_ID');
751 FND_MESSAGE.SET_TOKEN ('RECEIVABLES_TRX_ID', p_adjustment_activity_id);
752 app_exception.raise_exception;
753
754 WHEN OTHERS THEN
755 IF PG_DEBUG in ('Y', 'C') THEN
756 arp_util.debug('>>>>>>>>>> EXCEPTION : AR_BILLS_MAINTAIN_VAL_PVT.Validate_Adj_Activity_ID () ');
757 END IF;
758 RAISE;
759
760
761 END Validate_Adj_Activity_ID;
762
763
764
765 /*==============================================================================+
766 | PROCEDURE |
767 | Validate_Reversal_Reason |
768 | |
769 | DESCRIPTION |
770 | Validate the Reversal reason against the values in ar_lookups for |
771 | lookup_type = 'REVERSAL_CATEGORY_TYPE' |
772 | |
773 +===============================================================================*/
774
775 PROCEDURE Validate_Reversal_Reason ( p_reversal_reason IN VARCHAR2)
776 IS
777 l_reversal_reason_valid VARCHAR2(1);
778 BEGIN
779
780 IF PG_DEBUG in ('Y', 'C') THEN
781 arp_util.debug('AR_BILLS_MAINTAIN_VAL_LIB_PVT.Validate_Reversal_Reason()+');
782 END IF;
783
784 SELECT 'Y'
785 INTO l_reversal_reason_valid
786 FROM ar_lookups
787 WHERE lookup_type = 'CKAJST_REASON'
788 and enabled_flag = 'Y'
789 and lookup_code = p_reversal_reason;
790
791 IF PG_DEBUG in ('Y', 'C') THEN
792 arp_util.debug('AR_BILLS_MAINTAIN_VAL_LIB_PVT.Validate_Reversal_Reason()-');
793 END IF;
794
795 EXCEPTION
796 WHEN NO_DATA_FOUND THEN
797 IF PG_DEBUG in ('Y', 'C') THEN
798 arp_util.debug('>>>>>>>>>> EXCEPTION : AR_BILLS_MAINTAIN_VAL_LIB_PVT.Validate_Reversal_Reason () ');
799 arp_util.debug ('Validate_Reversal_Reason: ' || '>>>>>>>>>> The reversal reason is invalid');
800 END IF;
801 FND_MESSAGE.SET_NAME('AR','AR_BR_INVALID_REVERSAL_REASON');
802 app_exception.raise_exception;
803
804 WHEN Others THEN
805 IF PG_DEBUG in ('Y', 'C') THEN
806 arp_util.debug('>>>>>>>>>> EXCEPTION : AR_BILLS_MAINTAIN_VAL_LIB_PVT.Validate_Reversal_Reason () ');
807 arp_util.debug('Validate_Reversal_Reason: ' || 'p_reversal_reason : ' || p_reversal_reason);
808 END IF;
809 RAISE;
810 END Validate_Reversal_Reason;
811
812
813
814 /*==============================================================================+
815 | PROCEDURE |
816 | Validate_Complete_BR |
817 | |
818 | DESCRIPTION |
819 | Validates the BR before completion |
820 | - The GL Date must be in an open or future period |
821 | - All transactions must have the same currency as the BR Header |
822 | - All transactions must have the same exchange rate |
823 | - The total of the assignments must match the BR Total amount |
824 | |
825 +==============================================================================*/
826
827
828 PROCEDURE Validate_Complete_BR (
829 p_trx_rec IN OUT NOCOPY ra_customer_trx%ROWTYPE ,
830 p_gl_date IN DATE )
831 IS
832
833 BEGIN
834
835 IF PG_DEBUG in ('Y', 'C') THEN
836 arp_util.debug('AR_BILLS_MAINTAIN_VAL_PVT.Validate_Complete_BR()+');
837 END IF;
838
839
840 -- Validate GL Date
841
842 AR_BILLS_CREATION_VAL_PVT.Validate_GL_Date (p_gl_date);
843
844
845 -- Validate the assignments
846
847 Validate_Assignment (p_trx_rec);
848
849 IF PG_DEBUG in ('Y', 'C') THEN
850 arp_util.debug('AR_BILLS_MAINTAIN_VAL_PVT.Validate_Complete_BR()-');
851 END IF;
852
853 EXCEPTION
854 WHEN Others THEN
855 IF PG_DEBUG in ('Y', 'C') THEN
856 arp_util.debug('>>>>>>>>>> EXCEPTION : AR_BILLS_MAINTAIN_VAL_PVT.Validate_Complete_BR () ');
857 END IF;
858 RAISE;
859
860 END Validate_Complete_BR;
861
862
863 /*==============================================================================+
864 | PROCEDURE |
865 | Validate_Accept_BR |
866 | |
867 | DESCRIPTION |
868 | Validates the acceptance date and acceptance GL Date |
869 | |
870 +==============================================================================*/
871
872
873 PROCEDURE Validate_Accept_BR (
874 p_trx_rec IN ra_customer_trx%ROWTYPE,
875 p_trh_rec IN ar_transaction_history%ROWTYPE)
876 IS
877
878 BEGIN
879
880 IF PG_DEBUG in ('Y', 'C') THEN
881 arp_util.debug('AR_BILLS_MAINTAIN_VAL_PVT.Validate_Accept_BR()+');
882 END IF;
883
884
885 /*--------------------------------------+
886 | The Acceptance GL Date must not be |
887 | prior to the Issue Date |
888 +---------------------------------------*/
889
890 IF (p_trh_rec.gl_date < p_trx_rec.trx_date)
891 THEN
892 IF PG_DEBUG in ('Y', 'C') THEN
893 arp_util.debug('Validate_Accept_BR: ' || '>>>>>>>>>> Acceptance GL Date must not be prior to the Issue Date');
894 arp_util.debug('Validate_Accept_BR: ' || 'Acceptance GL Date : ' || p_trh_rec.gl_date);
895 arp_util.debug('Validate_Accept_BR: ' || 'Issue Date : ' || p_trx_rec.trx_date);
896 END IF;
897 FND_MESSAGE.set_name ( 'AR', 'AR_BR_INVALID_ACCEPT_GL_DATE' );
898 app_exception.raise_exception;
899 END IF;
900
901
902 /*--------------------------------------+
903 | The Acceptance Date must not be |
904 | prior to the Issue Date |
905 +---------------------------------------*/
906
907 IF (p_trh_rec.trx_date < p_trx_rec.trx_date)
908 THEN
909 IF PG_DEBUG in ('Y', 'C') THEN
910 arp_util.debug('Validate_Accept_BR: ' || '>>>>>>>>>> Acceptance Date must not be prior to the Issue Date');
911 arp_util.debug('Validate_Accept_BR: ' || 'Acceptance Date : ' || p_trh_rec.trx_date);
912 arp_util.debug('Validate_Accept_BR: ' || 'Issue Date : ' || p_trx_rec.trx_date);
913 END IF;
914 FND_MESSAGE.set_name ( 'AR', 'AR_BR_INVALID_ACCEPT_DATE' );
915 app_exception.raise_exception;
916 END IF;
917
918
919 IF PG_DEBUG in ('Y', 'C') THEN
920 arp_util.debug('AR_BILLS_MAINTAIN_VAL_PVT.Validate_Accept_BR()-');
921 END IF;
922
923 EXCEPTION
924 WHEN Others THEN
925 IF PG_DEBUG in ('Y', 'C') THEN
926 arp_util.debug('>>>>>>>>>> EXCEPTION : AR_BILLS_MAINTAIN_VAL_PVT.Validate_Accept_BR () ');
927 END IF;
928 RAISE;
929
930 END Validate_Accept_BR;
931
932
933
934 /*==============================================================================+
935 | PROCEDURE |
936 | Validate_Cancel_BR |
937 | |
938 | DESCRIPTION |
939 | Validates that the exchanged transactions have not been purged |
940 | |
941 +==============================================================================*/
942
943
944 PROCEDURE Validate_Cancel_BR (p_customer_trx_id IN ra_customer_trx.customer_trx_id%TYPE)
945 IS
946
947 BEGIN
948
949 IF PG_DEBUG in ('Y', 'C') THEN
950 arp_util.debug('AR_BILLS_MAINTAIN_VAL_PVT.Validate_Cancel_BR()+');
951 END IF;
952
953 /*----------------------------------------------+
954 | Validate that the exchanged transactions |
955 | have not been purged |
956 +-----------------------------------------------*/
957
958 Validate_Assignment_Exist (p_customer_trx_id);
959
960
961 IF PG_DEBUG in ('Y', 'C') THEN
962 arp_util.debug('AR_BILLS_MAINTAIN_VAL_PVT.Validate_Cancel_BR()-');
963 END IF;
964
965 EXCEPTION
966 WHEN Others THEN
967 IF PG_DEBUG in ('Y', 'C') THEN
968 arp_util.debug('>>>>>>>>>> EXCEPTION : AR_BILLS_MAINTAIN_VAL_PVT.Validate_Cancel_BR () ');
969 END IF;
970 RAISE;
971
972 END Validate_Cancel_BR;
973
974
975 /*==============================================================================+
976 | PROCEDURE |
977 | Validate_Unpaid_BR |
978 | |
979 | DESCRIPTION |
980 | Validates data before a BR is unpaid |
981 | |
982 +==============================================================================*/
983
984
985 PROCEDURE Validate_Unpaid_BR (p_trh_rec IN ar_transaction_history%ROWTYPE ,
986 p_unpaid_reason IN VARCHAR2 )
987 IS
988
989 l_batch_rec AR_BATCHES%ROWTYPE;
990 l_amount_applied NUMBER;
991 l_trx_rec ra_customer_trx%ROWTYPE;
992
993 BEGIN
994
995 IF PG_DEBUG in ('Y', 'C') THEN
996 arp_util.debug('AR_BILLS_MAINTAIN_VAL_PVT.Validate_Unpaid_BR()+');
997 END IF;
998
999
1000 -- Validate the Reversal Reason Category
1001
1002 IF (p_unpaid_reason IS NOT NULL)
1003 THEN
1004 Validate_Reversal_Reason (p_unpaid_reason);
1005 ELSE
1006 IF (p_trh_rec.status = C_MATURED_PEND_RISK_ELIM) or (p_trh_rec.event = C_CLOSED)
1007 THEN
1008 IF PG_DEBUG in ('Y', 'C') THEN
1009 arp_util.debug ('Validate_Unpaid_BR: ' || '>>>>>>>>>> The Unpaid reason is missing');
1010 END IF;
1011 FND_MESSAGE.SET_NAME ('AR', 'AR_BR_UNPAID_REASON_NULL');
1012 app_exception.raise_exception;
1013 END IF;
1014 END IF;
1015
1016 IF PG_DEBUG in ('Y', 'C') THEN
1017 arp_util.debug('AR_BILLS_MAINTAIN_VAL_PVT.Validate_Unpaid_BR()-');
1018 END IF;
1019
1020 EXCEPTION
1021 WHEN Others THEN
1022 IF PG_DEBUG in ('Y', 'C') THEN
1023 arp_util.debug('>>>>>>>>>> EXCEPTION : AR_BILLS_MAINTAIN_VAL_PVT.Validate_Unpaid_BR () ');
1024 END IF;
1025 RAISE;
1026
1027 END Validate_Unpaid_BR;
1028
1029
1030 /*==============================================================================+
1031 | PROCEDURE |
1032 | Validate_Action_Dates |
1033 | |
1034 | DESCRIPTION |
1035 | Validates the coherence of the trx_date and gl_date of the action, |
1036 | compared with the transaction history record. |
1037 | |
1038 +==============================================================================*/
1039
1040
1041 PROCEDURE Validate_Action_Dates ( p_trx_date IN DATE ,
1042 p_gl_date IN DATE ,
1043 p_trh_rec IN ar_transaction_history%ROWTYPE ,
1044 p_action IN VARCHAR2 )
1045
1046 IS
1047
1048 BEGIN
1049
1050 IF PG_DEBUG in ('Y', 'C') THEN
1051 arp_util.debug('AR_BILLS_MAINTAIN_VAL_PVT.Validate_Action_Dates()+');
1052 END IF;
1053
1054
1055 /*--------------------------------------+
1056 | The Trx Date of the action must be |
1057 | equal or later than the Trx Date |
1058 | in the current transaction history |
1059 | record. |
1060 +---------------------------------------*/
1061
1062 IF (p_trx_date < p_trh_rec.trx_date)
1063 THEN
1064 IF PG_DEBUG in ('Y', 'C') THEN
1065 arp_util.debug('Validate_Action_Dates: ' || '>>>>>>>>>> The ' || p_action || ' Date ' || p_trx_date || ' must not be prior to ' || p_trh_rec.trx_date);
1066 END IF;
1067 FND_MESSAGE.set_name ( 'AR', 'AR_BR_INVALID_TRX_DATE' );
1068 FND_MESSAGE.set_token ( 'ACTION' , p_action);
1069 FND_MESSAGE.set_token ( 'NEW_TRX_DATE', to_char(p_trx_date));
1070 FND_MESSAGE.set_token ( 'OLD_TRX_DATE', to_char(p_trh_rec.trx_date));
1071 app_exception.raise_exception;
1072 END IF;
1073
1074
1075
1076 /*--------------------------------------+
1077 | The GL Date of the action must be |
1078 | equal or later than the GL Date |
1079 | in the current transaction history |
1080 | record. |
1081 +---------------------------------------*/
1082
1083 IF (p_gl_date IS NOT NULL)
1084 THEN
1085
1086 IF (p_gl_date < nvl(p_trh_rec.gl_date, p_gl_date))
1087 THEN
1088 IF PG_DEBUG in ('Y', 'C') THEN
1089 arp_util.debug('Validate_Action_Dates: ' || '>>>>>>>>>> The ' || p_action || ' GL Date ' || p_gl_date || ' must not be prior to ' || p_trh_rec.gl_date);
1090 END IF;
1091 FND_MESSAGE.set_name( 'AR', 'AR_BR_INVALID_GL_DATE' );
1092 -- Bug 1865580: BR Message revision 7: only pass old_gl_date
1093 -- as token
1094 FND_MESSAGE.set_token( 'OLD_GL_DATE',
1095 to_char(p_trh_rec.gl_date));
1096 app_exception.raise_exception;
1097 END IF;
1098 END IF;
1099
1100 IF PG_DEBUG in ('Y', 'C') THEN
1101 arp_util.debug('AR_BILLS_MAINTAIN_VAL_PVT.Validate_Action_Dates()-');
1102 END IF;
1103
1104 EXCEPTION
1105 WHEN Others THEN
1106 IF PG_DEBUG in ('Y', 'C') THEN
1107 arp_util.debug('>>>>>>>>>> EXCEPTION : AR_BILLS_MAINTAIN_VAL_PVT.Validate_Action_Dates () ');
1108 END IF;
1109 RAISE;
1110
1111 END Validate_Action_Dates;
1112
1113
1114 /*==============================================================================+
1115 | PROCEDURE |
1116 | Validate_Remittance_Dates |
1117 | |
1118 | DESCRIPTION |
1119 | Validates the remittance batch date and gl_date, before selecting a BR |
1120 | for the remittance batch |
1121 | |
1122 +==============================================================================*/
1123
1124
1125 PROCEDURE Validate_Remittance_Dates ( p_batch_rec IN ar_batches%ROWTYPE ,
1126 p_trh_rec IN ar_transaction_history%ROWTYPE ,
1127 p_trx_number IN ra_customer_trx.trx_number%TYPE )
1128
1129 IS
1130
1131 BEGIN
1132
1133 IF PG_DEBUG in ('Y', 'C') THEN
1134 arp_util.debug('AR_BILLS_MAINTAIN_VAL_PVT.Validate_Remittance_Dates()+');
1135 END IF;
1136
1137
1138 /*----------------------------------------------+
1139 | The remittance batch date must not be prior |
1140 | to the Trx Date in the Current Transaction |
1141 | History Record of the BR selected |
1142 +-----------------------------------------------*/
1143
1144 IF trunc(p_batch_rec.batch_date) < p_trh_rec.trx_date
1145 THEN
1146 IF PG_DEBUG in ('Y', 'C') THEN
1147 arp_util.debug('Validate_Remittance_Dates: ' || '>>>>>>>>>> The BR ' || p_trx_number || ' cannot be selected in this remittance batch');
1148 arp_util.debug('Validate_Remittance_Dates: ' || ' To include this BR, the batch date should not be prior to ' || p_trh_rec.trx_date);
1149 END IF;
1150 FND_MESSAGE.set_name ( 'AR', 'AR_BR_INVALID_REMIT_DATE' );
1151 FND_MESSAGE.set_token ( 'BRNUM' , p_trx_number);
1152 FND_MESSAGE.set_token ( 'TRX_DATE', to_char(p_trh_rec.trx_date));
1153 app_exception.raise_exception;
1154 END IF;
1155
1156
1157
1158 /*----------------------------------------------+
1159 | The remittance batch GL date must not be prior|
1160 | to the GL Date in the Current Transaction |
1161 | History Record of the BR selected |
1162 +-----------------------------------------------*/
1163
1164 IF trunc(p_batch_rec.gl_date) < nvl(p_trh_rec.gl_date, p_batch_rec.gl_date)
1165 THEN
1166 IF PG_DEBUG in ('Y', 'C') THEN
1167 arp_util.debug('Validate_Remittance_Dates: ' || '>>>>>>>>>> The BR ' || p_trx_number || ' cannot be selected in this remittance batch');
1168 arp_util.debug('Validate_Remittance_Dates: ' || ' To include this BR, the batch GL date should not be prior to ' || p_trh_rec.gl_date);
1169 END IF;
1170 FND_MESSAGE.set_name ( 'AR', 'AR_BR_INVALID_REMIT_GL_DATE' );
1171 FND_MESSAGE.set_token ( 'BRNUM' , p_trx_number);
1172 FND_MESSAGE.set_token ( 'GL_DATE', to_char(p_trh_rec.gl_date));
1173 app_exception.raise_exception;
1174 END IF;
1175
1176 IF PG_DEBUG in ('Y', 'C') THEN
1177 arp_util.debug('AR_BILLS_MAINTAIN_VAL_PVT.Validate_Remittance_Dates()-');
1178 END IF;
1179
1180 EXCEPTION
1181 WHEN Others THEN
1182 IF PG_DEBUG in ('Y', 'C') THEN
1183 arp_util.debug('>>>>>>>>>> EXCEPTION : AR_BILLS_MAINTAIN_VAL_PVT.Validate_Remittance_Dates () ');
1184 END IF;
1185 RAISE;
1186
1187 END Validate_Remittance_Dates;
1188
1189
1190 END AR_BILLS_MAINTAIN_VAL_PVT;