[Home] [Help]
PACKAGE BODY: APPS.PER_GB_TERMINATION
Source
1 package body PER_GB_TERMINATION as
2 /* $Header: pergbtem.pkb 120.1 2006/10/26 10:58:50 kthampan noship $ */
3 /*
4 **
5 ** Copyright (C) 1999 Oracle Corporation
6 ** All Rights Reserved
7 **
8 ** GB Termination package
9 **
10 ** Change List
11 ** ===========
12 **
13 ** Date Author Version Reference Description
14 ** ----------+----------+-------+---------+------------------------------------
15 ** 16-MAY-05 K.Thampan 115.0 4351635 Added SSP/SMP recalculation when
16 ** reverse termination.
17 ** 17-MAY-05 K.Thampan 115.1 Added ssp_smp_support_pkg.
18 ** recalculate_ssp_and_smp method
19 ** 24-OCT-06 K.Thampan 115.2 Added validation for P45
20 -------------------------------------------------------------------------------
21 */
22 -- Gets Person_id for given period_of_service_id
23
24 CURSOR c_get_person_id (c_period_of_service_id per_periods_of_service.period_of_service_id%Type) is
25 select ppos.person_id
26 from per_periods_of_service ppos
27 where period_of_service_id = c_period_of_service_id;
28
29 PROCEDURE actual_termination(
30 p_period_of_service_id per_periods_of_service.period_of_service_id%TYPE,
31 p_actual_termination_date per_periods_of_service.actual_termination_date%TYPE)
32 IS
33 BEGIN
34 -- doing no processing here
35 hr_utility.set_location('Entering per_gb_termination.actual_termination',10);
36 hr_utility.set_location('Leaving pay_gb_termination.actual_termination',100);
37 EXCEPTION
38 WHEN OTHERS
39 THEN
40 raise_application_error(-20001, SQLERRM(SQLCODE) );
41 END actual_termination;
42
43 PROCEDURE Final_termination( p_period_of_service_id per_periods_of_service.period_of_service_id%TYPE
44 ,p_final_process_date Date)
45 IS
46 BEGIN
47 -- doing no processing here
48 hr_utility.set_location('Entering per_gb_termination.final_termination',10);
49 hr_utility.set_location('Leaving pay_gb_termination.final_termination',100);
50 EXCEPTION
51 WHEN OTHERS
52 THEN
53 raise_application_error(-20001, SQLERRM(SQLCODE) );
54 END Final_termination;
55
56 PROCEDURE REVERSE(
57 p_period_of_service_id per_periods_of_service.period_of_service_id%TYPE,
58 p_actual_termination_date per_periods_of_service.actual_termination_date%TYPE,
59 p_leaving_reason per_periods_of_service.leaving_reason%TYPE)
60 IS
61 l_person_id per_periods_of_service.person_id%TYPE;
62 l_date_of_birth DATE;
63 l_token varchar2(255);
64 l_count number;
65
66 CURSOR c_date_of_birth(p_person_id Number)
67 IS
68 SELECT date_of_birth
69 FROM per_all_people_f
70 WHERE person_id = p_person_id
71 AND p_actual_termination_date between effective_start_date and effective_end_date;
72
73 CURSOR c_assignment_id(p_person_id number,
74 p_date_active date)
75 IS
76 SELECT assignment_id, assignment_number
77 FROM per_all_assignments_f asg,
78 per_assignment_status_types typ
79 WHERE asg.person_id = p_person_id
80 AND asg.period_of_service_id = p_period_of_service_id
81 AND asg.assignment_status_type_id = typ.assignment_status_type_id
82 AND typ.per_system_status in ('ACTIVE_ASSIGN', 'SUSP_ASSIGN')
83 AND p_date_active between asg.effective_start_date and asg.effective_end_date
84 ORDER BY assignment_id;
85 --
86 BEGIN
87 hr_utility.set_location('Entering per_gb_termination.reverse',10);
88
89 if hr_general.g_data_migrator_mode <> 'Y' then
90 OPEN c_get_person_id (p_period_of_service_id);
91 FETCH c_get_person_id into l_person_id;
92 CLOSE c_get_person_id;
93
94 if ssp_ssp_pkg.ssp_is_installed then
95 --
96 hr_utility.set_location('Checking SSP/SMP Details',20);
97 --
98 OPEN c_date_of_birth(l_person_id);
99 FETCH c_date_of_birth into l_date_of_birth;
100 CLOSE c_date_of_birth;
101
102 ssp_smp_pkg.person_control ( l_person_id, p_actual_termination_date);
103 ssp_ssp_pkg.person_control ( l_Person_id, p_actual_termination_date, l_date_of_birth);
104
105 end if;
106 ssp_smp_support_pkg.recalculate_ssp_and_smp;
107 --
108 hr_utility.set_location('Checking for P45 Details',20);
109 --
110 l_count := 0;
111 for assignment in c_assignment_id(l_person_id,p_actual_termination_date)
112 loop
113 if pay_p45_pkg.return_p45_issued_flag(assignment.assignment_id) = 'Y' then
114 l_count := l_count + 1;
115 l_token := l_token || ', ' || assignment.assignment_number;
116 end if;
117 end loop;
118 if l_count > 0 then
119 l_token := substr(l_token,3);
120 if l_count > 1 then
121 l_token := substr(l_token,1, instr(l_token,',',-1,1) -1) || ' and ' ||
122 substr(l_token,instr(l_token,',',-1,1) + 2);
123 end if;
124 fnd_message.set_name ('PER', 'HR_GB_78089_P45_ISSUED');
125 fnd_message.set_token ('ASG_NUM',l_token);
126 fnd_message.raise_error;
127 end if;
128 --
129 end if;
130 hr_utility.set_location('Leaving pay_gb_termination.reverse',100);
131 END REVERSE;
132 END per_gb_termination;