68: l_amt_in_dispute ar_payment_schedules.amount_in_dispute%TYPE; /*Bug 5223829*/
69:
70: BEGIN
71: IF PG_DEBUG in ('Y', 'C') THEN
72: arp_standard.debug( 'arp_discounts_api.get_discount() +');
73: END IF;
74:
75: -- Get payment schedule info and populate the payment schedule record
76: p_ps_rec.payment_schedule_id := p_ps_id;
76: p_ps_rec.payment_schedule_id := p_ps_id;
77: arp_calculate_discount.get_payment_schedule_info(p_disc_rec, p_ps_rec);
78:
79: IF PG_DEBUG in ('Y', 'C') THEN
80: arp_standard.debug('get_discount: ' || 'initialized payment schedule record');
81: END IF;
82:
83: -- Get Customer Id and Site Use Id to obtain any grace days
84: -- available for the Customer.
90:
91: EXCEPTION
92: WHEN NO_DATA_FOUND THEN
93: IF PG_DEBUG in ('Y', 'C') THEN
94: arp_standard.debug('get_discount: ' || 'No data found for Customer id');
95: END IF;
96: END;
97:
98: -- If grace days is allowed from iReceivables, calculate the
133: l_grace_days := 0;
134: end if;
135:
136: IF PG_DEBUG in ('Y', 'C') THEN
137: arp_standard.debug('get_discount: ' || 'grace days:'||l_grace_days );
138: END IF;
139:
140:
141: -- Initilaize various variables necessary to be passed into
201: l_amt_in_dispute /*Bug 5223829*/
202: );
203:
204: IF PG_DEBUG in ('Y', 'C') THEN
205: arp_standard.debug('get_discount: ' || 'earned discount :'|| l_out_earned_disc );
206: arp_standard.debug('get_discount: ' || 'unearned discount :'|| l_out_unearned_disc );
207: END IF;
208:
209: -- This is the total discount available on the payment schedule
202: );
203:
204: IF PG_DEBUG in ('Y', 'C') THEN
205: arp_standard.debug('get_discount: ' || 'earned discount :'|| l_out_earned_disc );
206: arp_standard.debug('get_discount: ' || 'unearned discount :'|| l_out_unearned_disc );
207: END IF;
208:
209: -- This is the total discount available on the payment schedule
210: -- This program is intended only to give out NOCOPY earned disocunts.
214: /* Bug 4460264 - allows for negative discount */
215: p_out_discount := l_out_earned_disc;
216:
217: IF PG_DEBUG in ('Y', 'C') THEN
218: arp_standard.debug('get_discount: ' || 'Input Amount applied :'|| p_in_applied_amount);
219: arp_standard.debug('get_discount: ' || 'ADR on the Invoice :'||p_ps_rec.amount_due_remaining);
220: END IF;
221:
222:
215: p_out_discount := l_out_earned_disc;
216:
217: IF PG_DEBUG in ('Y', 'C') THEN
218: arp_standard.debug('get_discount: ' || 'Input Amount applied :'|| p_in_applied_amount);
219: arp_standard.debug('get_discount: ' || 'ADR on the Invoice :'||p_ps_rec.amount_due_remaining);
220: END IF;
221:
222:
223: -- This calculates if the receipt application plus the discount can
237: - (p_out_discount+p_in_applied_amount);
238: end if;
239:
240: IF PG_DEBUG in ('Y', 'C') THEN
241: arp_standard.debug('get_discount: ' || 'Total discount :'|| p_out_discount );
242: arp_standard.debug('get_discount: ' || 'ADR on the Invoice after discount :'||p_out_rem_amt_inv);
243: arp_standard.debug('get_discount: ' || 'ADR on the Receipt after discount :'||p_out_rem_amt_rcpt);
244: arp_standard.debug( 'arp_discounts_api.get_discount() -');
245: END IF;
238: end if;
239:
240: IF PG_DEBUG in ('Y', 'C') THEN
241: arp_standard.debug('get_discount: ' || 'Total discount :'|| p_out_discount );
242: arp_standard.debug('get_discount: ' || 'ADR on the Invoice after discount :'||p_out_rem_amt_inv);
243: arp_standard.debug('get_discount: ' || 'ADR on the Receipt after discount :'||p_out_rem_amt_rcpt);
244: arp_standard.debug( 'arp_discounts_api.get_discount() -');
245: END IF;
246:
239:
240: IF PG_DEBUG in ('Y', 'C') THEN
241: arp_standard.debug('get_discount: ' || 'Total discount :'|| p_out_discount );
242: arp_standard.debug('get_discount: ' || 'ADR on the Invoice after discount :'||p_out_rem_amt_inv);
243: arp_standard.debug('get_discount: ' || 'ADR on the Receipt after discount :'||p_out_rem_amt_rcpt);
244: arp_standard.debug( 'arp_discounts_api.get_discount() -');
245: END IF;
246:
247:
240: IF PG_DEBUG in ('Y', 'C') THEN
241: arp_standard.debug('get_discount: ' || 'Total discount :'|| p_out_discount );
242: arp_standard.debug('get_discount: ' || 'ADR on the Invoice after discount :'||p_out_rem_amt_inv);
243: arp_standard.debug('get_discount: ' || 'ADR on the Receipt after discount :'||p_out_rem_amt_rcpt);
244: arp_standard.debug( 'arp_discounts_api.get_discount() -');
245: END IF;
246:
247:
248: END get_discount;
293:
294: BEGIN
295:
296: IF PG_DEBUG in ('Y', 'C') THEN
297: arp_standard.debug( 'arp_discounts_api.get_max_discount() +');
298: arp_standard.debug('get_max_discount: ' || 'Payment schedule Id :'|| p_ps_id);
299: arp_standard.debug('get_max_discount: ' || 'Apply Date :'|| p_apply_date );
300: arp_standard.debug('get_max_discount: ' || 'Allow Grace Days :'|| p_grace_days_flag );
301: END IF;
294: BEGIN
295:
296: IF PG_DEBUG in ('Y', 'C') THEN
297: arp_standard.debug( 'arp_discounts_api.get_max_discount() +');
298: arp_standard.debug('get_max_discount: ' || 'Payment schedule Id :'|| p_ps_id);
299: arp_standard.debug('get_max_discount: ' || 'Apply Date :'|| p_apply_date );
300: arp_standard.debug('get_max_discount: ' || 'Allow Grace Days :'|| p_grace_days_flag );
301: END IF;
302:
295:
296: IF PG_DEBUG in ('Y', 'C') THEN
297: arp_standard.debug( 'arp_discounts_api.get_max_discount() +');
298: arp_standard.debug('get_max_discount: ' || 'Payment schedule Id :'|| p_ps_id);
299: arp_standard.debug('get_max_discount: ' || 'Apply Date :'|| p_apply_date );
300: arp_standard.debug('get_max_discount: ' || 'Allow Grace Days :'|| p_grace_days_flag );
301: END IF;
302:
303: p_mode := 1; --default mode
296: IF PG_DEBUG in ('Y', 'C') THEN
297: arp_standard.debug( 'arp_discounts_api.get_max_discount() +');
298: arp_standard.debug('get_max_discount: ' || 'Payment schedule Id :'|| p_ps_id);
299: arp_standard.debug('get_max_discount: ' || 'Apply Date :'|| p_apply_date );
300: arp_standard.debug('get_max_discount: ' || 'Allow Grace Days :'|| p_grace_days_flag );
301: END IF;
302:
303: p_mode := 1; --default mode
304:
312:
313: EXCEPTION
314: WHEN NO_DATA_FOUND THEN
315: IF PG_DEBUG in ('Y', 'C') THEN
316: arp_standard.debug('get_max_discount: ' || 'No Customer Data Found');
317: END IF;
318: END;
319:
320:
340: l_grace_days := 0;
341: end if;
342:
343: IF PG_DEBUG in ('Y', 'C') THEN
344: arp_standard.debug('get_max_discount: ' || 'Grace Days :'|| l_grace_days );
345: END IF;
346:
347: -- We need this following set of statements, because the
348: -- determine_max_discount always calculates max discount
358:
359: EXCEPTION
360: WHEN NO_DATA_FOUND THEN
361: IF PG_DEBUG in ('Y', 'C') THEN
362: arp_standard.debug('get_max_discount: ' || 'error getting discount date');
363: END IF;
364: END;
365:
366: IF PG_DEBUG in ('Y', 'C') THEN
363: END IF;
364: END;
365:
366: IF PG_DEBUG in ('Y', 'C') THEN
367: arp_standard.debug('get_max_discount: ' || 'Discount Date :'|| l_discount_date );
368: END IF;
369:
370: -- Populate the payment schedule record.
371: p_ps_rec.payment_schedule_id := p_ps_id;
370: -- Populate the payment schedule record.
371: p_ps_rec.payment_schedule_id := p_ps_id;
372: arp_calculate_discount.get_payment_schedule_info(p_disc_rec, p_ps_rec);
373: IF PG_DEBUG in ('Y', 'C') THEN
374: arp_standard.debug('get_max_discount: ' || 'Initialized the payment schedule record');
375: END IF;
376:
377: if ((p_apply_date - l_grace_days) > l_discount_date) then
378: --implies the application date is past the discount date
383:
384: --Get Discount Percentages
385: arp_calculate_discount.get_discount_percentages (p_disc_rec, p_ps_rec);
386: IF PG_DEBUG in ('Y', 'C') THEN
387: arp_standard.debug('get_max_discount: ' || 'Calculated Discount percentages');
388: END IF;
389:
390: -- Correct percentages for lines-only(ardline) discount if necessary.
391: IF p_disc_rec.calc_disc_on_lines <> 'I' AND
401: END IF;
402:
403: --Calculate max discount available
404: IF PG_DEBUG in ('Y', 'C') THEN
405: arp_standard.debug('get_max_discount: ' || 'Calling MAX discount routine() +');
406: END IF;
407: arp_calculate_discount.determine_max_allowed_disc
408: ( p_mode, p_disc_rec, p_ps_rec );
409:
413:
414: end if;
415:
416: IF PG_DEBUG in ('Y', 'C') THEN
417: arp_standard.debug('get_max_discount: ' || 'Maximum Available Discount :'|| p_out_discount);
418: END IF;
419:
420: if (p_out_discount > 0) then
421: p_out_applied_amt := p_ps_rec.amount_due_remaining - p_out_discount;
423: p_out_applied_amt := p_ps_rec.amount_due_remaining;
424: end if;
425:
426: IF PG_DEBUG in ('Y', 'C') THEN
427: arp_standard.debug('get_max_discount: ' || 'Amount Needed to Close the Invoice :'|| p_out_applied_amt);
428: arp_standard.debug( 'arp_discounts_api.get_max_discount() -');
429: END IF;
430:
431: END get_max_discount;
424: end if;
425:
426: IF PG_DEBUG in ('Y', 'C') THEN
427: arp_standard.debug('get_max_discount: ' || 'Amount Needed to Close the Invoice :'|| p_out_applied_amt);
428: arp_standard.debug( 'arp_discounts_api.get_max_discount() -');
429: END IF;
430:
431: END get_max_discount;
432: