[Home] [Help]
PACKAGE BODY: APPS.AR_BILLS_CREATION_LIB_PVT
Source
1 PACKAGE BODY AR_BILLS_CREATION_LIB_PVT AS
2 /* $Header: ARBRCRLB.pls 120.6 2005/11/11 12:33:42 sgnagara ship $ */
3
4 G_PKG_NAME CONSTANT VARCHAR2(30) := 'AR_BILLS_CREATION_LIB_PVT';
8
5
6
7 API_EXCEPTION EXCEPTION;
9 /*==============================================================================+
10 | PROCEDURE |
11 | Default_GL_Date |
12 | |
13 | DESCRIPTION |
14 | Validates the GL Date if passed to the procedure or defaults it |
15 | |
16 +==============================================================================*/
17
18
19 PG_DEBUG varchar2(1) := NVL(FND_PROFILE.value('AFLOG_ENABLED'), 'N');
20
21 PROCEDURE Default_GL_date(p_entered_date IN DATE ,
22 p_gl_date OUT NOCOPY DATE ,
23 p_return_status OUT NOCOPY VARCHAR2 ) IS
24
25 l_error_message VARCHAR2(128);
26 l_defaulting_rule_used VARCHAR2(50);
27 l_default_gl_date DATE;
28
29 BEGIN
30 IF PG_DEBUG in ('Y', 'C') THEN
31 arp_util.debug('AR_BILLS_CREATION_LIB_PVT.Default_gl_date ()+');
32 END IF;
33
34 p_return_status := FND_API.G_RET_STS_SUCCESS;
35
36 IF (arp_util.validate_and_default_gl_date(
37 p_entered_date ,
38 NULL ,
39 NULL ,
40 NULL ,
41 NULL ,
42 NULL ,
43 NULL ,
44 NULL ,
45 'N' ,
46 NULL ,
47 arp_global.set_of_books_id ,
48 222 ,
49 l_default_gl_date ,
50 l_defaulting_rule_used ,
51 l_error_message) = TRUE )
52 THEN
53 p_gl_date := l_default_gl_date;
54 ELSE
55 -- Raise error message if failure in defaulting the gl_date
56 -- this is the only place in the defaulting routine where we raise
57 -- error message
58
59 p_return_status := FND_API.G_RET_STS_ERROR;
60 FND_MESSAGE.SET_NAME('AR', 'GENERIC_MESSAGE');
61 FND_MESSAGE.SET_TOKEN('GENERIC_TEXT', l_error_message);
62 app_exception.raise_exception;
63
64 END IF;
65
66 IF PG_DEBUG in ('Y', 'C') THEN
67 arp_util.debug('AR_BILLS_CREATION_LIB_PVT.Default_gl_date ()-');
68 END IF;
69
70 EXCEPTION
71 WHEN OTHERS THEN
72 IF PG_DEBUG in ('Y', 'C') THEN
73 arp_util.debug('>>>>>>>>>> EXCEPTION : AR_BILLS_CREATION_LIB_PVT.default_gl_date () ');
74 arp_util.debug('Default_GL_date: ' || ' p_entered_date = ' || p_entered_date);
75 END IF;
76 RAISE;
77
78 END default_gl_date;
79
80
81
82
83 /*==============================================================================+
84 | PROCEDURE |
85 | Default_Drawee_Location |
86 | |
87 | DESCRIPTION |
88 | Defaults the Drawee Location : Primary Site for the BR Drawee Purpose |
89 | |
90 +==============================================================================*/
91
92 PROCEDURE Default_Drawee_Location (p_drawee_id IN NUMBER ,
93 p_drawee_site_use_id OUT NOCOPY NUMBER ) IS
94
95 l_drawee_site_use_id NUMBER;
96
97 BEGIN
98 IF PG_DEBUG in ('Y', 'C') THEN
99 arp_util.debug('AR_BILLS_CREATION_LIB_PVT.Default_Drawee_Location ()+');
100 END IF;
101
102 /* modified for tca uptake */
103 SELECT site_uses.SITE_USE_ID
104 INTO p_drawee_site_use_id
105 FROM hz_cust_site_uses site_uses,
106 hz_cust_acct_sites acct_site
107 WHERE acct_site.cust_account_id = p_drawee_id
108 AND acct_site.cust_acct_site_id = site_uses.cust_acct_site_id
109 AND site_uses.site_use_code = 'DRAWEE'
110 AND site_uses.status = 'A'
111 AND site_uses.primary_flag = 'Y';
112
113 IF PG_DEBUG in ('Y', 'C') THEN
114 arp_util.debug('AR_BILLS_CREATION_LIB_PVT.Default_Drawee_Location ()-');
115 END IF;
116
117 EXCEPTION
118 WHEN NO_DATA_FOUND THEN
119 IF PG_DEBUG in ('Y', 'C') THEN
120 arp_util.debug ('Default_Drawee_Location: ' || '>>>>>>>>>> No Drawee Location could be Defaulted');
121 arp_util.debug ('Default_Drawee_Location: ' || '>>>>>>>>>> The Drawee Location is Mandatory');
122 END IF;
123 FND_MESSAGE.SET_NAME ('AR', 'AR_BR_DRAWEE_SITE_NULL');
124 app_exception.raise_exception;
125
126 WHEN TOO_MANY_ROWS THEN
127 IF PG_DEBUG in ('Y', 'C') THEN
128 arp_util.debug('>>>>> Default_Drawee_Location : Too Many rows');
129 arp_util.debug('Default_Drawee_Location: ' || ' p_drawee_id = ' || p_drawee_id );
130 END IF;
131
132 WHEN OTHERS THEN
133 IF PG_DEBUG in ('Y', 'C') THEN
134 arp_util.debug('>>>>>>>>>> EXCEPTION : Default_Drawee_Location () ');
135 arp_util.debug('Default_Drawee_Location: ' || ' p_drawee_id = ' || p_drawee_id);
136 END IF;
137 RAISE;
138
139 END Default_Drawee_Location;
140
141
142
143 /*==============================================================================+
144 | PROCEDURE |
145 | Default_Drawee_Contact |
146 | |
147 | DESCRIPTION |
148 | Defaults the Drawee Contact : Primary Contact assigned to the site or |
149 | the client |
150 | |
151 +==============================================================================*/
152
153 PROCEDURE Default_Drawee_Contact (p_drawee_id IN NUMBER ,
154 p_drawee_site_use_id IN NUMBER ,
155 p_drawee_contact_id OUT NOCOPY NUMBER ) IS
156
157
158 BEGIN
159 IF PG_DEBUG in ('Y', 'C') THEN
160 arp_util.debug('AR_BILLS_CREATION_LIB_PVT.Default_Drawee_Contact ()+');
161 END IF;
162
163 /* modified for tca uptake */
164 /* fix bug 1883538: replace current role state with status column */
165 SELECT acct_role.cust_account_role_id
166 INTO p_drawee_contact_id
167 FROM hz_cust_account_roles acct_role,
168 hz_role_responsibility role_res,
169 HZ_CUST_SITE_USES site_uses
170 WHERE acct_role.cust_account_id = p_drawee_id
171 AND nvl(acct_role.status, 'I') = 'A'
172 AND acct_role.cust_acct_site_id = site_uses.cust_acct_site_id
173 AND site_uses.site_use_id = p_drawee_site_use_id
174 AND acct_role.cust_account_role_id = role_res.cust_account_role_id
175 AND role_res.responsibility_type = 'BILL_TO'
176 AND role_res.primary_flag = 'Y';
177
178 IF PG_DEBUG in ('Y', 'C') THEN
179 arp_util.debug('AR_BILLS_CREATION_LIB_PVT.Default_Drawee_Contact ()-');
180 END IF;
181
182 EXCEPTION
183 WHEN NO_DATA_FOUND THEN
184 IF PG_DEBUG in ('Y', 'C') THEN
185 arp_util.debug('Default_Drawee_Contact: ' || '>>>>> No Drawee Contact could be defaulted');
186 arp_util.debug('Default_Drawee_Contact: ' || ' p_drawee_id = ' || p_drawee_id );
187 arp_util.debug('Default_Drawee_Contact: ' || ' p_drawee_site_use_id = ' || p_drawee_site_use_id);
188 END IF;
189
190 WHEN TOO_MANY_ROWS THEN
191 IF PG_DEBUG in ('Y', 'C') THEN
192 arp_util.debug('>>>>> Default_Drawee_Contact : Too Many rows');
193 arp_util.debug('Default_Drawee_Contact: ' || ' p_drawee_id = ' || p_drawee_id );
194 arp_util.debug('Default_Drawee_Contact: ' || ' p_drawee_site_use_id = ' || p_drawee_site_use_id);
195 END IF;
196
197 WHEN OTHERS THEN
198 IF PG_DEBUG in ('Y', 'C') THEN
199 arp_util.debug('>>>>>>>>>> EXCEPTION : AR_BILLS_CREATION_LIB_PVT.Default_Drawee_Contact () ');
200 arp_util.debug('Default_Drawee_Contact: ' || ' p_drawee_id = ' || p_drawee_id );
201 arp_util.debug('Default_Drawee_Contact: ' || ' p_drawee_site_use_id = ' || p_drawee_site_use_id);
202 END IF;
203 RAISE;
204
205 END Default_Drawee_Contact;
206
207
208
209 /*==============================================================================+
210 | PROCEDURE |
211 | Default_Printing_Option |
212 | |
213 | DESCRIPTION |
214 | Defaults the Printing Option from the Transaction Type |
215 | |
216 +==============================================================================*/
217
218 PROCEDURE Default_Printing_Option (p_cust_trx_type_id IN NUMBER ,
219 p_printing_option OUT NOCOPY VARCHAR2 ) IS
220
221
222 BEGIN
223 IF PG_DEBUG in ('Y', 'C') THEN
224 arp_util.debug('AR_BILLS_CREATION_LIB_PVT.Default_Printing_Option ()+');
225 END IF;
226
227 SELECT default_printing_option
228 INTO p_printing_option
229 FROM RA_CUST_TRX_TYPES
230 WHERE cust_trx_type_id = p_cust_trx_type_id;
231
232 IF PG_DEBUG in ('Y', 'C') THEN
233 arp_util.debug('AR_BILLS_CREATION_LIB_PVT.Default_Printing_Option ()-');
234 END IF;
235
236 EXCEPTION
237 WHEN NO_DATA_FOUND THEN
238 IF PG_DEBUG in ('Y', 'C') THEN
239 arp_util.debug('>>>>>>>>>> EXCEPTION : AR_BILLS_CREATION_LIB_PVT.Default_Printing_Option () () ');
240 arp_util.debug('Default_Printing_Option: ' || '>>>>>>>>>> Invalid Transaction Type');
241 arp_util.debug('Default_Printing_Option: ' || ' p_cust_trx_type_id = ' || p_cust_trx_type_id);
242 END IF;
243 FND_MESSAGE.SET_NAME ('AR', 'AR_BR_INVALID_TRX_TYPE');
244 app_exception.raise_exception;
245
246 WHEN OTHERS THEN
247 IF PG_DEBUG in ('Y', 'C') THEN
248 arp_util.debug('>>>>>>>>>> EXCEPTION : AR_BILLS_CREATION_LIB_PVT.Default_Printing_Option () ');
249 arp_util.debug('Default_Printing_Option: ' || ' p_cust_trx_type_id = ' || p_cust_trx_type_id);
250 END IF;
251 RAISE;
252
253 END Default_Printing_Option;
254
255
259 | |
256 /*==============================================================================+
257 | PROCEDURE |
258 | Default_Drawee_Account |
260 | DESCRIPTION |
261 | Defaults the Drawee Bank Account ID : |
262 | Drawee's primary bank account for the the currency |
263 | |
264 +==============================================================================*/
265
266 PROCEDURE Default_Drawee_Account ( p_drawee_id IN NUMBER ,
267 p_invoice_currency_code IN VARCHAR2 ,
268 p_drawee_bank_account_id OUT NOCOPY NUMBER ) IS
269
270
271 BEGIN
272 /* PAYMENT_UPTAKE */
273 IF PG_DEBUG in ('Y', 'C') THEN
274 arp_util.debug('AR_BILLS_CREATION_LIB_PVT.Default_Drawee_Account ()+');
275 arp_util.debug('Default_Drawee_Account: ' || '>>>>> No Drawee Account could be defaulted');
276 arp_util.debug('AR_BILLS_CREATION_LIB_PVT.Default_Drawee_Account ()-');
277 END IF;
278
279 END Default_Drawee_Account;
280
281
282
283 /*==============================================================================+
284 | PROCEDURE |
285 | Get_Payment_Schedule_Id |
286 | |
287 | DESCRIPTION |
288 | Returns the payment schedule ID of the BR, identified by the |
289 | p_customer_trx_id parameter |
290 | |
291 +==============================================================================*/
292
293
294 PROCEDURE Get_Payment_Schedule_ID (
295 p_customer_trx_id IN ra_customer_trx.customer_trx_id%TYPE ,
296 p_payment_schedule_id OUT NOCOPY ar_payment_schedules.payment_schedule_id%TYPE )
297 IS
298
299 BEGIN
300
301 IF PG_DEBUG in ('Y', 'C') THEN
302 arp_util.debug('AR_BILLS_CREATION_LIB_PVT.Get_Payment_Schedule_Id()+ ');
303 END IF;
304
305 SELECT payment_schedule_id
306 INTO p_payment_schedule_id
307 FROM ar_payment_schedules
308 WHERE customer_trx_id = p_customer_trx_id;
309
310 IF PG_DEBUG in ('Y', 'C') THEN
311 arp_util.debug('Get_Payment_Schedule_ID: ' || 'Payment Schedule Id : ' || p_payment_schedule_id);
312 arp_util.debug('AR_BILLS_CREATION_LIB_PVT.Get_Payment_Schedule_Id()- ');
313 END IF;
314
315 EXCEPTION
316 WHEN NO_DATA_FOUND THEN
317 IF PG_DEBUG in ('Y', 'C') THEN
321
318 arp_util.debug('Get_Payment_Schedule_ID: ' || '>>>>> No Payment Schedule for the BR could found');
319 arp_util.debug('Get_Payment_Schedule_ID: ' || ' p_customer_trx_id = ' || p_customer_trx_id);
320 END IF;
322 WHEN OTHERS THEN
323 IF PG_DEBUG in ('Y', 'C') THEN
324 arp_util.debug('>>>>>>>>>> EXCEPTION : AR_BILLS_CREATION_LIB_PVT.Get_Payment_Schedule_Id () ');
325 arp_util.debug('Get_Payment_Schedule_ID: ' || ' p_customer_trx_id = ' || p_customer_trx_id);
326 END IF;
327 RAISE;
328
329 END Get_Payment_Schedule_Id;
330
331
332
333 /*==============================================================================+
334 | PROCEDURE |
335 | Check_Header_Mandatory_Data |
336 | |
337 | DESCRIPTION |
338 | Check that mandatory parameters are passed to the API |
339 | |
340 +==============================================================================*/
341
342
343
344 PROCEDURE Check_Header_Mandatory_Data ( p_trx_rec IN ra_customer_trx%ROWTYPE)
345 IS
346 BEGIN
347
348 IF PG_DEBUG in ('Y', 'C') THEN
349 arp_util.debug('AR_BILLS_CREATION_LIB_PVT.Check_Header_Mandatory_Data ()+ ');
350 END IF;
351
352 IF (p_trx_rec.batch_source_id IS NULL) THEN
353 IF PG_DEBUG in ('Y', 'C') THEN
354 arp_util.debug('Check_Header_Mandatory_Data: ' || '>>>>>>>>>> Batch Source Missing');
355 END IF;
356 FND_MESSAGE.SET_NAME ('AR', 'AR_BR_BATCH_SOURCE_NULL');
357 app_exception.raise_exception;
358 END IF;
359
360
361 IF (p_trx_rec.cust_trx_type_id IS NULL) THEN
362 IF PG_DEBUG in ('Y', 'C') THEN
363 arp_util.debug('Check_Header_Mandatory_Data: ' || '>>>>>>>>>> Transaction Type Missing');
364 END IF;
365 FND_MESSAGE.SET_NAME ('AR', 'AR_BR_TRX_TYPE_NULL');
366 app_exception.raise_exception;
367 END IF;
368
369
373 END IF;
370 IF (p_trx_rec.invoice_currency_code IS NULL) THEN
371 IF PG_DEBUG in ('Y', 'C') THEN
372 arp_util.debug('Check_Header_Mandatory_Data: ' || '>>>>>>>>>> Currency Code Missing');
374 FND_MESSAGE.SET_NAME ('AR', 'AR_BR_CURRENCY_NULL');
375 app_exception.raise_exception;
376 END IF;
377
378
379 IF (p_trx_rec.drawee_id IS NULL) THEN
380 IF PG_DEBUG in ('Y', 'C') THEN
381 arp_util.debug('Check_Header_Mandatory_Data: ' || '>>>>>>>>>> Drawee Id Missing');
382 END IF;
383 FND_MESSAGE.SET_NAME ('AR', 'AR_BR_DRAWEE_ID_NULL');
384 app_exception.raise_exception;
385 END IF;
386
387 IF (p_trx_rec.legal_entity_id IS NULL) THEN
388 IF PG_DEBUG in ('Y', 'C') THEN
389 arp_util.debug('Check_Header_Mandatory_Data: ' || '>>>>>>>>>> Legal Entity Id Missing');
390 END IF;
391 FND_MESSAGE.SET_NAME ('AR', 'AR_LE_NAME_MANDATORY');
392 app_exception.raise_exception;
393 END IF;
394
395 IF PG_DEBUG in ('Y', 'C') THEN
396 arp_util.debug('AR_BILLS_CREATION_LIB_PVT.Check_Header_Mandatory_Data ()- ');
397 END IF;
398
399 EXCEPTION
400 WHEN OTHERS THEN
401 IF PG_DEBUG in ('Y', 'C') THEN
402 arp_util.debug('>>>>>>>>>> EXCEPTION : AR_BILLS_CREATION_LIB_PVT.Check_Header_Mandatory_Data () ');
403 END IF;
404 RAISE;
405
406 END Check_Header_Mandatory_Data;
407
408
409 /*==============================================================================+
410 | PROCEDURE |
411 | Validate_Desc_Flexfield |
412 | |
413 | DESCRIPTION |
414 | Validate and Default the flexfields |
415 | |
416 +==============================================================================*/
417
418
419 PROCEDURE Validate_Desc_Flexfield ( p_attribute_category IN OUT NOCOPY VARCHAR2 ,
420 p_attribute1 IN OUT NOCOPY VARCHAR2 ,
421 p_attribute2 IN OUT NOCOPY VARCHAR2 ,
422 p_attribute3 IN OUT NOCOPY VARCHAR2 ,
423 p_attribute4 IN OUT NOCOPY VARCHAR2 ,
424 p_attribute5 IN OUT NOCOPY VARCHAR2 ,
425 p_attribute6 IN OUT NOCOPY VARCHAR2 ,
426 p_attribute7 IN OUT NOCOPY VARCHAR2 ,
427 p_attribute8 IN OUT NOCOPY VARCHAR2 ,
428 p_attribute9 IN OUT NOCOPY VARCHAR2 ,
429 p_attribute10 IN OUT NOCOPY VARCHAR2 ,
430 p_attribute11 IN OUT NOCOPY VARCHAR2 ,
431 p_attribute12 IN OUT NOCOPY VARCHAR2 ,
432 p_attribute13 IN OUT NOCOPY VARCHAR2 ,
433 p_attribute14 IN OUT NOCOPY VARCHAR2 ,
434 p_attribute15 IN OUT NOCOPY VARCHAR2 ,
435 p_desc_flex_name IN VARCHAR2 )
436 IS
437
438 l_flex_name fnd_descriptive_flexs.descriptive_flexfield_name%type;
439 l_count NUMBER;
440 l_col_name VARCHAR2(50);
441 p_desc_flex_rec arp_util.attribute_rec_type;
442 l_return_status VARCHAR2(1);
443
444
445 BEGIN
446
447 IF PG_DEBUG in ('Y', 'C') THEN
448 arp_util.debug('AR_BILLS_CREATION_LIB_PVT.Validate_Desc_Flexfield ()+');
449 END IF;
450
451 p_desc_flex_rec.attribute_category := p_attribute_category ;
452 p_desc_flex_rec.attribute1 := p_attribute1 ;
453 p_desc_flex_rec.attribute2 := p_attribute2 ;
454 p_desc_flex_rec.attribute3 := p_attribute3 ;
455 p_desc_flex_rec.attribute4 := p_attribute4 ;
456 p_desc_flex_rec.attribute5 := p_attribute5 ;
457 p_desc_flex_rec.attribute6 := p_attribute6 ;
458 p_desc_flex_rec.attribute7 := p_attribute7 ;
459 p_desc_flex_rec.attribute8 := p_attribute8 ;
460 p_desc_flex_rec.attribute9 := p_attribute9 ;
461 p_desc_flex_rec.attribute10 := p_attribute10 ;
462 p_desc_flex_rec.attribute11 := p_attribute11 ;
463 p_desc_flex_rec.attribute12 := p_attribute12 ;
464 p_desc_flex_rec.attribute13 := p_attribute13 ;
465 p_desc_flex_rec.attribute14 := p_attribute14 ;
466 p_desc_flex_rec.attribute15 := p_attribute15 ;
467
468 arp_util.Validate_Desc_Flexfield ( p_desc_flex_rec ,
469 p_desc_flex_name,
470 l_return_status );
471
472 IF ( l_return_status <> FND_API.G_RET_STS_SUCCESS)
473 THEN
474 IF PG_DEBUG in ('Y', 'C') THEN
478 FND_MESSAGE.SET_TOKEN ('DFF_NAME', p_desc_flex_name);
475 arp_util.debug ('Validate_Desc_Flexfield: ' || '>>>>>>>>>> Flexfield Invalid : ' || p_desc_flex_name);
476 END IF;
477 FND_MESSAGE.SET_NAME ('AR' , 'AR_RAPI_DESC_FLEX_INVALID');
479 app_exception.raise_exception;
480 END IF;
481
482 p_attribute_category := p_desc_flex_rec.attribute_category ;
483 p_attribute1 := p_desc_flex_rec.attribute1 ;
484 p_attribute2 := p_desc_flex_rec.attribute2 ;
485 p_attribute3 := p_desc_flex_rec.attribute3 ;
486 p_attribute4 := p_desc_flex_rec.attribute4 ;
487 p_attribute5 := p_desc_flex_rec.attribute5 ;
488 p_attribute6 := p_desc_flex_rec.attribute6 ;
489 p_attribute7 := p_desc_flex_rec.attribute7 ;
490 p_attribute8 := p_desc_flex_rec.attribute8 ;
491 p_attribute9 := p_desc_flex_rec.attribute9 ;
492 p_attribute10 := p_desc_flex_rec.attribute10 ;
493 p_attribute11 := p_desc_flex_rec.attribute11 ;
494 p_attribute12 := p_desc_flex_rec.attribute12 ;
495 p_attribute13 := p_desc_flex_rec.attribute13 ;
496 p_attribute14 := p_desc_flex_rec.attribute14 ;
497 p_attribute15 := p_desc_flex_rec.attribute15 ;
498
499 IF PG_DEBUG in ('Y', 'C') THEN
500 arp_util.debug('AR_BILLS_CREATION_LIB_PVT.Validate_Desc_Flexfield()-');
501 END IF;
502
503 EXCEPTION
504 WHEN OTHERS THEN
505 IF PG_DEBUG in ('Y', 'C') THEN
506 arp_util.debug('EXCEPTION: AR_BILLS_CREATION_LIB_PVT.Validate_Desc_Flexfield');
507 END IF;
508 RAISE;
509
510 END Validate_Desc_Flexfield;
511
512
513
514
515 /*==============================================================================+
516 | PROCEDURE |
517 | Default_Create_BR_Header |
518 | |
519 | DESCRIPTION |
520 | Defaults data in the BR Header |
521 | |
522 +==============================================================================*/
523
524
525 PROCEDURE Default_Create_BR_Header ( p_trx_rec IN OUT NOCOPY ra_customer_trx%ROWTYPE ,
526 p_gl_date IN OUT NOCOPY DATE )
527
528 IS
529 l_signed_flag VARCHAR2(1);
530 l_return_status VARCHAR2(1);
531
532 BEGIN
533
534 IF PG_DEBUG in ('Y', 'C') THEN
535 arp_util.debug('AR_BILLS_CREATION_LIB_PVT.Default_Create_BR_Header()+ ');
536 END IF;
537
538
539 Check_Header_Mandatory_Data (p_trx_rec);
540
541
542 /*-----------------------------------------------+
543 | Default the maturity date if NULL |
544 +-----------------------------------------------*/
545
546 IF (p_trx_rec.term_due_date IS NULL)
547 THEN
548 SELECT SYSDATE
549 INTO p_trx_rec.term_due_date
550 FROM dual;
551 END IF;
552
553
554 /*-----------------------------------------------+
555 | Default the Issue date if NULL |
556 +-----------------------------------------------*/
557
558 IF (p_trx_rec.trx_date IS NULL)
559 THEN
560 SELECT SYSDATE
561 INTO p_trx_rec.trx_date
562 FROM dual;
563 END IF;
564
565
566 /*-----------------------------------------------------------------------
567 Bug 1746385 : gl date was defaulting to sysdate when BR DID NOT
568 require acceptance, this was opposite of what it should have been
569 ie, If Bill requires acceptance, default the GL date to Sysdate
570 removed NOT before AR_BILLS_MAINTAIN_STATUS_PUB
571
575 defaults to Batch GL date regardless of whether the BR requires
572 Part 2 : since the GL date of a BR that requires acceptance will NOT
573 affect GL until it is actually accepted, the value that defaults in
574 is irrelevant, By commenting out NOCOPY the following IF clause, GL date
576 accpetance or not
577
578
579 IF AR_BILLS_MAINTAIN_STATUS_PUB.Is_Acceptance_Required(p_trx_rec.cust_trx_type_id)
580 THEN
581 Default_gl_date (sysdate, p_gl_date, l_return_status);
582 IF PG_DEBUG in ('Y', 'C') THEN
583 arp_util.debug('Default_Create_BR_Header: ' || 'l_default_gl_date_return_status : ' || l_return_status);
584 arp_util.debug('Default_Create_BR_Header: ' || 'GL Date defaulted : ' || p_gl_date);
585 END IF;
586 END IF;
587
588 ----------------------------------------------------------------------*/
589
590
591
592 /*-----------------------------------------------+
593 | Default the printing option |
594 +-----------------------------------------------*/
595
596 IF (p_trx_rec.printing_option IS NULL)
597 THEN
598 Default_Printing_Option (p_trx_rec.cust_trx_type_id,
599 p_trx_rec.printing_option );
600 END IF;
601
602
603 /*-----------------------------------------------+
604 | Default the Override Remittance Account Flag|
605 +-----------------------------------------------*/
606
607 IF (p_trx_rec.override_remit_account_flag IS NULL)
608 THEN
609 p_trx_rec.override_remit_account_flag := 'N';
610 END IF;
611
612
613
614 /*-----------------------------------------------+
615 | Default the drawee location, contact, |
616 | account for the auto creation program. |
617 +-----------------------------------------------*/
618
619 IF (p_trx_rec.created_from not in ('ARBRMAIN', 'ARBRMAIB'))
620 THEN
621
622 IF PG_DEBUG in ('Y', 'C') THEN
623 arp_util.debug('Default_Create_BR_Header: ' || 'Auto Creation Program Defaulting');
624 END IF;
625
626
627 /*----------------------------------------------+
628 | Default the drawee location |
629 +-----------------------------------------------*/
630
631 IF (p_trx_rec.drawee_site_use_id IS NULL)
632 THEN
633 Default_Drawee_Location (p_trx_rec.drawee_id, p_trx_rec.drawee_site_use_id);
634 END IF;
635
636
637 /*----------------------------------------------+
638 | Default the drawee contact id |
639 +-----------------------------------------------*/
640
641 IF (p_trx_rec.drawee_contact_id IS NULL)
642 THEN
643 Default_Drawee_Contact (p_trx_rec.drawee_id ,
644 p_trx_rec.drawee_site_use_id ,
645 p_trx_rec.drawee_contact_id );
646 END IF;
647
648
649 /*----------------------------------------------+
650 | Default the drawee account |
651 +-----------------------------------------------*/
652
653 /* bug 1808976 : the correct drawee_bank_account_id should have
654 been derived in ARBRTESB.pls procedure create_br, if at this
655 point it is still NULL, leave it NULL
656
657 IF (p_trx_rec.drawee_bank_account_id IS NULL)
658 THEN
659 Default_drawee_account ( p_trx_rec.drawee_id ,
660 p_trx_rec.invoice_currency_code,
661 p_trx_rec.drawee_bank_account_id);
662 END IF;
663
664 */
665
666 END IF;
667
668 -- 3999819 : flexfield validation should only be done when creating BR thru ARBRMAIN.fmb
669 -- for all other "automatic" methods of creating BR ie. batch/exchange from TRX WB,
670 -- desc flexfield validation is bypassed
671 IF (p_trx_rec.created_from = 'ARBRMAIN')
672 THEN
673
674 /*----------------------------------------------+
675 | Validate and default the flexfields |
676 +-----------------------------------------------*/
677
678 Validate_Desc_Flexfield ( p_trx_rec.attribute_category ,
679 p_trx_rec.attribute1 ,
680 p_trx_rec.attribute2 ,
681 p_trx_rec.attribute3 ,
682 p_trx_rec.attribute4 ,
683 p_trx_rec.attribute5 ,
684 p_trx_rec.attribute6 ,
685 p_trx_rec.attribute7 ,
686 p_trx_rec.attribute8 ,
687 p_trx_rec.attribute9 ,
688 p_trx_rec.attribute10 ,
689 p_trx_rec.attribute11 ,
690 p_trx_rec.attribute12 ,
691 p_trx_rec.attribute13 ,
692 p_trx_rec.attribute14 ,
693 p_trx_rec.attribute15 ,
694 'RA_CUSTOMER_TRX' );
695
696
697 END IF;
698
699
700 IF PG_DEBUG in ('Y', 'C') THEN
701 arp_util.debug('AR_BILLS_CREATION_LIB_PVT.Default_Create_BR_Header ()-');
702 END IF;
703
704 EXCEPTION
705 WHEN OTHERS THEN
706 IF PG_DEBUG in ('Y', 'C') THEN
707 arp_util.debug('>>>>>>>>>> EXCEPTION : AR_BILLS_CREATION_LIB_PVT.Default_Create_BR_Header () ');
708 END IF;
709 RAISE;
710
711
712 END Default_Create_BR_Header;
713
714
715
716 /*==============================================================================+
717 | PROCEDURE |
718 | Default_Update_BR_Header |
719 | |
720 | DESCRIPTION |
721 | Defaults data in the BR Header during Update |
722 | |
723 +==============================================================================*/
724
725
726 PROCEDURE Default_Update_BR_Header ( p_trx_rec IN OUT NOCOPY ra_customer_trx%ROWTYPE)
727 IS
728
729 BEGIN
730
731 IF PG_DEBUG in ('Y', 'C') THEN
732 arp_util.debug('AR_BILLS_CREATION_LIB_PVT.Default_Update_BR_Header()+ ');
733 END IF;
734
735 /*----------------------------------------------+
736 | Default the Batch Source ID |
737 +-----------------------------------------------*/
738
739 SELECT batch_source_id
740 INTO p_trx_rec.batch_source_id
741 FROM ra_customer_trx
742 WHERE customer_trx_id = p_trx_rec.customer_trx_id;
743
744
745 IF PG_DEBUG in ('Y', 'C') THEN
746 arp_util.debug('AR_BILLS_CREATION_LIB_PVT.Default_Update_BR_Header()- ');
747 END IF;
748
749 EXCEPTION
750 WHEN NO_DATA_FOUND THEN
751 IF PG_DEBUG in ('Y', 'C') THEN
752 arp_util.debug('Default_Update_BR_Header: ' || '>>>>> No Batch Source could be defaulted for the BR');
753 END IF;
754
755 WHEN OTHERS THEN
756 IF PG_DEBUG in ('Y', 'C') THEN
757 arp_util.debug('>>>>>>>>>> EXCEPTION : AR_BILLS_CREATION_LIB_PVT.Default_Update_BR_Header () ');
758 END IF;
759 RAISE;
760
761 END Default_Update_BR_Header;
762
763
764
765 /*==============================================================================+
766 | PROCEDURE |
767 | Default_Create_BR_Assignment |
768 | |
769 | DESCRIPTION |
770 | Defaults data in the BR Assignment during creation : |
771 | - The Assigned Amount |
772 | - The Identifier of the exchanged transaction |
773 | |
774 +==============================================================================*/
775
776
777 PROCEDURE Default_Create_BR_Assignment (p_trl_rec IN OUT NOCOPY ra_customer_trx_lines%ROWTYPE,
778 p_ps_rec IN ar_payment_schedules%ROWTYPE )
779 IS
780
781 l_amount_due_remaining NUMBER;
782 l_acctd_amount_due_remaining NUMBER;
783 l_count NUMBER;
784
785 BEGIN
786 IF PG_DEBUG in ('Y', 'C') THEN
787 arp_util.debug('AR_BILLS_CREATION_LIB_PVT.Default_Create_BR_Assignment()+ ');
788 END IF;
789
790 /*----------------------------------------------+
791 | Check that the transaction is not already |
792 | assigned to the BR |
793 +-----------------------------------------------*/
794
795 SELECT count(*)
796 INTO l_count
797 FROM RA_CUSTOMER_TRX_LINES
798 WHERE br_ref_payment_schedule_id = p_ps_rec.payment_schedule_id
799 AND customer_trx_id = p_trl_rec.customer_trx_id;
800
801 IF (l_count > 0)
802 THEN
803 IF PG_DEBUG in ('Y', 'C') THEN
804 arp_util.debug ('Default_Create_BR_Assignment: ' || 'The transaction is already assigned to the BR');
805 END IF;
806 FND_MESSAGE.SET_NAME ('AR', 'AR_BR_TRX_ASSIGNED_BR');
807 FND_MESSAGE.SET_TOKEN ('TRXNUM', p_ps_rec.trx_number);
808 app_exception.raise_exception;
809 END IF;
810
811
812 /*----------------------------------------------+
813 | Default the assigned amount |
814 +-----------------------------------------------*/
815
816 IF (p_trl_rec.extended_amount IS NULL) THEN
817 p_trl_rec.extended_amount := p_ps_rec.amount_due_remaining;
818 p_trl_rec.extended_acctd_amount := p_ps_rec.acctd_amount_due_remaining;
819 IF PG_DEBUG in ('Y', 'C') THEN
820 arp_util.debug('Default_Create_BR_Assignment: ' || 'Amount Defaulted : ' || p_trl_rec.extended_amount);
821 arp_util.debug('Default_Create_BR_Assignment: ' || 'Acctd Amount Defaulted : ' || p_trl_rec.extended_acctd_amount);
822 END IF;
823 END IF;
824
825
826 /*----------------------------------------------+
827 | Default the exchange transaction identifier |
828 +-----------------------------------------------*/
829
830 p_trl_rec.br_ref_customer_trx_id := p_ps_rec.customer_trx_id;
831
832
833 IF PG_DEBUG in ('Y', 'C') THEN
834 arp_util.debug('AR_BILLS_CREATION_LIB_PVT.Default_Create_BR_Assignment()-');
835 END IF;
836
837 EXCEPTION
838 WHEN OTHERS THEN
839 IF PG_DEBUG in ('Y', 'C') THEN
840 arp_util.debug('>>>>>>>>>> EXCEPTION : AR_BILLS_CREATION_LIB_PVT.Default_Create_BR_Assignment () ');
841 END IF;
842 RAISE;
843
844 END Default_Create_BR_Assignment;
845
846
847 /*==============================================================================+
848 | PROCEDURE |
849 | DeAssign_BR |
850 | |
851 | DESCRIPTION |
852 | Deassign all the transactions of a BR |
853 | |
854 +==============================================================================*/
855
856
857 PROCEDURE DeAssign_BR (p_customer_trx_id IN ra_customer_trx.customer_trx_id%TYPE)
858 IS
859
860 CURSOR assignment_cur IS
861 SELECT customer_trx_line_id
862 FROM ra_customer_trx_lines
863 WHERE customer_trx_id = p_customer_trx_id;
864
865 assignment_rec assignment_cur%ROWTYPE;
866
867 l_return_status VARCHAR2(1);
868 l_msg_count NUMBER;
869 l_msg_data VARCHAR2(2000);
870
871 BEGIN
872 IF PG_DEBUG in ('Y', 'C') THEN
873 arp_util.debug('AR_BILLS_CREATION_LIB_PVT.DeAssign_BR()+ ');
874 END IF;
875
876 FOR assignment_rec IN assignment_cur LOOP
877
878 AR_BILLS_CREATION_PUB.delete_br_assignment (
879 p_api_version => 1.0 ,
880 x_return_status => l_return_status ,
881 x_msg_count => l_msg_count ,
882 x_msg_data => l_msg_data ,
883 p_customer_trx_line_id => assignment_rec.customer_trx_line_id);
884
885
886 IF (l_return_status <> 'S')
887 THEN
888 IF PG_DEBUG in ('Y', 'C') THEN
889 arp_util.debug('DeAssign_BR: ' || '>>>>>>>>>> Problems during BR deassignment');
890 arp_util.debug('DeAssign_BR: ' || 'l_return_status : ' || l_return_status);
891 END IF;
892 app_exception.raise_exception;
893 END IF;
894
895 END LOOP;
896
897 IF PG_DEBUG in ('Y', 'C') THEN
898 arp_util.debug('AR_BILLS_CREATION_LIB_PVT.DeAssign_BR()- ');
899 END IF;
900
901 EXCEPTION
902 WHEN OTHERS THEN
903 IF PG_DEBUG in ('Y', 'C') THEN
904 arp_util.debug('>>>>>>>>>> EXCEPTION : AR_BILLS_CREATION_LIB_PVT.DeAssign_BR () ');
905 END IF;
906 IF (assignment_cur%ISOPEN)
907 THEN
908 CLOSE assignment_cur;
909 END IF;
910 RAISE;
911
912 END DeAssign_BR;
913
914
915 END AR_BILLS_CREATION_LIB_PVT ;