190: l_eot := to_date('4712/12/31 00:00:00', 'YYYY/MM/DD HH24:MI:SS');
191: l_proc := 'pay_sg_deductions.fwl_amount';
192:
193:
194: hr_utility.set_location('Entering : '||l_proc, 5);
195:
196: l_counter := 1;
197:
198: open c_get_dates( p_assignment_id, p_start_date, p_end_date) ;
197:
198: open c_get_dates( p_assignment_id, p_start_date, p_end_date) ;
199: fetch c_get_dates into l_permit(l_counter);
200: if c_get_dates%notfound then
201: hr_utility.set_location('Leaving - No fwl in month : '||l_proc, 10);
202: return 0;
203: end if;
204:
205: l_counter := l_counter + 1;
247: FOR i in 1..l_permit.last LOOP
248:
249: if l_permit(i).permit_category is null then
250:
251: hr_utility.set_location('Error - WP Category is null : '||l_proc, 88);
252: return (-88);
253:
254: else
255:
255:
256: if (l_permit(i).date_start > l_permit(i).date_end)
257: OR (l_permit(i).date_start > l_permit(i).date_cancel-1) THEN
258:
259: hr_utility.set_location('Invalid Date Ranges Within Month: '||l_proc, 77);
260: return (-77);
261:
262:
263: elsif (l_permit(i).date_start > p_end_date )
297:
298:
299: if l_tot_days > l_max_days then
300:
301: hr_utility.set_location('Invalid Date Ranges Within Month : '||l_proc, 77);
302: return (-77);
303:
304: end if;
305:
338: end if;
339:
340: END LOOP;
341:
342: hr_utility.set_location('Leaving:'||l_proc, 20);
343: return l_amt;
344:
345: EXCEPTION
346: WHEN others THEN
343: return l_amt;
344:
345: EXCEPTION
346: WHEN others THEN
347: hr_utility.set_location('Unhandled Exception in function call fwl_amount : '||l_proc, 99);
348: RETURN -99;
349:
350: end fwl_amount;
351:
425: l_eot := to_date('4712/12/31 00:00:00', 'YYYY/MM/DD HH24:MI:SS');
426: l_proc := 'pay_sg_deductions.spl_amount';
427:
428:
429: hr_utility.set_location('Entering : '||l_proc, 5);
430:
431: l_counter := 1;
432:
433: open c_get_dates( p_assignment_id, p_start_date, p_end_date) ;
432:
433: open c_get_dates( p_assignment_id, p_start_date, p_end_date) ;
434: fetch c_get_dates into l_permit(l_counter);
435: if c_get_dates%notfound then
436: hr_utility.set_location('Leaving - No spl in month : '||l_proc, 10);
437: return 0;
438: end if;
439:
440: l_counter := l_counter + 1;
480: FOR i in 1..l_permit.last LOOP
481:
482: if l_permit(i).permit_category is null then
483:
484: hr_utility.set_location('Error - SP Category is null : '||l_proc, 88);
485: return (-88);
486:
487: else
488:
488:
489: if (l_permit(i).date_start > l_permit(i).date_end)
490: OR (l_permit(i).date_start > l_permit(i).date_cancel-1) THEN
491:
492: hr_utility.set_location('Invalid Date Ranges Within Month: '||l_proc, 77);
493: return (-77);
494:
495:
496: elsif (l_permit(i).date_start > p_end_date )
531:
532:
533: if l_tot_days > l_max_days then
534:
535: hr_utility.set_location('Invalid Date Ranges Within Month : '||l_proc, 77);
536: return (-77);
537:
538: end if;
539:
573:
574: END LOOP;
575:
576:
577: hr_utility.set_location('Leaving:'||l_proc, 20);
578: return l_amt;
579:
580: EXCEPTION
581: WHEN others THEN
578: return l_amt;
579:
580: EXCEPTION
581: WHEN others THEN
582: hr_utility.set_location('Unhandled Exception in function call spl_amount : '||l_proc, 99);
583: RETURN -99;
584:
585: end spl_amount;
586:
656: l_emp_end_bet_period := 'N';
657: l_proc := 'pay_sg_deductions.sg_get_prorator';
658:
659: /* Get the WAC effective at start of the pay period */
660: hr_utility.set_location('Entering : '||l_proc, 5);
661: hr_utility.trace('p_assignment_id : '||p_assignment_id);
662: hr_utility.trace('p_pay_proc_start_date : '||p_pay_proc_start_date );
663: hr_utility.trace('p_pay_proc_end_date : '||p_pay_proc_end_date );
664: hr_utility.trace('p_date_earned : '||p_date_earned );
657: l_proc := 'pay_sg_deductions.sg_get_prorator';
658:
659: /* Get the WAC effective at start of the pay period */
660: hr_utility.set_location('Entering : '||l_proc, 5);
661: hr_utility.trace('p_assignment_id : '||p_assignment_id);
662: hr_utility.trace('p_pay_proc_start_date : '||p_pay_proc_start_date );
663: hr_utility.trace('p_pay_proc_end_date : '||p_pay_proc_end_date );
664: hr_utility.trace('p_date_earned : '||p_date_earned );
665: hr_utility.trace('p_wac : '||p_wac);
658:
659: /* Get the WAC effective at start of the pay period */
660: hr_utility.set_location('Entering : '||l_proc, 5);
661: hr_utility.trace('p_assignment_id : '||p_assignment_id);
662: hr_utility.trace('p_pay_proc_start_date : '||p_pay_proc_start_date );
663: hr_utility.trace('p_pay_proc_end_date : '||p_pay_proc_end_date );
664: hr_utility.trace('p_date_earned : '||p_date_earned );
665: hr_utility.trace('p_wac : '||p_wac);
666: hr_utility.trace('p_cpf_pro_method : '||p_cpf_pro_method );
659: /* Get the WAC effective at start of the pay period */
660: hr_utility.set_location('Entering : '||l_proc, 5);
661: hr_utility.trace('p_assignment_id : '||p_assignment_id);
662: hr_utility.trace('p_pay_proc_start_date : '||p_pay_proc_start_date );
663: hr_utility.trace('p_pay_proc_end_date : '||p_pay_proc_end_date );
664: hr_utility.trace('p_date_earned : '||p_date_earned );
665: hr_utility.trace('p_wac : '||p_wac);
666: hr_utility.trace('p_cpf_pro_method : '||p_cpf_pro_method );
667:
660: hr_utility.set_location('Entering : '||l_proc, 5);
661: hr_utility.trace('p_assignment_id : '||p_assignment_id);
662: hr_utility.trace('p_pay_proc_start_date : '||p_pay_proc_start_date );
663: hr_utility.trace('p_pay_proc_end_date : '||p_pay_proc_end_date );
664: hr_utility.trace('p_date_earned : '||p_date_earned );
665: hr_utility.trace('p_wac : '||p_wac);
666: hr_utility.trace('p_cpf_pro_method : '||p_cpf_pro_method );
667:
668: p_cpf_calc_type := p_wac ; /* assign the default value of WAC for the person as WAC exist at period end date */
661: hr_utility.trace('p_assignment_id : '||p_assignment_id);
662: hr_utility.trace('p_pay_proc_start_date : '||p_pay_proc_start_date );
663: hr_utility.trace('p_pay_proc_end_date : '||p_pay_proc_end_date );
664: hr_utility.trace('p_date_earned : '||p_date_earned );
665: hr_utility.trace('p_wac : '||p_wac);
666: hr_utility.trace('p_cpf_pro_method : '||p_cpf_pro_method );
667:
668: p_cpf_calc_type := p_wac ; /* assign the default value of WAC for the person as WAC exist at period end date */
669:
662: hr_utility.trace('p_pay_proc_start_date : '||p_pay_proc_start_date );
663: hr_utility.trace('p_pay_proc_end_date : '||p_pay_proc_end_date );
664: hr_utility.trace('p_date_earned : '||p_date_earned );
665: hr_utility.trace('p_wac : '||p_wac);
666: hr_utility.trace('p_cpf_pro_method : '||p_cpf_pro_method );
667:
668: p_cpf_calc_type := p_wac ; /* assign the default value of WAC for the person as WAC exist at period end date */
669:
670: open c_get_per_start_end_dates(p_assignment_id , p_pay_proc_start_date, p_pay_proc_end_date);
671: fetch c_get_per_start_end_dates into l_assign_start_date,l_assign_end_date;
672:
673: if c_get_per_start_end_dates%NOTFOUND then
674: close c_get_per_start_end_dates;
675: hr_utility.set_location('Error : Assignment does not exist in the pay process period'||l_proc,5);
676: else
677: if (l_assign_start_date > p_pay_proc_start_date ) then
678: l_proc_start_date := l_assign_start_date;
679: else
689: open c_get_wac( p_assignment_id , l_proc_start_date );
690: fetch c_get_wac into l_wac, l_effective_date;
691: if c_get_wac%NOTFOUND then
692: close c_get_wac;
693: hr_utility.set_location('Error : Assignment doesnot exist at the pay proc start date'||l_proc,10);
694: return 1; /* Bug#2858065 */
695: end if;
696: close c_get_wac;
697: /* store the wac at the start of the period */
704: if (l_effective_date < p_pay_proc_start_date) then
705: start_date := p_pay_proc_start_date;
706: end if;
707:
708: hr_utility.trace('start_wac : '||start_wac);
709: hr_utility.trace('start_date : '||start_date);
710:
711: /* Get the WAC and at the period end date*/
712:
705: start_date := p_pay_proc_start_date;
706: end if;
707:
708: hr_utility.trace('start_wac : '||start_wac);
709: hr_utility.trace('start_date : '||start_date);
710:
711: /* Get the WAC and at the period end date*/
712:
713: open c_get_wac( p_assignment_id,l_proc_end_date);
713: open c_get_wac( p_assignment_id,l_proc_end_date);
714: fetch c_get_wac into l_wac, l_effective_date;
715: if c_get_wac%NOTFOUND then
716: close c_get_wac;
717: hr_utility.set_location('Error : Assignment doesnot exist at the pay proc end date (ie terminated)'||l_proc,20);
718: return 1; /* Bug#2873083 */
719: end if;
720: close c_get_wac;
721:
730: if (l_effective_date < p_pay_proc_start_date ) then
731: prorate_date := p_pay_proc_start_date;
732: end if;
733:
734: hr_utility.trace('prorate_wac : '||prorate_wac);
735: hr_utility.trace('prorate_date : '||prorate_date);
736:
737: open c_get_pro_formula_id ('CPF_CAL_METHOD', l_proc_start_date);
738: fetch c_get_pro_formula_id into l_pro_formula_id;
731: prorate_date := p_pay_proc_start_date;
732: end if;
733:
734: hr_utility.trace('prorate_wac : '||prorate_wac);
735: hr_utility.trace('prorate_date : '||prorate_date);
736:
737: open c_get_pro_formula_id ('CPF_CAL_METHOD', l_proc_start_date);
738: fetch c_get_pro_formula_id into l_pro_formula_id;
739: if c_get_pro_formula_id%NOTFOUND then
736:
737: open c_get_pro_formula_id ('CPF_CAL_METHOD', l_proc_start_date);
738: fetch c_get_pro_formula_id into l_pro_formula_id;
739: if c_get_pro_formula_id%NOTFOUND then
740: hr_utility.set_location('Error : CPF_CAL_METHOD formula doesnot exist'||l_proc,30);
741: end if;
742: close c_get_pro_formula_id;
743:
744: if (p_date_earned <> start_date ) then
742: close c_get_pro_formula_id;
743:
744: if (p_date_earned <> start_date ) then
745:
746: hr_utility.trace('l_proc_start_date:'||to_char(l_proc_start_date,'YYYY/MM/DD'));
747:
748: if p_cpf_pro_method = 'C' then
749: l_total_days := fffunc.days_between(p_pay_proc_end_date , p_pay_proc_start_date)+1;
750: elsif p_cpf_pro_method = 'WC' then
767: --Bug# 4149190
768: --p_pay_proc_start_date, p_pay_proc_end_date are replaced by l_proc_start_date,
769: --l_proc_end_date respectively.
770: -------------------------------------------------------------------------------------------------
771: hr_utility.trace('l_total_days : '||l_total_days );
772: end if;
773:
774: /* Proration Calculation Block */
775: /* If the employee start date or end date is in between the pay period then
802: l_pro_check := 'Y';
803: l_proc_start_date := start_date;
804: l_proc_end_date := prorate_date-1;
805: p_cpf_calc_type := start_wac;
806: hr_utility.trace('p_cpf_calc_type :'||p_cpf_calc_type);
807:
808: elsif ((start_wac = 'WP' or start_wac = 'EP' or start_wac = 'SP') and (prorate_wac = 'PR' or prorate_wac = 'SG')) then
809: /* Need to calculate the proration for the second period and first period does not have
810: eligible for the CPF Proration */
810: eligible for the CPF Proration */
811: l_pro_check := 'Y';
812: l_proc_start_date := prorate_date;
813: p_cpf_calc_type := prorate_wac;
814: hr_utility.trace('p_cpf_calc_type :'||p_cpf_calc_type);
815:
816: elsif ((start_wac = 'SG' or start_wac = 'PR') and (prorate_wac = 'SG' or prorate_wac = 'PR')) then
817: /* Need not calculate the CPF Calculation. Hence setting the l_prorator value to 1 and the
818: CPF Calcualtion type to prorate type */
864:
865:
866: end if;
867: /* End of Proration Calculation */
868: hr_utility.trace('p_cpf_calc_type :'||p_cpf_calc_type);
869: hr_utility.trace('l_prorator : '||l_prorator);
870: hr_utility.set_location('Leaving : '||l_proc, 5);
871:
872: return l_prorator;
865:
866: end if;
867: /* End of Proration Calculation */
868: hr_utility.trace('p_cpf_calc_type :'||p_cpf_calc_type);
869: hr_utility.trace('l_prorator : '||l_prorator);
870: hr_utility.set_location('Leaving : '||l_proc, 5);
871:
872: return l_prorator;
873: end sg_get_prorator;
866: end if;
867: /* End of Proration Calculation */
868: hr_utility.trace('p_cpf_calc_type :'||p_cpf_calc_type);
869: hr_utility.trace('l_prorator : '||l_prorator);
870: hr_utility.set_location('Leaving : '||l_proc, 5);
871:
872: return l_prorator;
873: end sg_get_prorator;
874:
1049: l_balance_name pay_balance_types.balance_name%TYPE;
1050:
1051: begin
1052: l_earnings_type := ' ';
1053: hr_utility.set_location('Entering Earnings Type : ', 5);
1054: hr_utility.set_location('Element Type Id : ' || p_element_type_id, 10);
1055:
1056: l_balance_name := 'CPF Ordinary Earnings Eligible Comp';
1057: open c_earnings_type(p_element_type_id, l_balance_name);
1050:
1051: begin
1052: l_earnings_type := ' ';
1053: hr_utility.set_location('Entering Earnings Type : ', 5);
1054: hr_utility.set_location('Element Type Id : ' || p_element_type_id, 10);
1055:
1056: l_balance_name := 'CPF Ordinary Earnings Eligible Comp';
1057: open c_earnings_type(p_element_type_id, l_balance_name);
1058: fetch c_earnings_type into l_earnings_type;
1064: fetch c_earnings_type into l_earnings_type;
1065: close c_earnings_type;
1066: end if;
1067:
1068: hr_utility.set_location('Earnings Type : ' || l_earnings_type, 15);
1069:
1070: return l_earnings_type;
1071:
1072: EXCEPTION
1071:
1072: EXCEPTION
1073: when others then
1074: l_earnings_type := ' ';
1075: hr_utility.set_location('Exception Earnings Type : ', 20);
1076:
1077: end earnings_type;
1078: ---------------------------------------------------------------------------
1079: -- Function returns Previous Year Ordinary Earnings total with
1279: end loop;
1280: --
1281: close c_month_year_action_sequence;
1282: --
1283: hr_utility.trace('l_prev_ord_ytd : '||l_prev_ord_ytd);
1284: return l_prev_ord_ytd;
1285: --
1286: end get_prev_year_ord_ytd;
1287:
1488: end loop;
1489: --
1490: close c_month_year_action_sequence;
1491: --
1492: hr_utility.trace('l_cur_ord_ytd: '||l_cur_ord_ytd);
1493: return l_cur_ord_ytd;
1494: --
1495: end get_cur_year_ord_ytd;
1496: --
1562: l_effective_date := to_date('1-10-2003','dd-mm-yyyy');
1563: l_start_date := to_date('1-10-2003','dd-mm-yyyy');
1564:
1565: /* This function call returns -1 if the formula was not found */
1566: hr_utility.set_location('Starting init',5);
1567: hr_utility.trace('Formula_id:'||l_formula_id);
1568:
1569: open c_formula_id(p_formula_name, p_effective_date);
1570: fetch c_formula_id into l_formula_id, l_start_date;
1563: l_start_date := to_date('1-10-2003','dd-mm-yyyy');
1564:
1565: /* This function call returns -1 if the formula was not found */
1566: hr_utility.set_location('Starting init',5);
1567: hr_utility.trace('Formula_id:'||l_formula_id);
1568:
1569: open c_formula_id(p_formula_name, p_effective_date);
1570: fetch c_formula_id into l_formula_id, l_start_date;
1571: if c_formula_id%NOTFOUND then
1571: if c_formula_id%NOTFOUND then
1572: close c_formula_id;
1573: else
1574:
1575: hr_utility.trace('Formula_id:'||l_formula_id);
1576: ff_exec.init_formula (l_formula_id,
1577: l_start_date,
1578: g_inputs,
1579: g_outputs);
1578: g_inputs,
1579: g_outputs);
1580: end if;
1581: --
1582: hr_utility.set_location('Leaving init',10);
1583:
1584: End init_formula;
1585:
1586: Function calc_cpf_add_YTD (p_date_earned in date
1597: l_cpf_add_YTD number;
1598:
1599: Begin
1600: --
1601: hr_utility.set_location('Entering get_bal',7);
1602: --
1603: init_formula('SG_STAT',p_date_earned);
1604: --
1605: -- Set up contexts for the formula
1606: for i in g_inputs.first..g_inputs.last loop
1607: --
1608:
1609: if g_inputs(i).name = 'DATE_EARNED' then
1610: hr_utility.trace('setting date earned '||p_date_earned);
1611: g_inputs(i).value := fnd_date.date_to_canonical(p_date_earned);
1612: elsif g_inputs(i).name = 'ASSIGNMENT_ID' then
1613: g_inputs(i).value := p_assignment_id;
1614: elsif g_inputs(i).name = 'SOURCE_TEXT' then
1611: g_inputs(i).value := fnd_date.date_to_canonical(p_date_earned);
1612: elsif g_inputs(i).name = 'ASSIGNMENT_ID' then
1613: g_inputs(i).value := p_assignment_id;
1614: elsif g_inputs(i).name = 'SOURCE_TEXT' then
1615: hr_utility.trace('setting source text '||p_process_type);
1616: g_inputs(i).value := p_process_type;
1617: elsif g_inputs(i).name = 'PROCESS_TYPE' then
1618: g_inputs(i).value := p_process_type;
1619: elsif g_inputs(i).name = 'TAX_UNIT_ID' then
1628: g_inputs(i).value := p_payroll_id;
1629: elsif g_inputs(i).name = 'BALANCE_DATE' then
1630: g_inputs(i).value := fnd_date.date_to_canonical(p_balance_date);
1631: else
1632: hr_utility.set_location('ERROR value = '||g_inputs(i).name ,7);
1633: end if;
1634: --
1635: hr_utility.trace('g_inputs(i).name : '||g_inputs(i).name);
1636: hr_utility.trace('g_inputs(i).value : '||g_inputs(i).value);
1631: else
1632: hr_utility.set_location('ERROR value = '||g_inputs(i).name ,7);
1633: end if;
1634: --
1635: hr_utility.trace('g_inputs(i).name : '||g_inputs(i).name);
1636: hr_utility.trace('g_inputs(i).value : '||g_inputs(i).value);
1637: end loop;
1638: --
1639: -- Run the formula
1632: hr_utility.set_location('ERROR value = '||g_inputs(i).name ,7);
1633: end if;
1634: --
1635: hr_utility.trace('g_inputs(i).name : '||g_inputs(i).name);
1636: hr_utility.trace('g_inputs(i).value : '||g_inputs(i).value);
1637: end loop;
1638: --
1639: -- Run the formula
1640: --
1637: end loop;
1638: --
1639: -- Run the formula
1640: --
1641: hr_utility.set_location('Prior to execute the formula',8);
1642: ff_exec.run_formula (g_inputs ,
1643: g_outputs );
1644: --
1645: hr_utility.set_location('End run formula',9);
1641: hr_utility.set_location('Prior to execute the formula',8);
1642: ff_exec.run_formula (g_inputs ,
1643: g_outputs );
1644: --
1645: hr_utility.set_location('End run formula',9);
1646: --
1647: for l_out_cnt in g_outputs.first..g_outputs.last loop
1648: -- only store the output of L_CPF_ADD_CALC_YEAR , ignoe others
1649: if g_outputs(l_out_cnt).name = 'L_CPF_ADD_CALC_YEAR' then
1647: for l_out_cnt in g_outputs.first..g_outputs.last loop
1648: -- only store the output of L_CPF_ADD_CALC_YEAR , ignoe others
1649: if g_outputs(l_out_cnt).name = 'L_CPF_ADD_CALC_YEAR' then
1650: l_cpf_add_YTD := g_outputs(l_out_cnt).value;
1651: hr_utility.trace('l_cpf_add_YTD:'|| g_outputs(l_out_cnt).value);
1652: end if;
1653: --
1654: hr_utility.trace('Outputs:'||g_outputs(l_out_cnt).name);
1655: hr_utility.trace('Outputs(values):'||g_outputs(l_out_cnt).value);
1650: l_cpf_add_YTD := g_outputs(l_out_cnt).value;
1651: hr_utility.trace('l_cpf_add_YTD:'|| g_outputs(l_out_cnt).value);
1652: end if;
1653: --
1654: hr_utility.trace('Outputs:'||g_outputs(l_out_cnt).name);
1655: hr_utility.trace('Outputs(values):'||g_outputs(l_out_cnt).value);
1656: end loop;
1657: --
1658: return l_cpf_add_YTD;
1651: hr_utility.trace('l_cpf_add_YTD:'|| g_outputs(l_out_cnt).value);
1652: end if;
1653: --
1654: hr_utility.trace('Outputs:'||g_outputs(l_out_cnt).name);
1655: hr_utility.trace('Outputs(values):'||g_outputs(l_out_cnt).value);
1656: end loop;
1657: --
1658: return l_cpf_add_YTD;
1659: --