DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_JP_YEA_BAL_ADJ_PKG

Source


1 PACKAGE BODY PAY_JP_YEA_BAL_ADJ_PKG AS
2 /* $Header: pyjpyeba.pkb 120.0 2006/02/26 17:03 hikubo noship $ */
3 --
4 type number_t is table of number       index by binary_integer;
5 type text_t   is table of varchar2(60) index by binary_integer;
6 type date_t   is table of date         index by binary_integer;
7 --
8 g_number_value number_t;
9 g_text_value   text_t;
10 g_date_value   date_t;
11 --
12 FUNCTION get_formula_name
13 (
14 	p_business_group_id in varchar2,
15 	p_payroll_id        in varchar2,
16 	p_effective_date    in varchar2
17 ) RETURN varchar2 IS
18 	--
19 	l_pay_formula_id    ff_formulas_f.formula_id%type;
20 	l_org_formula_id    ff_formulas_f.formula_id%type;
21 	--
22 	l_formula_name      ff_formulas_f_tl.formula_name%type;
23 	--
24 	cursor c_org_formula is
25 		select fnd_number.canonical_to_number(org_information5)
26 		from hr_organization_information
27 		where organization_id = fnd_number.canonical_to_number(p_business_group_id)
28 		and org_information_context = 'JP_BUSINESS_GROUP_INFO';
29 	--
30 	cursor c_pay_formula is
31 		select fnd_number.canonical_to_number(prl_information4)
32 		from pay_all_payrolls_f
33 		where payroll_id = fnd_number.canonical_to_number(p_payroll_id)
34 		and fnd_date.canonical_to_date(p_effective_date)
35 			between effective_start_date and effective_end_date;
36 	--
37 	cursor c_formula is
38 		select fft.formula_name
39 		from ff_formulas_f ff, ff_formulas_f_tl fft
40 		where ff.formula_id = nvl(l_pay_formula_id, l_org_formula_id)
41 		and fnd_date.canonical_to_date(p_effective_date)
42 			between ff.effective_start_date and ff.effective_end_date
43 		and fft.formula_id = ff.formula_id
44 		and fft.language = userenv('LANG');
45 	--
46 BEGIN
47 	--
48 	l_pay_formula_id := null;
49 	l_org_formula_id := null;
50 	l_formula_name   := null;
51 	--
52 	open c_org_formula;
53 	fetch c_org_formula into l_org_formula_id;
54 	close c_org_formula;
55 	--
56 	open c_pay_formula;
57 	fetch c_pay_formula into l_pay_formula_id;
58 	close c_pay_formula;
59 	--
60 	if l_org_formula_id is not null or l_pay_formula_id is not null then
61 		--
62 		open c_formula;
63 		fetch c_formula into l_formula_name;
64 		close c_formula;
65 		--
66 	end if;
67 	--
68 	return l_formula_name;
69 	--
70 END;
71 
72 FUNCTION call_formula
73 (
74 	p_business_group_id    in number,
75 	p_payroll_id           in number,
76 	p_payroll_action_id    in number,
77 	p_assignment_id        in number,
78 	p_assignment_action_id in number,
79 	p_date_earned          in date,
80 	p_element_entry_id     in number,
81 	p_element_type_id      in number
82 ) RETURN number IS
83 	--
84 	l_formula_id number;
85 	--
86 	l_inputs     ff_exec.inputs_t;
87 	l_outputs    ff_exec.outputs_t;
88 	--
89 BEGIN
90 	--
91 	select to_number(pay_core_utils.get_parameter('FORMULA_ID', legislative_parameters))
92 	into l_formula_id
93 	from pay_payroll_actions
94 	where payroll_action_id = p_payroll_action_id;
95 	--
96 	if l_formula_id is not null then
97 		--
98 		ff_exec.init_formula
99 		(
100 			p_formula_id     => l_formula_id,
101 			p_effective_date => p_date_earned,
102 			p_inputs         => l_inputs,
103 			p_outputs        => l_outputs
104 		);
105 		--
106 		for i in 1 .. l_inputs.count loop
107 			--
108 			if l_inputs(i).class = 'CONTEXT' then
109 				--
110 				if l_inputs(i).datatype = 'NUMBER' then
111 					--
112 					if    l_inputs(i).name = 'BUSINESS_GROUP_ID' then
113 						l_inputs(i).value := fnd_number.canonical_to_number(p_business_group_id);
114 					elsif l_inputs(i).name = 'PAYROLL_ID' then
115 						l_inputs(i).value := fnd_number.canonical_to_number(p_payroll_id);
116 					elsif l_inputs(i).name = 'PAYROLL_ACTION_ID' then
117 						l_inputs(i).value := fnd_number.canonical_to_number(p_payroll_action_id);
118 					elsif l_inputs(i).name = 'ASSIGNMENT_ID' then
119 						l_inputs(i).value := fnd_number.canonical_to_number(p_assignment_id);
120 					elsif l_inputs(i).name = 'ASSIGNMENT_ACTION_ID' then
121 						l_inputs(i).value := fnd_number.canonical_to_number(p_assignment_action_id);
122 					elsif l_inputs(i).name = 'ELEMENT_ENTRY_ID' then
123 						l_inputs(i).value := fnd_number.canonical_to_number(p_element_entry_id);
124 					elsif l_inputs(i).name = 'ELEMENT_TYPE_ID' then
125 						l_inputs(i).value := fnd_number.canonical_to_number(p_element_type_id);
126 					end if;
127 					--
128 				elsif l_inputs(i).datatype = 'DATE' and l_inputs(i).name = 'DATE_EARNED' then
129 					--
130 					l_inputs(i).value := fnd_date.date_to_canonical(p_date_earned);
131 					--
132 				end if;
133 				--
134 			end if;
135 			--
136 		end loop;
137 		--
138 		ff_exec.run_formula
139 		(
140 			p_inputs  => l_inputs,
141 			p_outputs => l_outputs
142 		);
143 		--
144 		for i in 1 .. l_outputs.count loop
145 			--
146 			if l_outputs(i).datatype = 'NUMBER' then
147 				--
148 				if    l_outputs(i).name = 'L_NUM1'  then
149 					g_number_value(1)  := fnd_number.canonical_to_number(l_outputs(i).value);
150 				elsif l_outputs(i).name = 'L_NUM2'  then
151 					g_number_value(2)  := fnd_number.canonical_to_number(l_outputs(i).value);
152 				elsif l_outputs(i).name = 'L_NUM3'  then
153 					g_number_value(3)  := fnd_number.canonical_to_number(l_outputs(i).value);
154 				elsif l_outputs(i).name = 'L_NUM4'  then
155 					g_number_value(4)  := fnd_number.canonical_to_number(l_outputs(i).value);
156 				elsif l_outputs(i).name = 'L_NUM5'  then
157 					g_number_value(5)  := fnd_number.canonical_to_number(l_outputs(i).value);
158 				elsif l_outputs(i).name = 'L_NUM6'  then
159 					g_number_value(6)  := fnd_number.canonical_to_number(l_outputs(i).value);
160 				elsif l_outputs(i).name = 'L_NUM7'  then
161 					g_number_value(7)  := fnd_number.canonical_to_number(l_outputs(i).value);
162 				elsif l_outputs(i).name = 'L_NUM8'  then
163 					g_number_value(8)  := fnd_number.canonical_to_number(l_outputs(i).value);
164 				elsif l_outputs(i).name = 'L_NUM9'  then
165 					g_number_value(9)  := fnd_number.canonical_to_number(l_outputs(i).value);
166 				elsif l_outputs(i).name = 'L_NUM10' then
167 					g_number_value(10) := fnd_number.canonical_to_number(l_outputs(i).value);
168 				end if;
169 				--
170 			elsif l_outputs(i).datatype = 'TEXT' then
171 				--
172 				if    l_outputs(i).name = 'L_TEXT1'  then
173 					g_text_value(1)  := l_outputs(i).value;
174 				elsif l_outputs(i).name = 'L_TEXT2'  then
175 					g_text_value(2)  := l_outputs(i).value;
176 				elsif l_outputs(i).name = 'L_TEXT3'  then
177 					g_text_value(3)  := l_outputs(i).value;
178 				elsif l_outputs(i).name = 'L_TEXT4'  then
179 					g_text_value(4)  := l_outputs(i).value;
180 				elsif l_outputs(i).name = 'L_TEXT5'  then
181 					g_text_value(5)  := l_outputs(i).value;
182 				elsif l_outputs(i).name = 'L_TEXT6'  then
183 					g_text_value(6)  := l_outputs(i).value;
184 				elsif l_outputs(i).name = 'L_TEXT7'  then
185 					g_text_value(7)  := l_outputs(i).value;
186 				elsif l_outputs(i).name = 'L_TEXT8'  then
187 					g_text_value(8)  := l_outputs(i).value;
188 				elsif l_outputs(i).name = 'L_TEXT9'  then
189 					g_text_value(9)  := l_outputs(i).value;
190 				elsif l_outputs(i).name = 'L_TEXT10' then
191 					g_text_value(10) := l_outputs(i).value;
192 				end if;
193 				--
194 			elsif l_outputs(i).datatype = 'DATE' then
195 				--
196 				if    l_outputs(i).name = 'L_DATE1'  then
197 					g_date_value(1)  := fnd_date.canonical_to_date(l_outputs(i).value);
198 				elsif l_outputs(i).name = 'L_DATE2'  then
199 					g_date_value(2)  := fnd_date.canonical_to_date(l_outputs(i).value);
200 				elsif l_outputs(i).name = 'L_DATE3'  then
201 					g_date_value(3)  := fnd_date.canonical_to_date(l_outputs(i).value);
202 				elsif l_outputs(i).name = 'L_DATE4'  then
203 					g_date_value(4)  := fnd_date.canonical_to_date(l_outputs(i).value);
204 				elsif l_outputs(i).name = 'L_DATE5'  then
205 					g_date_value(5)  := fnd_date.canonical_to_date(l_outputs(i).value);
206 				elsif l_outputs(i).name = 'L_DATE6'  then
207 					g_date_value(6)  := fnd_date.canonical_to_date(l_outputs(i).value);
208 				elsif l_outputs(i).name = 'L_DATE7'  then
209 					g_date_value(7)  := fnd_date.canonical_to_date(l_outputs(i).value);
210 				elsif l_outputs(i).name = 'L_DATE8'  then
211 					g_date_value(8)  := fnd_date.canonical_to_date(l_outputs(i).value);
212 				elsif l_outputs(i).name = 'L_DATE9'  then
213 					g_date_value(9)  := fnd_date.canonical_to_date(l_outputs(i).value);
214 				elsif l_outputs(i).name = 'L_DATE10' then
215 					g_date_value(10) := fnd_date.canonical_to_date(l_outputs(i).value);
216 				end if;
217 				--
218 			end if;
219 			--
220 		end loop;
221 		--
222 	end if;
223 	--
224 	return 0;
225 	--
226 END;
227 
228 FUNCTION get_number_value(p_number in number) RETURN number IS
229 BEGIN
230 	return g_number_value(p_number);
231 END;
232 --
233 FUNCTION get_text_value(p_number in number) RETURN varchar2 IS
234 BEGIN
235 	return g_text_value(p_number);
236 END;
237 --
238 FUNCTION get_date_value(p_number in number) RETURN date IS
239 BEGIN
240 	return g_date_value(p_number);
241 END;
242 
243 BEGIN
244 	--
245 	for i in 1 .. 10 loop
246 		--
247 		g_number_value(i) := null;
248 		g_text_value(i)   := null;
249 		g_date_value(i)   := null;
250 		--
251 	end loop;
252 	--
253 END PAY_JP_YEA_BAL_ADJ_PKG;