17: ******************************************************************
18: Name : pay_us_pto_accrual
19: Description : This package holds building blocks used in PTO accrual
20: calculation.
21: Uses : hr_utility
22: Change List
23: -----------
24: Date Name Vers Bug No Description
25: ---- ---- ---- ------ -----------
343: P_first_period_end := null;
344: P_last_period_start := null;
345: P_last_period_end := null;
346: --
347: hr_utility.set_location('get_accrual',5);
348: ---
349: --- If both param null. RETURN
350: --
351: IF P_plan_id is null AND P_plan_category is null
349: --- If both param null. RETURN
350: --
351: IF P_plan_id is null AND P_plan_category is null
352: THEN
353: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
354: hr_utility.set_message_token('PROCEDURE','get_accrual');
355: hr_utility.set_message_token('STEP','1');
356: hr_utility.raise_error;
357: END IF;
350: --
351: IF P_plan_id is null AND P_plan_category is null
352: THEN
353: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
354: hr_utility.set_message_token('PROCEDURE','get_accrual');
355: hr_utility.set_message_token('STEP','1');
356: hr_utility.raise_error;
357: END IF;
358:
351: IF P_plan_id is null AND P_plan_category is null
352: THEN
353: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
354: hr_utility.set_message_token('PROCEDURE','get_accrual');
355: hr_utility.set_message_token('STEP','1');
356: hr_utility.raise_error;
357: END IF;
358:
359: OPEN csr_get_payroll(P_assignment_id, P_calculation_date);
352: THEN
353: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
354: hr_utility.set_message_token('PROCEDURE','get_accrual');
355: hr_utility.set_message_token('STEP','1');
356: hr_utility.raise_error;
357: END IF;
358:
359: OPEN csr_get_payroll(P_assignment_id, P_calculation_date);
360: FETCH csr_get_payroll INTO P_payroll_id,
365: l_termination_date;
366: IF csr_get_payroll%NOTFOUND
367: THEN
368: CLOSE csr_get_payroll;
369: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
370: hr_utility.set_message_token('PROCEDURE','get_accrual');
371: hr_utility.set_message_token('STEP','2');
372: hr_utility.raise_error;
373: END IF;
366: IF csr_get_payroll%NOTFOUND
367: THEN
368: CLOSE csr_get_payroll;
369: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
370: hr_utility.set_message_token('PROCEDURE','get_accrual');
371: hr_utility.set_message_token('STEP','2');
372: hr_utility.raise_error;
373: END IF;
374: CLOSE csr_get_payroll;
367: THEN
368: CLOSE csr_get_payroll;
369: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
370: hr_utility.set_message_token('PROCEDURE','get_accrual');
371: hr_utility.set_message_token('STEP','2');
372: hr_utility.raise_error;
373: END IF;
374: CLOSE csr_get_payroll;
375: hr_utility.set_location('get_accrual',10);
368: CLOSE csr_get_payroll;
369: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
370: hr_utility.set_message_token('PROCEDURE','get_accrual');
371: hr_utility.set_message_token('STEP','2');
372: hr_utility.raise_error;
373: END IF;
374: CLOSE csr_get_payroll;
375: hr_utility.set_location('get_accrual',10);
376: --
371: hr_utility.set_message_token('STEP','2');
372: hr_utility.raise_error;
373: END IF;
374: CLOSE csr_get_payroll;
375: hr_utility.set_location('get_accrual',10);
376: --
377: -- Get start and end date for the Calculation date
378: --
379: hr_utility.set_location('get_accrual',15);
375: hr_utility.set_location('get_accrual',10);
376: --
377: -- Get start and end date for the Calculation date
378: --
379: hr_utility.set_location('get_accrual',15);
380:
381: OPEN csr_get_period(P_payroll_id, P_calculation_date);
382: FETCH csr_get_period INTO l_calc_period_num,
383: l_calc_start_date,
384: l_calc_end_date;
385: IF csr_get_period%NOTFOUND
386: THEN
387: CLOSE csr_get_period;
388: hr_utility.set_message(801,'HR_51731_PTO_DATE_OUT_TIMEPRD');
389: -- hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
390: -- hr_utility.set_message_token('PROCEDURE','get_accrual');
391: -- hr_utility.set_message_token('STEP','3');
392: hr_utility.raise_error;
385: IF csr_get_period%NOTFOUND
386: THEN
387: CLOSE csr_get_period;
388: hr_utility.set_message(801,'HR_51731_PTO_DATE_OUT_TIMEPRD');
389: -- hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
390: -- hr_utility.set_message_token('PROCEDURE','get_accrual');
391: -- hr_utility.set_message_token('STEP','3');
392: hr_utility.raise_error;
393: END IF;
386: THEN
387: CLOSE csr_get_period;
388: hr_utility.set_message(801,'HR_51731_PTO_DATE_OUT_TIMEPRD');
389: -- hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
390: -- hr_utility.set_message_token('PROCEDURE','get_accrual');
391: -- hr_utility.set_message_token('STEP','3');
392: hr_utility.raise_error;
393: END IF;
394: CLOSE csr_get_period;
387: CLOSE csr_get_period;
388: hr_utility.set_message(801,'HR_51731_PTO_DATE_OUT_TIMEPRD');
389: -- hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
390: -- hr_utility.set_message_token('PROCEDURE','get_accrual');
391: -- hr_utility.set_message_token('STEP','3');
392: hr_utility.raise_error;
393: END IF;
394: CLOSE csr_get_period;
395: hr_utility.set_location('get_accrual',20);
388: hr_utility.set_message(801,'HR_51731_PTO_DATE_OUT_TIMEPRD');
389: -- hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
390: -- hr_utility.set_message_token('PROCEDURE','get_accrual');
391: -- hr_utility.set_message_token('STEP','3');
392: hr_utility.raise_error;
393: END IF;
394: CLOSE csr_get_period;
395: hr_utility.set_location('get_accrual',20);
396: --
391: -- hr_utility.set_message_token('STEP','3');
392: hr_utility.raise_error;
393: END IF;
394: CLOSE csr_get_period;
395: hr_utility.set_location('get_accrual',20);
396: --
397: -- Partial first period if start
398: --
399: -- Set return dates for the net process if nothing to accrue in this period
424: l_number_of_period;
425: IF csr_get_total_periods%NOTFOUND
426: THEN
427: CLOSE csr_get_total_periods;
428: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
429: hr_utility.set_message_token('PROCEDURE','get_accrual');
430: hr_utility.set_message_token('STEP','4');
431: hr_utility.raise_error;
432: END IF;
425: IF csr_get_total_periods%NOTFOUND
426: THEN
427: CLOSE csr_get_total_periods;
428: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
429: hr_utility.set_message_token('PROCEDURE','get_accrual');
430: hr_utility.set_message_token('STEP','4');
431: hr_utility.raise_error;
432: END IF;
433: CLOSE csr_get_total_periods;
426: THEN
427: CLOSE csr_get_total_periods;
428: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
429: hr_utility.set_message_token('PROCEDURE','get_accrual');
430: hr_utility.set_message_token('STEP','4');
431: hr_utility.raise_error;
432: END IF;
433: CLOSE csr_get_total_periods;
434: -- Set l_number_of_period such that it is based on NUMBER_PER_FISCAL_YEAR
427: CLOSE csr_get_total_periods;
428: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
429: hr_utility.set_message_token('PROCEDURE','get_accrual');
430: hr_utility.set_message_token('STEP','4');
431: hr_utility.raise_error;
432: END IF;
433: CLOSE csr_get_total_periods;
434: -- Set l_number_of_period such that it is based on NUMBER_PER_FISCAL_YEAR
435: -- for period type of payroll. Ie. The number returned from
445: AND PPF.payroll_id = P_payroll_id
446: AND l_calc_end_date BETWEEN PPF.effective_start_date
447: AND PPF.effective_end_date;
448: --
449: hr_utility.set_location('get_accrual',25);
450: --
451: -- In case of carry over a dummy date of 31-JUL-YYYY is passed in order to get
452: -- the no. of periods first and last period od that year etc. Check if P_mode
453: -- is 'C' then set the calculation date to the end date of last period and
452: -- the no. of periods first and last period od that year etc. Check if P_mode
453: -- is 'C' then set the calculation date to the end date of last period and
454: -- get period number for that period again.
455: --
456: hr_utility.set_location('get_accrual',27);
457: IF P_mode = 'C'
458: THEN
459: l_calc_period_num := l_number_of_period;
460: l_calc_start_date := P_last_period_start;
486: p_param_first_pendt := P_first_period_end;
487:
488: */
489:
490: hr_utility.set_location('get_accrual',30);
491: OPEN csr_get_period (P_payroll_id, P_first_period_start);
492: FETCH csr_get_period INTO p_param_first_pnum,
493: p_param_first_pstdt,
494: p_param_first_pendt;
494: p_param_first_pendt;
495: IF csr_get_period%NOTFOUND
496: THEN
497: CLOSE csr_get_period;
498: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
499: hr_utility.set_message_token('PROCEDURE','get_accrual');
500: hr_utility.set_message_token('STEP','5');
501: hr_utility.raise_error;
502: END IF;
495: IF csr_get_period%NOTFOUND
496: THEN
497: CLOSE csr_get_period;
498: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
499: hr_utility.set_message_token('PROCEDURE','get_accrual');
500: hr_utility.set_message_token('STEP','5');
501: hr_utility.raise_error;
502: END IF;
503: CLOSE csr_get_period;
496: THEN
497: CLOSE csr_get_period;
498: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
499: hr_utility.set_message_token('PROCEDURE','get_accrual');
500: hr_utility.set_message_token('STEP','5');
501: hr_utility.raise_error;
502: END IF;
503: CLOSE csr_get_period;
504: --
497: CLOSE csr_get_period;
498: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
499: hr_utility.set_message_token('PROCEDURE','get_accrual');
500: hr_utility.set_message_token('STEP','5');
501: hr_utility.raise_error;
502: END IF;
503: CLOSE csr_get_period;
504: --
505: -- Check termination date and adjust end date of the last calc Period
511: p_param_acc_calc_edt;
512: IF csr_get_period%NOTFOUND
513: THEN
514: CLOSE csr_get_period;
515: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
516: hr_utility.set_message_token('PROCEDURE','get_accrual');
517: hr_utility.set_message_token('STEP','6');
518: hr_utility.raise_error;
519: END IF;
512: IF csr_get_period%NOTFOUND
513: THEN
514: CLOSE csr_get_period;
515: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
516: hr_utility.set_message_token('PROCEDURE','get_accrual');
517: hr_utility.set_message_token('STEP','6');
518: hr_utility.raise_error;
519: END IF;
520: CLOSE csr_get_period;
513: THEN
514: CLOSE csr_get_period;
515: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
516: hr_utility.set_message_token('PROCEDURE','get_accrual');
517: hr_utility.set_message_token('STEP','6');
518: hr_utility.raise_error;
519: END IF;
520: CLOSE csr_get_period;
521: --
514: CLOSE csr_get_period;
515: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
516: hr_utility.set_message_token('PROCEDURE','get_accrual');
517: hr_utility.set_message_token('STEP','6');
518: hr_utility.raise_error;
519: END IF;
520: CLOSE csr_get_period;
521: --
522: hr_utility.set_location('get_accrual',35);
518: hr_utility.raise_error;
519: END IF;
520: CLOSE csr_get_period;
521: --
522: hr_utility.set_location('get_accrual',35);
523: --
524: -- No accruals for the partial periods
525: --
526: IF nvl(l_termination_date,P_calculation_date) < p_param_acc_calc_edt
524: -- No accruals for the partial periods
525: --
526: IF nvl(l_termination_date,P_calculation_date) < p_param_acc_calc_edt
527: THEN
528: hr_utility.set_location('get_accrual',36);
529: p_param_acc_calc_pno := p_param_acc_calc_pno - 1;
530: p_param_acc_calc_edt := l_temp_date - 1;
531:
532: END IF;
532: END IF;
533: --
534: -- Open plan cursor and check at least one plan should be there
535: --
536: hr_utility.set_location('get_accrual',40);
537: OPEN csr_get_plan_details(l_business_group_id);
538: FETCH csr_get_plan_details INTO l_acc_plan_type_id,
539: l_acc_plan_ele_type,
540: l_acc_uom,
545: l_element_entry_id;
546: IF csr_get_plan_details%NOTFOUND
547: THEN
548: CLOSE csr_get_plan_details;
549: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
550: hr_utility.set_message_token('PROCEDURE','get_accrual');
551: hr_utility.set_message_token('STEP','7');
552: hr_utility.raise_error;
553: END IF;
546: IF csr_get_plan_details%NOTFOUND
547: THEN
548: CLOSE csr_get_plan_details;
549: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
550: hr_utility.set_message_token('PROCEDURE','get_accrual');
551: hr_utility.set_message_token('STEP','7');
552: hr_utility.raise_error;
553: END IF;
554: --
547: THEN
548: CLOSE csr_get_plan_details;
549: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
550: hr_utility.set_message_token('PROCEDURE','get_accrual');
551: hr_utility.set_message_token('STEP','7');
552: hr_utility.raise_error;
553: END IF;
554: --
555: -- Loop thru all the plans and call function to calc. accruals for a plan
548: CLOSE csr_get_plan_details;
549: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
550: hr_utility.set_message_token('PROCEDURE','get_accrual');
551: hr_utility.set_message_token('STEP','7');
552: hr_utility.raise_error;
553: END IF;
554: --
555: -- Loop thru all the plans and call function to calc. accruals for a plan
556: --
553: END IF;
554: --
555: -- Loop thru all the plans and call function to calc. accruals for a plan
556: --
557: hr_utility.set_location('get_accrual',45);
558: LOOP
559: l_temp_date := null;
560: --
561: hr_utility.set_location('get_accrual',50);
557: hr_utility.set_location('get_accrual',45);
558: LOOP
559: l_temp_date := null;
560: --
561: hr_utility.set_location('get_accrual',50);
562: --
563: -- "Continous Service Date" is ALWAYS determined by:
564: -- 1. "Continuous Service Date" entry value on accrual plan.
565: -- 2. Hire Date of current period of service (ie. in absence of 1.)
565: -- 2. Hire Date of current period of service (ie. in absence of 1.)
566: --
567: IF l_csd_screen_value is null
568: THEN
569: hr_utility.set_location('get_accrual',51);
570: l_cont_service_date := l_service_start_date;
571: ELSE
572: hr_utility.set_location('get_accrual',52);
573: l_cont_service_date := fnd_date.canonical_to_date(l_csd_screen_value);
568: THEN
569: hr_utility.set_location('get_accrual',51);
570: l_cont_service_date := l_service_start_date;
571: ELSE
572: hr_utility.set_location('get_accrual',52);
573: l_cont_service_date := fnd_date.canonical_to_date(l_csd_screen_value);
574: END IF;
575: --
576: -- The "p_param_first..." variables determine when accrual begins for this
586: IF l_accrual_start = 'BOY'
587: THEN
588: -- 14022134
589: IF l_csd_screen_value is null then
590: hr_utility.set_location('get_accrual',811);
591:
592: select min (pee.effective_start_date) into l_plan_enrl_date
593: from pay_element_entries_f pee,
594: pay_element_links_f pel,
603: and pee.effective_end_date;
604:
605: if l_plan_enrl_date > l_service_start_date
606: then
607: hr_utility.set_location('get_accrual',820);
608: l_cont_service_date :=l_plan_enrl_date;
609: end if;
610: hr_utility.set_location('get_accrual',830);
611: end if;
606: then
607: hr_utility.set_location('get_accrual',820);
608: l_cont_service_date :=l_plan_enrl_date;
609: end if;
610: hr_utility.set_location('get_accrual',830);
611: end if;
612: -- 14022134
613:
614: -- Fix for the bug 14837603
614: -- Fix for the bug 14837603
615: -- l_temp_date := TRUNC(ADD_MONTHS(l_cont_service_date,12),'YEAR');
616: if months_between (fnd_date.canonical_to_date(l_csd_screen_value),p_calculation_date) < 12 then
617: l_temp_date := TRUNC(ADD_MONTHS(l_cont_service_date,12),'YEAR');
618: hr_utility.set_location('get_accrual :l_temp_date' ||l_temp_date,821);
619:
620: ELSE
621:
622: l_temp_date :=p_calculation_date;
619:
620: ELSE
621:
622: l_temp_date :=p_calculation_date;
623: hr_utility.set_location('get_accrual :l_temp_date' ||l_temp_date,822);
624: END IF;
625:
626: OPEN csr_get_period (P_payroll_id, p_calculation_date);
627:
632: p_param_first_pendt;
633: IF csr_get_period%NOTFOUND
634: THEN
635: CLOSE csr_get_period;
636: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
637: hr_utility.set_message_token('PROCEDURE','get_accrual');
638: hr_utility.set_message_token('STEP','8');
639: hr_utility.raise_error;
640: END IF;
633: IF csr_get_period%NOTFOUND
634: THEN
635: CLOSE csr_get_period;
636: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
637: hr_utility.set_message_token('PROCEDURE','get_accrual');
638: hr_utility.set_message_token('STEP','8');
639: hr_utility.raise_error;
640: END IF;
641: CLOSE csr_get_period;
634: THEN
635: CLOSE csr_get_period;
636: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
637: hr_utility.set_message_token('PROCEDURE','get_accrual');
638: hr_utility.set_message_token('STEP','8');
639: hr_utility.raise_error;
640: END IF;
641: CLOSE csr_get_period;
642: l_temp_date := null;
635: CLOSE csr_get_period;
636: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
637: hr_utility.set_message_token('PROCEDURE','get_accrual');
638: hr_utility.set_message_token('STEP','8');
639: hr_utility.raise_error;
640: END IF;
641: CLOSE csr_get_period;
642: l_temp_date := null;
643: ELSIF l_accrual_start = 'HD'
672: l_temp_date;
673: IF csr_get_period%NOTFOUND
674: THEN
675: CLOSE csr_get_period;
676: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
677: hr_utility.set_message_token('PROCEDURE','get_accrual');
678: hr_utility.set_message_token('STEP','10');
679: hr_utility.raise_error;
680: END IF;
673: IF csr_get_period%NOTFOUND
674: THEN
675: CLOSE csr_get_period;
676: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
677: hr_utility.set_message_token('PROCEDURE','get_accrual');
678: hr_utility.set_message_token('STEP','10');
679: hr_utility.raise_error;
680: END IF;
681: CLOSE csr_get_period;
674: THEN
675: CLOSE csr_get_period;
676: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
677: hr_utility.set_message_token('PROCEDURE','get_accrual');
678: hr_utility.set_message_token('STEP','10');
679: hr_utility.raise_error;
680: END IF;
681: CLOSE csr_get_period;
682: --
675: CLOSE csr_get_period;
676: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
677: hr_utility.set_message_token('PROCEDURE','get_accrual');
678: hr_utility.set_message_token('STEP','10');
679: hr_utility.raise_error;
680: END IF;
681: CLOSE csr_get_period;
682: --
683: OPEN csr_get_period (P_payroll_id, l_temp_date + 1);
686: p_param_first_pendt;
687: IF csr_get_period%NOTFOUND
688: THEN
689: CLOSE csr_get_period;
690: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
691: hr_utility.set_message_token('PROCEDURE','get_accrual');
692: hr_utility.set_message_token('STEP','11');
693: hr_utility.raise_error;
694: END IF;
687: IF csr_get_period%NOTFOUND
688: THEN
689: CLOSE csr_get_period;
690: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
691: hr_utility.set_message_token('PROCEDURE','get_accrual');
692: hr_utility.set_message_token('STEP','11');
693: hr_utility.raise_error;
694: END IF;
695: CLOSE csr_get_period;
688: THEN
689: CLOSE csr_get_period;
690: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
691: hr_utility.set_message_token('PROCEDURE','get_accrual');
692: hr_utility.set_message_token('STEP','11');
693: hr_utility.raise_error;
694: END IF;
695: CLOSE csr_get_period;
696: l_temp_date := null;
689: CLOSE csr_get_period;
690: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
691: hr_utility.set_message_token('PROCEDURE','get_accrual');
692: hr_utility.set_message_token('STEP','11');
693: hr_utility.raise_error;
694: END IF;
695: CLOSE csr_get_period;
696: l_temp_date := null;
697: END IF;
694: END IF;
695: CLOSE csr_get_period;
696: l_temp_date := null;
697: END IF;
698: hr_utility.set_location('get_accrual',55);
699: --
700: -- Add period of ineligibility
701: --
702: IF l_accrual_start <> 'PLUS_SIX_MONTHS' AND
701: --
702: IF l_accrual_start <> 'PLUS_SIX_MONTHS' AND
703: l_inelig_p_length > 0
704: THEN
705: hr_utility.set_location('get_accrual',60);
706: IF l_inelig_period = 'BM'
707: THEN
708: l_temp_date := ADD_MONTHS(l_cont_service_date,
709: (l_inelig_p_length * 2));
746: -- Determine start and end date and setup return parmas.
747: -- check Period of Service start date, plan element entry start date
748: -- if later then first period start. Accrual period start date accordingly.
749: --
750: hr_utility.set_location('get_accrual',65);
751: select min(effective_start_date)
752: into l_plan_start_date
753: from pay_element_entries_f
754: where element_entry_id = l_element_entry_id;
751: select min(effective_start_date)
752: into l_plan_start_date
753: from pay_element_entries_f
754: where element_entry_id = l_element_entry_id;
755: hr_utility.set_location('get_accrual',67);
756: ---
757:
758: --- Set the return params
759: --
763: P_end_date := LEAST(NVL(L_termination_date,P_calculation_date)
764: ,P_calculation_date);
765:
766: --
767: hr_utility.set_location('get_accrual',68);
768: IF ( l_temp_date is not null AND
769: l_temp_date >= p_param_acc_calc_edt ) OR
770: l_cont_service_date >= p_param_acc_calc_edt OR
771:
771:
772: p_param_first_pstdt >= p_param_acc_calc_edt
773:
774: THEN
775: hr_utility.set_location('get_accrual',70);
776: l_plan_accrual := 0;
777: ELSE
778: --
779: -- Set the Start Date appropriately.
789: --
790: IF l_temp_date > P_first_period_start
791: AND l_temp_date > nvl(p_param_first_pstdt, l_temp_date - 1)
792: THEN
793: hr_utility.set_location('get_accrual',71);
794: OPEN csr_get_period (P_payroll_id, l_temp_date);
795: FETCH csr_get_period INTO p_param_first_pnum,
796: p_param_first_pstdt,
797: p_param_first_pendt;
797: p_param_first_pendt;
798: IF csr_get_period%NOTFOUND
799: THEN
800: CLOSE csr_get_period;
801: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
802: hr_utility.set_message_token('PROCEDURE','get_accrual');
803: hr_utility.set_message_token('STEP','12');
804: hr_utility.raise_error;
805: END IF;
798: IF csr_get_period%NOTFOUND
799: THEN
800: CLOSE csr_get_period;
801: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
802: hr_utility.set_message_token('PROCEDURE','get_accrual');
803: hr_utility.set_message_token('STEP','12');
804: hr_utility.raise_error;
805: END IF;
806: CLOSE csr_get_period;
799: THEN
800: CLOSE csr_get_period;
801: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
802: hr_utility.set_message_token('PROCEDURE','get_accrual');
803: hr_utility.set_message_token('STEP','12');
804: hr_utility.raise_error;
805: END IF;
806: CLOSE csr_get_period;
807: hr_utility.set_location('get_accrual',80);
800: CLOSE csr_get_period;
801: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
802: hr_utility.set_message_token('PROCEDURE','get_accrual');
803: hr_utility.set_message_token('STEP','12');
804: hr_utility.raise_error;
805: END IF;
806: CLOSE csr_get_period;
807: hr_utility.set_location('get_accrual',80);
808: --
803: hr_utility.set_message_token('STEP','12');
804: hr_utility.raise_error;
805: END IF;
806: CLOSE csr_get_period;
807: hr_utility.set_location('get_accrual',80);
808: --
809: -- No Accruals fro the partial periods. First period to start the
810: -- accrual will be next one.
811: --
810: -- accrual will be next one.
811: --
812: IF l_temp_date > p_param_first_pstdt
813: THEN
814: hr_utility.set_location('get_accrual',85);
815: p_param_first_pendt := p_param_first_pendt +1;
816: OPEN csr_get_period (P_payroll_id, p_param_first_pendt);
817: FETCH csr_get_period INTO p_param_first_pnum,
818: p_param_first_pstdt,
819: p_param_first_pendt;
820: IF csr_get_period%NOTFOUND
821: THEN
822: CLOSE csr_get_period;
823: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
824: hr_utility.set_message_token('PROCEDURE','get_accrual');
825: hr_utility.set_message_token('STEP','13');
826: hr_utility.raise_error;
827: END IF;
820: IF csr_get_period%NOTFOUND
821: THEN
822: CLOSE csr_get_period;
823: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
824: hr_utility.set_message_token('PROCEDURE','get_accrual');
825: hr_utility.set_message_token('STEP','13');
826: hr_utility.raise_error;
827: END IF;
828: CLOSE csr_get_period;
821: THEN
822: CLOSE csr_get_period;
823: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
824: hr_utility.set_message_token('PROCEDURE','get_accrual');
825: hr_utility.set_message_token('STEP','13');
826: hr_utility.raise_error;
827: END IF;
828: CLOSE csr_get_period;
829: END IF;
822: CLOSE csr_get_period;
823: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
824: hr_utility.set_message_token('PROCEDURE','get_accrual');
825: hr_utility.set_message_token('STEP','13');
826: hr_utility.raise_error;
827: END IF;
828: CLOSE csr_get_period;
829: END IF;
830: END IF;
835: THEN
836: l_plan_accrual := 0;
837: ELSE
838: --
839: hr_utility.set_location('get_accrual_for_plan',90);
840: pay_us_pto_accrual.get_accrual_for_plan
841: ( p_plan_id => l_acc_plan_type_id,
842: p_first_p_start_date => p_param_first_pstdt,
843: p_first_p_end_date => p_param_first_pendt,
857: END IF;
858: --
859: -- Add accrual to the total and Fetch next set of plan
860: --
861: hr_utility.set_location('get_accrual',95);
862: l_total_accrual := l_total_accrual + l_plan_accrual;
863: l_plan_accrual := 0;
864:
865: FETCH csr_get_plan_details INTO l_acc_plan_type_id,
872: l_element_entry_id;
873: --
874:
875: EXIT WHEN csr_get_plan_details%NOTFOUND;
876: hr_utility.set_location('get_accrual',100);
877: --
878: END LOOP;
879: --
880: CLOSE csr_get_plan_details;
880: CLOSE csr_get_plan_details;
881: --
882: IF l_total_accrual is null
883: THEN
884: hr_utility.set_location('get_accrual',105);
885: l_total_accrual := 0;
886: END IF;
887: hr_utility.set_location('get_accrual',110);
888: l_total_accrual := round(l_total_accrual,3);
883: THEN
884: hr_utility.set_location('get_accrual',105);
885: l_total_accrual := 0;
886: END IF;
887: hr_utility.set_location('get_accrual',110);
888: l_total_accrual := round(l_total_accrual,3);
889: P_accrual := l_total_accrual;
890: --
891: -- Partial first period if end
1023: --
1024: --
1025: BEGIN
1026: --
1027: hr_utility.set_location('get_accrual_for_plan',1);
1028: l_year_1 := TRUNC(ABS(months_between(P_continuous_service_date,
1029: P_first_p_end_date)/12));
1030: l_year_2 := TRUNC(ABS(months_between(P_continuous_service_date,
1031: p_accrual_calc_p_end_date)/12));
1036: OPEN csr_get_bands (l_year_1);
1037: FETCH csr_get_bands INTO l_annual_rate,l_ceiling_1,
1038: l_lower_limit,l_upper_limit,
1039: l_carry_over_1;
1040: hr_utility.set_location('get_accrual_for_plan',5);
1041:
1042: IF csr_get_bands%NOTFOUND THEN
1043: l_acc_rate_pp_1 := 0;
1044: ELSE
1047: l_ceiling_flag := 'Y';
1048: END IF;
1049: END IF;
1050: CLOSE csr_get_bands;
1051: hr_utility.set_location('get_accrual_for_plan',10);
1052: --
1053: IF l_year_2 < l_upper_limit and l_acc_rate_pp_1 > 0 THEN
1054: l_acc_rate_pp_2 := 0;
1055: ELSE
1052: --
1053: IF l_year_2 < l_upper_limit and l_acc_rate_pp_1 > 0 THEN
1054: l_acc_rate_pp_2 := 0;
1055: ELSE
1056: hr_utility.set_location('get_accrual_for_plan',15);
1057: OPEN csr_get_bands (l_year_2);
1058: FETCH csr_get_bands INTO l_annual_rate,l_ceiling_2,
1059: l_lower_limit,l_upper_limit,
1060: l_carry_over_2;
1073: END IF;
1074: CLOSE csr_get_bands;
1075: END IF;
1076: END IF;
1077: hr_utility.set_location('get_accrual_for_plan',20);
1078: --
1079: --
1080: IF ((l_acc_rate_pp_1 <> l_acc_rate_pp_2) AND
1081: l_acc_rate_pp_2 <> 0 ) THEN
1104: ELSE
1105: P_current_carry_over := l_carry_over_2;
1106: END IF;
1107: --
1108: hr_utility.set_location('get_accrual_for_plan',25);
1109: OPEN csr_all_asg_status;
1110: FETCH csr_all_asg_status into l_asg_eff_start_date,
1111: l_asg_eff_end_date,
1112: l_asg_status;
1109: OPEN csr_all_asg_status;
1110: FETCH csr_all_asg_status into l_asg_eff_start_date,
1111: l_asg_eff_end_date,
1112: l_asg_status;
1113: hr_utility.set_location('get_accrual_for_plan',30);
1114: --
1115: -- Check if calc method should use ceiling calculation or Non-ceiling
1116: -- calculation. For simplicity if there is any asg. status change then
1117: -- ceiling calculation method is used.
1124: -- Non Ceiling Calc
1125: --
1126: OPEN csr_get_period(P_Payroll_id, l_band_change_date);
1127: FETCH csr_get_period INTO l_curr_p_num,l_curr_p_stdt,l_curr_p_endt;
1128: hr_utility.set_location('get_accrual_for_plan',35);
1129: IF csr_get_period%NOTFOUND THEN
1130: CLOSE csr_get_period;
1131: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
1132: hr_utility.set_message_token('PROCEDURE','get_accrual_for_plan');
1127: FETCH csr_get_period INTO l_curr_p_num,l_curr_p_stdt,l_curr_p_endt;
1128: hr_utility.set_location('get_accrual_for_plan',35);
1129: IF csr_get_period%NOTFOUND THEN
1130: CLOSE csr_get_period;
1131: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
1132: hr_utility.set_message_token('PROCEDURE','get_accrual_for_plan');
1133: hr_utility.set_message_token('STEP','14');
1134: hr_utility.raise_error;
1135: END IF;
1128: hr_utility.set_location('get_accrual_for_plan',35);
1129: IF csr_get_period%NOTFOUND THEN
1130: CLOSE csr_get_period;
1131: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
1132: hr_utility.set_message_token('PROCEDURE','get_accrual_for_plan');
1133: hr_utility.set_message_token('STEP','14');
1134: hr_utility.raise_error;
1135: END IF;
1136: CLOSE csr_get_period;
1129: IF csr_get_period%NOTFOUND THEN
1130: CLOSE csr_get_period;
1131: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
1132: hr_utility.set_message_token('PROCEDURE','get_accrual_for_plan');
1133: hr_utility.set_message_token('STEP','14');
1134: hr_utility.raise_error;
1135: END IF;
1136: CLOSE csr_get_period;
1137: --
1130: CLOSE csr_get_period;
1131: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
1132: hr_utility.set_message_token('PROCEDURE','get_accrual_for_plan');
1133: hr_utility.set_message_token('STEP','14');
1134: hr_utility.raise_error;
1135: END IF;
1136: CLOSE csr_get_period;
1137: --
1138: -- gpaytonm 15-nov mod - added close csr_get_period
1137: --
1138: -- gpaytonm 15-nov mod - added close csr_get_period
1139: --
1140: --
1141: hr_utility.set_location('get_accrual_for_plan',40);
1142: if l_curr_p_num = 1 AND
1143: p_accrual_calc_p_end_date < l_band_change_date
1144: then
1145: l_curr_p_num := P_number_of_periods;
1151: --
1152: -- Entitlement from first period to Band change date.
1153: --
1154: l_accrual := l_acc_rate_pp_1 * (l_curr_p_num - (p_first_calc_P_number - 1));
1155: hr_utility.set_location('get_accrual_for_plan',45);
1156: --
1157: -- Entitlement from Band change date to Calc. date
1158: --
1159: IF p_accrual_calc_p_end_date >= l_band_change_date THEN
1162: ELSE
1163: --
1164: -- Ceiling Calc
1165: --
1166: hr_utility.set_location('get_accrual_for_plan',50);
1167: OPEN csr_get_time_periods;
1168: l_running_total := 0;
1169: l_curr_p_acc := 0;
1170: LOOP
1167: OPEN csr_get_time_periods;
1168: l_running_total := 0;
1169: l_curr_p_acc := 0;
1170: LOOP
1171: hr_utility.set_location('get_accrual_for_plan',55);
1172: FETCH csr_get_time_periods into l_start_Date,
1173: l_end_date,
1174: l_period_num;
1175: EXIT WHEN csr_get_time_periods%NOTFOUND;
1187: l_working_day := 0;
1188: l_unpaid_day := 0;
1189: l_vac_taken := 0;
1190: l_prev_end_date := l_asg_eff_end_date;
1191: hr_utility.set_location('get_accrual_for_plan',60);
1192: --
1193: IF l_asg_eff_end_date between l_start_Date and l_end_date
1194: THEN
1195: IF l_asg_status <> 'ACTIVE_ASSIGN' THEN
1197: l_asg_eff_end_date);
1198: END IF;
1199: --
1200: --
1201: hr_utility.set_location('get_accrual_for_plan',65);
1202: LOOP
1203: hr_utility.set_location('get_accrual_for_plan',70);
1204: l_prev_end_date := l_asg_eff_end_date;
1205: FETCH csr_all_asg_status into l_asg_eff_start_date,
1199: --
1200: --
1201: hr_utility.set_location('get_accrual_for_plan',65);
1202: LOOP
1203: hr_utility.set_location('get_accrual_for_plan',70);
1204: l_prev_end_date := l_asg_eff_end_date;
1205: FETCH csr_all_asg_status into l_asg_eff_start_date,
1206: l_asg_eff_end_date,
1207: l_asg_status;
1220: --
1221: --
1222: ELSIF csr_all_asg_status%ISOPEN and l_asg_status <> 'ACTIVE_ASSIGN' THEN
1223: l_mult_factor := 0;
1224: hr_utility.set_location('get_accrual_for_plan',75);
1225: ELSIF NOT (csr_all_asg_status%ISOPEN ) THEN
1226: hr_utility.set_location('get_accrual_for_plan',80);
1227: l_mult_factor := 0;
1228: ELSE
1222: ELSIF csr_all_asg_status%ISOPEN and l_asg_status <> 'ACTIVE_ASSIGN' THEN
1223: l_mult_factor := 0;
1224: hr_utility.set_location('get_accrual_for_plan',75);
1225: ELSIF NOT (csr_all_asg_status%ISOPEN ) THEN
1226: hr_utility.set_location('get_accrual_for_plan',80);
1227: l_mult_factor := 0;
1228: ELSE
1229: hr_utility.set_location('get_accrual_for_plan',85);
1230: l_mult_factor := 1;
1225: ELSIF NOT (csr_all_asg_status%ISOPEN ) THEN
1226: hr_utility.set_location('get_accrual_for_plan',80);
1227: l_mult_factor := 0;
1228: ELSE
1229: hr_utility.set_location('get_accrual_for_plan',85);
1230: l_mult_factor := 1;
1231: END IF;
1232: --
1233: --
1231: END IF;
1232: --
1233: --
1234: IF l_unpaid_day <> 0 THEN
1235: hr_utility.set_location('get_accrual_for_plan',90);
1236: l_working_day := get_working_days(l_start_Date,l_end_date);
1237: IF l_working_day = l_unpaid_day THEN
1238: l_mult_factor := 0;
1239: ELSE
1243: --
1244: -- Find out vacation and carry over if the method is ceiling
1245: --
1246: IF l_ceiling_flag = 'Y' THEN
1247: hr_utility.set_location('get_accrual_for_plan',95);
1248: OPEN csr_calc_accrual(l_start_Date, l_end_date,
1249: P_assignment_id, P_plan_id);
1250: FETCH csr_calc_accrual INTO l_vac_taken;
1251: IF csr_calc_accrual%NOTFOUND or l_vac_taken is null THEN
1256: --
1257: -- Multiply the Accrual rate for the current band and Multiplication
1258: -- Factor to get current period accrual.
1259: --
1260: hr_utility.set_location('get_accrual_for_plan',100);
1261: IF (l_band_change_date between l_start_Date and l_end_date)
1262: OR ( l_band_change_date < l_end_date)
1263: THEN
1264: l_curr_p_acc := l_acc_rate_pp_2 * l_mult_factor;
1270: --
1271: --
1272: -- Check for ceiling limits
1273: --
1274: hr_utility.set_location('get_accrual_for_plan',105);
1275: IF l_ceiling_flag = 'Y' THEN
1276: l_running_total := l_running_total + l_vac_taken + l_curr_p_acc;
1277: IF l_running_total > l_curr_ceiling THEN
1278: IF (l_running_total - l_curr_ceiling) < l_curr_p_acc
1288: END IF;
1289: ELSE
1290: l_accrual := l_accrual + l_curr_p_acc;
1291: END IF;
1292: hr_utility.set_location('get_accrual_for_plan',110);
1293: --
1294: --
1295: -- #305751 Remove the END IF matching the removed IF above.
1296: --
1324: --
1325: BEGIN
1326: --
1327: -- Check for valid range
1328: hr_utility.set_location('get_working_days', 5);
1329: IF p_start_date > P_end_date THEN
1330: hr_utility.set_location('get_working_days', 8);
1331: RETURN l_total_days;
1332: END IF;
1326: --
1327: -- Check for valid range
1328: hr_utility.set_location('get_working_days', 5);
1329: IF p_start_date > P_end_date THEN
1330: hr_utility.set_location('get_working_days', 8);
1331: RETURN l_total_days;
1332: END IF;
1333: --
1334: l_curr_date := P_start_date;
1331: RETURN l_total_days;
1332: END IF;
1333: --
1334: l_curr_date := P_start_date;
1335: hr_utility.set_location('get_working_days', 10);
1336: LOOP
1337: l_curr_day := TO_CHAR(l_curr_date, 'DY');
1338: hr_utility.set_location('get_working_days', 15);
1339: IF UPPER(l_curr_day) in ('MON', 'TUE', 'WED', 'THU', 'FRI') THEN
1334: l_curr_date := P_start_date;
1335: hr_utility.set_location('get_working_days', 10);
1336: LOOP
1337: l_curr_day := TO_CHAR(l_curr_date, 'DY');
1338: hr_utility.set_location('get_working_days', 15);
1339: IF UPPER(l_curr_day) in ('MON', 'TUE', 'WED', 'THU', 'FRI') THEN
1340: l_total_days := l_total_days + 1;
1341: hr_utility.set_location('get_working_days', 20);
1342: END IF;
1337: l_curr_day := TO_CHAR(l_curr_date, 'DY');
1338: hr_utility.set_location('get_working_days', 15);
1339: IF UPPER(l_curr_day) in ('MON', 'TUE', 'WED', 'THU', 'FRI') THEN
1340: l_total_days := l_total_days + 1;
1341: hr_utility.set_location('get_working_days', 20);
1342: END IF;
1343: l_curr_date := l_curr_date + 1;
1344: EXIT WHEN l_curr_date > P_end_date;
1345: END LOOP;
1394: d7 date;
1395: --
1396: BEGIN
1397: --
1398: hr_utility.set_location('Entering: '||l_proc, 10);
1399:
1400: IF NOT use_fast_formula(p_effective_date => p_calculation_date
1401: ,p_plan_id => p_plan_id) THEN
1402: --
1407: -- payroll balance.
1408: -- For this reason, the old 10.7 code is called because it
1409: -- is significantly faster than executing Fast Formula.
1410: --
1411: hr_utility.set_location(l_proc, 20);
1412:
1413: pay_us_pto_accrual.net_accruals(
1414: P_assignment_id => P_assignment_id,
1415: P_calculation_date => c_date,
1462: else
1463: l_assignment_action_id := p_assignment_action_id;
1464: end if;
1465:
1466: hr_utility.set_location(l_proc, 30);
1467:
1468: per_accrual_calc_functions.get_net_accrual(
1469: P_assignment_id => p_assignment_id,
1470: P_plan_id => p_plan_id,
1483: );
1484: --
1485: end if;
1486:
1487: hr_utility.trace('l_entitlement: '||to_char(l_entitlement));
1488:
1489: hr_utility.set_location('Leaving: '||l_proc, 90);
1490:
1491: RETURN(l_entitlement);
1485: end if;
1486:
1487: hr_utility.trace('l_entitlement: '||to_char(l_entitlement));
1488:
1489: hr_utility.set_location('Leaving: '||l_proc, 90);
1490:
1491: RETURN(l_entitlement);
1492: --
1493: END get_net_accrual;
1526: BEGIN
1527: --
1528: -- Get vaction accrued
1529: --
1530: hr_utility.set_location('get_net_accrual',5);
1531: pay_us_pto_accrual.accrual_calc_detail(
1532: P_assignment_id => P_assignment_id,
1533: P_calculation_date => P_calculation_date,
1534: P_plan_id => P_plan_id,
1557: THEN
1558: l_taken := 0;
1559: END IF;
1560: CLOSE csr_calc_accrual;
1561: hr_utility.set_location('get_net_accrual',20);
1562: --
1563: --
1564: P_net_accrual := ROUND((P_accrual + l_taken),3);
1565:
1569: --
1570: IF P_mode = 'C'
1571: THEN
1572: OPEN csr_get_period(p_payroll_id,(P_last_period_end +1));
1573: hr_utility.set_location('get_net_accrual',21);
1574: FETCH csr_get_period into l_temp,P_start_date,P_end_date;
1575: IF csr_get_period%NOTFOUND THEN
1576: CLOSE csr_get_period;
1577: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
1573: hr_utility.set_location('get_net_accrual',21);
1574: FETCH csr_get_period into l_temp,P_start_date,P_end_date;
1575: IF csr_get_period%NOTFOUND THEN
1576: CLOSE csr_get_period;
1577: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
1578: hr_utility.set_message_token('PROCEDURE','net_accruals');
1579: hr_utility.set_message_token('STEP','15');
1580: hr_utility.raise_error;
1581: END IF;
1574: FETCH csr_get_period into l_temp,P_start_date,P_end_date;
1575: IF csr_get_period%NOTFOUND THEN
1576: CLOSE csr_get_period;
1577: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
1578: hr_utility.set_message_token('PROCEDURE','net_accruals');
1579: hr_utility.set_message_token('STEP','15');
1580: hr_utility.raise_error;
1581: END IF;
1582: CLOSE csr_get_period;
1575: IF csr_get_period%NOTFOUND THEN
1576: CLOSE csr_get_period;
1577: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
1578: hr_utility.set_message_token('PROCEDURE','net_accruals');
1579: hr_utility.set_message_token('STEP','15');
1580: hr_utility.raise_error;
1581: END IF;
1582: CLOSE csr_get_period;
1583: hr_utility.set_location('get_net_accrual',22);
1576: CLOSE csr_get_period;
1577: hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
1578: hr_utility.set_message_token('PROCEDURE','net_accruals');
1579: hr_utility.set_message_token('STEP','15');
1580: hr_utility.raise_error;
1581: END IF;
1582: CLOSE csr_get_period;
1583: hr_utility.set_location('get_net_accrual',22);
1584: END IF;
1579: hr_utility.set_message_token('STEP','15');
1580: hr_utility.raise_error;
1581: END IF;
1582: CLOSE csr_get_period;
1583: hr_utility.set_location('get_net_accrual',22);
1584: END IF;
1585: --
1586: --
1587: END net_accruals;