DBA Data[Home] [Help]

APPS.AP_CREATE_PAY_SCHEDS_PKG dependencies on AP_TERMS_LINES

Line 85: (DECODE(ap_terms_lines.due_days,

81: END IF;
82:
83: -- bug2682782 deleted needless least function
84: SELECT NVL(fixed_date,
85: (DECODE(ap_terms_lines.due_days,
86: NULL,TO_DATE(TO_CHAR(LEAST(NVL(ap_terms_lines.due_day_of_month,32),
87: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(P_Terms_Date,
88: NVL(ap_terms_lines.due_months_forward,0) +
89: DECODE(ap_terms.due_cutoff_day, NULL, 0,

Line 86: NULL,TO_DATE(TO_CHAR(LEAST(NVL(ap_terms_lines.due_day_of_month,32),

82:
83: -- bug2682782 deleted needless least function
84: SELECT NVL(fixed_date,
85: (DECODE(ap_terms_lines.due_days,
86: NULL,TO_DATE(TO_CHAR(LEAST(NVL(ap_terms_lines.due_day_of_month,32),
87: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(P_Terms_Date,
88: NVL(ap_terms_lines.due_months_forward,0) +
89: DECODE(ap_terms.due_cutoff_day, NULL, 0,
90: DECODE(GREATEST(NVL(ap_terms.due_cutoff_day, 32),

Line 88: NVL(ap_terms_lines.due_months_forward,0) +

84: SELECT NVL(fixed_date,
85: (DECODE(ap_terms_lines.due_days,
86: NULL,TO_DATE(TO_CHAR(LEAST(NVL(ap_terms_lines.due_day_of_month,32),
87: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(P_Terms_Date,
88: NVL(ap_terms_lines.due_months_forward,0) +
89: DECODE(ap_terms.due_cutoff_day, NULL, 0,
90: DECODE(GREATEST(NVL(ap_terms.due_cutoff_day, 32),
91: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),
92: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))

Line 95: NVL(ap_terms_lines.due_months_forward,0) +

91: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),
92: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))
93: , 1, 0)))), 'DD')))) || '-' ||
94: TO_CHAR(ADD_MONTHS(P_Terms_Date,
95: NVL(ap_terms_lines.due_months_forward,0) +
96: DECODE(ap_terms.due_cutoff_day, NULL, 0,
97: DECODE(GREATEST(NVL(ap_terms.due_cutoff_day, 32),
98: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),
99: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD')), 1, 0))),

Line 101: P_Terms_Date + NVL(ap_terms_lines.due_days,0))))

97: DECODE(GREATEST(NVL(ap_terms.due_cutoff_day, 32),
98: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),
99: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD')), 1, 0))),
100: 'MON-RR'),'DD-MON-RR'), /*bugfix:5647464 */
101: P_Terms_Date + NVL(ap_terms_lines.due_days,0))))
102: INTO l_due_date
103: FROM ap_terms,
104: ap_terms_lines
105: WHERE ap_terms.term_id = P_Terms_Id

Line 104: ap_terms_lines

100: 'MON-RR'),'DD-MON-RR'), /*bugfix:5647464 */
101: P_Terms_Date + NVL(ap_terms_lines.due_days,0))))
102: INTO l_due_date
103: FROM ap_terms,
104: ap_terms_lines
105: WHERE ap_terms.term_id = P_Terms_Id
106: AND ap_terms.term_id = ap_terms_lines.term_id
107: AND ap_terms_lines.sequence_num = p_sequence_num;
108: END IF;

Line 106: AND ap_terms.term_id = ap_terms_lines.term_id

102: INTO l_due_date
103: FROM ap_terms,
104: ap_terms_lines
105: WHERE ap_terms.term_id = P_Terms_Id
106: AND ap_terms.term_id = ap_terms_lines.term_id
107: AND ap_terms_lines.sequence_num = p_sequence_num;
108: END IF;
109:
110: l_debug_info := 'In the else part , l_due_date is '||l_due_date;

Line 107: AND ap_terms_lines.sequence_num = p_sequence_num;

103: FROM ap_terms,
104: ap_terms_lines
105: WHERE ap_terms.term_id = P_Terms_Id
106: AND ap_terms.term_id = ap_terms_lines.term_id
107: AND ap_terms_lines.sequence_num = p_sequence_num;
108: END IF;
109:
110: l_debug_info := 'In the else part , l_due_date is '||l_due_date;
111: IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL) THEN

Line 160: l_sequence_num ap_terms_lines.sequence_num%TYPE := 0;

156:
157: l_payment_schedule_index BINARY_INTEGER := 0;
158:
159: l_payment_cross_rate ap_payment_schedules.payment_cross_rate%TYPE;
160: l_sequence_num ap_terms_lines.sequence_num%TYPE := 0;
161: l_sign_due_amount ap_terms_lines.due_amount%TYPE;
162: l_sign_remaining_amount ap_terms_lines.due_amount%TYPE;
163: l_calendar ap_terms_lines.calendar%TYPE;
164: l_terms_calendar ap_terms_lines.calendar%TYPE;

Line 161: l_sign_due_amount ap_terms_lines.due_amount%TYPE;

157: l_payment_schedule_index BINARY_INTEGER := 0;
158:
159: l_payment_cross_rate ap_payment_schedules.payment_cross_rate%TYPE;
160: l_sequence_num ap_terms_lines.sequence_num%TYPE := 0;
161: l_sign_due_amount ap_terms_lines.due_amount%TYPE;
162: l_sign_remaining_amount ap_terms_lines.due_amount%TYPE;
163: l_calendar ap_terms_lines.calendar%TYPE;
164: l_terms_calendar ap_terms_lines.calendar%TYPE;
165: l_due_date ap_other_periods.due_date%TYPE;

Line 162: l_sign_remaining_amount ap_terms_lines.due_amount%TYPE;

158:
159: l_payment_cross_rate ap_payment_schedules.payment_cross_rate%TYPE;
160: l_sequence_num ap_terms_lines.sequence_num%TYPE := 0;
161: l_sign_due_amount ap_terms_lines.due_amount%TYPE;
162: l_sign_remaining_amount ap_terms_lines.due_amount%TYPE;
163: l_calendar ap_terms_lines.calendar%TYPE;
164: l_terms_calendar ap_terms_lines.calendar%TYPE;
165: l_due_date ap_other_periods.due_date%TYPE;
166: l_invoice_sign NUMBER;

Line 163: l_calendar ap_terms_lines.calendar%TYPE;

159: l_payment_cross_rate ap_payment_schedules.payment_cross_rate%TYPE;
160: l_sequence_num ap_terms_lines.sequence_num%TYPE := 0;
161: l_sign_due_amount ap_terms_lines.due_amount%TYPE;
162: l_sign_remaining_amount ap_terms_lines.due_amount%TYPE;
163: l_calendar ap_terms_lines.calendar%TYPE;
164: l_terms_calendar ap_terms_lines.calendar%TYPE;
165: l_due_date ap_other_periods.due_date%TYPE;
166: l_invoice_sign NUMBER;
167: l_pay_sched_total NUMBER := 0; -- 4537932

Line 164: l_terms_calendar ap_terms_lines.calendar%TYPE;

160: l_sequence_num ap_terms_lines.sequence_num%TYPE := 0;
161: l_sign_due_amount ap_terms_lines.due_amount%TYPE;
162: l_sign_remaining_amount ap_terms_lines.due_amount%TYPE;
163: l_calendar ap_terms_lines.calendar%TYPE;
164: l_terms_calendar ap_terms_lines.calendar%TYPE;
165: l_due_date ap_other_periods.due_date%TYPE;
166: l_invoice_sign NUMBER;
167: l_pay_sched_total NUMBER := 0; -- 4537932
168: l_inv_curr_sched_total NUMBER;

Line 243: FROM ap_terms_lines

239:
240:
241: CURSOR c_terms_percent IS
242: SELECT 'Terms are percent type'
243: FROM ap_terms_lines
244: WHERE term_id = P_Terms_Id
245: AND sequence_num = 1
246: AND due_percent IS NOT NULL;
247:

Line 250: FROM ap_terms_lines

246: AND due_percent IS NOT NULL;
247:
248: CURSOR c_terms IS
249: SELECT calendar, sequence_num
250: FROM ap_terms_lines
251: WHERE term_id = p_terms_id
252: ORDER BY sequence_num;
253:
254: CURSOR c_amounts IS

Line 261: FROM ap_terms_lines

257: , due_amount
258: , SIGN(ABS(l_remaining_amount) - ABS(due_amount))
259: , ABS(l_remaining_amount) - ABS(due_amount)
260: , calendar
261: FROM ap_terms_lines
262: WHERE term_id = P_Terms_Id
263: AND sequence_num = l_sequence_num;
264: --
265: BEGIN

Line 407: NVL(ap_terms_lines.discount_percent,0)/100 ,l_precision_pay_curr),

403: NULL, ROUND( l_ins_gross_amount *
404: DECODE(P_Pay_Curr_Invoice_Amount, 0, 0, (l_amount_for_discount/
405: DECODE(P_Pay_Curr_Invoice_Amount, 0, 1,
406: P_Pay_Curr_Invoice_Amount))) *
407: NVL(ap_terms_lines.discount_percent,0)/100 ,l_precision_pay_curr),
408: ROUND(( l_ins_gross_amount *
409: DECODE(P_Pay_Curr_Invoice_Amount, 0, 0,
410: (l_amount_for_discount/
411: DECODE(P_Pay_Curr_Invoice_Amount, 0, 1,

Line 413: NVL(ap_terms_lines.discount_percent,0)/100)

409: DECODE(P_Pay_Curr_Invoice_Amount, 0, 0,
410: (l_amount_for_discount/
411: DECODE(P_Pay_Curr_Invoice_Amount, 0, 1,
412: P_Pay_Curr_Invoice_Amount))) *
413: NVL(ap_terms_lines.discount_percent,0)/100)
414: / l_min_acc_unit_pay_curr) * l_min_acc_unit_pay_curr)
415: , DECODE(l_min_acc_unit_pay_curr,
416: NULL, ROUND( l_ins_gross_amount *
417: DECODE(P_Pay_Curr_Invoice_Amount, 0, 0,

Line 421: NVL(ap_terms_lines.discount_percent_2,0)/100 ,l_precision_pay_curr),

417: DECODE(P_Pay_Curr_Invoice_Amount, 0, 0,
418: (l_amount_for_discount/
419: DECODE(P_Pay_Curr_Invoice_Amount, 0, 1,
420: P_Pay_Curr_Invoice_Amount))) *
421: NVL(ap_terms_lines.discount_percent_2,0)/100 ,l_precision_pay_curr),
422: ROUND(( l_ins_gross_amount *
423: DECODE(P_Pay_Curr_Invoice_Amount, 0, 0,
424: (l_amount_for_discount/
425: DECODE(P_Pay_Curr_Invoice_Amount, 0, 1,

Line 427: NVL(ap_terms_lines.discount_percent_2,0)/100)

423: DECODE(P_Pay_Curr_Invoice_Amount, 0, 0,
424: (l_amount_for_discount/
425: DECODE(P_Pay_Curr_Invoice_Amount, 0, 1,
426: P_Pay_Curr_Invoice_Amount))) *
427: NVL(ap_terms_lines.discount_percent_2,0)/100)
428: / l_min_acc_unit_pay_curr) * l_min_acc_unit_pay_curr)
429: , DECODE(l_min_acc_unit_pay_curr,
430: NULL, ROUND( l_ins_gross_amount *
431: DECODE(P_Pay_Curr_Invoice_Amount, 0, 0,

Line 435: NVL(ap_terms_lines.discount_percent_3,0)/100 ,l_precision_pay_curr),

431: DECODE(P_Pay_Curr_Invoice_Amount, 0, 0,
432: (l_amount_for_discount/
433: DECODE(P_Pay_Curr_Invoice_Amount, 0, 1,
434: P_Pay_Curr_Invoice_Amount))) *
435: NVL(ap_terms_lines.discount_percent_3,0)/100 ,l_precision_pay_curr),
436: ROUND(( l_ins_gross_amount *
437: DECODE(P_Pay_Curr_Invoice_Amount, 0, 0,
438: (l_amount_for_discount/
439: DECODE(P_Pay_Curr_Invoice_Amount, 0, 1,

Line 441: NVL(ap_terms_lines.discount_percent_3,0)/100)

437: DECODE(P_Pay_Curr_Invoice_Amount, 0, 0,
438: (l_amount_for_discount/
439: DECODE(P_Pay_Curr_Invoice_Amount, 0, 1,
440: P_Pay_Curr_Invoice_Amount))) *
441: NVL(ap_terms_lines.discount_percent_3,0)/100)
442: / l_min_acc_unit_pay_curr) * l_min_acc_unit_pay_curr),
443: discount_amount,
444: discount_amount_2,
445: discount_amount_3

Line 451: , ap_terms_lines

447: l_disc_amt_by_percent, l_disc_amt_by_percent_2, l_disc_amt_by_percent_3,
448: l_discount_amount, l_discount_amount_2, l_discount_amount_3
449:
450: FROM ap_terms
451: , ap_terms_lines
452: , ap_invoices ai
453: WHERE ap_terms.term_id = ap_terms_lines.term_id
454: AND ap_terms_lines.term_id = P_Terms_Id
455: AND ap_terms_lines.sequence_num = l_sequence_num

Line 453: WHERE ap_terms.term_id = ap_terms_lines.term_id

449:
450: FROM ap_terms
451: , ap_terms_lines
452: , ap_invoices ai
453: WHERE ap_terms.term_id = ap_terms_lines.term_id
454: AND ap_terms_lines.term_id = P_Terms_Id
455: AND ap_terms_lines.sequence_num = l_sequence_num
456: AND ai.Invoice_Id = P_Invoice_Id;
457:

Line 454: AND ap_terms_lines.term_id = P_Terms_Id

450: FROM ap_terms
451: , ap_terms_lines
452: , ap_invoices ai
453: WHERE ap_terms.term_id = ap_terms_lines.term_id
454: AND ap_terms_lines.term_id = P_Terms_Id
455: AND ap_terms_lines.sequence_num = l_sequence_num
456: AND ai.Invoice_Id = P_Invoice_Id;
457:
458: --Bug 7357218 Quick Pay and Dispute Resolution Project

Line 455: AND ap_terms_lines.sequence_num = l_sequence_num

451: , ap_terms_lines
452: , ap_invoices ai
453: WHERE ap_terms.term_id = ap_terms_lines.term_id
454: AND ap_terms_lines.term_id = P_Terms_Id
455: AND ap_terms_lines.sequence_num = l_sequence_num
456: AND ai.Invoice_Id = P_Invoice_Id;
457:
458: --Bug 7357218 Quick Pay and Dispute Resolution Project
459: --Calculating discount amounts by percent for slab type END

Line 487: , DECODE(ap_terms_lines.discount_days,

483:
484: SELECT P_Invoice_Id,
485: l_sequence_num
486: , l_due_date
487: , DECODE(ap_terms_lines.discount_days,
488: NULL,
489: DECODE(ap_terms_lines.discount_day_of_month, NULL, NULL,
490: TO_DATE(TO_CHAR(LEAST(NVL(ap_terms_lines.discount_day_of_month,32),
491: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS

Line 489: DECODE(ap_terms_lines.discount_day_of_month, NULL, NULL,

485: l_sequence_num
486: , l_due_date
487: , DECODE(ap_terms_lines.discount_days,
488: NULL,
489: DECODE(ap_terms_lines.discount_day_of_month, NULL, NULL,
490: TO_DATE(TO_CHAR(LEAST(NVL(ap_terms_lines.discount_day_of_month,32),
491: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS
492: (P_Terms_Date, NVL(ap_terms_lines.discount_months_forward,0) +
493: DECODE(ap_terms.due_cutoff_day, NULL, 0,

Line 490: TO_DATE(TO_CHAR(LEAST(NVL(ap_terms_lines.discount_day_of_month,32),

486: , l_due_date
487: , DECODE(ap_terms_lines.discount_days,
488: NULL,
489: DECODE(ap_terms_lines.discount_day_of_month, NULL, NULL,
490: TO_DATE(TO_CHAR(LEAST(NVL(ap_terms_lines.discount_day_of_month,32),
491: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS
492: (P_Terms_Date, NVL(ap_terms_lines.discount_months_forward,0) +
493: DECODE(ap_terms.due_cutoff_day, NULL, 0,
494: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),

Line 492: (P_Terms_Date, NVL(ap_terms_lines.discount_months_forward,0) +

488: NULL,
489: DECODE(ap_terms_lines.discount_day_of_month, NULL, NULL,
490: TO_DATE(TO_CHAR(LEAST(NVL(ap_terms_lines.discount_day_of_month,32),
491: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS
492: (P_Terms_Date, NVL(ap_terms_lines.discount_months_forward,0) +
493: DECODE(ap_terms.due_cutoff_day, NULL, 0,
494: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),
495: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date), 'DD'))),
496: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),

Line 500: NVL(ap_terms_lines.discount_months_forward,0) +

496: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),
497: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))
498: , 1, 0)))), 'DD')))) || '-' ||
499: TO_CHAR(ADD_MONTHS(P_Terms_Date,
500: NVL(ap_terms_lines.discount_months_forward,0) +
501: DECODE(ap_terms.due_cutoff_day, NULL, 0,
502: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),
503: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date),'DD'))),
504: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),

Line 508: P_Terms_Date + NVL(ap_terms_lines.discount_days,0)

504: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),
505: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD')), 1, 0))),
506: 'MON-RR'),'DD-MON-RR')
507: ),
508: P_Terms_Date + NVL(ap_terms_lines.discount_days,0)
509: )
510: , DECODE(ap_terms_lines.discount_days_2,
511: NULL,DECODE(ap_terms_lines.discount_day_of_month_2,NULL,NULL,
512: TO_DATE(TO_CHAR(LEAST

Line 510: , DECODE(ap_terms_lines.discount_days_2,

506: 'MON-RR'),'DD-MON-RR')
507: ),
508: P_Terms_Date + NVL(ap_terms_lines.discount_days,0)
509: )
510: , DECODE(ap_terms_lines.discount_days_2,
511: NULL,DECODE(ap_terms_lines.discount_day_of_month_2,NULL,NULL,
512: TO_DATE(TO_CHAR(LEAST
513: (NVL(ap_terms_lines.discount_day_of_month_2,32),
514: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(P_Terms_Date,

Line 511: NULL,DECODE(ap_terms_lines.discount_day_of_month_2,NULL,NULL,

507: ),
508: P_Terms_Date + NVL(ap_terms_lines.discount_days,0)
509: )
510: , DECODE(ap_terms_lines.discount_days_2,
511: NULL,DECODE(ap_terms_lines.discount_day_of_month_2,NULL,NULL,
512: TO_DATE(TO_CHAR(LEAST
513: (NVL(ap_terms_lines.discount_day_of_month_2,32),
514: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(P_Terms_Date,
515: NVL(ap_terms_lines.discount_months_forward_2,0) +

Line 513: (NVL(ap_terms_lines.discount_day_of_month_2,32),

509: )
510: , DECODE(ap_terms_lines.discount_days_2,
511: NULL,DECODE(ap_terms_lines.discount_day_of_month_2,NULL,NULL,
512: TO_DATE(TO_CHAR(LEAST
513: (NVL(ap_terms_lines.discount_day_of_month_2,32),
514: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(P_Terms_Date,
515: NVL(ap_terms_lines.discount_months_forward_2,0) +
516: DECODE(ap_terms.due_cutoff_day, NULL, 0,
517: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),

Line 515: NVL(ap_terms_lines.discount_months_forward_2,0) +

511: NULL,DECODE(ap_terms_lines.discount_day_of_month_2,NULL,NULL,
512: TO_DATE(TO_CHAR(LEAST
513: (NVL(ap_terms_lines.discount_day_of_month_2,32),
514: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(P_Terms_Date,
515: NVL(ap_terms_lines.discount_months_forward_2,0) +
516: DECODE(ap_terms.due_cutoff_day, NULL, 0,
517: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),
518: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date), 'DD'))),
519: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),

Line 523: NVL(ap_terms_lines.discount_months_forward_2,0) +

519: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),
520: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))
521: , 1, 0)))), 'DD')))) || '-' ||
522: TO_CHAR(ADD_MONTHS(P_Terms_Date,
523: NVL(ap_terms_lines.discount_months_forward_2,0) +
524: DECODE(ap_terms.due_cutoff_day, NULL, 0,
525: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),
526: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date),'DD'))),
527: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),

Line 530: P_Terms_Date + NVL(ap_terms_lines.discount_days_2,0))

526: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date),'DD'))),
527: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),
528: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD')), 1, 0))),
529: 'MON-RR'),'DD-MON-RR')), /*bugfix:5647464 */
530: P_Terms_Date + NVL(ap_terms_lines.discount_days_2,0))
531: , DECODE(ap_terms_lines.discount_days_3,
532: NULL, DECODE(ap_terms_lines.discount_day_of_month_3, NULL,
533: NULL,
534: TO_DATE(TO_CHAR(LEAST

Line 531: , DECODE(ap_terms_lines.discount_days_3,

527: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),
528: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD')), 1, 0))),
529: 'MON-RR'),'DD-MON-RR')), /*bugfix:5647464 */
530: P_Terms_Date + NVL(ap_terms_lines.discount_days_2,0))
531: , DECODE(ap_terms_lines.discount_days_3,
532: NULL, DECODE(ap_terms_lines.discount_day_of_month_3, NULL,
533: NULL,
534: TO_DATE(TO_CHAR(LEAST
535: (NVL(ap_terms_lines.discount_day_of_month_3,32),

Line 532: NULL, DECODE(ap_terms_lines.discount_day_of_month_3, NULL,

528: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD')), 1, 0))),
529: 'MON-RR'),'DD-MON-RR')), /*bugfix:5647464 */
530: P_Terms_Date + NVL(ap_terms_lines.discount_days_2,0))
531: , DECODE(ap_terms_lines.discount_days_3,
532: NULL, DECODE(ap_terms_lines.discount_day_of_month_3, NULL,
533: NULL,
534: TO_DATE(TO_CHAR(LEAST
535: (NVL(ap_terms_lines.discount_day_of_month_3,32),
536: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(P_Terms_Date,

Line 535: (NVL(ap_terms_lines.discount_day_of_month_3,32),

531: , DECODE(ap_terms_lines.discount_days_3,
532: NULL, DECODE(ap_terms_lines.discount_day_of_month_3, NULL,
533: NULL,
534: TO_DATE(TO_CHAR(LEAST
535: (NVL(ap_terms_lines.discount_day_of_month_3,32),
536: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(P_Terms_Date,
537: NVL(ap_terms_lines.discount_months_forward_3,0) +
538: DECODE(ap_terms.due_cutoff_day, NULL, 0,
539: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),

Line 537: NVL(ap_terms_lines.discount_months_forward_3,0) +

533: NULL,
534: TO_DATE(TO_CHAR(LEAST
535: (NVL(ap_terms_lines.discount_day_of_month_3,32),
536: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(P_Terms_Date,
537: NVL(ap_terms_lines.discount_months_forward_3,0) +
538: DECODE(ap_terms.due_cutoff_day, NULL, 0,
539: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),
540: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date), 'DD'))),
541: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),

Line 545: NVL(ap_terms_lines.discount_months_forward_3,0) +

541: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),
542: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))
543: , 1, 0)))), 'DD')))) || '-' ||
544: TO_CHAR(ADD_MONTHS(P_Terms_Date,
545: NVL(ap_terms_lines.discount_months_forward_3,0) +
546: DECODE(ap_terms.due_cutoff_day, NULL, 0,
547: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),
548: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date),'DD'))),
549: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),

Line 552: P_Terms_Date + NVL(ap_terms_lines.discount_days_3,0))

548: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date),'DD'))),
549: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),
550: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD')), 1, 0))),
551: 'MON-RR'),'DD-M0N-RR')),
552: P_Terms_Date + NVL(ap_terms_lines.discount_days_3,0))
553: , SYSDATE
554: , P_Last_Updated_By
555: , NULL
556: , SYSDATE

Line 662: , ap_terms_lines

658: T_REMIT_TO_SUPPLIER_SITE(l_payment_schedule_index),
659: T_REMIT_TO_SUPPLIER_SITE_ID(l_payment_schedule_index),
660: T_RELATIONSHIP_ID(l_payment_schedule_index)
661: FROM ap_terms
662: , ap_terms_lines
663: , ap_invoices ai
664: WHERE ap_terms.term_id = ap_terms_lines.term_id
665: AND ap_terms_lines.term_id = P_Terms_Id
666: AND ap_terms_lines.sequence_num = l_sequence_num

Line 664: WHERE ap_terms.term_id = ap_terms_lines.term_id

660: T_RELATIONSHIP_ID(l_payment_schedule_index)
661: FROM ap_terms
662: , ap_terms_lines
663: , ap_invoices ai
664: WHERE ap_terms.term_id = ap_terms_lines.term_id
665: AND ap_terms_lines.term_id = P_Terms_Id
666: AND ap_terms_lines.sequence_num = l_sequence_num
667: AND ai.Invoice_Id = P_Invoice_Id;
668:

Line 665: AND ap_terms_lines.term_id = P_Terms_Id

661: FROM ap_terms
662: , ap_terms_lines
663: , ap_invoices ai
664: WHERE ap_terms.term_id = ap_terms_lines.term_id
665: AND ap_terms_lines.term_id = P_Terms_Id
666: AND ap_terms_lines.sequence_num = l_sequence_num
667: AND ai.Invoice_Id = P_Invoice_Id;
668:
669: --

Line 666: AND ap_terms_lines.sequence_num = l_sequence_num

662: , ap_terms_lines
663: , ap_invoices ai
664: WHERE ap_terms.term_id = ap_terms_lines.term_id
665: AND ap_terms_lines.term_id = P_Terms_Id
666: AND ap_terms_lines.sequence_num = l_sequence_num
667: AND ai.Invoice_Id = P_Invoice_Id;
668:
669: --
670: l_pay_sched_total := l_pay_sched_total +

Line 748: NVL(ap_terms_lines.discount_percent,0)/100 *

744: --Bug 7357218 Quick Pay and Dispute Resolution Project
745: debug_info := 'Calculating discount amounts by percent for Percent type BEGIN';
746: SELECT DECODE(l_min_acc_unit_pay_curr,NULL,
747: ROUND( l_amount_for_discount *
748: NVL(ap_terms_lines.discount_percent,0)/100 *
749: NVL(ap_terms_lines.due_percent, 0)/100, l_precision_pay_curr),
750: ROUND(( l_amount_for_discount *
751: NVL(ap_terms_lines.discount_percent,0)/100 *
752: NVL(ap_terms_lines.due_percent, 0)/100)

Line 749: NVL(ap_terms_lines.due_percent, 0)/100, l_precision_pay_curr),

745: debug_info := 'Calculating discount amounts by percent for Percent type BEGIN';
746: SELECT DECODE(l_min_acc_unit_pay_curr,NULL,
747: ROUND( l_amount_for_discount *
748: NVL(ap_terms_lines.discount_percent,0)/100 *
749: NVL(ap_terms_lines.due_percent, 0)/100, l_precision_pay_curr),
750: ROUND(( l_amount_for_discount *
751: NVL(ap_terms_lines.discount_percent,0)/100 *
752: NVL(ap_terms_lines.due_percent, 0)/100)
753: / l_min_acc_unit_pay_curr)

Line 751: NVL(ap_terms_lines.discount_percent,0)/100 *

747: ROUND( l_amount_for_discount *
748: NVL(ap_terms_lines.discount_percent,0)/100 *
749: NVL(ap_terms_lines.due_percent, 0)/100, l_precision_pay_curr),
750: ROUND(( l_amount_for_discount *
751: NVL(ap_terms_lines.discount_percent,0)/100 *
752: NVL(ap_terms_lines.due_percent, 0)/100)
753: / l_min_acc_unit_pay_curr)
754: * l_min_acc_unit_pay_curr)
755: , DECODE(l_min_acc_unit_pay_curr,NULL,

Line 752: NVL(ap_terms_lines.due_percent, 0)/100)

748: NVL(ap_terms_lines.discount_percent,0)/100 *
749: NVL(ap_terms_lines.due_percent, 0)/100, l_precision_pay_curr),
750: ROUND(( l_amount_for_discount *
751: NVL(ap_terms_lines.discount_percent,0)/100 *
752: NVL(ap_terms_lines.due_percent, 0)/100)
753: / l_min_acc_unit_pay_curr)
754: * l_min_acc_unit_pay_curr)
755: , DECODE(l_min_acc_unit_pay_curr,NULL,
756: ROUND( l_amount_for_discount *

Line 757: NVL(ap_terms_lines.discount_percent_2,0)/100 *

753: / l_min_acc_unit_pay_curr)
754: * l_min_acc_unit_pay_curr)
755: , DECODE(l_min_acc_unit_pay_curr,NULL,
756: ROUND( l_amount_for_discount *
757: NVL(ap_terms_lines.discount_percent_2,0)/100 *
758: NVL(ap_terms_lines.due_percent, 0)/100, l_precision_pay_curr),
759: ROUND(( l_amount_for_discount *
760: NVL(ap_terms_lines.discount_percent_2,0)/100 *
761: NVL(ap_terms_lines.due_percent, 0)/100)

Line 758: NVL(ap_terms_lines.due_percent, 0)/100, l_precision_pay_curr),

754: * l_min_acc_unit_pay_curr)
755: , DECODE(l_min_acc_unit_pay_curr,NULL,
756: ROUND( l_amount_for_discount *
757: NVL(ap_terms_lines.discount_percent_2,0)/100 *
758: NVL(ap_terms_lines.due_percent, 0)/100, l_precision_pay_curr),
759: ROUND(( l_amount_for_discount *
760: NVL(ap_terms_lines.discount_percent_2,0)/100 *
761: NVL(ap_terms_lines.due_percent, 0)/100)
762: / l_min_acc_unit_pay_curr)*l_min_acc_unit_pay_curr)

Line 760: NVL(ap_terms_lines.discount_percent_2,0)/100 *

756: ROUND( l_amount_for_discount *
757: NVL(ap_terms_lines.discount_percent_2,0)/100 *
758: NVL(ap_terms_lines.due_percent, 0)/100, l_precision_pay_curr),
759: ROUND(( l_amount_for_discount *
760: NVL(ap_terms_lines.discount_percent_2,0)/100 *
761: NVL(ap_terms_lines.due_percent, 0)/100)
762: / l_min_acc_unit_pay_curr)*l_min_acc_unit_pay_curr)
763: , DECODE(l_min_acc_unit_pay_curr,NULL,
764: ROUND( l_amount_for_discount *

Line 761: NVL(ap_terms_lines.due_percent, 0)/100)

757: NVL(ap_terms_lines.discount_percent_2,0)/100 *
758: NVL(ap_terms_lines.due_percent, 0)/100, l_precision_pay_curr),
759: ROUND(( l_amount_for_discount *
760: NVL(ap_terms_lines.discount_percent_2,0)/100 *
761: NVL(ap_terms_lines.due_percent, 0)/100)
762: / l_min_acc_unit_pay_curr)*l_min_acc_unit_pay_curr)
763: , DECODE(l_min_acc_unit_pay_curr,NULL,
764: ROUND( l_amount_for_discount *
765: NVL(ap_terms_lines.discount_percent_3,0)/100 *

Line 765: NVL(ap_terms_lines.discount_percent_3,0)/100 *

761: NVL(ap_terms_lines.due_percent, 0)/100)
762: / l_min_acc_unit_pay_curr)*l_min_acc_unit_pay_curr)
763: , DECODE(l_min_acc_unit_pay_curr,NULL,
764: ROUND( l_amount_for_discount *
765: NVL(ap_terms_lines.discount_percent_3,0)/100 *
766: NVL(ap_terms_lines.due_percent, 0)/100, l_precision_pay_curr),
767: ROUND(( l_amount_for_discount *
768: NVL(ap_terms_lines.discount_percent_3,0)/100 *
769: NVL(ap_terms_lines.due_percent, 0)/100)

Line 766: NVL(ap_terms_lines.due_percent, 0)/100, l_precision_pay_curr),

762: / l_min_acc_unit_pay_curr)*l_min_acc_unit_pay_curr)
763: , DECODE(l_min_acc_unit_pay_curr,NULL,
764: ROUND( l_amount_for_discount *
765: NVL(ap_terms_lines.discount_percent_3,0)/100 *
766: NVL(ap_terms_lines.due_percent, 0)/100, l_precision_pay_curr),
767: ROUND(( l_amount_for_discount *
768: NVL(ap_terms_lines.discount_percent_3,0)/100 *
769: NVL(ap_terms_lines.due_percent, 0)/100)
770: / l_min_acc_unit_pay_curr)*l_min_acc_unit_pay_curr),

