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