1 PACKAGE BODY OE_Validate_Header_Payment AS
2 /* $Header: OEXLHPMB.pls 120.6.12020000.2 2013/02/19 05:04:08 kadiraju ship $ */
3
4 -- Global constant holding the package name
5
6 G_PKG_NAME CONSTANT VARCHAR2(30) := 'OE_Validate_Header_Payment';
7
8 -- Procedure Entity
9
10 PROCEDURE Entity
11 ( x_return_status OUT NOCOPY VARCHAR2
12 , p_Header_Payment_rec IN OE_Order_PUB.Header_Payment_Rec_Type
13 , p_old_Header_Payment_rec IN OE_Order_PUB.Header_Payment_Rec_Type :=
14 OE_Order_PUB.G_MISS_HEADER_PAYMENT_REC
15 )
16 IS
17 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
18 l_prepay_payment_amount NUMBER := 0;
19 l_prepaid_amount NUMBER := 0;
20 l_count NUMBER := 0;
21 l_line_payment_count NUMBER := 0;
22 --R12 CC Encryption
23 l_invoice_to_org_id NUMBER;
24 BEGIN
25
26 OE_DEBUG_PUB.Add('Entering OE_VALIDATE_Header_Payments.Entity',1);
27 -- Check required attributes.
28
29 IF p_Header_Payment_rec.payment_number IS NULL
30 THEN
31
32 l_return_status := FND_API.G_RET_STS_ERROR;
33
34 IF oe_msg_pub.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
35 THEN
36
37 FND_MESSAGE.SET_NAME('ONT','OE_ATTRIBUTE_REQUIRED');
38 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','payment');
39 oe_msg_pub.Add;
40
41 END IF;
42
43 END IF;
44
45 IF p_Header_Payment_rec.payment_type_code IS NULL
46 THEN
47
48 l_return_status := FND_API.G_RET_STS_ERROR;
49
50 IF oe_msg_pub.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
51 THEN
52
53 FND_MESSAGE.SET_NAME('ONT','OE_ATTRIBUTE_REQUIRED');
54 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','payment type code');
55 oe_msg_pub.Add;
56
57 END IF;
58
59 END IF;
60
61 IF p_Header_Payment_rec.payment_collection_event = 'PREPAY' THEN
62
63 /*
64 IF p_Header_Payment_rec.receipt_method_id is null THEN
65
66 l_return_status := FND_API.G_RET_STS_ERROR;
67
68 IF oe_msg_pub.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
69 THEN
70
71 FND_MESSAGE.SET_NAME('ONT','OE_ATTRIBUTE_REQUIRED');
72 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','Receipt Method');
73 oe_msg_pub.Add;
74
75 END IF;
76
77 END IF;
78 */
79
80 -- Modified for Bug 8478559. This will allow users to save Payment record by specifying either the Payment Amount or Payment Percentage for Prepayment case.
81 -- One of them is mandatory. This is for Credit Card and Debit Card payment types only. For other Payment Types, Payment Amount will continue to be mandatory.
82 IF p_Header_Payment_rec.payment_type_code in ('CREDIT_CARD', 'DIRECT_DEBIT') THEN
83 IF p_Header_Payment_rec.payment_amount is null AND
84 p_Header_Payment_rec.payment_percentage is null
85 THEN
86
87 l_return_status := FND_API.G_RET_STS_ERROR;
88
89 IF oe_msg_pub.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
90 THEN
91
92 FND_MESSAGE.SET_NAME('ONT','OE_ATTRIBUTE_REQUIRED');
93 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','payment amount or percentage');
94 oe_msg_pub.Add;
95
96 END IF;
97 END IF;
98 ELSE
99 IF p_Header_Payment_rec.payment_amount is null
100 THEN
101
102 l_return_status := FND_API.G_RET_STS_ERROR;
103
104 IF oe_msg_pub.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
105 THEN
106
107 FND_MESSAGE.SET_NAME('ONT','OE_ATTRIBUTE_REQUIRED');
108 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','payment amount');
109 oe_msg_pub.Add;
110
111 END IF;
112 END IF;
113 END IF;
114 -- End of changes for bug 8478559
115 --commented for bug 8478559
116 /*IF p_Header_Payment_rec.payment_amount is null THEN
117
118 l_return_status := FND_API.G_RET_STS_ERROR;
119
120 IF oe_msg_pub.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
121 THEN
122
123 FND_MESSAGE.SET_NAME('ONT','OE_ATTRIBUTE_REQUIRED');
124 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','payment amount');
125 oe_msg_pub.Add;
126
127 END IF;
128
129 END IF;*/
130
131 IF p_Header_Payment_rec.payment_amount < 0 THEN
132
133 l_return_status := FND_API.G_RET_STS_ERROR;
134
135 IF oe_msg_pub.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
136 THEN
137
138 FND_MESSAGE.SET_NAME('ONT','ONT_NO_NEGTIVE_PAYMENT_AMOUNT');
139 oe_msg_pub.Add;
140
141 END IF;
142
143 END IF;
144
145 /* Removed the following validation.
146 -- total prepayment payment amount cannot be greater than order total.
147 BEGIN
148 select nvl(sum(payment_amount),0)
149 into l_prepay_payment_amount
150 from oe_payments
151 where header_id = p_Header_Payment_rec.header_id
152 and payment_collection_event = 'PREPAY'
153 and prepaid_amount is null
154 and nvl(payment_number, -1) <> nvl(p_Header_Payment_rec.payment_number, -1);
155 EXCEPTION WHEN NO_DATA_FOUND THEN
156 l_prepay_payment_amount := 0;
157 END;
158
159
160 BEGIN
161 select nvl(sum(prepaid_amount),0)
162 into l_prepaid_amount
163 from oe_payments
164 where header_id = p_Header_Payment_rec.header_id
165 and prepaid_amount is not null
166 and nvl(payment_number, -1) <> nvl(p_Header_Payment_rec.payment_number, -1);
167 EXCEPTION WHEN NO_DATA_FOUND THEN
168 l_prepaid_amount := 0;
169 END;
170
171 l_prepay_payment_amount := l_prepay_payment_amount
172 + l_prepaid_amount;
173
174 IF (p_Header_Payment_rec.payment_amount + l_prepay_payment_amount)
175 > OE_OE_TOTALS_SUMMARY.Outbound_Order_Total(p_Header_Payment_rec.header_id) THEN
176
177 l_return_status := FND_API.G_RET_STS_ERROR;
178
179 IF oe_msg_pub.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
180 THEN
181
182 FND_MESSAGE.SET_NAME('ONT','ONT_PREPAYMENT_PERCENT');
183 oe_msg_pub.Add;
184
185 END IF;
186
187 END IF;
188 */
189
190
191
192 -- if there exists any line level payment.
193 select count(payment_type_code) into l_line_payment_count
194 from oe_payments
195 where header_id = p_Header_Payment_rec.header_id
196 and line_id is not null
197 and payment_type_code <> 'COMMITMENT';
198
199 if l_line_payment_count > 0 then
200
201 IF oe_msg_pub.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
202 THEN
203 fnd_message.set_name('ONT', 'ONT_LINE_PAYMENTS_EXIST');
204 oe_msg_pub.add;
205 END IF;
206
207 l_return_status := FND_API.G_RET_STS_ERROR;
208
209 end if;
210
211 END IF; -- if payment_collection_event = 'PREPAY'
212
213 -- Check rest of required attributes here.
214 --
215
216 IF p_Header_Payment_rec.HEADER_ID IS NULL
217 THEN
218
219 l_return_status := FND_API.G_RET_STS_ERROR;
220
221 IF oe_msg_pub.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
222 THEN
223
224 FND_MESSAGE.SET_NAME('ONT','OE_ATTRIBUTE_REQUIRED');
225 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','HEADER');
226 oe_msg_pub.Add;
227
228 END IF;
229
230 END IF;
231
232 IF p_Header_Payment_rec.payment_type_code = 'CREDIT_CARD' THEN
233 --R12 CC Encryption
234 IF p_header_payment_rec.trxn_extension_id is null then
235 --bug 5176015
236 /*IF p_Header_Payment_rec.credit_card_number IS NULL THEN
237 l_return_status := FND_API.G_RET_STS_ERROR;
238
239 IF oe_msg_pub.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
240 THEN
241
242 FND_MESSAGE.SET_NAME('ONT','OE_ATTRIBUTE_REQUIRED');
243 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','CREDIT_CARD_NUMBER');
244 oe_msg_pub.Add;
245
246 END IF;
247 ELSIF p_Header_Payment_rec.credit_card_holder_name IS NULL THEN
248 l_return_status := FND_API.G_RET_STS_ERROR;
249
250 IF oe_msg_pub.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
251 THEN
252
253 FND_MESSAGE.SET_NAME('ONT','OE_ATTRIBUTE_REQUIRED');
254 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','CREDIT_CARD_HOLDER_NAME');
255 oe_msg_pub.Add;
256
257 END IF;
258 ELSIF p_Header_Payment_rec.credit_card_expiration_date IS NULL THEN
259 l_return_status := FND_API.G_RET_STS_ERROR;
260
261 IF oe_msg_pub.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
262 THEN
263
264 FND_MESSAGE.SET_NAME('ONT','OE_ATTRIBUTE_REQUIRED');
265 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','CREDIT_CARD_EXPIRATION_DATE');
266 oe_msg_pub.Add;
267
268 END IF;
269
270 END IF;*/
271 --bug 5176015
272 --R12 CC Encryption
273 oe_debug_pub.add('Header id in entity ksu'||p_header_payment_rec.header_id);
274 Begin
275 Select invoice_to_org_id
276 Into l_invoice_to_org_id
277 From oe_order_headers_all
278 Where header_id = p_header_payment_rec.header_id;
279 EXCEPTION WHEN NO_DATA_FOUND THEN
280 Null;
281 End;
282 oe_debug_pub.add('Invoice to org id'||l_invoice_to_org_id);
283 IF l_invoice_to_org_id IS NULL THEN
284 l_return_status := FND_API.G_RET_STS_ERROR;
285 IF oe_msg_pub.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
286 THEN
287 FND_MESSAGE.SET_NAME('ONT', 'OE_VPM_INV_TO_REQUIRED');
288 oe_msg_pub.Add;
289 END IF;
290 END IF;
291 --R12 CC Encryption
292 END IF;
293 --R12 CC Encryption
294
295 ELSIF p_Header_Payment_rec.payment_type_code = 'CHECK' THEN
296
297 IF p_Header_Payment_rec.check_number IS NULL THEN
298 l_return_status := FND_API.G_RET_STS_ERROR;
299
300 IF oe_msg_pub.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
301 THEN
302
303 FND_MESSAGE.SET_NAME('ONT','OE_ATTRIBUTE_REQUIRED');
304 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','CHECK_NUMBER');
305 oe_msg_pub.Add;
306
307 END IF;
308 END IF;
309 /* comment out for R12
310 ELSIF p_Header_Payment_rec.payment_type_code in ('ACH', 'DIRECT_DEBIT')
311 THEN
312
313 IF p_Header_Payment_rec.payment_trx_id IS NULL THEN
314 l_return_status := FND_API.G_RET_STS_ERROR;
315
316 IF oe_msg_pub.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
317 THEN
318
319 FND_MESSAGE.SET_NAME('ONT','OE_ATTRIBUTE_REQUIRED');
320 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','Bank Account ID');
321 oe_msg_pub.Add;
322
323 END IF;
324 END IF;
325 */
326
327 END IF;
328
329 IF p_Header_Payment_rec.payment_type_code in ('ACH', 'DIRECT_DEBIT') THEN
330
331 IF p_Header_Payment_rec.receipt_method_id IS NULL THEN
332 l_return_status := FND_API.G_RET_STS_ERROR;
333
334 IF oe_msg_pub.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
335 THEN
336
337 FND_MESSAGE.SET_NAME('ONT','OE_ATTRIBUTE_REQUIRED');
338 FND_MESSAGE.SET_TOKEN('ATTRIBUTE','Receipt Method');
339 oe_msg_pub.Add;
340
341 END IF;
342 END IF;
343
344 END IF; -- if payment_type_code in ACH, DIRECT_DEBIT, CREDIT_CARD
345
346 IF NVL(p_Header_Payment_rec.payment_collection_event, 'INVOICE') = 'INVOICE' THEN
347
348 l_count := 0;
349
350 -- Cannot have more than one 'Invoice' payment instrument
351 SELECT count(*)
352 INTO l_count
353 FROM oe_payments
354 WHERE header_id = p_Header_Payment_rec.header_id
355 AND line_id is null
356 AND payment_level_code = 'ORDER'
357 AND nvl(payment_collection_event, 'INVOICE') = 'INVOICE'
358 AND nvl(payment_number, -1) <> nvl(p_Header_Payment_rec.payment_number, -1);
359
360 IF l_count > 0 THEN
361 l_return_status := FND_API.G_RET_STS_ERROR;
362
363 IF oe_msg_pub.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
364 THEN
365
366 FND_MESSAGE.SET_NAME('ONT','ONT_INVOICE_PAYMENT_INSTRUMENT');
367 oe_msg_pub.Add;
368
369 END IF;
370 END IF;
371 ELSIF p_Header_Payment_rec.payment_type_code = 'WIRE_TRANSFER' AND
372 p_Header_Payment_rec.payment_collection_event = 'PREPAY' THEN
373
374 -- wire transfer is not supported for prepayment
375
376 l_return_status := FND_API.G_RET_STS_ERROR;
377
378 IF oe_msg_pub.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
379 THEN
380 -- Wire Transfer is not supported for prepayments.
381 FND_MESSAGE.SET_NAME('ONT','ONT_NO_WIRE_FOR_PREPAY');
382 oe_msg_pub.Add;
383
384 END IF;
385
386 END IF;
387
388 -- Return Error if a required attribute is missing.
389
390 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
391
392 RAISE FND_API.G_EXC_ERROR;
393
394 END IF;
395
396 --
397 -- Check conditionally required attributes here.
398 --
399
400
401 --
402 -- Validate attribute dependencies here.
403 --
404
405 -- Done validating entity
406
407 x_return_status := l_return_status;
408
409 OE_DEBUG_PUB.Add('Exiting OE_VALIDATE_Header_Payments.Entity',1);
410 EXCEPTION
411
412 WHEN FND_API.G_EXC_ERROR THEN
413
414 x_return_status := FND_API.G_RET_STS_ERROR;
415
416 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
417
418 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
419
420 WHEN OTHERS THEN
421
422 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
423
424 IF oe_msg_pub.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
425 THEN
426 oe_msg_pub.Add_Exc_Msg
427 ( G_PKG_NAME
428 , 'Entity'
429 );
430 END IF;
431
432 END Entity;
433
434 -- Procedure Attributes
435
436 PROCEDURE Attributes
437 ( x_return_status OUT NOCOPY VARCHAR2
438 , p_Header_Payment_rec IN OE_Order_PUB.Header_Payment_Rec_Type
439 , p_old_Header_Payment_rec IN OE_Order_PUB.Header_Payment_Rec_Type :=
440 OE_Order_PUB.G_MISS_HEADER_PAYMENT_REC
441 )
442 IS
443 l_line_payment_count number;
444 l_cc_security_code_use VARCHAR2(20); --R12 CVV2
445 BEGIN
446
447 OE_DEBUG_PUB.Add('Entering OE_VALIDATE_Header_Payments.Attributes',1);
448 x_return_status := FND_API.G_RET_STS_SUCCESS;
449
450 -- Validate Header_Payment attributes
451
452 IF p_Header_Payment_rec.created_by IS NOT NULL AND
453 ( p_Header_Payment_rec.created_by <>
454 p_old_Header_Payment_rec.created_by OR
455 p_old_Header_Payment_rec.created_by IS NULL )
456 THEN
457 IF NOT OE_Validate.Created_By(p_Header_Payment_rec.created_by) THEN
458 x_return_status := FND_API.G_RET_STS_ERROR;
459 END IF;
460 END IF;
461 oe_debug_pub.add('return status 1 : ' || x_return_status);
462
463 IF p_Header_Payment_rec.creation_date IS NOT NULL AND
464 ( p_Header_Payment_rec.creation_date <>
465 p_old_Header_Payment_rec.creation_date OR
466 p_old_Header_Payment_rec.creation_date IS NULL )
467 THEN
468 IF NOT OE_Validate.Creation_Date(p_Header_Payment_rec.creation_date) THEN
469 x_return_status := FND_API.G_RET_STS_ERROR;
470 END IF;
471 END IF;
472 oe_debug_pub.add('return status 2 : ' || x_return_status);
473
474 IF p_Header_Payment_rec.header_id IS NOT NULL AND
475 ( p_Header_Payment_rec.header_id <>
476 p_old_Header_Payment_rec.header_id OR
477 p_old_Header_Payment_rec.header_id IS NULL )
478 THEN
479 IF NOT OE_Validate.Header(p_Header_Payment_rec.header_id) THEN
480 x_return_status := FND_API.G_RET_STS_ERROR;
481 END IF;
482 END IF;
483
484 oe_debug_pub.add('return status 3 : ' || x_return_status);
485
486 IF p_Header_Payment_rec.last_updated_by IS NOT NULL AND
487 ( p_Header_Payment_rec.last_updated_by <>
488 p_old_Header_Payment_rec.last_updated_by OR
489 p_old_Header_Payment_rec.last_updated_by IS NULL )
490 THEN
491 IF NOT OE_Validate.Last_Updated_By(p_Header_Payment_rec.last_updated_by) THEN
492 x_return_status := FND_API.G_RET_STS_ERROR;
493 END IF;
494 END IF;
495
496 oe_debug_pub.add('return status 4 : ' || x_return_status);
497
498 IF p_Header_Payment_rec.last_update_date IS NOT NULL AND
499 ( p_Header_Payment_rec.last_update_date <>
500 p_old_Header_Payment_rec.last_update_date OR
501 p_old_Header_Payment_rec.last_update_date IS NULL )
502 THEN
503 IF NOT OE_Validate.Last_Update_Date(p_Header_Payment_rec.last_update_date) THEN
504 x_return_status := FND_API.G_RET_STS_ERROR;
505 END IF;
506 END IF;
507
508 oe_debug_pub.add('return status 5 : ' || x_return_status);
509
510 IF p_Header_Payment_rec.last_update_login IS NOT NULL AND
511 ( p_Header_Payment_rec.last_update_login <>
512 p_old_Header_Payment_rec.last_update_login OR
513 p_old_Header_Payment_rec.last_update_login IS NULL )
514 THEN
515 IF NOT OE_Validate.Last_Update_Login(p_Header_Payment_rec.last_update_login) THEN
516 x_return_status := FND_API.G_RET_STS_ERROR;
517 END IF;
518 END IF;
519
520 IF p_Header_Payment_rec.line_id IS NOT NULL AND
521 ( p_Header_Payment_rec.line_id <>
522 p_old_Header_Payment_rec.line_id OR
523 p_old_Header_Payment_rec.line_id IS NULL )
524 THEN
525 IF NOT OE_Validate.Line(p_Header_Payment_rec.line_id) THEN
526 x_return_status := FND_API.G_RET_STS_ERROR;
527 END IF;
528 END IF;
529
530 IF p_Header_Payment_rec.check_number IS NOT NULL AND
531 ( p_Header_Payment_rec.check_number <>
532 p_old_Header_Payment_rec.check_number OR
533 p_old_Header_Payment_rec.check_number IS NULL )
534 THEN
535 IF NOT OE_Validate.check_number(p_Header_Payment_rec.check_number) THEN
536 x_return_status := FND_API.G_RET_STS_ERROR;
537 END IF;
538 END IF;
539
540 IF p_Header_Payment_rec.credit_card_approval_code IS NOT NULL AND
541 ( p_Header_Payment_rec.credit_card_approval_code <>
542 p_old_Header_Payment_rec.credit_card_approval_code OR
543 p_old_Header_Payment_rec.credit_card_approval_code IS NULL )
544 THEN
545 IF NOT OE_Validate.credit_card_approval(p_Header_Payment_rec.credit_card_approval_code) THEN
546 x_return_status := FND_API.G_RET_STS_ERROR;
547 END IF;
548 END IF;
549
550 oe_debug_pub.add('return status 6 : ' || x_return_status);
551
552
553 IF p_Header_Payment_rec.credit_card_approval_date IS NOT NULL AND
554 ( p_Header_Payment_rec.credit_card_approval_date <>
555 p_old_Header_Payment_rec.credit_card_approval_date OR
556 p_old_Header_Payment_rec.credit_card_approval_date IS NULL )
557 THEN
558 IF NOT OE_Validate.credit_card_approval_date(p_Header_Payment_rec.credit_card_approval_date) THEN
559 x_return_status := FND_API.G_RET_STS_ERROR;
560 END IF;
561 END IF;
562
563 IF p_Header_Payment_rec.credit_card_code IS NOT NULL AND
564 ( p_Header_Payment_rec.credit_card_code <>
565 p_old_Header_Payment_rec.credit_card_code OR
566 p_old_Header_Payment_rec.credit_card_code IS NULL )
567 THEN
568 IF NOT OE_Validate.credit_card(p_Header_Payment_rec.credit_card_code) THEN
569 x_return_status := FND_API.G_RET_STS_ERROR;
570 END IF;
571 END IF;
572
573 oe_debug_pub.add('return status 7 : ' || x_return_status);
574 oe_Debug_pub.add('after credit_card_code');
575
576 --R12 CVV2
577 IF p_Header_Payment_rec.credit_card_number IS NOT NULL AND p_Header_Payment_rec.credit_card_number <> FND_API.G_MISS_CHAR THEN
578 l_cc_security_code_use := OE_Payment_Trxn_Util.Get_CC_Security_Code_Use;
579 IF l_cc_security_code_use = 'REQUIRED' THEN
580 IF p_Header_Payment_rec.instrument_security_code IS NULL OR
581 p_Header_Payment_rec.instrument_security_code = FND_API.G_MISS_CHAR THEN --bug 4613168, issue 22
582 FND_MESSAGE.SET_NAME('ONT','OE_CC_SECURITY_CODE_REQD');
583 OE_MSG_PUB.ADD;
584 x_return_status := FND_API.G_RET_STS_ERROR;
585 END IF;
586 END IF;
587 END IF;
588 --R12 CVV2
589
590 oe_debug_pub.add('after security code');
591
592
593 IF p_Header_Payment_rec.credit_card_expiration_date IS NOT NULL AND
594 ( p_Header_Payment_rec.credit_card_expiration_date <>
595 p_old_Header_Payment_rec.credit_card_expiration_date OR
596 p_old_Header_Payment_rec.credit_card_expiration_date IS NULL )
597 THEN
598 IF NOT OE_Validate.credit_card_expiration_date(p_Header_Payment_rec.credit_card_expiration_date) THEN
599 x_return_status := FND_API.G_RET_STS_ERROR;
600 END IF;
601 END IF;
602
603 oe_debug_pub.add('return status 8 : ' || x_return_status);
604 oe_debug_pub.add('after credit_card_expiration_date');
605
606 IF p_Header_Payment_rec.credit_card_holder_name IS NOT NULL AND
607 ( p_Header_Payment_rec.credit_card_holder_name <>
608 p_old_Header_Payment_rec.credit_card_holder_name OR
609 p_old_Header_Payment_rec.credit_card_holder_name IS NULL )
610 THEN
611 IF NOT OE_Validate.credit_card_holder_name(p_Header_Payment_rec.credit_card_holder_name) THEN
612 x_return_status := FND_API.G_RET_STS_ERROR;
613 END IF;
614 END IF;
615
616 oe_debug_pub.add('after credit_card_holder_name');
617
618 IF p_Header_Payment_rec.credit_card_number IS NOT NULL AND
619 ( p_Header_Payment_rec.credit_card_number <>
620 p_old_Header_Payment_rec.credit_card_number OR
621 p_old_Header_Payment_rec.credit_card_number IS NULL )
622 THEN
623 IF NOT OE_Validate.credit_card_number(p_Header_Payment_rec.credit_card_number) THEN
624 x_return_status := FND_API.G_RET_STS_ERROR;
625 END IF;
626 END IF;
627
628 oe_debug_pub.add('after credit_card_number');
629
630 IF p_Header_Payment_rec.payment_level_code IS NOT NULL AND
631 ( p_Header_Payment_rec.payment_level_code <>
632 p_old_Header_Payment_rec.payment_level_code OR
633 p_old_Header_Payment_rec.payment_level_code IS NULL )
634 THEN
635 IF NOT OE_Validate.payment_level(p_Header_Payment_rec.payment_level_code) THEN
636 x_return_status := FND_API.G_RET_STS_ERROR;
637 END IF;
638 END IF;
639
640 oe_debug_pub.add('return status 9 : ' || x_return_status);
641 oe_debug_pub.add('after payment_level_code');
642
643 IF p_Header_Payment_rec.commitment_applied_amount IS NOT NULL AND
644 ( p_Header_Payment_rec.commitment_applied_amount <>
645 p_old_Header_Payment_rec.commitment_applied_amount OR
646 p_old_Header_Payment_rec.commitment_applied_amount IS NULL )
647 THEN
648 IF NOT OE_Validate.commitment_applied_amount(p_Header_Payment_rec.commitment_applied_amount) THEN
649 x_return_status := FND_API.G_RET_STS_ERROR;
650 END IF;
651 END IF;
652
653 oe_debug_pub.add('after commitment_applied_amount');
654
655
656 IF p_Header_Payment_rec.commitment_interfaced_amount IS NOT NULL AND
657 ( p_Header_Payment_rec.commitment_interfaced_amount <>
658 p_old_Header_Payment_rec.commitment_interfaced_amount OR
659 p_old_Header_Payment_rec.commitment_interfaced_amount IS NULL )
660 THEN
661 IF NOT OE_Validate.commitment_interfaced_amount(p_Header_Payment_rec.commitment_interfaced_amount) THEN
662 x_return_status := FND_API.G_RET_STS_ERROR;
663 END IF;
664 END IF;
665
666 oe_debug_pub.add('after commitment_interfaced_amount');
667
668 IF p_Header_Payment_rec.payment_amount IS NOT NULL AND
669 ( p_Header_Payment_rec.payment_amount <>
670 p_old_Header_Payment_rec.payment_amount OR
671 p_old_Header_Payment_rec.payment_amount IS NULL )
672 THEN
673 IF NOT OE_Validate.payment_amount(p_Header_Payment_rec.payment_amount) THEN
674 x_return_status := FND_API.G_RET_STS_ERROR;
675 END IF;
676 END IF;
677
678 oe_debug_pub.add('after payment_amount');
679
680 IF p_Header_Payment_rec.payment_collection_event IS NOT NULL AND
681 ( p_Header_Payment_rec.payment_collection_event <>
682 p_old_Header_Payment_rec.payment_collection_event OR
683 p_old_Header_Payment_rec.payment_collection_event IS NULL )
684 THEN
685 IF NOT OE_Validate.payment_collection_event(p_Header_Payment_rec.payment_collection_event) THEN
686 x_return_status := FND_API.G_RET_STS_ERROR;
687 END IF;
688 --16309734 Start
689 IF p_Header_Payment_rec.payment_collection_event ='PREPAY' THEN
690 --16309734 End
691 select count(payment_type_code) into l_line_payment_count
692 from oe_payments
693 where header_id = p_Header_Payment_rec.header_id
694 and line_id is not null;
695
696 if l_line_payment_count > 0 then
697 fnd_message.set_name('ONT', 'ONT_LINE_PAYMENTS_EXIST');
698 oe_msg_pub.add;
699 x_return_status := FND_API.G_RET_STS_ERROR;
700 end if;
701 --16309734 Start
702 END IF;--end if of if prepay condition
703 --16309734 End
704
705 END IF;
706
707 oe_debug_pub.add('after payment_collection_event');
708
709 IF p_Header_Payment_rec.payment_trx_id IS NOT NULL AND
710 ( p_Header_Payment_rec.payment_trx_id <>
711 p_old_Header_Payment_rec.payment_trx_id OR
712 p_old_Header_Payment_rec.payment_trx_id IS NULL )
713 THEN
714 IF NOT OE_Validate.payment_trx(p_Header_Payment_rec.payment_trx_id) THEN
715 x_return_status := FND_API.G_RET_STS_ERROR;
716 END IF;
717 END IF;
718
719 oe_debug_pub.add('after payment_trx_id');
720
721 IF p_Header_Payment_rec.payment_type_code IS NOT NULL AND
722 ( p_Header_Payment_rec.payment_type_code <>
723 p_old_Header_Payment_rec.payment_type_code OR
724 p_old_Header_Payment_rec.payment_type_code IS NULL )
725 THEN
726 IF NOT OE_Validate.payment_type(p_Header_Payment_rec.payment_type_code) THEN
727 x_return_status := FND_API.G_RET_STS_ERROR;
728 END IF;
729 END IF;
730
731 oe_debug_pub.add('after payment_type_code');
732
733 IF p_Header_Payment_rec.payment_set_id IS NOT NULL AND
734 ( p_Header_Payment_rec.payment_set_id <>
735 p_old_Header_Payment_rec.payment_set_id OR
736 p_old_Header_Payment_rec.payment_set_id IS NULL )
737 THEN
738 IF NOT OE_Validate.payment_set(p_Header_Payment_rec.payment_set_id) THEN
739 x_return_status := FND_API.G_RET_STS_ERROR;
740 END IF;
741 END IF;
742
743 IF p_Header_Payment_rec.prepaid_amount IS NOT NULL AND
744 ( p_Header_Payment_rec.prepaid_amount <>
745 p_old_Header_Payment_rec.prepaid_amount OR
746 p_old_Header_Payment_rec.prepaid_amount IS NULL )
747 THEN
748 IF NOT OE_Validate.prepaid_amount(p_Header_Payment_rec.prepaid_amount) THEN
749 x_return_status := FND_API.G_RET_STS_ERROR;
750 END IF;
751 END IF;
752
753 IF p_Header_Payment_rec.receipt_method_id IS NOT NULL AND
754 ( p_Header_Payment_rec.receipt_method_id <>
755 p_old_Header_Payment_rec.receipt_method_id OR
756 p_old_Header_Payment_rec.receipt_method_id IS NULL )
757 THEN
758 IF NOT OE_Validate.receipt_method(p_Header_Payment_rec.receipt_method_id) THEN
759 x_return_status := FND_API.G_RET_STS_ERROR;
760 END IF;
761 END IF;
762
763 IF p_Header_Payment_rec.tangible_id IS NOT NULL AND
764 ( p_Header_Payment_rec.tangible_id <>
765 p_old_Header_Payment_rec.tangible_id OR
766 p_old_Header_Payment_rec.tangible_id IS NULL )
767 THEN
768 IF NOT OE_Validate.tangible(p_Header_Payment_rec.tangible_id) THEN
769 x_return_status := FND_API.G_RET_STS_ERROR;
770 END IF;
771 END IF;
772
773 IF p_Header_Payment_rec.trxn_extension_id IS NOT NULL AND --R12 Process order api changes
774 ( p_Header_Payment_rec.trxn_extension_id <>
775 p_old_Header_Payment_rec.trxn_extension_id OR
776 p_old_Header_Payment_rec.trxn_extension_id IS NULL )
777 THEN
778 IF NOT OE_Validate.Payment_Trxn_Extension(p_Header_Payment_rec.trxn_extension_id) THEN
779 x_return_status := FND_API.G_RET_STS_ERROR;
780 END IF;
781 END IF; --R12 Process order api changes
782
783 oe_debug_pub.add('after trxn_extension_id ');
784 oe_debug_pub.add('attribute1 new : ' || p_Header_Payment_rec.attribute1);
785 oe_debug_pub.add('attribute1 old : ' || p_old_Header_Payment_rec.attribute1);
786 oe_debug_pub.add('attribute10 new : ' || p_Header_Payment_rec.attribute10);
787 oe_debug_pub.add('attribute10 old : ' || p_old_Header_Payment_rec.attribute10);
788 oe_debug_pub.add('attribute11 new : ' || p_Header_Payment_rec.attribute11);
789 oe_debug_pub.add('attribute11 old : ' || p_old_Header_Payment_rec.attribute11);
790 oe_debug_pub.add('attribute12 new : ' || p_Header_Payment_rec.attribute12);
791 oe_debug_pub.add('attribute12 old : ' || p_old_Header_Payment_rec.attribute12);
792 oe_debug_pub.add('attribute13 new : ' || p_Header_Payment_rec.attribute13);
793 oe_debug_pub.add('attribute13 old : ' || p_old_Header_Payment_rec.attribute13);
794 oe_debug_pub.add('attribute14 new : ' || p_Header_Payment_rec.attribute14);
795 oe_debug_pub.add('attribute14 old : ' || p_old_Header_Payment_rec.attribute14);
796 oe_debug_pub.add('attribute15 new : ' || p_Header_Payment_rec.attribute15);
797 oe_debug_pub.add('attribute15 old : ' || p_old_Header_Payment_rec.attribute15);
798 oe_debug_pub.add('attribute2 new : ' || p_Header_Payment_rec.attribute2);
799 oe_debug_pub.add('attribute2 old : ' || p_old_Header_Payment_rec.attribute2);
800 oe_debug_pub.add('attribute3 new : ' || p_Header_Payment_rec.attribute3);
801 oe_debug_pub.add('attribute3 old : ' || p_old_Header_Payment_rec.attribute3);
802 oe_debug_pub.add('attribute4 new : ' || p_Header_Payment_rec.attribute4);
803 oe_debug_pub.add('attribute4 old : ' || p_old_Header_Payment_rec.attribute4);
804 oe_debug_pub.add('attribute5 new : ' || p_Header_Payment_rec.attribute5);
805 oe_debug_pub.add('attribute5 old : ' || p_old_Header_Payment_rec.attribute5);
806 oe_debug_pub.add('attribute6 new : ' || p_Header_Payment_rec.attribute6);
807 oe_debug_pub.add('attribute6 old : ' || p_old_Header_Payment_rec.attribute6);
808 oe_debug_pub.add('attribute7 new : ' || p_Header_Payment_rec.attribute7);
809 oe_debug_pub.add('attribute7 old : ' || p_old_Header_Payment_rec.attribute7);
810 oe_debug_pub.add('attribute8 new : ' || p_Header_Payment_rec.attribute8);
811 oe_debug_pub.add('attribute8 old : ' || p_old_Header_Payment_rec.attribute8);
812 oe_debug_pub.add('attribute9 new : ' || p_Header_Payment_rec.attribute9);
813 oe_debug_pub.add('attribute9 old : ' || p_old_Header_Payment_rec.attribute9);
814
815 if OE_GLOBALS.g_validate_desc_flex ='Y' then --4343612
816 oe_debug_pub.add('Validation of desc flex is set to Y in OE_Validate_Header_Payment.attributes',1);
817 IF (p_Header_Payment_rec.attribute1 IS NOT NULL AND
818 ( p_Header_Payment_rec.attribute1 <>
819 p_old_Header_Payment_rec.attribute1 OR
820 p_old_Header_Payment_rec.attribute1 IS NULL ))
821 OR (p_Header_Payment_rec.attribute10 IS NOT NULL AND
822 ( p_Header_Payment_rec.attribute10 <>
823 p_old_Header_Payment_rec.attribute10 OR
824 p_old_Header_Payment_rec.attribute10 IS NULL ))
825 OR (p_Header_Payment_rec.attribute11 IS NOT NULL AND
826 ( p_Header_Payment_rec.attribute11 <>
827 p_old_Header_Payment_rec.attribute11 OR
828 p_old_Header_Payment_rec.attribute11 IS NULL ))
829 OR (p_Header_Payment_rec.attribute12 IS NOT NULL AND
830 ( p_Header_Payment_rec.attribute12 <>
831 p_old_Header_Payment_rec.attribute12 OR
832 p_old_Header_Payment_rec.attribute12 IS NULL ))
833 OR (p_Header_Payment_rec.attribute13 IS NOT NULL AND
834 ( p_Header_Payment_rec.attribute13 <>
835 p_old_Header_Payment_rec.attribute13 OR
836 p_old_Header_Payment_rec.attribute13 IS NULL ))
837 OR (p_Header_Payment_rec.attribute14 IS NOT NULL AND
838 ( p_Header_Payment_rec.attribute14 <>
839 p_old_Header_Payment_rec.attribute14 OR
840 p_old_Header_Payment_rec.attribute14 IS NULL ))
841 OR (p_Header_Payment_rec.attribute15 IS NOT NULL AND
842 ( p_Header_Payment_rec.attribute15 <>
843 p_old_Header_Payment_rec.attribute15 OR
844 p_old_Header_Payment_rec.attribute15 IS NULL ))
845 OR (p_Header_Payment_rec.attribute2 IS NOT NULL AND
846 ( p_Header_Payment_rec.attribute2 <>
847 p_old_Header_Payment_rec.attribute2 OR
848 p_old_Header_Payment_rec.attribute2 IS NULL ))
849 OR (p_Header_Payment_rec.attribute3 IS NOT NULL AND
850 ( p_Header_Payment_rec.attribute3 <>
851 p_old_Header_Payment_rec.attribute3 OR
852 p_old_Header_Payment_rec.attribute3 IS NULL ))
853 OR (p_Header_Payment_rec.attribute4 IS NOT NULL AND
854 ( p_Header_Payment_rec.attribute4 <>
855 p_old_Header_Payment_rec.attribute4 OR
856 p_old_Header_Payment_rec.attribute4 IS NULL ))
857 OR (p_Header_Payment_rec.attribute5 IS NOT NULL AND
858 ( p_Header_Payment_rec.attribute5 <>
859 p_old_Header_Payment_rec.attribute5 OR
860 p_old_Header_Payment_rec.attribute5 IS NULL ))
861 OR (p_Header_Payment_rec.attribute6 IS NOT NULL AND
862 ( p_Header_Payment_rec.attribute6 <>
863 p_old_Header_Payment_rec.attribute6 OR
864 p_old_Header_Payment_rec.attribute6 IS NULL ))
865 OR (p_Header_Payment_rec.attribute7 IS NOT NULL AND
866 ( p_Header_Payment_rec.attribute7 <>
867 p_old_Header_Payment_rec.attribute7 OR
868 p_old_Header_Payment_rec.attribute7 IS NULL ))
869 OR (p_Header_Payment_rec.attribute8 IS NOT NULL AND
870 ( p_Header_Payment_rec.attribute8 <>
871 p_old_Header_Payment_rec.attribute8 OR
872 p_old_Header_Payment_rec.attribute8 IS NULL ))
873 OR (p_Header_Payment_rec.attribute9 IS NOT NULL AND
874 ( p_Header_Payment_rec.attribute9 <>
875 p_old_Header_Payment_rec.attribute9 OR
876 p_old_Header_Payment_rec.attribute9 IS NULL ))
877 OR (p_Header_Payment_rec.context IS NOT NULL AND
878 ( p_Header_Payment_rec.context <>
879 p_old_Header_Payment_rec.context OR
880 p_old_Header_Payment_rec.context IS NULL ))
881 THEN
882
883
884 oe_debug_pub.add('Before calling Payments_Desc_Flex',2);
885 IF NOT OE_VALIDATE.Payments_Desc_Flex
886 (p_context => p_Header_Payment_rec.context
887 ,p_attribute1 => p_Header_Payment_rec.attribute1
888 ,p_attribute2 => p_Header_Payment_rec.attribute2
889 ,p_attribute3 => p_Header_Payment_rec.attribute3
890 ,p_attribute4 => p_Header_Payment_rec.attribute4
891 ,p_attribute5 => p_Header_Payment_rec.attribute5
892 ,p_attribute6 => p_Header_Payment_rec.attribute6
893 ,p_attribute7 => p_Header_Payment_rec.attribute7
894 ,p_attribute8 => p_Header_Payment_rec.attribute8
895 ,p_attribute9 => p_Header_Payment_rec.attribute9
896 ,p_attribute10 => p_Header_Payment_rec.attribute10
897 ,p_attribute11 => p_Header_Payment_rec.attribute11
898 ,p_attribute12 => p_Header_Payment_rec.attribute12
899 ,p_attribute13 => p_Header_Payment_rec.attribute13
900 ,p_attribute14 => p_Header_Payment_rec.attribute14
901 ,p_attribute15 => p_Header_Payment_rec.attribute15) THEN
902
903 x_return_status := FND_API.G_RET_STS_ERROR;
904 END IF;
905
906 oe_debug_pub.add('After Payments_Desc_Flex ' || x_return_status,2);
907
908 END IF;
909
910 OE_DEBUG_PUB.Add('Exiting OE_VALIDATE_Header_Payments.Attributes',1);
911 end if ; /*if OE_GLOBALS.g_validate_desc_flex ='Y' then for bug4343612 */
912 -- Done validating attributes
913
914 EXCEPTION
915
916 WHEN FND_API.G_EXC_ERROR THEN
917
918 x_return_status := FND_API.G_RET_STS_ERROR;
919
920 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
921
922 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
923
924 WHEN OTHERS THEN
925
926 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
927
928 IF oe_msg_pub.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
929 THEN
930 oe_msg_pub.Add_Exc_Msg
931 ( G_PKG_NAME
932 , 'Attributes'
933 );
934 END IF;
935
936 END Attributes;
937
938 -- Procedure Entity_Delete
939
940 PROCEDURE Entity_Delete
941 ( x_return_status OUT NOCOPY VARCHAR2
942 , p_Header_Payment_rec IN OE_Order_PUB.Header_Payment_Rec_Type
943 )
944 IS
945 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
946 BEGIN
947
948 OE_DEBUG_PUB.Add('Entering OE_VALIDATE_Header_Payments.Entity_Delete',1);
949 -- Validate entity delete.
950 NULL;
951 -- Done.
952
953 x_return_status := l_return_status;
954 OE_DEBUG_PUB.Add('Exiting OE_VALIDATE_Header_Payments.Entity_Delete',1);
955
956 EXCEPTION
957
958 WHEN FND_API.G_EXC_ERROR THEN
959
960 x_return_status := FND_API.G_RET_STS_ERROR;
961
962 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
963
964 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
965
966 WHEN OTHERS THEN
967
968 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
969
970 IF oe_msg_pub.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
971 THEN
972 oe_msg_pub.Add_Exc_Msg
973 ( G_PKG_NAME
974 , 'Entity_Delete'
975 );
976 END IF;
977
978 END Entity_Delete;
979
980 END OE_Validate_Header_Payment;