Line 768: NVL(ap_terms_lines.discount_percent_3,0)/100 *

764: ROUND( l_amount_for_discount *
765: NVL(ap_terms_lines.discount_percent_3,0)/100 *
766: NVL(ap_terms_lines.due_percent, 0)/100, l_precision_pay_curr),
767: ROUND(( l_amount_for_discount *
768: NVL(ap_terms_lines.discount_percent_3,0)/100 *
769: NVL(ap_terms_lines.due_percent, 0)/100)
770: / l_min_acc_unit_pay_curr)*l_min_acc_unit_pay_curr),
771: discount_amount,
772: discount_amount_2,

Line 769: NVL(ap_terms_lines.due_percent, 0)/100)

765: NVL(ap_terms_lines.discount_percent_3,0)/100 *
766: NVL(ap_terms_lines.due_percent, 0)/100, l_precision_pay_curr),
767: ROUND(( l_amount_for_discount *
768: NVL(ap_terms_lines.discount_percent_3,0)/100 *
769: NVL(ap_terms_lines.due_percent, 0)/100)
770: / l_min_acc_unit_pay_curr)*l_min_acc_unit_pay_curr),
771: discount_amount,
772: discount_amount_2,
773: discount_amount_3

Line 779: ap_terms_lines,

775: l_disc_amt_by_percent, l_disc_amt_by_percent_2, l_disc_amt_by_percent_3,
776: l_discount_amount, l_discount_amount_2, l_discount_amount_3
777:
778: FROM ap_terms,
779: ap_terms_lines,
780: ap_invoices ai
781: WHERE ap_terms.term_id = ap_terms_lines.term_id
782: AND ap_terms_lines.term_id = P_Terms_Id
783: AND ap_terms_lines.sequence_num = l_sequence_num

