DBA Data[Home] [Help]

PACKAGE BODY: APPS.AR_BILLS_CREATION_PUB

Source


1 PACKAGE BODY AR_BILLS_CREATION_PUB AS
2 /* $Header: ARBRCREB.pls 120.11.12020000.2 2012/07/25 05:31:25 ashlkuma ship $ */
3 
4 
5 /* =======================================================================
6  | Global Data Types
7  * ======================================================================*/
8 
9 G_PKG_NAME      	CONSTANT VARCHAR2(30) 	:=  	'AR_BILLS_CREATION_PUB'			;
10 
11 G_MSG_UERROR   	 	CONSTANT NUMBER        	:=  	FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR	;
12 G_MSG_ERROR     	CONSTANT NUMBER        	:=  	FND_MSG_PUB.G_MSG_LVL_ERROR		;
13 G_MSG_SUCCESS   	CONSTANT NUMBER        	:=  	FND_MSG_PUB.G_MSG_LVL_SUCCESS		;
14 G_MSG_HIGH      	CONSTANT NUMBER   	:=  	FND_MSG_PUB.G_MSG_LVL_DEBUG_HIGH	;
15 G_MSG_MEDIUM    	CONSTANT NUMBER        	:=  	FND_MSG_PUB.G_MSG_LVL_DEBUG_MEDIUM	;
16 G_MSG_LOW       	CONSTANT NUMBER        	:=  	FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW		;
17 
18 
19 /* =======================================================================
20  | Bills Receivable status constants
21  * ======================================================================*/
22 
23 C_INCOMPLETE		CONSTANT VARCHAR2(30)	:=	'INCOMPLETE'				;
24 C_PENDING_ACCEPTANCE	CONSTANT VARCHAR2(30)	:=	'PENDING_ACCEPTANCE'			;
25 C_CANCELLED		CONSTANT VARCHAR2(30)	:=	'CANCELLED'				;
26 
27 
28 /* =======================================================================
29  | Bills Receivable action constants
30  * ======================================================================*/
31 
32 C_DELETE		CONSTANT VARCHAR2(30)	:=	'DELETE'				;
33 
34 
35 /*==============================================================================+
36  | PROCEDURE                                                                 	|
37  |    Create_BR_Header			                                     	|
38  |                                                                           	|
39  | DESCRIPTION                                                               	|
40  |    Stores BR Header information					     	|
41  |									  	|
42  +==============================================================================*/
43 
44 
45 PG_DEBUG varchar2(1) := NVL(FND_PROFILE.value('AFLOG_ENABLED'), 'N');
46 
47 PROCEDURE Create_BR_Header (
48 
49            --   *****  Standard API parameters *****
50                 p_api_version      		IN  NUMBER			,
51                 p_init_msg_list    		IN  VARCHAR2 := FND_API.G_TRUE	,
52                 p_commit           		IN  VARCHAR2 := FND_API.G_FALSE	,
53                 p_validation_level 		IN  NUMBER   := FND_API.G_VALID_LEVEL_FULL,
54                 x_return_status    		OUT NOCOPY VARCHAR2			,
55                 x_msg_count        		OUT NOCOPY NUMBER			,
56                 x_msg_data         		OUT NOCOPY VARCHAR2			,
57 
58            --   *****  BR Header information parameters *****
59 		p_trx_number			IN  VARCHAR2	DEFAULT NULL	,
60 		p_term_due_date			IN  DATE	DEFAULT NULL	,
61 		p_batch_source_id		IN  NUMBER	DEFAULT NULL	,
62 		p_cust_trx_type_id		IN  NUMBER	DEFAULT NULL	,
63 		p_invoice_currency_code 	IN  VARCHAR2	DEFAULT NULL	,
64 		p_br_amount			IN  NUMBER	DEFAULT NULL	,
65 		p_trx_date			IN  DATE	DEFAULT NULL	,
66 		p_gl_date			IN  DATE	DEFAULT NULL	,
67 		p_drawee_id			IN  NUMBER	DEFAULT NULL	,
68 		p_drawee_site_use_id		IN  NUMBER	DEFAULT NULL	,
69 		p_drawee_contact_id		IN  NUMBER	DEFAULT NULL	,
70 		p_printing_option		IN  VARCHAR2	DEFAULT NULL	,
71 		p_comments			IN  VARCHAR2	DEFAULT NULL	,
72 		p_special_instructions		IN  VARCHAR2	DEFAULT NULL	,
73 		p_drawee_bank_account_id     	IN  NUMBER	DEFAULT NULL	,
74 		p_remittance_bank_account_id 	IN  NUMBER 	DEFAULT NULL	,
75 		p_override_remit_account_flag	IN  VARCHAR2	DEFAULT NULL	,
76 		p_batch_id			IN  NUMBER	DEFAULT NULL	,
80 
77 		p_doc_sequence_id		IN  NUMBER	DEFAULT NULL	,
78 		p_doc_sequence_value		IN  NUMBER	DEFAULT NULL	,
79 		p_created_from			IN  VARCHAR2	DEFAULT NULL	,
81            --   ***** Descriptive Flexfield parameters *****
82                 p_attribute_category		IN  VARCHAR2	DEFAULT NULL	,
83 		p_attribute1			IN  VARCHAR2	DEFAULT NULL	,
84 		p_attribute2			IN  VARCHAR2	DEFAULT NULL	,
85 		p_attribute3			IN  VARCHAR2	DEFAULT NULL	,
86 		p_attribute4			IN  VARCHAR2	DEFAULT NULL	,
87 		p_attribute5			IN  VARCHAR2	DEFAULT NULL	,
88 		p_attribute6			IN  VARCHAR2	DEFAULT NULL	,
89 		p_attribute7			IN  VARCHAR2	DEFAULT NULL	,
90 		p_attribute8			IN  VARCHAR2	DEFAULT NULL	,
91 		p_attribute9			IN  VARCHAR2	DEFAULT NULL	,
92 		p_attribute10			IN  VARCHAR2	DEFAULT NULL	,
93 		p_attribute11			IN  VARCHAR2	DEFAULT NULL	,
94 		p_attribute12			IN  VARCHAR2	DEFAULT NULL	,
95 		p_attribute13			IN  VARCHAR2	DEFAULT NULL	,
96 		p_attribute14			IN  VARCHAR2	DEFAULT NULL	,
97 		p_attribute15			IN  VARCHAR2	DEFAULT NULL	,
98 
99            --   ***** Legal Entity and SSA *****
100                 p_le_id                         IN  NUMBER      DEFAULT NULL    ,
101                 p_org_id                        IN  NUMBER      DEFAULT NULL    ,
102                 p_payment_trxn_extn_id          IN  NUMBER      DEFAULT NULL    ,
103 
104            --   ***** OUT NOCOPY variables *****
105                 p_customer_trx_id		OUT NOCOPY NUMBER			,
106 		p_new_trx_number		OUT NOCOPY VARCHAR2			,
107 		p_status			OUT NOCOPY VARCHAR2			,
108                 p_customer_reference            IN  VARCHAR2    DEFAULT NULL)
109 
110 IS
111 		l_api_name			CONSTANT VARCHAR2(20)	:=	'Create_BR_Header';
112 		l_api_version			CONSTANT NUMBER		:=	1.0;
113 
114 		l_trx_rec			ra_customer_trx%ROWTYPE;
115 		l_trh_rec			ar_transaction_history%ROWTYPE;
116 
117 		l_gl_date			DATE				;
118 
119 		l_customer_trx_id		NUMBER				;
120 		l_new_trx_number		VARCHAR2(20)			;
121 		l_status			VARCHAR2(30)			;
122 
123 
124 BEGIN
125 
126 	IF PG_DEBUG in ('Y', 'C') THEN
127 	   arp_util.debug('AR_BILLS_CREATION_PUB.Create_BR_Header()+ ');
128 	END IF;
129 
130 	x_msg_count				:=	NULL;
131 	x_msg_data				:=	NULL;
132 
133        /*-----------------------------------------------+
134         |   Standard start of API savepoint     	|
135         +-----------------------------------------------*/
136 
137       	SAVEPOINT Create_BR_Header_PVT;
138 
139 
140        /*-----------------------------------------------+
141         | Standard call to check for call compatibility |
142         +-----------------------------------------------*/
143 
144         IF NOT FND_API.Compatible_API_Call( l_api_version	,
145                                             p_api_version	,
146                                             l_api_name		,
147                                             G_PKG_NAME          )
148         THEN
149         	RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
150         END IF;
151 
152 
153        /*-----------------------------------------------+
154         |   Initialize return status to SUCCESS   	|
155         +-----------------------------------------------*/
156 
157         x_return_status := FND_API.G_RET_STS_SUCCESS;
158 
159 
160        /*-----------------------------------------------+
161         |   ========  START OF API BODY  ============   |
162         +-----------------------------------------------*/
163 
164 
165        /*-----------------------------------------------+
166         |   Data preparation 				|
167         +-----------------------------------------------*/
168 
169 	l_trx_rec.trx_number			:=	p_trx_number			;
170 	l_trx_rec.term_due_date			:=	trunc(p_term_due_date)		;
171 	l_trx_rec.batch_source_id		:=	p_batch_source_id		;
172 	l_trx_rec.cust_trx_type_id		:=	p_cust_trx_type_id		;
173 	l_trx_rec.invoice_currency_code 	:=	p_invoice_currency_code		;
174 	l_trx_rec.br_amount			:=	p_br_amount			;
175 	l_trx_rec.trx_date			:=	trunc(p_trx_date)		;
176 	l_trx_rec.drawee_id			:=	p_drawee_id			;
177 	l_trx_rec.drawee_site_use_id		:=	p_drawee_site_use_id		;
178 	l_trx_rec.drawee_contact_id		:=	p_drawee_contact_id		;
179 	l_trx_rec.printing_option		:=	p_printing_option		;
180 	l_trx_rec.comments			:=	p_comments			;
181 	l_trx_rec.special_instructions		:=	p_special_instructions		;
182 	l_trx_rec.drawee_bank_account_id     	:=	p_drawee_bank_account_id	;
183 	l_trx_rec.remit_bank_acct_use_id	:=	p_remittance_bank_account_id	;
184 	l_trx_rec.override_remit_account_flag	:=	p_override_remit_account_flag	;
185 	l_trx_rec.batch_id			:=	p_batch_id			;
186 	l_trx_rec.doc_sequence_id		:=	p_doc_sequence_id		;
187 	l_trx_rec.doc_sequence_value		:=	p_doc_sequence_value		;
188 	l_trx_rec.created_from			:=	p_created_from			;
189 	l_trx_rec.attribute_category		:=	p_attribute_category		;
190 	l_trx_rec.attribute1			:=	p_attribute1			;
191 	l_trx_rec.attribute2			:=	p_attribute2			;
192 	l_trx_rec.attribute3			:=	p_attribute3			;
193 	l_trx_rec.attribute4			:=	p_attribute4			;
194 	l_trx_rec.attribute5			:=	p_attribute5			;
195 	l_trx_rec.attribute6			:=	p_attribute6			;
196 	l_trx_rec.attribute7			:=	p_attribute7			;
197 	l_trx_rec.attribute8			:=	p_attribute8			;
198 	l_trx_rec.attribute9			:=	p_attribute9			;
199 	l_trx_rec.attribute10			:=	p_attribute10			;
200 	l_trx_rec.attribute11			:=	p_attribute11			;
201 	l_trx_rec.attribute12			:=	p_attribute12			;
202 	l_trx_rec.attribute13			:=	p_attribute13			;
203 	l_trx_rec.attribute14			:=	p_attribute14			;
204 	l_trx_rec.attribute15			:=	p_attribute15			;
205         l_trx_rec.legal_entity_id               :=      p_le_id                         ;
209 
206         l_trx_rec.org_id                        :=      p_org_id                        ;
207         /* PAYMENT_UPTAKE */
208         l_trx_rec.payment_trxn_extension_id     :=      p_payment_trxn_extn_id          ;
210 	l_trx_rec.complete_flag			:=	'N'				;
211 	l_trx_rec.status_trx			:=	'OP'				;
212 	l_trx_rec.br_unpaid_flag		:=	'N'				;
213 	l_trx_rec.br_on_hold_flag		:=	'N'				;
214         l_trx_rec.customer_reference            :=      p_customer_reference            ;
215 
216 	l_gl_date				:=	trunc(p_gl_date)		;
217 
218 
219 
220 	/*----------------------------------------------+
221         |   Data Defaulting 				|
222         +-----------------------------------------------*/
223 
224     	AR_BILLS_CREATION_LIB_PVT.Default_Create_BR_Header (l_trx_rec, l_gl_date);
225 
226 
227        /*-----------------------------------------------+
228         |   Data Validation				|
229         +-----------------------------------------------*/
230 
231         AR_BILLS_CREATION_VAL_PVT.Validate_Create_BR_Header(l_trx_rec, l_gl_date);
232 
233 
234        /*-----------------------------------------------+
235         |   Call the Entity Handler  			|
236         +-----------------------------------------------*/
237 
238 	ARP_PROCESS_BR_HEADER.insert_header  (  l_trx_rec		,
239 						l_gl_date		,
240 						l_new_trx_number	,
241 						l_customer_trx_id	);
242 
243 
244 	/*-----------------------------------------------+
245         |   Output parameters	  			|
246         +-----------------------------------------------*/
247 
248 	l_trh_rec.customer_trx_id	:=	l_customer_trx_id;
249 	ARP_TRANSACTION_HISTORY_PKG.fetch_f_trx_id (l_trh_rec);
250 
251 	p_customer_trx_id		:=	l_customer_trx_id;
252 	p_new_trx_number		:=	l_new_trx_number ;
253 	p_status			:= 	l_trh_rec.status ;
254 
255 
256        /*-----------------------------------------------+
257         |   Standard check of p_commit   		|
258         +-----------------------------------------------*/
259 
260         IF FND_API.To_Boolean( p_commit )
261         THEN
262             IF PG_DEBUG in ('Y', 'C') THEN
263                arp_util.debug(  'committing');
264             END IF;
265             Commit;
266         END IF;
267 
268         IF PG_DEBUG in ('Y', 'C') THEN
269            arp_util.debug('AR_BILLS_CREATION_PUB.Create_BR_Header()- ');
270         END IF;
271 
272 
273 EXCEPTION
274        WHEN FND_API.G_EXC_ERROR THEN
275 
276                 IF PG_DEBUG in ('Y', 'C') THEN
277                    arp_util.debug (  'SQLERRM : ' || SQLERRM);
278 		   arp_util.debug (  'SQLCODE : ' || SQLCODE);
279 		END IF;
280                 ROLLBACK TO Create_BR_Header_PVT;
281                 x_return_status := FND_API.G_RET_STS_ERROR ;
282   	        IF PG_DEBUG in ('Y', 'C') THEN
283   	           arp_util.debug(  'Exception Error');
284   	        END IF;
285 		RAISE;
286 
287 
288         WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
289 
290                 IF PG_DEBUG in ('Y', 'C') THEN
291                    arp_util.debug (  'SQLERRM : ' || SQLERRM);
292 		   arp_util.debug (  'SQLCODE : ' || SQLCODE);
293 		END IF;
294                 ROLLBACK TO Create_BR_Header_PVT;
295                 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
296 		IF PG_DEBUG in ('Y', 'C') THEN
297 		   arp_util.debug(  'Exception Unexpected Error');
298 		END IF;
299 		RAISE;
300 
301 
302         WHEN OTHERS THEN
303 
304                /*-------------------------------------------------------+
305                 |  Handle application errors that result from trapable  |
306                 |  error conditions. The error messages have already    |
307                 |  been put on the error stack.                         |
308                 +-------------------------------------------------------*/
309 
310 		IF PG_DEBUG in ('Y', 'C') THEN
311 		   arp_util.debug (  'SQLERRM : ' || SQLERRM);
312 		   arp_util.debug (  'SQLCODE : ' || SQLCODE);
313 		END IF;
314 
315 	      	ROLLBACK TO Create_BR_Header_PVT;
316 
317 		IF (SQLCODE = -20001)
318                 THEN
319                      	x_return_status := FND_API.G_RET_STS_ERROR ;
320                 ELSE
321                	      	x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
322                 END IF;
323 
324 		RAISE;
325 
326 END Create_BR_Header;
327 
328 
329 
330 /*==============================================================================+
331  | PROCEDURE                                                                 	|
332  |    Update_BR_Header			                                     	|
333  |                                                                           	|
334  | DESCRIPTION                                                               	|
335  |    Updates BR Header information					     	|
336  |									  	|
337  +==============================================================================*/
338 
339 
340 PROCEDURE Update_BR_Header (
341 
342            --   *****  Standard API parameters *****
343                 p_api_version      		IN  NUMBER			,
344                 p_init_msg_list    		IN  VARCHAR2 := FND_API.G_TRUE	,
345                 p_commit           		IN  VARCHAR2 := FND_API.G_FALSE	,
346                 p_validation_level 		IN  NUMBER   := FND_API.G_VALID_LEVEL_FULL,
347                 x_return_status    		OUT NOCOPY VARCHAR2			,
351            --   *****  BR Header info. parameters *****
348                 x_msg_count        		OUT NOCOPY NUMBER			,
349                 x_msg_data         		OUT NOCOPY VARCHAR2			,
350 
352 		p_customer_trx_id		IN  NUMBER	DEFAULT NULL	,
353 		p_term_due_date			IN  DATE	DEFAULT NULL	,
354 		p_cust_trx_type_id		IN  NUMBER	DEFAULT NULL	,
355 		p_invoice_currency_code 	IN  VARCHAR2	DEFAULT NULL	,
356 		p_br_amount			IN  NUMBER	DEFAULT NULL	,
357 		p_trx_date			IN  DATE	DEFAULT NULL	,
358 		p_gl_date			IN  DATE	DEFAULT NULL	,
359 		p_drawee_id			IN  NUMBER	DEFAULT NULL	,
360 		p_drawee_site_use_id		IN  NUMBER	DEFAULT NULL	,
361 		p_drawee_contact_id		IN  NUMBER	DEFAULT NULL	,
362 		p_printing_option		IN  VARCHAR2	DEFAULT NULL	,
363 		p_comments			IN  VARCHAR2	DEFAULT NULL	,
364 		p_special_instructions		IN  VARCHAR2	DEFAULT NULL	,
365 		p_drawee_bank_account_id     	IN  NUMBER	DEFAULT NULL	,
366 		p_remittance_bank_account_id 	IN  NUMBER 	DEFAULT NULL	,
367 		p_override_remit_account_flag	IN  VARCHAR2	DEFAULT NULL	,
368 		p_doc_sequence_id		IN  NUMBER	DEFAULT NULL	,
369 		p_doc_sequence_value		IN  NUMBER	DEFAULT NULL	,
370 		p_created_from			IN  VARCHAR2	DEFAULT NULL	,
371 
372            --   ***** Descriptive Flexfield parameters *****
373                 p_attribute_category		IN  VARCHAR2	DEFAULT NULL	,
374 		p_attribute1			IN  VARCHAR2	DEFAULT NULL	,
375 		p_attribute2			IN  VARCHAR2	DEFAULT NULL	,
376 		p_attribute3			IN  VARCHAR2	DEFAULT NULL	,
377 		p_attribute4			IN  VARCHAR2	DEFAULT NULL	,
378 		p_attribute5			IN  VARCHAR2	DEFAULT NULL	,
379 		p_attribute6			IN  VARCHAR2	DEFAULT NULL	,
380 		p_attribute7			IN  VARCHAR2	DEFAULT NULL	,
381 		p_attribute8			IN  VARCHAR2	DEFAULT NULL	,
382 		p_attribute9			IN  VARCHAR2	DEFAULT NULL	,
383 		p_attribute10			IN  VARCHAR2	DEFAULT NULL	,
384 		p_attribute11			IN  VARCHAR2	DEFAULT NULL	,
385 		p_attribute12			IN  VARCHAR2	DEFAULT NULL	,
386 		p_attribute13			IN  VARCHAR2	DEFAULT NULL	,
387 		p_attribute14			IN  VARCHAR2	DEFAULT NULL	,
388 		p_attribute15			IN  VARCHAR2	DEFAULT NULL	,
389                 p_customer_reference            IN  VARCHAR2    DEFAULT NULL    ,
390                 p_le_id                         IN  NUMBER      DEFAULT NULL    ,
391                 p_payment_trxn_extn_id          IN  NUMBER      DEFAULT NULL)
392 
393 IS
394 		l_api_name			CONSTANT VARCHAR2(20)	:=	'Update_BR_Header';
395 		l_api_version			CONSTANT NUMBER		:=	1.0;
396 
397 		l_trx_rec			ra_customer_trx%ROWTYPE;
398 		l_trh_rec			ar_transaction_history%ROWTYPE;
399 		l_ps_rec			ar_payment_schedules%ROWTYPE;
400 
401 		l_gl_date			DATE		;
402 
403 BEGIN
404 
405         IF PG_DEBUG in ('Y', 'C') THEN
406            arp_util.debug('AR_BILLS_CREATION_PUB.Update_BR_Header()+ ');
407         END IF;
408 
409 	x_msg_count				:=	NULL;
410 	x_msg_data				:=	NULL;
411 
412        /*-----------------------------------------------+
413         |   Standard start of API savepoint     	|
414         +-----------------------------------------------*/
415 
416       	SAVEPOINT Update_BR_Header_PVT;
417 
418 
419        /*-----------------------------------------------+
420         | Standard call to check for call compatibility |
421         +-----------------------------------------------*/
422 
423         IF NOT FND_API.Compatible_API_Call(
424                                             l_api_version	,
425                                             p_api_version	,
426                                             l_api_name		,
427                                             G_PKG_NAME          )
428         THEN
429         	RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
430         END IF;
431 
432 
433        /*-----------------------------------------------+
434         |   Initialize return status to SUCCESS   	|
435         +-----------------------------------------------*/
436 
437         x_return_status := FND_API.G_RET_STS_SUCCESS;
438 
439 
440        /*-----------------------------------------------+
441         |   ========  START OF API BODY  ============   |
442         +-----------------------------------------------*/
443 
444 	AR_BILLS_CREATION_VAL_PVT.Validate_Customer_Trx_ID (p_customer_trx_id);
445 
446        /*-----------------------------------------------+
447         |   Data preparation 				|
448         +-----------------------------------------------*/
449 
450 	ARP_CT_PKG.set_to_dummy (l_trx_rec);
451 
452 	l_trx_rec.customer_trx_id		:=	p_customer_trx_id		;
453 	l_trx_rec.term_due_date			:=	trunc(p_term_due_date)		;
454 	l_trx_rec.cust_trx_type_id		:=	p_cust_trx_type_id		;
455 	l_trx_rec.invoice_currency_code 	:=	p_invoice_currency_code		;
456 	l_trx_rec.br_amount			:=	p_br_amount			;
457 	l_trx_rec.trx_date			:=	trunc(p_trx_date)		;
458 	l_trx_rec.drawee_id			:=	p_drawee_id			;
459 	l_trx_rec.drawee_site_use_id		:=	p_drawee_site_use_id		;
460 	l_trx_rec.drawee_contact_id		:=	p_drawee_contact_id		;
461 	l_trx_rec.printing_option		:=	p_printing_option		;
462 	l_trx_rec.comments			:=	p_comments			;
463 	l_trx_rec.special_instructions		:=	p_special_instructions		;
464 	l_trx_rec.drawee_bank_account_id     	:=	p_drawee_bank_account_id	;
465 	l_trx_rec.remit_bank_acct_use_id	:=	p_remittance_bank_account_id	;
466 	l_trx_rec.override_remit_account_flag	:=	p_override_remit_account_flag	;
467 	l_trx_rec.doc_sequence_id		:=	p_doc_sequence_id		;
468 	l_trx_rec.doc_sequence_value		:=	p_doc_sequence_value		;
469 	l_trx_rec.created_from			:=	p_created_from			;
470 	l_trx_rec.attribute_category		:=	p_attribute_category		;
471 	l_trx_rec.attribute1			:=	p_attribute1			;
475 	l_trx_rec.attribute5			:=	p_attribute5			;
472 	l_trx_rec.attribute2			:=	p_attribute2			;
473 	l_trx_rec.attribute3			:=	p_attribute3			;
474 	l_trx_rec.attribute4			:=	p_attribute4			;
476 	l_trx_rec.attribute6			:=	p_attribute6			;
477 	l_trx_rec.attribute7			:=	p_attribute7			;
478 	l_trx_rec.attribute8			:=	p_attribute8			;
479 	l_trx_rec.attribute9			:=	p_attribute9			;
480 	l_trx_rec.attribute10			:=	p_attribute10			;
481 	l_trx_rec.attribute11			:=	p_attribute11			;
482 	l_trx_rec.attribute12			:=	p_attribute12			;
483 	l_trx_rec.attribute13			:=	p_attribute13			;
484 	l_trx_rec.attribute14			:=	p_attribute14			;
485 	l_trx_rec.attribute15			:=	p_attribute15			;
486         l_trx_rec.customer_reference            :=      p_customer_reference            ;
487         l_trx_rec.legal_entity_id               :=      p_le_id                         ;
488         /* PAYMENT_UPTAKE */
489         l_trx_rec.payment_trxn_extension_id     :=      p_payment_trxn_extn_id          ;
490 
491 	l_gl_date				:=	trunc(p_gl_date);
492 
493 	/*----------------------------------------------+
494         |   Data Defaulting 				|
495         +-----------------------------------------------*/
496 
497 	AR_BILLS_CREATION_LIB_PVT.Default_Update_BR_Header  (l_trx_rec);
498 
499 
500        /*-----------------------------------------------+
501         |   Data Validation				|
502         +-----------------------------------------------*/
503 
504         AR_BILLS_CREATION_VAL_PVT.Validate_Update_BR_Header (l_trx_rec,	l_gl_date);
505 
506 
507        /*-----------------------------------------------+
508         |   Call the Entity Handler for BR Header	|
509         +-----------------------------------------------*/
510 
511 	ARP_PROCESS_BR_HEADER.update_header  (  l_trx_rec, l_trx_rec.customer_trx_id);
512 
513 
514        /*-----------------------------------------------+
515         |   Call the Entity Handler for BR History    	|
516         +-----------------------------------------------*/
517 
518 	l_trh_rec.customer_trx_id		:=	p_customer_trx_id		;
519 	ARP_TRANSACTION_HISTORY_PKG.lock_fetch_f_trx_id (l_trh_rec);
520 
521 	l_trh_rec.customer_trx_id		:=	l_trx_rec.customer_trx_id	;
522 	l_trh_rec.gl_date			:=	l_gl_date			;
523 	l_trh_rec.trx_date			:=	l_trx_rec.trx_date		;
524 	l_trh_rec.comments			:=	l_trx_rec.comments		;
525 
526 
527 	IF  (l_trh_rec.maturity_date <> l_trx_rec.term_due_date)
528 	THEN
529 		l_trh_rec.maturity_date   	:=	l_trx_rec.term_due_date;
530 		l_trh_rec.event			:=	'MATURITY_DATE_UPDATED';
531 		l_trh_rec.current_record_flag	:=  	'Y'		;
532 		l_trh_rec.prv_trx_history_id	:=  	NULL		;
533 		l_trh_rec.comments		:=  	NULL		;
534 		l_trh_rec.posting_control_id    := 	-3           	;
535 		l_trh_rec.gl_posted_date        :=  	NULL        	;
536 		l_trh_rec.first_posted_record_flag := 	'N'		;
537 		l_trh_rec.batch_id		:=	NULL		;
538 		l_trh_rec.postable_flag		:=	'N'		;
539 		l_trh_rec.current_accounted_flag:=	'N'		;
540 		ARP_PROC_TRANSACTION_HISTORY.insert_transaction_history (l_trh_rec,
541 								 	 l_trh_rec.transaction_history_id);
542 
543 		IF  (l_trh_rec.status not in (C_INCOMPLETE, C_PENDING_ACCEPTANCE, C_CANCELLED))
544 		THEN
545 			AR_BILLS_CREATION_LIB_PVT.Get_Payment_Schedule_Id (p_customer_trx_id, l_ps_rec.payment_schedule_id);
546 			arp_ps_pkg.lock_p(l_ps_rec.payment_schedule_id);
547 			arp_ps_pkg.set_to_dummy (l_ps_rec);
548 			l_ps_rec.due_date		:=	l_trx_rec.term_due_date;
549 			arp_ps_pkg.update_p (l_ps_rec, l_ps_rec.payment_schedule_id);
550 		END IF;
551 	ELSE
552 		ARP_PROC_TRANSACTION_HISTORY.update_transaction_history (l_trh_rec,
553 								 	 l_trh_rec.transaction_history_id);
554 	END IF;
555 
556 
557        /*-----------------------------------------------+
558         |   Update the Payment Schedule Information    	|
559         +-----------------------------------------------*/
560 
561 	IF  (l_trh_rec.status not in (C_INCOMPLETE, C_PENDING_ACCEPTANCE, C_CANCELLED))
562 	THEN
563 		AR_BILLS_CREATION_LIB_PVT.Get_Payment_Schedule_Id (p_customer_trx_id, l_ps_rec.payment_schedule_id);
564 		arp_ps_pkg.lock_p(l_ps_rec.payment_schedule_id);
565 		arp_ps_pkg.set_to_dummy (l_ps_rec);
566 		l_ps_rec.cust_trx_type_id	:=	l_trx_rec.cust_trx_type_id	;
567 		l_ps_rec.due_date		:=	l_trx_rec.term_due_date		;
568 		l_ps_rec.gl_date		:=	l_trh_rec.gl_date		;
569 		l_ps_rec.customer_site_use_id	:=	l_trx_rec.drawee_site_use_id	;
570 		l_ps_rec.trx_date		:=	l_trx_rec.trx_date		;
571 		arp_ps_pkg.update_p (l_ps_rec, l_ps_rec.payment_schedule_id);
572 	END IF;
573 
574 
575 
576        /*-----------------------------------------------+
577         |   Standard check of p_commit   		|
578         +-----------------------------------------------*/
579 
580         IF FND_API.To_Boolean( p_commit )
581         THEN
582             IF PG_DEBUG in ('Y', 'C') THEN
583                arp_util.debug(  'committing');
584             END IF;
585             Commit;
586         END IF;
587 
588         IF PG_DEBUG in ('Y', 'C') THEN
589            arp_util.debug('AR_BILLS_CREATION_PUB.Update_BR_Header()- ');
590         END IF;
591 
592 EXCEPTION
593        WHEN FND_API.G_EXC_ERROR THEN
594 
595                 IF PG_DEBUG in ('Y', 'C') THEN
596                    arp_util.debug (  'SQLERRM : ' || SQLERRM);
597 		   arp_util.debug (  'SQLCODE : ' || SQLCODE);
598 		END IF;
599                 ROLLBACK TO Update_BR_Header_PVT;
600                 x_return_status := FND_API.G_RET_STS_ERROR ;
601   	        IF PG_DEBUG in ('Y', 'C') THEN
602   	           arp_util.debug(  'Exception Error');
606 
603   	        END IF;
604 		RAISE;
605 
607         WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
608 
609                 IF PG_DEBUG in ('Y', 'C') THEN
610                    arp_util.debug (  'SQLERRM : ' || SQLERRM);
611 		   arp_util.debug (  'SQLCODE : ' || SQLCODE);
612 		END IF;
613                 ROLLBACK TO Update_BR_Header_PVT;
614                 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
615 		IF PG_DEBUG in ('Y', 'C') THEN
616 		   arp_util.debug(  'Exception Unexpected Error');
617 		END IF;
618 		RAISE;
619 
620 
621         WHEN OTHERS THEN
622 
623                /*-------------------------------------------------------+
624                 |  Handle application errors that result from trapable  |
625                 |  error conditions. The error messages have already    |
626                 |  been put on the error stack.                         |
627                 +-------------------------------------------------------*/
628 
629 		IF PG_DEBUG in ('Y', 'C') THEN
630 		   arp_util.debug (  'SQLERRM : ' || SQLERRM);
631 		   arp_util.debug (  'SQLCODE : ' || SQLCODE);
632 		END IF;
633 
634                 ROLLBACK TO Update_BR_Header_PVT;
635 
636 		IF (SQLCODE = -20001)
637                 THEN
638                      	x_return_status := FND_API.G_RET_STS_ERROR ;
639                 ELSE
640                	      	x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
641                 END IF;
642 
643 		RAISE;
644 
645 END Update_BR_Header;
646 
647 
648 /*==============================================================================+
649  | PROCEDURE                                                                 	|
650  |    Delete_BR_Header			                                     	|
651  |                                                                           	|
652  | DESCRIPTION                                                               	|
653  |    Delete BR Header information					     	|
654  |									  	|
655  +==============================================================================*/
656 
657 PROCEDURE Delete_BR_Header (
658 
659            --   *****  Standard API parameters *****
660                 p_api_version      		IN  NUMBER			,
661                 p_init_msg_list    		IN  VARCHAR2 := FND_API.G_TRUE	,
662                 p_commit           		IN  VARCHAR2 := FND_API.G_FALSE	,
663                 p_validation_level 		IN  NUMBER   := FND_API.G_VALID_LEVEL_FULL,
664                 x_return_status    		OUT NOCOPY VARCHAR2			,
665                 x_msg_count        		OUT NOCOPY NUMBER			,
666                 x_msg_data         		OUT NOCOPY VARCHAR2			,
667 
668            --   *****  BR Header info. parameters *****
669 		p_customer_trx_id		IN  NUMBER	DEFAULT NULL	)
670 
671 IS
672 		l_api_name			CONSTANT VARCHAR2(20)	:=	'Delete_BR_Header';
673 		l_api_version			CONSTANT NUMBER		:=	1.0;
674 
675 		l_complete_flag			VARCHAR2(1);
676 		l_uncomplete_flag		VARCHAR2(1);
677 		l_accept_flag			VARCHAR2(1);
678 	     	l_cancel_flag			VARCHAR2(1);
679 		l_select_remit_flag		VARCHAR2(1);
680 		l_deselect_remit_flag		VARCHAR2(1);
681 		l_approve_remit_flag		VARCHAR2(1);
682 		l_hold_flag			VARCHAR2(1);
683 		l_unhold_flag			VARCHAR2(1);
684 		l_recall_flag			VARCHAR2(1);
685 		l_eliminate_flag		VARCHAR2(1);
686 		l_uneliminate_flag		VARCHAR2(1);
687 		l_unpaid_flag			VARCHAR2(1);
688 		l_protest_flag			VARCHAR2(1);
689 		l_endorse_flag			VARCHAR2(1);
690 		l_restate_flag			VARCHAR2(1);
691 		l_exchange_flag			VARCHAR2(1);
692 		l_delete_flag			VARCHAR2(1);
693 
694 		l_trx_rec			ra_customer_trx%ROWTYPE;
695 
696 BEGIN
697 
698        	IF PG_DEBUG in ('Y', 'C') THEN
699        	   arp_util.debug('AR_BILLS_CREATION_PUB.Delete_BR_Header()+ ');
700        	END IF;
701 
702 	x_msg_count				:=	NULL;
703 	x_msg_data				:=	NULL;
704 
705        /*-----------------------------------------------+
706         |   Standard start of API savepoint     	|
707         +-----------------------------------------------*/
708 
709       	SAVEPOINT Delete_BR_Header_PVT;
710 
711 
712        /*-----------------------------------------------+
713         | Standard call to check for call compatibility |
714         +-----------------------------------------------*/
715 
716         IF NOT FND_API.Compatible_API_Call(
717                                             l_api_version	,
718                                             p_api_version	,
719                                             l_api_name		,
720                                             G_PKG_NAME
721                                           )
722         THEN
723         	RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
724         END IF;
725 
726 
727        /*-----------------------------------------------+
728         |   Initialize return status to SUCCESS   	|
729         +-----------------------------------------------*/
730 
731         x_return_status := FND_API.G_RET_STS_SUCCESS;
732 
733 
734        /*-----------------------------------------------+
735         |   ========  START OF API BODY  ============   |
736         +-----------------------------------------------*/
737 
738 
739        /*-----------------------------------------------+
740         |   Action Validation				|
741         +-----------------------------------------------*/
742 
743 
744 	AR_BILLS_MAINTAIN_STATUS_PUB.validate_actions (
745 		p_customer_trx_id	=>  	p_customer_trx_id	,
746 		p_complete_flag		=>	l_complete_flag		,
747 		p_uncomplete_flag	=>	l_uncomplete_flag	,
748 		p_accept_flag		=>	l_accept_flag		,
749 		p_cancel_flag		=>	l_cancel_flag		,
753 		p_hold_flag		=>	l_hold_flag		,
750 		p_select_remit_flag	=>	l_select_remit_flag	,
751 		p_deselect_remit_flag	=>	l_deselect_remit_flag	,
752 		p_approve_remit_flag	=>	l_approve_remit_flag	,
754 		p_unhold_flag		=>	l_unhold_flag		,
755 		p_recall_flag		=>	l_recall_flag		,
756 		p_eliminate_flag	=>	l_eliminate_flag	,
757 		p_uneliminate_flag	=>	l_uneliminate_flag	,
758 		p_unpaid_flag		=>	l_unpaid_flag		,
759 		p_protest_flag		=>	l_protest_flag		,
760 		p_endorse_flag		=>	l_endorse_flag		,
761 		p_restate_flag		=>	l_restate_flag		,
762 		p_exchange_flag		=>	l_exchange_flag		,
763 		p_delete_flag		=>	l_delete_flag		);
764 
765 
766 	-- Do not continue if the action is not allowed for the BR
767 
768 
769 	IF	(l_delete_flag	<>	'Y')
770 	THEN
771 		ARP_CT_PKG.fetch_p (l_trx_rec, p_customer_trx_id);
772 		IF PG_DEBUG in ('Y', 'C') THEN
773 		   arp_util.debug(  '>>>>>>>>>> The Action Delete is not allowed on the BR ' || p_customer_trx_id);
774 		END IF;
775 		FND_MESSAGE.set_name	( 'AR', 'AR_BR_ACTION_FORBIDDEN' );
776 		FND_MESSAGE.set_token	( 'ACTION', C_DELETE);
777 		FND_MESSAGE.set_token	( 'BRNUM' , l_trx_rec.trx_number);
778 		app_exception.raise_exception;
779 	END IF;
780 
781 
782 	/*-----------------------------------------------+
783         |   Deassign the exchanged transactions		 |
784         +-----------------------------------------------*/
785 
786 	AR_BILLS_CREATION_LIB_PVT.Deassign_BR (p_customer_trx_id);
787 
788 
789        /*-----------------------------------------------+
790         |   Call the Entity Handler for BR Header     	|
791         +-----------------------------------------------*/
792 
793 	ARP_PROCESS_BR_HEADER.delete_header  (p_customer_trx_id);
794 
795 
796        /*-----------------------------------------------+
797         |   Standard check of p_commit   		|
798         +-----------------------------------------------*/
799 
800         IF FND_API.To_Boolean( p_commit )
801         THEN
802             IF PG_DEBUG in ('Y', 'C') THEN
803                arp_util.debug(  'committing');
804             END IF;
805             Commit;
806         END IF;
807 
808         IF PG_DEBUG in ('Y', 'C') THEN
809            arp_util.debug('AR_BILLS_CREATION_PUB.Delete_BR_Header()- ');
810         END IF;
811 
812 
813 EXCEPTION
814        WHEN FND_API.G_EXC_ERROR THEN
815 
816 		IF PG_DEBUG in ('Y', 'C') THEN
817 		   arp_util.debug (  'SQLERRM : ' || SQLERRM);
818 		   arp_util.debug (  'SQLCODE : ' || SQLCODE);
819 		END IF;
820                 ROLLBACK TO Delete_BR_Header_PVT;
821                 x_return_status := FND_API.G_RET_STS_ERROR ;
822   	        IF PG_DEBUG in ('Y', 'C') THEN
823   	           arp_util.debug(  'Exception Error');
824   	        END IF;
825 		RAISE;
826 
827         WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
828 
829 		IF PG_DEBUG in ('Y', 'C') THEN
830 		   arp_util.debug (  'SQLERRM : ' || SQLERRM);
831 		   arp_util.debug (  'SQLCODE : ' || SQLCODE);
832 		END IF;
833                 ROLLBACK TO Delete_BR_Header_PVT;
834                 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
835 		IF PG_DEBUG in ('Y', 'C') THEN
836 		   arp_util.debug(  'Exception Unexpected Error');
837 		END IF;
838 		RAISE;
839 
840         WHEN OTHERS THEN
841 
842                /*-------------------------------------------------------+
843                 |  Handle application errors that result from trapable  |
844                 |  error conditions. The error messages have already    |
845                 |  been put on the error stack.                         |
846                 +-------------------------------------------------------*/
847 
848 		IF PG_DEBUG in ('Y', 'C') THEN
849 		   arp_util.debug (  'SQLERRM : ' || SQLERRM);
850 		   arp_util.debug (  'SQLCODE : ' || SQLCODE);
851 		END IF;
852 
853 		ROLLBACK TO Delete_BR_Header_PVT;
854 
855 		IF (SQLCODE = -20001)
856                 THEN
857                      	x_return_status := FND_API.G_RET_STS_ERROR ;
858                 ELSE
859                	      	x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
860                 END IF;
861 
862 		RAISE;
863 
864 END Delete_BR_Header;
865 
866 
867 
868 /*==============================================================================+
869  | PROCEDURE                                                                 	|
870  |    Lock_BR_Header			                                     	|
871  |                                                                           	|
872  | DESCRIPTION                                                               	|
873  |    Locks BR Header information					     	|
874  |									  	|
875  +==============================================================================*/
876 
877 
878 PROCEDURE Lock_BR_Header (
879 
880            --   *****  Standard API parameters *****
881                 p_api_version      		IN  NUMBER			,
882                 p_init_msg_list    		IN  VARCHAR2 := FND_API.G_TRUE	,
883                 p_commit           		IN  VARCHAR2 := FND_API.G_FALSE	,
884                 p_validation_level 		IN  NUMBER   := FND_API.G_VALID_LEVEL_FULL,
885                 x_return_status    		OUT NOCOPY VARCHAR2			,
889            --   *****  BR Header info. parameters *****
886                 x_msg_count        		OUT NOCOPY NUMBER			,
887                 x_msg_data         		OUT NOCOPY VARCHAR2			,
888 
890 		p_customer_trx_id		IN  NUMBER	DEFAULT NULL	,
891 		p_term_due_date			IN  DATE	DEFAULT NULL	,
892 		p_cust_trx_type_id		IN  NUMBER	DEFAULT NULL	,
893 		p_invoice_currency_code 	IN  VARCHAR2	DEFAULT NULL	,
894 		p_br_amount			IN  NUMBER	DEFAULT NULL	,
895 		p_trx_date			IN  DATE	DEFAULT NULL	,
896 		p_gl_date			IN  DATE	DEFAULT NULL	,
897 		p_drawee_id			IN  NUMBER	DEFAULT NULL	,
898 		p_drawee_site_use_id		IN  NUMBER	DEFAULT NULL	,
899 		p_drawee_contact_id		IN  NUMBER	DEFAULT NULL	,
900 		p_printing_option		IN  VARCHAR2	DEFAULT NULL	,
901 		p_comments			IN  VARCHAR2	DEFAULT NULL	,
902 		p_special_instructions		IN  VARCHAR2	DEFAULT NULL	,
903 		p_drawee_bank_account_id     	IN  NUMBER	DEFAULT NULL	,
904 		p_remittance_bank_account_id 	IN  NUMBER 	DEFAULT NULL	,
905 		p_override_remit_account_flag	IN  VARCHAR2	DEFAULT NULL	,
906 		p_doc_sequence_id		IN  NUMBER	DEFAULT NULL	,
907 		p_doc_sequence_value		IN  NUMBER	DEFAULT NULL	,
908 		p_created_from			IN  VARCHAR2	DEFAULT NULL	,
909 
910            --   ***** Descriptive Flexfield parameters *****
911                 p_attribute_category		IN  VARCHAR2	DEFAULT NULL	,
912 		p_attribute1			IN  VARCHAR2	DEFAULT NULL	,
913 		p_attribute2			IN  VARCHAR2	DEFAULT NULL	,
914 		p_attribute3			IN  VARCHAR2	DEFAULT NULL	,
915 		p_attribute4			IN  VARCHAR2	DEFAULT NULL	,
916 		p_attribute5			IN  VARCHAR2	DEFAULT NULL	,
917 		p_attribute6			IN  VARCHAR2	DEFAULT NULL	,
918 		p_attribute7			IN  VARCHAR2	DEFAULT NULL	,
919 		p_attribute8			IN  VARCHAR2	DEFAULT NULL	,
920 		p_attribute9			IN  VARCHAR2	DEFAULT NULL	,
921 		p_attribute10			IN  VARCHAR2	DEFAULT NULL	,
922 		p_attribute11			IN  VARCHAR2	DEFAULT NULL	,
923 		p_attribute12			IN  VARCHAR2	DEFAULT NULL	,
924 		p_attribute13			IN  VARCHAR2	DEFAULT NULL	,
925 		p_attribute14			IN  VARCHAR2	DEFAULT NULL	,
926 		p_attribute15			IN  VARCHAR2	DEFAULT NULL	,
927                 p_customer_reference            IN  VARCHAR2    DEFAULT NULL    )
928 IS
929 		l_api_name			CONSTANT VARCHAR2(20)	:=	'Lock_BR_Header';
930 		l_api_version			CONSTANT NUMBER		:=	1.0;
931 
932 		l_trx_rec			ra_customer_trx%ROWTYPE;
933 
934 
935 
936 BEGIN
937 
938       	IF PG_DEBUG in ('Y', 'C') THEN
939       	   arp_util.debug('AR_BILLS_CREATION_PUB.Lock_BR_Header()+ ');
940       	END IF;
941 
942 	x_msg_count				:=	NULL;
943 	x_msg_data				:=	NULL;
944 
945 
946        /*-----------------------------------------------+
947         |   Standard start of API savepoint     	|
948         +-----------------------------------------------*/
949 
950       	SAVEPOINT Lock_BR_Header_PVT;
951 
952 
953        /*-----------------------------------------------+
954         | Standard call to check for call compatibility |
955         +-----------------------------------------------*/
956 
957         IF NOT FND_API.Compatible_API_Call(
958                                             l_api_version	,
959                                             p_api_version	,
960                                             l_api_name		,
961                                             G_PKG_NAME
962                                           )
963         THEN
964         	RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
965         END IF;
966 
967 
968        /*-----------------------------------------------+
969         |   Initialize return status to SUCCESS   	|
970         +-----------------------------------------------*/
971 
972         x_return_status := FND_API.G_RET_STS_SUCCESS;
973 
974 
975        /*-----------------------------------------------+
976         |   ========  START OF API BODY  ============   |
977         +-----------------------------------------------*/
978 
979 	AR_BILLS_CREATION_VAL_PVT.Validate_Customer_Trx_ID (p_customer_trx_id);
980 
981        /*-----------------------------------------------+
982         |   Data preparation 				|
983         +-----------------------------------------------*/
984 
985 	ARP_CT_PKG.set_to_dummy (l_trx_rec);
986 
987 	l_trx_rec.customer_trx_id		:=	p_customer_trx_id		;
988 	l_trx_rec.term_due_date			:=	trunc(p_term_due_date)		;
989 	l_trx_rec.cust_trx_type_id		:=	p_cust_trx_type_id		;
990 	l_trx_rec.invoice_currency_code 	:=	p_invoice_currency_code		;
991 	l_trx_rec.br_amount			:=	p_br_amount			;
992 	l_trx_rec.trx_date			:=	trunc(p_trx_date)		;
993 	l_trx_rec.drawee_id			:=	p_drawee_id			;
994 	l_trx_rec.drawee_site_use_id		:=	p_drawee_site_use_id		;
995 	l_trx_rec.drawee_contact_id		:=	p_drawee_contact_id		;
996 	l_trx_rec.printing_option		:=	p_printing_option		;
997 	l_trx_rec.comments			:=	p_comments			;
998 	l_trx_rec.special_instructions		:=	p_special_instructions		;
999 	l_trx_rec.drawee_bank_account_id     	:=	p_drawee_bank_account_id	;
1000 	l_trx_rec.remit_bank_acct_use_id	:=	p_remittance_bank_account_id	;
1001 	l_trx_rec.override_remit_account_flag	:=	p_override_remit_account_flag	;
1002 	l_trx_rec.doc_sequence_id		:=	p_doc_sequence_id		;
1003 	l_trx_rec.doc_sequence_value		:=	p_doc_sequence_value		;
1004 	l_trx_rec.created_from			:=	p_created_from			;
1005 	l_trx_rec.attribute_category		:=	p_attribute_category		;
1006 	l_trx_rec.attribute1			:=	p_attribute1			;
1007 	l_trx_rec.attribute2			:=	p_attribute2			;
1008 	l_trx_rec.attribute3			:=	p_attribute3			;
1009 	l_trx_rec.attribute4			:=	p_attribute4			;
1010 	l_trx_rec.attribute5			:=	p_attribute5			;
1011 	l_trx_rec.attribute6			:=	p_attribute6			;
1012 	l_trx_rec.attribute7			:=	p_attribute7			;
1013 	l_trx_rec.attribute8			:=	p_attribute8			;
1017 	l_trx_rec.attribute12			:=	p_attribute12			;
1014 	l_trx_rec.attribute9			:=	p_attribute9			;
1015 	l_trx_rec.attribute10			:=	p_attribute10			;
1016 	l_trx_rec.attribute11			:=	p_attribute11			;
1018 	l_trx_rec.attribute13			:=	p_attribute13			;
1019 	l_trx_rec.attribute14			:=	p_attribute14			;
1020 	l_trx_rec.attribute15			:=	p_attribute15			;
1021         l_trx_rec.customer_reference            :=      p_customer_reference            ;
1022 
1023        /*-----------------------------------------------+
1024         |   Call the Table Handler    			|
1025         +-----------------------------------------------*/
1026 
1027 	ARP_CT_PKG.lock_compare_p( l_trx_rec, p_customer_trx_id);
1028 
1029         IF PG_DEBUG in ('Y', 'C') THEN
1030            arp_util.debug('AR_BILLS_CREATION_PUB.Lock_BR_Header()- ');
1031         END IF;
1032 
1033 
1034 EXCEPTION
1035        WHEN FND_API.G_EXC_ERROR THEN
1036 
1037 		IF PG_DEBUG in ('Y', 'C') THEN
1038 		   arp_util.debug (  'SQLERRM : ' || SQLERRM);
1039 		   arp_util.debug (  'SQLCODE : ' || SQLCODE);
1040 		END IF;
1041                 ROLLBACK TO Lock_BR_Header_PVT;
1042                 x_return_status := FND_API.G_RET_STS_ERROR ;
1043   	        IF PG_DEBUG in ('Y', 'C') THEN
1044   	           arp_util.debug(  'Exception Error');
1045   	        END IF;
1046 		RAISE;
1047 
1048         WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1049 
1050                 IF PG_DEBUG in ('Y', 'C') THEN
1051                    arp_util.debug (  'SQLERRM : ' || SQLERRM);
1052 		   arp_util.debug (  'SQLCODE : ' || SQLCODE);
1053 		END IF;
1054                 ROLLBACK TO Lock_BR_Header_PVT;
1055                 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1056 		IF PG_DEBUG in ('Y', 'C') THEN
1057 		   arp_util.debug(  'Exception Unexpected Error');
1058 		END IF;
1059 		RAISE;
1060 
1061         WHEN OTHERS THEN
1062 
1063                /*-------------------------------------------------------+
1064                 |  Handle application errors that result from trapable  |
1065                 |  error conditions. The error messages have already    |
1066                 |  been put on the error stack.                         |
1067                 +-------------------------------------------------------*/
1068 
1069 		IF PG_DEBUG in ('Y', 'C') THEN
1070 		   arp_util.debug (  'SQLERRM : ' || SQLERRM);
1071 		   arp_util.debug (  'SQLCODE : ' || SQLCODE);
1072 		END IF;
1073 
1074 
1075                 ROLLBACK TO Lock_BR_Header_PVT;
1076 
1077                 IF (SQLCODE = -20001)
1078                 THEN
1079                       	x_return_status := FND_API.G_RET_STS_ERROR ;
1080                 ELSE
1081                	   	x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1082                 END IF;
1083 
1084 		RAISE;
1085 
1086 END Lock_BR_Header;
1087 
1088 
1089 /*==============================================================================+
1090  | PROCEDURE                                                                 	|
1091  |    Create_BR_Assignment			                               	|
1092  |                                                                           	|
1093  | DESCRIPTION                                                               	|
1094  |    Stores BR Assignment information					     	|
1095  |									  	|
1096  | 25-MAY-05	V Crisostomo	SSA-R12 : add p_org_id                          |
1097  +==============================================================================*/
1098 
1099 
1100 PROCEDURE Create_BR_Assignment (
1101 
1102            --   *****  Standard API parameters *****
1103                 p_api_version      		IN  NUMBER			,
1104                 p_init_msg_list    		IN  VARCHAR2 := FND_API.G_TRUE	,
1105                 p_commit           		IN  VARCHAR2 := FND_API.G_FALSE	,
1106                 p_validation_level 		IN  NUMBER   := FND_API.G_VALID_LEVEL_FULL,
1107                 x_return_status    		OUT NOCOPY VARCHAR2			,
1108                 x_msg_count        		OUT NOCOPY NUMBER			,
1109                 x_msg_data         		OUT NOCOPY VARCHAR2			,
1110 
1111            --   *****  BR Assignment information parameters *****
1112 		p_customer_trx_id		IN  NUMBER	DEFAULT NULL	,
1113 		p_br_ref_payment_schedule_id	IN  NUMBER	DEFAULT NULL	,
1114 		p_assigned_amount		IN  NUMBER	DEFAULT NULL	,
1115 
1116            --   ***** Descriptive Flexfield parameters *****
1117                 p_attribute_category		IN  VARCHAR2	DEFAULT NULL	,
1118 		p_attribute1			IN  VARCHAR2	DEFAULT NULL	,
1119 		p_attribute2			IN  VARCHAR2	DEFAULT NULL	,
1120 		p_attribute3			IN  VARCHAR2	DEFAULT NULL	,
1121 		p_attribute4			IN  VARCHAR2	DEFAULT NULL	,
1122 		p_attribute5			IN  VARCHAR2	DEFAULT NULL	,
1123 		p_attribute6			IN  VARCHAR2	DEFAULT NULL	,
1124 		p_attribute7			IN  VARCHAR2	DEFAULT NULL	,
1125 		p_attribute8			IN  VARCHAR2	DEFAULT NULL	,
1126 		p_attribute9			IN  VARCHAR2	DEFAULT NULL	,
1127 		p_attribute10			IN  VARCHAR2	DEFAULT NULL	,
1128 		p_attribute11			IN  VARCHAR2	DEFAULT NULL	,
1129 		p_attribute12			IN  VARCHAR2	DEFAULT NULL	,
1130 		p_attribute13			IN  VARCHAR2	DEFAULT NULL	,
1131 		p_attribute14			IN  VARCHAR2	DEFAULT NULL	,
1132 		p_attribute15			IN  VARCHAR2	DEFAULT NULL	,
1133 
1134            --   ***** SSA  *****
1135                 p_org_id                        IN  NUMBER      DEFAULT NULL    ,
1136 
1137            --   ***** OUT NOCOPY variables *****
1138                 p_customer_trx_line_id		OUT NOCOPY NUMBER 			)
1139 
1140 
1141 IS
1142 		l_api_name			CONSTANT VARCHAR2(20)	:=	'Create_BR_Assignment';
1143 		l_api_version			CONSTANT NUMBER		:=	1.0;
1144 		l_trl_rec			ra_customer_trx_lines%ROWTYPE	;
1145 		l_ps_rec			ar_payment_schedules%ROWTYPE	;
1146 		l_trx_rec			ra_customer_trx%ROWTYPE		;
1147 		l_BR_rec			ra_customer_trx%ROWTYPE		;
1148 		l_customer_trx_line_id		NUMBER				;
1152 
1149 		l_trh_rec			ar_transaction_history%ROWTYPE	;
1150 
1151 BEGIN
1153 	IF PG_DEBUG in ('Y', 'C') THEN
1154 	   arp_util.debug('AR_BILLS_CREATION_PUB.Create_BR_Assignment()+ ');
1155 	END IF;
1156 
1157 	x_msg_count				:=	NULL;
1158 	x_msg_data				:=	NULL;
1159 
1160 
1161        /*-----------------------------------------------+
1162         |   Standard start of API savepoint     	|
1163         +-----------------------------------------------*/
1164 
1165     	SAVEPOINT Create_BR_Assignment_PVT;
1166 
1167        /*-----------------------------------------------+
1168         | Standard call to check for call compatibility |
1169         +-----------------------------------------------*/
1170 
1171         IF NOT FND_API.Compatible_API_Call( l_api_version	,
1172                                             p_api_version	,
1173                                             l_api_name		,
1174                                             G_PKG_NAME          )
1175         THEN
1176         	RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1177         END IF;
1178 
1179 
1180        /*-----------------------------------------------+
1181         |   Initialize return status to SUCCESS   	|
1182         +-----------------------------------------------*/
1183 
1184         x_return_status := FND_API.G_RET_STS_SUCCESS;
1185 
1186 
1187        /*-----------------------------------------------+
1188         |   ========  START OF API BODY  ============   |
1189         +-----------------------------------------------*/
1190 
1191 	/*-----------------------------------------------+
1192         |   Validation of the Input parameters 		 |
1193         +-----------------------------------------------*/
1194 
1195 	AR_BILLS_CREATION_VAL_PVT.Validate_Customer_Trx_ID (p_customer_trx_id);
1196 	AR_BILLS_MAINTAIN_VAL_PVT.Validate_Payment_schedule_ID (p_br_ref_payment_schedule_id);
1197 
1198 
1199 	--  Fetch the BR transaction information
1200 
1201 	ARP_CT_PKG.fetch_p (l_BR_rec, p_customer_trx_id);
1202 
1203 
1204 	--  Fetch the payment schedule information of the exchanged transaction
1205 
1206 	arp_ps_pkg.fetch_p (p_br_ref_payment_schedule_id, l_ps_rec);
1207 
1208 	--  Fetch the exchanged transaction information
1209 
1210 	ARP_CT_PKG.fetch_p (l_trx_rec, l_ps_rec.customer_trx_id);
1211 
1212 
1213        /*-----------------------------------------------+
1214         |   Data preparation 				|
1215         +-----------------------------------------------*/
1216 
1217 	l_trl_rec.customer_trx_id		:=	p_customer_trx_id	;
1218 	l_trl_rec.br_ref_payment_schedule_id	:=	p_br_ref_payment_schedule_id;
1219 	l_trl_rec.extended_amount		:=	p_assigned_amount	;
1220 
1221 	l_trl_rec.attribute_category		:=	p_attribute_category	;
1222 	l_trl_rec.attribute1			:=	p_attribute1		;
1223 	l_trl_rec.attribute2			:=	p_attribute2		;
1224 	l_trl_rec.attribute3			:=	p_attribute3		;
1225 	l_trl_rec.attribute4			:=	p_attribute4		;
1226 	l_trl_rec.attribute5			:=	p_attribute5		;
1227 	l_trl_rec.attribute6			:=	p_attribute6		;
1228 	l_trl_rec.attribute7			:=	p_attribute7		;
1229 	l_trl_rec.attribute8			:=	p_attribute8		;
1230 	l_trl_rec.attribute9			:=	p_attribute9		;
1231 	l_trl_rec.attribute10			:=	p_attribute10		;
1232 	l_trl_rec.attribute11			:=	p_attribute11		;
1233 	l_trl_rec.attribute12			:=	p_attribute12		;
1234 	l_trl_rec.attribute13			:=	p_attribute13		;
1235 	l_trl_rec.attribute14			:=	p_attribute14		;
1236 	l_trl_rec.attribute15			:=	p_attribute15		;
1237 
1238 	l_trl_rec.line_number			:=	1;
1239 	l_trl_rec.line_type			:=	'LINE';
1240 
1241 	l_trl_rec.revenue_amount		:=	p_assigned_amount;
1242 
1243         l_trl_rec.org_id                        :=      p_org_id;
1244 
1245 
1246 	/*----------------------------------------------+
1247         |   Data Defaulting 				|
1248         +-----------------------------------------------*/
1249 
1250    	AR_BILLS_CREATION_LIB_PVT.Default_Create_BR_Assignment (l_trl_rec, l_ps_rec);
1251 
1252 
1253        /*-----------------------------------------------+
1254         |   Data Validation				|
1255         +-----------------------------------------------*/
1256 
1257         AR_BILLS_CREATION_VAL_PVT.Validate_BR_Assignment (l_trl_rec	,
1258 						 	  l_ps_rec	,
1259 							  l_trx_rec	,
1260 							  l_br_rec	);
1261 
1262 
1263        /*-----------------------------------------------+
1264         |   Call the Entity Handler  			|
1265         +-----------------------------------------------*/
1266 
1267 	ARP_PROCESS_BR_LINE.insert_line (l_trl_rec, l_customer_trx_line_id);
1268 
1269 
1270        /*-----------------------------------------------+
1271         |   Transaction History Entity Handler		|
1272         +-----------------------------------------------*/
1273 
1274 	IF	(AR_BILLS_CREATION_VAL_PVT.Is_transaction_BR (l_trx_rec.cust_trx_type_id))
1275 	THEN
1276 
1277 		/*----------------------------------------------+
1278 	        |   If the transaction to be exchanged is a BR,	|
1279 		|   create a transaction history record for the |
1280 		|   BR						|
1281 	        +-----------------------------------------------*/
1282 
1283 		l_trh_rec.customer_trx_id	:=	l_trx_rec.customer_trx_id;
1284 		ARP_TRANSACTION_HISTORY_PKG.lock_fetch_f_trx_id (l_trh_rec);
1285 
1286 		AR_BILLS_MAINTAIN_STATUS_PUB.New_Status_Event (
1287 			p_trx_rec		=>	l_trx_rec		,
1288 			p_action       	 	=>	'EXCHANGE'		,
1289 			p_new_status		=>	l_trh_rec.status	,
1290 			p_new_event		=>	l_trh_rec.event		);
1291 
1292 		l_trh_rec.postable_flag		:=	'N'		;
1293 		l_trh_rec.current_accounted_flag:=	'N'		;
1297 		l_trh_rec.comments		:=  	NULL		;
1294 		l_trh_rec.transaction_history_id:=	NULL		;
1295 		l_trh_rec.current_record_flag	:=  	'Y'		;
1296 		l_trh_rec.prv_trx_history_id	:=  	NULL		;
1298 		l_trh_rec.posting_control_id    := 	-3           	;
1299 		l_trh_rec.gl_posted_date        :=  	NULL        	;
1300 		l_trh_rec.first_posted_record_flag := 	'N'		;
1301 		l_trh_rec.created_from		:=	'ARBRMAIB'	;
1302 		l_trh_rec.batch_id		:=	NULL		;
1303                 l_trh_rec.org_id                :=      p_org_id        ;
1304 
1305 
1306 		arp_proc_transaction_history.insert_transaction_history (l_trh_rec	,
1307 									 l_trh_rec.transaction_history_id);
1308 	END IF;
1309 
1310 
1311 	/*----------------------------------------------+
1312         |   Output parameter				|
1313         +-----------------------------------------------*/
1314 
1315 	p_customer_trx_line_id		:=   	l_customer_trx_line_id;
1316 
1317 
1318 
1319        /*-----------------------------------------------+
1320         |   Standard check of p_commit   		|
1321         +-----------------------------------------------*/
1322 
1323         IF FND_API.To_Boolean( p_commit )
1324         THEN
1325             IF PG_DEBUG in ('Y', 'C') THEN
1326                arp_util.debug(  'committing');
1327             END IF;
1328             Commit;
1329         END IF;
1330 
1331         IF PG_DEBUG in ('Y', 'C') THEN
1332            arp_util.debug('AR_BILLS_CREATION_PUB.Create_BR_Assignment()- ');
1333         END IF;
1334 
1335 
1336 EXCEPTION
1337        WHEN FND_API.G_EXC_ERROR THEN
1338 
1339                 IF PG_DEBUG in ('Y', 'C') THEN
1340                    arp_util.debug (  'SQLERRM : ' || SQLERRM);
1341 		   arp_util.debug (  'SQLCODE : ' || SQLCODE);
1342 		END IF;
1343                 ROLLBACK TO Create_BR_Assignment_PVT;
1344                 x_return_status := FND_API.G_RET_STS_ERROR ;
1345                 IF PG_DEBUG in ('Y', 'C') THEN
1346                    arp_util.debug(  'Exception Error');
1347                 END IF;
1348 		RAISE;
1349 
1350 
1351         WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1352 
1353                 IF PG_DEBUG in ('Y', 'C') THEN
1354                    arp_util.debug (  'SQLERRM : ' || SQLERRM);
1355 		   arp_util.debug (  'SQLCODE : ' || SQLCODE);
1356 		END IF;
1357                 ROLLBACK TO Create_BR_Assignment_PVT;
1358                 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1359 		IF PG_DEBUG in ('Y', 'C') THEN
1360 		   arp_util.debug(  'Exception Unexpected Error');
1361 		END IF;
1362 		RAISE;
1363 
1364 
1365         WHEN OTHERS THEN
1366 
1367                /*-------------------------------------------------------+
1368                 |  Handle application errors that result from trapable  |
1369                 |  error conditions. The error messages have already    |
1370                 |  been put on the error stack.                         |
1371                 +-------------------------------------------------------*/
1372 
1373 		IF PG_DEBUG in ('Y', 'C') THEN
1374 		   arp_util.debug (  'SQLERRM : ' || SQLERRM);
1375 		   arp_util.debug (  'SQLCODE : ' || SQLCODE);
1376 		END IF;
1377 
1378 		ROLLBACK TO Create_BR_Assignment_PVT;
1379 
1380 		IF (SQLCODE = -20001)
1381                 THEN
1382                      	x_return_status := FND_API.G_RET_STS_ERROR ;
1383                 ELSE
1384                	      	x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1385                 END IF;
1386 
1387 		RAISE;
1388 
1389 END Create_BR_Assignment;
1390 
1391 
1392 
1393 
1394 /*==============================================================================+
1395  | PROCEDURE                                                                 	|
1396  |    Update_BR_Assignment			                               	|
1397  |                                                                           	|
1398  | DESCRIPTION                                                               	|
1399  |    Update BR Assignment information					     	|
1400  |									  	|
1401  +==============================================================================*/
1402 
1403 
1404 PROCEDURE Update_BR_Assignment (
1405 
1406            --   *****  Standard API parameters *****
1407                 p_api_version      		IN  NUMBER			,
1408                 p_init_msg_list    		IN  VARCHAR2 := FND_API.G_TRUE	,
1409                 p_commit           		IN  VARCHAR2 := FND_API.G_FALSE	,
1410                 p_validation_level 		IN  NUMBER   := FND_API.G_VALID_LEVEL_FULL,
1411                 x_return_status    		OUT NOCOPY VARCHAR2			,
1412                 x_msg_count        		OUT NOCOPY NUMBER			,
1413                 x_msg_data         		OUT NOCOPY VARCHAR2			,
1414 
1415            --   *****  BR Assignment information parameters *****
1416 		p_customer_trx_id		IN  NUMBER	DEFAULT NULL	,
1417 		p_customer_trx_line_id		IN  NUMBER	DEFAULT NULL	,
1418 		p_br_ref_payment_schedule_id	IN  NUMBER	DEFAULT NULL	,
1419 		p_assigned_amount		IN  NUMBER	DEFAULT NULL	,
1420 
1421            --   ***** Descriptive Flexfield parameters *****
1422                 p_attribute_category		IN  VARCHAR2	DEFAULT NULL	,
1423 		p_attribute1			IN  VARCHAR2	DEFAULT NULL	,
1424 		p_attribute2			IN  VARCHAR2	DEFAULT NULL	,
1425 		p_attribute3			IN  VARCHAR2	DEFAULT NULL	,
1426 		p_attribute4			IN  VARCHAR2	DEFAULT NULL	,
1427 		p_attribute5			IN  VARCHAR2	DEFAULT NULL	,
1428 		p_attribute6			IN  VARCHAR2	DEFAULT NULL	,
1429 		p_attribute7			IN  VARCHAR2	DEFAULT NULL	,
1430 		p_attribute8			IN  VARCHAR2	DEFAULT NULL	,
1431 		p_attribute9			IN  VARCHAR2	DEFAULT NULL	,
1432 		p_attribute10			IN  VARCHAR2	DEFAULT NULL	,
1433 		p_attribute11			IN  VARCHAR2	DEFAULT NULL	,
1434 		p_attribute12			IN  VARCHAR2	DEFAULT NULL	,
1435 		p_attribute13			IN  VARCHAR2	DEFAULT NULL	,
1439 IS
1436 		p_attribute14			IN  VARCHAR2	DEFAULT NULL	,
1437 		p_attribute15			IN  VARCHAR2	DEFAULT NULL	)
1438 
1440 		l_api_name			CONSTANT VARCHAR2(20)	:=	'Update_BR_Assignment';
1441 		l_api_version			CONSTANT NUMBER		:=	1.0;
1442 
1443 		l_trl_rec			ra_customer_trx_lines%ROWTYPE;
1444 		l_ps_rec			ar_payment_schedules%ROWTYPE;
1445 
1446 		l_trx_rec			ra_customer_trx%ROWTYPE;
1447 		l_BR_rec			ra_customer_trx%ROWTYPE;
1448 
1449 BEGIN
1450 
1451 	IF PG_DEBUG in ('Y', 'C') THEN
1452 	   arp_util.debug('AR_BILLS_CREATION_PUB.Update_BR_Assignment()+ ');
1453 	END IF;
1454 
1455 	x_msg_count				:=	NULL;
1456 	x_msg_data				:=	NULL;
1457 
1458 
1459        /*-----------------------------------------------+
1460         |   Standard start of API savepoint     	|
1461         +-----------------------------------------------*/
1462 
1463       	SAVEPOINT Update_BR_Assignment_PVT;
1464 
1465 
1466        /*-----------------------------------------------+
1467         | Standard call to check for call compatibility |
1468         +-----------------------------------------------*/
1469 
1470         IF NOT FND_API.Compatible_API_Call( l_api_version	,
1471                                             p_api_version	,
1472                                             l_api_name		,
1473                                             G_PKG_NAME          )
1474         THEN
1475         	RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1476         END IF;
1477 
1478 
1479        /*-----------------------------------------------+
1480         |   Initialize return status to SUCCESS   	|
1481         +-----------------------------------------------*/
1482 
1483         x_return_status := FND_API.G_RET_STS_SUCCESS;
1484 
1485 
1486        /*-----------------------------------------------+
1487         |   ========  START OF API BODY  ============   |
1488         +-----------------------------------------------*/
1489 
1490 
1491        /*-----------------------------------------------+
1492         |   Data preparation 				|
1493         +----------------------------------------------*/
1494 
1495 	AR_BILLS_CREATION_VAL_PVT.Validate_Customer_trx_line_id (p_customer_trx_line_id);
1496 
1497 	ARP_CTL_PKG.lock_fetch_p (l_trl_rec, p_customer_trx_line_id);
1498 
1499 	l_trl_rec.extended_amount		:=	p_assigned_amount	;
1500 	l_trl_rec.attribute_category		:=	p_attribute_category	;
1501 	l_trl_rec.attribute1			:=	p_attribute1		;
1502 	l_trl_rec.attribute2			:=	p_attribute2		;
1503 	l_trl_rec.attribute3			:=	p_attribute3		;
1504 	l_trl_rec.attribute4			:=	p_attribute4		;
1505 	l_trl_rec.attribute5			:=	p_attribute5		;
1506 	l_trl_rec.attribute6			:=	p_attribute6		;
1507 	l_trl_rec.attribute7			:=	p_attribute7		;
1508 	l_trl_rec.attribute8			:=	p_attribute8		;
1509 	l_trl_rec.attribute9			:=	p_attribute9		;
1510 	l_trl_rec.attribute10			:=	p_attribute10		;
1511 	l_trl_rec.attribute11			:=	p_attribute11		;
1512 	l_trl_rec.attribute12			:=	p_attribute12		;
1513 	l_trl_rec.attribute13			:=	p_attribute13		;
1514 	l_trl_rec.attribute14			:=	p_attribute14		;
1515 	l_trl_rec.attribute15			:=	p_attribute15		;
1516 
1517 
1518 
1519 	/*----------------------------------------------+
1520         |   Data Defaulting 				|
1521         +-----------------------------------------------*/
1522 
1523 
1524 	--  Fetch the BR transaction information
1525 
1526 	ARP_CT_PKG.fetch_p (l_BR_rec, l_trl_rec.customer_trx_id);
1527 
1528 
1529 	--  Fetch the payment schedule information of the exchanged transaction
1530 
1531 	arp_ps_pkg.fetch_p (l_trl_rec.br_ref_payment_schedule_id, l_ps_rec);
1532 
1533 
1534 	--  Fetch the exchanged transaction information
1535 
1536 	ARP_CT_PKG.fetch_p (l_trx_rec, l_trl_rec.br_ref_customer_trx_id);
1537 
1538 
1539 
1540        /*-----------------------------------------------+
1541         |   Data Validation				|
1542         +-----------------------------------------------*/
1543 
1544         AR_BILLS_CREATION_VAL_PVT.Validate_BR_Assignment (l_trl_rec	,
1545 						 	  l_ps_rec	,
1546 							  l_trx_rec	,
1547 							  l_br_rec	);
1548 
1549 
1550        /*-----------------------------------------------+
1551         |   Call the Entity Handler  		     	|
1552         +-----------------------------------------------*/
1553 
1554 	ARP_PROCESS_BR_LINE.update_line  (l_trl_rec.customer_trx_line_id, l_trl_rec);
1555 
1556 
1557        /*-----------------------------------------------+
1558         |   Standard check of p_commit   		|
1559         +-----------------------------------------------*/
1560 
1561         IF FND_API.To_Boolean( p_commit )
1562         THEN
1563             IF PG_DEBUG in ('Y', 'C') THEN
1564                arp_util.debug(  'committing');
1565             END IF;
1566             Commit;
1567         END IF;
1568 
1569         IF PG_DEBUG in ('Y', 'C') THEN
1570            arp_util.debug('AR_BILLS_CREATION_PUB.Update_BR_Assignment()- ');
1571         END IF;
1572 
1573 
1574 EXCEPTION
1575        WHEN FND_API.G_EXC_ERROR THEN
1576 		IF PG_DEBUG in ('Y', 'C') THEN
1577 		   arp_util.debug (  'SQLERRM : ' || SQLERRM);
1578 		   arp_util.debug (  'SQLCODE : ' || SQLCODE);
1579 		END IF;
1580                 ROLLBACK TO Update_BR_Assignment_PVT;
1581                 x_return_status := FND_API.G_RET_STS_ERROR ;
1582 		RAISE;
1583 
1584         WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1585 
1586                 IF PG_DEBUG in ('Y', 'C') THEN
1587                    arp_util.debug (  'SQLERRM : ' || SQLERRM);
1588 		   arp_util.debug (  'SQLCODE : ' || SQLCODE);
1589 		END IF;
1590                 ROLLBACK TO Update_BR_Assignment_PVT;
1591                 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1592 		RAISE;
1596                /*-------------------------------------------------------+
1593 
1594         WHEN OTHERS THEN
1595 
1597                 |  Handle application errors that result from trapable  |
1598                 |  error conditions. The error messages have already    |
1599                 |  been put on the error stack.                         |
1600                 +-------------------------------------------------------*/
1601 
1602 		IF PG_DEBUG in ('Y', 'C') THEN
1603 		   arp_util.debug (  'SQLERRM : ' || SQLERRM);
1604 		   arp_util.debug (  'SQLCODE : ' || SQLCODE);
1605 		END IF;
1606 
1607 
1608 		ROLLBACK TO Update_BR_Assignment_PVT;
1609 
1610 		IF (SQLCODE = -20001)
1611                 THEN
1612                      	x_return_status := FND_API.G_RET_STS_ERROR ;
1613                 ELSE
1614                	      	x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1615                 END IF;
1616 
1617 		RAISE;
1618 
1619 END Update_BR_Assignment;
1620 
1621 
1622 
1623 
1624 /*==============================================================================+
1625  | PROCEDURE                                                                 	|
1626  |    Delete_BR_Assignment			                               	|
1627  |                                                                           	|
1628  | DESCRIPTION                                                               	|
1629  |    Delete BR Assignment information					     	|
1630  |									  	|
1631  +==============================================================================*/
1632 
1633 
1634 PROCEDURE Delete_BR_Assignment (
1635 
1636            --   *****  Standard API parameters *****
1637                 p_api_version      		IN  NUMBER			,
1638                 p_init_msg_list    		IN  VARCHAR2 := FND_API.G_TRUE	,
1639                 p_commit           		IN  VARCHAR2 := FND_API.G_FALSE	,
1640                 p_validation_level 		IN  NUMBER   := FND_API.G_VALID_LEVEL_FULL,
1641                 x_return_status    		OUT NOCOPY VARCHAR2			,
1642                 x_msg_count        		OUT NOCOPY NUMBER			,
1643                 x_msg_data         		OUT NOCOPY VARCHAR2			,
1644 
1645            --   *****  BR Assignment information parameters *****
1646 		p_customer_trx_id		IN  NUMBER	DEFAULT NULL	,
1647 		p_customer_trx_line_id		IN  NUMBER	DEFAULT NULL	)
1648 
1649 IS
1650 		l_api_name			CONSTANT VARCHAR2(20)	:=	'Delete_BR_Assignment';
1651 		l_api_version			CONSTANT NUMBER		:=	1.0;
1652 		l_trl_rec			ra_customer_trx_lines%ROWTYPE;
1653 		l_BR_rec			ra_customer_trx%ROWTYPE;
1654 
1655 
1656 BEGIN
1657 
1658        	IF PG_DEBUG in ('Y', 'C') THEN
1659        	   arp_util.debug('AR_BILLS_CREATION_PUB.Delete_BR_Assignment()+ ');
1660        	END IF;
1661 
1662        	x_msg_count				:=	NULL;
1663 	x_msg_data				:=	NULL;
1664 
1665        /*-----------------------------------------------+
1666         |   Standard start of API savepoint     	|
1667         +-----------------------------------------------*/
1668 
1669       	SAVEPOINT Delete_BR_Assignment_PVT;
1670 
1671 
1672        /*-----------------------------------------------+
1673         | Standard call to check for call compatibility |
1674         +-----------------------------------------------*/
1675 
1676         IF NOT FND_API.Compatible_API_Call( l_api_version	,
1677                                             p_api_version	,
1678                                             l_api_name		,
1679                                             G_PKG_NAME          )
1680         THEN
1681         	RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1682         END IF;
1683 
1684 
1685        /*-----------------------------------------------+
1686         |   Initialize return status to SUCCESS   	|
1687         +-----------------------------------------------*/
1688 
1689         x_return_status := FND_API.G_RET_STS_SUCCESS;
1690 
1691 
1692        /*-----------------------------------------------+
1693         |   ========  START OF API BODY  ============   |
1694         +-----------------------------------------------*/
1695 
1696        /*-----------------------------------------------+
1697         |   Data preparation 				|
1698         +----------------------------------------------*/
1699 
1700 	AR_BILLS_CREATION_VAL_PVT.Validate_Customer_trx_line_id (p_customer_trx_line_id);
1701 
1702 	--  Fetch the Assignment information
1703 	arp_ctl_pkg.fetch_p (l_trl_rec, p_customer_trx_line_id);
1704 
1705 	--  Fetch the BR transaction information
1706 	ARP_CT_PKG.fetch_p (l_BR_rec, l_trl_rec.customer_trx_id);
1707 
1708 
1709        /*-----------------------------------------------+
1710         |   Data Validation				|
1711         +-----------------------------------------------*/
1712 
1713         --  Validate the status of the BR (must be INCOMPLETE)
1714 
1715 	AR_BILLS_CREATION_VAL_PVT.Validate_BR_Status (l_trl_rec.customer_trx_id);
1716 
1717 
1718        /*-----------------------------------------------+
1719         |   Call the Entity Handler  		     	|
1720         +-----------------------------------------------*/
1721 
1722 	ARP_PROCESS_BR_LINE.Delete_line  (p_customer_trx_line_id, l_trl_rec.customer_trx_id);
1723 
1724        /*-----------------------------------------------+
1725         |   Standard check of p_commit   		|
1726         +-----------------------------------------------*/
1727 
1728         IF FND_API.To_Boolean( p_commit )
1729         THEN
1730             IF PG_DEBUG in ('Y', 'C') THEN
1731                arp_util.debug(  'committing');
1732             END IF;
1733             Commit;
1734         END IF;
1735 
1739 
1736         IF PG_DEBUG in ('Y', 'C') THEN
1737            arp_util.debug('AR_BILLS_CREATION_PUB.Delete_BR_Assignment()- ');
1738         END IF;
1740 
1741 EXCEPTION
1742        WHEN FND_API.G_EXC_ERROR THEN
1743 
1744                 IF PG_DEBUG in ('Y', 'C') THEN
1745                    arp_util.debug (  'SQLERRM : ' || SQLERRM);
1746 		   arp_util.debug (  'SQLCODE : ' || SQLCODE);
1747 		END IF;
1748                 ROLLBACK TO Delete_BR_Assignment_PVT;
1749                 x_return_status := FND_API.G_RET_STS_ERROR ;
1750   	        IF PG_DEBUG in ('Y', 'C') THEN
1751   	           arp_util.debug(  'Exception Error');
1752   	        END IF;
1753 		RAISE;
1754 
1755         WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1756 
1757                 IF PG_DEBUG in ('Y', 'C') THEN
1758                    arp_util.debug (  'SQLERRM : ' || SQLERRM);
1759 		   arp_util.debug (  'SQLCODE : ' || SQLCODE);
1760 		END IF;
1761                 ROLLBACK TO Delete_BR_Assignment_PVT;
1762                 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1763 		IF PG_DEBUG in ('Y', 'C') THEN
1764 		   arp_util.debug(  'Exception Unexpected Error');
1765 		END IF;
1766 		RAISE;
1767 
1768         WHEN OTHERS THEN
1769 
1770                /*-------------------------------------------------------+
1771                 |  Handle application errors that result from trapable  |
1772                 |  error conditions. The error messages have already    |
1773                 |  been put on the error stack.                         |
1774                 +-------------------------------------------------------*/
1775 
1776 		IF PG_DEBUG in ('Y', 'C') THEN
1777 		   arp_util.debug (  'SQLERRM : ' || SQLERRM);
1778 		   arp_util.debug (  'SQLCODE : ' || SQLCODE);
1779 		END IF;
1780 
1781 		ROLLBACK TO Delete_BR_Assignment_PVT;
1782 
1783 		IF (SQLCODE = -20001)
1784                 THEN
1785                      	x_return_status := FND_API.G_RET_STS_ERROR ;
1786                 ELSE
1787                	      	x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1788                 END IF;
1789 
1790 		RAISE;
1791 
1792 END Delete_BR_Assignment;
1793 
1794 
1795 
1796 /*==============================================================================+
1797  | PROCEDURE                                                                 	|
1798  |    Lock_BR_Assignment			                               	|
1799  |                                                                           	|
1800  | DESCRIPTION                                                               	|
1801  |    Lock BR Assignment information					     	|
1802  |									  	|
1803  +==============================================================================*/
1804 
1805 
1806 PROCEDURE Lock_BR_Assignment (
1807 
1808            --   *****  Standard API parameters *****
1809                 p_api_version      		IN  NUMBER			,
1810                 p_init_msg_list    		IN  VARCHAR2 := FND_API.G_TRUE	,
1811                 p_commit           		IN  VARCHAR2 := FND_API.G_FALSE	,
1812                 p_validation_level 		IN  NUMBER   := FND_API.G_VALID_LEVEL_FULL,
1813                 x_return_status    		OUT NOCOPY VARCHAR2			,
1814                 x_msg_count        		OUT NOCOPY NUMBER			,
1815                 x_msg_data         		OUT NOCOPY VARCHAR2			,
1816 
1817            --   *****  BR Assignment information parameters *****
1818 		p_customer_trx_id		IN  NUMBER	DEFAULT NULL	,
1819 		p_customer_trx_line_id		IN  NUMBER	DEFAULT NULL	,
1820 		p_br_ref_payment_schedule_id	IN  NUMBER	DEFAULT NULL	,
1821 		p_assigned_amount		IN  NUMBER	DEFAULT NULL	,
1822 
1823            --   ***** Descriptive Flexfield parameters *****
1824                 p_attribute_category		IN  VARCHAR2	DEFAULT NULL	,
1825 		p_attribute1			IN  VARCHAR2	DEFAULT NULL	,
1826 		p_attribute2			IN  VARCHAR2	DEFAULT NULL	,
1827 		p_attribute3			IN  VARCHAR2	DEFAULT NULL	,
1828 		p_attribute4			IN  VARCHAR2	DEFAULT NULL	,
1829 		p_attribute5			IN  VARCHAR2	DEFAULT NULL	,
1830 		p_attribute6			IN  VARCHAR2	DEFAULT NULL	,
1831 		p_attribute7			IN  VARCHAR2	DEFAULT NULL	,
1832 		p_attribute8			IN  VARCHAR2	DEFAULT NULL	,
1833 		p_attribute9			IN  VARCHAR2	DEFAULT NULL	,
1834 		p_attribute10			IN  VARCHAR2	DEFAULT NULL	,
1835 		p_attribute11			IN  VARCHAR2	DEFAULT NULL	,
1836 		p_attribute12			IN  VARCHAR2	DEFAULT NULL	,
1837 		p_attribute13			IN  VARCHAR2	DEFAULT NULL	,
1838 		p_attribute14			IN  VARCHAR2	DEFAULT NULL	,
1839 		p_attribute15			IN  VARCHAR2	DEFAULT NULL	)
1840 
1841 IS
1842 		l_api_name			CONSTANT VARCHAR2(20)	:=	'Lock_BR_Assignment';
1843 		l_api_version			CONSTANT NUMBER		:=	1.0;
1844 
1845 		l_trl_rec			ra_customer_trx_lines%ROWTYPE;
1846 
1847 
1848 BEGIN
1849 
1850        	IF PG_DEBUG in ('Y', 'C') THEN
1851        	   arp_util.debug('AR_BILLS_CREATION_PUB.Lock_BR_Assignment()+ ');
1852        	END IF;
1853 
1854        	x_msg_count				:=	NULL;
1855 	x_msg_data				:=	NULL;
1856 
1857 
1858        /*-----------------------------------------------+
1859         |   Standard start of API savepoint     	|
1860         +-----------------------------------------------*/
1861 
1862       	SAVEPOINT Lock_BR_Assignment_PVT;
1863 
1864 
1865        /*-----------------------------------------------+
1866         | Standard call to check for call compatibility |
1867         +-----------------------------------------------*/
1868 
1869         IF NOT FND_API.Compatible_API_Call( l_api_version	,
1870                                             p_api_version	,
1871                                             l_api_name		,
1872                                             G_PKG_NAME          )
1873         THEN
1874         	RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1875         END IF;
1876 
1877 
1881 
1878        /*-----------------------------------------------+
1879         |   Initialize return status to SUCCESS   	|
1880         +-----------------------------------------------*/
1882         x_return_status := FND_API.G_RET_STS_SUCCESS;
1883 
1884 
1885        /*-----------------------------------------------+
1886         |   ========  START OF API BODY  ============   |
1887         +-----------------------------------------------*/
1888 
1889        /*-----------------------------------------------+
1890         |   Data preparation 				|
1891         +-----------------------------------------------*/
1892 
1893 	AR_BILLS_CREATION_VAL_PVT.Validate_Customer_trx_line_id (p_customer_trx_line_id);
1894 
1895 	arp_ctl_pkg.set_to_dummy (l_trl_rec);
1896 
1897 	l_trl_rec.customer_trx_id		:=	p_customer_trx_id	;
1898 	l_trl_rec.customer_trx_line_id		:=	p_customer_trx_line_id	;
1899 	l_trl_rec.br_ref_payment_schedule_id	:=	p_br_ref_payment_schedule_id;
1900 	l_trl_rec.extended_amount		:=	p_assigned_amount	;
1901 
1902 	l_trl_rec.attribute_category		:=	p_attribute_category	;
1903 	l_trl_rec.attribute1			:=	p_attribute1		;
1904 	l_trl_rec.attribute2			:=	p_attribute2		;
1905 	l_trl_rec.attribute3			:=	p_attribute3		;
1906 	l_trl_rec.attribute4			:=	p_attribute4		;
1907 	l_trl_rec.attribute5			:=	p_attribute5		;
1908 	l_trl_rec.attribute6			:=	p_attribute6		;
1909 	l_trl_rec.attribute7			:=	p_attribute7		;
1910 	l_trl_rec.attribute8			:=	p_attribute8		;
1911 	l_trl_rec.attribute9			:=	p_attribute9		;
1912 	l_trl_rec.attribute10			:=	p_attribute10		;
1913 	l_trl_rec.attribute11			:=	p_attribute11		;
1914 	l_trl_rec.attribute12			:=	p_attribute12		;
1915 	l_trl_rec.attribute13			:=	p_attribute13		;
1916 	l_trl_rec.attribute14			:=	p_attribute14		;
1917 	l_trl_rec.attribute15			:=	p_attribute15		;
1918 
1919        /*-----------------------------------------------+
1920         |   Call the Table Handler    			|
1921         +-----------------------------------------------*/
1922 
1923 	ARP_CTL_PKG.lock_compare_p  (l_trl_rec, p_customer_trx_line_id);
1924 
1925         IF PG_DEBUG in ('Y', 'C') THEN
1926            arp_util.debug('AR_BILLS_CREATION_PUB.Lock_BR_Assignment()- ');
1927         END IF;
1928 
1929 EXCEPTION
1930        WHEN FND_API.G_EXC_ERROR THEN
1931 
1932                 IF PG_DEBUG in ('Y', 'C') THEN
1933                    arp_util.debug (  'SQLERRM : ' || SQLERRM);
1934 		   arp_util.debug (  'SQLCODE : ' || SQLCODE);
1935 		END IF;
1936                 ROLLBACK TO Lock_BR_Assignment_PVT;
1937                 x_return_status := FND_API.G_RET_STS_ERROR ;
1938   	        RAISE;
1939 
1940         WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1941 
1942                 IF PG_DEBUG in ('Y', 'C') THEN
1943                    arp_util.debug (  'SQLERRM : ' || SQLERRM);
1944 		   arp_util.debug (  'SQLCODE : ' || SQLCODE);
1945 		END IF;
1946                 ROLLBACK TO Lock_BR_Assignment_PVT;
1947                 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1948 		RAISE;
1949 
1950         WHEN OTHERS THEN
1951 
1952                /*-------------------------------------------------------+
1953                 |  Handle application errors that result from trapable  |
1954                 |  error conditions. The error messages have already    |
1955                 |  been put on the error stack.                         |
1956                 +-------------------------------------------------------*/
1957 
1958 		IF PG_DEBUG in ('Y', 'C') THEN
1959 		   arp_util.debug (  'SQLERRM : ' || SQLERRM);
1960 		   arp_util.debug (  'SQLCODE : ' || SQLCODE);
1961 		END IF;
1962 
1963 		ROLLBACK TO Lock_BR_Assignment_PVT;
1964 
1965 		IF (SQLCODE = -20001)
1966                 THEN
1967                       x_return_status := FND_API.G_RET_STS_ERROR ;
1968                 ELSE
1969                       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1970                 END IF;
1971 
1972 		RAISE;
1973 
1974 END Lock_BR_Assignment;
1975 
1976 
1977 /*==============================================================================+
1978  | PROCEDURE                                                                    |
1979  |    Create_BR_Trxn_Extension                                                  |
1980  |                                                                              |
1981  | DESCRIPTION                                                                  |
1982  |    Creates payment trxn extension details via IBY API                        |
1983  |                                                                              |
1984  +==============================================================================*/
1985 
1986 PROCEDURE Create_BR_Trxn_Extension(
1987 
1988            --   *****  Standard API parameters *****
1989                 p_api_version                   IN  NUMBER                      ,
1990                 p_init_msg_list                 IN  VARCHAR2 := FND_API.G_TRUE  ,
1991                 p_commit                        IN  VARCHAR2 := FND_API.G_FALSE ,
1992                 x_return_status                 OUT NOCOPY VARCHAR2             ,
1993                 x_msg_count                     OUT NOCOPY NUMBER               ,
1994                 x_msg_data                      OUT NOCOPY VARCHAR2             ,
1995 
1996            --   *****  BR Header information parameters *****
1997                 p_customer_trx_id               IN  NUMBER      DEFAULT NULL    ,
1998                 p_trx_number                    IN  VARCHAR2    DEFAULT NULL    ,
1999                 p_org_id                        IN  NUMBER      DEFAULT NULL    ,
2000                 p_drawee_id                     IN  NUMBER      DEFAULT NULL    ,
2001                 p_drawee_site_use_id            IN  NUMBER      DEFAULT NULL    ,
2002                 p_payment_channel               IN  VARCHAR2    DEFAULT NULL    ,
2006 IS
2003                 p_instrument_assign_id          IN  NUMBER      DEFAULT NULL    ,
2004            --   ***** OUTPUT variables *****
2005                 p_payment_trxn_extn_id          OUT NOCOPY NUMBER              )
2007     l_payer_rec            IBY_FNDCPT_COMMON_PUB.payercontext_rec_type;
2008     l_trxn_attribs_rec     IBY_FNDCPT_TRXN_PUB.trxnextension_rec_type;
2009     l_response             IBY_FNDCPT_COMMON_PUB.result_rec_type;
2010     l_payment_channel      ar_receipt_methods.payment_channel_code%type;
2011 Begin
2012         arp_standard.debug('AR_BILLS_CREATION_PUB.Create_BR_Trxn_Extension()+ ');
2013         x_msg_count          := NULL;
2014         x_msg_data           := NULL;
2015         x_return_status      := FND_API.G_RET_STS_SUCCESS;
2016         l_payer_rec.party_id :=  arp_trx_defaults_3.get_party_Id(P_DRAWEE_ID);
2017         l_payer_rec.payment_function                  := 'CUSTOMER_PAYMENT';
2018         l_payer_rec.org_type                          := 'OPERATING_UNIT';
2019         l_payer_rec.cust_account_id                   :=  P_DRAWEE_ID;
2020         l_payer_rec.org_id                            :=  P_ORG_ID;
2021         l_payer_rec.account_site_id                   :=  P_DRAWEE_SITE_USE_ID;
2022         l_payment_channel                             := 'BILLS_RECEIVABLE';
2023         l_trxn_attribs_rec.originating_application_id := 222;
2024         l_trxn_attribs_rec.trxn_ref_number1           := 'BILLS_RECEIVABLE';
2025         l_trxn_attribs_rec.order_id                   := P_TRX_NUMBER;
2026         l_trxn_attribs_rec.trxn_ref_number2           := P_CUSTOMER_TRX_ID;
2027 
2028            /*-------------------------+
2029             |   Call the IBY API      |
2030             +-------------------------*/
2031             arp_standard.debug('Call TO IBY API ()+ ');
2032 
2033             IBY_FNDCPT_TRXN_PUB.create_transaction_extension(
2034                p_api_version           => 1.0,
2035                p_init_msg_list         => p_init_msg_list,
2036                p_commit                => p_commit,
2037                x_return_status         => x_return_status,
2038                x_msg_count             => x_msg_count,
2039                x_msg_data              => x_msg_data,
2040                p_payer                 => l_payer_rec,
2041                p_payer_equivalency     => 'UPWARD',
2042                p_pmt_channel           => l_payment_channel,
2043                p_instr_assignment      => p_instrument_assign_id,
2044                p_trxn_attribs          => l_trxn_attribs_rec,
2045                x_entity_id             => p_payment_trxn_extn_id,
2046                x_response              => l_response);
2047 
2048     IF x_return_status  = fnd_api.g_ret_sts_success
2049     THEN
2050        arp_standard.debug('Payment_Trxn_Extension_Id : ' || p_payment_trxn_extn_id);
2051     Else
2052        arp_standard.debug('Errors Reported by IBY API: ');
2053     END IF;
2054 EXCEPTION
2055      WHEN OTHERS THEN
2056        arp_standard.debug('exception in AR_BILLS_CREATION_PUB.Create_BR_Trxn_Extension ');
2057        RAISE;
2058 END Create_BR_Trxn_Extension;
2059 
2060 
2061 
2062 /*==============================================================================+
2063  | PROCEDURE                                                                    |
2064  |   Update_BR_Trxn_Extension                                                  |
2065  |                                                                              |
2066  | DESCRIPTION                                                                  |
2067  |    Updates  payment trxn extension details via IBY API                        |
2068  |                                                                              |
2069  +==============================================================================*/
2070 
2071 PROCEDURE Update_BR_Trxn_Extension(
2072 
2073            --   *****  Standard API parameters *****
2074                 p_api_version                   IN  NUMBER                      ,
2075                 p_init_msg_list                 IN  VARCHAR2 := FND_API.G_TRUE  ,
2076                 p_commit                        IN  VARCHAR2 := FND_API.G_FALSE ,
2077                 x_return_status                 OUT NOCOPY VARCHAR2             ,
2078                 x_msg_count                     OUT NOCOPY NUMBER               ,
2079                 x_msg_data                      OUT NOCOPY VARCHAR2             ,
2080 
2081            --   *****  BR Header information parameters *****
2082                 p_customer_trx_id               IN  NUMBER      DEFAULT NULL    ,
2083                 p_trx_number                    IN  VARCHAR2    DEFAULT NULL    ,
2084                 p_org_id                        IN  NUMBER      DEFAULT NULL    ,
2085                 p_drawee_id                     IN  NUMBER      DEFAULT NULL    ,
2086                 p_drawee_site_use_id            IN  NUMBER      DEFAULT NULL    ,
2090 IS
2087                 p_payment_channel               IN  VARCHAR2    DEFAULT NULL    ,
2088                 p_instrument_assign_id          IN  NUMBER      DEFAULT NULL    ,
2089                 p_payment_trxn_extn_id          IN  IBY_TRXN_EXTENSIONS_V.TRXN_EXTENSION_ID%TYPE    )
2091     l_payer_rec            IBY_FNDCPT_COMMON_PUB.payercontext_rec_type;
2092     l_trxn_attribs_rec     IBY_FNDCPT_TRXN_PUB.trxnextension_rec_type;
2093     l_response             IBY_FNDCPT_COMMON_PUB.result_rec_type;
2094     l_payment_channel      ar_receipt_methods.payment_channel_code%type;
2095 Begin
2096         arp_standard.debug('AR_BILLS_CREATION_PUB.Update_BR_Trxn_Extension()+ ');
2097         x_msg_count          := NULL;
2098         x_msg_data           := NULL;
2099         x_return_status      := FND_API.G_RET_STS_SUCCESS;
2100         l_payer_rec.party_id :=  arp_trx_defaults_3.get_party_Id(P_DRAWEE_ID);
2101         l_payer_rec.payment_function                  := 'CUSTOMER_PAYMENT';
2102         l_payer_rec.org_type                          := 'OPERATING_UNIT';
2103         l_payer_rec.cust_account_id                   :=  P_DRAWEE_ID;
2104         l_payer_rec.org_id                            :=  P_ORG_ID;
2105         l_payer_rec.account_site_id                   :=  P_DRAWEE_SITE_USE_ID;
2106         l_payment_channel                             := 'BILLS_RECEIVABLE';
2107         l_trxn_attribs_rec.originating_application_id := 222;
2108         l_trxn_attribs_rec.trxn_ref_number1           := 'BILLS_RECEIVABLE';
2109         l_trxn_attribs_rec.order_id                   := P_TRX_NUMBER;
2110         l_trxn_attribs_rec.trxn_ref_number2           := P_CUSTOMER_TRX_ID;
2111 
2112            /*-------------------------+
2113             |   Call the IBY API      |
2114             +-------------------------*/
2115             arp_standard.debug('Call TO IBY API ()+ ');
2116 
2117             IBY_FNDCPT_TRXN_PUB.update_transaction_extension(
2118                p_api_version           => 1.0,
2119                p_init_msg_list         => p_init_msg_list,
2120                p_commit                => p_commit,
2121                x_return_status         => x_return_status,
2122                x_msg_count             => x_msg_count,
2123                x_msg_data              => x_msg_data,
2124                p_payer                 => l_payer_rec,
2125                p_payer_equivalency     => 'UPWARD',
2126                p_pmt_channel           => l_payment_channel,
2127                p_instr_assignment      => nvl(p_instrument_assign_id,FND_API.G_MISS_NUM),
2128                p_trxn_attribs          => l_trxn_attribs_rec,
2129                p_entity_id             => p_payment_trxn_extn_id,
2130                x_response              => l_response);
2131 
2132     IF x_return_status  = fnd_api.g_ret_sts_success
2133     THEN
2134        arp_standard.debug('Payment_Trxn_Extension_Id : ' || p_payment_trxn_extn_id);
2135     Else
2136        arp_standard.debug('Errors Reported by IBY API:Update Transaction Extension ');
2137     END IF;
2138 EXCEPTION
2139      WHEN OTHERS THEN
2140        arp_standard.debug('exception in AR_BILLS_CREATION_PUB.Update_BR_Trxn_Extension ');
2141        RAISE;
2142 END Update_BR_Trxn_Extension;
2143 
2144 
2145 
2146 /*==============================================================================+
2147  | PROCEDURE                                                                    |
2148  |   Delete_BR_Trxn_Extension      	                                        |
2149  |                                                                              |
2150  | DESCRIPTION                                                                  |
2151  |    Deletes  payment trxn extension details via IBY API                       |
2152  |                                                                              |
2153  +==============================================================================*/
2154 
2155 PROCEDURE Delete_BR_Trxn_Extension(
2156 
2157            --   *****  Standard API parameters *****
2158                 p_api_version                   IN  NUMBER                      ,
2159                 p_init_msg_list                 IN  VARCHAR2 := FND_API.G_TRUE  ,
2160                 p_commit                        IN  VARCHAR2 := FND_API.G_FALSE ,
2161                 x_return_status                 OUT NOCOPY VARCHAR2             ,
2162                 x_msg_count                     OUT NOCOPY NUMBER               ,
2163                 x_msg_data                      OUT NOCOPY VARCHAR2             ,
2164 
2165            --   *****  BR Header information parameters *****
2166                 p_customer_trx_id               IN  NUMBER      DEFAULT NULL    ,
2167                 p_trx_number                    IN  VARCHAR2    DEFAULT NULL    ,
2168                 p_org_id                        IN  NUMBER      DEFAULT NULL    ,
2169                 p_drawee_id                     IN  NUMBER      DEFAULT NULL    ,
2170                 p_drawee_site_use_id            IN  NUMBER      DEFAULT NULL    ,
2171                 p_payment_channel               IN  VARCHAR2    DEFAULT NULL    ,
2172                 p_instrument_assign_id          IN  NUMBER      DEFAULT NULL    ,
2173                 p_payment_trxn_extn_id          IN  IBY_TRXN_EXTENSIONS_V.TRXN_EXTENSION_ID%TYPE    )
2174 IS
2175     l_payer_rec            IBY_FNDCPT_COMMON_PUB.payercontext_rec_type;
2176     l_trxn_attribs_rec     IBY_FNDCPT_TRXN_PUB.trxnextension_rec_type;
2177     l_response             IBY_FNDCPT_COMMON_PUB.result_rec_type;
2178     l_payment_channel      ar_receipt_methods.payment_channel_code%type;
2179 Begin
2180         arp_standard.debug('AR_BILLS_CREATION_PUB.Delete_BR_Trxn_Extension()+ ');
2181         x_msg_count          := NULL;
2182         x_msg_data           := NULL;
2183         x_return_status      := FND_API.G_RET_STS_SUCCESS;
2184         l_payer_rec.party_id :=  arp_trx_defaults_3.get_party_Id(P_DRAWEE_ID);
2188         l_payer_rec.org_id                            :=  P_ORG_ID;
2185         l_payer_rec.payment_function                  := 'CUSTOMER_PAYMENT';
2186         l_payer_rec.org_type                          := 'OPERATING_UNIT';
2187         l_payer_rec.cust_account_id                   :=  P_DRAWEE_ID;
2189         l_payer_rec.account_site_id                   :=  NVL(ARP_PROGRAM_BR_REMIT.get_site_use_id(
2190                                                           p_cust_account_id   => P_DRAWEE_ID,
2191                                                           p_org_id            => p_org_id,
2192                                                           p_instr_id          => p_instrument_assign_id),
2193                                                           p_drawee_site_use_id); -- Modified for Bug 1386014
2194 
2195            /*-------------------------+
2196             |   Call the IBY API      |
2197             +-------------------------*/
2198             arp_standard.debug('Call TO IBY API ()+ ');
2199 
2200             IBY_FNDCPT_TRXN_PUB.delete_transaction_extension(
2201                p_api_version           => 1.0,
2202                p_init_msg_list         => p_init_msg_list,
2203                p_commit                => p_commit,
2204                x_return_status         => x_return_status,
2205                x_msg_count             => x_msg_count,
2206                x_msg_data              => x_msg_data,
2207                p_payer                 => l_payer_rec,
2208                p_payer_equivalency     => 'UPWARD',
2209                p_entity_id             => p_payment_trxn_extn_id,
2210                x_response              => l_response);
2211 
2212     IF x_return_status  = fnd_api.g_ret_sts_success
2213     THEN
2214        arp_standard.debug('Payment_Trxn_Extension_Id : ' || p_payment_trxn_extn_id);
2215     Else
2216        arp_standard.debug('Errors Reported by IBY API:Delete Transaction Extension ');
2217     END IF;
2218 EXCEPTION
2219      WHEN OTHERS THEN
2220        arp_standard.debug('exception in AR_BILLS_CREATION_PUB.Delete_BR_Trxn_Extension ');
2221        RAISE;
2222 END Delete_BR_Trxn_Extension;
2223 
2224 
2225 
2226 
2227 
2228 /*===========================================================================+
2229  | FUNCTION                                                                  |
2230  |    revision                                                               |
2231  |                                                                           |
2232  | DESCRIPTION                                                               |
2233  |    This function returns the revision number of this package.             |
2234  |                                                                           |
2235  | SCOPE - PUBLIC                                                            |
2236  |                                                                           |
2237  | RETURNS    : Revision number of this package                              |
2238  |                                                                           |
2239  | MODIFICATION HISTORY                                                      |
2240  |      10 JAN 2001 John HALL           Created                              |
2241  +===========================================================================*/
2242 FUNCTION revision RETURN VARCHAR2 IS
2243 BEGIN
2244   RETURN '$Revision: 120.11.12020000.2 $';
2245 END revision;
2246 --
2247 
2248 END AR_BILLS_CREATION_PUB;
2249