[Home] [Help]
PACKAGE BODY: APPS.PAY_FR_REBATES
Source
1 package body PAY_FR_REBATES as
2 /* $Header: pyfrebat.pkb 115.10 2003/11/11 07:58:33 autiwari noship $ */
3 --
4 -- Globals used by get_prev_asg_hours:
5 g_hours_worked_def_bal_id ff_user_entities.creator_id%TYPE;
6 g_hours_absent_def_bal_id ff_user_entities.creator_id%TYPE;
7 --
8 Procedure init_formula (p_formula_name in varchar2) is
9 --
10 l_effective_date date;
11 l_start_date date;
12 l_formula_id number;
13 --
14 Begin
15 --
16 select effective_date
17 into l_effective_date
18 from fnd_sessions
19 where session_id = userenv('SESSIONID');
20 --
21 /* This function call returns -1 if the formula was not found */
22 l_formula_id := pay_fr_general.get_formula_info
23 (p_formula_name => p_formula_name
24 ,p_effective_date => l_effective_date
25 ,p_effective_start_date => l_start_date);
26 --
27 hr_utility.set_location('After cursor formula_id = '||to_char(l_formula_id),10);
28 hr_utility.set_location('After cursor date = '||to_char(l_start_date),10);
29 hr_utility.set_location('Formula name = '||p_formula_name, 10);
30 --
31 ff_exec.init_formula (l_formula_id,
32 l_start_date,
33 g_inputs,
34 g_outputs);
35 --
36 hr_utility.set_location('Leaving init',10);
37 End init_formula;
38
39 Function get_aubry_II_rebate (p_date_earned in date
40 ,p_assignment_id in number
41 ,p_process_type in varchar2
42 ,p_tax_unit_id in number
43 ,p_asg_action_id in number
44 ,p_business_group_id in number
45 ,p_aubry_I_used in varchar2
46 ,p_robien_used in varchar2
47 ,p_subject_to_ss_cont in number
48 ,p_hours_worked in number
49 ,p_sick_pay in number
50 ,p_absence_days in number
51 ,p_aubry_II_rebate out nocopy number
52 ,p_aubry_II_rebate_code out nocopy varchar2
53 ,p_aubry_II_contribution_id out nocopy number
54 ,p_aubry_II_zrr_rebate out nocopy number
55 ,p_aubry_II_zrr_rebate_code out nocopy varchar2
56 ,p_aubry_II_zrr_contribution_id out nocopy number
57 ,p_message out nocopy varchar2) return number is
58 --
59 Begin
60 --
61 hr_utility.set_location('Entering pay_fr_rebates.get_aubry_II_rebate ',7);
62 --
63 init_formula('FR_AUBRY_II_REBATE');
64 --
65 -- Set up parameter values for the formula
66 for i in g_inputs.first..g_inputs.last loop
67 --
68 if g_inputs(i).name = 'DATE_EARNED' then
69 g_inputs(i).value := fnd_date.date_to_canonical(p_date_earned);
70 elsif g_inputs(i).name = 'ASSIGNMENT_ID' then
71 g_inputs(i).value := p_assignment_id;
72 elsif g_inputs(i).name = 'SOURCE_TEXT' then
73 g_inputs(i).value := p_process_type;
74 elsif g_inputs(i).name = 'PROCESS_TYPE' then
75 g_inputs(i).value := p_process_type;
76 elsif g_inputs(i).name = 'AUBRY_I_USED' then
77 g_inputs(i).value := p_aubry_I_used;
78 elsif g_inputs(i).name = 'ROBIEN_USED' then
79 g_inputs(i).value := p_robien_used;
80 elsif g_inputs(i).name = 'SUBJECT_TO_SS_CONTRIBUTIONS' then
81 g_inputs(i).value := p_subject_to_ss_cont;
82 elsif g_inputs(i).name = 'HOURS_WORKED' then
83 g_inputs(i).value := p_hours_worked;
84 elsif g_inputs(i).name = 'SICK_PAY' then
85 g_inputs(i).value := p_sick_pay;
86 elsif g_inputs(i).name = 'ABSENCE_DAYS' then
87 g_inputs(i).value := p_absence_days;
88 elsif g_inputs(i).name = 'TAX_UNIT_ID' then
89 g_inputs(i).value := p_tax_unit_id;
90 elsif g_inputs(i).name = 'ASSIGNMENT_ACTION_ID' then
91 g_inputs(i).value := p_asg_action_id;
92 elsif g_inputs(i).name = 'BUSINESS_GROUP_ID' then
93 g_inputs(i).value := p_business_group_id;
94 else
95 hr_utility.set_location('ERROR value = '||g_inputs(i).name ,7);
96 end if;
97 --
98 end loop;
99 --
100 -- Run the formula
101 --
102 hr_utility.set_location('Prior to execute the formula',8);
103 ff_exec.run_formula (g_inputs ,
104 g_outputs
105 );
106 --
107 hr_utility.set_location('End run formula',9);
108 --
109 for l_out_cnt in g_outputs.first..g_outputs.last loop
110 --
111 if g_outputs(l_out_cnt).name = 'L_AUBRY_II_REBATE' then
112 p_aubry_ii_rebate := g_outputs(l_out_cnt).value;
113 elsif g_outputs(l_out_cnt).name = 'L_AUBRY_II_REBATE_CODE' then
114 p_aubry_II_rebate_code := g_outputs(l_out_cnt).value;
115 elsif g_outputs(l_out_cnt).name = 'L_AUBRY_II_CONTRIBUTION_ID' then
116 p_aubry_II_contribution_id := g_outputs(l_out_cnt).value;
117 elsif g_outputs(l_out_cnt).name = 'L_AUBRY_II_ZRR_REBATE' then
118 p_aubry_II_zrr_rebate := g_outputs(l_out_cnt).value;
119 elsif g_outputs(l_out_cnt).name = 'L_AUBRY_II_ZRR_REBATE_CODE' then
120 p_aubry_II_zrr_rebate_code := g_outputs(l_out_cnt).value;
121 elsif g_outputs(l_out_cnt).name = 'L_AUBRY_II_ZRR_CONTRIBUTION_ID' then
122 p_aubry_II_zrr_contribution_id := g_outputs(l_out_cnt).value;
123 elsif g_outputs(l_out_cnt).name = 'MESG' then
124 p_message := g_outputs(l_out_cnt).value;
125 end if;
126 --
127 end loop;
128 --
129 if (p_aubry_II_contribution_id = -1 or p_aubry_II_zrr_contribution_id = -1) then
130 hr_utility.set_location('get_aubry_II_rebate: Returning -1',10);
131 return -1;
132 else
133 hr_utility.set_location('get_aubry_II_rebate: Returning 0',10);
134 return 0;
135 end if;
136 --
137 End get_aubry_II_rebate;
138
139 Function get_aubry_I_rebate (p_date_earned in date
140 ,p_assignment_id in number
141 ,p_process_type in varchar2
142 ,p_tax_unit_id in number
143 ,p_mesg out nocopy varchar2
144 ,p_aubry_I_rebate out nocopy number
145 ,p_aubry_I_rebate_code out nocopy varchar2
146 ,p_aubry_I_contribution_id out nocopy number) return number is
147 --
148 Begin
149 --
150 hr_utility.set_location('Entering pay_fr_rebates.get_aubry_I_rebate ',7);
151 --
152 init_formula('FR_AUBRY_I_REBATE');
153 --
154 -- Set up parameter values for the formula
155 for i in g_inputs.first..g_inputs.last loop
156 --
157 if g_inputs(i).name = 'DATE_EARNED' then
158 g_inputs(i).value := fnd_date.date_to_canonical(p_date_earned);
159 elsif g_inputs(i).name = 'PROCESS_TYPE' then
160 g_inputs(i).value := p_process_type;
161 elsif g_inputs(i).name = 'SOURCE_TEXT' then
162 g_inputs(i).value := p_process_type;
163 elsif g_inputs(i).name = 'ASSIGNMENT_ID' then
164 g_inputs(i).value := p_assignment_id;
165 elsif g_inputs(i).name = 'TAX_UNIT_ID' then
166 g_inputs(i).value := p_tax_unit_id;
167 else
168 hr_utility.set_location('ERROR value = '||g_inputs(i).name ,7);
169 end if;
170 --
171 end loop;
172 --
173 -- Run the formula
174 --
175 hr_utility.set_location(' Prior to execute the formula',8);
176 ff_exec.run_formula (g_inputs ,
177 g_outputs
178 );
179 --
180 hr_utility.set_location(' End run formula',9);
181 --
182 for l_out_cnt in g_outputs.first..g_outputs.last loop
183 --
184 if g_outputs(l_out_cnt).name = 'L_AUBRY_I_REBATE' then
185 p_aubry_I_rebate := g_outputs(l_out_cnt).value;
186 elsif g_outputs(l_out_cnt).name = 'L_AUBRY_I_REBATE_CODE' then
187 p_aubry_I_rebate_code := g_outputs(l_out_cnt).value;
188 elsif g_outputs(l_out_cnt).name = 'L_AUBRY_I_CONTRIBUTION_ID' then
189 p_aubry_I_contribution_id := g_outputs(l_out_cnt).value;
190 elsif g_outputs(l_out_cnt).name = 'MESG' then
191 p_mesg := g_outputs(l_out_cnt).value;
192 end if;
193 --
194 end loop;
195 --
196 if p_aubry_I_contribution_id = -1 then
197 hr_utility.set_location('get_aubry_I_rebate: Returning -1',10);
198 return -1;
199 else
200 hr_utility.set_location('get_aubry_I_rebate: Returning 0',10);
201 return 0;
202 end if;
203 --
204 End get_aubry_I_rebate;
205
206 Function get_robien_rebate (p_date_earned in date
207 ,p_assignment_id in number
208 ,p_process_type in varchar2
209 ,p_tax_unit_id in number
210 ,p_contributions_base in number
211 ,p_mesg out nocopy varchar2
212 ,p_robien_rebate out nocopy number
213 ,p_robien_rebate_code out nocopy varchar2
214 ,p_robien_rebate_rate out nocopy number
215 ,p_robien_contribution_id out nocopy number) return number is
216 --
217 Begin
218 --
219 hr_utility.set_location('Entering pay_fr_rebates.get_robien_rebate ',7);
220 --
221 init_formula('FR_ROBIEN_REBATE');
222 --
223 -- Set up parameter values for the formula
224 for i in g_inputs.first..g_inputs.last loop
225 --
226 if g_inputs(i).name = 'DATE_EARNED' then
227 g_inputs(i).value := fnd_date.date_to_canonical(p_date_earned);
228 elsif g_inputs(i).name = 'SOURCE_TEXT' then
229 g_inputs(i).value := p_process_type;
230 elsif g_inputs(i).name = 'PROCESS_TYPE' then
231 g_inputs(i).value := p_process_type;
232 elsif g_inputs(i).name = 'ASSIGNMENT_ID' then
233 g_inputs(i).value := p_assignment_id;
234 elsif g_inputs(i).name = 'CONTRIBUTIONS_BASE' then
235 g_inputs(i).value := p_contributions_base;
236 elsif g_inputs(i).name = 'TAX_UNIT_ID' then
237 g_inputs(i).value := p_tax_unit_id;
238 else
239 hr_utility.set_location('ERROR value = '||g_inputs(i).name ,7);
240 end if;
241 --
242 end loop;
243 --
244 -- Run the formula
245 --
246 hr_utility.set_location(' Prior to execute the formula',8);
247 ff_exec.run_formula (g_inputs ,
248 g_outputs
249 );
250 --
251 hr_utility.set_location(' End run formula',9);
252 --
253 for l_out_cnt in g_outputs.first..g_outputs.last loop
254 --
255 if g_outputs(l_out_cnt).name = 'L_ROBIEN_REBATE' then
256 p_robien_rebate := g_outputs(l_out_cnt).value;
257 elsif g_outputs(l_out_cnt).name = 'L_ROBIEN_REBATE_CODE' then
258 p_robien_rebate_code := g_outputs(l_out_cnt).value;
259 elsif g_outputs(l_out_cnt).name = 'L_ROBIEN_REBATE_RATE' then
260 p_robien_rebate_rate := g_outputs(l_out_cnt).value;
261 elsif g_outputs(l_out_cnt).name = 'L_ROBIEN_CONTRIBUTION_ID' then
262 p_robien_contribution_id := g_outputs(l_out_cnt).value;
263 elsif g_outputs(l_out_cnt).name = 'MESG' then
264 p_mesg := g_outputs(l_out_cnt).value;
265 end if;
266 --
267 end loop;
268 --
269 if p_robien_contribution_id = -1 then
270 hr_utility.set_location('get_robien_rebate: Returning -1',10);
271 return -1;
272 else
273 hr_utility.set_location('get_robien_rebate: Returning 0',10);
274 return 0;
275 end if;
276 --
277 End get_robien_rebate;
278
279 Function get_part_time_rebate (p_date_earned in date
280 ,p_assignment_id in number
281 ,p_process_type in varchar2
282 ,p_tax_unit_id in number
283 ,p_contributions_base in number
284 ,p_mesg out nocopy varchar2
285 ,p_part_time_rebate out nocopy number
286 ,p_part_time_rebate_code out nocopy varchar2
287 ,p_part_time_contribution_id out nocopy number) return number is
288 --
289 Begin
290 --
291 hr_utility.set_location('Entering pay_fr_rebates.get_part_time_rebate ',7);
292 --
293 init_formula('FR_PART_TIME_REBATE');
294 --
295 -- Set up parameter values for the formula
296 for i in g_inputs.first..g_inputs.last loop
297 --
298 if g_inputs(i).name = 'DATE_EARNED' then
299 g_inputs(i).value := fnd_date.date_to_canonical(p_date_earned);
300 elsif g_inputs(i).name = 'PROCESS_TYPE' then
301 g_inputs(i).value := p_process_type;
302 elsif g_inputs(i).name = 'SOURCE_TEXT' then
303 g_inputs(i).value := p_process_type;
304 elsif g_inputs(i).name = 'CONTRIBUTIONS_BASE' then
305 g_inputs(i).value := p_contributions_base;
306 elsif g_inputs(i).name = 'ASSIGNMENT_ID' then
307 g_inputs(i).value := p_assignment_id;
308 elsif g_inputs(i).name = 'TAX_UNIT_ID' then
309 g_inputs(i).value := p_tax_unit_id;
310 else
311 hr_utility.set_location('ERROR value = '||g_inputs(i).name ,7);
312 end if;
313 --
314 end loop;
315 --
316 -- Run the formula
317 --
318 hr_utility.set_location(' Prior to execute the formula',8);
319 ff_exec.run_formula (g_inputs,
320 g_outputs
321 );
322 --
323 hr_utility.set_location(' End run formula',9);
324 --
325 for l_out_cnt in g_outputs.first..g_outputs.last loop
326 --
327 if g_outputs(l_out_cnt).name = 'L_PART_TIME_REBATE' then
328 p_part_time_rebate := g_outputs(l_out_cnt).value;
329 elsif g_outputs(l_out_cnt).name = 'L_PART_TIME_REBATE_CODE' then
330 p_part_time_rebate_code := g_outputs(l_out_cnt).value;
331 elsif g_outputs(l_out_cnt).name = 'L_PART_TIME_CONTRIBUTION_ID' then
332 p_part_time_contribution_id := g_outputs(l_out_cnt).value;
333 elsif g_outputs(l_out_cnt).name = 'MESG' then
334 p_mesg := g_outputs(l_out_cnt).value;
335 end if;
336 --
337 end loop;
338 --
339 if p_part_time_contribution_id = -1 then
340 hr_utility.set_location('get_part_time_rebate: Returning -1',10);
341 return -1;
342 else
343 hr_utility.set_location('get_part_time_rebate: Returning 0',10);
344 return 0;
345 end if;
346 --
347 End get_part_time_rebate;
348
349 Function get_ss_lower_rebate (p_date_earned in date
350 ,p_assignment_id in number
351 ,p_process_type in varchar2
352 ,p_tax_unit_id in number
353 ,p_business_group_id in number
354 ,p_salary in number
355 ,p_salary_excluding_absence in number
356 ,p_hours_worked in number
357 ,p_absence_days in number
358 ,p_mesg out nocopy varchar2
359 ,p_ss_lower_rebate out nocopy number
360 ,p_ss_lower_rebate_code out nocopy varchar2
361 ,p_ss_lower_contribution_id out nocopy number) return number is
362 --
363 Begin
364 --
365 hr_utility.set_location('Entering pay_fr_rebates.get_ss_lower_rebate ',7);
366 --
367 init_formula('FR_SS_LOWER_REBATE');
368 --
369 -- Set up parameter values for the formula
370 for i in g_inputs.first..g_inputs.last loop
371 --
372 if g_inputs(i).name = 'DATE_EARNED' then
373 g_inputs(i).value := fnd_date.date_to_canonical(p_date_earned);
374 elsif g_inputs(i).name = 'PROCESS_TYPE' then
375 g_inputs(i).value := p_process_type;
376 elsif g_inputs(i).name = 'SOURCE_TEXT' then
377 g_inputs(i).value := p_process_type;
378 elsif g_inputs(i).name = 'SALARY' then
379 g_inputs(i).value := p_salary;
380 elsif g_inputs(i).name = 'SALARY_EXCLUDING_ABSENCE' then
381 g_inputs(i).value := p_salary_excluding_absence;
382 elsif g_inputs(i).name = 'HOURS_WORKED' then
383 g_inputs(i).value := p_hours_worked;
384 elsif g_inputs(i).name = 'ABSENCE_DAYS' then
385 g_inputs(i).value := p_absence_days;
386 elsif g_inputs(i).name = 'ASSIGNMENT_ID' then
387 g_inputs(i).value := p_assignment_id;
388 elsif g_inputs(i).name = 'TAX_UNIT_ID' then
389 g_inputs(i).value := p_tax_unit_id;
390 elsif g_inputs(i).name = 'BUSINESS_GROUP_ID' then
391 g_inputs(i).value := p_business_group_id;
392 else
393 hr_utility.set_location('ERROR value = '||g_inputs(i).name ,7);
394 end if;
395 --
396 end loop;
397 --
398 -- Run the formula
399 --
400 hr_utility.set_location(' Prior to execute the formula',8);
401 --
402 ff_exec.run_formula (g_inputs,
403 g_outputs
404 );
405 --
406 hr_utility.set_location(' End run formula',9);
407 --
408 for l_out_cnt in g_outputs.first..g_outputs.last loop
409 --
410 if g_outputs(l_out_cnt).name = 'L_SS_LOWER_REBATE' then
411 p_ss_lower_rebate := g_outputs(l_out_cnt).value;
412 elsif g_outputs(l_out_cnt).name = 'L_SS_LOWER_REBATE_CODE' then
413 p_ss_lower_rebate_code := g_outputs(l_out_cnt).value;
414 elsif g_outputs(l_out_cnt).name = 'L_SS_LOWER_CONTRIBUTION_ID' then
415 p_ss_lower_contribution_id := g_outputs(l_out_cnt).value;
416 elsif g_outputs(l_out_cnt).name = 'MESG' then
417 p_mesg := g_outputs(l_out_cnt).value;
418 end if;
419 --
420 end loop;
421 --
422 if p_ss_lower_contribution_id = -1 then
423 hr_utility.set_location('get_ss_lower_rebate: Returning -1',10);
424 return -1;
425 else
426 hr_utility.set_location('get_ss_lower_rebate: Returning 0',10);
427 return 0;
428 end if;
429 --
430 End get_ss_lower_rebate;
431
432 Function valid_aubry_robien_dates (p_org_id in number,
433 p_information_type in varchar2,
434 p_date_from in date,
435 p_date_to in date default null) return varchar2 is
436 --
437 l_end_date date;
438 l_dummy varchar2(1);
439 --
440 cursor c1 is
441 select 'X'
442 from hr_organization_information hoi
443 where (
444 (
445 p_date_from between fnd_date.canonical_to_date(hoi.org_information1)
446 and decode(p_information_type,'FR_ESTAB_ROBIEN',add_months(fnd_date.canonical_to_date(hoi.org_information1),60)
447 ,fnd_date.canonical_to_date(hoi.org_information2))
448 )
449 or
450 (
451 l_end_date between fnd_date.canonical_to_date(hoi.org_information1)
452 and decode(p_information_type,'FR_ESTAB_ROBIEN',add_months(fnd_date.canonical_to_date(hoi.org_information1),60)
453 ,fnd_date.canonical_to_date(hoi.org_information2))
454 )
455 or
456 (
457 l_end_date >= decode(p_information_type,'FR_ESTAB_ROBIEN',add_months(fnd_date.canonical_to_date(hoi.org_information1),60)
458 ,fnd_date.canonical_to_date(hoi.org_information2))
459 and p_date_from <= fnd_date.canonical_to_date(hoi.org_information1)
460 )
461 )
462 and hoi.org_information_context = decode(p_information_type,'FR_ESTAB_ROBIEN',
463 'FR_ESTAB_AUBRY_I','FR_ESTAB_ROBIEN')
464 and hoi.organization_id = p_org_id;
465 --
466 Begin
467 --
468 if p_information_type = 'FR_ESTAB_ROBIEN' then
469 l_end_date := NVL(p_date_to,to_date('4712/12/31','YYYY/MM/DD'));
470 else
471 l_end_date := add_months(p_date_from,60);
472 end if;
473 --
474 open c1;
475 fetch c1 into l_dummy;
476 if c1%found then
477 close c1;
478 return 'N';
479 else
480 close c1;
481 return 'Y';
482 end if;
483 --
484 End valid_aubry_robien_dates;
485
486 Function contribution_info (p_date_earned in date
487 ,p_process_type in varchar2
488 ,p_element_name in varchar2
489 ,p_usage_type in varchar2
490 ,p_contribution_id out nocopy number
491 ,p_contribution_code out nocopy varchar2
492 ,mesg out nocopy varchar2) return number is
493 --
494 l_contribution_usage pay_fr_contribution_usages%rowtype;
495 l_contribution_code pay_fr_contribution_usages.contribution_code%type;
496 --
497 Begin
498 --
499 hr_utility.set_location('Entering pay_fr_rebates.contribution info ', 10);
500 --
501 l_contribution_usage := pay_fr_general.get_contribution_usage
502 (p_process_type => p_process_type
503 ,p_element_name => p_element_name
504 ,p_usage_type => p_usage_type
505 ,p_effective_date => p_date_earned);
506 --
507 /* Call function to substitute base code into contribution code */
508 l_contribution_code := pay_fr_general.sub_contrib_code(p_contribution_type => l_contribution_usage.contribution_type
509 ,p_contribution_code => l_contribution_usage.contribution_code);
510 --
511 p_contribution_code := l_contribution_code;
512 p_contribution_id := l_contribution_usage.contribution_usage_id;
513 --
514 hr_utility.set_location('Contribution code = '||l_contribution_usage.contribution_code, 10);
515 hr_utility.set_location('Contribution id = '||to_char(l_contribution_usage.contribution_usage_id), 10);
516 --
517 mesg := ' ';
518 --
519 hr_utility.set_location('Entering pay_fr_rebates.contribution info = 0', 10);
520 return 0;
521 --
522 Exception when others then
523 fnd_message.set_name('PAY','PAY_74918_SD_NO_CNU_DATA');
524 fnd_message.set_token('ET',p_element_name);
525 fnd_message.set_token('PT',p_process_type);
526 fnd_message.set_token('UT',p_usage_type);
527 mesg := fnd_message.get;
528 p_contribution_id := -1;
529 p_contribution_code := ' ';
530 hr_utility.set_location('Leaving pay_fr_rebates.contribution info = -1', 10);
531 return -1;
532 --
533 End contribution_info;
534
535 Function get_eligibility (p_date_earned in date
536 ,p_assignment_id in number
537 ,p_process_type in varchar2
538 ,p_tax_unit_id in number
539 ,p_asg_action_id in number
540 ,p_pay_action_id in number
541 ,p_aubry_II_used out nocopy varchar2
542 ,p_aubry_I_used out nocopy varchar2
543 ,p_robien_used out nocopy varchar2
544 ,p_part_time_used out nocopy varchar2
545 ,p_ss_lower_used out nocopy varchar2
546 ,p_mesg out nocopy varchar2
547 ,p_fillon_used out nocopy varchar2
548 ,p_fillon_mesg out nocopy varchar2
549 ,p_director_mesg out nocopy varchar2
550 ,p_fillon_part_time_mesg
551 out nocopy varchar2
552 ) return number is
553 --
554 l_warn varchar2(150);
555 l_err varchar2(150);
556 l_warn_flag varchar2(150);
557 --
558 Begin
559 --
560 init_formula('FR_GET_REBATE_ELIGIBILITY');
561 hr_utility.set_location('FORMULA Initialised ' ,10);
562 --
563 -- Set up parameter values for the formula
564 for i in g_inputs.first..g_inputs.last loop
565 --
566 if g_inputs(i).name = 'PROCESS_TYPE' then
567 g_inputs(i).value := p_process_type;
568 elsif g_inputs(i).name = 'SOURCE_TEXT' then
569 g_inputs(i).value := p_process_type;
570 elsif g_inputs(i).name = 'DATE_EARNED' then
571 g_inputs(i).value := fnd_date.date_to_canonical(p_date_earned);
572 elsif g_inputs(i).name = 'ASSIGNMENT_ID' then
573 g_inputs(i).value := p_assignment_id;
574 elsif g_inputs(i).name = 'TAX_UNIT_ID' then
575 g_inputs(i).value := p_tax_unit_id;
576 elsif g_inputs(i).name = 'ASSIGNMENT_ACTION_ID' then
577 g_inputs(i).value := p_asg_action_id;
578 elsif g_inputs(i).name = 'PAYROLL_ACTION_ID' then
579 g_inputs(i).value := p_pay_action_id;
580 else
581 hr_utility.set_location('ERROR value = '||g_inputs(i).name ,7);
582 end if;
583 --
584 end loop;
585 --
586 -- Run the formula
587 --
588 hr_utility.set_location(' Prior to execute the formula',8);
589 --
590 ff_exec.run_formula (g_inputs,
591 g_outputs
592 );
593 --
594 hr_utility.set_location(' End run formula',9);
595 --
596 for l_out_cnt in g_outputs.first..g_outputs.last loop
597 --
598 if g_outputs(l_out_cnt).name = 'AUBRY_II_USED' then
599 p_aubry_II_used := g_outputs(l_out_cnt).value;
600 elsif g_outputs(l_out_cnt).name = 'AUBRY_I_USED' then
601 p_aubry_I_used := g_outputs(l_out_cnt).value;
602 elsif g_outputs(l_out_cnt).name = 'ROBIEN_USED' then
603 p_robien_used := g_outputs(l_out_cnt).value;
604 elsif g_outputs(l_out_cnt).name = 'PART_TIME_USED' then
605 p_part_time_used := g_outputs(l_out_cnt).value;
606 elsif g_outputs(l_out_cnt).name = 'SS_LOWER_USED' then
607 p_ss_lower_used := g_outputs(l_out_cnt).value;
608 elsif g_outputs(l_out_cnt).name = 'MESG' then
609 p_mesg := g_outputs(l_out_cnt).value;
610 elsif g_outputs(l_out_cnt).name = 'L_ERROR' then
611 l_err := g_outputs(l_out_cnt).value;
612 elsif g_outputs(l_out_cnt).name = 'L_WARNING' then
613 l_warn := g_outputs(l_out_cnt).value;
614 elsif g_outputs(l_out_cnt).name = 'FILLON_USED' then
615 p_fillon_used := g_outputs(l_out_cnt).value;
616 elsif g_outputs(l_out_cnt).name = 'L_FILLON_MESG' then
617 p_fillon_mesg := g_outputs(l_out_cnt).value;
618 elsif g_outputs(l_out_cnt).name = 'L_DIRECTOR_MESG' then
619 p_director_mesg := g_outputs(l_out_cnt).value;
620 elsif g_outputs(l_out_cnt).name = 'L_FILLON_PART_TIME_MESG' then
621 p_fillon_part_time_mesg := g_outputs(l_out_cnt).value;
622 else
623 hr_utility.set_location('Output = '||g_outputs(l_out_cnt).name, 10);
624 end if;
625 --
626 end loop;
627 --
628
629 if l_err like 'PAY_7%' then
630 -- Returns either PAY_74972_PART_TIME_ELIG_ERROR
631 -- or PAY_79999_NO_AUBRY_II
632 fnd_message.set_name('PAY', l_err);
633 p_mesg := fnd_message.get;
634 hr_utility.set_location(' Returning -1',10);
635 return -1;
636 else
637
638 if l_warn = 'PAY_74972_PART_TIME_ELIG_WARN' then
639 fnd_message.set_name('PAY',l_warn);
640 p_mesg := fnd_message.get;
641 l_warn_flag := 'Y';
642 end if;
643
644 if p_director_mesg = 'PAY_75081_REBATE_DIRECTOR_ELIG' then
645 fnd_message.set_name('PAY', p_director_mesg);
646 p_director_mesg := fnd_message.get;
647 l_warn_flag := 'Y';
648 end if;
649
650 if p_fillon_mesg = 'PAY_75082_FILLON_ESTAB_ELIG' then
651 fnd_message.set_name('PAY', p_fillon_mesg);
652 p_fillon_mesg := fnd_message.get;
653 l_warn_flag := 'Y';
654 end if;
655
656 if p_fillon_part_time_mesg = 'PAY_75083_FILLON_PART_TIME' then
657 fnd_message.set_name('PAY', p_fillon_part_time_mesg);
658 p_fillon_part_time_mesg := fnd_message.get;
659 l_warn_flag := 'Y';
660 end if;
661
662 if l_warn_flag = 'Y' then
663 hr_utility.set_location(' Returning -2',10);
664 return -2;
665 end if;
666
667 end if;
668
669 --
670 hr_utility.set_location(' Returning 0',10);
671 return 0;
672 --
673 End get_eligibility;
674
675
676 Function get_prev_asg_hours (p_assignment_id in number
677 ,p_payroll_action_id in number
678 ,p_process_type in varchar2
679 ,p_tax_unit_id in number) return number is
680 --
681 cursor csr_get_assignment_action is
682 select fnd_number.canonical_to_number(substr(max(lpad(paa.action_sequence,15,'0')||
683 paa.assignment_action_id),16))
684 from pay_assignment_actions paa,
685 pay_payroll_actions ppa
686 where paa.assignment_id = p_assignment_id
687 and ppa.payroll_action_id = paa.payroll_action_id
688 and ppa.effective_date between
689 pay_fr_general.g_prev_start_date and
690 pay_fr_general.g_prev_end_date
691 and ppa.action_type in ('R', 'Q', 'I', 'V', 'B');
692 --
693 cursor csr_get_defined_bal_id (p_balance_name in varchar2) is
694 select creator_id
695 from ff_user_entities
696 where user_entity_name = p_balance_name;
697 --
698 l_err number;
699 l_result number;
700 l_assignment_action_id number := -1;
701 --
702 Begin
703 --
704 hr_utility.set_location('In function ', 10);
705 l_err := pay_fr_general.get_prev_start_end(p_payroll_action_id,
706 pay_fr_general.g_prev_start_date,
707 pay_fr_general.g_prev_end_date);
708 hr_utility.set_location('PREV MONTH value '||to_char(l_err),10);
709 hr_utility.set_location('Start date = '||to_char(pay_fr_general.g_prev_start_date),10);
710 hr_utility.set_location('End date = '||to_char(pay_fr_general.g_prev_end_date),10);
711 --
712 if l_err = 0 then
713 --
714 open csr_get_assignment_action;
715 fetch csr_get_assignment_action into l_assignment_action_id;
716 close csr_get_assignment_action;
717 hr_utility.set_location('Action id = '||to_char(l_assignment_action_id),10);
718 if l_assignment_action_id > -1 then
719 --
720 /* now call bue for the asg hours balance using this assignment action id
721 - this should get balance for previous period (at the end) */
722 --
723 if g_hours_worked_def_bal_id is null then
724 open csr_get_defined_bal_id ('FR_ACTUAL_HOURS_BASE_ASG_ET_PR_PTD');
725 fetch csr_get_defined_bal_id into g_hours_worked_def_bal_id;
726 close csr_get_defined_bal_id;
727 end if;
728 if g_hours_absent_def_bal_id is null then
729 open csr_get_defined_bal_id ('FR_ABSENCE_HOURS_BASE_ASG_ET_PR_PTD');
730 fetch csr_get_defined_bal_id into g_hours_absent_def_bal_id;
731 close csr_get_defined_bal_id;
732 end if;
733 --
734 pay_balance_pkg.set_context ('SOURCE_TEXT',p_process_type);
735 pay_balance_pkg.set_context ('TAX_UNIT_ID',p_tax_unit_id);
736 l_result := nvl(pay_balance_pkg.get_value(g_hours_worked_def_bal_id,
737 l_assignment_action_id),0) +
738 nvl(pay_balance_pkg.get_value(g_hours_absent_def_bal_id,
739 l_assignment_action_id),0);
740 return l_result;
741 --
742 else
743 return 0;
744 end if;
745 --
746 else
747 return -1;
748 end if;
749 --
750 End get_prev_asg_hours;
751
752 end pay_fr_rebates;