Line 781: WHERE ap_terms.term_id = ap_terms_lines.term_id

777:
778: FROM ap_terms,
779: ap_terms_lines,
780: ap_invoices ai
781: WHERE ap_terms.term_id = ap_terms_lines.term_id
782: AND ap_terms_lines.term_id = P_Terms_Id
783: AND ap_terms_lines.sequence_num = l_sequence_num
784: AND ai.invoice_id = P_Invoice_Id;
785:

Line 782: AND ap_terms_lines.term_id = P_Terms_Id

778: FROM ap_terms,
779: ap_terms_lines,
780: ap_invoices ai
781: WHERE ap_terms.term_id = ap_terms_lines.term_id
782: AND ap_terms_lines.term_id = P_Terms_Id
783: AND ap_terms_lines.sequence_num = l_sequence_num
784: AND ai.invoice_id = P_Invoice_Id;
785:
786: --Bug 7357218 Quick Pay and Dispute Resolution Project

Line 783: AND ap_terms_lines.sequence_num = l_sequence_num

779: ap_terms_lines,
780: ap_invoices ai
781: WHERE ap_terms.term_id = ap_terms_lines.term_id
782: AND ap_terms_lines.term_id = P_Terms_Id
783: AND ap_terms_lines.sequence_num = l_sequence_num
784: AND ai.invoice_id = P_Invoice_Id;
785:
786: --Bug 7357218 Quick Pay and Dispute Resolution Project
787: --Calculating discount amounts by percent for Percent type END

