[Home] [Help]
PACKAGE BODY: APPS.PAY_IN_RULES
Source
1 PACKAGE BODY pay_in_rules AS
2 /* $Header: pyinrule.pkb 120.9 2008/02/26 06:46:52 pannapur noship $ */
3
4 g_package CONSTANT VARCHAR2(100) := 'pay_in_rules.';
5 g_debug BOOLEAN;
6
7 PROCEDURE get_default_run_type(p_asg_id IN NUMBER,
8 p_ee_id IN NUMBER,
9 p_effdate IN DATE,
10 p_run_type OUT NOCOPY VARCHAR2)
11 IS
12 CURSOR c_run_type_id
13 IS
14 SELECT run_type_id
15 FROM pay_run_types_f
16 WHERE run_type_name = 'Cumulative Run'
17 AND legislation_code='IN'
18 AND p_effdate BETWEEN effective_start_date
19 AND effective_end_date;
20
21 l_run_type_id NUMBER;
22 l_procedure VARCHAR(100);
23 l_message VARCHAR2(250);
24
25 BEGIN
26 l_procedure := g_package||'get_default_run_type';
27 pay_in_utils.set_location(g_debug,'Entering: '||l_procedure,10);
28
29 IF g_debug THEN
30 pay_in_utils.trace ('**************************************************','********************');
31 pay_in_utils.trace ('p_asg_id',p_asg_id);
32 pay_in_utils.trace ('p_ee_id',p_ee_id);
33 pay_in_utils.trace ('p_effdate',p_effdate);
34 pay_in_utils.trace ('**************************************************','********************');
35 END IF;
36
37 OPEN c_run_type_id;
38 FETCH c_run_type_id INTO l_run_type_id;
39 CLOSE c_run_type_id;
40 p_run_type := to_char(l_run_type_id);
41
42 IF g_debug THEN
43 pay_in_utils.trace ('**************************************************','********************');
44 pay_in_utils.trace ('p_run_type',p_run_type);
45 pay_in_utils.trace ('**************************************************','********************');
46 END IF;
47 pay_in_utils.set_location(g_debug,'Leaving: '||l_procedure,20);
48
49 END get_default_run_type;
50
51
52
53
54
55 PROCEDURE get_source_context(p_asg_act_id IN NUMBER,
56 p_ee_id IN NUMBER,
57 p_source_id IN OUT NOCOPY VARCHAR2)
58 IS
59
60 l_element_name VARCHAR2(240);
61 l_procedure VARCHAR(100);
62 l_message VARCHAR2(250);
63
64 --
65 -- Cursor for fetching the Element Name
66 CURSOR csr_element_name IS
67 SELECT pet.element_name
68 FROM pay_element_entries_f pee
69 ,pay_element_types_f pet
70 WHERE pet.element_type_id = pee.element_type_id
71 AND pee.element_entry_id = p_ee_id;
72 --
73 --Cursor for fetching PF Org Id
74 CURSOR csr_get_pf_source IS
75 SELECT hsc.segment2
76 FROM pay_element_entries_f target
77 ,pay_assignment_actions paa
78 ,pay_payroll_actions ppa
79 ,per_assignments_f paf
80 ,hr_soft_coding_keyflex hsc
81 WHERE ppa.payroll_action_id = paa.payroll_action_id
82 AND target.element_entry_id = p_ee_id
83 AND target.assignment_id = paa.assignment_id
84 AND paa.assignment_action_id = p_asg_act_id
85 AND paf.assignment_id = paa.assignment_id
86 AND paf.soft_coding_keyflex_id = hsc.soft_coding_keyflex_id
87 AND ppa.effective_date BETWEEN target.effective_start_date
88 AND target.effective_end_date
89 AND ppa.effective_date BETWEEN paf.effective_start_date
90 AND paf.effective_end_date;
91 --
92 --Cursor for fetching PT Org Id
93 CURSOR csr_get_pt_source is
94 SELECT hsc.segment3
95 FROM pay_element_entries_f target
96 ,pay_assignment_actions paa
97 ,pay_payroll_actions ppa
98 ,per_assignments_f paf
99 ,hr_soft_coding_keyflex hsc
100 WHERE ppa.payroll_action_id = paa.payroll_action_id
101 AND target.element_entry_id = p_ee_id
102 AND target.assignment_id = paa.assignment_id
103 AND paa.assignment_action_id = p_asg_act_id
104 AND paf.assignment_id = paa.assignment_id
105 AND paf.soft_coding_keyflex_id = hsc.soft_coding_keyflex_id
106 AND ppa.effective_date BETWEEN target.effective_start_date
107 AND target.effective_end_date
108 AND ppa.effective_date BETWEEN paf.effective_start_date
109 AND paf.effective_end_date;
110 --
111 --Cursor for fetching ESI Org Id
112 CURSOR csr_get_esi_source IS
113 SELECT hsc.segment4
114 FROM pay_element_entries_f target
115 ,pay_assignment_actions paa
116 ,pay_payroll_actions ppa
117 ,per_assignments_f paf
118 ,hr_soft_coding_keyflex hsc
119 WHERE ppa.payroll_action_id = paa.payroll_action_id
120 AND target.element_entry_id = p_ee_id
121 AND target.assignment_id = paa.assignment_id
122 AND paa.assignment_action_id = p_asg_act_id
123 AND paf.assignment_id = paa.assignment_id
124 AND paf.soft_coding_keyflex_id = hsc.soft_coding_keyflex_id
125 AND ppa.effective_date BETWEEN target.effective_start_date
126 AND target.effective_end_date
127 AND ppa.effective_date BETWEEN paf.effective_start_date
128 AND paf.effective_end_date;
129
130 --Cursor for fetching fact/Establishment Org Id
131 CURSOR csr_get_lwf_org is
132 SELECT nvl(hsc.segment6,hsc.segment5)
133 FROM pay_element_entries_f target
134 ,pay_assignment_actions paa
135 ,pay_payroll_actions ppa
136 ,per_assignments_f paf
137 ,hr_soft_coding_keyflex hsc
138 WHERE ppa.payroll_action_id = paa.payroll_action_id
139 AND target.element_entry_id = p_ee_id
140 AND target.assignment_id = paa.assignment_id
141 AND paa.assignment_action_id = p_asg_act_id
142 AND paf.assignment_id = paa.assignment_id
143 AND paf.soft_coding_keyflex_id = hsc.soft_coding_keyflex_id
144 AND ppa.effective_date BETWEEN target.effective_start_date
145 AND target.effective_end_date
146 AND ppa.effective_date BETWEEN paf.effective_start_date
147 AND paf.effective_end_date;
148 BEGIN
149 --
150 l_procedure := g_package||'get_source_context';
151 pay_in_utils.set_location(g_debug,'Entering: '||l_procedure,10);
152
153 IF g_debug THEN
154 pay_in_utils.trace ('**************************************************','********************');
155 pay_in_utils.trace ('p_asg_act_id',p_asg_act_id);
156 pay_in_utils.trace ('p_ee_id',p_ee_id);
157 pay_in_utils.trace ('**************************************************','********************');
158 END IF;
159
160 OPEN csr_element_name;
161 FETCH csr_element_name INTO l_element_name;
162 CLOSE csr_element_name;
163 --
164 pay_in_utils.trace('l_element_name ',l_element_name);
165 pay_in_utils.set_location(g_debug,l_procedure,20);
166
167 IF l_element_name = 'PF Information' THEN
168 OPEN csr_get_pf_source;
169 FETCH csr_get_pf_source INTO p_source_id;
170 p_source_id := nvl(p_source_id, '-1');
171 CLOSE csr_get_pf_source;
172 END IF;
173 --
174 IF l_element_name = 'Professional Tax Information' THEN
175 OPEN csr_get_pt_source;
176 FETCH csr_get_pt_source into p_source_id;
177 p_source_id := nvl(p_source_id, '-1');
178 CLOSE csr_get_pt_source;
179 END IF;
180 --
181 IF l_element_name = 'ESI Information' THEN
182 OPEN csr_get_esi_source;
183 FETCH csr_get_esi_source into p_source_id;
184 p_source_id := nvl(p_source_id, '-1');
185 CLOSE csr_get_esi_source;
186 END IF;
187 --
188 IF l_element_name = 'LWF Information' THEN
189 OPEN csr_get_lwf_org;
190 FETCH csr_get_lwf_org into p_source_id;
191 p_source_id := nvl(p_source_id, '-1');
192 CLOSE csr_get_lwf_org;
193 END IF;
194 IF g_debug THEN
195 pay_in_utils.trace ('**************************************************','********************');
196 pay_in_utils.trace ('p_source_id',p_source_id);
197 pay_in_utils.trace ('**************************************************','********************');
198 END IF;
199
200 pay_in_utils.set_location(g_debug,'Leaving: '||l_procedure,30);
201
202 END get_source_context;
203
204
205
206
207 PROCEDURE get_default_jurisdiction(p_asg_act_id NUMBER,
208 p_ee_id NUMBER,
209 p_jurisdiction IN OUT NOCOPY VARCHAR2) IS
210 --
211 l_element_name VARCHAR2(240);
212 l_org_id VARCHAR2(240);
213 l_lwf_org_id VARCHAR2(240);
214 l_procedure VARCHAR(100);
215 l_message VARCHAR2(250);
216
217 --
218 -- Cursor for fetching the Element Name
219 CURSOR csr_element_name IS
220 SELECT pet.element_name
221 FROM pay_element_entries_f pee
222 ,pay_element_types_f pet
223 WHERE pet.element_type_id = pee.element_type_id
224 AND pee.element_entry_id = p_ee_id;
225 --
226 --Cursor for fetching PT Org Id
227 CURSOR csr_get_pt_org is
228 SELECT hsc.segment3
229 FROM pay_element_entries_f target
230 ,pay_assignment_actions paa
231 ,pay_payroll_actions ppa
232 ,per_assignments_f paf
233 ,hr_soft_coding_keyflex hsc
234 WHERE ppa.payroll_action_id = paa.payroll_action_id
235 AND target.element_entry_id = p_ee_id
236 AND target.assignment_id = paa.assignment_id
237 AND paa.assignment_action_id = p_asg_act_id
238 AND paf.assignment_id = paa.assignment_id
239 AND paf.soft_coding_keyflex_id = hsc.soft_coding_keyflex_id
240 AND ppa.effective_date BETWEEN target.effective_start_date
241 AND target.effective_end_date
242 AND ppa.effective_date BETWEEN paf.effective_start_date
243 AND paf.effective_end_date;
244
245 --Cursor for fetching fact/Establishment Org Id
246 CURSOR csr_get_lwf_org is
247 SELECT nvl(hsc.segment6,hsc.segment5)
248 FROM pay_element_entries_f target
249 ,pay_assignment_actions paa
250 ,pay_payroll_actions ppa
251 ,per_assignments_f paf
252 ,hr_soft_coding_keyflex hsc
253 WHERE ppa.payroll_action_id = paa.payroll_action_id
254 AND target.element_entry_id = p_ee_id
255 AND target.assignment_id = paa.assignment_id
256 AND paa.assignment_action_id = p_asg_act_id
257 AND paf.assignment_id = paa.assignment_id
258 AND paf.soft_coding_keyflex_id = hsc.soft_coding_keyflex_id
259 AND ppa.effective_date BETWEEN target.effective_start_date
260 AND target.effective_end_date
261 AND ppa.effective_date BETWEEN paf.effective_start_date
262 AND paf.effective_end_date;
263 --
264 BEGIN
265 --
266 l_procedure := g_package||'get_default_jurisdiction';
267 pay_in_utils.set_location(g_debug,'Entering: '||l_procedure,10);
268
269 IF g_debug THEN
270 pay_in_utils.trace ('**************************************************','********************');
271 pay_in_utils.trace ('p_asg_act_id',p_asg_act_id);
272 pay_in_utils.trace ('p_ee_id',p_ee_id);
273 pay_in_utils.trace ('**************************************************','********************');
274 END IF;
275 --
276 OPEN csr_element_name;
277 FETCH csr_element_name INTO l_element_name;
278 CLOSE csr_element_name;
279 --
280 pay_in_utils.trace('l_element_name ',l_element_name);
281 pay_in_utils.set_location(g_debug,l_procedure,20);
282 --
283 IF l_element_name in('Income Information', 'Professional Tax Information') THEN
284 OPEN csr_get_pt_org;
285 FETCH csr_get_pt_org into l_org_id;
286 l_org_id := nvl(l_org_id, '-1');
287 CLOSE csr_get_pt_org;
288 pay_in_utils.trace('l_org_id ',l_org_id);
289 pay_in_utils.set_location(g_debug,l_procedure,30);
290 IF l_org_id = '-1' THEN
291 p_jurisdiction := 'XX';
292 ELSE
293 p_jurisdiction := nvl(pay_in_prof_tax_pkg.get_state(l_org_id), 'XX');
294 END IF;
295
296 ELSIF l_element_name = 'LWF Information' THEN
297 pay_in_utils.trace('LWF information attached ',l_element_name);
298 OPEN csr_get_lwf_org;
299 FETCH csr_get_lwf_org into l_lwf_org_id;
300 l_lwf_org_id := nvl(l_lwf_org_id, '-1');
301 CLOSE csr_get_lwf_org;
302 pay_in_utils.trace('l_lwf_org_id ',l_lwf_org_id);
303 pay_in_utils.set_location(g_debug,l_procedure,40);
304 IF l_lwf_org_id = '-1' THEN
305 p_jurisdiction := 'XX';
306 ELSE
307 p_jurisdiction := nvl(pay_in_ff_pkg.get_lwf_state(l_lwf_org_id), 'XX');
308 END IF;
309 END IF;
310
311 IF g_debug THEN
312 pay_in_utils.trace ('**************************************************','********************');
313 pay_in_utils.trace ('p_jurisdiction',p_jurisdiction);
314 pay_in_utils.trace ('**************************************************','********************');
315 END IF;
316
317 pay_in_utils.set_location(g_debug,'Leaving: '||l_procedure,40);
318
319 END get_default_jurisdiction;
320 --
321
322
323
324 PROCEDURE get_source_text2_context(p_asg_act_id NUMBER
325 ,p_ee_id NUMBER
326 ,p_source_text2 IN OUT NOCOPY VARCHAR2)
327 IS
328
329 l_procedure VARCHAR(100);
330 l_message VARCHAR2(250);
331
332 CURSOR csr_context
333 IS
334 SELECT element_information1
335 FROM pay_element_types pet
336 ,pay_element_links pel
337 ,pay_element_entries pee
338 WHERE pet.element_type_id = pel.element_type_id
339 AND pel.element_link_id = pee.element_link_id
340 AND pee.element_entry_id = p_ee_id;
341
342 BEGIN
343
344 l_procedure := g_package||'get_source_text2_context';
345 pay_in_utils.set_location(g_debug,'Entering: '||l_procedure,10);
346
347 IF g_debug THEN
348 pay_in_utils.trace ('**************************************************','********************');
349 pay_in_utils.trace ('p_asg_act_id',p_asg_act_id);
350 pay_in_utils.trace ('p_ee_id',p_ee_id);
351 pay_in_utils.trace ('**************************************************','********************');
352 END IF;
353
354 OPEN csr_context;
355 FETCH csr_context
356 INTO p_source_text2;
357 IF csr_context%NOTFOUND THEN
358 p_source_text2 := 'Blank';
359 END IF;
360 CLOSE csr_context;
361
362 IF g_debug THEN
363 pay_in_utils.trace ('**************************************************','********************');
364 pay_in_utils.trace ('p_source_text2',p_source_text2);
365 pay_in_utils.trace ('**************************************************','********************');
366 END IF;
367
368 pay_in_utils.set_location(g_debug,'Leaving: '||l_procedure,20);
369
370 END get_source_text2_context;
371
372
373
374 FUNCTION element_template_pre_process
375 (p_template_obj IN PAY_ELE_TMPLT_OBJ)
376 RETURN PAY_ELE_TMPLT_OBJ
377 IS
378 l_procedure VARCHAR(100);
379 l_message VARCHAR2(250);
380 l_template_obj PAY_ELE_TMPLT_OBJ;
381
382 BEGIN
383 l_procedure := g_package||'element_template_pre_process';
384 pay_in_utils.set_location(g_debug,'Entering: '||l_procedure,10);
385
386 l_template_obj := p_template_obj;
387 l_template_obj :=
388 pay_in_element_template_pkg.element_template_pre_process
389 (p_template_obj => p_template_obj);
390
391 pay_in_utils.set_location(g_debug,'Leaving: '||l_procedure,20);
392 RETURN l_template_obj;
393
394 END element_template_pre_process;
395
396
397
398 PROCEDURE element_template_upd_user_stru
399 (p_template_id IN NUMBER)
400 IS
401 l_procedure VARCHAR(100);
402 l_message VARCHAR2(250);
403
404
405 BEGIN
406
407 l_procedure := g_package||'element_template_upd_user_stru';
408 pay_in_utils.set_location(g_debug,'Entering: '||l_procedure,10);
409
410 IF g_debug THEN
411 pay_in_utils.trace ('**************************************************','********************');
412 pay_in_utils.trace ('p_template_id',p_template_id);
413 pay_in_utils.trace ('**************************************************','********************');
414 END IF;
415
416 pay_in_element_template_pkg.element_template_upd_user_stru
417 (p_template_id => p_template_id);
418
419 pay_in_utils.trace('p_template_id ',p_template_id);
420 pay_in_utils.set_location(g_debug,l_procedure,20);
421
422 pay_in_utils.set_location(g_debug,'Leaving: '||l_procedure,30);
423
424 END element_template_upd_user_stru;
425
426
427
428 PROCEDURE element_template_post_process
429 (p_template_id IN NUMBER)
430 IS
431 l_procedure VARCHAR(100);
432 l_message VARCHAR2(250);
433
434
435 BEGIN
436
437 l_procedure := g_package||'element_template_post_process';
438 pay_in_utils.set_location(g_debug,'Entering: '||l_procedure,10);
439
440 IF g_debug THEN
441 pay_in_utils.trace ('**************************************************','********************');
442 pay_in_utils.trace ('p_template_id',p_template_id);
443 pay_in_utils.trace ('**************************************************','********************');
444 END IF;
445
446 pay_in_utils.set_location(g_debug, l_procedure, 20);
447 pay_in_element_template_pkg.element_template_post_process
448 (p_template_id => p_template_id);
449
450 pay_in_utils.trace('p_template_id ',p_template_id);
451 pay_in_utils.set_location(g_debug,l_procedure,30);
452
453 pay_in_utils.set_location(g_debug,'Leaving: '||l_procedure,40);
454
455 END element_template_post_process;
456
457
458
459
460
461 PROCEDURE delete_pre_process
462 (p_template_id IN NUMBER)
463 IS
464 l_procedure VARCHAR(100);
465 l_message VARCHAR2(250);
466
467 BEGIN
468
469 l_procedure := g_package||'get_source_text2_context';
470 pay_in_utils.set_location(g_debug,'Entering: '||l_procedure,10);
471
472 IF g_debug THEN
473 pay_in_utils.trace ('**************************************************','********************');
474 pay_in_utils.trace ('p_template_id',p_template_id);
475 pay_in_utils.trace ('**************************************************','********************');
476 END IF;
477
478 pay_in_element_template_pkg.delete_pre_process
479 (p_template_id => p_template_id);
480
481 pay_in_utils.trace('p_template_id ',p_template_id);
482 pay_in_utils.set_location(g_debug,l_procedure,20);
483
484 pay_in_utils.set_location(g_debug,'Leaving: '||l_procedure,30);
485
486
487 END delete_pre_process;
488
489 BEGIN
490 g_debug := hr_utility.debug_enabled;
491 END pay_in_rules;