Line 814: DECODE(ap_terms_lines.discount_days,

810:
811: SELECT P_Invoice_Id,l_sequence_num
812: , l_due_date
813: , DECODE(l_amount_for_discount, NULL, NULL,
814: DECODE(ap_terms_lines.discount_days,
815: NULL, DECODE(ap_terms_lines.discount_day_of_month, NULL, NULL,
816: TO_DATE(TO_CHAR(LEAST(NVL(ap_terms_lines.discount_day_of_month,32),
817: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS
818: (P_Terms_Date,

Line 815: NULL, DECODE(ap_terms_lines.discount_day_of_month, NULL, NULL,

811: SELECT P_Invoice_Id,l_sequence_num
812: , l_due_date
813: , DECODE(l_amount_for_discount, NULL, NULL,
814: DECODE(ap_terms_lines.discount_days,
815: NULL, DECODE(ap_terms_lines.discount_day_of_month, NULL, NULL,
816: TO_DATE(TO_CHAR(LEAST(NVL(ap_terms_lines.discount_day_of_month,32),
817: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS
818: (P_Terms_Date,
819: NVL(ap_terms_lines.discount_months_forward,0) +

Line 816: TO_DATE(TO_CHAR(LEAST(NVL(ap_terms_lines.discount_day_of_month,32),

812: , l_due_date
813: , DECODE(l_amount_for_discount, NULL, NULL,
814: DECODE(ap_terms_lines.discount_days,
815: NULL, DECODE(ap_terms_lines.discount_day_of_month, NULL, NULL,
816: TO_DATE(TO_CHAR(LEAST(NVL(ap_terms_lines.discount_day_of_month,32),
817: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS
818: (P_Terms_Date,
819: NVL(ap_terms_lines.discount_months_forward,0) +
820: DECODE(ap_terms.due_cutoff_day, NULL, 0,

Line 819: NVL(ap_terms_lines.discount_months_forward,0) +

815: NULL, DECODE(ap_terms_lines.discount_day_of_month, NULL, NULL,
816: TO_DATE(TO_CHAR(LEAST(NVL(ap_terms_lines.discount_day_of_month,32),
817: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS
818: (P_Terms_Date,
819: NVL(ap_terms_lines.discount_months_forward,0) +
820: DECODE(ap_terms.due_cutoff_day, NULL, 0,
821: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),
822: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date), 'DD'))),
823: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),

Line 827: NVL(ap_terms_lines.discount_months_forward,0) +

823: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),
824: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))
825: , 1, 0)))), 'DD')))) || '-' ||
826: TO_CHAR(ADD_MONTHS(P_Terms_Date,
827: NVL(ap_terms_lines.discount_months_forward,0) +
828: DECODE(ap_terms.due_cutoff_day, NULL, 0,
829: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),
830: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date),'DD'))),
831: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),

Line 834: P_Terms_Date + NVL(ap_terms_lines.discount_days,0)))

830: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date),'DD'))),
831: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),
832: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD')), 1, 0))),
833: 'MON-RR'),'DD-MON-RR')),
834: P_Terms_Date + NVL(ap_terms_lines.discount_days,0)))
835: , DECODE(l_amount_for_discount, NULL, NULL,
836: DECODE(ap_terms_lines.discount_days_2,
837: NULL,DECODE(ap_terms_lines.discount_day_of_month_2,NULL,NULL,
838: TO_DATE(TO_CHAR(LEAST(

Line 836: DECODE(ap_terms_lines.discount_days_2,

832: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD')), 1, 0))),
833: 'MON-RR'),'DD-MON-RR')),
834: P_Terms_Date + NVL(ap_terms_lines.discount_days,0)))
835: , DECODE(l_amount_for_discount, NULL, NULL,
836: DECODE(ap_terms_lines.discount_days_2,
837: NULL,DECODE(ap_terms_lines.discount_day_of_month_2,NULL,NULL,
838: TO_DATE(TO_CHAR(LEAST(
839: NVL(ap_terms_lines.discount_day_of_month_2,32),
840: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(P_Terms_Date,

Line 837: NULL,DECODE(ap_terms_lines.discount_day_of_month_2,NULL,NULL,

833: 'MON-RR'),'DD-MON-RR')),
834: P_Terms_Date + NVL(ap_terms_lines.discount_days,0)))
835: , DECODE(l_amount_for_discount, NULL, NULL,
836: DECODE(ap_terms_lines.discount_days_2,
837: NULL,DECODE(ap_terms_lines.discount_day_of_month_2,NULL,NULL,
838: TO_DATE(TO_CHAR(LEAST(
839: NVL(ap_terms_lines.discount_day_of_month_2,32),
840: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(P_Terms_Date,
841: NVL(ap_terms_lines.discount_months_forward_2,0) +

Line 839: NVL(ap_terms_lines.discount_day_of_month_2,32),

835: , DECODE(l_amount_for_discount, NULL, NULL,
836: DECODE(ap_terms_lines.discount_days_2,
837: NULL,DECODE(ap_terms_lines.discount_day_of_month_2,NULL,NULL,
838: TO_DATE(TO_CHAR(LEAST(
839: NVL(ap_terms_lines.discount_day_of_month_2,32),
840: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(P_Terms_Date,
841: NVL(ap_terms_lines.discount_months_forward_2,0) +
842: DECODE(ap_terms.due_cutoff_day, NULL, 0,
843: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),

Line 841: NVL(ap_terms_lines.discount_months_forward_2,0) +

837: NULL,DECODE(ap_terms_lines.discount_day_of_month_2,NULL,NULL,
838: TO_DATE(TO_CHAR(LEAST(
839: NVL(ap_terms_lines.discount_day_of_month_2,32),
840: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(P_Terms_Date,
841: NVL(ap_terms_lines.discount_months_forward_2,0) +
842: DECODE(ap_terms.due_cutoff_day, NULL, 0,
843: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),
844: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date), 'DD'))),
845: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),

Line 849: NVL(ap_terms_lines.discount_months_forward_2,0) +

845: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),
846: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))
847: , 1, 0)))), 'DD')))) || '-' ||
848: TO_CHAR(ADD_MONTHS(P_Terms_Date,
849: NVL(ap_terms_lines.discount_months_forward_2,0) +
850: DECODE(ap_terms.due_cutoff_day, NULL, 0,
851: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),
852: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date),'DD'))),
853: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),

Line 856: P_Terms_Date + NVL(ap_terms_lines.discount_days_2,0)))

852: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date),'DD'))),
853: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),
854: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD')), 1, 0))),
855: 'MON-RR'),'DD-MON-RR')),
856: P_Terms_Date + NVL(ap_terms_lines.discount_days_2,0)))
857: , DECODE(l_amount_for_discount, NULL, NULL,
858: DECODE(ap_terms_lines.discount_days_3,
859: NULL,DECODE(ap_terms_lines.discount_day_of_month_3,NULL,NULL,
860: TO_DATE(TO_CHAR(LEAST(

Line 858: DECODE(ap_terms_lines.discount_days_3,

854: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD')), 1, 0))),
855: 'MON-RR'),'DD-MON-RR')),
856: P_Terms_Date + NVL(ap_terms_lines.discount_days_2,0)))
857: , DECODE(l_amount_for_discount, NULL, NULL,
858: DECODE(ap_terms_lines.discount_days_3,
859: NULL,DECODE(ap_terms_lines.discount_day_of_month_3,NULL,NULL,
860: TO_DATE(TO_CHAR(LEAST(
861: NVL(ap_terms_lines.discount_day_of_month_3,32),
862: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(P_Terms_Date,

Line 859: NULL,DECODE(ap_terms_lines.discount_day_of_month_3,NULL,NULL,

855: 'MON-RR'),'DD-MON-RR')),
856: P_Terms_Date + NVL(ap_terms_lines.discount_days_2,0)))
857: , DECODE(l_amount_for_discount, NULL, NULL,
858: DECODE(ap_terms_lines.discount_days_3,
859: NULL,DECODE(ap_terms_lines.discount_day_of_month_3,NULL,NULL,
860: TO_DATE(TO_CHAR(LEAST(
861: NVL(ap_terms_lines.discount_day_of_month_3,32),
862: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(P_Terms_Date,
863: NVL(ap_terms_lines.discount_months_forward_3,0) +

Line 861: NVL(ap_terms_lines.discount_day_of_month_3,32),

857: , DECODE(l_amount_for_discount, NULL, NULL,
858: DECODE(ap_terms_lines.discount_days_3,
859: NULL,DECODE(ap_terms_lines.discount_day_of_month_3,NULL,NULL,
860: TO_DATE(TO_CHAR(LEAST(
861: NVL(ap_terms_lines.discount_day_of_month_3,32),
862: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(P_Terms_Date,
863: NVL(ap_terms_lines.discount_months_forward_3,0) +
864: DECODE(ap_terms.due_cutoff_day, NULL, 0,
865: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),

Line 863: NVL(ap_terms_lines.discount_months_forward_3,0) +

859: NULL,DECODE(ap_terms_lines.discount_day_of_month_3,NULL,NULL,
860: TO_DATE(TO_CHAR(LEAST(
861: NVL(ap_terms_lines.discount_day_of_month_3,32),
862: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(P_Terms_Date,
863: NVL(ap_terms_lines.discount_months_forward_3,0) +
864: DECODE(ap_terms.due_cutoff_day, NULL, 0,
865: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),
866: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date), 'DD'))),
867: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),

Line 871: NVL(ap_terms_lines.discount_months_forward_3,0) +

867: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),
868: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))
869: , 1, 0)))), 'DD')))) || '-' ||
870: TO_CHAR(ADD_MONTHS(P_Terms_Date,
871: NVL(ap_terms_lines.discount_months_forward_3,0) +
872: DECODE(ap_terms.due_cutoff_day, NULL, 0,
873: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),
874: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date),'DD'))),
875: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),

Line 878: P_Terms_Date + NVL(ap_terms_lines.discount_days_3,0)))

874: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date),'DD'))),
875: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),
876: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD')), 1, 0))),
877: 'MON-RR'),'DD-M0N-RR')),
878: P_Terms_Date + NVL(ap_terms_lines.discount_days_3,0)))
879: , SYSDATE
880: , P_Last_Updated_By
881: , NULL
882: , SYSDATE

Line 887: NVL(ap_terms_lines.due_percent,0)/100,l_precision_pay_curr),

883: , P_Created_By
884: , l_payment_cross_rate
885: , DECODE(l_min_acc_unit_pay_curr,NULL,
886: ROUND(P_Pay_Curr_Invoice_Amount *
887: NVL(ap_terms_lines.due_percent,0)/100,l_precision_pay_curr),
888: ROUND((P_Pay_Curr_Invoice_Amount *
889: NVL(ap_terms_lines.due_percent,0)/100)
890: / l_min_acc_unit_pay_curr)
891: * l_min_acc_unit_pay_curr)

Line 889: NVL(ap_terms_lines.due_percent,0)/100)

885: , DECODE(l_min_acc_unit_pay_curr,NULL,
886: ROUND(P_Pay_Curr_Invoice_Amount *
887: NVL(ap_terms_lines.due_percent,0)/100,l_precision_pay_curr),
888: ROUND((P_Pay_Curr_Invoice_Amount *
889: NVL(ap_terms_lines.due_percent,0)/100)
890: / l_min_acc_unit_pay_curr)
891: * l_min_acc_unit_pay_curr)
892: , NULL ,
893:

Line 933: NVL(ap_terms_lines.due_percent, 0)/100, l_precision_pay_curr),

929: END,
930:
931: DECODE(l_min_acc_unit_pay_curr,NULL,
932: ROUND( P_Pay_Curr_Invoice_Amount *
933: NVL(ap_terms_lines.due_percent, 0)/100, l_precision_pay_curr),
934: ROUND(( P_Pay_Curr_Invoice_Amount *
935: NVL(ap_terms_lines.due_percent, 0)/100)
936: / l_min_acc_unit_pay_curr)*l_min_acc_unit_pay_curr)
937: , 0

Line 935: NVL(ap_terms_lines.due_percent, 0)/100)

931: DECODE(l_min_acc_unit_pay_curr,NULL,
932: ROUND( P_Pay_Curr_Invoice_Amount *
933: NVL(ap_terms_lines.due_percent, 0)/100, l_precision_pay_curr),
934: ROUND(( P_Pay_Curr_Invoice_Amount *
935: NVL(ap_terms_lines.due_percent, 0)/100)
936: / l_min_acc_unit_pay_curr)*l_min_acc_unit_pay_curr)
937: , 0
938: , 'N'
939: , 'N'

Line 989: , ap_terms_lines

985: T_REMIT_TO_SUPPLIER_SITE(l_payment_schedule_index),
986: T_REMIT_TO_SUPPLIER_SITE_ID(l_payment_schedule_index),
987: T_RELATIONSHIP_ID(l_payment_schedule_index)
988: FROM ap_terms
989: , ap_terms_lines
990: , ap_invoices ai
991: WHERE ap_terms.term_id = ap_terms_lines.term_id
992: AND ap_terms_lines.term_id = P_Terms_Id
993: AND ap_terms_lines.sequence_num = l_sequence_num

Line 991: WHERE ap_terms.term_id = ap_terms_lines.term_id

987: T_RELATIONSHIP_ID(l_payment_schedule_index)
988: FROM ap_terms
989: , ap_terms_lines
990: , ap_invoices ai
991: WHERE ap_terms.term_id = ap_terms_lines.term_id
992: AND ap_terms_lines.term_id = P_Terms_Id
993: AND ap_terms_lines.sequence_num = l_sequence_num
994: AND ai.invoice_id = P_Invoice_Id;
995:

Line 992: AND ap_terms_lines.term_id = P_Terms_Id

988: FROM ap_terms
989: , ap_terms_lines
990: , ap_invoices ai
991: WHERE ap_terms.term_id = ap_terms_lines.term_id
992: AND ap_terms_lines.term_id = P_Terms_Id
993: AND ap_terms_lines.sequence_num = l_sequence_num
994: AND ai.invoice_id = P_Invoice_Id;
995:
996: --

Line 993: AND ap_terms_lines.sequence_num = l_sequence_num

989: , ap_terms_lines
990: , ap_invoices ai
991: WHERE ap_terms.term_id = ap_terms_lines.term_id
992: AND ap_terms_lines.term_id = P_Terms_Id
993: AND ap_terms_lines.sequence_num = l_sequence_num
994: AND ai.invoice_id = P_Invoice_Id;
995:
996: --
997: l_pay_sched_total := l_pay_sched_total +

Line 1211: -- All amounts in AP_TERMS_LINES will be interpreted to be in the payment

1207: -- ====== ==========
1208: -- P_Invoice_amount invoice currency
1209: -- P_Pay_Curr_Invoice_Amount payment currency
1210: -- P_Amount_For_Discount invoice currency
1211: -- All amounts in AP_TERMS_LINES will be interpreted to be in the payment
1212: -- currency
1213:
1214: l_payment_cross_rate ap_payment_schedules.payment_cross_rate%TYPE;
1215: l_sequence_num ap_terms_lines.sequence_num%TYPE := 0;

Line 1215: l_sequence_num ap_terms_lines.sequence_num%TYPE := 0;

1211: -- All amounts in AP_TERMS_LINES will be interpreted to be in the payment
1212: -- currency
1213:
1214: l_payment_cross_rate ap_payment_schedules.payment_cross_rate%TYPE;
1215: l_sequence_num ap_terms_lines.sequence_num%TYPE := 0;
1216: l_sign_due_amount ap_terms_lines.due_amount%TYPE;
1217: l_sign_remaining_amount ap_terms_lines.due_amount%TYPE;
1218: l_calendar ap_terms_lines.calendar%TYPE; -- for payment terms
1219: l_terms_calendar ap_terms_lines.calendar%TYPE; -- for payment terms

Line 1216: l_sign_due_amount ap_terms_lines.due_amount%TYPE;

1212: -- currency
1213:
1214: l_payment_cross_rate ap_payment_schedules.payment_cross_rate%TYPE;
1215: l_sequence_num ap_terms_lines.sequence_num%TYPE := 0;
1216: l_sign_due_amount ap_terms_lines.due_amount%TYPE;
1217: l_sign_remaining_amount ap_terms_lines.due_amount%TYPE;
1218: l_calendar ap_terms_lines.calendar%TYPE; -- for payment terms
1219: l_terms_calendar ap_terms_lines.calendar%TYPE; -- for payment terms
1220: l_due_date ap_other_periods.due_date%TYPE; -- for payment terms

Line 1217: l_sign_remaining_amount ap_terms_lines.due_amount%TYPE;

1213:
1214: l_payment_cross_rate ap_payment_schedules.payment_cross_rate%TYPE;
1215: l_sequence_num ap_terms_lines.sequence_num%TYPE := 0;
1216: l_sign_due_amount ap_terms_lines.due_amount%TYPE;
1217: l_sign_remaining_amount ap_terms_lines.due_amount%TYPE;
1218: l_calendar ap_terms_lines.calendar%TYPE; -- for payment terms
1219: l_terms_calendar ap_terms_lines.calendar%TYPE; -- for payment terms
1220: l_due_date ap_other_periods.due_date%TYPE; -- for payment terms
1221: l_invoice_sign NUMBER;

Line 1218: l_calendar ap_terms_lines.calendar%TYPE; -- for payment terms

1214: l_payment_cross_rate ap_payment_schedules.payment_cross_rate%TYPE;
1215: l_sequence_num ap_terms_lines.sequence_num%TYPE := 0;
1216: l_sign_due_amount ap_terms_lines.due_amount%TYPE;
1217: l_sign_remaining_amount ap_terms_lines.due_amount%TYPE;
1218: l_calendar ap_terms_lines.calendar%TYPE; -- for payment terms
1219: l_terms_calendar ap_terms_lines.calendar%TYPE; -- for payment terms
1220: l_due_date ap_other_periods.due_date%TYPE; -- for payment terms
1221: l_invoice_sign NUMBER;
1222: l_pay_sched_total NUMBER;

Line 1219: l_terms_calendar ap_terms_lines.calendar%TYPE; -- for payment terms

1215: l_sequence_num ap_terms_lines.sequence_num%TYPE := 0;
1216: l_sign_due_amount ap_terms_lines.due_amount%TYPE;
1217: l_sign_remaining_amount ap_terms_lines.due_amount%TYPE;
1218: l_calendar ap_terms_lines.calendar%TYPE; -- for payment terms
1219: l_terms_calendar ap_terms_lines.calendar%TYPE; -- for payment terms
1220: l_due_date ap_other_periods.due_date%TYPE; -- for payment terms
1221: l_invoice_sign NUMBER;
1222: l_pay_sched_total NUMBER;
1223: l_inv_curr_sched_total NUMBER;

Line 1262: FROM ap_terms_lines

1258: l_log_msg FND_LOG_MESSAGES.MESSAGE_TEXT%TYPE;
1259:
1260: CURSOR c_terms_percent IS
1261: SELECT 'Terms are percent type'
1262: FROM ap_terms_lines
1263: WHERE term_id = P_Terms_Id
1264: AND sequence_num = 1
1265: AND due_percent IS NOT NULL;
1266:

Line 1271: FROM ap_terms_lines

1267: -- add cursor c_terms for calendar based payment terms
1268:
1269: CURSOR c_terms IS
1270: SELECT calendar, sequence_num
1271: FROM ap_terms_lines
1272: WHERE term_id = p_terms_id
1273: ORDER BY sequence_num;
1274:
1275: --bug 2143298 provides payment terms for credit/debit memo

Line 1283: FROM ap_terms_lines

1279: due_amount ,
1280: SIGN(ABS(l_remaining_amount) - ABS(due_amount)) ,
1281: ABS(l_remaining_amount) - ABS(due_amount) ,
1282: calendar -- change for calendar based payment terms
1283: FROM ap_terms_lines
1284: WHERE term_id = P_Terms_Id
1285: AND sequence_num = l_sequence_num;
1286:
1287: CURSOR c_shed_total IS

Line 1532: NVL(ap_terms_lines.discount_percent,0)/100 ,

1528: DECODE(P_Pay_Curr_Invoice_Amount, 0, 0,
1529: (l_amount_for_discount/
1530: DECODE(P_Pay_Curr_Invoice_Amount, 0, 1,
1531: P_Pay_Curr_Invoice_Amount))) *
1532: NVL(ap_terms_lines.discount_percent,0)/100 ,
1533: l_precision_pay_curr),
1534: ROUND(( l_ins_gross_amount *
1535: DECODE(P_Pay_Curr_Invoice_Amount, 0, 0,
1536: (l_amount_for_discount/

Line 1539: NVL(ap_terms_lines.discount_percent,0)/100)

1535: DECODE(P_Pay_Curr_Invoice_Amount, 0, 0,
1536: (l_amount_for_discount/
1537: DECODE(P_Pay_Curr_Invoice_Amount, 0, 1,
1538: P_Pay_Curr_Invoice_Amount))) *
1539: NVL(ap_terms_lines.discount_percent,0)/100)
1540: / l_min_acc_unit_pay_curr) * l_min_acc_unit_pay_curr)
1541: , DECODE(l_min_acc_unit_pay_curr,
1542: NULL, ROUND( l_ins_gross_amount *
1543: DECODE(P_Pay_Curr_Invoice_Amount, 0, 0,

Line 1547: NVL(ap_terms_lines.discount_percent_2,0)/100 ,

1543: DECODE(P_Pay_Curr_Invoice_Amount, 0, 0,
1544: (l_amount_for_discount/
1545: DECODE(P_Pay_Curr_Invoice_Amount, 0, 1,
1546: P_Pay_Curr_Invoice_Amount))) *
1547: NVL(ap_terms_lines.discount_percent_2,0)/100 ,
1548: l_precision_pay_curr),
1549: ROUND(( l_ins_gross_amount *
1550: DECODE(P_Pay_Curr_Invoice_Amount, 0, 0,
1551: (l_amount_for_discount/

Line 1554: NVL(ap_terms_lines.discount_percent_2,0)/100)

1550: DECODE(P_Pay_Curr_Invoice_Amount, 0, 0,
1551: (l_amount_for_discount/
1552: DECODE(P_Pay_Curr_Invoice_Amount, 0, 1,
1553: P_Pay_Curr_Invoice_Amount))) *
1554: NVL(ap_terms_lines.discount_percent_2,0)/100)
1555: / l_min_acc_unit_pay_curr) * l_min_acc_unit_pay_curr)
1556: , DECODE(l_min_acc_unit_pay_curr,
1557: NULL, ROUND( l_ins_gross_amount *
1558: DECODE(P_Pay_Curr_Invoice_Amount, 0, 0,

Line 1562: NVL(ap_terms_lines.discount_percent_3,0)/100 ,

1558: DECODE(P_Pay_Curr_Invoice_Amount, 0, 0,
1559: (l_amount_for_discount/
1560: DECODE(P_Pay_Curr_Invoice_Amount, 0, 1,
1561: P_Pay_Curr_Invoice_Amount))) *
1562: NVL(ap_terms_lines.discount_percent_3,0)/100 ,
1563: l_precision_pay_curr),
1564: ROUND(( l_ins_gross_amount *
1565: DECODE(P_Pay_Curr_Invoice_Amount, 0, 0,
1566: (l_amount_for_discount/

Line 1569: NVL(ap_terms_lines.discount_percent_3,0)/100)

1565: DECODE(P_Pay_Curr_Invoice_Amount, 0, 0,
1566: (l_amount_for_discount/
1567: DECODE(P_Pay_Curr_Invoice_Amount, 0, 1,
1568: P_Pay_Curr_Invoice_Amount))) *
1569: NVL(ap_terms_lines.discount_percent_3,0)/100)
1570: / l_min_acc_unit_pay_curr) * l_min_acc_unit_pay_curr),
1571: discount_amount,
1572: discount_amount_2,
1573: discount_amount_3

Line 1579: , ap_terms_lines

1575: l_disc_amt_by_percent, l_disc_amt_by_percent_2, l_disc_amt_by_percent_3,
1576: l_discount_amount, l_discount_amount_2, l_discount_amount_3
1577:
1578: FROM ap_terms
1579: , ap_terms_lines
1580: , ap_invoices ai
1581: WHERE ap_terms.term_id = ap_terms_lines.term_id
1582: AND ap_terms_lines.term_id = P_Terms_Id
1583: AND ap_terms_lines.sequence_num = l_sequence_num

Line 1581: WHERE ap_terms.term_id = ap_terms_lines.term_id

1577:
1578: FROM ap_terms
1579: , ap_terms_lines
1580: , ap_invoices ai
1581: WHERE ap_terms.term_id = ap_terms_lines.term_id
1582: AND ap_terms_lines.term_id = P_Terms_Id
1583: AND ap_terms_lines.sequence_num = l_sequence_num
1584: AND ai.Invoice_Id = P_Invoice_Id;
1585:

Line 1582: AND ap_terms_lines.term_id = P_Terms_Id

1578: FROM ap_terms
1579: , ap_terms_lines
1580: , ap_invoices ai
1581: WHERE ap_terms.term_id = ap_terms_lines.term_id
1582: AND ap_terms_lines.term_id = P_Terms_Id
1583: AND ap_terms_lines.sequence_num = l_sequence_num
1584: AND ai.Invoice_Id = P_Invoice_Id;
1585:
1586: --Bug 7357218 Quick Pay and Dispute Resolution Project

Line 1583: AND ap_terms_lines.sequence_num = l_sequence_num

1579: , ap_terms_lines
1580: , ap_invoices ai
1581: WHERE ap_terms.term_id = ap_terms_lines.term_id
1582: AND ap_terms_lines.term_id = P_Terms_Id
1583: AND ap_terms_lines.sequence_num = l_sequence_num
1584: AND ai.Invoice_Id = P_Invoice_Id;
1585:
1586: --Bug 7357218 Quick Pay and Dispute Resolution Project
1587: --Calculating discount amounts by percent for slab type END

Line 1656: DECODE(ap_terms_lines.discount_days,

1652: SELECT
1653: P_Invoice_Id,
1654: l_sequence_num,
1655: l_due_date, -- change for payment terms
1656: DECODE(ap_terms_lines.discount_days,
1657: NULL, DECODE(ap_terms_lines.discount_day_of_month, NULL, NULL,
1658: TO_DATE(TO_CHAR(LEAST(NVL(ap_terms_lines.discount_day_of_month,32),
1659: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS
1660: (P_Terms_Date, NVL(ap_terms_lines.discount_months_forward,0) +

Line 1657: NULL, DECODE(ap_terms_lines.discount_day_of_month, NULL, NULL,

1653: P_Invoice_Id,
1654: l_sequence_num,
1655: l_due_date, -- change for payment terms
1656: DECODE(ap_terms_lines.discount_days,
1657: NULL, DECODE(ap_terms_lines.discount_day_of_month, NULL, NULL,
1658: TO_DATE(TO_CHAR(LEAST(NVL(ap_terms_lines.discount_day_of_month,32),
1659: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS
1660: (P_Terms_Date, NVL(ap_terms_lines.discount_months_forward,0) +
1661: DECODE(ap_terms.due_cutoff_day, NULL, 0,

Line 1658: TO_DATE(TO_CHAR(LEAST(NVL(ap_terms_lines.discount_day_of_month,32),

1654: l_sequence_num,
1655: l_due_date, -- change for payment terms
1656: DECODE(ap_terms_lines.discount_days,
1657: NULL, DECODE(ap_terms_lines.discount_day_of_month, NULL, NULL,
1658: TO_DATE(TO_CHAR(LEAST(NVL(ap_terms_lines.discount_day_of_month,32),
1659: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS
1660: (P_Terms_Date, NVL(ap_terms_lines.discount_months_forward,0) +
1661: DECODE(ap_terms.due_cutoff_day, NULL, 0,
1662: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),

Line 1660: (P_Terms_Date, NVL(ap_terms_lines.discount_months_forward,0) +

1656: DECODE(ap_terms_lines.discount_days,
1657: NULL, DECODE(ap_terms_lines.discount_day_of_month, NULL, NULL,
1658: TO_DATE(TO_CHAR(LEAST(NVL(ap_terms_lines.discount_day_of_month,32),
1659: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS
1660: (P_Terms_Date, NVL(ap_terms_lines.discount_months_forward,0) +
1661: DECODE(ap_terms.due_cutoff_day, NULL, 0,
1662: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),
1663: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date), 'DD'))),
1664: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),

Line 1668: NVL(ap_terms_lines.discount_months_forward,0) +

1664: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),
1665: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))
1666: , 1, 0)))), 'DD')))) || '-' ||
1667: TO_CHAR(ADD_MONTHS(P_Terms_Date,
1668: NVL(ap_terms_lines.discount_months_forward,0) +
1669: DECODE(ap_terms.due_cutoff_day, NULL, 0,
1670: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),
1671: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date),'DD'))),
1672: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),

Line 1674: P_Terms_Date + NVL(ap_terms_lines.discount_days,0)),

1670: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),
1671: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date),'DD'))),
1672: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),
1673: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD')), 1, 0))), 'MON-RR'),'DD-MON-RR')), /*bugfix:5647464 */
1674: P_Terms_Date + NVL(ap_terms_lines.discount_days,0)),
1675: DECODE(ap_terms_lines.discount_days_2,
1676: NULL,DECODE(ap_terms_lines.discount_day_of_month_2,NULL,NULL,
1677: TO_DATE(TO_CHAR(LEAST
1678: (NVL(ap_terms_lines.discount_day_of_month_2,32),

Line 1675: DECODE(ap_terms_lines.discount_days_2,

1671: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date),'DD'))),
1672: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),
1673: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD')), 1, 0))), 'MON-RR'),'DD-MON-RR')), /*bugfix:5647464 */
1674: P_Terms_Date + NVL(ap_terms_lines.discount_days,0)),
1675: DECODE(ap_terms_lines.discount_days_2,
1676: NULL,DECODE(ap_terms_lines.discount_day_of_month_2,NULL,NULL,
1677: TO_DATE(TO_CHAR(LEAST
1678: (NVL(ap_terms_lines.discount_day_of_month_2,32),
1679: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(P_Terms_Date,

Line 1676: NULL,DECODE(ap_terms_lines.discount_day_of_month_2,NULL,NULL,

1672: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),
1673: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD')), 1, 0))), 'MON-RR'),'DD-MON-RR')), /*bugfix:5647464 */
1674: P_Terms_Date + NVL(ap_terms_lines.discount_days,0)),
1675: DECODE(ap_terms_lines.discount_days_2,
1676: NULL,DECODE(ap_terms_lines.discount_day_of_month_2,NULL,NULL,
1677: TO_DATE(TO_CHAR(LEAST
1678: (NVL(ap_terms_lines.discount_day_of_month_2,32),
1679: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(P_Terms_Date,
1680: NVL(ap_terms_lines.discount_months_forward_2,0) +

Line 1678: (NVL(ap_terms_lines.discount_day_of_month_2,32),

1674: P_Terms_Date + NVL(ap_terms_lines.discount_days,0)),
1675: DECODE(ap_terms_lines.discount_days_2,
1676: NULL,DECODE(ap_terms_lines.discount_day_of_month_2,NULL,NULL,
1677: TO_DATE(TO_CHAR(LEAST
1678: (NVL(ap_terms_lines.discount_day_of_month_2,32),
1679: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(P_Terms_Date,
1680: NVL(ap_terms_lines.discount_months_forward_2,0) +
1681: DECODE(ap_terms.due_cutoff_day, NULL, 0,
1682: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),

Line 1680: NVL(ap_terms_lines.discount_months_forward_2,0) +

1676: NULL,DECODE(ap_terms_lines.discount_day_of_month_2,NULL,NULL,
1677: TO_DATE(TO_CHAR(LEAST
1678: (NVL(ap_terms_lines.discount_day_of_month_2,32),
1679: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(P_Terms_Date,
1680: NVL(ap_terms_lines.discount_months_forward_2,0) +
1681: DECODE(ap_terms.due_cutoff_day, NULL, 0,
1682: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),
1683: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date), 'DD'))),
1684: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),

Line 1688: NVL(ap_terms_lines.discount_months_forward_2,0) +

1684: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),
1685: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))
1686: , 1, 0)))), 'DD')))) || '-' ||
1687: TO_CHAR(ADD_MONTHS(P_Terms_Date,
1688: NVL(ap_terms_lines.discount_months_forward_2,0) +
1689: DECODE(ap_terms.due_cutoff_day, NULL, 0,
1690: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),
1691: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date),'DD'))),
1692: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),

Line 1694: P_Terms_Date + NVL(ap_terms_lines.discount_days_2,0)),

1690: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),
1691: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date),'DD'))),
1692: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),
1693: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD')), 1, 0))), 'MON-RR'),'DD-MON-RR')), /*bugfix:5647464 */
1694: P_Terms_Date + NVL(ap_terms_lines.discount_days_2,0)),
1695: DECODE(ap_terms_lines.discount_days_3,
1696: NULL, DECODE(ap_terms_lines.discount_day_of_month_3, NULL,NULL,
1697: TO_DATE(TO_CHAR(LEAST
1698: (NVL(ap_terms_lines.discount_day_of_month_3,32),

Line 1695: DECODE(ap_terms_lines.discount_days_3,

1691: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date),'DD'))),
1692: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),
1693: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD')), 1, 0))), 'MON-RR'),'DD-MON-RR')), /*bugfix:5647464 */
1694: P_Terms_Date + NVL(ap_terms_lines.discount_days_2,0)),
1695: DECODE(ap_terms_lines.discount_days_3,
1696: NULL, DECODE(ap_terms_lines.discount_day_of_month_3, NULL,NULL,
1697: TO_DATE(TO_CHAR(LEAST
1698: (NVL(ap_terms_lines.discount_day_of_month_3,32),
1699: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(P_Terms_Date,

Line 1696: NULL, DECODE(ap_terms_lines.discount_day_of_month_3, NULL,NULL,

1692: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),
1693: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD')), 1, 0))), 'MON-RR'),'DD-MON-RR')), /*bugfix:5647464 */
1694: P_Terms_Date + NVL(ap_terms_lines.discount_days_2,0)),
1695: DECODE(ap_terms_lines.discount_days_3,
1696: NULL, DECODE(ap_terms_lines.discount_day_of_month_3, NULL,NULL,
1697: TO_DATE(TO_CHAR(LEAST
1698: (NVL(ap_terms_lines.discount_day_of_month_3,32),
1699: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(P_Terms_Date,
1700: NVL(ap_terms_lines.discount_months_forward_3,0) +

Line 1698: (NVL(ap_terms_lines.discount_day_of_month_3,32),

1694: P_Terms_Date + NVL(ap_terms_lines.discount_days_2,0)),
1695: DECODE(ap_terms_lines.discount_days_3,
1696: NULL, DECODE(ap_terms_lines.discount_day_of_month_3, NULL,NULL,
1697: TO_DATE(TO_CHAR(LEAST
1698: (NVL(ap_terms_lines.discount_day_of_month_3,32),
1699: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(P_Terms_Date,
1700: NVL(ap_terms_lines.discount_months_forward_3,0) +
1701: DECODE(ap_terms.due_cutoff_day, NULL, 0,
1702: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),

Line 1700: NVL(ap_terms_lines.discount_months_forward_3,0) +

1696: NULL, DECODE(ap_terms_lines.discount_day_of_month_3, NULL,NULL,
1697: TO_DATE(TO_CHAR(LEAST
1698: (NVL(ap_terms_lines.discount_day_of_month_3,32),
1699: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(P_Terms_Date,
1700: NVL(ap_terms_lines.discount_months_forward_3,0) +
1701: DECODE(ap_terms.due_cutoff_day, NULL, 0,
1702: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),
1703: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date), 'DD'))),
1704: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),

Line 1708: NVL(ap_terms_lines.discount_months_forward_3,0) +

1704: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),
1705: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))
1706: , 1, 0)))), 'DD')))) || '-' ||
1707: TO_CHAR(ADD_MONTHS(P_Terms_Date,
1708: NVL(ap_terms_lines.discount_months_forward_3,0) +
1709: DECODE(ap_terms.due_cutoff_day, NULL, 0,
1710: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),
1711: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date),'DD'))),
1712: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),

Line 1714: P_Terms_Date + NVL(ap_terms_lines.discount_days_3,0)),

1710: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),
1711: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date),'DD'))),
1712: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),
1713: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD')), 1, 0))), 'MON-RR'),'DD-MON-RR')), /*bugfix:5647464 */
1714: P_Terms_Date + NVL(ap_terms_lines.discount_days_3,0)),
1715: SYSDATE,
1716: P_Last_Updated_By,
1717: NULL,
1718: SYSDATE,

Line 1795: ap_terms_lines,

1791: ,ai.remit_to_supplier_site
1792: ,ai.remit_to_supplier_site_id
1793: ,ai.relationship_id
1794: FROM ap_terms,
1795: ap_terms_lines,
1796: ap_invoices ai,
1797: ap_recurring_payments arp --bug 5332569
1798: WHERE ap_terms.term_id = ap_terms_lines.term_id
1799: AND ap_terms_lines.term_id = P_Terms_Id

Line 1798: WHERE ap_terms.term_id = ap_terms_lines.term_id

1794: FROM ap_terms,
1795: ap_terms_lines,
1796: ap_invoices ai,
1797: ap_recurring_payments arp --bug 5332569
1798: WHERE ap_terms.term_id = ap_terms_lines.term_id
1799: AND ap_terms_lines.term_id = P_Terms_Id
1800: AND ap_terms_lines.sequence_num = l_sequence_num
1801: AND ai.Invoice_Id = P_Invoice_Id
1802: AND ai.recurring_payment_id = arp.recurring_payment_id(+); --bug 5332569

Line 1799: AND ap_terms_lines.term_id = P_Terms_Id

1795: ap_terms_lines,
1796: ap_invoices ai,
1797: ap_recurring_payments arp --bug 5332569
1798: WHERE ap_terms.term_id = ap_terms_lines.term_id
1799: AND ap_terms_lines.term_id = P_Terms_Id
1800: AND ap_terms_lines.sequence_num = l_sequence_num
1801: AND ai.Invoice_Id = P_Invoice_Id
1802: AND ai.recurring_payment_id = arp.recurring_payment_id(+); --bug 5332569
1803:

Line 1800: AND ap_terms_lines.sequence_num = l_sequence_num

1796: ap_invoices ai,
1797: ap_recurring_payments arp --bug 5332569
1798: WHERE ap_terms.term_id = ap_terms_lines.term_id
1799: AND ap_terms_lines.term_id = P_Terms_Id
1800: AND ap_terms_lines.sequence_num = l_sequence_num
1801: AND ai.Invoice_Id = P_Invoice_Id
1802: AND ai.recurring_payment_id = arp.recurring_payment_id(+); --bug 5332569
1803:
1804:

Line 1859: NVL(ap_terms_lines.discount_percent,0)/100 *

1855: debug_info := 'Calculating discount amounts by percent for pecent type BEGIN';
1856:
1857: SELECT DECODE(l_min_acc_unit_pay_curr,NULL,
1858: ROUND( l_amount_for_discount *
1859: NVL(ap_terms_lines.discount_percent,0)/100 *
1860: NVL(ap_terms_lines.due_percent, 0)/100,
1861: l_precision_pay_curr),
1862: ROUND(( l_amount_for_discount *
1863: NVL(ap_terms_lines.discount_percent,0)/100 *

Line 1860: NVL(ap_terms_lines.due_percent, 0)/100,

1856:
1857: SELECT DECODE(l_min_acc_unit_pay_curr,NULL,
1858: ROUND( l_amount_for_discount *
1859: NVL(ap_terms_lines.discount_percent,0)/100 *
1860: NVL(ap_terms_lines.due_percent, 0)/100,
1861: l_precision_pay_curr),
1862: ROUND(( l_amount_for_discount *
1863: NVL(ap_terms_lines.discount_percent,0)/100 *
1864: NVL(ap_terms_lines.due_percent, 0)/100)

Line 1863: NVL(ap_terms_lines.discount_percent,0)/100 *

1859: NVL(ap_terms_lines.discount_percent,0)/100 *
1860: NVL(ap_terms_lines.due_percent, 0)/100,
1861: l_precision_pay_curr),
1862: ROUND(( l_amount_for_discount *
1863: NVL(ap_terms_lines.discount_percent,0)/100 *
1864: NVL(ap_terms_lines.due_percent, 0)/100)
1865: / l_min_acc_unit_pay_curr)
1866: * l_min_acc_unit_pay_curr)
1867: , DECODE(l_min_acc_unit_pay_curr,NULL,

Line 1864: NVL(ap_terms_lines.due_percent, 0)/100)

1860: NVL(ap_terms_lines.due_percent, 0)/100,
1861: l_precision_pay_curr),
1862: ROUND(( l_amount_for_discount *
1863: NVL(ap_terms_lines.discount_percent,0)/100 *
1864: NVL(ap_terms_lines.due_percent, 0)/100)
1865: / l_min_acc_unit_pay_curr)
1866: * l_min_acc_unit_pay_curr)
1867: , DECODE(l_min_acc_unit_pay_curr,NULL,
1868: ROUND( l_amount_for_discount *

Line 1869: NVL(ap_terms_lines.discount_percent_2,0)/100 *

1865: / l_min_acc_unit_pay_curr)
1866: * l_min_acc_unit_pay_curr)
1867: , DECODE(l_min_acc_unit_pay_curr,NULL,
1868: ROUND( l_amount_for_discount *
1869: NVL(ap_terms_lines.discount_percent_2,0)/100 *
1870: NVL(ap_terms_lines.due_percent, 0)/100,
1871: l_precision_pay_curr),
1872: ROUND(( l_amount_for_discount *
1873: NVL(ap_terms_lines.discount_percent_2,0)/100 *

Line 1870: NVL(ap_terms_lines.due_percent, 0)/100,

1866: * l_min_acc_unit_pay_curr)
1867: , DECODE(l_min_acc_unit_pay_curr,NULL,
1868: ROUND( l_amount_for_discount *
1869: NVL(ap_terms_lines.discount_percent_2,0)/100 *
1870: NVL(ap_terms_lines.due_percent, 0)/100,
1871: l_precision_pay_curr),
1872: ROUND(( l_amount_for_discount *
1873: NVL(ap_terms_lines.discount_percent_2,0)/100 *
1874: NVL(ap_terms_lines.due_percent, 0)/100)

Line 1873: NVL(ap_terms_lines.discount_percent_2,0)/100 *

1869: NVL(ap_terms_lines.discount_percent_2,0)/100 *
1870: NVL(ap_terms_lines.due_percent, 0)/100,
1871: l_precision_pay_curr),
1872: ROUND(( l_amount_for_discount *
1873: NVL(ap_terms_lines.discount_percent_2,0)/100 *
1874: NVL(ap_terms_lines.due_percent, 0)/100)
1875: / l_min_acc_unit_pay_curr)
1876: * l_min_acc_unit_pay_curr)
1877: ,DECODE(l_min_acc_unit_pay_curr,NULL,

Line 1874: NVL(ap_terms_lines.due_percent, 0)/100)

1870: NVL(ap_terms_lines.due_percent, 0)/100,
1871: l_precision_pay_curr),
1872: ROUND(( l_amount_for_discount *
1873: NVL(ap_terms_lines.discount_percent_2,0)/100 *
1874: NVL(ap_terms_lines.due_percent, 0)/100)
1875: / l_min_acc_unit_pay_curr)
1876: * l_min_acc_unit_pay_curr)
1877: ,DECODE(l_min_acc_unit_pay_curr,NULL,
1878: ROUND( l_amount_for_discount *

Line 1879: NVL(ap_terms_lines.discount_percent_3,0)/100 *

1875: / l_min_acc_unit_pay_curr)
1876: * l_min_acc_unit_pay_curr)
1877: ,DECODE(l_min_acc_unit_pay_curr,NULL,
1878: ROUND( l_amount_for_discount *
1879: NVL(ap_terms_lines.discount_percent_3,0)/100 *
1880: NVL(ap_terms_lines.due_percent, 0)/100,
1881: l_precision_pay_curr),
1882: ROUND(( l_amount_for_discount *
1883: NVL(ap_terms_lines.discount_percent_3,0)/100 *

Line 1880: NVL(ap_terms_lines.due_percent, 0)/100,

1876: * l_min_acc_unit_pay_curr)
1877: ,DECODE(l_min_acc_unit_pay_curr,NULL,
1878: ROUND( l_amount_for_discount *
1879: NVL(ap_terms_lines.discount_percent_3,0)/100 *
1880: NVL(ap_terms_lines.due_percent, 0)/100,
1881: l_precision_pay_curr),
1882: ROUND(( l_amount_for_discount *
1883: NVL(ap_terms_lines.discount_percent_3,0)/100 *
1884: NVL(ap_terms_lines.due_percent, 0)/100)

Line 1883: NVL(ap_terms_lines.discount_percent_3,0)/100 *

1879: NVL(ap_terms_lines.discount_percent_3,0)/100 *
1880: NVL(ap_terms_lines.due_percent, 0)/100,
1881: l_precision_pay_curr),
1882: ROUND(( l_amount_for_discount *
1883: NVL(ap_terms_lines.discount_percent_3,0)/100 *
1884: NVL(ap_terms_lines.due_percent, 0)/100)
1885: / l_min_acc_unit_pay_curr)
1886: * l_min_acc_unit_pay_curr),
1887: discount_amount,

Line 1884: NVL(ap_terms_lines.due_percent, 0)/100)

1880: NVL(ap_terms_lines.due_percent, 0)/100,
1881: l_precision_pay_curr),
1882: ROUND(( l_amount_for_discount *
1883: NVL(ap_terms_lines.discount_percent_3,0)/100 *
1884: NVL(ap_terms_lines.due_percent, 0)/100)
1885: / l_min_acc_unit_pay_curr)
1886: * l_min_acc_unit_pay_curr),
1887: discount_amount,
1888: discount_amount_2,

Line 1895: ap_terms_lines,

1891: l_disc_amt_by_percent, l_disc_amt_by_percent_2, l_disc_amt_by_percent_3,
1892: l_discount_amount, l_discount_amount_2, l_discount_amount_3
1893:
1894: FROM ap_terms,
1895: ap_terms_lines,
1896: ap_invoices ai,
1897: ap_recurring_payments arp
1898: WHERE ap_terms.term_id = ap_terms_lines.term_id
1899: AND ap_terms_lines.term_id = P_Terms_Id

Line 1898: WHERE ap_terms.term_id = ap_terms_lines.term_id

1894: FROM ap_terms,
1895: ap_terms_lines,
1896: ap_invoices ai,
1897: ap_recurring_payments arp
1898: WHERE ap_terms.term_id = ap_terms_lines.term_id
1899: AND ap_terms_lines.term_id = P_Terms_Id
1900: AND ap_terms_lines.sequence_num = l_sequence_num
1901: AND ai.Invoice_Id = P_Invoice_Id
1902: AND ai.recurring_payment_id = arp.recurring_payment_id(+);

Line 1899: AND ap_terms_lines.term_id = P_Terms_Id

1895: ap_terms_lines,
1896: ap_invoices ai,
1897: ap_recurring_payments arp
1898: WHERE ap_terms.term_id = ap_terms_lines.term_id
1899: AND ap_terms_lines.term_id = P_Terms_Id
1900: AND ap_terms_lines.sequence_num = l_sequence_num
1901: AND ai.Invoice_Id = P_Invoice_Id
1902: AND ai.recurring_payment_id = arp.recurring_payment_id(+);
1903:

Line 1900: AND ap_terms_lines.sequence_num = l_sequence_num

1896: ap_invoices ai,
1897: ap_recurring_payments arp
1898: WHERE ap_terms.term_id = ap_terms_lines.term_id
1899: AND ap_terms_lines.term_id = P_Terms_Id
1900: AND ap_terms_lines.sequence_num = l_sequence_num
1901: AND ai.Invoice_Id = P_Invoice_Id
1902: AND ai.recurring_payment_id = arp.recurring_payment_id(+);
1903:
1904: --Bug 7357218 Quick Pay and Dispute Resolution Project

Line 1969: l_sequence_num, -- ap_terms_lines.sequence_num

1965: ,remit_to_supplier_site_id
1966: ,relationship_id)
1967: SELECT
1968: P_Invoice_Id,
1969: l_sequence_num, -- ap_terms_lines.sequence_num
1970: l_due_date, -- change for payment terms
1971: DECODE(l_amount_for_discount, NULL, NULL,
1972: DECODE(ap_terms_lines.discount_days, NULL,
1973: DECODE(ap_terms_lines.discount_day_of_month,

Line 1972: DECODE(ap_terms_lines.discount_days, NULL,

1968: P_Invoice_Id,
1969: l_sequence_num, -- ap_terms_lines.sequence_num
1970: l_due_date, -- change for payment terms
1971: DECODE(l_amount_for_discount, NULL, NULL,
1972: DECODE(ap_terms_lines.discount_days, NULL,
1973: DECODE(ap_terms_lines.discount_day_of_month,
1974: NULL, NULL, TO_DATE(TO_CHAR(LEAST(NVL(
1975: ap_terms_lines.discount_day_of_month,32),
1976: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS

Line 1973: DECODE(ap_terms_lines.discount_day_of_month,

1969: l_sequence_num, -- ap_terms_lines.sequence_num
1970: l_due_date, -- change for payment terms
1971: DECODE(l_amount_for_discount, NULL, NULL,
1972: DECODE(ap_terms_lines.discount_days, NULL,
1973: DECODE(ap_terms_lines.discount_day_of_month,
1974: NULL, NULL, TO_DATE(TO_CHAR(LEAST(NVL(
1975: ap_terms_lines.discount_day_of_month,32),
1976: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS
1977: (P_Terms_Date,

Line 1975: ap_terms_lines.discount_day_of_month,32),

1971: DECODE(l_amount_for_discount, NULL, NULL,
1972: DECODE(ap_terms_lines.discount_days, NULL,
1973: DECODE(ap_terms_lines.discount_day_of_month,
1974: NULL, NULL, TO_DATE(TO_CHAR(LEAST(NVL(
1975: ap_terms_lines.discount_day_of_month,32),
1976: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS
1977: (P_Terms_Date,
1978: NVL(ap_terms_lines.discount_months_forward,0) +
1979: DECODE(ap_terms.due_cutoff_day, NULL, 0,

Line 1978: NVL(ap_terms_lines.discount_months_forward,0) +

1974: NULL, NULL, TO_DATE(TO_CHAR(LEAST(NVL(
1975: ap_terms_lines.discount_day_of_month,32),
1976: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS
1977: (P_Terms_Date,
1978: NVL(ap_terms_lines.discount_months_forward,0) +
1979: DECODE(ap_terms.due_cutoff_day, NULL, 0,
1980: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),
1981: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date), 'DD'))),
1982: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),

Line 1986: NVL(ap_terms_lines.discount_months_forward,0) +

1982: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),
1983: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))
1984: , 1, 0)))), 'DD')))) || '-' ||
1985: TO_CHAR(ADD_MONTHS(P_Terms_Date,
1986: NVL(ap_terms_lines.discount_months_forward,0) +
1987: DECODE(ap_terms.due_cutoff_day, NULL, 0,
1988: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),
1989: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date),'DD'))),
1990: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),

Line 1993: P_Terms_Date + NVL(ap_terms_lines.discount_days,0))),

1989: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date),'DD'))),
1990: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),
1991: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD')), 1, 0))),
1992: 'MON-RR'),'DD-MON-RR')), /*bugfix:5647464 */
1993: P_Terms_Date + NVL(ap_terms_lines.discount_days,0))),
1994: DECODE(l_amount_for_discount, NULL, NULL,
1995: DECODE(ap_terms_lines.discount_days_2,
1996: NULL,DECODE(ap_terms_lines.discount_day_of_month_2,NULL,NULL,
1997: TO_DATE(TO_CHAR(LEAST(

Line 1995: DECODE(ap_terms_lines.discount_days_2,

1991: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD')), 1, 0))),
1992: 'MON-RR'),'DD-MON-RR')), /*bugfix:5647464 */
1993: P_Terms_Date + NVL(ap_terms_lines.discount_days,0))),
1994: DECODE(l_amount_for_discount, NULL, NULL,
1995: DECODE(ap_terms_lines.discount_days_2,
1996: NULL,DECODE(ap_terms_lines.discount_day_of_month_2,NULL,NULL,
1997: TO_DATE(TO_CHAR(LEAST(
1998: NVL(ap_terms_lines.discount_day_of_month_2,32),
1999: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(P_Terms_Date,

Line 1996: NULL,DECODE(ap_terms_lines.discount_day_of_month_2,NULL,NULL,

1992: 'MON-RR'),'DD-MON-RR')), /*bugfix:5647464 */
1993: P_Terms_Date + NVL(ap_terms_lines.discount_days,0))),
1994: DECODE(l_amount_for_discount, NULL, NULL,
1995: DECODE(ap_terms_lines.discount_days_2,
1996: NULL,DECODE(ap_terms_lines.discount_day_of_month_2,NULL,NULL,
1997: TO_DATE(TO_CHAR(LEAST(
1998: NVL(ap_terms_lines.discount_day_of_month_2,32),
1999: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(P_Terms_Date,
2000: NVL(ap_terms_lines.discount_months_forward_2,0) +

Line 1998: NVL(ap_terms_lines.discount_day_of_month_2,32),

1994: DECODE(l_amount_for_discount, NULL, NULL,
1995: DECODE(ap_terms_lines.discount_days_2,
1996: NULL,DECODE(ap_terms_lines.discount_day_of_month_2,NULL,NULL,
1997: TO_DATE(TO_CHAR(LEAST(
1998: NVL(ap_terms_lines.discount_day_of_month_2,32),
1999: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(P_Terms_Date,
2000: NVL(ap_terms_lines.discount_months_forward_2,0) +
2001: DECODE(ap_terms.due_cutoff_day, NULL, 0,
2002: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),

Line 2000: NVL(ap_terms_lines.discount_months_forward_2,0) +

1996: NULL,DECODE(ap_terms_lines.discount_day_of_month_2,NULL,NULL,
1997: TO_DATE(TO_CHAR(LEAST(
1998: NVL(ap_terms_lines.discount_day_of_month_2,32),
1999: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(P_Terms_Date,
2000: NVL(ap_terms_lines.discount_months_forward_2,0) +
2001: DECODE(ap_terms.due_cutoff_day, NULL, 0,
2002: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),
2003: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date), 'DD'))),
2004: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),

Line 2008: NVL(ap_terms_lines.discount_months_forward_2,0) +

2004: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),
2005: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))
2006: , 1, 0)))), 'DD')))) || '-' ||
2007: TO_CHAR(ADD_MONTHS(P_Terms_Date,
2008: NVL(ap_terms_lines.discount_months_forward_2,0) +
2009: DECODE(ap_terms.due_cutoff_day, NULL, 0,
2010: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),
2011: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date),'DD'))),
2012: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),

Line 2015: P_Terms_Date + NVL(ap_terms_lines.discount_days_2,0))),

2011: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date),'DD'))),
2012: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),
2013: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD')), 1, 0))),
2014: 'MON-RR'),'DD-MON-RR')), /*bugfix:5647464 */
2015: P_Terms_Date + NVL(ap_terms_lines.discount_days_2,0))),
2016: DECODE(l_amount_for_discount, NULL, NULL,
2017: DECODE(ap_terms_lines.discount_days_3,
2018: NULL,DECODE(ap_terms_lines.discount_day_of_month_3,NULL,NULL,
2019: TO_DATE(TO_CHAR(LEAST(

Line 2017: DECODE(ap_terms_lines.discount_days_3,

2013: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD')), 1, 0))),
2014: 'MON-RR'),'DD-MON-RR')), /*bugfix:5647464 */
2015: P_Terms_Date + NVL(ap_terms_lines.discount_days_2,0))),
2016: DECODE(l_amount_for_discount, NULL, NULL,
2017: DECODE(ap_terms_lines.discount_days_3,
2018: NULL,DECODE(ap_terms_lines.discount_day_of_month_3,NULL,NULL,
2019: TO_DATE(TO_CHAR(LEAST(
2020: NVL(ap_terms_lines.discount_day_of_month_3,32),
2021: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(P_Terms_Date,

Line 2018: NULL,DECODE(ap_terms_lines.discount_day_of_month_3,NULL,NULL,

2014: 'MON-RR'),'DD-MON-RR')), /*bugfix:5647464 */
2015: P_Terms_Date + NVL(ap_terms_lines.discount_days_2,0))),
2016: DECODE(l_amount_for_discount, NULL, NULL,
2017: DECODE(ap_terms_lines.discount_days_3,
2018: NULL,DECODE(ap_terms_lines.discount_day_of_month_3,NULL,NULL,
2019: TO_DATE(TO_CHAR(LEAST(
2020: NVL(ap_terms_lines.discount_day_of_month_3,32),
2021: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(P_Terms_Date,
2022: NVL(ap_terms_lines.discount_months_forward_3,0) +

Line 2020: NVL(ap_terms_lines.discount_day_of_month_3,32),

2016: DECODE(l_amount_for_discount, NULL, NULL,
2017: DECODE(ap_terms_lines.discount_days_3,
2018: NULL,DECODE(ap_terms_lines.discount_day_of_month_3,NULL,NULL,
2019: TO_DATE(TO_CHAR(LEAST(
2020: NVL(ap_terms_lines.discount_day_of_month_3,32),
2021: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(P_Terms_Date,
2022: NVL(ap_terms_lines.discount_months_forward_3,0) +
2023: DECODE(ap_terms.due_cutoff_day, NULL, 0,
2024: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),

Line 2022: NVL(ap_terms_lines.discount_months_forward_3,0) +

2018: NULL,DECODE(ap_terms_lines.discount_day_of_month_3,NULL,NULL,
2019: TO_DATE(TO_CHAR(LEAST(
2020: NVL(ap_terms_lines.discount_day_of_month_3,32),
2021: TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(P_Terms_Date,
2022: NVL(ap_terms_lines.discount_months_forward_3,0) +
2023: DECODE(ap_terms.due_cutoff_day, NULL, 0,
2024: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),
2025: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date), 'DD'))),
2026: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),

Line 2030: NVL(ap_terms_lines.discount_months_forward_3,0) +

2026: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),
2027: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))
2028: , 1, 0)))), 'DD')))) || '-' ||
2029: TO_CHAR(ADD_MONTHS(P_Terms_Date,
2030: NVL(ap_terms_lines.discount_months_forward_3,0) +
2031: DECODE(ap_terms.due_cutoff_day, NULL, 0,
2032: DECODE(GREATEST(LEAST(NVL(ap_terms.due_cutoff_day, 32),
2033: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date),'DD'))),
2034: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),

Line 2037: P_Terms_Date + NVL(ap_terms_lines.discount_days_3,0))),

2033: TO_NUMBER(TO_CHAR(LAST_DAY(P_Terms_Date),'DD'))),
2034: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD'))),
2035: TO_NUMBER(TO_CHAR(P_Terms_Date, 'DD')), 1, 0))),
2036: 'MON-RR'),'DD-MON-RR')), /*bugfix:5647464 */
2037: P_Terms_Date + NVL(ap_terms_lines.discount_days_3,0))),
2038: SYSDATE,
2039: P_Last_Updated_By,
2040: NULL,
2041: SYSDATE,

Line 2046: NVL(ap_terms_lines.due_percent,0)/100,

2042: P_Last_Updated_By,--bug4563272
2043: l_payment_cross_rate,
2044: DECODE(l_min_acc_unit_pay_curr,NULL,
2045: ROUND(P_Pay_Curr_Invoice_Amount *
2046: NVL(ap_terms_lines.due_percent,0)/100,
2047: l_precision_pay_curr),
2048: ROUND((P_Pay_Curr_Invoice_Amount *
2049: NVL(ap_terms_lines.due_percent,0)/100)
2050: / l_min_acc_unit_pay_curr)

Line 2049: NVL(ap_terms_lines.due_percent,0)/100)

2045: ROUND(P_Pay_Curr_Invoice_Amount *
2046: NVL(ap_terms_lines.due_percent,0)/100,
2047: l_precision_pay_curr),
2048: ROUND((P_Pay_Curr_Invoice_Amount *
2049: NVL(ap_terms_lines.due_percent,0)/100)
2050: / l_min_acc_unit_pay_curr)
2051: * l_min_acc_unit_pay_curr),
2052:
2053: --Bug 7357218 Quick Pay and Dispute Resolution Project

Line 2092: NVL(ap_terms_lines.due_percent, 0)/100,

2088: END,
2089:
2090: DECODE(l_min_acc_unit_pay_curr,NULL,
2091: ROUND( P_Pay_Curr_Invoice_Amount *
2092: NVL(ap_terms_lines.due_percent, 0)/100,
2093: l_precision_pay_curr),
2094: ROUND(( P_Pay_Curr_Invoice_Amount *
2095: NVL(ap_terms_lines.due_percent, 0)/100)
2096: / l_min_acc_unit_pay_curr)

Line 2095: NVL(ap_terms_lines.due_percent, 0)/100)

2091: ROUND( P_Pay_Curr_Invoice_Amount *
2092: NVL(ap_terms_lines.due_percent, 0)/100,
2093: l_precision_pay_curr),
2094: ROUND(( P_Pay_Curr_Invoice_Amount *
2095: NVL(ap_terms_lines.due_percent, 0)/100)
2096: / l_min_acc_unit_pay_curr)
2097: * l_min_acc_unit_pay_curr),
2098: 0,
2099: NVL(l_Payment_Priority,P_Payment_priority),

Line 2128: ap_terms_lines,

2124: ,ai.remit_to_supplier_site
2125: ,ai.remit_to_supplier_site_id
2126: ,ai.relationship_id
2127: FROM ap_terms,
2128: ap_terms_lines,
2129: ap_invoices ai,
2130: ap_recurring_payments arp
2131: WHERE ap_terms.term_id = ap_terms_lines.term_id
2132: AND ap_terms_lines.term_id = P_Terms_Id

Line 2131: WHERE ap_terms.term_id = ap_terms_lines.term_id

2127: FROM ap_terms,
2128: ap_terms_lines,
2129: ap_invoices ai,
2130: ap_recurring_payments arp
2131: WHERE ap_terms.term_id = ap_terms_lines.term_id
2132: AND ap_terms_lines.term_id = P_Terms_Id
2133: AND ap_terms_lines.sequence_num = l_sequence_num
2134: AND ai.invoice_id = P_Invoice_Id
2135: AND ai.recurring_payment_id = arp.recurring_payment_id(+);

Line 2132: AND ap_terms_lines.term_id = P_Terms_Id

2128: ap_terms_lines,
2129: ap_invoices ai,
2130: ap_recurring_payments arp
2131: WHERE ap_terms.term_id = ap_terms_lines.term_id
2132: AND ap_terms_lines.term_id = P_Terms_Id
2133: AND ap_terms_lines.sequence_num = l_sequence_num
2134: AND ai.invoice_id = P_Invoice_Id
2135: AND ai.recurring_payment_id = arp.recurring_payment_id(+);
2136:

Line 2133: AND ap_terms_lines.sequence_num = l_sequence_num

2129: ap_invoices ai,
2130: ap_recurring_payments arp
2131: WHERE ap_terms.term_id = ap_terms_lines.term_id
2132: AND ap_terms_lines.term_id = P_Terms_Id
2133: AND ap_terms_lines.sequence_num = l_sequence_num
2134: AND ai.invoice_id = P_Invoice_Id
2135: AND ai.recurring_payment_id = arp.recurring_payment_id(+);
2136:
2137: --Bug 4539462 DBI logginG