[Home] [Help]
PACKAGE BODY: APPS.BEN_EVALUATE_ELIG_PROFILES
Source
1 package body ben_evaluate_elig_profiles as
2 /* $Header: benevlpr.pkb 120.10.12010000.5 2008/10/07 09:09:23 krupani ship $ */
3 --------------------------------------------------------------------------------
4 /*
5 +==============================================================================+
6 | Copyright (c) 1997 Oracle Corporation |
7 | Redwood Shores, California, USA |
8 | All rights reserved. |
9 +==============================================================================+
10
11 Name
12 Profile Evaluation Package
13 Purpose
14 This package is used to determine if a person satisfies eligiblity
15 profiles or not. Created by moving the criteria evaluation logic from
16 bendetel.pkb Will be called from both elpro and vapro
17 History
18 Date Who Version What?
19 --------- ----------- ------- --------------------------------------------
20 18 May 03 mmudigon 115.0 Original version
21 10 Oct 03 mmudigon 115.1 Fixes in check_person_ben_bal and
22 check_person_balance for Vapros
23 23-nov-03 nhunur 115.2 changed exception handling part.
24 02-feb-03 pbodla 115.3 Bug 3450533 : pass life event occured date
25 to rule (check_rule_elig).
26 22-mar-04 Hariram 115.5 Bug 3520054 - Cached plip/ptip records were
27 unavailable since the code was moved from
28 bendetel to benevlpr.
29 17-Apr-04 ikasire 115.6 FONM changes
30 18-Apr-04 mmudigon 115.7 Universal Eligibility
31 11-Jun-04 mmudigon 115.8 FONM : now populating l_fonm_cvg_strt_dt
32 in function eligible
33 13-aug-04 tjesumic 115.9 FONM : fonm date passed as parameter
34 17-aug-04 tjesumic 115.10 FONM : intialise the global
35 13-Sep-04 tjesumic 115.12 FONM : reset the person cache if the date is not within effective dates
36 29-Sep-04 tjesumic 115.13 FONM : clearing cache call asg
37 14-Dec-04 abparekh 115.14 Bug 4031314 : Modified logic in check_perf_rtng_elig
38 not to compare Event Type when ELPRO criteria has
39 Performance Type as -1
40 Modified check_qua_in_gr_elig to fetch approved pay proposal
41 21-Dec-04 abparekh 115.15 Bug 4031314 : In check_perf_rtng_elig consider only latest
42 Performance Rating
43 06-Feb-05 mmudigon 115.16 RBC changes
44 24-Feb-05 tjesumic 115.17 fonm-4204020 after determining date adjustment of cvrd/enrol in another
45 criteria using fonm date, the calcualted date isreplace by fonm date
46 this is fixed by removing l_date_to_use := NVL(l_fonm_cvg_strt_dt,l_date_to_use)
47 08-Mar-05 nhunur 115.18 GSI - NL issue. check legal entity for US legislation only.
48 18-Apr-05 mmudigon 115.19 RBC changes continued.
49 26-Apr-05 mmudigon 115.20 Score and Weight
50 14-Jun-05 abparekh 115.21 Bug 4429071 : For derived factors use this formula :
51 Score + (Criteria Value * Weightage )
52 23-Jun-05 abparekh 115.22 Bug 4449229 : Fix for AGE LOS Combination derived factors
53 Score calculation
54 27-Jun-05 abparekh 115.23 Bug 4454878 : Reset g_per_eligible before processing ELPROs
55 24-jan-06 ssarkar 115.24 Bug 4958846 : Eligibilty fix for only IREC.
56 20-Apr-06 bmanyam 115.25 Bug 5173693 : Numeric Value error in benmngle.g_output string.
57 Truncated the string
58 09-May-06 gsehgal 115.26 Bug 4558945 : change get_quartile to ben_cwb_person_info_pkg.get_grd_quartile
59 27-Jun-06 swjain 115.27 Bug 5331889 : Added person_id in call to benutils.formula in procedure check_rule_elig
60 25-Sep-06 stee 115.28 Bug 5550851 : Fix check_elig_dpnt_cvrd_othr_pgm cursor
61 to use the calculated date to determine
62 eligibility instead of the fonm date.
63 07-Sep-07 rtagarra 115.29 Bug 6399423 : Used proper variable for Assignment checking for FONM case.
64 22-Oct-07 rtagarra 115.30 Bug 6509099 : Handled code for Irec case.
65 14-Jan-07 rtagarra 115.31 Bug 6747807 : Modified cursor c1 in procedures check_elig_dpnt_cvrd_othr_pl
66 ,check_elig_dpnt_cvrd_othr_plip,check_elig_dpnt_cvrd_othr_ptip,check_elig_dpnt_cvrd_othr_pgm
67 07-Oct-08 krupani 115.34 Bug 7411918 : Moved 'Leaving Reason' eligibility criteria out of cobra if condition
68 so that, it can be used for plan not in program too
69 */
70 --------------------------------------------------------------------------------
71 --
72 g_package varchar2(30) := 'ben_evaluate_elig_profiles.';
73 g_score_compute_mode boolean := false;
74 g_trk_scr_for_inelg_flag boolean := false;
75 g_per_eligible boolean;
76 --
77 l_fonm_cvg_strt_dt date ;
78 --
79 procedure write(p_score_tab in out nocopy scoreTab,
80 p_eligy_prfl_id number,
81 p_tab_short_name varchar2,
82 p_pk_id number,
83 p_computed_score number) is
84
85 l_count number := 0;
86 l_proc varchar2(100):= g_package||'write';
87 begin
88 hr_utility.set_location('Entering: '||l_proc,10);
89
90 l_count := p_score_tab.count +1;
91 p_score_tab(l_count).eligy_prfl_id := p_eligy_prfl_id;
92 p_score_tab(l_count).crit_tab_short_name := p_tab_short_name;
93 p_score_tab(l_count).crit_tab_pk_id := p_pk_id;
94 p_score_tab(l_count).computed_score := p_computed_score;
95 p_score_tab(l_count).benefit_action_id := benutils.g_benefit_action_id;
96
97 hr_utility.set_location('Leaving: '||l_proc,10);
98
99 end write;
100
101 procedure write(p_profile_score_tab in out nocopy scoreTab,
102 p_crit_score_tab in scoreTab) is
103 l_proc varchar2(100):= g_package||'write';
104 begin
105
106 hr_utility.set_location('Entering: '||l_proc,10);
107 if p_crit_score_tab.count > 0
108 then
109 for i in 1..p_crit_score_tab.count
110 loop
111 p_profile_score_tab(p_profile_score_tab.count+1) := p_crit_score_tab(i);
112 end loop;
113 end if;
114 hr_utility.set_location('Leaving: '||l_proc,10);
115
116 end write;
117
118 function is_ok (p_val number
119 ,p_max number
120 ,p_min number
121 ,p_max_flag varchar2 default null
122 ,p_min_flag varchar2 default null
123 ,p_pct_value varchar2 default 'N' )
124 return boolean is
125 l_min number:=-999999999999999999999999999999999999999;
126 l_max number:= 999999999999999999999999999999999999999;
127 begin
128 -- Bug 2101937 fixes
129 -- We deal Decimals and Whole numbers in two different ways not to changes the
130 -- existing functionality with the customers.
131 -- In case of decimal is used in min or max limit, user needs to handle the
132 -- the p_val to make sure that it falls in one of the ranges using the
133 -- rounding code. To get this we are using (p_max + 0.000000001) as the upper
134 -- boundary. So we check for p_val < (p_max + 0.000000001).
135 -- In case of whole numbers, we always take the p_max + 1 in the upper boundary
136 -- to make sure that the p_val is less than < (p_max + 1 ).
137 --
138 if p_max is not null then
139 --
140 if ( nvl(p_pct_value,'N') = 'Y' OR
141 p_max <> trunc(p_max) OR
142 p_min <> trunc(p_min) ) then
143 --
144 -- Decimal Case
145 l_max := p_max + 0.000000001 ;
146 --
147 else
148 -- Whole number
149 l_max := p_max + 1 ;
150 --
151 end if;
152 --
153 end if;
154 --
155 return (nvl(p_val,0) >= nvl(p_min,l_min) and
156 nvl(p_val,0) < l_max )
157 or
158 (nvl(p_min_flag,'N') = 'Y' and
159 nvl(p_max_flag,'N') = 'Y')
160 or
161 (nvl(p_min_flag,'N') = 'Y' and
162 nvl(p_val,0) < l_max )
163 or
164 (nvl(p_max_flag,'N') = 'Y' and
165 nvl(p_val,0) >= nvl(p_min,l_min));
166 --
167 end;
168 --
169 -- --------------------------------------------------------------------
170 -- Hours worked in a period
171 -- --------------------------------------------------------------------
172 --
173 function get_rt_hrs_wkd
174 (p_person_id in number
175 ,p_business_group_id in number
176 ,p_effective_date in date
177 ,p_opt_id in number default null
178 ,p_plip_id in number default null
179 ,p_pl_id in number default null
180 ,p_pgm_id in number default null)
181 return number is
182 --
183 l_rt_hrs_wkd_val ben_elig_per_f.rt_hrs_wkd_val%type;
184 --
185
186 cursor c_hrs_wkd is
187 select bep.rt_hrs_wkd_val
188 from ben_elig_per_f bep,
189 ben_per_in_ler pil
190 where bep.person_id = p_person_id
191 and nvl(bep.pgm_id,-1) = nvl(p_pgm_id,-1)
192 and nvl(bep.pl_id,-1) = nvl(p_pl_id,-1)
193 and nvl(l_fonm_cvg_strt_dt,p_effective_date) between bep.effective_start_date
194 and bep.effective_end_date
195 and pil.per_in_ler_id(+)=bep.per_in_ler_id
196 and pil.business_group_id(+)=bep.business_group_id
197 and (pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT') -- found row condition
198 or pil.per_in_ler_stat_cd is null); -- outer join condition
199
200 cursor c_hrs_wkd_opt is
201 select epo.rt_hrs_wkd_val
202 from ben_elig_per_f bep, ben_elig_per_opt_f epo,
203 ben_per_in_ler pil
204 where bep.person_id = p_person_id
205 and bep.elig_per_id = epo.elig_per_id
206 and epo.opt_id = p_opt_id
207 and nvl(bep.pgm_id,-1) = nvl(p_pgm_id,-1)
208 and nvl(bep.pl_id,-1) = nvl(p_pl_id,-1)
209 and nvl(l_fonm_cvg_strt_dt,p_effective_date) between epo.effective_start_date
210 and epo.effective_end_date
211 and nvl(l_fonm_cvg_strt_dt,p_effective_date) between bep.effective_start_date
212 and bep.effective_end_date
213 and pil.per_in_ler_id(+)=bep.per_in_ler_id
214 and pil.business_group_id(+)=bep.business_group_id
215 and (pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT') -- found row condition
216 or pil.per_in_ler_stat_cd is null); -- outer join condition
217
218 cursor c_hrs_wkd_plip is
219 select epo.rt_hrs_wkd_val
220 from ben_elig_per_f bep, ben_elig_per_opt_f epo,
221 ben_per_in_ler pil
222 where bep.person_id = p_person_id
223 and bep.elig_per_id = epo.elig_per_id
224 and epo.opt_id = p_opt_id
225 and nvl(bep.pgm_id,-1) = nvl(p_pgm_id,-1)
226 and nvl(bep.plip_id,-1) = nvl(p_plip_id,-1)
227 and nvl(l_fonm_cvg_strt_dt,p_effective_date) between epo.effective_start_date
228 and epo.effective_end_date
229 and nvl(l_fonm_cvg_strt_dt,p_effective_date) between bep.effective_start_date
230 and bep.effective_end_date
231 and pil.per_in_ler_id(+)=bep.per_in_ler_id
232 and pil.business_group_id(+)=bep.business_group_id
233 and (pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT') -- found row condition
234 or pil.per_in_ler_stat_cd is null); -- outer join condition
235
236 begin
237
238 if p_opt_id is not null then
239 -- Look for oiplip first. oiplip elig_per_opt rows hang off plip elig_per
240 -- records.
241 if p_plip_id is not null then
242 open c_hrs_wkd_plip;
243 fetch c_hrs_wkd_plip into l_rt_hrs_wkd_val;
244 hr_utility.set_location ('oiplip '||to_char(l_rt_hrs_wkd_val),01);
245 close c_hrs_wkd_plip;
246 end if;
247
248 -- If there is no oiplip, check for oipl
249 if l_rt_hrs_wkd_val is null then
250 open c_hrs_wkd_opt;
251 fetch c_hrs_wkd_opt into l_rt_hrs_wkd_val;
252 hr_utility.set_location ('oipl '||to_char(l_rt_hrs_wkd_val),01);
253 close c_hrs_wkd_opt;
254 end if;
255 else
256 -- just look for pl elig per record.
257 open c_hrs_wkd;
258 fetch c_hrs_wkd into l_rt_hrs_wkd_val;
259 hr_utility.set_location ('pl '||to_char(l_rt_hrs_wkd_val),01);
260 close c_hrs_wkd;
261 end if;
262
263 return l_rt_hrs_wkd_val;
264
265 end get_rt_hrs_wkd;
266 --
267 -- -----------------------------------------------------------------
268 -- percent fulltime.
269 -- -----------------------------------------------------------------
270 --
271 function get_rt_pct_fltm
272 (p_person_id in number
273 ,p_business_group_id in number
274 ,p_effective_date in date
275 ,p_opt_id in number default null
276 ,p_plip_id in number default null
277 ,p_pl_id in number default null
278 ,p_pgm_id in number default null)
279 return number is
280 --
281 cursor c_pct_ft is
282 select bep.rt_pct_fl_tm_val
283 from ben_elig_per_f bep,
284 ben_per_in_ler pil
285 where bep.person_id = p_person_id
286 and nvl(bep.pgm_id,-1) = nvl(p_pgm_id,-1)
287 and nvl(bep.pl_id,-1) = nvl(p_pl_id,-1)
288 and p_effective_date
289 between bep.effective_start_date
290 and bep.effective_end_date
291 and pil.per_in_ler_id(+)=bep.per_in_ler_id
292 and pil.business_group_id(+)=bep.business_group_id+0
293 and (pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT') -- found row condition
294 or pil.per_in_ler_stat_cd is null -- outer join condition
295 );
296
297 cursor c_pct_ft_opt is
298 select epo.rt_pct_fl_tm_val
299 from ben_elig_per_f bep, ben_elig_per_opt_f epo,
300 ben_per_in_ler pil
301 where bep.person_id = p_person_id
302 and bep.elig_per_id = epo.elig_per_id
303 and epo.opt_id = p_opt_id
304 and nvl(bep.pgm_id,-1) = nvl(p_pgm_id,-1)
305 and nvl(bep.pl_id,-1) = nvl(p_pl_id,-1)
306 and p_effective_date between epo.effective_start_date
307 and epo.effective_end_date
308 and p_effective_date between bep.effective_start_date
309 and bep.effective_end_date
310 and pil.per_in_ler_id(+)=bep.per_in_ler_id
311 and pil.business_group_id(+)=bep.business_group_id
312 and (pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT') -- found row condition
313 or pil.per_in_ler_stat_cd is null); -- outer join condition
314
315 cursor c_pct_ft_plip is
316 select epo.rt_pct_fl_tm_val
317 from ben_elig_per_f bep, ben_elig_per_opt_f epo,
318 ben_per_in_ler pil
319 where bep.person_id = p_person_id
320 and bep.elig_per_id = epo.elig_per_id
321 and epo.opt_id = p_opt_id
322 and nvl(bep.pgm_id,-1) = nvl(p_pgm_id,-1)
323 and nvl(bep.plip_id,-1) = nvl(p_plip_id,-1)
324 and p_effective_date between epo.effective_start_date
325 and epo.effective_end_date
326 and p_effective_date between bep.effective_start_date
327 and bep.effective_end_date
328 and pil.per_in_ler_id(+)=bep.per_in_ler_id
329 and pil.business_group_id(+)=bep.business_group_id
330 and (pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT') -- found row condition
331 or pil.per_in_ler_stat_cd is null); -- outer join condition
332
333 l_per_pct_ft_val number;
334 --
335 begin
336 --
337 if p_opt_id is not null then
338 -- Look for oiplip first. oiplip elig_per_opt rows hang off plip elig_per
339 -- records.
340 if p_plip_id is not null then
341 open c_pct_ft_plip;
342 fetch c_pct_ft_plip into l_per_pct_ft_val;
343 hr_utility.set_location ('oiplip '||to_char(l_per_pct_ft_val),01);
344 close c_pct_ft_plip;
345 end if;
346
347 -- If there is no oiplip, check for oipl
348 if l_per_pct_ft_val is null then
349 open c_pct_ft_opt;
350 fetch c_pct_ft_opt into l_per_pct_ft_val;
351 hr_utility.set_location ('oipl '||to_char(l_per_pct_ft_val),01);
352 close c_pct_ft_opt;
353 end if;
354 else
355 -- just look for pl elig per record.
356 open c_pct_ft;
357 fetch c_pct_ft into l_per_pct_ft_val;
358 hr_utility.set_location ('pl '||to_char(l_per_pct_ft_val),01);
359 close c_pct_ft;
360 end if;
361 --
362 return l_per_pct_ft_val;
363
364 end get_rt_pct_fltm;
365 --
366 -- -----------------------------------------------------
367 -- This procedure determines eligibility based on LOS.
368 -- -----------------------------------------------------
369 --
370 procedure check_los_elig(p_eligy_prfl_id in number,
371 p_business_group_id in number,
372 p_effective_date in date,
373 p_person_id in number,
374 p_per_los in number,
375 p_eval_typ in varchar2,
376 p_comp_obj_mode in boolean,
377 p_currepe_row in ben_determine_rates.g_curr_epe_rec,
378 p_lf_evt_ocrd_dt in date,
379 p_score_compute_mode in boolean default false,
380 p_profile_score_tab in out nocopy scoreTab,
381 p_per_in_ler_id in number default null,
382 p_pl_id in number default null,
383 p_pgm_id in number default null,
384 p_oipl_id in number default null,
385 p_plip_id in number default null,
386 p_opt_id in number default null) is
387 --
388 l_proc varchar2(100):= g_package||'check_los_elig';
389 l_inst_dets ben_elp_cache.g_cache_elpels_instor;
390 l_inst_count number;
391 l_insttorrw_num binary_integer;
392 l_ok boolean := false;
393 l_rows_found boolean := false;
394 l_pl_id number;
395 l_pgm_id number;
396 l_per_in_ler_id number;
397 l_oipl_id number;
398 l_per_los number := p_per_los;
399 l_dummy_date date;
400 l_prtn_ovridn_flag varchar2(30);
401 l_prtn_ovridn_thru_dt date;
402 l_epo_row ben_derive_part_and_rate_facts.g_cache_structure;
403 l_crit_passed boolean;
404 l_score_tab scoreTab;
405 --
406 begin
407 --
408 hr_utility.set_location('Entering: '||l_proc,10);
409 --
410 -- Getting eligibility profile length of service by eligibility profile
411 --
412 ben_elp_cache.elpels_getcacdets
413 (p_effective_date => nvl(l_fonm_cvg_strt_dt,p_effective_date)
414 ,p_business_group_id => p_business_group_id
415 ,p_eligy_prfl_id => p_eligy_prfl_id
416 ,p_inst_set => l_inst_dets
417 ,p_inst_count => l_inst_count);
418 --
419 if l_inst_count > 0 then
420 --
421 if p_eval_typ <> 'E' then
422 --
423 -- plan in program is overriden, capture the data from cache by
424 -- passing plip_id
425 --
426 if p_opt_id is null and p_pgm_id is not null then
427 ben_pep_cache.get_pilpep_dets(
428 p_person_id => p_person_id,
429 p_business_group_id => p_business_group_id,
430 p_effective_date => nvl(l_fonm_cvg_strt_dt,p_effective_date),
431 p_pgm_id => p_pgm_id,
432 p_plip_id => p_plip_id,
433 p_inst_row => l_epo_row);
434 l_prtn_ovridn_flag := l_epo_row.prtn_ovridn_flag;
435 l_prtn_ovridn_thru_dt := l_epo_row.prtn_ovridn_thru_dt;
436 l_per_los := l_epo_row.rt_los_val;
437 elsif p_opt_id is not null and p_pgm_id is not null then
438 ben_pep_cache.get_pilepo_dets(
439 p_person_id => p_person_id,
440 p_business_group_id => p_business_group_id,
441 p_effective_date => nvl(l_fonm_cvg_strt_dt,p_effective_date),
442 p_pgm_id => p_pgm_id,
443 p_plip_id => p_plip_id,
444 p_opt_id => p_opt_id,
445 p_inst_row => l_epo_row);
446 l_prtn_ovridn_flag := l_epo_row.prtn_ovridn_flag;
447 l_prtn_ovridn_thru_dt := l_epo_row.prtn_ovridn_thru_dt;
448 l_per_los := l_epo_row.rt_los_val;
449 else
450 hr_utility.set_location('Plan not in Program',10);
451 l_prtn_ovridn_flag := p_currepe_row.prtn_ovridn_flag;
452 l_prtn_ovridn_thru_dt := p_currepe_row.prtn_ovridn_thru_dt;
453 l_per_los := p_currepe_row.rt_los_val;
454 end if;
455 end if;
456
457 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
458 --
459 if not p_comp_obj_mode or
460 (p_eval_typ <> 'E' and
461 not (nvl(l_prtn_ovridn_flag,'N') = 'Y' and
462 nvl(l_prtn_ovridn_thru_dt,hr_api.g_eot) > nvl(l_fonm_cvg_strt_dt,p_effective_date))
463 ) then
464 --
465 ben_derive_factors.determine_los
466 (p_person_id => p_person_id
467 ,p_los_fctr_id => l_inst_dets(l_insttorrw_num).los_fctr_id
468 ,p_pgm_id => p_pgm_id
469 ,p_pl_id => p_pl_id
470 ,p_oipl_id => p_oipl_id
471 ,p_per_in_ler_id => p_per_in_ler_id
472 ,p_comp_obj_mode => p_comp_obj_mode
473 ,p_effective_date => p_effective_date
474 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
475 ,p_business_group_id => p_business_group_id
476 ,p_perform_rounding_flg => TRUE
477 ,p_value => l_per_los
478 ,p_start_date => l_dummy_date
479 ,p_fonm_cvg_strt_dt => l_fonm_cvg_strt_dt );
480 --
481 end if;
482
483 l_ok := is_ok(l_per_los
484 ,l_inst_dets(l_insttorrw_num).mx_los_num
485 ,l_inst_dets(l_insttorrw_num).mn_los_num
486 ,l_inst_dets(l_insttorrw_num).no_mx_los_num_apls_flag
487 ,l_inst_dets(l_insttorrw_num).no_mn_los_num_apls_flag
488 );
489 hr_utility.set_location('l_per_los '||l_per_los,20);
490 hr_utility.set_location('ACE Score = ' || l_inst_dets(l_insttorrw_num).criteria_score, 20);
491 hr_utility.set_location('ACE Weight = ' || l_inst_dets(l_insttorrw_num).criteria_weight, 20);
492 hr_utility.set_location('ACE Value = ' || to_char(( l_per_los * nvl(l_inst_dets(l_insttorrw_num).criteria_weight, 0) ) + nvl(l_inst_dets(l_insttorrw_num).criteria_score, 0)), 20);
493 --
494 if l_per_los is null then
495 --
496 l_ok := false;
497 --
498 end if;
499 --
500 if l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
501 --
502 if p_score_compute_mode then
503 if l_crit_passed is null then
504 l_crit_passed := true;
505 end if;
506 write(l_score_tab,
507 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
508 l_inst_dets(l_insttorrw_num).short_code,
509 l_inst_dets(l_insttorrw_num).pk_id,
510 ( l_per_los * nvl(l_inst_dets(l_insttorrw_num).criteria_weight, 0) ) +
511 nvl(l_inst_dets(l_insttorrw_num).criteria_score, 0) /* Bug 4429071 */
512 );
513 else
514 exit;
515 end if;
516 --
517 elsif l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
518 --
519 l_rows_found := true;
520 l_ok := false;
521 exit;
522 --
523 elsif (not l_ok) and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
524 --
525 l_rows_found := true;
526 l_ok := true;
527 if p_score_compute_mode then
528 write(l_score_tab,
529 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
530 l_inst_dets(l_insttorrw_num).short_code,
531 l_inst_dets(l_insttorrw_num).pk_id,
532 ( l_per_los * nvl(l_inst_dets(l_insttorrw_num).criteria_weight, 0) ) +
533 nvl(l_inst_dets(l_insttorrw_num).criteria_score, 0) /* Bug 4429071 */
534 );
535 end if;
536 --exit ;
537 --
538 elsif l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
539 --
540 l_rows_found := true;
541 --
542 end if;
543 --
544 end loop;
545 --
546 end if;
547 --
548 if l_crit_passed is null
549 then
550 if l_rows_found and
551 not l_ok then
552 --
553 l_score_tab.delete;
554 g_inelg_rsn_cd := 'LOS';
555 fnd_message.set_name('BEN','BEN_91669_LOS_PRFL_FAIL');
556 hr_utility.set_location('Criteria Failed: '||l_proc,20);
557 raise g_criteria_failed;
558 --
559 end if;
560 end if;
561 --
562 if p_score_compute_mode
563 then
564 hr_utility.set_location('count '||l_score_tab.count,20);
565 write(p_profile_score_tab,l_score_tab);
566 end if;
567 hr_utility.set_location('Leaving: '||l_proc,20);
568 --
569 end check_los_elig;
570 --
571 -- ----------------------------------------------------
572 -- This procedure determines eligibility based on age.
573 -- ----------------------------------------------------
574 --
575 procedure check_age_elig(p_eligy_prfl_id in number,
576 p_person_id in number,
577 p_business_group_id in number,
578 p_effective_date in date,
579 p_per_age in number,
580 p_per_dob in date,
581 p_eval_typ in varchar2,
582 p_comp_obj_mode in boolean,
583 p_currepe_row in ben_determine_rates.g_curr_epe_rec,
584 p_lf_evt_ocrd_dt in date,
585 p_score_compute_mode in boolean default false,
586 p_profile_score_tab in out nocopy scoreTab,
587 p_per_in_ler_id in number default null,
588 p_pl_id in number default null,
589 p_pgm_id in number default null,
590 p_oipl_id in number default null,
591 p_plip_id in number default null,
592 p_opt_id in number default null) is
593 --
594 l_proc varchar2(100):= g_package||'check_age_elig';
595 l_dob date:=p_per_dob;
596 l_ok boolean := false;
597 l_rows_found boolean := false;
598 l_pl_id number;
599 l_pgm_id number;
600 l_per_in_ler_id number;
601 l_oipl_id number;
602 l_per_age number := p_per_age;
603 l_dummy_date date;
604 l_prtn_ovridn_flag varchar2(30);
605 l_prtn_ovridn_thru_dt date;
606 l_epo_row ben_derive_part_and_rate_facts.g_cache_structure;
607 l_inst_dets ben_elp_cache.g_cache_elpeap_instor;
608 l_inst_count number;
609 l_insttorrw_num binary_integer;
610 l_crit_passed boolean;
611 l_score_tab scoreTab;
612 --
613 begin
614 --
615 hr_utility.set_location('Entering :'||l_proc, 10);
616 --
617 -- Getting eligibility profile age details by eligibility profile
618 --
619 ben_elp_cache.elpeap_getcacdets
620 (p_effective_date => nvl(l_fonm_cvg_strt_dt,p_effective_date)
621 ,p_business_group_id => p_business_group_id
622 ,p_eligy_prfl_id => p_eligy_prfl_id
623 ,p_inst_set => l_inst_dets
624 ,p_inst_count => l_inst_count);
625 --
626 hr_utility.set_location('Age :'||l_per_age, 10);
627 if l_inst_count > 0 then
628
629 if p_eval_typ <> 'E' then
630 --
631 -- plan in program is overriden, capture the data from cache by
632 -- passing plip_id
633 --
634 if p_opt_id is null and p_pgm_id is not null then
635 ben_pep_cache.get_pilpep_dets(
636 p_person_id => p_person_id,
637 p_business_group_id => p_business_group_id,
638 p_effective_date => nvl(l_fonm_cvg_strt_dt,p_effective_date),
639 p_pgm_id => p_pgm_id,
640 p_plip_id => p_plip_id,
641 p_inst_row => l_epo_row);
642 l_prtn_ovridn_flag := l_epo_row.prtn_ovridn_flag;
643 l_prtn_ovridn_thru_dt := l_epo_row.prtn_ovridn_thru_dt;
644 l_per_age := l_epo_row.rt_age_val;
645 elsif p_opt_id is not null and p_pgm_id is not null then
646 ben_pep_cache.get_pilepo_dets(
647 p_person_id => p_person_id,
648 p_business_group_id => p_business_group_id,
649 p_effective_date => nvl(l_fonm_cvg_strt_dt,p_effective_date),
650 p_pgm_id => p_pgm_id,
651 p_plip_id => p_plip_id,
652 p_opt_id => p_opt_id,
653 p_inst_row => l_epo_row);
654 l_prtn_ovridn_flag := l_epo_row.prtn_ovridn_flag;
655 l_prtn_ovridn_thru_dt := l_epo_row.prtn_ovridn_thru_dt;
656 l_per_age := l_epo_row.rt_age_val;
657 else
658 hr_utility.set_location('Plan not in Program',10);
659 l_prtn_ovridn_flag := p_currepe_row.prtn_ovridn_flag;
660 l_prtn_ovridn_thru_dt := p_currepe_row.prtn_ovridn_thru_dt;
661 l_per_age := p_currepe_row.rt_age_val;
662 end if;
663 end if;
664
665 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
666 --
667 if not p_comp_obj_mode or
668 (p_eval_typ <> 'E' and
669 not (nvl(l_prtn_ovridn_flag,'N') = 'Y' and
670 nvl(l_prtn_ovridn_thru_dt,hr_api.g_eot) > nvl(l_fonm_cvg_strt_dt,p_effective_date))
671 ) then
672 --
673 ben_derive_factors.determine_age
674 (p_person_id => p_person_id
675 ,p_per_dob => l_dob
676 ,p_age_fctr_id => l_inst_dets(l_insttorrw_num).age_fctr_id
677 ,p_pgm_id => p_pgm_id
678 ,p_pl_id => p_pl_id
679 ,p_oipl_id => p_oipl_id
680 ,p_per_in_ler_id => p_per_in_ler_id
681 ,p_comp_obj_mode => p_comp_obj_mode
682 ,p_effective_date => p_effective_date
683 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
684 ,p_business_group_id => p_business_group_id
685 ,p_perform_rounding_flg => TRUE
686 ,p_value => l_per_age
687 ,p_change_date => l_dummy_date
688 ,p_fonm_cvg_strt_dt => l_fonm_cvg_strt_dt );
689 --
690 end if;
691
692 l_ok := is_ok(l_per_age
693 ,l_inst_dets(l_insttorrw_num).mx_age_num
694 ,l_inst_dets(l_insttorrw_num).mn_age_num
695 ,l_inst_dets(l_insttorrw_num).no_mx_age_flag
696 ,l_inst_dets(l_insttorrw_num).no_mn_age_flag
697 );
698 if l_per_age is null then
699 --
700 l_ok := false;
701 --
702 end if;
703 --
704 if l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
705 --
706 if p_score_compute_mode then
707 if l_crit_passed is null then
708 l_crit_passed := true;
709 end if;
710 write(l_score_tab,
711 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
712 l_inst_dets(l_insttorrw_num).short_code,
713 l_inst_dets(l_insttorrw_num).pk_id,
714 ( l_per_age * nvl(l_inst_dets(l_insttorrw_num).criteria_weight, 0) ) +
715 nvl(l_inst_dets(l_insttorrw_num).criteria_score, 0) /* Bug 4429071 */
716 );
717 else
718 exit;
719 end if;
720 --
721 elsif l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
722 --
723 l_rows_found := true;
724 l_ok := false;
725 exit;
726 --
727 elsif (not l_ok) and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
728 --
729 l_rows_found := true;
730 l_ok := true;
731 if p_score_compute_mode then
732 write(l_score_tab,
733 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
734 l_inst_dets(l_insttorrw_num).short_code,
735 l_inst_dets(l_insttorrw_num).pk_id,
736 ( l_per_age * nvl(l_inst_dets(l_insttorrw_num).criteria_weight, 0) ) +
737 nvl(l_inst_dets(l_insttorrw_num).criteria_score, 0) /* Bug 4429071 */
738 );
739 end if;
740 --exit ;
741 --
742 elsif l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
743 --
744 l_rows_found := true;
745 --
746 end if;
747 --
748 end loop;
749 --
750 end if;
751 --
752 --
753 if l_crit_passed is null
754 then
755 if l_rows_found and
756 not l_ok then
757 --
758 g_inelg_rsn_cd := 'AGE';
759 fnd_message.set_name('BEN','BEN_91670_AGE_PRFL_FAIL');
760 hr_utility.set_location('Criteria Failed: '||l_proc,20);
761 raise g_criteria_failed;
762 --
763 end if;
764 end if;
765 --
766 if p_score_compute_mode
767 then
768 hr_utility.set_location('count '||l_score_tab.count,20);
769 write(p_profile_score_tab,l_score_tab);
770 end if;
771 hr_utility.set_location('Leaving :'||l_proc, 20);
772 --
773 end check_age_elig;
774 --
775 -- --------------------------------------------------------------------
776 -- This procedure determines eligibility based on combination age/los.
777 -- --------------------------------------------------------------------
778 --
779 procedure check_age_los_elig(p_eligy_prfl_id in number,
780 p_person_id in number,
781 p_business_group_id in number,
782 p_effective_date in date,
783 p_per_cmbn_age_los in number,
784 p_per_cmbn_age in number,
785 p_per_cmbn_los in number,
786 p_dob in date,
787 p_eval_typ in varchar2,
788 p_comp_obj_mode in boolean,
789 p_currepe_row in ben_determine_rates.g_curr_epe_rec,
790 p_lf_evt_ocrd_dt in date,
791 p_score_compute_mode in boolean default false,
792 p_profile_score_tab in out nocopy scoreTab,
793 p_per_in_ler_id in number default null,
794 p_pl_id in number default null,
795 p_pgm_id in number default null,
796 p_oipl_id in number default null,
797 p_plip_id in number default null,
798 p_opt_id in number default null) is
799 --
800 l_proc varchar2(100):= g_package||'check_age_los_elig';
801 l_inst_dets ben_elp_cache.g_cache_elpecp_instor;
802 l_inst_count number;
803 l_insttorrw_num binary_integer;
804 l_ok boolean := false;
805 l_rows_found boolean := false;
806 l_age_fctr_id number;
807 l_los_fctr_id number;
808 l_age_check ben_agf_cache.g_cache_agf_instor;
809 l_los_check ben_los_cache.g_cache_los_instor;
810 l_dummy_date date;
811 l_pl_id number;
812 l_pgm_id number;
813 l_per_in_ler_id number;
814 l_oipl_id number;
815 l_dob date := p_dob;
816 l_per_cmbn_age number := p_per_cmbn_age;
817 l_per_cmbn_los number := p_per_cmbn_los;
818 l_per_cmbn_age_los number := p_per_cmbn_age_los;
819 l_prtn_ovridn_flag varchar2(30);
820 l_prtn_ovridn_thru_dt date;
821 l_epo_row ben_derive_part_and_rate_facts.g_cache_structure;
822 l_crit_passed boolean;
823 l_score_tab scoreTab;
824 --
825 begin
826 --
827 hr_utility.set_location('Entering :'||l_proc,10);
828 --
829 -- Getting eligibility profile age/los combination by eligibility profile
830 --
831 ben_elp_cache.elpecp_getcacdets
832 (p_effective_date => nvl(l_fonm_cvg_strt_dt,p_effective_date)
833 ,p_business_group_id => p_business_group_id
834 ,p_eligy_prfl_id => p_eligy_prfl_id
835 ,p_inst_set => l_inst_dets
836 ,p_inst_count => l_inst_count);
837 --
838 if l_inst_count > 0 then
839 --
840 if p_eval_typ <> 'E' then
841 --
842 -- plan in program is overriden, capture the data from cache by
843 -- passing plip_id
844 --
845 if p_opt_id is null and p_pgm_id is not null then
846 ben_pep_cache.get_pilpep_dets(
847 p_person_id => p_person_id,
848 p_business_group_id => p_business_group_id,
849 p_effective_date => nvl(l_fonm_cvg_strt_dt,p_effective_date),
850 p_pgm_id => p_pgm_id,
851 p_plip_id => p_plip_id,
852 p_inst_row => l_epo_row);
853 l_prtn_ovridn_flag := l_epo_row.prtn_ovridn_flag;
854 l_prtn_ovridn_thru_dt := l_epo_row.prtn_ovridn_thru_dt;
855 l_per_cmbn_age_los := l_epo_row.rt_cmbn_age_n_los_val;
856 elsif p_opt_id is not null and p_pgm_id is not null then
857 ben_pep_cache.get_pilepo_dets(
858 p_person_id => p_person_id,
859 p_business_group_id => p_business_group_id,
860 p_effective_date => nvl(l_fonm_cvg_strt_dt,p_effective_date),
861 p_pgm_id => p_pgm_id,
862 p_plip_id => p_plip_id,
863 p_opt_id => p_opt_id,
864 p_inst_row => l_epo_row);
865 l_prtn_ovridn_flag := l_epo_row.prtn_ovridn_flag;
866 l_prtn_ovridn_thru_dt := l_epo_row.prtn_ovridn_thru_dt;
867 l_per_cmbn_age_los := l_epo_row.rt_cmbn_age_n_los_val;
868 else
869 hr_utility.set_location('Plan not in Program',10);
870 l_prtn_ovridn_flag := p_currepe_row.prtn_ovridn_flag;
871 l_prtn_ovridn_thru_dt := p_currepe_row.prtn_ovridn_thru_dt;
872 l_per_cmbn_age_los := p_currepe_row.rt_cmbn_age_n_los_val;
873 end if;
874 end if;
875 --
876 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
877 --
878 l_los_fctr_id := l_inst_dets(l_insttorrw_num).los_fctr_id;
879 l_age_fctr_id := l_inst_dets(l_insttorrw_num).age_fctr_id;
880 --
881 if not p_comp_obj_mode or
882 (p_eval_typ <> 'E' and
883 not (nvl(l_prtn_ovridn_flag,'N') = 'Y' and
884 nvl(l_prtn_ovridn_thru_dt,hr_api.g_eot) > nvl(l_fonm_cvg_strt_dt,p_effective_date))
885 ) then
886 --
887 ben_derive_factors.determine_los
888 (p_person_id => p_person_id,
889 p_los_fctr_id => l_los_fctr_id,
890 p_pgm_id => p_pgm_id ,
891 p_pl_id => p_pl_id ,
892 p_oipl_id => p_oipl_id ,
893 p_per_in_ler_id => p_per_in_ler_id ,
894 p_comp_obj_mode => p_comp_obj_mode ,
895 p_effective_date => p_effective_date,
896 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
897 p_business_group_id => p_business_group_id ,
898 p_perform_rounding_flg => TRUE ,
899 p_value => l_per_cmbn_los,
900 p_start_date => l_dummy_date,
901 p_fonm_cvg_strt_dt => l_fonm_cvg_strt_dt );
902 --
903 ben_derive_factors.determine_age
904 (p_person_id => p_person_id,
905 p_per_dob => l_dob,
906 p_age_fctr_id => l_age_fctr_id,
907 p_pgm_id => p_pgm_id ,
908 p_pl_id => p_pl_id ,
909 p_oipl_id => p_oipl_id ,
910 p_per_in_ler_id => p_per_in_ler_id ,
911 p_comp_obj_mode => p_comp_obj_mode ,
912 p_effective_date => p_effective_date,
913 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
914 p_business_group_id => p_business_group_id ,
915 p_perform_rounding_flg => TRUE,
916 p_value => l_per_cmbn_age,
917 p_change_date => l_dummy_date,
918 p_fonm_cvg_strt_dt => l_fonm_cvg_strt_dt );
919 --
920 l_per_cmbn_age_los := l_per_cmbn_age + l_per_cmbn_los;
921 --
922 end if;
923 --
924 -- Combo passes, now check if components pass
925 --
926 l_ok := is_ok(l_per_cmbn_age_los
927 ,l_inst_dets(l_insttorrw_num).cmbnd_max_val
928 ,l_inst_dets(l_insttorrw_num).cmbnd_min_val
929 );
930 --
931 hr_utility.set_location('TOTAL ='||l_per_cmbn_age_los,10);
932 hr_utility.set_location('MIN ='||l_inst_dets(l_insttorrw_num).cmbnd_min_val,10);
933 hr_utility.set_location('MAX ='||l_inst_dets(l_insttorrw_num).cmbnd_max_val,10);
934 if l_per_cmbn_age_los is null then
935 --
936 l_ok := false;
937 --
938 end if;
939 --
940 if not l_ok then
941 --
942 hr_utility.set_location('Failed cmbn',10);
943 --
944 elsif l_ok then
945 --
946 -- Getting length of service factor
947 --
948 ben_los_cache.los_getcacdets
949 (p_effective_date => nvl(l_fonm_cvg_strt_dt,p_effective_date)
950 ,p_business_group_id => p_business_group_id
951 ,p_los_fctr_id => l_los_fctr_id
952 ,p_inst_set => l_los_check
953 ,p_inst_count => l_inst_count);
954 --
955 l_ok := is_ok(l_per_cmbn_los
956 ,l_los_check(0).mx_los_num
957 ,l_los_check(0).mn_los_num
958 ,l_los_check(0).no_mx_los_num_apls_flag
959 ,l_los_check(0).no_mn_los_num_apls_flag
960 );
961 if l_per_cmbn_los is null then
962 --
963 l_ok := false;
964 --
965 end if;
966 --
967 end if;
968 --
969 if not l_ok then
970 --
971 hr_utility.set_location('Failed los',10);
972 --
973 elsif l_ok then
974 --
975 -- Check if age passes
976 --
977 -- Getting age factor
978 --
979 ben_agf_cache.agf_getcacdets
980 (p_effective_date => nvl(l_fonm_cvg_strt_dt,p_effective_date)
981 ,p_business_group_id => p_business_group_id
982 ,p_age_fctr_id => l_age_fctr_id
983 --
984 ,p_inst_set => l_age_check
985 ,p_inst_count => l_inst_count);
986 --
987 l_ok := is_ok(l_per_cmbn_age
988 ,l_age_check(0).mx_age_num
989 ,l_age_check(0).mn_age_num
990 ,l_age_check(0).no_mx_age_flag
991 ,l_age_check(0).no_mn_age_flag
992 );
993 --
994 if l_per_cmbn_age is null then
995 --
996 l_ok := false;
997 --
998 end if;
999 --
1000 end if;
1001 --
1002 if l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
1003 --
1004 if p_score_compute_mode then
1005 if l_crit_passed is null then
1006 l_crit_passed := true;
1007 end if;
1008 write(l_score_tab,
1009 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
1010 l_inst_dets(l_insttorrw_num).short_code,
1011 l_inst_dets(l_insttorrw_num).pk_id,
1012 ( l_per_cmbn_age_los * nvl(l_inst_dets(l_insttorrw_num).criteria_weight, 0) ) +
1013 nvl(l_inst_dets(l_insttorrw_num).criteria_score, 0) /* Bug 4449229 */
1014 );
1015 else
1016 exit;
1017 end if;
1018 --
1019 elsif l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
1020 --
1021 l_rows_found := true;
1022 l_ok := false;
1023 exit;
1024 --
1025 elsif (not l_ok) and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
1026 --
1027 l_rows_found := true;
1028 l_ok := true;
1029 if p_score_compute_mode then
1030 write(l_score_tab,
1031 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
1032 l_inst_dets(l_insttorrw_num).short_code,
1033 l_inst_dets(l_insttorrw_num).pk_id,
1034 ( l_per_cmbn_age_los * nvl(l_inst_dets(l_insttorrw_num).criteria_weight, 0) ) +
1035 nvl(l_inst_dets(l_insttorrw_num).criteria_score, 0) /* Bug 4449229 */
1036 );
1037 end if;
1038 --exit ;
1039 --
1040 elsif l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
1041 --
1042 l_rows_found := true;
1043 --
1044 end if;
1045 --
1046 end loop;
1047 --
1048 end if;
1049 --
1050 if l_crit_passed is null
1051 then
1052 if l_rows_found and
1053 not l_ok then
1054 --
1055 hr_utility.set_location('Failed Elig ',10);
1056 g_inelg_rsn_cd := 'AGL';
1057 fnd_message.set_name('BEN','BEN_91671_AGE_LOS_PRFL_FAIL');
1058 raise g_criteria_failed;
1059 --
1060 end if;
1061 end if;
1062 --
1063 if p_score_compute_mode
1064 then
1065 hr_utility.set_location('count '||l_score_tab.count,20);
1066 write(p_profile_score_tab,l_score_tab);
1067 end if;
1068 hr_utility.set_location('Leaving :'||l_proc,20);
1069 --
1070 end check_age_los_elig;
1071 --
1072 -- -----------------------------------------------------------
1073 -- This procedure determines eligibility based on comp level.
1074 -- -----------------------------------------------------------
1075 --
1076 procedure check_comp_level_rl_elig(p_eligy_prfl_id in number,
1077 p_person_id in number,
1078 p_business_group_id in number,
1079 p_effective_date in date,
1080 p_per_comp_val in number,
1081 p_eval_typ in varchar2,
1082 p_comp_obj_mode in boolean,
1083 p_lf_evt_ocrd_dt in date,
1084 p_score_compute_mode in boolean default false,
1085 p_profile_score_tab in out nocopy scoreTab,
1086 p_per_in_ler_id in number default null,
1087 p_pl_id in number default null,
1088 p_pgm_id in number default null,
1089 p_oipl_id in number default null,
1090 p_plip_id in number default null,
1091 p_opt_id in number default null) is
1092 --
1093 l_proc varchar2(100):=g_package||'check_comp_level_rl_elig';
1094 l_inst_dets ben_elp_cache.g_cache_elpecl_instor;
1095 l_inst_count number;
1096 l_insttorrw_num binary_integer;
1097 l_ok boolean := false;
1098 l_rows_found boolean := false;
1099 l_pl_id number;
1100 l_pgm_id number;
1101 l_per_in_ler_id number;
1102 l_oipl_id number;
1103 l_per_comp_val number := p_per_comp_val;
1104 l_crit_passed boolean;
1105 l_score_tab scoreTab;
1106 --
1107 begin
1108 --
1109 hr_utility.set_location('Entering: '||l_proc, 10);
1110 --
1111 -- Getting eligibility profile compensation level by eligibility profile
1112 --
1113 ben_elp_cache.elpecl_getcacdets
1114 (p_effective_date => nvl(l_fonm_cvg_strt_dt,p_effective_date)
1115 ,p_business_group_id => p_business_group_id
1116 ,p_comp_src_cd => 'RL'
1117 ,p_eligy_prfl_id => p_eligy_prfl_id
1118 ,p_inst_set => l_inst_dets
1119 ,p_inst_count => l_inst_count);
1120 --
1121 if l_inst_count > 0 then
1122 --
1123 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
1124 --
1125 if not p_comp_obj_mode or
1126 p_eval_typ <> 'E' then
1127 --
1128 ben_derive_factors.determine_compensation
1129 (p_person_id => p_person_id
1130 ,p_comp_lvl_fctr_id => l_inst_dets(l_insttorrw_num).comp_lvl_fctr_id
1131 ,p_pgm_id => p_pgm_id
1132 ,p_pl_id => p_pl_id
1133 ,p_oipl_id => p_oipl_id
1134 ,p_per_in_ler_id => p_per_in_ler_id
1135 ,p_comp_obj_mode => p_comp_obj_mode
1136 ,p_perform_rounding_flg => true
1137 ,p_effective_date => p_effective_date
1138 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
1139 ,p_business_group_id => p_business_group_id
1140 ,p_value => l_per_comp_val
1141 ,p_fonm_cvg_strt_dt => l_fonm_cvg_strt_dt );
1142 --
1143 end if;
1144 --
1145 l_ok := is_ok(l_per_comp_val
1146 ,l_inst_dets(l_insttorrw_num).mx_comp_val
1147 ,l_inst_dets(l_insttorrw_num).mn_comp_val
1148 ,l_inst_dets(l_insttorrw_num).no_mx_comp_flag
1149 ,l_inst_dets(l_insttorrw_num).no_mn_comp_flag
1150 );
1151 --
1152 if l_per_comp_val is null then
1153 --
1154 l_ok := false;
1155 --
1156 end if;
1157 --
1158 if l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
1159 --
1160 if p_score_compute_mode then
1161 if l_crit_passed is null then
1162 l_crit_passed := true;
1163 end if;
1164 write(l_score_tab,
1165 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
1166 l_inst_dets(l_insttorrw_num).short_code,
1167 l_inst_dets(l_insttorrw_num).pk_id,
1168 ( l_per_comp_val * nvl(l_inst_dets(l_insttorrw_num).criteria_weight, 0) ) +
1169 nvl(l_inst_dets(l_insttorrw_num).criteria_score, 0) /* Bug 4429071 */
1170 );
1171 else
1172 exit;
1173 end if;
1174 --
1175 elsif l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
1176 --
1177 l_rows_found := true;
1178 l_ok := false;
1179 exit;
1180 --
1181 elsif (not l_ok) and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
1182 --
1183 l_rows_found := true;
1184 l_ok := true;
1185 if p_score_compute_mode then
1186 write(l_score_tab,
1187 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
1188 l_inst_dets(l_insttorrw_num).short_code,
1189 l_inst_dets(l_insttorrw_num).pk_id,
1190 ( l_per_comp_val * nvl(l_inst_dets(l_insttorrw_num).criteria_weight, 0) ) +
1191 nvl(l_inst_dets(l_insttorrw_num).criteria_score, 0) /* Bug 4429071 */
1192 );
1193 end if;
1194 --exit ;
1195 --
1196 elsif l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
1197 --
1198 l_rows_found := true;
1199 --
1200 end if;
1201 --
1202 end loop;
1203 --
1204 end if;
1205 --
1206 if l_crit_passed is null
1207 then
1208 if l_rows_found and
1209 not l_ok then
1210 --
1211 g_inelg_rsn_cd := 'CMP';
1212 fnd_message.set_name('BEN','BEN_91672_COMP_LVL_PRFL_FAIL');
1213 hr_utility.set_location('Criteria Failed: '||l_proc,20);
1214 raise g_criteria_failed;
1215 --
1216 end if;
1217 end if;
1218 --
1219 hr_utility.set_location('Leaving :'||l_proc,20);
1220 --
1221 if p_score_compute_mode
1222 then
1223 hr_utility.set_location('count '||l_score_tab.count,20);
1224 write(p_profile_score_tab,l_score_tab);
1225 end if;
1226 end check_comp_level_rl_elig;
1227 --
1228 -- -----------------------------------------------------------
1229 -- This procedure determines eligibility based on comp level.
1230 -- -----------------------------------------------------------
1231 --
1232 procedure check_comp_level_elig(p_eligy_prfl_id in number,
1233 p_business_group_id in number,
1234 p_effective_date in date,
1235 p_comp_obj_mode in boolean,
1236 p_pgm_id in number,
1237 p_pl_id in number,
1238 p_oipl_id in number,
1239 p_per_in_ler_id in number,
1240 p_score_compute_mode in boolean default false,
1241 p_profile_score_tab in out nocopy scoreTab,
1242 p_person_id in number,
1243 p_per_comp_val in number) is
1244 --
1245 l_proc varchar2(100):=g_package||'check_comp_level_elig';
1246 l_inst_dets ben_elp_cache.g_cache_elpecl_instor;
1247 l_inst_count number;
1248 l_insttorrw_num binary_integer;
1249 l_ok boolean := false;
1250 l_rows_found boolean := false;
1251 l_per_comp_val number;
1252 l_crit_passed boolean;
1253 l_score_tab scoreTab;
1254 --
1255 begin
1256 --
1257 hr_utility.set_location('Entering: '||l_proc, 10);
1258 --
1259 -- Getting eligibility profile compensation level by eligibility profile
1260 --
1261 ben_elp_cache.elpecl_getcacdets
1262 (p_effective_date => nvl(l_fonm_cvg_strt_dt,p_effective_date)
1263 ,p_business_group_id => p_business_group_id
1264 ,p_comp_src_cd => 'STTDCOMP'
1265 ,p_eligy_prfl_id => p_eligy_prfl_id
1266 ,p_inst_set => l_inst_dets
1267 ,p_inst_count => l_inst_count);
1268 --
1269 if l_inst_count > 0 then
1270 --
1271 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
1272 --
1273 --if p_per_comp_val is null then
1274 --
1275 --fnd_message.set_name('BEN','BEN_91767_DERIVABLE_NO_EXIST');
1276 --raise ben_manage_life_events.g_record_error;
1277 --
1278 --end if;
1279 --
1280 -- as the derived factor may have periodicity, we need to compute the compensation
1281 -- based on periodicity before comparing for min and max value
1282 -- bug#2015717
1283 ben_derive_factors.determine_compensation
1284 (p_comp_lvl_fctr_id => l_inst_dets(l_insttorrw_num).comp_lvl_fctr_id,
1285 p_person_id => p_person_id,
1286 p_pgm_id => p_pgm_id,
1287 p_pl_id => p_pl_id,
1288 p_oipl_id => p_oipl_id,
1289 p_per_in_ler_id => p_per_in_ler_id,
1290 p_comp_obj_mode => p_comp_obj_mode,
1291 p_business_group_id => p_business_group_id,
1292 p_effective_date => p_effective_date,
1293 p_value => l_per_comp_val,
1294 p_fonm_cvg_strt_dt => l_fonm_cvg_strt_dt);
1295 --
1296 l_ok := is_ok(l_per_comp_val
1297 ,l_inst_dets(l_insttorrw_num).mx_comp_val
1298 ,l_inst_dets(l_insttorrw_num).mn_comp_val
1299 ,l_inst_dets(l_insttorrw_num).no_mx_comp_flag
1300 ,l_inst_dets(l_insttorrw_num).no_mn_comp_flag
1301 );
1302 --
1303 if l_per_comp_val is null then
1304 --
1305 l_ok := false;
1306 --
1307 end if;
1308 --
1309 if l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
1310 if p_score_compute_mode then
1311 if l_crit_passed is null then
1312 l_crit_passed := true;
1313 end if;
1314 write(l_score_tab,
1315 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
1316 l_inst_dets(l_insttorrw_num).short_code,
1317 l_inst_dets(l_insttorrw_num).pk_id,
1318 ( l_per_comp_val * nvl(l_inst_dets(l_insttorrw_num).criteria_weight, 0) ) +
1319 nvl(l_inst_dets(l_insttorrw_num).criteria_score, 0) /* Bug 4429071 */
1320 );
1321 else
1322 exit;
1323 end if;
1324 --
1325 elsif l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
1326 --
1327 l_rows_found := true;
1328 l_ok := false;
1329 exit;
1330 --
1331 elsif (not l_ok) and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
1332 --
1333 l_rows_found := true;
1334 l_ok := true;
1335 if p_score_compute_mode then
1336 write(l_score_tab,
1337 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
1338 l_inst_dets(l_insttorrw_num).short_code,
1339 l_inst_dets(l_insttorrw_num).pk_id,
1340 ( l_per_comp_val * nvl(l_inst_dets(l_insttorrw_num).criteria_weight, 0) ) +
1341 nvl(l_inst_dets(l_insttorrw_num).criteria_score, 0) /* Bug 4429071 */
1342 );
1343 end if;
1344 --exit ;
1345 --
1346 elsif l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
1347 --
1348 l_rows_found := true;
1349 --
1350 end if;
1351 --
1352 end loop;
1353 --
1354 end if;
1355 --
1356 if l_crit_passed is null
1357 then
1358 if l_rows_found and
1359 not l_ok then
1360 --
1361 g_inelg_rsn_cd := 'CMP';
1362 fnd_message.set_name('BEN','BEN_91672_COMP_LVL_PRFL_FAIL');
1363 hr_utility.set_location('Criteria Failed: '||l_proc,20);
1364 raise g_criteria_failed;
1365 --
1366 end if;
1367 end if;
1368 --
1369 hr_utility.set_location('Leaving :'||l_proc,20);
1370 --
1371 if p_score_compute_mode
1372 then
1373 hr_utility.set_location('count '||l_score_tab.count,20);
1374 write(p_profile_score_tab,l_score_tab);
1375 end if;
1376 end check_comp_level_elig;
1377 --
1378 -- --------------------------------------------------------------------
1379 -- This procedure determines eligibility based on hours wkd benefits
1380 -- balance.
1381 -- --------------------------------------------------------------------
1382 --
1383 procedure check_hrs_wkd_ben_bal(p_person_id in number,
1384 p_assignment_id in number,
1385 p_eligy_prfl_id in number,
1386 p_once_r_cntug_cd in varchar2,
1387 p_elig_flag in varchar2,
1388 p_business_group_id in number,
1389 p_comp_obj_mode in boolean,
1390 p_lf_evt_ocrd_dt in date,
1391 p_score_compute_mode in boolean default false,
1392 p_profile_score_tab in out nocopy scoreTab,
1393 p_effective_date in date,
1394 p_per_hrs_wkd in number) is
1395 --
1396 l_proc varchar2(100):= g_package||'check_hrs_wkd_ben_bal';
1397 l_inst_dets ben_elp_cache.g_cache_elpehw_instor;
1398 l_inst_count number;
1399 l_insttorrw_num binary_integer;
1400 l_ok boolean := false;
1401 l_rows_found boolean := false;
1402 l_per_hrs_wkd number := p_per_hrs_wkd;
1403 l_crit_passed boolean;
1404 l_score_tab scoreTab;
1405 --
1406 begin
1407 --
1408 hr_utility.set_location('Entering :'||l_proc,10);
1409 --
1410 -- Check if we need to test this business rule at all
1411 --
1412 hr_utility.set_location('Elig Flag :'||p_elig_flag,10);
1413 hr_utility.set_location('Once r Cntug Cd :'||p_once_r_cntug_cd,10);
1414 --
1415 if p_elig_flag = 'Y' and
1416 nvl(p_once_r_cntug_cd,'-1') = 'ONCE' then
1417 --
1418 return;
1419 --
1420 end if;
1421 --
1422 -- Getting hours worked profile information
1423 --
1424 ben_elp_cache.elpehw_getcacdets
1425 (p_effective_date => p_effective_date
1426 ,p_business_group_id => p_business_group_id
1427 ,p_hrs_src_cd => 'BNFTBALTYP'
1428 ,p_eligy_prfl_id => p_eligy_prfl_id
1429 ,p_inst_set => l_inst_dets
1430 ,p_inst_count => l_inst_count);
1431 --
1432 hr_utility.set_location('Inst Count :'||l_inst_count,10);
1433 --
1434 if l_inst_count > 0 then
1435 --
1436
1437 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
1438 --
1439 --if p_per_hrs_wkd is null then
1440 --
1441 --fnd_message.set_name('BEN','BEN_91767_DERIVABLE_NO_EXIST');
1442 --raise ben_manage_life_events.g_record_error;
1443 --
1444 --end if;
1445 --
1446 if not p_comp_obj_mode then
1447 ben_derive_factors.determine_hours_worked
1448 (p_person_id => p_person_id,
1449 p_assignment_id => p_assignment_id,
1450 p_hrs_wkd_in_perd_fctr_id =>
1451 l_inst_dets(l_insttorrw_num).hrs_wkd_in_perd_fctr_id,
1452 p_comp_obj_mode => p_comp_obj_mode,
1453 p_effective_date => p_effective_date,
1454 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
1455 p_business_group_id => p_business_group_id,
1456 p_value => l_per_hrs_wkd,
1457 p_fonm_cvg_strt_dt => l_fonm_cvg_strt_dt );
1458 end if;
1459
1460 l_ok := is_ok(l_per_hrs_wkd
1461 ,l_inst_dets(l_insttorrw_num).mx_hrs_num
1462 ,l_inst_dets(l_insttorrw_num).mn_hrs_num
1463 ,l_inst_dets(l_insttorrw_num).no_mx_hrs_wkd_flag
1464 ,l_inst_dets(l_insttorrw_num).no_mn_hrs_wkd_flag
1465 );
1466 --
1467 if l_per_hrs_wkd is null then
1468 --
1469 l_ok := false;
1470 --
1471 end if;
1472 --
1473 if l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
1474 --
1475 if p_score_compute_mode then
1476 if l_crit_passed is null then
1477 l_crit_passed := true;
1478 end if;
1479 write(l_score_tab,
1480 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
1481 l_inst_dets(l_insttorrw_num).short_code,
1482 l_inst_dets(l_insttorrw_num).pk_id,
1483 ( l_per_hrs_wkd * nvl(l_inst_dets(l_insttorrw_num).criteria_weight, 0) ) +
1484 nvl(l_inst_dets(l_insttorrw_num).criteria_score, 0) /* Bug 4429071 */
1485 );
1486 else
1487 exit;
1488 end if;
1489 --
1490 elsif l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
1491 --
1492 l_rows_found := true;
1493 l_ok := false;
1494 exit;
1495 --
1496 elsif (not l_ok) and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
1497 --
1498 l_rows_found := true;
1499 l_ok := true;
1500 if p_score_compute_mode then
1501 write(l_score_tab,
1502 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
1503 l_inst_dets(l_insttorrw_num).short_code,
1504 l_inst_dets(l_insttorrw_num).pk_id,
1505 ( l_per_hrs_wkd * nvl(l_inst_dets(l_insttorrw_num).criteria_weight, 0) ) +
1506 nvl(l_inst_dets(l_insttorrw_num).criteria_score, 0) /* Bug 4429071 */
1507 );
1508 end if;
1509 --exit ;
1510 --
1511 elsif l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
1512 --
1513 l_rows_found := true;
1514 --
1515 end if;
1516 --
1517 end loop;
1518 --
1519 end if;
1520 --
1521 if l_crit_passed is null
1522 then
1523 if l_rows_found and
1524 not l_ok then
1525 --
1526 g_inelg_rsn_cd := 'HRS';
1527 fnd_message.set_name('BEN','BEN_91673_HRS_WKD_PRFL_FAIL');
1528 hr_utility.set_location('Criteria Failed: '||l_proc,20);
1529 raise g_criteria_failed;
1530 --
1531 end if;
1532 end if;
1533 --
1534 hr_utility.set_location('Leaving :'||l_proc,20);
1535 --
1536 if p_score_compute_mode
1537 then
1538 hr_utility.set_location('count '||l_score_tab.count,20);
1539 write(p_profile_score_tab,l_score_tab);
1540 end if;
1541 end check_hrs_wkd_ben_bal;
1542 --
1543 -- --------------------------------------------------------------------
1544 -- This procedure determines eligibility based on hours wkd balance.
1545 -- --------------------------------------------------------------------
1546 --
1547 procedure check_hrs_wkd_rl_balance(p_person_id in number,
1548 p_assignment_id in number,
1549 p_eligy_prfl_id in number,
1550 p_once_r_cntug_cd in varchar2,
1551 p_elig_flag in varchar2,
1552 p_business_group_id in number,
1553 p_comp_obj_mode in boolean,
1554 p_lf_evt_ocrd_dt in date,
1555 p_score_compute_mode in boolean default false,
1556 p_profile_score_tab in out nocopy scoreTab,
1557 p_effective_date in date,
1558 p_per_hrs_wkd in number) is
1559 --
1560 l_proc varchar2(100):= g_package||'check_hrs_wkd_balance';
1561 l_inst_dets ben_elp_cache.g_cache_elpehw_instor;
1562 l_inst_count number;
1563 l_insttorrw_num binary_integer;
1564 l_ok boolean := false;
1565 l_rows_found boolean := false;
1566 l_per_hrs_wkd number := p_per_hrs_wkd;
1567 l_crit_passed boolean;
1568 l_score_tab scoreTab;
1569 --
1570 begin
1571 --
1572 hr_utility.set_location('Entering :'||l_proc,10);
1573 --
1574 if p_elig_flag = 'Y' and
1575 nvl(p_once_r_cntug_cd,'-1') = 'ONCE' then
1576 --
1577 return;
1578 --
1579 end if;
1580 --
1581 -- Getting hours worked profile information
1582 --
1583 ben_elp_cache.elpehw_getcacdets
1584 (p_effective_date => p_effective_date
1585 ,p_business_group_id => p_business_group_id
1586 ,p_hrs_src_cd => 'RL'
1587 ,p_eligy_prfl_id => p_eligy_prfl_id
1588 ,p_inst_set => l_inst_dets
1589 ,p_inst_count => l_inst_count);
1590 --
1591 if l_inst_count > 0 then
1592 --
1593 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
1594 --
1595 --if p_per_hrs_wkd is null then
1596 --
1597 --fnd_message.set_name('BEN','BEN_91767_DERIVABLE_NO_EXIST');
1598 --raise ben_manage_life_events.g_record_error;
1599 --
1600 --end if;
1601 --
1602 if not p_comp_obj_mode then
1603 ben_derive_factors.determine_hours_worked
1604 (p_person_id => p_person_id,
1605 p_assignment_id => p_assignment_id,
1606 p_hrs_wkd_in_perd_fctr_id =>
1607 l_inst_dets(l_insttorrw_num).hrs_wkd_in_perd_fctr_id,
1608 p_comp_obj_mode => p_comp_obj_mode,
1609 p_effective_date => p_effective_date,
1610 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
1611 p_business_group_id => p_business_group_id,
1612 p_value => l_per_hrs_wkd,
1613 p_fonm_cvg_strt_dt => l_fonm_cvg_strt_dt );
1614 end if;
1615 l_ok := is_ok(l_per_hrs_wkd
1616 ,l_inst_dets(l_insttorrw_num).mx_hrs_num
1617 ,l_inst_dets(l_insttorrw_num).mn_hrs_num
1618 ,l_inst_dets(l_insttorrw_num).no_mx_hrs_wkd_flag
1619 ,l_inst_dets(l_insttorrw_num).no_mn_hrs_wkd_flag
1620 );
1621 --
1622 if l_per_hrs_wkd is null then
1623 --
1624 l_ok := false;
1625 --
1626 end if;
1627 --
1628 if l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
1629 --
1630 if p_score_compute_mode then
1631 if l_crit_passed is null then
1632 l_crit_passed := true;
1633 end if;
1634 write(l_score_tab,
1635 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
1636 l_inst_dets(l_insttorrw_num).short_code,
1637 l_inst_dets(l_insttorrw_num).pk_id,
1638 ( l_per_hrs_wkd * nvl(l_inst_dets(l_insttorrw_num).criteria_weight, 0) ) +
1639 nvl(l_inst_dets(l_insttorrw_num).criteria_score, 0) /* Bug 4429071 */
1640 );
1641 else
1642 exit;
1643 end if;
1644 --
1645 elsif l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
1646 --
1647 l_rows_found := true;
1648 l_ok := false;
1649 exit;
1650 --
1651 elsif (not l_ok) and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
1652 --
1653 l_rows_found := true;
1654 l_ok := true;
1655 if p_score_compute_mode then
1656 write(l_score_tab,
1657 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
1658 l_inst_dets(l_insttorrw_num).short_code,
1659 l_inst_dets(l_insttorrw_num).pk_id,
1660 ( l_per_hrs_wkd * nvl(l_inst_dets(l_insttorrw_num).criteria_weight, 0) ) +
1661 nvl(l_inst_dets(l_insttorrw_num).criteria_score, 0) /* Bug 4429071 */
1662 );
1663 end if;
1664 --exit ;
1665 --
1666 elsif l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
1667 --
1668 l_rows_found := true;
1669 --
1670 end if;
1671 --
1672 end loop;
1673 --
1674 end if;
1675 --
1676 if l_crit_passed is null
1677 then
1678 if l_rows_found and
1679 not l_ok then
1680 --
1681 g_inelg_rsn_cd := 'HRS';
1682 fnd_message.set_name('BEN','BEN_91673_HRS_WKD_PRFL_FAIL');
1683 hr_utility.set_location('Criteria Failed: '||l_proc,20);
1684 raise g_criteria_failed;
1685 --
1686 end if;
1687 end if;
1688 --
1689 if p_score_compute_mode
1690 then
1691 hr_utility.set_location('count '||l_score_tab.count,20);
1692 write(p_profile_score_tab,l_score_tab);
1693 end if;
1694 hr_utility.set_location('Leaving :'||l_proc,20);
1695 --
1696 end check_hrs_wkd_rl_balance;
1697 --
1698 -- --------------------------------------------------------------------
1699 -- This procedure determines eligibility based on hours wkd balance.
1700 -- --------------------------------------------------------------------
1701 --
1702 procedure check_hrs_wkd_balance(p_person_id in number,
1703 p_assignment_id in number,
1704 p_eligy_prfl_id in number,
1705 p_once_r_cntug_cd in varchar2,
1706 p_elig_flag in varchar2,
1707 p_business_group_id in number,
1708 p_comp_obj_mode in boolean,
1709 p_lf_evt_ocrd_dt in date,
1710 p_score_compute_mode in boolean default false,
1711 p_profile_score_tab in out nocopy scoreTab,
1712 p_effective_date in date,
1713 p_per_hrs_wkd in number) is
1714 --
1715 l_proc varchar2(100):= g_package||'check_hrs_wkd_balance';
1716 l_inst_dets ben_elp_cache.g_cache_elpehw_instor;
1717 l_inst_count number;
1718 l_insttorrw_num binary_integer;
1719 l_ok boolean := false;
1720 l_rows_found boolean := false;
1721 l_per_hrs_wkd number := p_per_hrs_wkd;
1722 l_crit_passed boolean;
1723 l_score_tab scoreTab;
1724 --
1725 begin
1726 --
1727 hr_utility.set_location('Entering :'||l_proc,10);
1728 --
1729 if p_elig_flag = 'Y' and
1730 nvl(p_once_r_cntug_cd,'-1') = 'ONCE' then
1731 --
1732 return;
1733 --
1734 end if;
1735 --
1736 -- Getting hours worked profile information
1737 --
1738 ben_elp_cache.elpehw_getcacdets
1739 (p_effective_date => p_effective_date
1740 ,p_business_group_id => p_business_group_id
1741 ,p_hrs_src_cd => 'BALTYP'
1742 ,p_eligy_prfl_id => p_eligy_prfl_id
1743 ,p_inst_set => l_inst_dets
1744 ,p_inst_count => l_inst_count);
1745 --
1746 if l_inst_count > 0 then
1747 --
1748 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
1749 --
1750 --if p_per_hrs_wkd is null then
1751 --
1752 --fnd_message.set_name('BEN','BEN_91767_DERIVABLE_NO_EXIST');
1753 --raise ben_manage_life_events.g_record_error;
1754 --
1755 --end if;
1756 --
1757 if not p_comp_obj_mode then
1758 ben_derive_factors.determine_hours_worked
1759 (p_person_id => p_person_id,
1760 p_assignment_id => p_assignment_id,
1761 p_hrs_wkd_in_perd_fctr_id =>
1762 l_inst_dets(l_insttorrw_num).hrs_wkd_in_perd_fctr_id,
1763 p_comp_obj_mode => p_comp_obj_mode,
1764 p_effective_date => p_effective_date,
1765 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
1766 p_business_group_id => p_business_group_id,
1767 p_value => l_per_hrs_wkd,
1768 p_fonm_cvg_strt_dt => l_fonm_cvg_strt_dt );
1769 end if;
1770 l_ok := is_ok(l_per_hrs_wkd
1771 ,l_inst_dets(l_insttorrw_num).mx_hrs_num
1772 ,l_inst_dets(l_insttorrw_num).mn_hrs_num
1773 ,l_inst_dets(l_insttorrw_num).no_mx_hrs_wkd_flag
1774 ,l_inst_dets(l_insttorrw_num).no_mn_hrs_wkd_flag
1775 );
1776 --
1777 if l_per_hrs_wkd is null then
1778 --
1779 l_ok := false;
1780 --
1781 end if;
1782 --
1783 if l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
1784 if p_score_compute_mode then
1785 if l_crit_passed is null then
1786 l_crit_passed := true;
1787 end if;
1788 write(l_score_tab,
1789 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
1790 l_inst_dets(l_insttorrw_num).short_code,
1791 l_inst_dets(l_insttorrw_num).pk_id,
1792 ( l_per_hrs_wkd * nvl(l_inst_dets(l_insttorrw_num).criteria_weight, 0) ) +
1793 nvl(l_inst_dets(l_insttorrw_num).criteria_score, 0) /* Bug 4429071 */
1794 );
1795 else
1796 exit;
1797 end if;
1798 --
1799 elsif l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
1800 --
1801 l_rows_found := true;
1802 l_ok := false;
1803 exit;
1804 --
1805 elsif (not l_ok) and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
1806 --
1807 l_rows_found := true;
1808 l_ok := true;
1809 if p_score_compute_mode then
1810 write(l_score_tab,
1811 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
1812 l_inst_dets(l_insttorrw_num).short_code,
1813 l_inst_dets(l_insttorrw_num).pk_id,
1814 ( l_per_hrs_wkd * nvl(l_inst_dets(l_insttorrw_num).criteria_weight, 0) ) +
1815 nvl(l_inst_dets(l_insttorrw_num).criteria_score, 0) /* Bug 4429071 */
1816 );
1817 end if;
1818 --exit ;
1819 --
1820 elsif l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
1821 --
1822 l_rows_found := true;
1823 --
1824 end if;
1825 --
1826 end loop;
1827 --
1828 end if;
1829 --
1830 if l_crit_passed is null
1831 then
1832 if l_rows_found and
1833 not l_ok then
1834 --
1835 g_inelg_rsn_cd := 'HRS';
1836 fnd_message.set_name('BEN','BEN_91673_HRS_WKD_PRFL_FAIL');
1837 hr_utility.set_location('Criteria Failed: '||l_proc,20);
1838 raise g_criteria_failed;
1839 --
1840 end if;
1841 end if;
1842 --
1843 if p_score_compute_mode
1844 then
1845 hr_utility.set_location('count '||l_score_tab.count,20);
1846 write(p_profile_score_tab,l_score_tab);
1847 end if;
1848 hr_utility.set_location('Leaving :'||l_proc,20);
1849 --
1850 end check_hrs_wkd_balance;
1851 --
1852 -- -----------------------------------------------------------------
1853 -- This procedure determines eligibility based on percent fulltime.
1854 -- -----------------------------------------------------------------
1855 --
1856 procedure check_pct_fltm_elig(p_person_id in number,
1857 p_assignment_id in number,
1858 p_eligy_prfl_id in number,
1859 p_business_group_id in number,
1860 p_evl_typ in varchar2,
1861 p_comp_obj_mode in boolean,
1862 p_lf_evt_ocrd_dt in date,
1863 p_score_compute_mode in boolean default false,
1864 p_profile_score_tab in out nocopy scoreTab,
1865 p_effective_date in date,
1866 p_per_pct_ft_val in number) is
1867 --
1868 l_proc varchar2(100):=g_package||'check_pct_fltm_elig';
1869 l_inst_dets ben_elp_cache.g_cache_elpepf_instor;
1870 l_inst_count number;
1871 l_insttorrw_num binary_integer;
1872 l_ok boolean := false;
1873 l_rows_found boolean := false;
1874 l_per_pct_ft_val number := p_per_pct_ft_val;
1875 l_crit_passed boolean;
1876 l_score_tab scoreTab;
1877 --
1878 begin
1879 --
1880 hr_utility.set_location('Entering :'||l_proc,10);
1881 --
1882 -- Getting eligibility profile full time by eligibility profile
1883 --
1884 ben_elp_cache.elpepf_getcacdets
1885 (p_effective_date => p_effective_date
1886 ,p_business_group_id => p_business_group_id
1887 ,p_eligy_prfl_id => p_eligy_prfl_id
1888 ,p_inst_set => l_inst_dets
1889 ,p_inst_count => l_inst_count);
1890 --
1891 if l_inst_count > 0 then
1892 --
1893 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
1894 --
1895 if not p_comp_obj_mode then
1896 ben_derive_factors.determine_pct_fulltime
1897 (p_person_id => p_person_id,
1898 p_assignment_id => p_assignment_id,
1899 p_pct_fl_tm_fctr_id =>
1900 l_inst_dets(l_insttorrw_num).pct_fl_tm_fctr_id,
1901 p_comp_obj_mode => p_comp_obj_mode,
1902 p_effective_date => p_effective_date,
1903 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
1904 p_business_group_id => p_business_group_id,
1905 p_value => l_per_pct_ft_val,
1906 p_fonm_cvg_strt_dt => l_fonm_cvg_strt_dt );
1907 end if;
1908 --
1909 l_ok := is_ok(l_per_pct_ft_val
1910 ,l_inst_dets(l_insttorrw_num).mx_pct_val
1911 ,l_inst_dets(l_insttorrw_num).mn_pct_val
1912 ,l_inst_dets(l_insttorrw_num).no_mx_pct_val_flag
1913 ,l_inst_dets(l_insttorrw_num).no_mn_pct_val_flag
1914 ,'Y'
1915 );
1916 --
1917 if l_per_pct_ft_val is null then
1918 --
1919 l_ok := false;
1920 --
1921 end if;
1922 --
1923 if l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
1924 --
1925 if p_score_compute_mode then
1926 if l_crit_passed is null then
1927 l_crit_passed := true;
1928 end if;
1929 write(l_score_tab,
1930 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
1931 l_inst_dets(l_insttorrw_num).short_code,
1932 l_inst_dets(l_insttorrw_num).pk_id,
1933 ( l_per_pct_ft_val * nvl(l_inst_dets(l_insttorrw_num).criteria_weight, 0) ) +
1934 nvl(l_inst_dets(l_insttorrw_num).criteria_score, 0) /* Bug 4429071 */
1935 );
1936 else
1937 exit;
1938 end if;
1939 --
1940 elsif l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
1941 --
1942 l_rows_found := true;
1943 l_ok := false;
1944 exit;
1945 --
1946 elsif (not l_ok) and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
1947 --
1948 l_rows_found := true;
1949 l_ok := true;
1950 if p_score_compute_mode then
1951 write(l_score_tab,
1952 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
1953 l_inst_dets(l_insttorrw_num).short_code,
1954 l_inst_dets(l_insttorrw_num).pk_id,
1955 ( l_per_pct_ft_val * nvl(l_inst_dets(l_insttorrw_num).criteria_weight, 0) ) +
1956 nvl(l_inst_dets(l_insttorrw_num).criteria_score, 0) /* Bug 4429071 */
1957 );
1958 end if;
1959 --exit ;
1960 --
1961 elsif l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
1962 --
1963 l_rows_found := true;
1964 --
1965 end if;
1966 --
1967 end loop;
1968 --
1969 end if;
1970 --
1971 if l_crit_passed is null
1972 then
1973 if l_rows_found and
1974 not l_ok then
1975 --
1976 g_inelg_rsn_cd := 'PFT';
1977 fnd_message.set_name('BEN','BEN_91674_PCT_FT_PRFL_FAIL');
1978 hr_utility.set_location('Criteria Failed: '||l_proc,20);
1979 raise g_criteria_failed;
1980 --
1981 end if;
1982 end if;
1983 --
1984 if p_score_compute_mode
1985 then
1986 hr_utility.set_location('count '||l_score_tab.count,20);
1987 write(p_profile_score_tab,l_score_tab);
1988 end if;
1989 hr_utility.set_location('Leaving :'||l_proc,20);
1990 --
1991 end check_pct_fltm_elig;
1992 --
1993 -- ------------------------------------------------------
1994 -- This procedure determines eligibility based on grade.
1995 -- ------------------------------------------------------
1996 --
1997 procedure check_grade_elig(p_eligy_prfl_id in number,
1998 p_business_group_id in number,
1999 p_score_compute_mode in boolean default false,
2000 p_profile_score_tab in out nocopy scoreTab,
2001 p_effective_date in date,
2002 p_grade_id in number) is
2003 --
2004 l_proc varchar2(100) := g_package||'check_grade_elig';
2005 l_inst_dets ben_elp_cache.g_cache_elpegr_instor;
2006 l_inst_count number;
2007 l_insttorrw_num binary_integer;
2008 l_ok boolean := false;
2009 l_rows_found boolean := false;
2010 l_crit_passed boolean;
2011 l_score_tab scoreTab;
2012 --
2013 begin
2014 --
2015 hr_utility.set_location('Entering : '||l_proc,10);
2016 --
2017 -- Getting eligibility profile grade by eligibility profile
2018 --
2019 ben_elp_cache.elpegr_getcacdets
2020 (p_effective_date => p_effective_date
2021 ,p_business_group_id => p_business_group_id
2022 ,p_eligy_prfl_id => p_eligy_prfl_id
2023 ,p_inst_set => l_inst_dets
2024 ,p_inst_count => l_inst_count
2025 );
2026 --
2027 if l_inst_count > 0 then
2028 --
2029 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
2030 --
2031 hr_utility.set_location('GRADE'||p_grade_id,10);
2032 hr_utility.set_location('COMPARE GRADE'||l_inst_dets(l_insttorrw_num).grade_id,10);
2033 l_ok := nvl((nvl(p_grade_id,-1) = l_inst_dets(l_insttorrw_num).grade_id),FALSE);
2034 --if l_ok is null then
2035 -- l_ok:=false;
2036 --end if;
2037 --
2038 if l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
2039 --
2040 if p_score_compute_mode then
2041 if l_crit_passed is null then
2042 l_crit_passed := true;
2043 end if;
2044 write(l_score_tab,
2045 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
2046 l_inst_dets(l_insttorrw_num).short_code,
2047 l_inst_dets(l_insttorrw_num).pk_id,
2048 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
2049 l_inst_dets(l_insttorrw_num).criteria_weight));
2050 else
2051 exit;
2052 end if;
2053 --
2054 elsif l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
2055 --
2056 l_rows_found := true;
2057 l_ok := false;
2058 exit;
2059 --
2060 elsif (not l_ok) and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
2061 --
2062 l_rows_found := true;
2063 l_ok := true;
2064 if p_score_compute_mode then
2065 write(l_score_tab,
2066 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
2067 l_inst_dets(l_insttorrw_num).short_code,
2068 l_inst_dets(l_insttorrw_num).pk_id,
2069 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
2070 l_inst_dets(l_insttorrw_num).criteria_weight));
2071 end if;
2072 --exit ;
2073 --
2074 elsif l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
2075 --
2076 l_rows_found := true;
2077 --
2078 end if;
2079 --
2080 end loop;
2081 --
2082 end if;
2083 --
2084 if l_crit_passed is null
2085 then
2086 if l_rows_found and
2087 not l_ok then
2088 --
2089 g_inelg_rsn_cd := 'GRD';
2090 fnd_message.set_name('BEN','BEN_91675_GRD_PRFL_FAIL');
2091 hr_utility.set_location('Criteria Failed: '||l_proc,20);
2092 raise g_criteria_failed;
2093 --
2094 end if;
2095 end if;
2096 --
2097 if p_score_compute_mode
2098 then
2099 hr_utility.set_location('count '||l_score_tab.count,20);
2100 write(p_profile_score_tab,l_score_tab);
2101 end if;
2102 hr_utility.set_location('Leaving: '||l_proc,20);
2103 --
2104 end check_grade_elig;
2105 --
2106 -- ------------------------------------------------------
2107 -- This procedure determines eligibility based on sex.
2108 -- ------------------------------------------------------
2109 --
2110 procedure check_gender_elig(p_eligy_prfl_id in number,
2111 p_business_group_id in number,
2112 p_score_compute_mode in boolean default false,
2113 p_profile_score_tab in out nocopy scoreTab,
2114 p_effective_date in date,
2115 p_sex in varchar2) is
2116 --
2117 l_proc varchar2(100) := g_package||'check_gender_elig';
2118 l_inst_dets ben_elp_cache.g_cache_elpegn_instor;
2119 l_inst_count number;
2120 l_insttorrw_num binary_integer;
2121 l_ok boolean := false;
2122 l_rows_found boolean := false;
2123 l_crit_passed boolean;
2124 l_score_tab scoreTab;
2125 --
2126 begin
2127 --
2128 hr_utility.set_location('Entering : '||l_proc,10);
2129 --
2130 -- Getting eligibility profile sex by eligibility profile
2131 --
2132 ben_elp_cache.elpegn_getcacdets
2133 (p_effective_date => p_effective_date
2134 ,p_business_group_id => p_business_group_id
2135 ,p_eligy_prfl_id => p_eligy_prfl_id
2136 ,p_inst_set => l_inst_dets
2137 ,p_inst_count => l_inst_count
2138 );
2139 --
2140 if l_inst_count > 0 then
2141 --
2142 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
2143 --
2144 hr_utility.set_location('SEX'||p_sex,10);
2145 l_ok := nvl((nvl(p_sex,'zz') = l_inst_dets(l_insttorrw_num).sex),FALSE);
2146 --
2147 if l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
2148 if p_score_compute_mode then
2149 if l_crit_passed is null then
2150 l_crit_passed := true;
2151 end if;
2152 write(l_score_tab,
2153 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
2154 l_inst_dets(l_insttorrw_num).short_code,
2155 l_inst_dets(l_insttorrw_num).pk_id,
2156 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
2157 l_inst_dets(l_insttorrw_num).criteria_weight));
2158 else
2159 exit;
2160 end if;
2161 --
2162 elsif l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
2163 --
2164 l_rows_found := true;
2165 l_ok := false;
2166 exit;
2167 --
2168 elsif (not l_ok) and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
2169 --
2170 l_rows_found := true;
2171 l_ok := true;
2172 if p_score_compute_mode then
2173 write(l_score_tab,
2174 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
2175 l_inst_dets(l_insttorrw_num).short_code,
2176 l_inst_dets(l_insttorrw_num).pk_id,
2177 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
2178 l_inst_dets(l_insttorrw_num).criteria_weight));
2179 end if;
2180 --exit ;
2181 --
2182 elsif l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
2183 --
2184 l_rows_found := true;
2185 --
2186 end if;
2187 --
2188 end loop;
2189 --
2190 end if;
2191 --
2192 if l_crit_passed is null
2193 then
2194 if l_rows_found and
2195 not l_ok then
2196 --
2197 g_inelg_rsn_cd := 'GND';
2198 fnd_message.set_name('BEN','BEN_91675_GND_PRFL_FAIL');
2199 hr_utility.set_location('Criteria Failed: '||l_proc,20);
2200 raise g_criteria_failed;
2201 --
2202 end if;
2203 end if;
2204 --
2205 if p_score_compute_mode
2206 then
2207 hr_utility.set_location('count '||l_score_tab.count,20);
2208 write(p_profile_score_tab,l_score_tab);
2209 end if;
2210 hr_utility.set_location('Leaving: '||l_proc,20);
2211 --
2212 end check_gender_elig;
2213 --
2214 -- ------------------------------------------------------
2215 -- This procedure determines eligibility based on rules.
2216 -- ------------------------------------------------------
2217 --
2218 procedure check_rule_elig
2219 (p_person_id in number
2220 ,p_business_group_id in number
2221 ,p_pgm_id in number
2222 ,p_pl_id in number
2223 ,p_oipl_id in number
2224 -- Added ler_id to call RCHASE 17-JUL-2000 Bug#5392
2225 ,p_ler_id in number
2226 ,p_eligy_prfl_id in number
2227 ,p_effective_date in date
2228 ,p_score_compute_mode in boolean default false
2229 ,p_profile_score_tab in out nocopy scoreTab
2230 ,p_assignment_id in number
2231 -- Bug# 2424041
2232 ,p_pl_typ_id in number
2233 ,p_organization_id in number
2234 )
2235 is
2236 --
2237 cursor c_ff_use_asg(cv_formula_id in number) is
2238 select 'Y'
2239 from ff_fdi_usages_f
2240 where FORMULA_ID = cv_formula_id
2241 and ITEM_NAME = 'ASSIGNMENT_ID'
2242 and usage = 'U';
2243 --
2244 l_proc varchar2(100) := g_package||'check_rule_elig';
2245 l_inst_dets ben_elp_cache.g_cache_elperl_instor;
2246 l_inst_count number;
2247 l_insttorrw_num binary_integer;
2248 l_ok boolean := false;
2249 l_rows_found boolean := false;
2250 l_output ff_exec.outputs_t;
2251 l_eligible varchar2(30);
2252 l_oipl_rec ben_cobj_cache.g_oipl_inst_row;
2253 l_ff_use_asg_id_flag varchar2(1);
2254 l_ben_elgy_prfl_rl_Cond varchar2(30) := 'A' ;
2255 l_crit_passed boolean;
2256 l_score_tab scoreTab;
2257 --
2258 begin
2259 --
2260 hr_utility.set_location('Entering : '||l_proc,10);
2261 --
2262 -- Getting eligibility profile rule by eligibility profile
2263 --
2264
2265 ben_elp_cache.elperl_getcacdets
2266 (p_effective_date => p_effective_date
2267 ,p_business_group_id => p_business_group_id
2268 ,p_eligy_prfl_id => p_eligy_prfl_id
2269 ,p_inst_set => l_inst_dets
2270 ,p_inst_count => l_inst_count);
2271 --
2272 if l_inst_count > 0 then
2273 --find the profile value for formul and/Or # 2508757\
2274 l_ben_elgy_prfl_rl_Cond := fnd_profile.value('BEN_ELGY_PRFL_RL_COND');
2275 --
2276 hr_utility.set_location('assignment_id='||p_assignment_id,1963);
2277 hr_utility.set_location('l_ben_elgy_prfl_rl_Cond='||l_ben_elgy_prfl_rl_Cond,1963);
2278 --
2279 if p_oipl_id is not null then
2280 --
2281 l_oipl_rec := ben_cobj_cache.g_oipl_currow;
2282 --
2283 end if;
2284 --
2285 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
2286 --
2287 -- Bug : 5059 : If the person have no assignment id, and formula
2288 -- uses data base items based on assignment id, then formula raises
2289 -- error like : A SQL SELECT statement, obtained from the application
2290 -- dictionary returned no rows. If assignement id is null and formula
2291 -- uses any DBI's which depend on it, make the person ineligible.
2292 --
2293 if p_assignment_id is null then
2294 --
2295 l_ff_use_asg_id_flag := 'N';
2296 open c_ff_use_asg(l_inst_dets(l_insttorrw_num).formula_id);
2297 fetch c_ff_use_asg into l_ff_use_asg_id_flag;
2298 close c_ff_use_asg;
2299 --
2300 if l_ff_use_asg_id_flag = 'Y'
2301 then
2302 --
2303 g_inelg_rsn_cd := 'ERL';
2304 fnd_message.set_name('BEN','BEN_92445_ERL_PRFL_FAIL');
2305 hr_utility.set_location('Criteria Failed: '||l_proc,19);
2306 raise g_criteria_failed;
2307 --
2308 end if;
2309 --
2310 end if;
2311 --
2312 -- New param1 added for bug # 2679854
2313 l_output :=
2314 benutils.formula
2315 (p_formula_id => l_inst_dets(l_insttorrw_num).formula_id,
2316 p_assignment_id => p_assignment_id,
2317 p_business_group_id => p_business_group_id,
2318 p_pgm_id => p_pgm_id,
2319 p_pl_id => p_pl_id,
2320 -- Added ler_id to call RCHASE 17-JUL-2000 Bug#5392
2321 p_ler_id => p_ler_id,
2322 p_opt_id => l_oipl_rec.opt_id,
2323 -- bug 2424041
2324 p_pl_typ_id => p_pl_typ_id,
2325 p_organization_id => p_organization_id,
2326 p_effective_date => p_effective_date,
2327 p_param1 => 'BEN_ELP_I_ELIGY_PRFL_ID',
2328 p_param1_value => to_char(nvl(p_eligy_prfl_id, -1)),
2329 p_param2 => 'BEN_IV_RT_STRT_DT',
2330 p_param2_value => fnd_date.date_to_canonical(ben_manage_life_events.g_fonm_rt_strt_dt),
2331 p_param3 => 'BEN_IV_CVG_STRT_DT',
2332 p_param3_value => fnd_date.date_to_canonical(l_fonm_cvg_strt_dt),
2333 p_param4 => 'BEN_IV_PERSON_ID', -- Bug 5331889 : Added person_id param as well
2334 p_param4_value => to_char(p_person_id)
2335 );
2336
2337 --
2338 for l_count in l_output.first..l_output.last loop
2339 --
2340 begin
2341 --
2342 if l_output(l_count).name = 'ELIGIBLE' then
2343 --
2344 l_eligible := l_output(l_count).value;
2345 --
2346 else
2347 --
2348 -- Account for cases where formula returns an unknown
2349 -- variable name
2350 --
2351 fnd_message.set_name('BEN','BEN_92310_FORMULA_RET_PARAM_');
2352 fnd_message.set_token('PROC',l_proc);
2353 fnd_message.set_token('FORMULA', l_inst_dets(l_insttorrw_num).formula_id);
2354 fnd_message.set_token('PARAMETER',l_output(l_count).name);
2355 fnd_message.raise_error;
2356 --
2357 end if;
2358 --
2359 -- Code for type casting errors from formula return variables
2360 --
2361 exception
2362 --
2363 when others then
2364 --
2365 fnd_message.set_name('BEN','BEN_92311_FORMULA_VAL_PARAM');
2366 fnd_message.set_token('PROC',l_proc);
2367 fnd_message.set_token('FORMULA',
2368 l_inst_dets(l_insttorrw_num).formula_id);
2369 fnd_message.set_token('PARAMETER',l_output(l_count).name);
2370 fnd_message.raise_error;
2371 --
2372 end;
2373 --
2374 end loop;
2375 --if the condition is AND and fails go out 2508757
2376 hr_utility.set_location('l_eligible='||l_eligible,1963);
2377 if nvl(l_ben_elgy_prfl_rl_Cond,'A') = 'A' then
2378
2379 if l_eligible <> 'Y' then
2380 --
2381 g_inelg_rsn_cd := 'ERL';
2382 fnd_message.set_name('BEN','BEN_92445_ERL_PRFL_FAIL');
2383 hr_utility.set_location('Criteria Failed: '||l_proc,20);
2384 raise g_criteria_failed;
2385 End if ;
2386 Else ---- if the condition is OR and pass then exit
2387 if l_eligible = 'Y' then
2388 if p_score_compute_mode then
2389 if l_crit_passed is null then
2390 l_crit_passed := true;
2391 end if;
2392 write(l_score_tab,
2393 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
2394 l_inst_dets(l_insttorrw_num).short_code,
2395 l_inst_dets(l_insttorrw_num).pk_id,
2396 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
2397 l_inst_dets(l_insttorrw_num).criteria_weight));
2398 else
2399 exit;
2400 end if;
2401 end if ;
2402 End if ;
2403
2404 --
2405 end loop;
2406 --if the condition is OR and and exit the loop with 'N' throw error
2407 if l_crit_passed is null
2408 then
2409 if nvl(l_ben_elgy_prfl_rl_Cond,'A') = 'O' and l_eligible <> 'Y' then
2410 hr_utility.set_location('erroring on OR and N ',1963);
2411 g_inelg_rsn_cd := 'ERL';
2412 fnd_message.set_name('BEN','BEN_92445_ERL_PRFL_FAIL');
2413 hr_utility.set_location('Criteria Failed: '||l_proc,20);
2414 raise g_criteria_failed;
2415 end if ;
2416 end if ;
2417
2418 end if;
2419 --
2420 if p_score_compute_mode --999
2421 then
2422 hr_utility.set_location('count '||l_score_tab.count,20);
2423 write(p_profile_score_tab,l_score_tab);
2424 end if;
2425 hr_utility.set_location('Leaving: '||l_proc,20);
2426 --
2427 end check_rule_elig;
2428 -- --------------------------------------------------
2429 -- This procedure determines elibility based on job.
2430 -- --------------------------------------------------
2431 procedure check_job_elig(p_eligy_prfl_id in number,
2432 p_business_group_id in number,
2433 p_score_compute_mode in boolean default false,
2434 p_profile_score_tab in out nocopy scoreTab,
2435 p_effective_date in date,
2436 p_job_id in number) is
2437 --
2438 l_proc varchar2(100) := g_package||'check_job_elig';
2439 l_inst_dets ben_elp_cache.g_cache_elpejp_instor;
2440 l_inst_count number;
2441 l_insttorrw_num binary_integer;
2442 l_ok boolean := false;
2443 l_rows_found boolean := false;
2444 l_crit_passed boolean;
2445 l_score_tab scoreTab;
2446 --
2447 begin
2448 --
2449 hr_utility.set_location('Entering : '||l_proc,10);
2450 --
2451 -- Getting eligibility profile job by eligibility profile
2452 --
2453 ben_elp_cache.elpejp_getcacdets
2454 (p_effective_date => p_effective_date
2455 ,p_business_group_id => p_business_group_id
2456 ,p_eligy_prfl_id => p_eligy_prfl_id
2457 ,p_inst_set => l_inst_dets
2458 ,p_inst_count => l_inst_count);
2459 --
2460 if l_inst_count > 0 then
2461 --
2462 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
2463 --
2464 l_ok := nvl((nvl(p_job_id,-1) = l_inst_dets(l_insttorrw_num).job_id),FALSE);
2465 --if l_ok is null then
2466 -- l_ok:=false;
2467 --end if;
2468 --
2469 if l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
2470 --
2471 if p_score_compute_mode then
2472 if l_crit_passed is null then
2473 l_crit_passed := true;
2474 end if;
2475 write(l_score_tab,
2476 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
2477 l_inst_dets(l_insttorrw_num).short_code,
2478 l_inst_dets(l_insttorrw_num).pk_id,
2479 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
2480 l_inst_dets(l_insttorrw_num).criteria_weight));
2481 else
2482 exit;
2483 end if;
2484 --
2485 elsif l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
2486 --
2487 l_rows_found := true;
2488 l_ok := false;
2489 exit;
2490 --
2491 elsif (not l_ok) and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
2492 --
2493 l_rows_found := true;
2494 l_ok := true;
2495 if p_score_compute_mode then
2496 write(l_score_tab,
2497 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
2498 l_inst_dets(l_insttorrw_num).short_code,
2499 l_inst_dets(l_insttorrw_num).pk_id,
2500 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
2501 l_inst_dets(l_insttorrw_num).criteria_weight));
2502 end if;
2503 -- exit ;
2504 --
2505 elsif l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
2506 --
2507 l_rows_found := true;
2508 --
2509 end if;
2510 --
2511 end loop;
2512 --
2513 end if;
2514 --
2515 if l_crit_passed is null
2516 then
2517 if l_rows_found and
2518 not l_ok then
2519 --
2520 g_inelg_rsn_cd := 'JOB';
2521 fnd_message.set_name('BEN','BEN_91676_JOB_PRFL_FAIL');
2522 hr_utility.set_location('Criteria Failed: '||l_proc,20);
2523 raise g_criteria_failed;
2524 --
2525 end if;
2526 end if;
2527 --
2528 if p_score_compute_mode
2529 then
2530 hr_utility.set_location('count '||l_score_tab.count,20);
2531 write(p_profile_score_tab,l_score_tab);
2532 end if;
2533 hr_utility.set_location('Leaving: '||l_proc,20);
2534 --
2535 end check_job_elig;
2536 --
2537 -- -----------------------------------------------------------
2538 -- This procedure determines eligibility based on person type.
2539 -- -----------------------------------------------------------
2540 --
2541 procedure check_per_typ_elig(p_eligy_prfl_id in number,
2542 p_business_group_id in number,
2543 p_score_compute_mode in boolean default false,
2544 p_profile_score_tab in out nocopy scoreTab,
2545 p_effective_date in date,
2546 p_per_per_typ in ben_person_object.
2547 g_cache_typ_table) is
2548 --
2549 l_proc varchar2(100) := g_package||'check_per_typ_elig';
2550 --
2551 l_inst_dets ben_elp_cache.g_cache_elpept_instor;
2552 l_inst_count number;
2553 l_insttorrw_num binary_integer;
2554 --
2555 l_rows_found boolean := false;
2556 l_ok boolean := false;
2557 l_crit_passed boolean;
2558 l_score_tab scoreTab;
2559 --
2560 begin
2561 --
2562 hr_utility.set_location('Entering :'||l_proc,10);
2563 --
2564 ben_elp_cache.elpept_getcacdets
2565 (p_effective_date => p_effective_date
2566 ,p_business_group_id => p_business_group_id
2567 ,p_eligy_prfl_id => p_eligy_prfl_id
2568 ,p_inst_set => l_inst_dets
2569 ,p_inst_count => l_inst_count);
2570 --
2571 -- loop thru all the person type criteria, checking the excludes first.
2572 --
2573 -- If any of the excludes matches a person's person type, fail the criteria
2574 -- Once we get to the non-excludes, one of the person's person
2575 -- types MUST match one of them (if non-exludes exist).
2576 --
2577 if l_inst_count > 0 then
2578 --
2579 <<outer>>
2580 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
2581 --
2582 l_rows_found := true;
2583 --
2584 for l_count in p_per_per_typ.first..p_per_per_typ.last loop
2585 --
2586 -- using person_type_id to support user created person
2587 -- person types.
2588 --
2589 /* l_ok := nvl((nvl(p_per_per_typ(l_count).system_person_type,'-1')
2590 = l_inst_dets(l_insttorrw_num).per_typ_cd),FALSE); */
2591 l_ok := nvl((nvl(p_per_per_typ(l_count).person_type_id,'-1')
2592 = l_inst_dets(l_insttorrw_num).person_type_id),FALSE);
2593 --if l_ok is null then
2594 -- l_ok:=false;
2595 --end if;
2596 --
2597 if l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
2598 --
2599 if p_score_compute_mode then
2600 if l_crit_passed is null then
2601 l_crit_passed := true;
2602 end if;
2603 write(l_score_tab,
2604 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
2605 l_inst_dets(l_insttorrw_num).short_code,
2606 l_inst_dets(l_insttorrw_num).pk_id,
2607 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
2608 l_inst_dets(l_insttorrw_num).criteria_weight));
2609 else
2610 exit outer;
2611 end if;
2612 --
2613 elsif l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
2614 --
2615 l_rows_found := true;
2616 l_ok := false;
2617 exit outer;
2618 --
2619 elsif (not l_ok) and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
2620 --
2621 l_rows_found := true;
2622 l_ok := true;
2623 if p_score_compute_mode then
2624 write(l_score_tab,
2625 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
2626 l_inst_dets(l_insttorrw_num).short_code,
2627 l_inst_dets(l_insttorrw_num).pk_id,
2628 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
2629 l_inst_dets(l_insttorrw_num).criteria_weight));
2630 end if;
2631 --exit outer;
2632 --
2633 elsif l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
2634 --
2635 l_rows_found := true;
2636 --
2637 end if;
2638 --
2639 end loop;
2640 --
2641 end loop outer;
2642 --
2643 end if;
2644 --
2645 if l_crit_passed is null
2646 then
2647 if l_rows_found and
2648 not l_ok then
2649 --
2650 g_inelg_rsn_cd := 'PTP';
2651 fnd_message.set_name('BEN','BEN_91677_PER_TYPE_PRFL_FAIL');
2652 hr_utility.set_location('Criteria Failed: '||l_proc,20);
2653 raise g_criteria_failed;
2654 --
2655 end if;
2656 end if;
2657 --
2658 if p_score_compute_mode
2659 then
2660 hr_utility.set_location('count '||l_score_tab.count,20);
2661 write(p_profile_score_tab,l_score_tab);
2662 end if;
2663 hr_utility.set_location('Leaving: '||l_proc,20);
2664 --
2665 end check_per_typ_elig;
2666 -- ----------------------------------------------------------
2667 -- This procedure determines eligibility based on pay basis.
2668 -- ----------------------------------------------------------
2669 procedure check_py_bss_elig(p_eligy_prfl_id in number,
2670 p_business_group_id in number,
2671 p_score_compute_mode in boolean default false,
2672 p_profile_score_tab in out nocopy scoreTab,
2673 p_effective_date in date,
2674 p_pay_basis_id in number) is
2675 --
2676 l_proc varchar2(100) := g_package||'check_py_bss_elig';
2677 l_inst_dets ben_elp_cache.g_cache_elpepb_instor;
2678 l_inst_count number;
2679 l_insttorrw_num binary_integer;
2680 l_ok boolean := false;
2681 l_rows_found boolean := false;
2682 l_crit_passed boolean;
2683 l_score_tab scoreTab;
2684 --
2685 begin
2686 --
2687 hr_utility.set_location('Entering : '||l_proc,10);
2688 --
2689 -- Getting eligibility profile pay basis by eligibility profile
2690 --
2691 ben_elp_cache.elpepb_getcacdets
2692 (p_effective_date => p_effective_date
2693 ,p_business_group_id => p_business_group_id
2694 ,p_eligy_prfl_id => p_eligy_prfl_id
2695 ,p_inst_set => l_inst_dets
2696 ,p_inst_count => l_inst_count);
2697 --
2698 if l_inst_count > 0 then
2699 --
2700 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
2701 --
2702 l_ok := nvl((l_inst_dets(l_insttorrw_num).pay_basis_id
2703 = nvl(p_pay_basis_id,-1)),FALSE);
2704 --if l_ok is null then
2705 -- l_ok:=false;
2706 --end if;
2707 if l_ok then
2708 hr_utility.set_location('ok',10);
2709 else
2710 hr_utility.set_location('not ok',10);
2711 end if;
2712 hr_utility.set_location('pay_basis_id='||p_pay_basis_id,10);
2713 --
2714 if l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
2715 hr_utility.set_location(l_proc,10);
2716 --
2717 if p_score_compute_mode then
2718 if l_crit_passed is null then
2719 l_crit_passed := true;
2720 end if;
2721 write(l_score_tab,
2722 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
2723 l_inst_dets(l_insttorrw_num).short_code,
2724 l_inst_dets(l_insttorrw_num).pk_id,
2725 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
2726 l_inst_dets(l_insttorrw_num).criteria_weight));
2727 else
2728 exit;
2729 end if;
2730 --
2731 elsif l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
2732 hr_utility.set_location(l_proc,20);
2733 --
2734 l_rows_found := true;
2735 l_ok := false;
2736 exit;
2737 --
2738 elsif (not l_ok) and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
2739 hr_utility.set_location(l_proc,30);
2740 --
2741 l_rows_found := true;
2742 l_ok := true;
2743 if p_score_compute_mode then
2744 write(l_score_tab,
2745 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
2746 l_inst_dets(l_insttorrw_num).short_code,
2747 l_inst_dets(l_insttorrw_num).pk_id,
2748 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
2749 l_inst_dets(l_insttorrw_num).criteria_weight));
2750 end if;
2751 -- exit;
2752 --
2753 elsif l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
2754 hr_utility.set_location(l_proc,40);
2755 --
2756 l_rows_found := true;
2757 --
2758 end if;
2759 hr_utility.set_location(l_proc,50);
2760 --
2761 end loop;
2762 hr_utility.set_location(l_proc,60);
2763 --
2764 end if;
2765 --
2766 hr_utility.set_location(l_proc,70);
2767 if l_ok then
2768 hr_utility.set_location('ok',10);
2769 else
2770 hr_utility.set_location('not ok',10);
2771 end if;
2772 if l_rows_found then
2773 hr_utility.set_location('found',10);
2774 else
2775 hr_utility.set_location('not found',10);
2776 end if;
2777 if l_rows_found is null then
2778 hr_utility.set_location('found is null',10);
2779 end if;
2780 if l_ok is null then
2781 hr_utility.set_location('ok is null',10);
2782 end if;
2783
2784 if l_crit_passed is null
2785 then
2786 if l_rows_found and
2787 not l_ok then
2788 --
2789 hr_utility.set_location(l_proc,80);
2790 g_inelg_rsn_cd := 'PBS';
2791 fnd_message.set_name('BEN','BEN_91678_PY_BSS_PRFL_FAIL');
2792 hr_utility.set_location('Criteria Failed: '||l_proc,20);
2793 raise g_criteria_failed;
2794 --
2795 end if;
2796 end if;
2797 --
2798 if p_score_compute_mode
2799 then
2800 hr_utility.set_location('count '||l_score_tab.count,20);
2801 write(p_profile_score_tab,l_score_tab);
2802 end if;
2803 hr_utility.set_location('Leaving: '||l_proc,20);
2804 --
2805 end check_py_bss_elig;
2806 -- --------------------------------------------------------
2807 -- This procedure determines eligibility based on payroll.
2808 -- --------------------------------------------------------
2809 procedure check_pyrl_elig(p_eligy_prfl_id in number,
2810 p_business_group_id in number,
2811 p_score_compute_mode in boolean default false,
2812 p_profile_score_tab in out nocopy scoreTab,
2813 p_effective_date in date,
2814 p_payroll_id in number) is
2815 --
2816 l_proc varchar2(100) := g_package||'check_pyrl_elig';
2817 l_inst_dets ben_elp_cache.g_cache_elpepy_instor;
2818 l_inst_count number;
2819 l_insttorrw_num binary_integer;
2820 l_ok boolean := false;
2821 l_rows_found boolean := false;
2822 l_crit_passed boolean;
2823 l_score_tab scoreTab;
2824 --
2825 begin
2826 --
2827 hr_utility.set_location('Entering : '||l_proc,10);
2828 hr_utility.set_location('payroll id : '||p_payroll_id,10);
2829 --
2830 -- Getting eligibility profile payroll by eligibility profile
2831 --
2832 ben_elp_cache.elpepy_getcacdets
2833 (p_effective_date => p_effective_date
2834 ,p_business_group_id => p_business_group_id
2835 ,p_eligy_prfl_id => p_eligy_prfl_id
2836 ,p_inst_set => l_inst_dets
2837 ,p_inst_count => l_inst_count
2838 );
2839 --
2840 hr_utility.set_location('Inst Count : '||l_inst_count,10);
2841 if l_inst_count > 0 then
2842 --
2843 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
2844 --
2845 l_ok := nvl((l_inst_dets(l_insttorrw_num).payroll_id = nvl(p_payroll_id,-1)),FALSE);
2846 --if l_ok is null then
2847 -- l_ok:=false;
2848 --end if;
2849 --
2850 if l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
2851 --
2852 if p_score_compute_mode then
2853 if l_crit_passed is null then
2854 l_crit_passed := true;
2855 end if;
2856 write(l_score_tab,
2857 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
2858 l_inst_dets(l_insttorrw_num).short_code,
2859 l_inst_dets(l_insttorrw_num).pk_id,
2860 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
2861 l_inst_dets(l_insttorrw_num).criteria_weight));
2862 else
2863 exit;
2864 end if;
2865 --
2866 elsif l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
2867 --
2868 l_rows_found := true;
2869 l_ok := false;
2870 exit;
2871 --
2872 elsif (not l_ok) and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
2873 --
2874 l_rows_found := true;
2875 l_ok := true;
2876 if p_score_compute_mode then
2877 write(l_score_tab,
2878 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
2879 l_inst_dets(l_insttorrw_num).short_code,
2880 l_inst_dets(l_insttorrw_num).pk_id,
2881 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
2882 l_inst_dets(l_insttorrw_num).criteria_weight));
2883 end if;
2884 --exit;
2885 --
2886 elsif l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
2887 --
2888 l_rows_found := true;
2889 --
2890 end if;
2891 --
2892 end loop;
2893 --
2894 end if;
2895 --
2896 if l_crit_passed is null
2897 then
2898 if l_rows_found and
2899 not l_ok then
2900 --
2901 g_inelg_rsn_cd := 'PYR';
2902 fnd_message.set_name('BEN','BEN_91679_PYRL_PRFL_FAIL');
2903 hr_utility.set_location('Criteria Failed: '||l_proc,20);
2904 raise g_criteria_failed;
2905 --
2906 end if;
2907 end if;
2908 --
2909 if p_score_compute_mode
2910 then
2911 hr_utility.set_location('count '||l_score_tab.count,20);
2912 write(p_profile_score_tab,l_score_tab);
2913 end if;
2914 hr_utility.set_location('Leaving: '||l_proc,20);
2915 --
2916 end check_pyrl_elig;
2917 -- ---------------------------------------------------------------
2918 -- This procedure determines eligibility based on benefits group.
2919 -- ---------------------------------------------------------------
2920 procedure check_benefits_grp_elig(p_eligy_prfl_id in number,
2921 p_business_group_id in number,
2922 p_score_compute_mode in boolean default false,
2923 p_profile_score_tab in out nocopy scoreTab,
2924 p_effective_date in date,
2925 p_benefit_group_id in number) is
2926 --
2927 l_proc varchar2(100) := g_package||'check_benefits_grp_elig';
2928 l_inst_dets ben_elp_cache.g_cache_elpebn_instor;
2929 l_inst_count number;
2930 l_insttorrw_num binary_integer;
2931 l_ok boolean := false;
2932 l_rows_found boolean := false;
2933 l_crit_passed boolean;
2934 l_score_tab scoreTab;
2935 --
2936 begin
2937 --
2938 hr_utility.set_location('Entering : '||l_proc,10);
2939 --
2940 -- Getting eligibility profile benefits group by eligibility profile
2941 --
2942 ben_elp_cache.elpebn_getcacdets
2943 (p_effective_date => p_effective_date
2944 ,p_business_group_id => p_business_group_id
2945 ,p_eligy_prfl_id => p_eligy_prfl_id
2946 ,p_inst_set => l_inst_dets
2947 ,p_inst_count => l_inst_count
2948 );
2949 --
2950 if l_inst_count > 0 then
2951 --
2952 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
2953 --
2954 l_ok := nvl((l_inst_dets(l_insttorrw_num).benfts_grp_id
2955 = nvl(p_benefit_group_id,-1)),FALSE);
2956 --if l_ok is null then
2957 -- l_ok:=false;
2958 --end if;
2959 --
2960 if l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
2961 --
2962 if p_score_compute_mode then
2963 if l_crit_passed is null then
2964 l_crit_passed := true;
2965 end if;
2966 write(l_score_tab,
2967 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
2968 l_inst_dets(l_insttorrw_num).short_code,
2969 l_inst_dets(l_insttorrw_num).pk_id,
2970 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
2971 l_inst_dets(l_insttorrw_num).criteria_weight));
2972 else
2973 exit;
2974 end if;
2975 --
2976 elsif l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
2977 --
2978 l_rows_found := true;
2979 l_ok := false;
2980 exit;
2981 --
2982 elsif (not l_ok) and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
2983 --
2984 l_rows_found := true;
2985 l_ok := true;
2986 if p_score_compute_mode then
2987 write(l_score_tab,
2988 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
2989 l_inst_dets(l_insttorrw_num).short_code,
2990 l_inst_dets(l_insttorrw_num).pk_id,
2991 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
2992 l_inst_dets(l_insttorrw_num).criteria_weight));
2993 end if;
2994 --exit;
2995 --
2996 elsif l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
2997 --
2998 l_rows_found := true;
2999 --
3000 end if;
3001 --
3002 end loop;
3003 --
3004 end if;
3005 --
3006 if l_crit_passed is null
3007 then
3008 if l_rows_found and
3009 not l_ok then
3010 --
3011 g_inelg_rsn_cd := 'BGR';
3012 fnd_message.set_name('BEN','BEN_91680_BENFTS_GRP_PRFL_FAIL');
3013 hr_utility.set_location('Criteria Failed: '||l_proc,20);
3014 raise g_criteria_failed;
3015 --
3016 end if;
3017 end if;
3018 --
3019 if p_score_compute_mode
3020 then
3021 hr_utility.set_location('count '||l_score_tab.count,20);
3022 write(p_profile_score_tab,l_score_tab);
3023 end if;
3024 hr_utility.set_location('Leaving: '||l_proc,20);
3025 --
3026 end check_benefits_grp_elig;
3027 -- --------------------------------------------------------------
3028 -- This procedure determines eligibility based on work location.
3029 -- --------------------------------------------------------------
3030 procedure check_wk_location_elig(p_eligy_prfl_id in number,
3031 p_business_group_id in number,
3032 p_score_compute_mode in boolean default false,
3033 p_profile_score_tab in out nocopy scoreTab,
3034 p_effective_date in date,
3035 p_location_id in number) is
3036 --
3037 l_proc varchar2(100) := g_package||'check_wk_location_elig';
3038 l_inst_dets ben_elp_cache.g_cache_elpewl_instor;
3039 l_inst_count number;
3040 l_insttorrw_num binary_integer;
3041 l_ok boolean := false;
3042 l_rows_found boolean := false;
3043 l_crit_passed boolean;
3044 l_score_tab scoreTab;
3045 --
3046 begin
3047 --
3048 hr_utility.set_location('Entering : '||l_proc,10);
3049 --
3050 -- Getting eligibility profile location by eligibility profile
3051 --
3052 ben_elp_cache.elpewl_getcacdets
3053 (p_effective_date => p_effective_date
3054 ,p_business_group_id => p_business_group_id
3055 ,p_eligy_prfl_id => p_eligy_prfl_id
3056 ,p_inst_set => l_inst_dets
3057 ,p_inst_count => l_inst_count);
3058 --
3059 if l_inst_count > 0 then
3060 --
3061 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
3062 --
3063 l_ok := nvl((l_inst_dets(l_insttorrw_num).location_id = nvl(p_location_id,-1)),FALSE);
3064 --if l_ok is null then
3065 -- l_ok:=false;
3066 --end if;
3067 --
3068 if l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
3069 --
3070 if p_score_compute_mode then
3071 if l_crit_passed is null then
3072 l_crit_passed := true;
3073 end if;
3074 write(l_score_tab,
3075 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
3076 l_inst_dets(l_insttorrw_num).short_code,
3077 l_inst_dets(l_insttorrw_num).pk_id,
3078 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
3079 l_inst_dets(l_insttorrw_num).criteria_weight));
3080 else
3081 exit;
3082 end if;
3083 --
3084 elsif l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
3085 --
3086 l_rows_found := true;
3087 l_ok := false;
3088 exit;
3089 --
3090 elsif (not l_ok) and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
3091 --
3092 l_rows_found := true;
3093 l_ok := true;
3094 if p_score_compute_mode then
3095 write(l_score_tab,
3096 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
3097 l_inst_dets(l_insttorrw_num).short_code,
3098 l_inst_dets(l_insttorrw_num).pk_id,
3099 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
3100 l_inst_dets(l_insttorrw_num).criteria_weight));
3101 end if;
3102 --exit;
3103 --
3104 elsif l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
3105 --
3106 l_rows_found := true;
3107 --
3108 end if;
3109 --
3110 end loop;
3111 --
3112 end if;
3113 --
3114 if l_crit_passed is null
3115 then
3116 if l_rows_found and
3117 not l_ok then
3118 --
3119 g_inelg_rsn_cd := 'LOC';
3120 fnd_message.set_name('BEN','BEN_91681_WK_LOC_PRFL_FAIL');
3121 hr_utility.set_location('Criteria Failed: '||l_proc,20);
3122 raise g_criteria_failed;
3123 --
3124 end if;
3125 end if;
3126 --
3127 if p_score_compute_mode
3128 then
3129 hr_utility.set_location('count '||l_score_tab.count,20);
3130 write(p_profile_score_tab,l_score_tab);
3131 end if;
3132 hr_utility.set_location('Leaving: '||l_proc,20);
3133 --
3134 end check_wk_location_elig;
3135 -- -------------------------------------------------------------
3136 -- This procedure determines eligibility based on people group.
3137 -- -------------------------------------------------------------
3138 procedure check_people_group_elig(p_eligy_prfl_id in number,
3139 p_business_group_id in number,
3140 p_score_compute_mode in boolean default false,
3141 p_profile_score_tab in out nocopy scoreTab,
3142 p_effective_date in date,
3143 p_people_group_id in number) is
3144 --
3145 l_proc varchar2(100) := g_package||'check_people_group_elig';
3146 l_inst_dets ben_elp_cache.g_cache_elpepg_instor;
3147 l_inst_count number;
3148 l_insttorrw_num binary_integer;
3149 l_ok boolean := false;
3150 l_rows_found boolean := false;
3151 --
3152 l_seg_ok boolean ;
3153 l_crit_passed boolean;
3154 l_score_tab scoreTab;
3155 --
3156 -- added for elpro enhancement of flexfield in ppl grp profile
3157 --
3158 cursor c_ppl_grp is
3159 select ppg.people_group_id,
3160 ppg.segment1 ,
3161 ppg.segment2 ,
3162 ppg.segment3 ,
3163 ppg.segment4 ,
3164 ppg.segment5 ,
3165 ppg.segment6 ,
3166 ppg.segment7 ,
3167 ppg.segment8 ,
3168 ppg.segment9 ,
3169 ppg.segment10,
3170 ppg.segment11,
3171 ppg.segment12,
3172 ppg.segment13,
3173 ppg.segment14,
3174 ppg.segment15,
3175 ppg.segment16,
3176 ppg.segment17,
3177 ppg.segment18,
3178 ppg.segment19,
3179 ppg.segment20,
3180 ppg.segment21,
3181 ppg.segment22,
3182 ppg.segment23,
3183 ppg.segment24,
3184 ppg.segment25,
3185 ppg.segment26,
3186 ppg.segment27,
3187 ppg.segment28,
3188 ppg.segment29,
3189 ppg.segment30
3190 from pay_people_groups ppg
3191 where ppg.people_group_id = p_people_group_id ;
3192 --
3193 l_ppl_grp_rec c_ppl_grp%ROWTYPE ;
3194 --
3195 begin
3196 --
3197 hr_utility.set_location('Entering : '||l_proc,10);
3198 --
3199 -- Getting eligibility profile organization by eligibility profile
3200 --
3201 ben_elp_cache.elpepg_getcacdets
3202 (p_effective_date => p_effective_date
3203 ,p_business_group_id => p_business_group_id
3204 ,p_eligy_prfl_id => p_eligy_prfl_id
3205 ,p_inst_set => l_inst_dets
3206 ,p_inst_count => l_inst_count);
3207 --
3208 if l_inst_count > 0 then
3209 --
3210 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
3211 --
3212 l_rows_found := true;
3213 --
3214 l_ok := (l_inst_dets(l_insttorrw_num).people_group_id = nvl(p_people_group_id,-1));
3215 --
3216 if l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
3217 if p_score_compute_mode then
3218 if l_crit_passed is null then
3219 l_crit_passed := true;
3220 end if;
3221 write(l_score_tab,
3222 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
3223 l_inst_dets(l_insttorrw_num).short_code,
3224 l_inst_dets(l_insttorrw_num).pk_id,
3225 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
3226 l_inst_dets(l_insttorrw_num).criteria_weight));
3227 else
3228 exit;
3229 end if;
3230 --
3231 elsif l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
3232 --
3233 l_ok := false;
3234 exit;
3235 --
3236 elsif (not l_ok) and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
3237 --
3238 l_ok := true;
3239 if p_score_compute_mode then
3240 write(l_score_tab,
3241 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
3242 l_inst_dets(l_insttorrw_num).short_code,
3243 l_inst_dets(l_insttorrw_num).pk_id,
3244 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
3245 l_inst_dets(l_insttorrw_num).criteria_weight));
3246 end if;
3247 --
3248 end if;
3249 --
3250 -- Once id matching is over, check for segment matching if id is not null
3251 --
3252 if p_people_group_id is not null then
3253 --
3254 open c_ppl_grp ;
3255 fetch c_ppl_grp into l_ppl_grp_rec ;
3256 close c_ppl_grp ;
3257 --
3258 l_seg_ok := true;
3259 --
3260 /* bug 2786772: remove nvl for boolean variables as it gives unpredictable results */
3261 --
3262 if l_seg_ok and l_inst_dets(l_insttorrw_num).segment1 is not null then
3263 if l_inst_dets(l_insttorrw_num).segment1 = l_ppl_grp_rec.segment1 then
3264 l_seg_ok := true ;
3265 else
3266 l_seg_ok := false;
3267 end if;
3268 end if ;
3269 --
3270 if l_seg_ok and l_inst_dets(l_insttorrw_num).segment2 is not null then
3271 if l_inst_dets(l_insttorrw_num).segment2 = l_ppl_grp_rec.segment2 then
3272 l_seg_ok := true ;
3273 else
3274 l_seg_ok := false;
3275 end if;
3276 end if ;
3277 --
3278 if l_seg_ok and l_inst_dets(l_insttorrw_num).segment3 is not null then
3279 if l_inst_dets(l_insttorrw_num).segment3 = l_ppl_grp_rec.segment3 then
3280 l_seg_ok := true ;
3281 else
3282 l_seg_ok := false;
3283 end if;
3284 end if ;
3285
3286 --
3287 if l_seg_ok and l_inst_dets(l_insttorrw_num).segment4 is not null then
3288 if l_inst_dets(l_insttorrw_num).segment4 = l_ppl_grp_rec.segment4 then
3289 l_seg_ok := true ;
3290 else
3291 l_seg_ok := false;
3292 end if;
3293 end if ;
3294
3295 if l_seg_ok and l_inst_dets(l_insttorrw_num).segment5 is not null then
3296 if l_inst_dets(l_insttorrw_num).segment5 = l_ppl_grp_rec.segment5 then
3297 l_seg_ok := true ;
3298 else
3299 l_seg_ok := false;
3300 end if;
3301 end if ;
3302
3303
3304 if l_seg_ok and l_inst_dets(l_insttorrw_num).segment6 is not null then
3305 if l_inst_dets(l_insttorrw_num).segment6 = l_ppl_grp_rec.segment6 then
3306 l_seg_ok := true ;
3307 else
3308 l_seg_ok := false;
3309 end if;
3310 end if ;
3311
3312 if l_seg_ok and l_inst_dets(l_insttorrw_num).segment7 is not null then
3313 if l_inst_dets(l_insttorrw_num).segment7 = l_ppl_grp_rec.segment7 then
3314 l_seg_ok := true ;
3315 else
3316 l_seg_ok := false;
3317 end if;
3318 end if ;
3319
3320 if l_seg_ok and l_inst_dets(l_insttorrw_num).segment8 is not null then
3321 if l_inst_dets(l_insttorrw_num).segment8 = l_ppl_grp_rec.segment8 then
3322 l_seg_ok := true ;
3323 else
3324 l_seg_ok := false;
3325 end if;
3326 end if ;
3327
3328
3329 if l_seg_ok and l_inst_dets(l_insttorrw_num).segment9 is not null then
3330 if l_inst_dets(l_insttorrw_num).segment9 = l_ppl_grp_rec.segment9 then
3331 l_seg_ok := true ;
3332 else
3333 l_seg_ok := false;
3334 end if;
3335 end if ;
3336
3337 if l_seg_ok and l_inst_dets(l_insttorrw_num).segment10 is not null then
3338 if l_inst_dets(l_insttorrw_num).segment10 = l_ppl_grp_rec.segment10 then
3339 l_seg_ok := true ;
3340 else
3341 l_seg_ok := false;
3342 end if;
3343 end if ;
3344
3345 if l_seg_ok and l_inst_dets(l_insttorrw_num).segment11 is not null then
3346 if l_inst_dets(l_insttorrw_num).segment11 = l_ppl_grp_rec.segment11 then
3347 l_seg_ok := true ;
3348 else
3349 l_seg_ok := false;
3350 end if;
3351 end if ;
3352
3353
3354 if l_seg_ok and l_inst_dets(l_insttorrw_num).segment12 is not null then
3355 if l_inst_dets(l_insttorrw_num).segment12 = l_ppl_grp_rec.segment12 then
3356 l_seg_ok := true ;
3357 else
3358 l_seg_ok := false;
3359 end if;
3360 end if ;
3361
3362
3363 if l_seg_ok and l_inst_dets(l_insttorrw_num).segment13 is not null then
3364 if l_inst_dets(l_insttorrw_num).segment13 = l_ppl_grp_rec.segment13 then
3365 l_seg_ok := true ;
3366 else
3367 l_seg_ok := false;
3368 end if;
3369 end if ;
3370
3371 if l_seg_ok and l_inst_dets(l_insttorrw_num).segment14 is not null then
3372 if l_inst_dets(l_insttorrw_num).segment14 = l_ppl_grp_rec.segment14 then
3373 l_seg_ok := true ;
3374 else
3375 l_seg_ok := false;
3376 end if;
3377 end if ;
3378
3379
3380 if l_seg_ok and l_inst_dets(l_insttorrw_num).segment15 is not null then
3381 if l_inst_dets(l_insttorrw_num).segment15 = l_ppl_grp_rec.segment15 then
3382 l_seg_ok := true ;
3383 else
3384 l_seg_ok := false;
3385 end if;
3386 end if ;
3387
3388
3389 if l_seg_ok and l_inst_dets(l_insttorrw_num).segment16 is not null then
3390 if l_inst_dets(l_insttorrw_num).segment16 = l_ppl_grp_rec.segment16 then
3391 l_seg_ok := true ;
3392 else
3393 l_seg_ok := false;
3394 end if;
3395 end if ;
3396
3397 if l_seg_ok and l_inst_dets(l_insttorrw_num).segment17 is not null then
3398 if l_inst_dets(l_insttorrw_num).segment17 = l_ppl_grp_rec.segment17 then
3399 l_seg_ok := true ;
3400 else
3401 l_seg_ok := false;
3402 end if;
3403 end if ;
3404
3405
3406 if l_seg_ok and l_inst_dets(l_insttorrw_num).segment18 is not null then
3407 if l_inst_dets(l_insttorrw_num).segment18 = l_ppl_grp_rec.segment18 then
3408 l_seg_ok := true ;
3409 else
3410 l_seg_ok := false;
3411 end if;
3412 end if ;
3413
3414 if l_seg_ok and l_inst_dets(l_insttorrw_num).segment19 is not null then
3415 if l_inst_dets(l_insttorrw_num).segment19 = l_ppl_grp_rec.segment19 then
3416 l_seg_ok := true ;
3417 else
3418 l_seg_ok := false;
3419 end if;
3420 end if ;
3421
3422 if l_seg_ok and l_inst_dets(l_insttorrw_num).segment20 is not null then
3423 if l_inst_dets(l_insttorrw_num).segment20 = l_ppl_grp_rec.segment20 then
3424 l_seg_ok := true ;
3425 else
3426 l_seg_ok := false;
3427 end if;
3428 end if ;
3429
3430
3431 if l_seg_ok and l_inst_dets(l_insttorrw_num).segment21 is not null then
3432 if l_inst_dets(l_insttorrw_num).segment21 = l_ppl_grp_rec.segment21 then
3433 l_seg_ok := true ;
3434 else
3435 l_seg_ok := false;
3436 end if;
3437 end if ;
3438
3439 if l_seg_ok and l_inst_dets(l_insttorrw_num).segment22 is not null then
3440 if l_inst_dets(l_insttorrw_num).segment22 = l_ppl_grp_rec.segment22 then
3441 l_seg_ok := true ;
3442 else
3443 l_seg_ok := false;
3444 end if;
3445 end if ;
3446
3447 if l_seg_ok and l_inst_dets(l_insttorrw_num).segment23 is not null then
3448 if l_inst_dets(l_insttorrw_num).segment23 = l_ppl_grp_rec.segment23 then
3449 l_seg_ok := true ;
3450 else
3451 l_seg_ok := false;
3452 end if;
3453 end if ;
3454
3455
3456 if l_seg_ok and l_inst_dets(l_insttorrw_num).segment24 is not null then
3457 if l_inst_dets(l_insttorrw_num).segment24 = l_ppl_grp_rec.segment24 then
3458 l_seg_ok := true ;
3459 else
3460 l_seg_ok := false;
3461 end if;
3462 end if ;
3463
3464
3465 if l_seg_ok and l_inst_dets(l_insttorrw_num).segment25 is not null then
3466 if l_inst_dets(l_insttorrw_num).segment25 = l_ppl_grp_rec.segment25 then
3467 l_seg_ok := true ;
3468 else
3469 l_seg_ok := false;
3470 end if;
3471 end if ;
3472
3473 if l_seg_ok and l_inst_dets(l_insttorrw_num).segment26 is not null then
3474 if l_inst_dets(l_insttorrw_num).segment26 = l_ppl_grp_rec.segment26 then
3475 l_seg_ok := true ;
3476 else
3477 l_seg_ok := false;
3478 end if;
3479 end if ;
3480
3481 if l_seg_ok and l_inst_dets(l_insttorrw_num).segment27 is not null then
3482 if l_inst_dets(l_insttorrw_num).segment27 = l_ppl_grp_rec.segment27 then
3483 l_seg_ok := true ;
3484 else
3485 l_seg_ok := false;
3486 end if;
3487 end if ;
3488
3489
3490 if l_seg_ok and l_inst_dets(l_insttorrw_num).segment28 is not null then
3491 if l_inst_dets(l_insttorrw_num).segment28 = l_ppl_grp_rec.segment28 then
3492 l_seg_ok := true ;
3493 else
3494 l_seg_ok := false;
3495 end if;
3496 end if ;
3497
3498 if l_seg_ok and l_inst_dets(l_insttorrw_num).segment29 is not null then
3499 if l_inst_dets(l_insttorrw_num).segment29 = l_ppl_grp_rec.segment29 then
3500 l_seg_ok := true ;
3501 else
3502 l_seg_ok := false;
3503 end if;
3504 end if ;
3505
3506 if l_seg_ok and l_inst_dets(l_insttorrw_num).segment30 is not null then
3507 if l_inst_dets(l_insttorrw_num).segment30 = l_ppl_grp_rec.segment30 then
3508 l_seg_ok := true ;
3509 else
3510 l_seg_ok := false;
3511 end if;
3512 end if ;
3513
3514 --
3515
3516 if l_seg_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
3517 --
3518 l_ok := FALSE;
3519 exit;
3520 --
3521 elsif l_seg_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
3522 --
3523 l_ok := TRUE;
3524 if p_score_compute_mode then
3525 if l_crit_passed is null then
3526 l_crit_passed := true;
3527 end if;
3528 write(l_score_tab,
3529 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
3530 l_inst_dets(l_insttorrw_num).short_code,
3531 l_inst_dets(l_insttorrw_num).pk_id,
3532 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
3533 l_inst_dets(l_insttorrw_num).criteria_weight));
3534 else
3535 exit;
3536 end if;
3537 --
3538 end if;
3539 --
3540 end if;
3541 --
3542 end loop;
3543 --
3544 end if;
3545 --
3546 if l_crit_passed is null
3547 then
3548 if l_rows_found and
3549 not l_ok then
3550 --
3551 g_inelg_rsn_cd := 'PEO';
3552 fnd_message.set_name('BEN','BEN_92224_PEO_GROUP_PRFL_FAIL');
3553 hr_utility.set_location('Criteria Failed: '||l_proc,20);
3554 raise g_criteria_failed;
3555 --
3556 end if;
3557 end if;
3558 --
3559 if p_score_compute_mode
3560 then
3561 hr_utility.set_location('count '||l_score_tab.count,20);
3562 write(p_profile_score_tab,l_score_tab);
3563 end if;
3564 hr_utility.set_location('Leaving: '||l_proc,20);
3565 --
3566 end check_people_group_elig;
3567 -- ---------------------------------------------------------
3568 -- This procedure determines eligibility based on org unit.
3569 -- ---------------------------------------------------------
3570 procedure check_org_unit_elig(p_eligy_prfl_id in number,
3571 p_business_group_id in number,
3572 p_score_compute_mode in boolean default false,
3573 p_profile_score_tab in out nocopy scoreTab,
3574 p_effective_date in date,
3575 p_organization_id in number) is
3576 --
3577 l_proc varchar2(100) := g_package||'check_org_unit_elig';
3578 l_inst_dets ben_elp_cache.g_cache_elpeou_instor;
3579 l_inst_count number;
3580 l_insttorrw_num binary_integer;
3581 l_ok boolean := false;
3582 l_rows_found boolean := false;
3583 l_crit_passed boolean;
3584 l_score_tab scoreTab;
3585 --
3586 begin
3587 --
3588 hr_utility.set_location('Entering : '||l_proc,10);
3589 --
3590 -- Getting eligibility profile organization by eligibility profile
3591 --
3592 ben_elp_cache.elpeou_getcacdets
3593 (p_effective_date => p_effective_date
3594 ,p_business_group_id => p_business_group_id
3595 ,p_eligy_prfl_id => p_eligy_prfl_id
3596 ,p_inst_set => l_inst_dets
3597 ,p_inst_count => l_inst_count);
3598 --
3599 if l_inst_count > 0 then
3600 --
3601 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
3602 --
3603 l_ok := nvl((l_inst_dets(l_insttorrw_num).organization_id = nvl(p_organization_id,-1)),FALSE);
3604 --if l_ok is null then
3605 -- l_ok:=false;
3606 --end if;
3607 --
3608 if l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
3609 --
3610 if p_score_compute_mode then
3611 if l_crit_passed is null then
3612 l_crit_passed := true;
3613 end if;
3614 write(l_score_tab,
3615 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
3616 l_inst_dets(l_insttorrw_num).short_code,
3617 l_inst_dets(l_insttorrw_num).pk_id,
3618 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
3619 l_inst_dets(l_insttorrw_num).criteria_weight));
3620 else
3621 exit;
3622 end if;
3623 --
3624 elsif l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
3625 --
3626 l_rows_found := true;
3627 l_ok := false;
3628 exit;
3629 --
3630 elsif (not l_ok) and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
3631 --
3632 l_rows_found := true;
3633 l_ok := true;
3634 if p_score_compute_mode then
3635 write(l_score_tab,
3636 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
3637 l_inst_dets(l_insttorrw_num).short_code,
3638 l_inst_dets(l_insttorrw_num).pk_id,
3639 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
3640 l_inst_dets(l_insttorrw_num).criteria_weight));
3641 end if;
3642 --exit;
3643 --
3644 elsif l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
3645 --
3646 l_rows_found := true;
3647 --
3648 end if;
3649 --
3650 end loop;
3651 --
3652 end if;
3653 --
3654 if l_crit_passed is null
3655 then
3656 if l_rows_found and
3657 not l_ok then
3658 --
3659 g_inelg_rsn_cd := 'ORG';
3660 fnd_message.set_name('BEN','BEN_91682_ORG_UNIT_PRFL_FAIL');
3661 hr_utility.set_location('Criteria Failed: '||l_proc,20);
3662 raise g_criteria_failed;
3663 --
3664 end if;
3665 end if;
3666 --
3667 if p_score_compute_mode
3668 then
3669 hr_utility.set_location('count '||l_score_tab.count,20);
3670 write(p_profile_score_tab,l_score_tab);
3671 end if;
3672 hr_utility.set_location('Leaving: '||l_proc,20);
3673 --
3674 end check_org_unit_elig;
3675 -- --------------------------------------------------------------
3676 -- This procedure determines eligibility based on pay frequency.
3677 -- --------------------------------------------------------------
3678 procedure check_py_freq_elig(p_eligy_prfl_id in number,
3679 p_business_group_id in number,
3680 p_score_compute_mode in boolean default false,
3681 p_profile_score_tab in out nocopy scoreTab,
3682 p_effective_date in date,
3683 p_hourly_salaried_code in varchar2) is
3684 --
3685 l_proc varchar2(100) := g_package||'check_py_freq_elig';
3686 l_inst_dets ben_elp_cache.g_cache_elpehs_instor;
3687 l_inst_count number;
3688 l_insttorrw_num binary_integer;
3689 l_ok boolean := false;
3690 l_rows_found boolean := false;
3691 l_crit_passed boolean;
3692 l_score_tab scoreTab;
3693 --
3694 begin
3695 --
3696 hr_utility.set_location('Entering : '||l_proc,10);
3697 --
3698 -- Getting eligibility profile pay frequency by eligibility profile
3699 --
3700 ben_elp_cache.elpehs_getcacdets
3701 (p_effective_date => p_effective_date
3702 ,p_business_group_id => p_business_group_id
3703 ,p_eligy_prfl_id => p_eligy_prfl_id
3704 ,p_inst_set => l_inst_dets
3705 ,p_inst_count => l_inst_count
3706 );
3707 --
3708 if l_inst_count > 0 then
3709 --
3710 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
3711 --
3712 l_ok := nvl((nvl(p_hourly_salaried_code,'-1') = l_inst_dets(l_insttorrw_num).hrly_slrd_cd),FALSE);
3713 --if l_ok is null then
3714 -- l_ok:=false;
3715 --end if;
3716 --
3717 if l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
3718 --
3719 if p_score_compute_mode then
3720 if l_crit_passed is null then
3721 l_crit_passed := true;
3722 end if;
3723 write(l_score_tab,
3724 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
3725 l_inst_dets(l_insttorrw_num).short_code,
3726 l_inst_dets(l_insttorrw_num).pk_id,
3727 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
3728 l_inst_dets(l_insttorrw_num).criteria_weight));
3729 else
3730 exit;
3731 end if;
3732 --
3733 elsif l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
3734 --
3735 l_rows_found := true;
3736 l_ok := false;
3737 exit;
3738 --
3739 elsif (not l_ok) and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
3740 --
3741 l_rows_found := true;
3742 l_ok := true;
3743 if p_score_compute_mode then
3744 write(l_score_tab,
3745 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
3746 l_inst_dets(l_insttorrw_num).short_code,
3747 l_inst_dets(l_insttorrw_num).pk_id,
3748 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
3749 l_inst_dets(l_insttorrw_num).criteria_weight));
3750 end if;
3751 --exit;
3752 --
3753 elsif l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
3754 --
3755 l_rows_found := true;
3756 --
3757 end if;
3758 --
3759 end loop;
3760 --
3761 end if;
3762 --
3763 if l_crit_passed is null
3764 then
3765 if l_rows_found and
3766 not l_ok then
3767 --
3768 g_inelg_rsn_cd := 'PFQ';
3769 fnd_message.set_name('BEN','BEN_91683_PY_FREQ_PRFL_FAIL');
3770 hr_utility.set_location('Criteria Failed: '||l_proc,20);
3771 raise g_criteria_failed;
3772 --
3773 end if;
3774 end if;
3775 --
3776 if p_score_compute_mode
3777 then
3778 hr_utility.set_location('count '||l_score_tab.count,20);
3779 write(p_profile_score_tab,l_score_tab);
3780 end if;
3781 hr_utility.set_location('Leaving: '||l_proc,20);
3782 --
3783 end check_py_freq_elig;
3784 -- ---------------------------------------------------------------
3785 -- This procedure determines eligibility based on service area.
3786 -- ---------------------------------------------------------------
3787 procedure check_service_area_elig
3788 (p_eligy_prfl_id in number
3789 ,p_person_id in number
3790 ,p_business_group_id in number
3791 ,p_score_compute_mode in boolean default false
3792 ,p_profile_score_tab in out nocopy scoreTab
3793 ,p_postal_code in varchar2 default null
3794 ,p_effective_date in date
3795 )
3796 is
3797 --
3798 l_proc varchar2(100) := g_package||'check_service_area_elig';
3799 /*
3800 l_inst_dets ben_elp_cache.g_cache_elpesa_instor;
3801 */
3802 l_rows_found boolean := false;
3803 l_pad_rec per_addresses%rowtype;
3804 l_svc_area_id number(15);
3805 l_excld_flag varchar2(1);
3806 l_from_value VARCHAR2(90);
3807 l_to_value VARCHAR2(90);
3808 l_pk_id number;
3809 l_criteria_score number;
3810 l_criteria_weight number;
3811 l_crit_passed boolean;
3812 l_score_tab scoreTab;
3813 --
3814 cursor get_elig_svc(p_eligy_prfl_id in number) is
3815 select elig_svc.elig_svc_area_prte_id,
3816 elig_svc.excld_flag,
3817 elig_svc.svc_area_id,
3818 elig_svc.criteria_score,
3819 elig_svc.criteria_weight
3820 from ben_elig_svc_area_prte_f elig_svc
3821 where eligy_prfl_id = p_eligy_prfl_id
3822 and p_effective_date between effective_start_date
3823 and effective_end_date;
3824 --
3825 cursor get_zip_ranges(p_svc_area_id in number
3826 ,p_zip_code in VARCHAR2) is
3827 select zip.from_value, zip.to_value
3828 from ben_pstl_zip_rng_f zip
3829 where zip.pstl_zip_rng_id in (
3830 select pstl_zip_rng_id
3831 from ben_svc_area_pstl_zip_rng_f rng
3832 where rng.SVC_AREA_ID = p_svc_area_id
3833 and p_effective_date between rng.effective_start_date
3834 and rng.effective_end_date)
3835 and length(p_zip_code) >= length(zip.from_value)
3836 and (substr( nvl(p_zip_code,'-1'),1,length(zip.from_value))
3837 between zip.from_value and nvl(zip.to_value,p_zip_code)
3838 or nvl(p_zip_code,'-1') = zip.from_value
3839 or nvl(p_zip_code,'-1') = zip.to_value)
3840 and p_effective_date between zip.effective_start_date
3841 and zip.effective_end_date;
3842 begin
3843 --
3844 hr_utility.set_location('Entering : '||l_proc,10);
3845 --
3846 if p_postal_code is null then
3847 ben_person_object.get_object(p_person_id => p_person_id,
3848 p_rec => l_pad_rec);
3849 else
3850 l_pad_rec.postal_code := p_postal_code;
3851 end if;
3852 --
3853 -- Getting eligibility profile service area range by eligibility profile
3854 --
3855 --
3856 open get_elig_svc(p_eligy_prfl_id);
3857 <<range_loop>>
3858 loop
3859 fetch get_elig_svc into l_pk_id,
3860 l_excld_flag,
3861 l_svc_area_id,
3862 l_criteria_score,
3863 l_criteria_weight;
3864 exit when get_elig_svc%notfound;
3865 l_rows_found := false;
3866 --
3867 ben_saz_cache.SAZRZR_Exists
3868 (p_svc_area_id => l_svc_area_id
3869 ,p_zip_code => l_pad_rec.postal_code
3870 ,p_eff_date => p_effective_date
3871 --
3872 ,p_exists => l_rows_found
3873 );
3874 --
3875 IF (l_rows_found AND l_excld_flag = 'N') then
3876 --
3877 l_rows_found := TRUE;
3878 if p_score_compute_mode then
3879 if l_crit_passed is null then
3880 l_crit_passed := true;
3881 end if;
3882 write(l_score_tab,
3883 p_eligy_prfl_id,
3884 'ESA',
3885 l_pk_id,
3886 nvl(l_criteria_score, l_criteria_weight));
3887 else
3888 exit;
3889 end if;
3890 hr_utility.set_location(' l_rows_found := TRUE ' ,99);
3891 --
3892 ELSIF (NOT l_rows_found AND l_excld_flag = 'Y' ) then
3893 --
3894 l_rows_found := TRUE;
3895 if p_score_compute_mode then
3896 write(l_score_tab,
3897 p_eligy_prfl_id,
3898 'ESA',
3899 l_pk_id,
3900 nvl(l_criteria_score, l_criteria_weight));
3901 end if;
3902 hr_utility.set_location(' l_rows_found := TRUE ' ,99);
3903 --
3904 ELSIF ( l_rows_found AND l_excld_flag = 'Y' ) then
3905 --
3906 g_inelg_rsn_cd := 'SVC';
3907 l_rows_found := FALSE ;
3908 fnd_message.set_name('BEN','BEN_92225_SVC_AREA_PRFL_FAIL');
3909 exit;
3910 --
3911 END IF;
3912 --
3913 end loop range_loop;
3914 close get_elig_svc;
3915 --
3916 if l_crit_passed is null
3917 then
3918 if NOT l_rows_found then
3919 --
3920 hr_utility.set_location(' g_profile_failed ',99);
3921 RAISE g_criteria_failed ;
3922 --
3923 End if;
3924 End if;
3925 --
3926 if p_score_compute_mode
3927 then
3928 hr_utility.set_location('count '||l_score_tab.count,20);
3929 write(p_profile_score_tab,l_score_tab);
3930 end if;
3931 hr_utility.set_location('Leaving: '||l_proc,20);
3932 --
3933 end check_service_area_elig;
3934 --
3935 -- ---------------------------------------------------------------
3936 -- This procedure determines eligibility based on zip code range.
3937 -- ---------------------------------------------------------------
3938 --
3939 procedure check_zip_code_rng_elig(p_eligy_prfl_id in number,
3940 p_person_id in number,
3941 p_score_compute_mode in boolean default false,
3942 p_profile_score_tab in out nocopy scoreTab,
3943 p_postal_code in varchar2 default null,
3944 p_business_group_id in number,
3945 p_effective_date in date) is
3946 --
3947 l_proc varchar2(100) := g_package||'check_zip_code_rng_elig';
3948 l_ok boolean := false;
3949 l_rows_found boolean := false;
3950 l_pad_rec per_addresses%rowtype;
3951 l_pstl_zip_rng_id number(15);
3952 l_excld_flag varchar2(1);
3953 l_from_value VARCHAR2(90);
3954 l_to_value VARCHAR2(90);
3955 l_pk_id number;
3956 l_criteria_score number;
3957 l_criteria_weight number;
3958 l_crit_passed boolean;
3959 l_score_tab scoreTab;
3960 --
3961 cursor get_elig_zip(p_eligy_prfl_id in number) is
3962 select elig_zip.elig_pstl_cd_r_rng_prte_id,
3963 elig_zip.excld_flag,
3964 elig_zip.pstl_zip_rng_id,
3965 elig_zip.criteria_score,
3966 elig_zip.criteria_weight
3967 from ben_elig_pstl_cd_r_rng_prte_f elig_zip
3968 where elig_zip.eligy_prfl_id = p_eligy_prfl_id
3969 and p_effective_date between effective_start_date
3970 and effective_end_date;
3971 --
3972 cursor get_zip_ranges(p_pstl_zip_rng_id in number
3973 ,p_zip_code in VARCHAR2) is
3974 select zip.from_value, zip.to_value
3975 from ben_pstl_zip_rng_f zip
3976 where zip.pstl_zip_rng_id = p_pstl_zip_rng_id
3977 and length(p_zip_code) >= length(zip.from_value)
3978 and (substr( nvl(p_zip_code,'-1'),1,length(zip.from_value))
3979 between zip.from_value and nvl(zip.to_value,p_zip_code)
3980 or nvl(p_zip_code,'-1') = zip.from_value
3981 or nvl(p_zip_code,'-1') = zip.to_value)
3982 and p_effective_date between zip.effective_start_date
3983 and zip.effective_end_date;
3984 begin
3985 --
3986 hr_utility.set_location('Entering : '||l_proc,10);
3987 --
3988 -- Getting eligibility profile zip code range by eligibility profile
3989 --
3990 --
3991 if p_postal_code is null then
3992 ben_person_object.get_object(p_person_id => p_person_id,
3993 p_rec => l_pad_rec);
3994 else
3995 l_pad_rec.postal_code := p_postal_code;
3996 end if;
3997 --
3998
3999 open get_elig_zip(p_eligy_prfl_id);
4000 <<range_loop>>
4001 loop
4002 fetch get_elig_zip into l_pk_id,
4003 l_excld_flag,
4004 l_pstl_zip_rng_id,
4005 l_criteria_score,
4006 l_criteria_weight;
4007 exit when get_elig_zip%notfound;
4008 l_ok := false;
4009 l_rows_found := false;
4010 open get_zip_ranges(l_pstl_zip_rng_id,l_pad_rec.postal_code);
4011 <<zip_loop>>
4012 loop
4013 fetch get_zip_ranges into l_from_value,l_to_value;
4014 exit when get_zip_ranges%NOTFOUND;
4015 --
4016 hr_utility.set_location('person zip '||l_pad_rec.postal_code ,2219.3);
4017 hr_utility.set_location('from zip '||l_from_value ,2219.3);
4018 hr_utility.set_location('to zip '||l_to_value ,2219.3);
4019 --
4020 l_rows_found := true;
4021 exit;
4022 end loop zip_loop;
4023 --
4024 IF (l_pad_rec.postal_code is null)
4025 OR (l_rows_found AND l_excld_flag = 'N') then
4026 --
4027 close get_zip_ranges;
4028 l_rows_found := TRUE;
4029 if p_score_compute_mode then
4030 if l_crit_passed is null then
4031 l_crit_passed := true;
4032 end if;
4033 write(l_score_tab,
4034 p_eligy_prfl_id,
4035 'EPZ',
4036 l_pk_id,
4037 nvl(l_criteria_score, l_criteria_weight));
4038 else
4039 exit;
4040 end if;
4041 --
4042 ELSIF (not l_rows_found AND l_excld_flag = 'Y' ) THEN
4043 --
4044 l_rows_found := TRUE;
4045 --
4046 if p_score_compute_mode then
4047 write(l_score_tab,
4048 p_eligy_prfl_id,
4049 'EPZ',
4050 l_pk_id,
4051 nvl(l_criteria_score, l_criteria_weight));
4052 end if;
4053 ELSIF ( l_rows_found AND l_excld_flag = 'Y') THEN
4054 --
4055 l_rows_found := FALSE ;
4056 exit ;
4057 --
4058 END IF;
4059 --
4060 CLOSE get_zip_ranges;
4061
4062 end loop range_loop;
4063 close get_elig_zip;
4064 --
4065 if l_crit_passed is null
4066 then
4067 if not l_rows_found then
4068 --
4069 g_inelg_rsn_cd := 'ZIP';
4070 RAISE g_criteria_failed ;
4071 --
4072 end if;
4073 end if;
4074 if p_score_compute_mode
4075 then
4076 hr_utility.set_location('count '||l_score_tab.count,20);
4077 write(p_profile_score_tab,l_score_tab);
4078 end if;
4079 hr_utility.set_location('Leaving: '||l_proc,20);
4080 --
4081 end check_zip_code_rng_elig;
4082 -- ---------------------------------------------------------
4083 -- This procedure determines elig based on scheduled hours.
4084 -- ---------------------------------------------------------
4085 --
4086 -- Range of Scheduled hours enhancement
4087 --
4088 procedure check_sched_hrs_elig(p_eligy_prfl_id in number,
4089 p_business_group_id in number,
4090 p_effective_date in date,
4091 p_lf_evt_ocrd_dt in date,
4092 p_person_id in number,
4093 p_pgm_id in number,
4094 p_pl_id in number,
4095 p_oipl_id in number,
4096 p_pl_typ_id in number,
4097 p_opt_id in number,
4098 p_comp_obj_mode in boolean default true,
4099 p_per_in_ler_id in number,
4100 p_score_compute_mode in boolean default false,
4101 p_profile_score_tab in out nocopy scoreTab,
4102 p_ler_id in number,
4103 p_jurisdiction_code in varchar2,
4104 p_assignment_id in number,
4105 p_organization_id in number) is
4106 --
4107 l_proc varchar2(100) := g_package||'check_sched_hrs_elig';
4108 l_ok boolean := false;
4109 l_rows_found boolean := false;
4110 --
4111 l_inst_dets ben_elp_cache.g_cache_elpesh_instor;
4112 l_inst_count number;
4113 l_insttorrw_num binary_integer;
4114 --
4115 l_sched_effective_date date;
4116 -- l_fonm_cvg_strt_dt date;
4117 l_output ff_exec.outputs_t;
4118 l_pgm_use_all_asnts_elig_flag varchar2(30);
4119 l_pl_use_all_asnts_elig_flag varchar2(30);
4120 l_use_all_asnts_elig_flag varchar2(30);
4121 l_pl_rec ben_pl_f%rowtype;
4122 l_pgm_rec ben_pgm_f%rowtype;
4123 --
4124 l_min_hours number;
4125 l_max_hours number;
4126 l_freq_cd varchar2(30);
4127 l_normal_hours number;
4128 l_crit_passed boolean;
4129 l_score_tab scoreTab;
4130 --
4131 -- Cursor to grab sched hrs requirement
4132 --
4133 cursor c_normal_hours(p_frequency varchar2,
4134 p_use_all_asnts_elig_flag varchar2) is
4135 select sum(normal_hours)
4136 from per_all_assignments_f asg
4137 where asg.person_id = p_person_id
4138 and asg.business_group_id = p_business_group_id
4139 and (
4140 (nvl(p_use_all_asnts_elig_flag,'N') = 'N' and asg.assignment_id = p_assignment_id)
4141 or
4142 (nvl(p_use_all_asnts_elig_flag,'N') = 'Y')
4143 )
4144 and l_sched_effective_date between asg.effective_start_date
4145 and asg.effective_end_date
4146 and frequency = p_frequency ;
4147 --
4148 begin
4149 --
4150 hr_utility.set_location('Entering : '||l_proc,10);
4151 --
4152
4153 -- Getting eligibility profile scheduled hours by eligibility profile
4154 --
4155
4156 ben_elp_cache.elpesh_getcacdets
4157 (p_effective_date => nvl(l_fonm_cvg_strt_dt, p_effective_date)
4158 ,p_business_group_id => p_business_group_id
4159 ,p_eligy_prfl_id => p_eligy_prfl_id
4160 ,p_inst_set => l_inst_dets
4161 ,p_inst_count => l_inst_count);
4162 --
4163 if l_inst_count > 0 then
4164 --
4165 -- Retreive the Use All Assignments for Eligibility flag from plan level
4166 -- or from program level
4167 --
4168 l_use_all_asnts_elig_flag := 'N' ;
4169 if p_pl_id is not null then
4170 --
4171 ben_comp_object.get_object(p_pl_id => p_pl_id
4172 ,p_rec => l_pl_rec);
4173 l_pl_use_all_asnts_elig_flag := l_pl_rec.use_all_asnts_elig_flag;
4174 --
4175 end if;
4176 if p_pgm_id is not null then
4177 --
4178 ben_comp_object.get_object(p_pgm_id => p_pgm_id
4179 ,p_rec => l_pgm_rec);
4180 l_pgm_use_all_asnts_elig_flag := l_pgm_rec.pgm_use_all_asnts_elig_flag;
4181 --
4182 end if;
4183 --
4184 -- looping thru each of the criteria
4185 --
4186 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
4187 --
4188 -- Now, we should check if there is a Rule given so that
4189 -- the min, max and frequency codes are to retrieved from the rule.
4190 --
4191 l_sched_effective_date := nvl(l_fonm_cvg_strt_dt,
4192 nvl(p_lf_evt_ocrd_dt,p_effective_date));
4193 --
4194 l_min_hours := null;
4195 l_max_hours := null;
4196 l_freq_cd := null;
4197 --
4198 hr_utility.set_location('criteria #' || l_insttorrw_num,20);
4199 --
4200 if l_inst_dets(l_insttorrw_num).schedd_hrs_rl is not null then
4201 l_output := benutils.formula
4202 (p_formula_id => l_inst_dets(l_insttorrw_num).schedd_hrs_rl
4203 ,p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date)
4204 ,p_business_group_id => p_business_group_id
4205 ,p_assignment_id => p_assignment_id
4206 ,p_organization_id => p_organization_id
4207 ,p_pgm_id => p_pgm_id
4208 ,p_pl_id => p_pl_id
4209 ,p_pl_typ_id => p_pl_typ_id
4210 ,p_opt_id => p_opt_id
4211 ,p_ler_id => p_ler_id
4212 ,p_param1 => 'BEN_IV_RT_STRT_DT'
4213 ,p_param1_value => fnd_date.date_to_canonical(ben_manage_life_events.g_fonm_rt_strt_dt)
4214 ,p_param2 => 'BEN_IV_CVG_STRT_DT'
4215 ,p_param2_value => fnd_date.date_to_canonical(l_fonm_cvg_strt_dt)
4216
4217 ,p_jurisdiction_code => p_jurisdiction_code);
4218
4219 --
4220 for l_count in l_output.first..l_output.last loop
4221 --
4222 declare
4223 invalid_param exception;
4224 begin
4225
4226 --
4227 if l_output(l_count).name = 'MIN_HOURS' then
4228 --
4229 l_min_hours := to_number(l_output(l_count).value);
4230 --
4231 elsif l_output(l_count).name = 'MAX_HOURS' then
4232 --
4233 l_max_hours := to_number(l_output(l_count).value);
4234 --
4235 elsif l_output(l_count).name = 'FREQUENCY' then
4236 --
4237 l_freq_cd := l_output(l_count).value;
4238 --
4239 else
4240 --
4241 -- Account for cases where formula returns an unknown
4242 -- variable name
4243
4244
4245 fnd_message.set_name('BEN','BEN_92310_FORMULA_RET_PARAM_');
4246 fnd_message.set_token('PROC',l_proc);
4247 fnd_message.set_token('FORMULA', l_inst_dets(l_insttorrw_num).schedd_hrs_rl);
4248 fnd_message.set_token('PARAMETER',l_output(l_count).name);
4249 -- Handling this particular exception seperately.
4250 raise invalid_param;
4251 --
4252 end if;
4253 --
4254 -- Code for type casting errors from formula return variables
4255 --
4256 exception
4257 --
4258 -- Code appended for bug# 2620550
4259 when invalid_param then
4260 fnd_message.raise_error;
4261 when others then
4262 --
4263 fnd_message.set_name('BEN','BEN_92311_FORMULA_VAL_PARAM');
4264 fnd_message.set_token('PROC',l_proc);
4265 fnd_message.set_token('FORMULA', l_inst_dets(l_insttorrw_num).schedd_hrs_rl);
4266 fnd_message.set_token('PARAMETER',l_output(l_count).name);
4267 fnd_message.raise_error;
4268 --
4269 end;
4270 end loop;
4271 --
4272 if l_min_hours is null and l_max_hours is null then
4273 fnd_message.set_name('BEN','BEN_92310_FORMULA_RET_PARAM_');
4274 fnd_message.set_token('PROC',l_proc);
4275 fnd_message.set_token('FORMULA', l_inst_dets(l_insttorrw_num).schedd_hrs_rl);
4276 fnd_message.set_token('PARAMETER','MIN_HOURS');
4277 fnd_message.raise_error;
4278 end if;
4279
4280 if l_freq_cd is null then
4281 fnd_message.set_name('BEN','BEN_92310_FORMULA_RET_PARAM_');
4282 fnd_message.set_token('PROC',l_proc);
4283 fnd_message.set_token('FORMULA', l_inst_dets(l_insttorrw_num).schedd_hrs_rl);
4284 fnd_message.set_token('PARAMETER','FREQUENCY');
4285 fnd_message.raise_error;
4286 end if;
4287 else
4288 l_min_hours := l_inst_dets(l_insttorrw_num).hrs_num;
4289 l_max_hours := l_inst_dets(l_insttorrw_num).max_hrs_num;
4290 l_freq_cd := l_inst_dets(l_insttorrw_num).freq_cd;
4291 end if;
4292 --
4293 hr_utility.set_location('l_min_hours' || l_min_hours,30);
4294 hr_utility.set_location('l_max_hours' || l_max_hours,30);
4295 hr_utility.set_location('l_freq_cd ' || l_freq_cd ,30);
4296 --
4297 -- Use the determination code given in the criteria in ELPRO to arrive
4298 -- at the effective date to be used for retrieving Normal Hours of the person.
4299 --
4300 if l_inst_dets(l_insttorrw_num).determination_cd is not null then
4301 --
4302 --
4303 ben_determine_date.main
4304 (p_date_cd => l_inst_dets(l_insttorrw_num).determination_cd,
4305 p_formula_id => l_inst_dets(l_insttorrw_num).determination_rl,
4306 p_per_in_ler_id => p_per_in_ler_id,
4307 p_person_id => p_person_id,
4308 p_pgm_id => p_pgm_id,
4309 p_pl_id => p_pl_id,
4310 p_oipl_id => p_oipl_id,
4311 p_comp_obj_mode => p_comp_obj_mode,
4312 p_business_group_id => p_business_group_id,
4313 p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date),
4314 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
4315 p_fonm_cvg_strt_dt => ben_manage_life_events.g_fonm_cvg_strt_dt,
4316 p_fonm_rt_strt_dt => ben_manage_life_events.g_fonm_rt_strt_dt,
4317 p_returned_date => l_sched_effective_date);
4318 --
4319 end if;
4320 --
4321 -- Get the persons Normal Hours which matches the frequency, or the sum of
4322 -- Normal Hours from all assignments which have the matching frequency when
4323 -- Use All assignments for eligibility flag is checked.
4324 --
4325 if l_pgm_use_all_asnts_elig_flag = 'Y' or l_pl_use_all_asnts_elig_flag = 'Y' then
4326 --
4327 l_use_all_asnts_elig_flag := 'Y';
4328 --
4329 end if;
4330 --
4331 hr_utility.set_location('asg eff. date ' || l_sched_effective_date ,40);
4332 hr_utility.set_location('l_use_all_asnts_elig_flag ' || l_use_all_asnts_elig_flag ,40);
4333 --
4334 open c_normal_hours (l_freq_cd,l_use_all_asnts_elig_flag) ;
4335 fetch c_normal_hours into l_normal_hours ;
4336 if c_normal_hours%found then
4337 --
4338 hr_utility.set_location('l_normal_hours ' || l_normal_hours ,50);
4339 close c_normal_hours ;
4340 --
4341 -- Before comparing the normal hours with the range , we have to perform
4342 -- the rounding
4343 --
4344 if (l_normal_hours is not null
4345 and l_inst_dets(l_insttorrw_num).rounding_cd is not null) then
4346 --
4347 l_normal_hours := benutils.do_rounding
4348 (p_rounding_cd => l_inst_dets(l_insttorrw_num).rounding_cd
4349 ,p_rounding_rl => l_inst_dets(l_insttorrw_num).rounding_rl
4350 ,p_value => l_normal_hours
4351 ,p_effective_date => nvl(p_lf_evt_ocrd_dt
4352 ,p_effective_date));
4353 --
4354 end if;
4355 --
4356 -- Now compare the normal hours with min and max values
4357 --
4358 if l_normal_hours is null then
4359 --
4360 l_ok := false;
4361 --
4362 else
4363 --
4364 if l_normal_hours between nvl(l_min_hours,0) and nvl(l_max_hours,999999999999999) then
4365 --
4366 l_ok := true;
4367 --
4368 else
4369 --
4370 l_ok := false;
4371 --
4372 end if;
4373 --
4374 end if;
4375 --
4376 else
4377 --
4378 close c_normal_hours ;
4379 l_ok := false;
4380 --
4381 end if;
4382
4383
4384 -- *********** start code prior to range of scheduled hours enhancement *********
4385 -- l_ok := nvl((nvl(p_normal_hrs,-1) = l_inst_dets(l_insttorrw_num).hrs_num and
4386 -- nvl(p_frequency,'-1') = l_inst_dets(l_insttorrw_num).freq_cd),FALSE);
4387 --if l_ok is null then
4388 -- l_ok:=false;
4389 --end if;
4390 --
4391 -- ************ end of code prior to range of scheduled hours enhancement *******
4392
4393 if l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
4394 --
4395 if p_score_compute_mode then
4396 if l_crit_passed is null then
4397 l_crit_passed := true;
4398 end if;
4399 write(l_score_tab,
4400 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
4401 l_inst_dets(l_insttorrw_num).short_code,
4402 l_inst_dets(l_insttorrw_num).pk_id,
4403 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
4404 l_inst_dets(l_insttorrw_num).criteria_weight));
4405 else
4406 exit;
4407 end if;
4408 --
4409 elsif l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
4410 --
4411 l_rows_found := true;
4412 l_ok := false;
4413 exit;
4414 --
4415 elsif (not l_ok) and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
4416 --
4417 l_rows_found := true;
4418 l_ok := true;
4419 if p_score_compute_mode then
4420 write(l_score_tab,
4421 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
4422 l_inst_dets(l_insttorrw_num).short_code,
4423 l_inst_dets(l_insttorrw_num).pk_id,
4424 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
4425 l_inst_dets(l_insttorrw_num).criteria_weight));
4426 end if;
4427 --exit;
4428 --
4429 elsif l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
4430 --
4431 l_rows_found := true;
4432 --
4433 end if;
4434 --
4435 end loop;
4436 --
4437 end if;
4438 --
4439 if l_crit_passed is null
4440 then
4441 if l_rows_found and
4442 not l_ok then
4443 --
4444 g_inelg_rsn_cd := 'SHR';
4445 fnd_message.set_name('BEN','BEN_91685_SCHED_HRS_PRFL_FAIL');
4446 hr_utility.set_location('Criteria Failed: '||l_proc,60);
4447 raise g_criteria_failed;
4448 --
4449 end if;
4450 end if;
4451 --
4452 if p_score_compute_mode
4453 then
4454 hr_utility.set_location('count '||l_score_tab.count,20);
4455 write(p_profile_score_tab,l_score_tab);
4456 end if;
4457 hr_utility.set_location('Leaving: '||l_proc,70);
4458 --
4459 end check_sched_hrs_elig;
4460 -- --------------------------------------------------
4461 -- This procedure det elig based on bargaining unit.
4462 -- --------------------------------------------------
4463 procedure check_brgng_unit_elig(p_eligy_prfl_id in number,
4464 p_business_group_id in number,
4465 p_score_compute_mode in boolean default false,
4466 p_profile_score_tab in out nocopy scoreTab,
4467 p_effective_date in date,
4468 p_bargaining_unit_code in varchar2) is
4469 --
4470 l_proc varchar2(100) := g_package||'check_brg_unit_elig';
4471 l_inst_dets ben_elp_cache.g_cache_elpebu_instor;
4472 l_inst_count number;
4473 l_insttorrw_num binary_integer;
4474 l_ok boolean := false;
4475 l_rows_found boolean := false;
4476 l_crit_passed boolean;
4477 l_score_tab scoreTab;
4478 --
4479 begin
4480 --
4481 hr_utility.set_location('Entering : '||l_proc,10);
4482 --
4483 -- Getting eligibility profile bargaining unit by eligibility profile
4484 --
4485 ben_elp_cache.elpebu_getcacdets
4486 (p_effective_date => p_effective_date
4487 ,p_business_group_id => p_business_group_id
4488 ,p_eligy_prfl_id => p_eligy_prfl_id
4489 ,p_inst_set => l_inst_dets
4490 ,p_inst_count => l_inst_count);
4491 --
4492 if l_inst_count > 0 then
4493 --
4494 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
4495 --
4496 l_ok := nvl((nvl(p_bargaining_unit_code,'-1') = l_inst_dets(l_insttorrw_num).brgng_unit_cd),FALSE);
4497 --if l_ok is null then
4498 -- l_ok:=false;
4499 --end if;
4500 --
4501 if l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
4502 --
4503 if p_score_compute_mode then
4504 if l_crit_passed is null then
4505 l_crit_passed := true;
4506 end if;
4507 write(l_score_tab,
4508 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
4509 l_inst_dets(l_insttorrw_num).short_code,
4510 l_inst_dets(l_insttorrw_num).pk_id,
4511 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
4512 l_inst_dets(l_insttorrw_num).criteria_weight));
4513 else
4514 exit;
4515 end if;
4516 --
4517 elsif l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
4518 --
4519 l_rows_found := true;
4520 l_ok := false;
4521 exit;
4522 --
4523 elsif (not l_ok) and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
4524 --
4525 l_rows_found := true;
4526 l_ok := true;
4527 if p_score_compute_mode then
4528 write(l_score_tab,
4529 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
4530 l_inst_dets(l_insttorrw_num).short_code,
4531 l_inst_dets(l_insttorrw_num).pk_id,
4532 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
4533 l_inst_dets(l_insttorrw_num).criteria_weight));
4534 end if;
4535 -- exit;
4536 --
4537 elsif l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
4538 --
4539 l_rows_found := true;
4540 --
4541 end if;
4542 --
4543 end loop;
4544 --
4545 end if;
4546 --
4547 if l_crit_passed is null
4548 then
4549 if l_rows_found and
4550 not l_ok then
4551 --
4552 g_inelg_rsn_cd := 'BRG';
4553 fnd_message.set_name('BEN','BEN_91686_BRGNG_UNIT_PRFL_FAIL');
4554 hr_utility.set_location('Criteria Failed: '||l_proc,20);
4555 raise g_criteria_failed;
4556 --
4557 end if;
4558 end if;
4559 --
4560 if p_score_compute_mode
4561 then
4562 hr_utility.set_location('count '||l_score_tab.count,20);
4563 write(p_profile_score_tab,l_score_tab);
4564 end if;
4565 hr_utility.set_location('Leaving: '||l_proc,20);
4566 --
4567 end check_brgng_unit_elig;
4568 -- ----------------------------------------------------------
4569 -- This procedure det elig based on labour union membership.
4570 -- ----------------------------------------------------------
4571 procedure check_lbr_union_elig(p_eligy_prfl_id in number,
4572 p_business_group_id in number,
4573 p_score_compute_mode in boolean default false,
4574 p_profile_score_tab in out nocopy scoreTab,
4575 p_effective_date in date,
4576 p_labour_union_member_flag in varchar2) is
4577 --
4578 l_proc varchar2(100) := g_package||'check_lbr_union_elig';
4579 l_inst_dets ben_elp_cache.g_cache_elpelu_instor;
4580 l_inst_count number;
4581 l_insttorrw_num binary_integer;
4582 l_ok boolean := false;
4583 l_rows_found boolean := false;
4584 l_crit_passed boolean;
4585 l_score_tab scoreTab;
4586 --
4587 begin
4588 --
4589 hr_utility.set_location('Entering : '||l_proc,10);
4590 --
4591 -- Getting eligibility profile labour union membership by eligibility profile
4592 --
4593 ben_elp_cache.elpelu_getcacdets
4594 (p_effective_date => p_effective_date
4595 ,p_business_group_id => p_business_group_id
4596 ,p_eligy_prfl_id => p_eligy_prfl_id
4597 ,p_inst_set => l_inst_dets
4598 ,p_inst_count => l_inst_count);
4599 --
4600 if l_inst_count > 0 then
4601 --
4602 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
4603 --
4604 l_ok := nvl((l_inst_dets(l_insttorrw_num).lbr_mmbr_flag = nvl(p_labour_union_member_flag,'-1')),FALSE);
4605 --if l_ok is null then
4606 -- l_ok:=false;
4607 --end if;
4608 --
4609 if l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
4610 --
4611 if p_score_compute_mode then
4612 if l_crit_passed is null then
4613 l_crit_passed := true;
4614 end if;
4615 write(l_score_tab,
4616 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
4617 l_inst_dets(l_insttorrw_num).short_code,
4618 l_inst_dets(l_insttorrw_num).pk_id,
4619 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
4620 l_inst_dets(l_insttorrw_num).criteria_weight));
4621 else
4622 exit;
4623 end if;
4624 --
4625 elsif l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
4626 --
4627 l_rows_found := true;
4628 l_ok := false;
4629 exit;
4630 --
4631 elsif (not l_ok) and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
4632 --
4633 l_rows_found := true;
4634 l_ok := true;
4635 if p_score_compute_mode then
4636 write(l_score_tab,
4637 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
4638 l_inst_dets(l_insttorrw_num).short_code,
4639 l_inst_dets(l_insttorrw_num).pk_id,
4640 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
4641 l_inst_dets(l_insttorrw_num).criteria_weight));
4642 end if;
4643 -- exit;
4644 --
4645 elsif l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
4646 --
4647 l_rows_found := true;
4648 --
4649 end if;
4650 --
4651 end loop;
4652 --
4653 end if;
4654 --
4655 if l_crit_passed is null
4656 then
4657 if l_rows_found and
4658 not l_ok then
4659 --
4660 g_inelg_rsn_cd := 'LBR';
4661 fnd_message.set_name('BEN','BEN_91687_LBR_MMBR_PRFL_FAIL');
4662 hr_utility.set_location('Criteria Failed: '||l_proc,20);
4663 raise g_criteria_failed;
4664 --
4665 end if;
4666 end if;
4667 --
4668 if p_score_compute_mode
4669 then
4670 hr_utility.set_location('count '||l_score_tab.count,20);
4671 write(p_profile_score_tab,l_score_tab);
4672 end if;
4673 hr_utility.set_location('Leaving: '||l_proc,20);
4674 --
4675 end check_lbr_union_elig;
4676 -- --------------------------------------------------
4677 -- This procedure det elig based on employee status.
4678 -- --------------------------------------------------
4679 procedure check_ee_stat_elig(p_eligy_prfl_id in number,
4680 p_business_group_id in number,
4681 p_score_compute_mode in boolean default false,
4682 p_profile_score_tab in out nocopy scoreTab,
4683 p_effective_date in date,
4684 p_assignment_status_type_id in number) is
4685 --
4686 l_proc varchar2(100) := g_package||'check_ee_stat_elig';
4687 --
4688 l_inst_dets ben_elp_cache.g_cache_elpees_instor;
4689 l_inst_count number;
4690 l_insttorrw_num binary_integer;
4691 --
4692 l_ok boolean := false;
4693 l_rows_found boolean := false;
4694 l_crit_passed boolean;
4695 l_score_tab scoreTab;
4696 --
4697 begin
4698 --
4699 hr_utility.set_location('Entering : '||l_proc,10);
4700 --
4701 -- Getting eligibility profile assignment status type by eligibility profile
4702 --
4703 ben_elp_cache.elpees_getcacdets
4704 (p_effective_date => p_effective_date
4705 ,p_business_group_id => p_business_group_id
4706 ,p_eligy_prfl_id => p_eligy_prfl_id
4707 ,p_inst_set => l_inst_dets
4708 ,p_inst_count => l_inst_count);
4709 --
4710 if l_inst_count > 0 then
4711 --
4712 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
4713 --
4714 l_ok := nvl((l_inst_dets(l_insttorrw_num).assignment_status_type_id =
4715 nvl(p_assignment_status_type_id,-1)),FALSE);
4716 --if l_ok is null then
4717 -- l_ok:=false;
4718 --end if;
4719 --
4720 if l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
4721 --
4722 if p_score_compute_mode then
4723 if l_crit_passed is null then
4724 l_crit_passed := true;
4725 end if;
4726 write(l_score_tab,
4727 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
4728 l_inst_dets(l_insttorrw_num).short_code,
4729 l_inst_dets(l_insttorrw_num).pk_id,
4730 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
4731 l_inst_dets(l_insttorrw_num).criteria_weight));
4732 else
4733 exit;
4734 end if;
4735 --
4736 elsif l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
4737 --
4738 l_rows_found := true;
4739 l_ok := false;
4740 exit;
4741 --
4742 elsif (not l_ok) and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
4743 --
4744 l_rows_found := true;
4745 l_ok := true;
4746 if p_score_compute_mode then
4747 write(l_score_tab,
4748 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
4749 l_inst_dets(l_insttorrw_num).short_code,
4750 l_inst_dets(l_insttorrw_num).pk_id,
4751 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
4752 l_inst_dets(l_insttorrw_num).criteria_weight));
4753 end if;
4754 -- exit;
4755 --
4756 elsif l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
4757 --
4758 l_rows_found := true;
4759 --
4760 end if;
4761 --
4762 end loop;
4763 --
4764 end if;
4765 --
4766 if l_crit_passed is null
4767 then
4768 if l_rows_found and
4769 not l_ok then
4770 --
4771 g_inelg_rsn_cd := 'STA';
4772 fnd_message.set_name('BEN','BEN_91688_EE_STAT_PRFL_FAIL');
4773 hr_utility.set_location('Criteria Failed: '||l_proc,20);
4774 raise g_criteria_failed;
4775 --
4776 end if;
4777 end if;
4778 --
4779 if p_score_compute_mode
4780 then
4781 hr_utility.set_location('count '||l_score_tab.count,20);
4782 write(p_profile_score_tab,l_score_tab);
4783 end if;
4784 hr_utility.set_location('Leaving: '||l_proc,20);
4785 --
4786 end check_ee_stat_elig;
4787 -- ---------------------------------------------------
4788 -- This procedure det elig based on leave of absence.
4789 -- ---------------------------------------------------
4790 procedure check_loa_rsn_elig
4791 (p_eligy_prfl_id in number,
4792 p_person_id in number,
4793 p_business_group_id in number,
4794 p_score_compute_mode in boolean default false,
4795 p_profile_score_tab in out nocopy scoreTab,
4796 p_assignment_id in number,
4797 p_assignment_type in varchar2,
4798 p_abs_attd_type_id in varchar2 default null,
4799 p_abs_attd_reason_id in varchar2 default null,
4800 p_effective_date in date) is
4801 --
4802 l_proc varchar2(100) := g_package||'check_loa_rsn_elig';
4803 l_inst_dets ben_elp_cache.g_cache_elpelr_instor;
4804 l_inst_count number;
4805 l_insttorrw_num binary_integer;
4806 l_ok boolean := false;
4807 l_ok1 boolean := false;
4808 l_ok2 boolean := false;
4809 l_rows_found boolean := false;
4810 l_dummy varchar2(1);
4811 l_ass_rec per_all_assignments_f%rowtype;
4812 l_aei_rec per_assignment_extra_info%rowtype;
4813 l_crit_passed boolean;
4814 l_score_tab scoreTab;
4815 --
4816 cursor c1(p_absence_attendance_type_id in number,
4817 p_abs_attendance_reason_id in number) is
4818 select null
4819 from per_absence_attendances abs
4820 where abs.person_id = p_person_id
4821 and abs.absence_attendance_type_id = p_absence_attendance_type_id
4822 and nvl(abs.abs_attendance_reason_id,-1) =
4823 nvl(p_abs_attendance_reason_id,nvl(abs.abs_attendance_reason_id,-1))
4824 and p_effective_date
4825 between nvl(abs.date_start,p_effective_date)
4826 and nvl(abs.date_end, p_effective_date)
4827 and abs.business_group_id = p_business_group_id;
4828 --
4829 begin
4830 --
4831 hr_utility.set_location('Entering : '||l_proc,10);
4832 --
4833 -- Getting eligibility profile leave of absence reason by eligibility profile
4834 --
4835 ben_elp_cache.elpelr_getcacdets
4836 (p_effective_date => p_effective_date
4837 ,p_business_group_id => p_business_group_id
4838 ,p_eligy_prfl_id => p_eligy_prfl_id
4839 ,p_inst_set => l_inst_dets
4840 ,p_inst_count => l_inst_count);
4841 --
4842 if l_inst_count > 0 then
4843 --
4844 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
4845 --
4846 l_rows_found := true;
4847 --
4848 if p_abs_attd_type_id is not null then
4849 if p_abs_attd_type_id = l_inst_dets(l_insttorrw_num).absence_attendance_type_id and
4850 nvl(p_abs_attd_reason_id,-1) = nvl(l_inst_dets(l_insttorrw_num).abs_attendance_reason_id,-1) then
4851 if l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
4852 --
4853 l_ok := true;
4854 if p_score_compute_mode then
4855 if l_crit_passed is null then
4856 l_crit_passed := true;
4857 end if;
4858 write(l_score_tab,
4859 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
4860 l_inst_dets(l_insttorrw_num).short_code,
4861 l_inst_dets(l_insttorrw_num).pk_id,
4862 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
4863 l_inst_dets(l_insttorrw_num).criteria_weight));
4864 else
4865 exit;
4866 end if;
4867 --
4868 elsif l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
4869 --
4870 l_ok := false;
4871 exit;
4872 --
4873 end if;
4874
4875 elsif l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
4876 --
4877 l_ok := false;
4878 --
4879 elsif l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
4880 --
4881 l_ok := true;
4882 if p_score_compute_mode then
4883 write(l_score_tab,
4884 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
4885 l_inst_dets(l_insttorrw_num).short_code,
4886 l_inst_dets(l_insttorrw_num).pk_id,
4887 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
4888 l_inst_dets(l_insttorrw_num).criteria_weight));
4889 end if;
4890 --
4891 end if;
4892
4893 else
4894 if p_assignment_type <> 'B' then
4895 --
4896 open c1(l_inst_dets(l_insttorrw_num).absence_attendance_type_id,
4897 l_inst_dets(l_insttorrw_num).abs_attendance_reason_id);
4898 --
4899 fetch c1 into l_dummy;
4900 --
4901 if c1%found then
4902 --
4903 if l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
4904 --
4905 l_ok := true;
4906 if p_score_compute_mode then
4907 if l_crit_passed is null then
4908 l_crit_passed := true;
4909 end if;
4910 write(l_score_tab,
4911 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
4912 l_inst_dets(l_insttorrw_num).short_code,
4913 l_inst_dets(l_insttorrw_num).pk_id,
4914 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
4915 l_inst_dets(l_insttorrw_num).criteria_weight));
4916 else
4917 exit;
4918 end if;
4919 --
4920 elsif l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
4921 --
4922 l_ok := false;
4923 exit;
4924 --
4925 end if;
4926 --
4927 elsif l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
4928 --
4929 l_ok := false;
4930 --
4931 elsif l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
4932 --
4933 l_ok := true;
4934 if p_score_compute_mode then
4935 write(l_score_tab,
4936 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
4937 l_inst_dets(l_insttorrw_num).short_code,
4938 l_inst_dets(l_insttorrw_num).pk_id,
4939 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
4940 l_inst_dets(l_insttorrw_num).criteria_weight));
4941 end if;
4942 --
4943 end if;
4944 --
4945 close c1;
4946 --
4947 else
4948 --
4949 /* Start of Changes for WWBUG: 2141209 */
4950 if p_assignment_id is not null then
4951 ben_person_object.get_object(p_assignment_id => p_assignment_id,
4952 p_rec => l_aei_rec);
4953 --
4954 l_ok1 := nvl((nvl(l_aei_rec.aei_information11,'-1') =
4955 l_inst_dets(l_insttorrw_num).absence_attendance_type_id),FALSE);
4956 l_ok2 := nvl((nvl(l_aei_rec.aei_information12,'-1') =
4957 l_inst_dets(l_insttorrw_num).abs_attendance_reason_id),FALSE);
4958 else l_ok := false;
4959 exit;
4960 end if;
4961 /* End of Changes for WWBUG: 2141209 */
4962 --
4963 if l_ok1 and
4964 l_ok2 and
4965 l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
4966 --
4967 l_ok := true;
4968 if p_score_compute_mode then
4969 if l_crit_passed is null then
4970 l_crit_passed := true;
4971 end if;
4972 write(l_score_tab,
4973 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
4974 l_inst_dets(l_insttorrw_num).short_code,
4975 l_inst_dets(l_insttorrw_num).pk_id,
4976 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
4977 l_inst_dets(l_insttorrw_num).criteria_weight));
4978 else
4979 exit;
4980 end if;
4981 --
4982 elsif l_ok1 and
4983 l_ok2 and
4984 l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
4985 --
4986 l_ok := false;
4987 exit;
4988 --
4989 elsif (not (l_ok1 and l_ok2)) and
4990 l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
4991 --
4992 l_ok := true;
4993 if p_score_compute_mode then
4994 write(l_score_tab,
4995 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
4996 l_inst_dets(l_insttorrw_num).short_code,
4997 l_inst_dets(l_insttorrw_num).pk_id,
4998 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
4999 l_inst_dets(l_insttorrw_num).criteria_weight));
5000 end if;
5001 -- exit ;
5002 --
5003 elsif l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
5004 --
5005 l_ok := false;
5006 --
5007 end if;
5008 --
5009 end if;
5010 end if;
5011 --
5012 end loop;
5013 --
5014 end if;
5015 --
5016 if l_crit_passed is null
5017 then
5018 if l_rows_found and
5019 not l_ok then
5020 --
5021 g_inelg_rsn_cd := 'LOA';
5022 fnd_message.set_name('BEN','BEN_91689_PER_LOA_PRFL_FAIL');
5023 hr_utility.set_location('Criteria Failed: '||l_proc,20);
5024 raise g_criteria_failed;
5025 --
5026 end if;
5027 end if;
5028 --
5029 if p_score_compute_mode
5030 then
5031 hr_utility.set_location('count '||l_score_tab.count,20);
5032 write(p_profile_score_tab,l_score_tab);
5033 end if;
5034 hr_utility.set_location('Leaving: '||l_proc,20);
5035 --
5036 end check_loa_rsn_elig;
5037 -- -----------------------------------------------
5038 -- This procedure det elig based on legal entity.
5039 -- -----------------------------------------------
5040 procedure check_lgl_enty_elig(p_eligy_prfl_id in number,
5041 p_business_group_id in number,
5042 p_score_compute_mode in boolean default false,
5043 p_profile_score_tab in out nocopy scoreTab,
5044 p_effective_date in date,
5045 p_gre_name in varchar2) is
5046 --
5047 l_proc varchar2(100) := g_package||'check_lgl_ent_elig';
5048 l_inst_dets ben_elp_cache.g_cache_elpeln_instor;
5049 l_inst_count number;
5050 l_insttorrw_num binary_integer;
5051 l_ok boolean := false;
5052 l_rows_found boolean := false;
5053 l_crit_passed boolean;
5054 l_score_tab scoreTab;
5055 --
5056 begin
5057 --
5058 hr_utility.set_location('Entering : '||l_proc,10);
5059 --
5060 -- Getting eligibility profile legal entity by eligibility profile
5061 --
5062 ben_elp_cache.elpeln_getcacdets
5063 (p_effective_date => p_effective_date
5064 ,p_business_group_id => p_business_group_id
5065 ,p_eligy_prfl_id => p_eligy_prfl_id
5066 ,p_inst_set => l_inst_dets
5067 ,p_inst_count => l_inst_count);
5068 --
5069 hr_utility.set_location('Got Profiles : '||l_proc,10);
5070 --
5071 if l_inst_count > 0 then
5072 --
5073 hr_utility.set_location('In Loop : '||l_proc,10);
5074 --
5075 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
5076 --
5077 l_ok := nvl((l_inst_dets(l_insttorrw_num).name = nvl(p_gre_name,'-1')),FALSE);
5078 --if l_ok is null then
5079 -- l_ok:=false;
5080 --end if;
5081 --
5082 if l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
5083 --
5084 if p_score_compute_mode then
5085 if l_crit_passed is null then
5086 l_crit_passed := true;
5087 end if;
5088 write(l_score_tab,
5089 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
5090 l_inst_dets(l_insttorrw_num).short_code,
5091 l_inst_dets(l_insttorrw_num).pk_id,
5092 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
5093 l_inst_dets(l_insttorrw_num).criteria_weight));
5094 else
5095 exit;
5096 end if;
5097 --
5098 elsif l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
5099 --
5100 l_rows_found := true;
5101 l_ok := false;
5102 exit;
5103 --
5104 elsif (not l_ok) and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
5105 --
5106 l_rows_found := true;
5107 l_ok := true;
5108 if p_score_compute_mode then
5109 write(l_score_tab,
5110 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
5111 l_inst_dets(l_insttorrw_num).short_code,
5112 l_inst_dets(l_insttorrw_num).pk_id,
5113 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
5114 l_inst_dets(l_insttorrw_num).criteria_weight));
5115 end if;
5116 -- exit ;
5117 --
5118 elsif l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
5119 --
5120 l_rows_found := true;
5121 --
5122 end if;
5123 --
5124 end loop;
5125 --
5126 end if;
5127 --
5128 if l_crit_passed is null
5129 then
5130 if l_rows_found and
5131 not l_ok then
5132 --
5133 g_inelg_rsn_cd := 'LGL';
5134 fnd_message.set_name('BEN','BEN_91690_LGL_ENTY_PRFL_FAIL');
5135 hr_utility.set_location('Criteria Failed: '||l_proc,20);
5136 raise g_criteria_failed;
5137 --
5138 end if;
5139 end if;
5140 --
5141 if p_score_compute_mode
5142 then
5143 hr_utility.set_location('count '||l_score_tab.count,20);
5144 write(p_profile_score_tab,l_score_tab);
5145 end if;
5146 hr_utility.set_location('Copying gre cd : ',10);
5147 --
5148 hr_utility.set_location('Leaving : '||l_proc,10);
5149 --
5150 end check_lgl_enty_elig;
5151 -- ----------------------------------------------------------------
5152 -- This procedure det elig based on participation in another plan.
5153 -- ----------------------------------------------------------------
5154 procedure check_prtt_in_anthr_pl_elig(p_eligy_prfl_id in number,
5155 p_person_id in number,
5156 p_business_group_id in number,
5157 p_effective_date in date,
5158 p_lf_evt_ocrd_dt in date) is
5159 --
5160 l_proc varchar2(100) := g_package||
5161 'check_prtt_in_anthr_pl_elig';
5162 l_inst_dets ben_elp_cache.g_cache_elpepp_instor;
5163 l_inst_count number;
5164 l_insttorrw_num binary_integer;
5165 l_ok boolean := false;
5166 l_rows_found boolean := false;
5167 l_dummy varchar2(1);
5168 l_pl_id ben_elig_prtt_anthr_pl_prte_f.pl_id%type;
5169 l_excld_flag ben_elig_prtt_anthr_pl_prte_f.excld_flag%type;
5170 l_enrlt_pl_id ben_prtt_enrt_rslt_f.pl_id%type;
5171 l_sspndd_flag ben_prtt_enrt_rslt_f.sspndd_flag%type;
5172 l_prtt_is_cvrd_flag ben_prtt_enrt_rslt_f.prtt_is_cvrd_flag%type;
5173 --
5174 cursor c1(p_pl_id in number) is
5175 select null
5176 from ben_elig_per_f epo,
5177 ben_per_in_ler pil
5178 where epo.person_id = p_person_id
5179 and epo.pl_id = p_pl_id
5180 and p_effective_date
5181 between epo.effective_start_date
5182 and epo.effective_end_date
5183 and epo.business_group_id = p_business_group_id
5184 and pil.per_in_ler_id(+)=epo.per_in_ler_id
5185 -- and pil.business_group_id(+)=epo.business_group_id
5186 and ( pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT') -- found row condition
5187 or pil.per_in_ler_stat_cd is null -- outer join condition
5188 )
5189 ;
5190
5191 begin
5192 --
5193 hr_utility.set_location('Entering : '||l_proc,10);
5194 --
5195 -- Getting eligibility profile other plan by eligibility profile
5196 --
5197 ben_elp_cache.elpepp_getcacdets
5198 (p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date)
5199 ,p_business_group_id => p_business_group_id
5200 ,p_eligy_prfl_id => p_eligy_prfl_id
5201 ,p_inst_set => l_inst_dets
5202 ,p_inst_count => l_inst_count
5203 );
5204 --
5205 if l_inst_count > 0 then
5206 --
5207 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
5208 --
5209 l_rows_found := true;
5210 --
5211 open c1(l_inst_dets(l_insttorrw_num).pl_id);
5212 fetch c1 into l_dummy;
5213 if c1%found then
5214 --
5215 close c1;
5216 --
5217 if l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
5218 l_ok := true;
5219 exit;
5220 end if;
5221 --
5222 if l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
5223 l_ok := false;
5224 exit;
5225 end if;
5226 --
5227 else
5228 --
5229 close c1;
5230 --
5231 if l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
5232 l_ok := true;
5233 -- exit;
5234 end if;
5235 end if;
5236 --
5237 end loop;
5238 --
5239 end if;
5240 --
5241 if l_rows_found and
5242 not l_ok then
5243 --
5244 g_inelg_rsn_cd := 'PLN';
5245 fnd_message.set_name('BEN','BEN_91691_PRTN_PL_PRFL_FAIL');
5246 hr_utility.set_location('Criteria Failed: '||l_proc,20);
5247 raise g_criteria_failed;
5248 --
5249 end if;
5250 --
5251 hr_utility.set_location('Leaving: '||l_proc,20);
5252 --
5253 end check_prtt_in_anthr_pl_elig;
5254 -- ---------------------------------------------------------------
5255 -- This procedure det elig based on full time/part time category.
5256 -- ---------------------------------------------------------------
5257 procedure check_fl_tm_pt_elig(p_eligy_prfl_id in number,
5258 p_business_group_id in number,
5259 p_score_compute_mode in boolean default false,
5260 p_profile_score_tab in out nocopy scoreTab,
5261 p_effective_date in date,
5262 p_employment_category in varchar2) is
5263 --
5264 l_proc varchar2(100) := g_package||'check_fl_tm_pt_elig';
5265 l_inst_dets ben_elp_cache.g_cache_elpefp_instor;
5266 l_inst_count number;
5267 l_insttorrw_num binary_integer;
5268 l_rows_found boolean := false;
5269 l_ok boolean := false;
5270 l_crit_passed boolean;
5271 l_score_tab scoreTab;
5272 --
5273 begin
5274 --
5275 hr_utility.set_location('Entering : '||l_proc,10);
5276 --
5277 -- Getting eligibility profile full/part time by eligibility profile
5278 --
5279 ben_elp_cache.elpefp_getcacdets
5280 (p_effective_date => p_effective_date
5281 ,p_business_group_id => p_business_group_id
5282 ,p_eligy_prfl_id => p_eligy_prfl_id
5283 ,p_inst_set => l_inst_dets
5284 ,p_inst_count => l_inst_count);
5285 --
5286 if l_inst_count > 0 then
5287 --
5288 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
5289 --
5290 l_ok := nvl((nvl(p_employment_category,'-1') =
5291 l_inst_dets(l_insttorrw_num).fl_tm_pt_tm_cd),FALSE);
5292 --if l_ok is null then
5293 -- l_ok:=false;
5294 --end if;
5295 --
5296 if l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
5297 --
5298 if p_score_compute_mode then
5299 if l_crit_passed is null then
5300 l_crit_passed := true;
5301 end if;
5302 write(l_score_tab,
5303 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
5304 l_inst_dets(l_insttorrw_num).short_code,
5305 l_inst_dets(l_insttorrw_num).pk_id,
5306 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
5307 l_inst_dets(l_insttorrw_num).criteria_weight));
5308 else
5309 exit;
5310 end if;
5311 --
5312 elsif l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
5313 --
5314 l_rows_found := true;
5315 l_ok := false;
5316 exit;
5317 --
5318 elsif (not l_ok) and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
5319 --
5320 l_rows_found := true;
5321 l_ok := true;
5322 if p_score_compute_mode then
5323 write(l_score_tab,
5324 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
5325 l_inst_dets(l_insttorrw_num).short_code,
5326 l_inst_dets(l_insttorrw_num).pk_id,
5327 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
5328 l_inst_dets(l_insttorrw_num).criteria_weight));
5329 end if;
5330 -- exit;
5331 --
5332 elsif l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
5333 --
5334 l_rows_found := true;
5335 --
5336 end if;
5337 --
5338 end loop;
5339 --
5340 end if;
5341 --
5342 if l_crit_passed is null
5343 then
5344 if l_rows_found and
5345 not l_ok then
5346 --
5347 -- There were non-excludes and we didn't match any
5348 --
5349 g_inelg_rsn_cd := 'FPT';
5350 fnd_message.set_name('BEN','BEN_91692_FL_PT_PRFL_FAIL');
5351 hr_utility.set_location('Criteria Failed: '||l_proc,20);
5352 raise g_criteria_failed;
5353 --
5354 end if;
5355 end if;
5356 --
5357 if p_score_compute_mode
5358 then
5359 hr_utility.set_location('count '||l_score_tab.count,20);
5360 write(p_profile_score_tab,l_score_tab);
5361 end if;
5362 hr_utility.set_location('Leaving: '||l_proc,20);
5363 --
5364 end check_fl_tm_pt_elig;
5365 -- ---------------------------------------------------------------
5366 -- This procedure det elig based on persons benefit balance.
5367 -- ---------------------------------------------------------------
5368 procedure check_person_ben_bal(p_eligy_prfl_id in number,
5369 p_person_id in number,
5370 p_business_group_id in number,
5371 p_effective_date in date,
5372 p_per_comp_val in number,
5373 p_eval_typ in varchar2,
5374 p_comp_obj_mode in boolean,
5375 p_lf_evt_ocrd_dt in date,
5376 p_per_in_ler_id in number default null,
5377 p_score_compute_mode in boolean default false,
5378 p_profile_score_tab in out nocopy scoreTab,
5379 p_pl_id in number default null,
5380 p_pgm_id in number default null,
5381 p_oipl_id in number default null,
5382 p_plip_id in number default null,
5383 p_opt_id in number default null) is
5384 --
5385 l_proc varchar2(100):=g_package||'check_person_ben_bal';
5386 l_inst_dets ben_elp_cache.g_cache_elpecl_instor;
5387 l_inst_count number;
5388 l_insttorrw_num binary_integer;
5389 l_ok boolean := false;
5390 l_rows_found boolean := false;
5391 l_per_comp_val number := p_per_comp_val;
5392 l_crit_passed boolean;
5393 l_score_tab scoreTab;
5394 --
5395 begin
5396 --
5397 hr_utility.set_location('Entering: '||l_proc, 10);
5398 --
5399 -- Getting eligibility profile compensation level by eligibility profile
5400 --
5401 ben_elp_cache.elpecl_getcacdets
5402 (p_effective_date => nvl(l_fonm_cvg_strt_dt,p_effective_date)
5403 ,p_business_group_id => p_business_group_id
5404 ,p_comp_src_cd => 'BNFTBALTYP'
5405 ,p_eligy_prfl_id => p_eligy_prfl_id
5406 ,p_inst_set => l_inst_dets
5407 ,p_inst_count => l_inst_count);
5408 --
5409 if l_inst_count > 0 then
5410 --
5411 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
5412 --
5413 --if p_per_comp_val is null then
5414 --
5415 --fnd_message.set_name('BEN','BEN_91767_DERIVABLE_NO_EXIST');
5416 --raise ben_manage_life_events.g_record_error;
5417 --
5418 --end if;
5419 --
5420 if not p_comp_obj_mode or
5421 p_eval_typ <> 'E' then
5422 --
5423 ben_derive_factors.determine_compensation
5424 (p_person_id => p_person_id
5425 ,p_comp_lvl_fctr_id => l_inst_dets(l_insttorrw_num).comp_lvl_fctr_id
5426 ,p_pgm_id => p_pgm_id
5427 ,p_pl_id => p_pl_id
5428 ,p_oipl_id => p_oipl_id
5429 ,p_per_in_ler_id => p_per_in_ler_id
5430 ,p_comp_obj_mode => p_comp_obj_mode
5431 ,p_perform_rounding_flg => true
5432 ,p_effective_date => p_effective_date
5433 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
5434 ,p_business_group_id => p_business_group_id
5435 ,p_value => l_per_comp_val
5436 ,p_fonm_cvg_strt_dt => l_fonm_cvg_strt_dt );
5437 --
5438 end if;
5439 l_ok := is_ok(l_per_comp_val
5440 ,l_inst_dets(l_insttorrw_num).mx_comp_val
5441 ,l_inst_dets(l_insttorrw_num).mn_comp_val
5442 ,l_inst_dets(l_insttorrw_num).no_mx_comp_flag
5443 ,l_inst_dets(l_insttorrw_num).no_mn_comp_flag
5444 );
5445 --if l_ok is null then
5446 -- l_ok:=false;
5447 --end if;
5448 --
5449 if l_per_comp_val is null then
5450 --
5451 l_ok := false;
5452 --
5453 end if;
5454 --
5455 if l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
5456 --
5457 if p_score_compute_mode then
5458 if l_crit_passed is null then
5459 l_crit_passed := true;
5460 end if;
5461 write(l_score_tab,
5462 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
5463 l_inst_dets(l_insttorrw_num).short_code,
5464 l_inst_dets(l_insttorrw_num).pk_id,
5465 ( l_per_comp_val * nvl(l_inst_dets(l_insttorrw_num).criteria_weight, 0) ) +
5466 nvl(l_inst_dets(l_insttorrw_num).criteria_score, 0) /* Bug 4429071 */
5467 );
5468 else
5469 exit;
5470 end if;
5471 --
5472 elsif l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
5473 --
5474 l_rows_found := true;
5475 l_ok := false;
5476 exit;
5477 --
5478 elsif (not l_ok) and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
5479 --
5480 l_rows_found := true;
5481 l_ok := true;
5482 if p_score_compute_mode then
5483 write(l_score_tab,
5484 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
5485 l_inst_dets(l_insttorrw_num).short_code,
5486 l_inst_dets(l_insttorrw_num).pk_id,
5487 ( l_per_comp_val * nvl(l_inst_dets(l_insttorrw_num).criteria_weight, 0) ) +
5488 nvl(l_inst_dets(l_insttorrw_num).criteria_score, 0) /* Bug 4429071 */
5489 );
5490 end if;
5491 -- exit;
5492 --
5493 elsif l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
5494 --
5495 l_rows_found := true;
5496 --
5497 end if;
5498 --
5499 end loop;
5500 --
5501 end if;
5502 --
5503 if l_crit_passed is null
5504 then
5505 if l_rows_found and
5506 not l_ok then
5507 --
5508 g_inelg_rsn_cd := 'CMP';
5509 fnd_message.set_name('BEN','BEN_91672_COMP_LVL_PRFL_FAIL');
5510 hr_utility.set_location('Criteria Failed: '||l_proc,20);
5511 raise g_criteria_failed;
5512 --
5513 end if;
5514 end if;
5515 --
5516 if p_score_compute_mode
5517 then
5518 hr_utility.set_location('count '||l_score_tab.count,20);
5519 write(p_profile_score_tab,l_score_tab);
5520 end if;
5521 hr_utility.set_location('Leaving :'||l_proc,20);
5522 --
5523 end check_person_ben_bal;
5524 --
5525 procedure check_asnt_set
5526 (p_eligy_prfl_id in number,
5527 p_business_group_id in number,
5528 p_score_compute_mode in boolean default false,
5529 p_profile_score_tab in out nocopy scoreTab,
5530 p_person_id in number,
5531 p_effective_date in date) is
5532 --
5533 l_proc varchar2(100):=g_package||'check_asnt_set';
5534 l_inst_dets ben_elp_cache.g_cache_elpean_instor;
5535 l_inst_count number;
5536 l_insttorrw_num binary_integer;
5537 l_ok boolean := false;
5538 l_rows_found boolean := false;
5539 l_ass_rec per_all_assignments_f%rowtype;
5540 l_outputs ff_exec.outputs_t;
5541 l_include_flag varchar2(80);
5542 l_crit_passed boolean;
5543 l_score_tab scoreTab;
5544 --
5545 begin
5546 --
5547 hr_utility.set_location('Entering: '||l_proc, 10);
5548 --
5549 -- Getting eligibility profile compensation level by eligibility profile
5550 --
5551 ben_elp_cache.elpean_getcacdets
5552 (p_effective_date => p_effective_date
5553 ,p_business_group_id => p_business_group_id
5554 ,p_eligy_prfl_id => p_eligy_prfl_id
5555 ,p_inst_set => l_inst_dets
5556 ,p_inst_count => l_inst_count);
5557 --
5558 if l_inst_count > 0 then
5559 --
5560 ben_person_object.get_object(p_person_id => p_person_id,
5561 p_rec => l_ass_rec);
5562 --
5563 for l_count in l_inst_dets.first .. l_inst_dets.last loop
5564 --
5565 -- Error if someone hasn't built the formula as this will
5566 -- cause an error. In this case kill the run.
5567 --
5568 if l_inst_dets(l_count).formula_id is null then
5569 --
5570 fnd_message.set_name('BEN','BEN_92460_ASS_SET_FORMULA');
5571 fnd_message.set_token('PROC',l_proc);
5572 fnd_message.set_token('ELIGY_PRFL_ID',to_char(p_eligy_prfl_id));
5573 fnd_message.raise_error;
5574 --
5575 end if;
5576 --
5577 l_outputs := benutils.formula
5578 (p_formula_id => l_inst_dets(l_count).formula_id,
5579 p_assignment_id => l_ass_rec.assignment_id,
5580 p_effective_date => p_effective_date,
5581 p_param1 => 'BEN_IV_RT_STRT_DT',
5582 p_param1_value => fnd_date.date_to_canonical(ben_manage_life_events.g_fonm_rt_strt_dt),
5583 p_param2 => 'BEN_IV_CVG_STRT_DT',
5584 p_param2_value => fnd_date.date_to_canonical(l_fonm_cvg_strt_dt)
5585 );
5586 --
5587 begin
5588 --
5589 if l_outputs(l_outputs.first).name = 'INCLUDE_FLAG' then
5590 --
5591 l_include_flag := l_outputs(l_outputs.first).value;
5592 --
5593 else
5594 --
5595 -- Account for cases where formula returns an unknown
5596 -- variable name
5597 --
5598 fnd_message.set_name('BEN','BEN_92310_FORMULA_RET_PARAM_');
5599 fnd_message.set_token('PROC',l_proc);
5600 fnd_message.set_token('FORMULA',l_inst_dets(l_count).formula_id);
5601 fnd_message.set_token('PARAMETER',l_outputs(l_outputs.first).name);
5602 fnd_message.raise_error;
5603 --
5604 end if;
5605 --
5606 -- Code for type casting errors from formula return variables
5607 --
5608 exception
5609 --
5610 when others then
5611 --
5612 fnd_message.set_name('BEN','BEN_92311_FORMULA_VAL_PARAM');
5613 fnd_message.set_token('PROC',l_proc);
5614 fnd_message.set_token('FORMULA',l_inst_dets(l_count).formula_id);
5615 fnd_message.set_token('PARAMETER',l_outputs(l_outputs.first).name);
5616 fnd_message.raise_error;
5617 --
5618 end;
5619 --
5620 hr_utility.set_location('Include Flag '||l_include_flag,10);
5621 --
5622 l_ok := nvl((l_include_flag = 'Y'),FALSE);
5623 --if l_ok is null then
5624 -- l_ok:=false;
5625 --end if;
5626 --
5627 if l_ok and l_inst_dets(l_count).excld_flag = 'N' then
5628 --
5629 if p_score_compute_mode then
5630 if l_crit_passed is null then
5631 l_crit_passed := true;
5632 end if;
5633 write(l_score_tab,
5634 l_inst_dets(l_count).eligy_prfl_id,
5635 l_inst_dets(l_count).short_code,
5636 l_inst_dets(l_count).pk_id,
5637 nvl(l_inst_dets(l_count).criteria_score,
5638 l_inst_dets(l_count).criteria_weight));
5639 else
5640 exit;
5641 end if;
5642 --
5643 elsif l_ok and l_inst_dets(l_count).excld_flag = 'Y' then
5644 --
5645 l_rows_found := true;
5646 l_ok := false;
5647 exit;
5648 --
5649 elsif (not l_ok) and l_inst_dets(l_count).excld_flag = 'Y' then
5650 --
5651 l_rows_found := true;
5652 l_ok := true;
5653 if p_score_compute_mode then
5654 write(l_score_tab,
5655 l_inst_dets(l_count).eligy_prfl_id,
5656 l_inst_dets(l_count).short_code,
5657 l_inst_dets(l_count).pk_id,
5658 nvl(l_inst_dets(l_count).criteria_score,
5659 l_inst_dets(l_count).criteria_weight));
5660 end if;
5661 -- exit;
5662 --
5663 elsif l_inst_dets(l_count).excld_flag = 'N' then
5664 --
5665 l_rows_found := true;
5666 --
5667 end if;
5668 --
5669 end loop;
5670 --
5671 end if;
5672 --
5673 if l_crit_passed is null
5674 then
5675 if l_rows_found and
5676 not l_ok then
5677 --
5678 g_inelg_rsn_cd := 'ASS';
5679 fnd_message.set_name('BEN','BEN_92459_ASS_SET_PRFL_FAIL');
5680 hr_utility.set_location('Criteria Failed: '||l_proc,20);
5681 raise g_criteria_failed;
5682 --
5683 end if;
5684 end if;
5685 --
5686 if p_score_compute_mode
5687 then
5688 hr_utility.set_location('count '||l_score_tab.count,20);
5689 write(p_profile_score_tab,l_score_tab);
5690 end if;
5691 hr_utility.set_location('Leaving :'||l_proc,20);
5692 --
5693 end check_asnt_set;
5694 ------------------------------------------------------------------------
5695 -- ---------------------------------------------------------------
5696 -- This procedure det elig based on persons benefit balance.
5697 -- ---------------------------------------------------------------
5698 procedure check_person_balance(p_eligy_prfl_id in number,
5699 p_person_id in number,
5700 p_business_group_id in number,
5701 p_effective_date in date,
5702 p_per_comp_val in number,
5703 p_eval_typ in varchar2,
5704 p_comp_obj_mode in boolean,
5705 p_lf_evt_ocrd_dt in date,
5706 p_score_compute_mode in boolean default false,
5707 p_profile_score_tab in out nocopy scoreTab,
5708 p_per_in_ler_id in number default null,
5709 p_pl_id in number default null,
5710 p_pgm_id in number default null,
5711 p_oipl_id in number default null,
5712 p_plip_id in number default null,
5713 p_opt_id in number default null) is
5714 --
5715 l_proc varchar2(100):=g_package||'check_person_balance';
5716 l_inst_dets ben_elp_cache.g_cache_elpecl_instor;
5717 l_inst_count number;
5718 l_insttorrw_num binary_integer;
5719 l_ok boolean := false;
5720 l_rows_found boolean := false;
5721 l_per_comp_val number := p_per_comp_val;
5722 l_crit_passed boolean;
5723 l_score_tab scoreTab;
5724 --
5725 begin
5726 --
5727 hr_utility.set_location('Entering: '||l_proc, 10);
5728 --
5729 -- Getting eligibility profile compensation level by eligibility profile
5730 --
5731 ben_elp_cache.elpecl_getcacdets
5732 (p_effective_date => nvl(l_fonm_cvg_strt_dt,p_effective_date)
5733 ,p_business_group_id => p_business_group_id
5734 ,p_comp_src_cd => 'BALTYP'
5735 ,p_eligy_prfl_id => p_eligy_prfl_id
5736 ,p_inst_set => l_inst_dets
5737 ,p_inst_count => l_inst_count);
5738 --
5739 if l_inst_count > 0 then
5740 --
5741 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
5742 --
5743 --if p_per_comp_val is null then
5744 --
5745 --fnd_message.set_name('BEN','BEN_91767_DERIVABLE_NO_EXIST');
5746 --raise ben_manage_life_events.g_record_error;
5747 --
5748 --end if;
5749 --
5750 if not p_comp_obj_mode or
5751 p_eval_typ <> 'E' then
5752 --
5753 ben_derive_factors.determine_compensation
5754 (p_person_id => p_person_id
5755 ,p_comp_lvl_fctr_id => l_inst_dets(l_insttorrw_num).comp_lvl_fctr_id
5756 ,p_pgm_id => p_pgm_id
5757 ,p_pl_id => p_pl_id
5758 ,p_oipl_id => p_oipl_id
5759 ,p_per_in_ler_id => p_per_in_ler_id
5760 ,p_perform_rounding_flg => true
5761 ,p_effective_date => p_effective_date
5762 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
5763 ,p_business_group_id => p_business_group_id
5764 ,p_value => l_per_comp_val
5765 ,p_fonm_cvg_strt_dt => l_fonm_cvg_strt_dt);
5766 --
5767 end if;
5768 l_ok := is_ok(l_per_comp_val
5769 ,l_inst_dets(l_insttorrw_num).mx_comp_val
5770 ,l_inst_dets(l_insttorrw_num).mn_comp_val
5771 ,l_inst_dets(l_insttorrw_num).no_mx_comp_flag
5772 ,l_inst_dets(l_insttorrw_num).no_mn_comp_flag
5773 );
5774 --
5775 if l_per_comp_val is null then
5776 --
5777 l_ok := false;
5778 --
5779 end if;
5780 --
5781 if l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
5782 --
5783 if p_score_compute_mode then
5784 if l_crit_passed is null then
5785 l_crit_passed := true;
5786 end if;
5787 write(l_score_tab,
5788 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
5789 l_inst_dets(l_insttorrw_num).short_code,
5790 l_inst_dets(l_insttorrw_num).pk_id,
5791 ( l_per_comp_val * nvl(l_inst_dets(l_insttorrw_num).criteria_weight, 0) ) +
5792 nvl(l_inst_dets(l_insttorrw_num).criteria_score, 0) /* Bug 4429071 */
5793 );
5794 else
5795 exit;
5796 end if;
5797 --
5798 elsif l_ok and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
5799 --
5800 l_rows_found := true;
5801 l_ok := false;
5802 exit;
5803 --
5804 elsif (not l_ok) and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
5805 --
5806 l_rows_found := true;
5807 l_ok := true;
5808 if p_score_compute_mode then
5809 write(l_score_tab,
5810 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
5811 l_inst_dets(l_insttorrw_num).short_code,
5812 l_inst_dets(l_insttorrw_num).pk_id,
5813 ( l_per_comp_val * nvl(l_inst_dets(l_insttorrw_num).criteria_weight, 0) ) +
5814 nvl(l_inst_dets(l_insttorrw_num).criteria_score, 0) /* Bug 4429071 */
5815 );
5816 end if;
5817 -- exit;
5818 --
5819 elsif l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
5820 --
5821 l_rows_found := true;
5822 --
5823 end if;
5824 --
5825 end loop;
5826 --
5827 end if;
5828 --
5829 if l_crit_passed is null
5830 then
5831 if l_rows_found and
5832 not l_ok then
5833 --
5834 g_inelg_rsn_cd := 'CMP';
5835 fnd_message.set_name('BEN','BEN_91672_COMP_LVL_PRFL_FAIL');
5836 hr_utility.set_location('Criteria Failed: '||l_proc,20);
5837 raise g_criteria_failed;
5838 --
5839 end if;
5840 end if;
5841 --
5842 if p_score_compute_mode
5843 then
5844 hr_utility.set_location('count '||l_score_tab.count,20);
5845 write(p_profile_score_tab,l_score_tab);
5846 end if;
5847 hr_utility.set_location('Leaving :'||l_proc,20);
5848 --
5849 end check_person_balance;
5850 --------------------------------------------------------------------
5851 --
5852 -- --------------------------------------------------------------------------
5853 -- This procedure det elig based on no other coverage participation.
5854 -- --------------------------------------------------------------------------
5855 --
5856 procedure check_elig_no_othr_cvg_prte(p_eligy_prfl_id in number,
5857 p_person_id in number,
5858 p_business_group_id in number,
5859 p_effective_date in date) is
5860 --
5861 l_proc varchar2(100):=g_package||'check_elig_no_othr_cvg_prte';
5862 l_inst_dets ben_elp_cache.g_cache_elpeno_instor;
5863 l_inst_count number;
5864 l_insttorrw_num binary_integer;
5865 l_ok boolean := false;
5866 l_rows_found boolean := false;
5867 l_rec per_all_people_f%rowtype;
5868 --
5869 begin
5870 --
5871 hr_utility.set_location('Entering: '||l_proc, 10);
5872 --
5873 -- Getting eligibility profile compensation level by eligibility profile
5874 --
5875 ben_elp_cache.elpeno_getcacdets
5876 (p_effective_date => p_effective_date,
5877 p_business_group_id => p_business_group_id,
5878 p_eligy_prfl_id => p_eligy_prfl_id,
5879 p_inst_set => l_inst_dets,
5880 p_inst_count => l_inst_count);
5881 --
5882 if l_inst_count > 0 then
5883 --
5884 -- Operation
5885 -- =========
5886 -- 1) Grab all profiles for this eligibility profile id
5887 -- 2) Check that the flag corresponds to the person record. If not error.
5888 --
5889 ben_person_object.get_object(p_person_id => p_person_id,
5890 p_rec => l_rec);
5891 --
5892 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
5893 --
5894 l_rows_found := true;
5895 l_ok := nvl((nvl(l_rec.coord_ben_no_cvg_flag,'N') =
5896 l_inst_dets(l_insttorrw_num).coord_ben_no_cvg_flag),FALSE);
5897 --if l_ok is null then
5898 -- l_ok:=false;
5899 --end if;
5900 --
5901 --
5902 end loop;
5903 --
5904 end if;
5905 --
5906 if l_rows_found and
5907 not l_ok then
5908 --
5909 g_inelg_rsn_cd := 'ENO';
5910 fnd_message.set_name('BEN','BEN_92227_ENO_ELIG_PRFL_FAIL');
5911 hr_utility.set_location('Criteria Failed: '||l_proc,20);
5912 raise g_criteria_failed;
5913 --
5914 end if;
5915 --
5916 hr_utility.set_location('Leaving :'||l_proc,20);
5917 --
5918 end check_elig_no_othr_cvg_prte;
5919 --
5920 -- --------------------------------------------------------------------------
5921 -- This procedure det elig based on leaving reason participation.
5922 -- --------------------------------------------------------------------------
5923 --
5924 procedure check_elig_lvg_rsn_prte(p_eligy_prfl_id in number,
5925 p_person_id in number,
5926 p_business_group_id in number,
5927 p_score_compute_mode in boolean default false,
5928 p_profile_score_tab in out nocopy scoreTab,
5929 p_leaving_reason in varchar2 default null,
5930 p_effective_date in date) is
5931 --
5932 l_proc varchar2(100):=g_package||'check_elig_lvg_rsn_prte';
5933 l_inst_dets ben_elp_cache.g_cache_elpelv_instor;
5934 l_inst_count number;
5935 l_insttorrw_num binary_integer;
5936 l_ok boolean := false;
5937 l_rows_found boolean := false;
5938 l_rec per_periods_of_service%rowtype;
5939 --
5940 l_crit_passed boolean;
5941 l_score_tab scoreTab;
5942 begin
5943 --
5944 hr_utility.set_location('Entering: '||l_proc, 10);
5945 --
5946 -- Getting eligibility profile compensation level by eligibility profile
5947 --
5948 ben_elp_cache.elpelv_getcacdets
5949 (p_effective_date => p_effective_date,
5950 p_business_group_id => p_business_group_id,
5951 p_eligy_prfl_id => p_eligy_prfl_id,
5952 p_inst_set => l_inst_dets,
5953 p_inst_count => l_inst_count);
5954 --
5955 if l_inst_count > 0 then
5956 --
5957 -- Operation
5958 -- =========
5959 -- 1) Grab all profiles for this eligibility profile id
5960 -- 2) If the leaving reason code is excluded then person is not eligible
5961 -- 3) If the leaving reason code is not excluded then person is eligible.
5962 --
5963 if p_leaving_reason is null then
5964 ben_person_object.get_object(p_person_id => p_person_id,
5965 p_rec => l_rec);
5966 else
5967 l_rec.leaving_reason := p_leaving_reason;
5968 end if;
5969 --
5970 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
5971 --
5972 l_rows_found := true;
5973 l_ok := nvl((nvl(l_rec.leaving_reason,'-1') =
5974 l_inst_dets(l_insttorrw_num).lvg_rsn_cd),FALSE);
5975 --if l_ok is null then
5976 -- l_ok:=false;
5977 --end if;
5978 --
5979 if l_ok = true then
5980 if l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
5981 --
5982 l_ok := false;
5983 exit ;
5984 --
5985 else
5986 --
5987 if p_score_compute_mode then
5988 if l_crit_passed is null then
5989 l_crit_passed := true;
5990 end if;
5991 write(l_score_tab,
5992 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
5993 l_inst_dets(l_insttorrw_num).short_code,
5994 l_inst_dets(l_insttorrw_num).pk_id,
5995 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
5996 l_inst_dets(l_insttorrw_num).criteria_weight));
5997 else
5998 exit;
5999 end if;
6000 --
6001 end if;
6002 elsif l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
6003 --
6004 l_ok := true;
6005 if p_score_compute_mode then
6006 write(l_score_tab,
6007 l_inst_dets(l_insttorrw_num).eligy_prfl_id,
6008 l_inst_dets(l_insttorrw_num).short_code,
6009 l_inst_dets(l_insttorrw_num).pk_id,
6010 nvl(l_inst_dets(l_insttorrw_num).criteria_score,
6011 l_inst_dets(l_insttorrw_num).criteria_weight));
6012 end if;
6013 -- exit;
6014 --
6015 end if;
6016 --
6017 end loop;
6018 --
6019 end if;
6020 --
6021 if l_crit_passed is null
6022 then
6023 if l_rows_found and
6024 not l_ok then
6025 --
6026 g_inelg_rsn_cd := 'ELV';
6027 fnd_message.set_name('BEN','BEN_92228_ELV_ELIG_PRFL_FAIL');
6028 hr_utility.set_location('Criteria Failed: '||l_proc,20);
6029 raise g_criteria_failed;
6030 --
6031 end if;
6032 end if;
6033 --
6034 if p_score_compute_mode
6035 then
6036 hr_utility.set_location('count '||l_score_tab.count,20);
6037 write(p_profile_score_tab,l_score_tab);
6038 end if;
6039 hr_utility.set_location('Leaving :'||l_proc,20);
6040 --
6041 end check_elig_lvg_rsn_prte;
6042 --
6043 -- --------------------------------------------------------------------------
6044 -- This procedure det elig based on opting medicare participation.
6045 -- --------------------------------------------------------------------------
6046 --
6047 procedure check_elig_optd_mdcr_prte(p_eligy_prfl_id in number,
6048 p_person_id in number,
6049 p_business_group_id in number,
6050 p_effective_date in date) is
6051 --
6052 l_proc varchar2(100):=g_package||'check_elig_optd_mdcr_prte';
6053 l_inst_dets ben_elp_cache.g_cache_elpeom_instor;
6054 l_inst_count number;
6055 l_insttorrw_num binary_integer;
6056 l_ok boolean := false;
6057 l_rows_found boolean := false;
6058 l_rec per_all_people_f%rowtype;
6059 --
6060 begin
6061 --
6062 hr_utility.set_location('Entering: '||l_proc, 10);
6063 --
6064 -- Getting eligibility profile compensation level by eligibility profile
6065 --
6066 ben_elp_cache.elpeom_getcacdets
6067 (p_effective_date => p_effective_date,
6068 p_business_group_id => p_business_group_id,
6069 p_eligy_prfl_id => p_eligy_prfl_id,
6070 p_inst_set => l_inst_dets,
6071 p_inst_count => l_inst_count);
6072 --
6073 if l_inst_count > 0 then
6074 --
6075 -- Operation
6076 -- =========
6077 -- 1) Grab all profiles for this eligibility profile id
6078 -- 2) If the leaving reason code is excluded then person is not eligible
6079 -- 3) If the leaving reason code is not excluded then person is eligible.
6080 --
6081 ben_person_object.get_object(p_person_id => p_person_id,
6082 p_rec => l_rec);
6083 --
6084 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
6085 --
6086 l_rows_found := true;
6087 l_ok := nvl((nvl(l_rec.per_information10,'N') =
6088 l_inst_dets(l_insttorrw_num).optd_mdcr_flag),FALSE);
6089 --if l_ok is null then
6090 -- l_ok:=false;
6091 --end if;
6092 --
6093 -- There is only one row so there is no need to do further checking.
6094 --
6095 end loop;
6096 --
6097 end if;
6098 --
6099 if l_rows_found and
6100 not l_ok then
6101 --
6102 g_inelg_rsn_cd := 'EOM';
6103 fnd_message.set_name('BEN','BEN_92229_EOM_ELIG_PRFL_FAIL');
6104 hr_utility.set_location('Criteria Failed: '||l_proc,20);
6105 raise g_criteria_failed;
6106 --
6107 end if;
6108 --
6109 hr_utility.set_location('Leaving :'||l_proc,20);
6110 --
6111 end check_elig_optd_mdcr_prte;
6112 --
6113 -- --------------------------------------------------------------------------
6114 -- This procedure det elig based on enrolled in another plan.
6115 -- --------------------------------------------------------------------------
6116 --
6117 procedure check_elig_enrld_anthr_pl(p_eligy_prfl_id in number,
6118 p_business_group_id in number,
6119 p_pl_id in number,
6120 p_person_id in number,
6121 p_effective_date in date,
6122 p_lf_evt_ocrd_dt in date) is
6123 --
6124 l_proc varchar2(100):=g_package||'check_elig_enrld_anthr_pl';
6125 l_inst_dets ben_elp_cache.g_cache_elpeep_instor;
6126 l_inst_count number;
6127 l_insttorrw_num binary_integer;
6128 l_ok boolean := false;
6129 l_rows_found boolean := false;
6130 l_found_plan boolean := false;
6131 l_date_to_use date;
6132 l_dummy varchar2(1);
6133 --
6134 begin
6135 --
6136 hr_utility.set_location('Entering: '||l_proc, 10);
6137 --
6138 -- Getting eligibility profile enrld in another plan by eligibility profile
6139 --
6140 ben_elp_cache.elpeep_getcacdets
6141 (p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date),
6142 p_business_group_id => p_business_group_id,
6143 p_eligy_prfl_id => p_eligy_prfl_id,
6144 p_inst_set => l_inst_dets,
6145 p_inst_count => l_inst_count);
6146 --
6147 if l_inst_count > 0 then
6148 --
6149 -- Operation
6150 -- =========
6151 -- 1) Grab all profiles for this eligibility profile id
6152 -- 2) If the plan id is the same then check if the person was covered
6153 -- the day before the life event.
6154 --
6155 <<prfl>>
6156 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
6157 --
6158 l_rows_found := true;
6159 --
6160 <<rslt>>
6161 for l_count in nvl(ben_manage_life_events.g_cache_person_prtn.first,0)..
6162 nvl(ben_manage_life_events.g_cache_person_prtn.last,-1) loop
6163 if ben_manage_life_events.g_cache_person_prtn(l_count).pl_id =
6164 l_inst_dets(l_insttorrw_num).pl_id then
6165 --
6166 -- Apply the date logic to the life event occurred date.
6167 --
6168 ben_determine_date.main
6169 (p_date_cd => l_inst_dets(l_insttorrw_num).enrl_det_dt_cd,
6170 p_effective_date => p_effective_date,
6171 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
6172 p_fonm_cvg_strt_dt => ben_manage_life_events.g_fonm_cvg_strt_dt,
6173 p_fonm_rt_strt_dt => ben_manage_life_events.g_fonm_rt_strt_dt,
6174 p_returned_date => l_date_to_use);
6175 --
6176 if (l_date_to_use
6177 between ben_manage_life_events.
6178 g_cache_person_prtn(l_count).enrt_cvg_strt_dt
6179 and ben_manage_life_events.
6180 g_cache_person_prtn(l_count).enrt_cvg_thru_dt) then
6181 l_found_plan := true;
6182 --
6183 if l_inst_dets(l_insttorrw_num).excld_flag = 'N'then
6184 --
6185 l_ok := true;
6186 exit prfl;
6187 --
6188 end if;
6189 --
6190 if l_inst_dets(l_insttorrw_num).excld_flag = 'Y'then
6191 --
6192 l_ok := false;
6193 exit prfl;
6194 --
6195 end if;
6196 --
6197 end if;
6198 --
6199 end if;
6200 end loop rslt;
6201 --
6202 -- If person is not enrolled in plan and exclude flag = 'Y',
6203 -- person is eligible.
6204 --
6205 if (l_found_plan = false
6206 and l_inst_dets(l_insttorrw_num).excld_flag = 'Y') then
6207 l_ok := true;
6208 exit;
6209 end if;
6210 --
6211 end loop prfl;
6212 --
6213 end if;
6214 --
6215 if l_rows_found and
6216 not l_ok then
6217 --
6218 g_inelg_rsn_cd := 'EEP';
6219 fnd_message.set_name('BEN','BEN_92230_EEP_ELIG_PRFL_FAIL');
6220 hr_utility.set_location('Criteria Failed: '||l_proc,20);
6221 raise g_criteria_failed;
6222 --
6223 end if;
6224 --
6225 hr_utility.set_location('Leaving :'||l_proc,20);
6226 --
6227 end check_elig_enrld_anthr_pl;
6228 --
6229 -- --------------------------------------------------------------------------
6230 -- This procedure det elig based on enrolled in another option in plan.
6231 -- --------------------------------------------------------------------------
6232 --
6233 procedure check_elig_enrld_anthr_oipl(p_eligy_prfl_id in number,
6234 p_business_group_id in number,
6235 p_oipl_id in number,
6236 p_person_id in number,
6237 p_effective_date in date,
6238 p_lf_evt_ocrd_dt in date) is
6239 --
6240 l_proc varchar2(100):=g_package||'check_elig_enrld_anthr_oipl';
6241 l_inst_dets ben_elp_cache.g_cache_elpeei_instor;
6242 l_inst_count number;
6243 l_insttorrw_num binary_integer;
6244 l_ok boolean := false;
6245 l_rows_found boolean := false;
6246 l_found_oipl boolean := false;
6247 l_date_to_use date;
6248 l_dummy varchar2(1);
6249 --
6250 cursor c1(p_date_to_use DATE) is
6251 select null
6252 from ben_prtt_enrt_rslt_f pen
6253 where pen.business_group_id = p_business_group_id
6254 and pen.oipl_id = p_oipl_id
6255 and pen.person_id = p_person_id
6256 and p_date_to_use
6257 between pen.enrt_cvg_strt_dt
6258 and pen.enrt_cvg_thru_dt
6259 and pen.enrt_cvg_thru_dt <= pen.effective_end_date
6260 and pen.prtt_enrt_rslt_stat_cd is null;
6261 --
6262 begin
6263 --
6264 hr_utility.set_location('Entering: '||l_proc, 10);
6265 --
6266 -- Getting eligibility profile compensation level by eligibility profile
6267 --
6268 ben_elp_cache.elpeei_getcacdets
6269 (p_effective_date => nvl(l_fonm_cvg_strt_dt,nvl(p_lf_evt_ocrd_dt,p_effective_date)),
6270 p_business_group_id => p_business_group_id,
6271 p_eligy_prfl_id => p_eligy_prfl_id,
6272 p_inst_set => l_inst_dets,
6273 p_inst_count => l_inst_count);
6274 --
6275 if l_inst_count > 0 then
6276 --
6277 -- Operation
6278 -- =========
6279 -- 1) Grab all profiles for this eligibility profile id
6280 -- 2) If the plan id is the same then check if the person was covered
6281 -- the day before the life event.
6282 --
6283 <<prfl>>
6284 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
6285 --
6286 l_rows_found := true;
6287 --
6288 <<rslt>>
6289 for l_count in nvl(ben_manage_life_events.g_cache_person_prtn.first,0)..
6290 nvl(ben_manage_life_events.g_cache_person_prtn.last,-1) loop
6291 if ben_manage_life_events.
6292 g_cache_person_prtn(l_count).oipl_id =
6293 l_inst_dets(l_insttorrw_num).oipl_id then
6294 --
6295 -- Apply the date logic to the life event occurred date.
6296 --
6297 ben_determine_date.main
6298 (p_date_cd => l_inst_dets(l_insttorrw_num).enrl_det_dt_cd,
6299 p_effective_date => p_effective_date,
6300 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
6301 p_fonm_cvg_strt_dt => ben_manage_life_events.g_fonm_cvg_strt_dt,
6302 p_fonm_rt_strt_dt => ben_manage_life_events.g_fonm_rt_strt_dt,
6303 p_returned_date => l_date_to_use);
6304 --
6305 if (l_date_to_use
6306 between ben_manage_life_events.
6307 g_cache_person_prtn(l_count).enrt_cvg_strt_dt
6308 and ben_manage_life_events.
6309 g_cache_person_prtn(l_count).enrt_cvg_thru_dt) then
6310 --
6311 l_found_oipl := true;
6312 --
6313 if l_inst_dets(l_insttorrw_num).excld_flag = 'N'then
6314 --
6315 l_ok := true;
6316 exit prfl;
6317 --
6318 end if;
6319 --
6320 if l_inst_dets(l_insttorrw_num).excld_flag = 'Y'then
6321 --
6322 l_ok := false;
6323 exit prfl;
6324 --
6325 end if;
6326 --
6327 end if;
6328 --
6329 end if;
6330 --
6331 end loop rslt;
6332 --
6333 if (l_found_oipl = false
6334 and l_inst_dets(l_insttorrw_num).excld_flag = 'Y') then
6335 --
6336 l_ok := true;
6337 exit;
6338 --
6339 end if;
6340 --
6341 end loop prfl;
6342 --
6343 end if;
6344 --
6345 if l_rows_found and
6346 not l_ok then
6347 --
6348 g_inelg_rsn_cd := 'EEI';
6349 fnd_message.set_name('BEN','BEN_92231_EEI_ELIG_PRFL_FAIL');
6350 hr_utility.set_location('Criteria Failed: '||l_proc,20);
6351 raise g_criteria_failed;
6352 --
6353 end if;
6354 --
6355 hr_utility.set_location('Leaving :'||l_proc,20);
6356 --
6357 end check_elig_enrld_anthr_oipl;
6358 --
6359 -- --------------------------------------------------------------------------
6360 -- This procedure det elig based on enrolled in another program.
6361 -- --------------------------------------------------------------------------
6362 --
6363 procedure check_elig_enrld_anthr_pgm
6364 (p_eligy_prfl_id in number
6365 ,p_business_group_id in number
6366 ,p_pgm_id in number
6367 ,p_person_id in number
6368 ,p_effective_date in date
6369 ,p_lf_evt_ocrd_dt in date
6370 )
6371 is
6372 --
6373 l_proc varchar2(100):=g_package||'check_elig_enrld_anthr_pgm';
6374 l_inst_dets ben_elp_cache.g_cache_elpeeg_instor;
6375 l_inst_count number;
6376 l_insttorrw_num binary_integer;
6377 l_ok boolean := false;
6378 l_rows_found boolean := false;
6379 l_found_pgm boolean := false;
6380 l_date_to_use date;
6381 l_dummy varchar2(1);
6382 --
6383 begin
6384 --
6385 hr_utility.set_location('Entering: '||l_proc, 10);
6386 hr_utility.set_location('prfl_id: '||p_eligy_prfl_id, 10);
6387 --
6388 -- Getting eligibility profile compensation level by eligibility profile
6389 --
6390 ben_elp_cache.elpeeg_getcacdets
6391 (p_effective_date => nvl(l_fonm_cvg_strt_dt,nvl(p_lf_evt_ocrd_dt,p_effective_date)),
6392 p_business_group_id => p_business_group_id,
6393 p_eligy_prfl_id => p_eligy_prfl_id,
6394 p_inst_set => l_inst_dets,
6395 p_inst_count => l_inst_count);
6396 --
6397 if l_inst_count > 0 then
6398 --
6399 -- Operation
6400 -- =========
6401 -- 1) Grab all profiles for this eligibility profile id
6402 -- 2) If the plan id is the same then check if the person was covered
6403 -- the day before the life event.
6404 --
6405 <<prfl>>
6406 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
6407 --
6408 l_rows_found := true;
6409 --
6410 <<rslt>>
6411 for l_count in nvl(ben_manage_life_events.g_cache_person_prtn.first,0)..
6412 nvl(ben_manage_life_events.g_cache_person_prtn.last,-1) loop
6413 if ben_manage_life_events.g_cache_person_prtn(l_count).pgm_id =
6414 l_inst_dets(l_insttorrw_num).pgm_id then
6415 l_found_pgm := true;
6416 --
6417 -- Apply the date logic to the life event occurred date.
6418 --
6419 ben_determine_date.main
6420 (p_date_cd => l_inst_dets(l_insttorrw_num).enrl_det_dt_cd,
6421 p_effective_date => p_effective_date,
6422 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
6423 p_fonm_cvg_strt_dt => ben_manage_life_events.g_fonm_cvg_strt_dt,
6424 p_fonm_rt_strt_dt => ben_manage_life_events.g_fonm_rt_strt_dt,
6425 p_returned_date => l_date_to_use);
6426 --
6427 if (l_date_to_use
6428 between ben_manage_life_events.
6429 g_cache_person_prtn(l_count).enrt_cvg_strt_dt
6430 and ben_manage_life_events.
6431 g_cache_person_prtn(l_count).enrt_cvg_thru_dt) then
6432 --
6433 if l_inst_dets(l_insttorrw_num).excld_flag = 'N'then
6434 --
6435 l_ok := true;
6436 exit prfl;
6437 --
6438 end if;
6439 --
6440 if l_inst_dets(l_insttorrw_num).excld_flag = 'Y'then
6441 --
6442 l_ok := false;
6443 exit prfl;
6444 --
6445 end if;
6446 --
6447 end if;
6448 --
6449 end if;
6450 --
6451 end loop rslt;
6452 --
6453 -- If person is not enrolled in the program and exclude flag = "Y"
6454 -- person is eligible.
6455 --
6456 if (l_found_pgm = false
6457 and l_inst_dets(l_insttorrw_num).excld_flag = 'Y') then
6458 --
6459 l_ok := true;
6460 exit;
6461 --
6462 end if;
6463
6464 --
6465 end loop prfl;
6466 --
6467 end if;
6468 --
6469 if l_rows_found and
6470 not l_ok then
6471 --
6472 g_inelg_rsn_cd := 'EEG';
6473 fnd_message.set_name('BEN','BEN_92232_EEG_ELIG_PRFL_FAIL');
6474 hr_utility.set_location('Criteria Failed: '||l_proc,20);
6475 raise g_criteria_failed;
6476 --
6477 end if;
6478 --
6479 hr_utility.set_location('Leaving :'||l_proc,20);
6480 --
6481 end check_elig_enrld_anthr_pgm;
6482 --
6483 -- --------------------------------------------------------------------------
6484 -- This procedure det elig based on dependent covered by another plan.
6485 -- --------------------------------------------------------------------------
6486 procedure check_elig_dpnt_cvrd_othr_pl(p_eligy_prfl_id in number,
6487 p_business_group_id in number,
6488 p_pl_id in number,
6489 p_person_id in number,
6490 p_effective_date in date,
6491 p_lf_evt_ocrd_dt in date) is
6492 --
6493 l_proc varchar2(100):=g_package||'check_elig_dpnt_cvrd_othr_pl';
6494 l_inst_dets ben_elp_cache.g_cache_elpedp_instor;
6495 l_inst_count number;
6496 l_insttorrw_num binary_integer;
6497 l_ok boolean := false;
6498 l_rows_found boolean := false;
6499 l_date_to_use date;
6500 l_dummy varchar2(1);
6501 --
6502 cursor c1(p_pl_id in number) is
6503 select null
6504 from ben_elig_cvrd_dpnt_f pdp,
6505 ben_prtt_enrt_rslt_f pen
6506 where pen.business_group_id = p_business_group_id
6507 and pen.pl_id = p_pl_id
6508 and pdp.dpnt_person_id = p_person_id
6509 and l_date_to_use
6510 between pen.enrt_cvg_strt_dt
6511 and pen.enrt_cvg_thru_dt
6512 and pen.enrt_cvg_thru_dt <= pen.effective_end_date
6513 and pdp.business_group_id = pen.business_group_id
6514 and pdp.prtt_enrt_rslt_id = pen.prtt_enrt_rslt_id
6515 --
6516 and pen.prtt_enrt_rslt_stat_cd is null
6517 and l_date_to_use
6518 between pdp.cvg_strt_dt
6519 and pdp.cvg_thru_dt
6520 and pdp.effective_end_date = hr_api.g_eot;
6521 --
6522 begin
6523 --
6524 hr_utility.set_location('Entering: '||l_proc, 10);
6525 --
6526 -- Getting eligibility profile compensation level by eligibility profile
6527 --
6528 ben_elp_cache.elpedp_getcacdets
6529 (p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date),
6530 p_business_group_id => p_business_group_id,
6531 p_eligy_prfl_id => p_eligy_prfl_id,
6532 p_inst_set => l_inst_dets,
6533 p_inst_count => l_inst_count);
6534 --
6535 if l_inst_count > 0 then
6536 --
6537 -- Operation
6538 -- =========
6539 -- 1) Grab all profiles for this eligibility profile id
6540 -- 2) If the plan id is the same then check if the person was covered
6541 -- the day before the life event.
6542 --
6543 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
6544 --
6545 l_rows_found := true;
6546 --
6547 --
6548 -- Apply the date logic to the life event occurred date.
6549 --
6550 ben_determine_date.main
6551 (p_date_cd => l_inst_dets(l_insttorrw_num).cvg_det_dt_cd,
6552 p_effective_date => p_effective_date,
6553 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
6554 p_fonm_cvg_strt_dt => ben_manage_life_events.g_fonm_cvg_strt_dt,
6555 p_fonm_rt_strt_dt => ben_manage_life_events.g_fonm_rt_strt_dt,
6556 p_returned_date => l_date_to_use);
6557 --
6558 open c1(l_inst_dets(l_insttorrw_num).pl_id);
6559 fetch c1 into l_dummy;
6560 --
6561 if c1%found then
6562 --
6563 close c1;
6564 --
6565 if l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
6566 l_ok := true;
6567 exit;
6568 end if;
6569 --
6570 if l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
6571 l_ok := false;
6572 exit;
6573 end if;
6574 --
6575 else
6576 --
6577 close c1;
6578 if l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
6579 l_ok := true;
6580 -- exit;
6581 end if;
6582 end if;
6583 --
6584 end loop;
6585 --
6586 end if;
6587 --
6588 if l_rows_found and
6589 not l_ok then
6590 --
6591 g_inelg_rsn_cd := 'EDP';
6592 fnd_message.set_name('BEN','BEN_92233_EDP_ELIG_PRFL_FAIL');
6593 hr_utility.set_location('Criteria Failed: '||l_proc,20);
6594 raise g_criteria_failed;
6595 --
6596 end if;
6597 --
6598 hr_utility.set_location('Leaving :'||l_proc,20);
6599 --
6600 end check_elig_dpnt_cvrd_othr_pl;
6601 --
6602 -- --------------------------------------------------------------------------
6603 -- This procedure det elig based on enrolled in another plan in program.
6604 -- --------------------------------------------------------------------------
6605 --
6606 procedure check_elig_enrld_anthr_plip(p_eligy_prfl_id in number,
6607 p_business_group_id in number,
6608 p_person_id in number,
6609 p_effective_date in date,
6610 p_lf_evt_ocrd_dt in date) is
6611 --
6612 l_proc varchar2(100):=g_package||'check_elig_enrld_anthr_plip';
6613 l_inst_dets ben_elp_cache.g_cache_elpeai_instor;
6614 l_inst_count number;
6615 l_insttorrw_num binary_integer;
6616 l_ok boolean := false;
6617 l_rows_found boolean := false;
6618 l_date_to_use date;
6619 l_dummy varchar2(1);
6620 --
6621 cursor c1(p_plip_id in number,p_date_to_use date) is
6622 select null
6623 from ben_prtt_enrt_rslt_f pen
6624 ,ben_plip_f cpp
6625 where pen.business_group_id = p_business_group_id
6626 and pen.pgm_id = cpp.pgm_id
6627 and pen.pl_id = cpp.pl_id
6628 and cpp.plip_id = p_plip_id
6629 and p_date_to_use
6630 between cpp.effective_start_date
6631 and cpp.effective_end_date
6632 and cpp.business_group_id = pen.business_group_id
6633 and pen.person_id = p_person_id
6634 and p_date_to_use
6635 between pen.enrt_cvg_strt_dt
6636 and pen.enrt_cvg_thru_dt
6637 and pen.enrt_cvg_thru_dt <= pen.effective_end_date
6638 and pen.prtt_enrt_rslt_stat_cd is null;
6639 --
6640 begin
6641 --
6642 hr_utility.set_location('Entering: '||l_proc, 10);
6643 --
6644 -- Getting eligibility profile compensation level by eligibility profile
6645 --
6646 ben_elp_cache.elpeai_getcacdets
6647 (p_effective_date => nvl(l_fonm_cvg_strt_dt,nvl(p_lf_evt_ocrd_dt,p_effective_date)),
6648 p_business_group_id => p_business_group_id,
6649 p_eligy_prfl_id => p_eligy_prfl_id,
6650 p_inst_set => l_inst_dets,
6651 p_inst_count => l_inst_count);
6652 --
6653 if l_inst_count > 0 then
6654 --
6655 -- Operation
6656 -- =========
6657 -- 1) Grab all profiles for this eligibility profile id
6658 -- 2) If the plan id is the same then check if the person was covered
6659 -- the day before the life event.
6660 --
6661 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
6662 --
6663 l_rows_found := true;
6664 --
6665 --
6666 -- Apply the date logic to the life event occurred date.
6667 --
6668 ben_determine_date.main
6669 (p_date_cd => l_inst_dets(l_insttorrw_num).enrl_det_dt_cd,
6670 p_effective_date => p_effective_date,
6671 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
6672 p_fonm_cvg_strt_dt => ben_manage_life_events.g_fonm_cvg_strt_dt,
6673 p_fonm_rt_strt_dt => ben_manage_life_events.g_fonm_rt_strt_dt,
6674 p_returned_date => l_date_to_use);
6675 --
6676 -- 4204020 l_date_to_use := nvl(l_fonm_cvg_strt_dt,l_date_to_use);
6677 --
6678 open c1(l_inst_dets(l_insttorrw_num).plip_id,l_date_to_use);
6679 fetch c1 into l_dummy;
6680 --
6681 if c1%found then
6682 --
6683 close c1;
6684 --
6685 if l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
6686 l_ok := true;
6687 exit;
6688 end if;
6689 --
6690 if l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
6691 l_ok := false;
6692 exit;
6693 end if;
6694 --
6695 else
6696 --
6697 close c1;
6698 if l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
6699 l_ok := true;
6700 -- exit;
6701 end if;
6702 end if;
6703 --
6704 end loop;
6705 --
6706 end if;
6707 --
6708 if l_rows_found and
6709 not l_ok then
6710 --
6711 g_inelg_rsn_cd := 'EAI';
6712 fnd_message.set_name('BEN','BEN_92420_EAI_ELIG_PRFL_FAIL');
6713 hr_utility.set_location('Criteria Failed: '||l_proc,20);
6714 raise g_criteria_failed;
6715 --
6716 end if;
6717 --
6718 hr_utility.set_location('Leaving :'||l_proc,20);
6719 --
6720 end check_elig_enrld_anthr_plip;
6721 --
6722 -- --------------------------------------------------------------------------
6723 -- This procedure det elig based on dependent coverd in another plan in program.
6724 -- --------------------------------------------------------------------------
6725 --
6726 procedure check_elig_dpnt_cvrd_othr_plip(p_eligy_prfl_id in number,
6727 p_business_group_id in number,
6728 p_person_id in number,
6729 p_effective_date in date,
6730 p_lf_evt_ocrd_dt in date) is
6731 --
6732 l_proc varchar2(100):=g_package||'check_elig_dpnt_cvrd_othr_plip';
6733 l_inst_dets ben_elp_cache.g_cache_elpedi_instor;
6734 l_inst_count number;
6735 l_insttorrw_num binary_integer;
6736 l_ok boolean := false;
6737 l_rows_found boolean := false;
6738 l_date_to_use date;
6739 l_dummy varchar2(1);
6740 --
6741 cursor c1(p_plip_id in number,p_date_to_use date ) is
6742 select null
6743 from ben_prtt_enrt_rslt_f pen
6744 ,ben_elig_cvrd_dpnt_f pdp
6745 ,ben_plip_f cpp
6746 where pen.prtt_enrt_rslt_id = pdp.prtt_enrt_rslt_id
6747 --and pen.prtt_enrt_rslt_stat_cd not in ('BCKDT', 'VOIDD')
6748 and pen.prtt_enrt_rslt_stat_cd is null
6749 and pdp.dpnt_person_id = p_person_id
6750 and pen.pgm_id = cpp.pgm_id
6751 and pen.pl_id = cpp.pl_id
6752 and cpp.plip_id = p_plip_id
6753 and p_date_to_use
6754 between cpp.effective_start_date
6755 and cpp.effective_end_date
6756 and cpp.business_group_id = pen.business_group_id
6757 and p_date_to_use
6758 between pen.enrt_cvg_strt_dt
6759 and pen.enrt_cvg_thru_dt
6760 and pen.business_group_id = p_business_group_id
6761 and pen.enrt_cvg_thru_dt <= pen.effective_end_date
6762 and pen.prtt_enrt_rslt_stat_cd is null
6763 and pdp.business_group_id = pen.business_group_id
6764 and p_date_to_use
6765 between pdp.cvg_strt_dt
6766 and pdp.cvg_thru_dt
6767 and pdp.effective_end_date = hr_api.g_eot;
6768 --
6769 begin
6770 --
6771 hr_utility.set_location('Entering: '||l_proc, 10);
6772 --
6773 -- Getting eligibility profile compensation level by eligibility profile
6774 --
6775 ben_elp_cache.elpedi_getcacdets
6776 (p_effective_date => nvl(l_fonm_cvg_strt_dt,nvl(p_lf_evt_ocrd_dt,p_effective_date)),
6777 p_business_group_id => p_business_group_id,
6778 p_eligy_prfl_id => p_eligy_prfl_id,
6779 p_inst_set => l_inst_dets,
6780 p_inst_count => l_inst_count);
6781 --
6782 if l_inst_count > 0 then
6783 --
6784 -- Operation
6785 -- =========
6786 -- 1) Grab all profiles for this eligibility profile id
6787 -- 2) If the plan id is the same then check if the person was covered
6788 -- the day before the life event.
6789 --
6790 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
6791 --
6792 l_rows_found := true;
6793 --
6794 --
6795 -- Apply the date logic to the life event occurred date.
6796 --
6797 ben_determine_date.main
6798 (p_date_cd => l_inst_dets(l_insttorrw_num).enrl_det_dt_cd,
6799 p_effective_date => p_effective_date,
6800 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
6801 p_fonm_cvg_strt_dt => ben_manage_life_events.g_fonm_cvg_strt_dt,
6802 p_fonm_rt_strt_dt => ben_manage_life_events.g_fonm_rt_strt_dt,
6803 p_returned_date => l_date_to_use);
6804 --
6805 -- 4204020 l_date_to_use := nvl(l_fonm_cvg_strt_dt,l_date_to_use);
6806 --
6807 open c1(l_inst_dets(l_insttorrw_num).plip_id,l_date_to_use );
6808 fetch c1 into l_dummy;
6809 --
6810 if c1%found then
6811 --
6812 close c1;
6813 --
6814 if l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
6815 l_ok := true;
6816 exit;
6817 end if;
6818 --
6819 if l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
6820 l_ok := false;
6821 exit;
6822 end if;
6823 --
6824 else
6825 --
6826 close c1;
6827 if l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
6828 l_ok := true;
6829 -- exit;
6830 end if;
6831 end if;
6832 --
6833 end loop;
6834 --
6835 end if;
6836 --
6837 if l_rows_found and
6838 not l_ok then
6839 --
6840 g_inelg_rsn_cd := 'EDI';
6841 fnd_message.set_name('BEN','BEN_92421_EDI_ELIG_PRFL_FAIL');
6842 hr_utility.set_location('Criteria Failed: '||l_proc,20);
6843 raise g_criteria_failed;
6844 --
6845 end if;
6846 --
6847 hr_utility.set_location('Leaving :'||l_proc,20);
6848 --
6849 end check_elig_dpnt_cvrd_othr_plip;
6850 --
6851 -- --------------------------------------------------------------------------
6852 -- This procedure det elig based enrollment in other plan type in program.
6853 -- --------------------------------------------------------------------------
6854 --
6855 procedure check_elig_enrld_anthr_ptip(p_eligy_prfl_id in number,
6856 p_business_group_id in number,
6857 p_effective_date in date,
6858 p_lf_evt_ocrd_dt in date) is
6859 --
6860 l_proc varchar2(100):=g_package||'check_elig_enrld_anthr_ptip';
6861 --
6862 l_inst_dets ben_elp_cache.g_cache_elpeet_instor;
6863 l_inst_count number;
6864 l_insttorrw_num binary_integer;
6865 l_ok boolean := false;
6866 l_rows_found boolean := false;
6867 l_found_ptip boolean := false;
6868 l_continue boolean := true;
6869 l_date_to_use date;
6870 l_dummy varchar2(1);
6871 l_pl_rec ben_comp_object.g_cache_pl_rec_table;
6872 --
6873 cursor c1(p_pl_id in number,p_date_to_use date ) is
6874 select null
6875 from ben_pl_f pln,
6876 ben_pl_regn_f prg,
6877 ben_regn_f reg
6878 where pln.pl_id = p_pl_id
6879 and pln.business_group_id = p_business_group_id
6880 and p_date_to_use
6881 between pln.effective_start_date
6882 and pln.effective_end_date
6883 and pln.pl_id = prg.pl_id
6884 and prg.business_group_id = pln.business_group_id
6885 and p_date_to_use
6886 between prg.effective_start_date
6887 and prg.effective_end_date
6888 and prg.regn_id = reg.regn_id
6889 and reg.business_group_id = prg.business_group_id
6890 and p_date_to_use
6891 between reg.effective_start_date
6892 and reg.effective_end_date
6893 and reg.sttry_citn_name = 'COBRA';
6894
6895 --
6896 begin
6897 --
6898 hr_utility.set_location('Entering: '||l_proc, 10);
6899 hr_utility.set_location('l_fonm_cvg_strt_dt: '||l_fonm_cvg_strt_dt, 10);
6900 --
6901 -- Getting eligibility profile compensation level by eligibility profile
6902 --
6903 ben_elp_cache.elpeet_getcacdets
6904 (p_effective_date => nvl(l_fonm_cvg_strt_dt,nvl(p_lf_evt_ocrd_dt,p_effective_date)),
6905 p_business_group_id => p_business_group_id,
6906 p_eligy_prfl_id => p_eligy_prfl_id,
6907 p_inst_set => l_inst_dets,
6908 p_inst_count => l_inst_count);
6909 --
6910 hr_utility.set_location('l_inst_count: '||l_inst_count, 10);
6911 if l_inst_count > 0 then
6912 --
6913 -- Operation
6914 -- =========
6915 -- 1) Grab all profiles for this eligibility profile id
6916 -- 2) Look only at profiles for this PTIP_ID
6917 -- 3) Set must be derived based on whether the plans are subject
6918 -- to COBRA or not.
6919 -- 4) If person eligible for any of the plans and exclude flag = 'Y'
6920 -- then no problem.
6921 -- 5) If person eligible for any of the plans and exclude flag = 'N'
6922 -- then fail criteria.
6923 --
6924 hr_utility.set_location('Getting profiles',10);
6925 <<prfl>>
6926 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
6927 --
6928 l_rows_found := true;
6929 --
6930 hr_utility.set_location('Getting results' || ben_manage_life_events.g_cache_person_prtn.last ,10);
6931
6932 <<rslt>>
6933 for l_count in nvl(ben_manage_life_events.g_cache_person_prtn.first,0)..
6934 nvl(ben_manage_life_events.g_cache_person_prtn.last,-1) loop
6935 if ben_manage_life_events.
6936 g_cache_person_prtn(l_count).ptip_id =
6937 l_inst_dets(l_insttorrw_num).ptip_id then
6938 --
6939 -- Apply the date logic to the life event occurred date.
6940 --
6941 ben_determine_date.main
6942 (p_date_cd => l_inst_dets(l_insttorrw_num).enrl_det_dt_cd,
6943 p_effective_date => p_effective_date,
6944 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
6945 p_fonm_cvg_strt_dt => ben_manage_life_events.g_fonm_cvg_strt_dt,
6946 p_fonm_rt_strt_dt => ben_manage_life_events.g_fonm_rt_strt_dt,
6947 p_returned_date => l_date_to_use);
6948 --
6949 hr_utility.set_location( 'l_date_to_use ' || l_date_to_use , 99 ) ;
6950
6951 -- 4204020 l_date_to_use := NVL(l_fonm_cvg_strt_dt,l_date_to_use);
6952 hr_utility.set_location( 'l_date_to_use ' || l_date_to_use , 99 ) ;
6953 --
6954 -- If only check plans that are subject to COBRA.
6955 --
6956 l_continue := true;
6957 --
6958 hr_utility.set_location('Getting cobra plans',10);
6959 --
6960 if l_inst_dets(l_insttorrw_num).only_pls_subj_cobra_flag = 'Y' then
6961 --
6962 open c1(ben_manage_life_events.g_cache_person_prtn(l_count).pl_id,
6963 l_date_to_use );
6964 --
6965 fetch c1 into l_dummy;
6966 --
6967 if c1%notfound then
6968 --
6969 hr_utility.set_location('Cobra plans not found',10);
6970 l_continue := false;
6971 --
6972 end if;
6973 --
6974 close c1;
6975 --
6976 end if;
6977 --
6978 if l_continue then
6979 --
6980 hr_utility.set_location('Cobra plans found',10);
6981 --
6982 if (l_date_to_use
6983 between ben_manage_life_events.
6984 g_cache_person_prtn(l_count).enrt_cvg_strt_dt
6985 and ben_manage_life_events.
6986 g_cache_person_prtn(l_count).enrt_cvg_thru_dt) then
6987 --
6988 l_found_ptip := true;
6989 hr_utility.set_location('cobra plans found',10);
6990 --
6991 if l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
6992 --
6993 hr_utility.set_location('Exclude flags = N Cobra plans found',10);
6994 l_ok := true;
6995 exit prfl;
6996 --
6997 end if;
6998 --
6999 if l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
7000 --
7001 hr_utility.set_location('Exclude flags = Y Cobra plans found',10);
7002 l_ok := false;
7003 exit prfl;
7004 --
7005 end if;
7006 --
7007 end if;
7008 --
7009 end if;
7010 --
7011 end if;
7012 --
7013 end loop rslt;
7014 --
7015 if l_found_ptip = false
7016 and l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
7017 --
7018 l_ok := true;
7019 exit;
7020 --
7021 end if;
7022 --
7023 end loop prfl;
7024 --
7025 end if;
7026 --
7027 if l_rows_found and
7028 not l_ok then
7029 --
7030 g_inelg_rsn_cd := 'EET';
7031 fnd_message.set_name('BEN','BEN_92422_EET_ELIG_PRFL_FAIL');
7032 hr_utility.set_location('Criteria Failed: '||l_proc,20);
7033 raise g_criteria_failed;
7034 --
7035 end if;
7036 --
7037 hr_utility.set_location('Leaving :'||l_proc,20);
7038 --
7039 end check_elig_enrld_anthr_ptip;
7040 --
7041 -- --------------------------------------------------------------------------
7042 -- This procedure det elig based on dependent covered in another plan type
7043 -- in program.
7044 -- --------------------------------------------------------------------------
7045 --
7046 procedure check_elig_dpnt_cvrd_othr_ptip(p_eligy_prfl_id in number,
7047 p_business_group_id in number,
7048 p_person_id in number,
7049 p_effective_date in date,
7050 p_lf_evt_ocrd_dt in date) is
7051 --
7052 l_proc varchar2(100):=g_package||'check_elig_dpnt_cvrd_othr_ptip';
7053 l_inst_dets ben_elp_cache.g_cache_elpedt_instor;
7054 l_inst_count number;
7055 l_insttorrw_num binary_integer;
7056 l_ok boolean := false;
7057 l_rows_found boolean := false;
7058 l_continue boolean := true;
7059 l_found_ptip boolean := false;
7060 l_date_to_use date;
7061 l_dummy varchar2(1);
7062 --
7063 cursor c1(p_ptip_id in number,p_date_to_use date ) is
7064 select pen.pl_id
7065 from ben_prtt_enrt_rslt_f pen
7066 ,ben_elig_cvrd_dpnt_f pdp
7067 where pen.prtt_enrt_rslt_id = pdp.prtt_enrt_rslt_id
7068 --and pen.prtt_enrt_rslt_stat_cd not in ('BCKDT', 'VOIDD')
7069 and pen.prtt_enrt_rslt_stat_cd is null
7070 and pdp.dpnt_person_id = p_person_id
7071 and pen.ptip_id = p_ptip_id
7072 and p_date_to_use
7073 between pen.enrt_cvg_strt_dt
7074 and pen.enrt_cvg_thru_dt
7075 and pen.business_group_id = p_business_group_id
7076 and pen.enrt_cvg_thru_dt <= pen.effective_end_date
7077 and pen.prtt_enrt_rslt_stat_cd is null
7078 and pdp.business_group_id = pen.business_group_id
7079 and p_date_to_use
7080 between pdp.cvg_strt_dt
7081 and pdp.cvg_thru_dt
7082 and pdp.effective_end_date = hr_api.g_eot;
7083 --
7084 cursor c2(p_pl_id in number,p_date_to_use date ) is
7085 select null
7086 from ben_pl_regn_f prg
7087 ,ben_regn_f reg
7088 where prg.pl_id = p_pl_id
7089 and prg.regn_id = reg.regn_id
7090 and reg.sttry_citn_name = 'COBRA'
7091 and prg.business_group_id = p_business_group_id
7092 and p_date_to_use
7093 between prg.effective_start_date
7094 and prg.effective_end_date
7095 and prg.business_group_id = reg.business_group_id
7096 and p_date_to_use
7097 between reg.effective_start_date
7098 and reg.effective_end_date;
7099 --
7100 begin
7101 --
7102 hr_utility.set_location('Entering: '||l_proc, 10);
7103 --
7104 -- Getting eligibility profile compensation level by eligibility profile
7105 --
7106 ben_elp_cache.elpedt_getcacdets
7107 (p_effective_date => nvl(l_fonm_cvg_strt_dt,
7108 nvl(p_lf_evt_ocrd_dt,p_effective_date)),
7109 p_business_group_id => p_business_group_id,
7110 p_eligy_prfl_id => p_eligy_prfl_id,
7111 p_inst_set => l_inst_dets,
7112 p_inst_count => l_inst_count);
7113 --
7114 if l_inst_count > 0 then
7115 --
7116 -- Operation
7117 -- =========
7118 -- 1) Grab all profiles for this eligibility profile id
7119 -- 2) If the plan id is the same then check if the person was covered
7120 -- the day before the life event.
7121 --
7122 <<prfl>>
7123 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
7124 --
7125 l_rows_found := true;
7126 --
7127 --
7128 -- Apply the date logic to the life event occurred date.
7129 --
7130 ben_determine_date.main
7131 (p_date_cd => l_inst_dets(l_insttorrw_num).enrl_det_dt_cd,
7132 p_effective_date => p_effective_date,
7133 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
7134 p_fonm_cvg_strt_dt => ben_manage_life_events.g_fonm_cvg_strt_dt,
7135 p_fonm_rt_strt_dt => ben_manage_life_events.g_fonm_rt_strt_dt,
7136 p_returned_date => l_date_to_use);
7137 --
7138 -- 4204020 l_date_to_use := nvl(l_fonm_cvg_strt_dt,l_date_to_use);
7139 --
7140 <<dpnt>>
7141 for l_pdp_rec in c1(l_inst_dets(l_insttorrw_num).ptip_id,l_date_to_use ) loop
7142 --
7143 -- Check if the dependent have to be covered in the ptip where
7144 -- there are plans subject to cobra.
7145 --
7146 l_continue := true;
7147 --
7148 if l_inst_dets(l_insttorrw_num).only_pls_subj_cobra_flag = 'Y' then
7149 open c2(l_pdp_rec.pl_id, l_date_to_use );
7150 fetch c2 into l_dummy;
7151 if c2%notfound then
7152 l_continue := false;
7153 end if;
7154 close c2;
7155 end if;
7156 --
7157 if l_continue then
7158 l_found_ptip := true;
7159 --
7160 if l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
7161 l_ok := true;
7162 exit prfl;
7163 end if;
7164 --
7165 if l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
7166 l_ok := false;
7167 exit prfl;
7168 end if;
7169 --
7170 end if;
7171 --
7172 end loop dpnt;
7173 --
7174 if (l_found_ptip = false
7175 and l_inst_dets(l_insttorrw_num).excld_flag = 'Y') then
7176 l_ok := true;
7177 exit;
7178 end if;
7179 --
7180 end loop prfl;
7181 --
7182 end if;
7183 --
7184 if l_rows_found and
7185 not l_ok then
7186 --
7187 g_inelg_rsn_cd := 'EDT';
7188 fnd_message.set_name('BEN','BEN_92423_EDT_ELIG_PRFL_FAIL');
7189 hr_utility.set_location('Criteria Failed: '||l_proc,20);
7190 raise g_criteria_failed;
7191 --
7192 end if;
7193 --
7194 hr_utility.set_location('Leaving :'||l_proc,20);
7195 --
7196 end check_elig_dpnt_cvrd_othr_ptip;
7197 --
7198 -- --------------------------------------------------------------------------
7199 -- This procedure det elig based on dependent covered in another program.
7200 -- --------------------------------------------------------------------------
7201 procedure check_elig_dpnt_cvrd_othr_pgm(p_eligy_prfl_id in number,
7202 p_business_group_id in number,
7203 p_person_id in number,
7204 p_effective_date in date,
7205 p_lf_evt_ocrd_dt in date) is
7206 --
7207 l_proc varchar2(100):=g_package||'check_elig_dpnt_cvrd_othr_pgm';
7208 l_inst_dets ben_elp_cache.g_cache_elpedg_instor;
7209 l_inst_count number;
7210 l_insttorrw_num binary_integer;
7211 l_ok boolean := false;
7212 l_rows_found boolean := false;
7213 l_date_to_use date;
7214 l_dummy varchar2(1);
7215 --
7216 cursor c1(p_pgm_id in number) is
7217 select null
7218 from ben_elig_cvrd_dpnt_f pdp,
7219 ben_prtt_enrt_rslt_f pen
7220 where pen.business_group_id = p_business_group_id
7221 and pen.pgm_id = p_pgm_id
7222 and pdp.dpnt_person_id = p_person_id
7223 and l_date_to_use -- 5550851
7224 between pen.enrt_cvg_strt_dt
7225 and pen.enrt_cvg_thru_dt
7226 and pen.enrt_cvg_thru_dt <= pen.effective_end_date
7227 and pdp.business_group_id = pen.business_group_id
7228 and pdp.prtt_enrt_rslt_id = pen.prtt_enrt_rslt_id
7229 --and pen.prtt_enrt_rslt_stat_cd not in ('BCKDT', 'VOIDD')
7230 and pen.prtt_enrt_rslt_stat_cd is null
7231 and l_date_to_use -- 5550851
7232 between pdp.cvg_strt_dt
7233 and pdp.cvg_thru_dt
7234 and pdp.effective_end_date = hr_api.g_eot;
7235 --
7236 begin
7237 --
7238 hr_utility.set_location('Entering: '||l_proc, 10);
7239 --
7240 -- Getting eligibility profile compensation level by eligibility profile
7241 --
7242 ben_elp_cache.elpedg_getcacdets
7243 (p_effective_date => nvl(l_fonm_cvg_strt_dt,nvl(p_lf_evt_ocrd_dt,p_effective_date)),
7244 p_business_group_id => p_business_group_id,
7245 p_eligy_prfl_id => p_eligy_prfl_id,
7246 p_inst_set => l_inst_dets,
7247 p_inst_count => l_inst_count);
7248 --
7249 if l_inst_count > 0 then
7250 --
7251 -- Operation
7252 -- =========
7253 -- 1) Grab all profiles for this eligibility profile id
7254 -- 2) If the plan id is the same then check if the person was covered
7255 -- the day before the life event.
7256 --
7257 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
7258 --
7259 l_rows_found := true;
7260 --
7261 --
7262 -- Apply the date logic to the life event occurred date.
7263 --
7264 ben_determine_date.main
7265 (p_date_cd => l_inst_dets(l_insttorrw_num).enrl_det_dt_cd,
7266 p_effective_date => p_effective_date,
7267 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
7268 p_fonm_cvg_strt_dt => ben_manage_life_events.g_fonm_cvg_strt_dt,
7269 p_fonm_rt_strt_dt => ben_manage_life_events.g_fonm_rt_strt_dt,
7270 p_returned_date => l_date_to_use);
7271 --
7272 open c1(l_inst_dets(l_insttorrw_num).pgm_id);
7273 fetch c1 into l_dummy;
7274 --
7275 if c1%found then
7276 --
7277 close c1;
7278 --
7279 if l_inst_dets(l_insttorrw_num).excld_flag = 'N' then
7280 l_ok := true;
7281 exit;
7282 end if;
7283 --
7284 if l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
7285 l_ok := false;
7286 exit;
7287 end if;
7288 --
7289 else
7290 --
7291 close c1;
7292 if l_inst_dets(l_insttorrw_num).excld_flag = 'Y' then
7293 l_ok := true;
7294 --exit ;
7295 end if;
7296 end if;
7297 --
7298 end loop;
7299 --
7300 end if;
7301 --
7302 if l_rows_found and
7303 not l_ok then
7304 --
7305 g_inelg_rsn_cd := 'EDG';
7306 fnd_message.set_name('BEN','BEN_92424_EDG_ELIG_PRFL_FAIL');
7307 hr_utility.set_location('Criteria Failed: '||l_proc,20);
7308 raise g_criteria_failed;
7309 --
7310 end if;
7311 --
7312 hr_utility.set_location('Leaving :'||l_proc,20);
7313 --
7314 end check_elig_dpnt_cvrd_othr_pgm;
7315 --
7316 -- --------------------------------------------------------------------------
7317 -- This procedure det elig based on cobra qualified benificiary status.
7318 -- --------------------------------------------------------------------------
7319 --
7320 procedure check_elig_cbr_quald_bnf
7321 (p_eligy_prfl_id in number,
7322 p_person_id in number,
7323 p_business_group_id in number,
7324 p_lf_evt_ocrd_dt in date,
7325 p_effective_date in date) is
7326 --
7327 l_proc varchar2(100):=g_package||'check_elig_cbr_quald_bnf';
7328 l_inst_dets ben_elp_cache.g_cache_elpecq_instor;
7329 l_quald_bnf_flag ben_cbr_quald_bnf.quald_bnf_flag%type;
7330 l_inst_count number;
7331 l_insttorrw_num binary_integer;
7332 l_ok boolean := false;
7333 l_rows_found boolean := false;
7334 l_rec per_all_people_f%rowtype;
7335 --
7336 cursor c1(p_person_id in number
7337 ,p_lf_evt_ocrd_dt in date
7338 ,p_pgm_id in number
7339 ,p_ptip_id in number) is
7340 select cqb.quald_bnf_flag
7341 from ben_cbr_quald_bnf cqb
7342 ,ben_cbr_per_in_ler crp
7343 ,ben_per_in_ler pil
7344 where cqb.quald_bnf_person_id = p_person_id
7345 -- lamc added these next 2 lines
7346 and cqb.pgm_id = nvl(p_pgm_id,cqb.pgm_id)
7347 and nvl(cqb.ptip_id,-1) = nvl(p_ptip_id, -1)
7348 --
7349 and nvl(p_lf_evt_ocrd_dt,p_effective_date)
7350 between cqb.cbr_elig_perd_strt_dt
7351 and cqb.cbr_elig_perd_end_dt
7352 and cqb.business_group_id = p_business_group_id
7353 and cqb.cbr_quald_bnf_id = crp.cbr_quald_bnf_id
7354 and crp.per_in_ler_id = pil.per_in_ler_id
7355 and crp.business_group_id = cqb.business_group_id
7356 -- and pil.business_group_id = crp.business_group_id
7357 and crp.init_evt_flag = 'Y'
7358 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT');
7359 --
7360 begin
7361 --
7362 hr_utility.set_location('Entering: '||l_proc, 10);
7363 --
7364 -- Getting eligibility profile compensation level by eligibility profile
7365 --
7366 ben_elp_cache.elpecq_getcacdets
7367 (p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date),
7368 p_business_group_id => p_business_group_id,
7369 p_eligy_prfl_id => p_eligy_prfl_id,
7370 p_inst_set => l_inst_dets,
7371 p_inst_count => l_inst_count);
7372 --
7373 if l_inst_count > 0 then
7374 --
7375 -- Operation
7376 -- =========
7377 -- 1) Grab all profiles for this eligibility profile id
7378 -- 2) If the leaving reason code is excluded then person is not eligible
7379 -- 3) If the leaving reason code is not excluded then person is eligible.
7380 --
7381 for l_insttorrw_num in l_inst_dets.first .. l_inst_dets.last loop
7382 --
7383 l_rows_found := true;
7384 --
7385 open c1(p_person_id
7386 ,p_lf_evt_ocrd_dt
7387 ,l_inst_dets(l_insttorrw_num).pgm_id
7388 ,l_inst_dets(l_insttorrw_num).ptip_id);
7389 fetch c1 into l_quald_bnf_flag;
7390 if c1%found then
7391 l_ok := nvl((nvl(l_quald_bnf_flag,'-1') = l_inst_dets(l_insttorrw_num).quald_bnf_flag),FALSE);
7392 else
7393 l_ok := nvl((l_inst_dets(l_insttorrw_num).quald_bnf_flag = 'N'),FALSE);
7394 end if;
7395 close c1;
7396 --if l_ok is null then
7397 -- l_ok:=false;
7398 if l_ok then
7399 exit;
7400 end if;
7401 end loop;
7402 --
7403 end if;
7404 --
7405 if l_rows_found and
7406 not l_ok then
7407 --
7408 g_inelg_rsn_cd := 'ECQ';
7409 fnd_message.set_name('BEN','BEN_92425_ECQ_ELIG_PRFL_FAIL');
7410 hr_utility.set_location('Criteria Failed: '||l_proc,20);
7411 raise g_criteria_failed;
7412 --
7413 end if;
7414 --
7415 hr_utility.set_location('Leaving :'||l_proc,20);
7416 --
7417 end check_elig_cbr_quald_bnf;
7418 -- ----------------------------------------------------------------------------
7419 -- Disabled
7420 -- ----------------------------------------------------------------------------
7421 procedure check_dsbld_elig
7422 (p_eligy_prfl_id in number
7423 ,p_effective_date in date
7424 ,p_score_compute_mode in boolean default false
7425 ,p_profile_score_tab in out nocopy scoreTab
7426 ,p_dsbld_cd in varchar2
7427 )
7428 is
7429 --
7430 l_proc varchar2(100) := g_package||'check_dsbld_elig';
7431 --
7432 l_inst_set ben_elp_cache.g_elp_cache := ben_elp_cache.g_elp_cache();
7433 l_ok boolean := false;
7434 l_rows_found boolean := false;
7435 l_ele_num pls_integer;
7436 l_crit_passed boolean;
7437 l_score_tab scoreTab;
7438 --
7439 begin
7440 --
7441 hr_utility.set_location('Entering : '||l_proc,10);
7442 --
7443 ben_elp_cache.elpeds_getdets
7444 (p_effective_date => p_effective_date
7445 ,p_eligy_prfl_id => p_eligy_prfl_id
7446 --
7447 ,p_inst_set => l_inst_set
7448 );
7449 --
7450 if l_inst_set.count > 0 then
7451 --
7452 l_ele_num := 1;
7453 --
7454 for i in l_inst_set.first .. l_inst_set.last loop
7455 --
7456 l_rows_found := true;
7457 --
7458 l_ok := nvl((nvl(p_dsbld_cd,'xxxx') = l_inst_set(l_ele_num).v230_val),FALSE);
7459 --
7460 if l_ok and l_inst_set(l_ele_num).excld_flag = 'N' then
7461 --
7462 hr_utility.set_location('Exclude Flag = N, Disabled Code = ' || p_dsbld_cd || ' found ', 20 );
7463 if p_score_compute_mode then
7464 if l_crit_passed is null then
7465 l_crit_passed := true;
7466 end if;
7467 write(l_score_tab,
7468 l_inst_set(l_ele_num).eligy_prfl_id,
7469 l_inst_set(l_ele_num).short_code,
7470 l_inst_set(l_ele_num).pk_id,
7471 nvl(l_inst_set(l_ele_num).criteria_score,
7472 l_inst_set(l_ele_num).criteria_weight));
7473 else
7474 exit;
7475 end if;
7476 --
7477 elsif l_ok and l_inst_set(l_ele_num).excld_flag = 'Y' then
7478 --
7479 hr_utility.set_location('Exclude Flag = Y, Disabled Code = ' || p_dsbld_cd || ' found ', 20 );
7480 l_ok := false;
7481 exit;
7482 --
7483 elsif (not l_ok) and l_inst_set(l_ele_num).excld_flag = 'Y' then
7484 --
7485 l_ok := true;
7486 if p_score_compute_mode then
7487 write(l_score_tab,
7488 l_inst_set(l_ele_num).eligy_prfl_id,
7489 l_inst_set(l_ele_num).short_code,
7490 l_inst_set(l_ele_num).pk_id,
7491 nvl(l_inst_set(l_ele_num).criteria_score,
7492 l_inst_set(l_ele_num).criteria_weight));
7493 end if;
7494 --
7495 end if;
7496 --
7497 l_ele_num := l_ele_num+1;
7498 --
7499 end loop;
7500 --
7501 -- clean up varray since it is no longer required
7502 --
7503 l_inst_set.delete;
7504 --
7505 end if;
7506 --
7507 if l_crit_passed is null
7508 then
7509 if l_rows_found
7510 and not l_ok
7511 then
7512 --
7513 g_inelg_rsn_cd := 'DSB';
7514 fnd_message.set_name('BEN','BEN_93080_DSBLD_PRFL_FAIL');
7515 hr_utility.set_location('Criteria Failed: '||l_proc,40);
7516 raise g_criteria_failed;
7517 --
7518 end if;
7519 end if;
7520 --
7521 if p_score_compute_mode
7522 then
7523 hr_utility.set_location('count '||l_score_tab.count,20);
7524 write(p_profile_score_tab,l_score_tab);
7525 end if;
7526 hr_utility.set_location('Leaving: '||l_proc,50);
7527 --
7528 end check_dsbld_elig;
7529 --
7530 -- ----------------------------------------------------------------------------
7531 -- Tobacco Use
7532 -- ----------------------------------------------------------------------------
7533 procedure check_tbco_use_elig
7534 (p_eligy_prfl_id in number
7535 ,p_effective_date in date
7536 ,p_score_compute_mode in boolean default false
7537 ,p_profile_score_tab in out nocopy scoreTab
7538 ,p_tbco_use_flag in varchar2
7539 )
7540 is
7541 --
7542 l_proc varchar2(100) := g_package||'check_tbco_use_elig';
7543 --
7544 l_inst_set ben_elp_cache.g_elp_cache := ben_elp_cache.g_elp_cache();
7545 l_ok boolean := false;
7546 l_rows_found boolean := false;
7547 l_ele_num pls_integer;
7548 l_crit_passed boolean;
7549 l_score_tab scoreTab;
7550 --
7551 begin
7552 --
7553 hr_utility.set_location('Entering : '||l_proc,10);
7554 --
7555 ben_elp_cache.elpetu_getdets
7556 (p_effective_date => p_effective_date
7557 ,p_eligy_prfl_id => p_eligy_prfl_id
7558 --
7559 ,p_inst_set => l_inst_set
7560 );
7561 --
7562 if l_inst_set.count > 0 then
7563 --
7564 l_ele_num := 1;
7565 --
7566 for i in l_inst_set.first .. l_inst_set.last loop
7567 --
7568 l_rows_found := true;
7569 --
7570 l_ok := nvl((nvl(p_tbco_use_flag,'xxxx') = l_inst_set(l_ele_num).v230_val),FALSE);
7571 --
7572 if l_ok and l_inst_set(l_ele_num).excld_flag = 'N' then
7573 --
7574 hr_utility.set_location('Exclude Flag = N, Tobacco Use = ' || p_tbco_use_flag || ' found ', 20 );
7575 if p_score_compute_mode then
7576 if l_crit_passed is null then
7577 l_crit_passed := true;
7578 end if;
7579 write(l_score_tab,
7580 l_inst_set(l_ele_num).eligy_prfl_id,
7581 l_inst_set(l_ele_num).short_code,
7582 l_inst_set(l_ele_num).pk_id,
7583 nvl(l_inst_set(l_ele_num).criteria_score,
7584 l_inst_set(l_ele_num).criteria_weight));
7585 else
7586 exit;
7587 end if;
7588 --
7589 elsif l_ok and l_inst_set(l_ele_num).excld_flag = 'Y' then
7590 --
7591 hr_utility.set_location('Exclude Flag = Y, Tobacco Use = ' || p_tbco_use_flag || ' found ', 20 );
7592 l_ok := false;
7593 exit;
7594 --
7595 elsif (not l_ok) and l_inst_set(l_ele_num).excld_flag = 'Y' then
7596 --
7597 l_ok := true;
7598 --
7599 if p_score_compute_mode then
7600 write(l_score_tab,
7601 l_inst_set(l_ele_num).eligy_prfl_id,
7602 l_inst_set(l_ele_num).short_code,
7603 l_inst_set(l_ele_num).pk_id,
7604 nvl(l_inst_set(l_ele_num).criteria_score,
7605 l_inst_set(l_ele_num).criteria_weight));
7606 end if;
7607 end if;
7608 --
7609 l_ele_num := l_ele_num+1;
7610 --
7611 end loop;
7612 --
7613 -- clean up varray since it is no longer required
7614 --
7615 l_inst_set.delete;
7616 --
7617 end if;
7618 --
7619 if l_crit_passed is null
7620 then
7621 if l_rows_found
7622 and not l_ok
7623 then
7624 --
7625 g_inelg_rsn_cd := 'ETU';
7626 fnd_message.set_name('BEN','BEN_93081_TBCO_USE_PRFL_FAIL');
7627 hr_utility.set_location('Criteria Failed: '||l_proc,40);
7628 raise g_criteria_failed;
7629 --
7630 end if;
7631 end if;
7632 --
7633 if p_score_compute_mode
7634 then
7635 hr_utility.set_location('count '||l_score_tab.count,20);
7636 write(p_profile_score_tab,l_score_tab);
7637 end if;
7638 hr_utility.set_location('Leaving: '||l_proc,50);
7639 --
7640 end check_tbco_use_elig;
7641 --
7642 -- ----------------------------------------------------------------------------
7643 -- Total Coverage Volume
7644 -- ----------------------------------------------------------------------------
7645 procedure check_ttl_cvg_vol_elig
7646 (p_eligy_prfl_id in number,
7647 p_business_group_id in number,
7648 p_person_id in number,
7649 p_ttl_cvg in number,
7650 p_lf_evt_ocrd_dt in date,
7651 p_effective_date in date) is
7652 --
7653 l_proc varchar2(100):=g_package||'.check_ttl_cvg_vol_elig';
7654 --
7655 l_inst_set ben_elp_cache.g_elp_cache := ben_elp_cache.g_elp_cache();
7656 l_ok boolean := false;
7657 l_rows_found boolean := false;
7658 l_ele_num pls_integer;
7659 --
7660 l_ttl_cvg_vol number ;
7661 l_dummy char;
7662 --
7663 l_eot date := hr_api.g_eot;
7664 --
7665 cursor c_bnft_amt(cp_lf_evt_ocrd_dt in date ,
7666 cp_effective_date in date ,
7667 cp_business_group_id in number) is
7668 select sum(nvl(pen.bnft_amt,0))
7669 from ben_prtt_enrt_rslt_f pen
7670 where pen.business_group_id = cp_business_group_id
7671 and nvl(cp_lf_evt_ocrd_dt,cp_effective_date)
7672 between pen.enrt_cvg_strt_dt and pen.enrt_cvg_thru_dt
7673 and pen.sspndd_flag = 'N'
7674 and pen.prtt_enrt_rslt_stat_cd is null
7675 and pen.effective_end_date = l_eot;
7676 --
7677 cursor c_pen_found(cp_lf_evt_ocrd_dt in date , -- bug 2431619
7678 cp_effective_date in date ,
7679 cp_person_id in number,
7680 cp_business_group_id in number) is
7681 select null
7682 from ben_prtt_enrt_rslt_f pen
7683 where pen.person_id = cp_person_id
7684 and pen.business_group_id = cp_business_group_id
7685 and nvl(cp_lf_evt_ocrd_dt,cp_effective_date)
7686 between pen.enrt_cvg_strt_dt and pen.enrt_cvg_thru_dt
7687 and pen.sspndd_flag = 'N'
7688 and pen.prtt_enrt_rslt_stat_cd is null
7689 and pen.effective_end_date = l_eot;
7690 --
7691 begin
7692 --
7693 hr_utility.set_location('Entering: '||l_proc, 10);
7694 --
7695 ben_elp_cache.elpetc_getdets
7696 (p_effective_date => nvl(l_fonm_cvg_strt_dt,p_effective_date)
7697 ,p_eligy_prfl_id => p_eligy_prfl_id
7698 --
7699 ,p_inst_set => l_inst_set
7700 );
7701 --
7702 if l_inst_set.count > 0 then
7703 --
7704 if p_ttl_cvg is not null then
7705 l_ttl_cvg_vol := p_ttl_cvg;
7706 else
7707 open c_bnft_amt(nvl(l_fonm_cvg_strt_dt,p_lf_evt_ocrd_dt) ,
7708 p_effective_date ,
7709 p_business_group_id ) ;
7710 fetch c_bnft_amt into l_ttl_cvg_vol ;
7711 close c_bnft_amt ;
7712 end if;
7713
7714 l_ele_num := 1;
7715
7716 --
7717 for i in l_inst_set.first .. l_inst_set.last loop
7718 --
7719 l_rows_found := true;
7720 --
7721 if nvl(l_ttl_cvg_vol,0)
7722 between nvl(l_inst_set(l_ele_num).num_val,0)
7723 and nvl(l_inst_set(l_ele_num).num_val1 - 1 , 999999999999999) -- 2431619
7724 then
7725 hr_utility.set_location(l_proc, 20);
7726 l_ok := true;
7727 exit;
7728 --
7729 elsif nvl(l_ttl_cvg_vol,0) = nvl(l_inst_set(l_ele_num).num_val1, 999999999999999) then -- bug 2431619
7730 --
7731 open c_pen_found(nvl(l_fonm_cvg_strt_dt,p_lf_evt_ocrd_dt) ,
7732 p_effective_date ,
7733 p_person_id ,
7734 p_business_group_id ) ;
7735 fetch c_pen_found into l_dummy;
7736 if c_pen_found%found then
7737 --
7738 hr_utility.set_location(l_proc, 30);
7739 close c_pen_found;
7740 l_ok := true;
7741 exit;
7742 --
7743 else
7744 --
7745 hr_utility.set_location(l_proc, 40);
7746 close c_pen_found;
7747 l_ok := false;
7748 --
7749 end if;
7750 -- -- end 2431619
7751 else
7752 --
7753 hr_utility.set_location(l_proc, 50);
7754 l_ok := false;
7755 --
7756 end if;
7757 --
7758 l_ele_num := l_ele_num + 1;
7759 --
7760 end loop;
7761 --
7762 end if;
7763 --
7764 if l_rows_found
7765 and not l_ok
7766 then
7767 --
7768 g_inelg_rsn_cd := 'ETC';
7769 fnd_message.set_name('BEN','BEN_93082_TTLCVGVOL_PRFL_FAIL');
7770 hr_utility.set_location('Criteria Failed: '||l_proc,60);
7771 raise g_criteria_failed;
7772 --
7773 end if;
7774 --
7775 hr_utility.set_location('Leaving: '||l_proc,50);
7776 --
7777 end check_ttl_cvg_vol_elig;
7778 --
7779 -- ----------------------------------------------------------------------------
7780 -- Total Participants
7781 -- ----------------------------------------------------------------------------
7782 procedure check_ttl_prtt_elig
7783 (p_eligy_prfl_id in number,
7784 p_business_group_id in number,
7785 p_person_id in number,
7786 p_ttl_prtt in number,
7787 p_lf_evt_ocrd_dt in date,
7788 p_effective_date in date) is
7789 --
7790 l_proc varchar2(100):=g_package||'.check_ttl_prtt_elig';
7791 --
7792 l_inst_set ben_elp_cache.g_elp_cache := ben_elp_cache.g_elp_cache();
7793 l_ok boolean := false;
7794 l_rows_found boolean := false;
7795 l_ele_num pls_integer;
7796 --
7797 l_ttl_prtt number ;
7798 l_dummy char;
7799 --
7800 l_eot date := hr_api.g_eot;
7801 --
7802 cursor c_ttl_prtt(cp_lf_evt_ocrd_dt in date ,
7803 cp_effective_date in date ,
7804 cp_business_group_id in number) is
7805 select count(pen.prtt_enrt_rslt_id)
7806 from ben_prtt_enrt_rslt_f pen
7807 where pen.business_group_id = cp_business_group_id
7808 and nvl(cp_lf_evt_ocrd_dt,cp_effective_date)
7809 between pen.enrt_cvg_strt_dt and pen.enrt_cvg_thru_dt
7810 and pen.sspndd_flag = 'N'
7811 and pen.prtt_enrt_rslt_stat_cd is null
7812 and pen.effective_end_date = l_eot;
7813 --
7814 cursor c_pen_found(cp_lf_evt_ocrd_dt in date , -- bug 2431619
7815 cp_effective_date in date ,
7816 cp_person_id in number,
7817 cp_business_group_id in number) is
7818 select null
7819 from ben_prtt_enrt_rslt_f pen
7820 where pen.person_id = cp_person_id
7821 and pen.business_group_id = cp_business_group_id
7822 and nvl(cp_lf_evt_ocrd_dt,cp_effective_date)
7823 between pen.enrt_cvg_strt_dt and pen.enrt_cvg_thru_dt
7824 and pen.sspndd_flag = 'N'
7825 and pen.prtt_enrt_rslt_stat_cd is null
7826 and pen.effective_end_date = l_eot;
7827 --
7828 begin
7829 --
7830 hr_utility.set_location('Entering: '||l_proc, 10);
7831 --
7832 ben_elp_cache.elpetp_getdets
7833 (p_effective_date => nvl(l_fonm_cvg_strt_dt,p_effective_date)
7834 ,p_eligy_prfl_id => p_eligy_prfl_id
7835 --
7836 ,p_inst_set => l_inst_set
7837 );
7838 --
7839 if l_inst_set.count > 0 then
7840 --
7841 if p_ttl_prtt is not null then
7842 l_ttl_prtt := p_ttl_prtt;
7843 else
7844 open c_ttl_prtt(nvl(l_fonm_cvg_strt_dt,p_lf_evt_ocrd_dt) ,
7845 p_effective_date ,
7846 p_business_group_id ) ;
7847 fetch c_ttl_prtt into l_ttl_prtt ;
7848 close c_ttl_prtt ;
7849 end if;
7850
7851 l_ele_num := 1;
7852 --
7853 for i in l_inst_set.first .. l_inst_set.last loop
7854 --
7855 l_rows_found := true;
7856 --
7857 hr_utility.set_location('l_ttl_prtt ' || l_ttl_prtt || ' num_val1 ' || l_inst_set(l_ele_num).num_val1, -729);
7858 if nvl(l_ttl_prtt,0)
7859 between nvl(l_inst_set(l_ele_num).num_val,0)
7860 and nvl(l_inst_set(l_ele_num).num_val1 - 1 , 999999999999999) -- bug 2431619
7861 then
7862 hr_utility.set_location(l_proc, 20);
7863 l_ok := true;
7864 exit;
7865 --
7866 elsif nvl(l_ttl_prtt,0) = nvl(l_inst_set(l_ele_num).num_val1, 999999999999999) then -- bug 2431619
7867 --
7868 open c_pen_found(nvl(l_fonm_cvg_strt_dt,p_lf_evt_ocrd_dt) ,
7869 p_effective_date ,
7870 p_person_id ,
7871 p_business_group_id ) ;
7872 fetch c_pen_found into l_dummy;
7873 if c_pen_found%found then
7874 --
7875 hr_utility.set_location(l_proc, 30);
7876 close c_pen_found;
7877 l_ok := true;
7878 exit;
7879 --
7880 else
7881 --
7882 hr_utility.set_location(l_proc, 40);
7883 close c_pen_found;
7884 l_ok := false;
7885 --
7886 end if;
7887 -- -- end 2431619
7888 else
7889 --
7890 hr_utility.set_location(l_proc, 50);
7891 l_ok := false;
7892 --
7893 end if;
7894 --
7895 l_ele_num := l_ele_num+1;
7896 --
7897 end loop;
7898 --
7899 end if;
7900 --
7901 if l_rows_found
7902 and not l_ok
7903 then
7904 --
7905 g_inelg_rsn_cd := 'ETP';
7906 fnd_message.set_name('BEN','BEN_93083_TTL_PRTT_PRFL_FAIL');
7907 hr_utility.set_location('Criteria Failed: '||l_proc,60);
7908 raise g_criteria_failed;
7909 --
7910 end if;
7911 --
7912 hr_utility.set_location('Leaving: '||l_proc,50);
7913 --
7914 end check_ttl_prtt_elig;
7915 --
7916 -- ----------------------------------------------------------------------------
7917 -- Participation in Another Plan
7918 -- ----------------------------------------------------------------------------
7919 procedure check_anthr_pl_elig
7920 (p_eligy_prfl_id in number,
7921 p_business_group_id in number,
7922 p_person_id in number,
7923 p_lf_evt_ocrd_dt in date,
7924 p_effective_date in date) is
7925 --
7926 l_proc varchar2(100):=g_package||'.check_anthr_pl_elig';
7927 --
7928 l_inst_set ben_elp_cache.g_elp_cache := ben_elp_cache.g_elp_cache();
7929 l_ok boolean := false;
7930 l_rows_found boolean := false;
7931 l_ele_num pls_integer;
7932 --
7933 l_dummy char ;
7934 --
7935 l_eot date := hr_api.g_eot;
7936 --
7937 cursor c_prtt_in_pl(cp_person_id in number,
7938 cp_pl_id in number,
7939 cp_lf_evt_ocrd_dt in date ,
7940 cp_effective_date in date ,
7941 cp_business_group_id in number) is
7942 select null
7943 from ben_prtt_enrt_rslt_f pen
7944 where pen.business_group_id = cp_business_group_id
7945 and pen.person_id = cp_person_id
7946 and pen.pl_id = cp_pl_id
7947 and nvl(cp_lf_evt_ocrd_dt,cp_effective_date)
7948 between pen.enrt_cvg_strt_dt and pen.enrt_cvg_thru_dt
7949 and pen.sspndd_flag = 'N'
7950 and pen.prtt_enrt_rslt_stat_cd is null
7951 and pen.effective_end_date = l_eot;
7952 --
7953 begin
7954 --
7955 hr_utility.set_location('Entering: '||l_proc, 10);
7956 --
7957 ben_elp_cache.elpeop_getdets
7958 (p_effective_date => p_effective_date
7959 ,p_eligy_prfl_id => p_eligy_prfl_id
7960 --
7961 ,p_inst_set => l_inst_set
7962 );
7963 --
7964 if l_inst_set.count > 0 then
7965 --
7966 l_ele_num := 1;
7967 --
7968 for i in l_inst_set.first .. l_inst_set.last loop
7969 --
7970 l_rows_found := true;
7971 --
7972 open c_prtt_in_pl(p_person_id,
7973 l_inst_set(l_ele_num).num_val,
7974 p_lf_evt_ocrd_dt ,
7975 p_effective_date ,
7976 p_business_group_id ) ;
7977 fetch c_prtt_in_pl into l_dummy ;
7978 --
7979 if c_prtt_in_pl%found then
7980 l_ok := true;
7981 else
7982 l_ok := false;
7983 end if;
7984 --
7985 close c_prtt_in_pl ;
7986 --
7987 --
7988 if l_ok and l_inst_set(l_ele_num).excld_flag = 'N' then
7989 --
7990 hr_utility.set_location('Exclude Flag = N, Participation in Plan id = ' || l_inst_set(l_ele_num).num_val || ' found ', 20 );
7991 exit;
7992 --
7993 elsif l_ok and l_inst_set(l_ele_num).excld_flag = 'Y' then
7994 --
7995 hr_utility.set_location('Exclude Flag = Y, Participation in Plan id = ' || l_inst_set(l_ele_num).num_val || ' found ', 20 );
7996 l_ok := false;
7997 exit;
7998 --
7999 elsif (not l_ok) and l_inst_set(l_ele_num).excld_flag = 'Y' then
8000 --
8001 l_ok := true;
8002 --
8003 end if;
8004 --
8005 l_ele_num := l_ele_num+1;
8006 --
8007 end loop;
8008 --
8009 end if;
8010 --
8011 if l_rows_found
8012 and not l_ok
8013 then
8014 --
8015 g_inelg_rsn_cd := 'EOP';
8016 fnd_message.set_name('BEN','BEN_93084_ANTHR_PL_PRFL_FAIL');
8017 hr_utility.set_location('Criteria Failed: '||l_proc,40);
8018 raise g_criteria_failed;
8019 --
8020 end if;
8021 --
8022 hr_utility.set_location('Leaving: '||l_proc,50);
8023 --
8024 end check_anthr_pl_elig;
8025 --
8026 -- ----------------------------------------------------------------------------
8027 -- Health Coverage Selected
8028 -- ----------------------------------------------------------------------------
8029 procedure check_hlth_cvg_elig
8030 (p_eligy_prfl_id in number,
8031 p_business_group_id in number,
8032 p_person_id in number,
8033 p_lf_evt_ocrd_dt in date,
8034 p_effective_date in date) is
8035 --
8036 l_proc varchar2(100):=g_package||'.check_hlth_cvg_elig';
8037 --
8038 l_inst_set ben_elp_cache.g_elp_cache := ben_elp_cache.g_elp_cache();
8039 l_ok boolean := false;
8040 l_rows_found boolean := false;
8041 l_ele_num pls_integer;
8042 --
8043 l_dummy char ;
8044 --
8045 l_eot date := hr_api.g_eot;
8046 --
8047 cursor c_prtt_in_oipl(cp_person_id in number,
8048 cp_pl_typ_opt_typ_id in number,
8049 cp_oipl_id in number,
8050 cp_lf_evt_ocrd_dt in date ,
8051 cp_effective_date in date ,
8052 cp_business_group_id in number) is
8053 select null
8054 from ben_prtt_enrt_rslt_f pen
8055 , ben_pl_typ_opt_typ_f pto
8056 where pto.pl_typ_opt_typ_id = cp_pl_typ_opt_typ_id
8057 and pto.business_group_id = cp_business_group_id
8058 and nvl(cp_lf_evt_ocrd_dt,cp_effective_date)
8059 between pto.effective_start_date and pto.effective_end_date
8060 and pen.person_id = cp_person_id
8061 and pen.pl_typ_id = pto.pl_typ_id
8062 and pen.oipl_id = cp_oipl_id
8063 and pen.business_group_id = cp_business_group_id
8064 and nvl(cp_lf_evt_ocrd_dt,cp_effective_date)
8065 between pen.enrt_cvg_strt_dt and pen.enrt_cvg_thru_dt
8066 and pen.sspndd_flag = 'N'
8067 and pen.prtt_enrt_rslt_stat_cd is null
8068 and pen.effective_end_date = l_eot;
8069
8070 --
8071 begin
8072 --
8073 hr_utility.set_location('Entering: '||l_proc, 10);
8074 --
8075 ben_elp_cache.elpehc_getdets
8076 (p_effective_date => nvl(l_fonm_cvg_strt_dt,p_effective_date)
8077 ,p_eligy_prfl_id => p_eligy_prfl_id
8078 --
8079 ,p_inst_set => l_inst_set
8080 );
8081 --
8082 if l_inst_set.count > 0 then
8083 --
8084 l_ele_num := 1;
8085 --
8086 for i in l_inst_set.first .. l_inst_set.last loop
8087 --
8088 l_rows_found := true;
8089 --
8090 open c_prtt_in_oipl(p_person_id,
8091 l_inst_set(l_ele_num).num_val,
8092 l_inst_set(l_ele_num).num_val1,
8093 nvl(l_fonm_cvg_strt_dt,p_lf_evt_ocrd_dt) ,
8094 p_effective_date ,
8095 p_business_group_id ) ;
8096 fetch c_prtt_in_oipl into l_dummy ;
8097 --
8098 if c_prtt_in_oipl%found then
8099 l_ok := true;
8100 else
8101 l_ok := false;
8102 end if;
8103 --
8104 close c_prtt_in_oipl ;
8105 --
8106 --
8107 if l_ok and l_inst_set(l_ele_num).excld_flag = 'N' then
8108 --
8109 hr_utility.set_location('Exclude Flag = N, Health Coverage in OIPL id = ' || l_inst_set(l_ele_num).num_val1 || ' found ', 20 );
8110 exit;
8111 --
8112 elsif l_ok and l_inst_set(l_ele_num).excld_flag = 'Y' then
8113 --
8114 hr_utility.set_location('Exclude Flag = Y, Health Coverage in OIPL id = ' || l_inst_set(l_ele_num).num_val1 || ' found ', 20 );
8115 l_ok := false;
8116 exit;
8117 --
8118 elsif (not l_ok) and l_inst_set(l_ele_num).excld_flag = 'Y' then
8119 --
8120 l_ok := true;
8121 --
8122 end if;
8123 --
8124 l_ele_num := l_ele_num+1;
8125 --
8126 end loop;
8127 --
8128 end if;
8129 --
8130 if l_rows_found
8131 and not l_ok
8132 then
8133 --
8134 g_inelg_rsn_cd := 'EHC';
8135 fnd_message.set_name('BEN','BEN_93085_HLTH_CVG_PRFL_FAIL');
8136 hr_utility.set_location('Criteria Failed: '||l_proc,40);
8137 raise g_criteria_failed;
8138 --
8139 end if;
8140 --
8141 hr_utility.set_location('Leaving: '||l_proc,50);
8142 --
8143 end check_hlth_cvg_elig;
8144 --
8145 -- ----------------------------------------------------------------------------
8146 -- Competency
8147 -- ----------------------------------------------------------------------------
8148 procedure check_comptncy_elig
8149 (p_eligy_prfl_id in number,
8150 p_business_group_id in number,
8151 p_person_id in number,
8152 p_competence_id in number default null,
8153 p_rating_level_id in number default null,
8154 p_score_compute_mode in boolean default false,
8155 p_profile_score_tab in out nocopy scoreTab,
8156 p_lf_evt_ocrd_dt in date,
8157 p_effective_date in date) is
8158 --
8159 l_proc varchar2(100):=g_package||'.check_comptncy_elig';
8160 --
8161 l_inst_set ben_elp_cache.g_elp_cache := ben_elp_cache.g_elp_cache();
8162 l_ok boolean := false;
8163 l_rows_found boolean := false;
8164 l_ele_num pls_integer;
8165 l_effective_date date;
8166 l_crit_passed boolean;
8167 l_score_tab scoreTab;
8168 --
8169 l_dummy char ;
8170 --
8171 cursor c_competency(cp_person_id in number,
8172 cp_competence_id in number,
8173 cp_rating_level_id in number,
8174 cp_effective_date in date ,
8175 cp_business_group_id in number) is
8176 select null
8177 from per_competence_elements cmp
8178 where cmp.person_id = cp_person_id
8179 and cmp.type = 'PERSONAL'
8180 and cmp.competence_id = cp_competence_id
8181 and cmp.proficiency_level_id = cp_rating_level_id
8182 and cmp.business_group_id = cp_business_group_id
8183 and cp_effective_date
8184 between nvl(cmp.effective_date_from, cp_effective_date)
8185 and nvl(cmp.effective_date_to, cp_effective_date) ;
8186 --
8187 begin
8188 --
8189 hr_utility.set_location('Entering: '||l_proc, 10);
8190 --
8191 ben_elp_cache.elpecy_getdets
8192 (p_effective_date => nvl(l_fonm_cvg_strt_dt,p_effective_date)
8193 ,p_eligy_prfl_id => p_eligy_prfl_id
8194 --
8195 ,p_inst_set => l_inst_set
8196 );
8197 --
8198 if l_inst_set.count > 0 then
8199 --
8200 l_ele_num := 1;
8201 --
8202 for i in l_inst_set.first .. l_inst_set.last loop
8203 --
8204 l_rows_found := true;
8205 --
8206 l_effective_date := nvl(l_fonm_cvg_strt_dt,nvl(p_lf_evt_ocrd_dt,p_effective_date));
8207 if p_competence_id is null then
8208 open c_competency(p_person_id,
8209 l_inst_set(l_ele_num).num_val,
8210 l_inst_set(l_ele_num).num_val1,
8211 l_effective_date ,
8212 p_business_group_id ) ;
8213 fetch c_competency into l_dummy ;
8214 --
8215 if c_competency%found then
8216 l_ok := true;
8217 else
8218 l_ok := false;
8219 end if;
8220 --
8221 close c_competency ;
8222 else
8223 if p_competence_id = l_inst_set(l_ele_num).num_val and
8224 p_rating_level_id = l_inst_set(l_ele_num).num_val1 then
8225 l_ok := true;
8226 else
8227 l_ok := false;
8228 end if;
8229 end if;
8230 --
8231 --
8232 if l_ok and l_inst_set(l_ele_num).excld_flag = 'N' then
8233 --
8234 hr_utility.set_location('Exclude Flag = N, Competence ' || l_inst_set(l_ele_num).num_val || ' and Rating level ' || l_inst_set(l_ele_num).num_val1 || ' found ', 20 );
8235 if p_score_compute_mode then
8236 if l_crit_passed is null then
8237 l_crit_passed := true;
8238 end if;
8239 write(l_score_tab,
8240 l_inst_set(l_ele_num).eligy_prfl_id,
8241 l_inst_set(l_ele_num).short_code,
8242 l_inst_set(l_ele_num).pk_id,
8243 nvl(l_inst_set(l_ele_num).criteria_score,
8244 l_inst_set(l_ele_num).criteria_weight));
8245 else
8246 exit;
8247 end if;
8248 --
8249 elsif l_ok and l_inst_set(l_ele_num).excld_flag = 'Y' then
8250 --
8251 hr_utility.set_location('Exclude Flag = Y, Competence ' || l_inst_set(l_ele_num).num_val || ' and Rating level ' || l_inst_set(l_ele_num).num_val1 || ' found ', 20 );
8252 l_ok := false;
8253 exit;
8254 --
8255 elsif (not l_ok) and l_inst_set(l_ele_num).excld_flag = 'Y' then
8256 --
8257 l_ok := true;
8258 --
8259 if p_score_compute_mode then
8260 write(l_score_tab,
8261 l_inst_set(l_ele_num).eligy_prfl_id,
8262 l_inst_set(l_ele_num).short_code,
8263 l_inst_set(l_ele_num).pk_id,
8264 nvl(l_inst_set(l_ele_num).criteria_score,
8265 l_inst_set(l_ele_num).criteria_weight));
8266 end if;
8267 end if;
8268 --
8269 l_ele_num := l_ele_num+1;
8270 --
8271 end loop;
8272 --
8273 end if;
8274 --
8275 if l_crit_passed is null
8276 then
8277 if l_rows_found
8278 and not l_ok
8279 then
8280 --
8281 g_inelg_rsn_cd := 'ECY';
8282 fnd_message.set_name('BEN','BEN_93086_COMPTNCY_PRFL_FAIL');
8283 hr_utility.set_location('Criteria Failed: '||l_proc,40);
8284 raise g_criteria_failed;
8285 --
8286 end if;
8287 end if;
8288 --
8289 if p_score_compute_mode
8290 then
8291 hr_utility.set_location('count '||l_score_tab.count,20);
8292 write(p_profile_score_tab,l_score_tab);
8293 end if;
8294 hr_utility.set_location('Leaving: '||l_proc,50);
8295 --
8296 end check_comptncy_elig;
8297 --
8298 -- ----------------------------------------------------------------------------
8299 -- Performance Rating
8300 -- ----------------------------------------------------------------------------
8301 procedure check_perf_rtng_elig
8302 (p_eligy_prfl_id in number,
8303 p_business_group_id in number,
8304 p_person_id in number,
8305 p_perf_rtng_cd in varchar2 default null,
8306 p_event_type in varchar2 default null,
8307 p_score_compute_mode in boolean default false,
8308 p_profile_score_tab in out nocopy scoreTab,
8309 p_lf_evt_ocrd_dt in date,
8310 p_effective_date in date) is
8311 --
8312
8313 l_proc varchar2(100):=g_package||'.check_perf_rtng_elig';
8314 --
8315 l_inst_set ben_elp_cache.g_elp_cache := ben_elp_cache.g_elp_cache();
8316 l_ok boolean := false;
8317 l_rows_found boolean := false;
8318 l_ele_num pls_integer;
8319 l_crit_passed boolean;
8320 l_score_tab scoreTab;
8321 --
8322 l_dummy varchar2(10) ;
8323 --
8324 l_performance_rating varchar2(80);
8325 --
8326 CURSOR c1 (
8327 p_person_id NUMBER,
8328 p_event_type VARCHAR2,
8329 p_business_group_id NUMBER,
8330 p_effective_date DATE
8331 )
8332 IS
8333 SELECT ppr.performance_rating
8334 FROM per_performance_reviews ppr,
8335 per_events pev,
8336 per_all_assignments_f asg
8337 WHERE pev.assignment_id = asg.assignment_id
8338 AND pev.TYPE = p_event_type
8339 AND pev.business_group_id = p_business_group_id
8340 AND p_effective_date BETWEEN NVL (pev.date_start,
8341 p_effective_date)
8342 AND NVL (pev.date_end, p_effective_date)
8343 AND ppr.event_id = pev.event_id
8344 -- AND ppr.performance_rating = p_performance_rating
8345 AND p_effective_date BETWEEN NVL (asg.effective_start_date,
8346 p_effective_date
8347 )
8348 AND NVL (asg.effective_end_date,
8349 p_effective_date
8350 )
8351 AND asg.business_group_id = p_business_group_id
8352 AND asg.primary_flag = 'Y'
8353 AND asg.person_id = ppr.person_id
8354 AND ppr.person_id = p_person_id
8355 ORDER BY pev.date_start desc, ppr.review_date desc;
8356 --
8357 /* Bug 4031314
8358 * If ELPRO criteria does not specify Performance Type then we would select
8359 * only those performance reviews which do have Performance (Interview) Type
8360 * as NULL i.e PPR.EVENT_ID IS NULL
8361 */
8362 CURSOR c2_without_events (
8363 p_person_id NUMBER,
8364 p_effective_date DATE
8365 )
8366 IS
8367 SELECT ppr.performance_rating
8368 FROM per_performance_reviews ppr
8369 WHERE ppr.person_id = p_person_id
8370 AND ppr.review_date <= p_effective_date
8371 AND ppr.event_id IS NULL
8372 ORDER BY ppr.review_date desc;
8373 --
8374 begin
8375 --
8376 hr_utility.set_location('Entering: '||l_proc, 10);
8377 --
8378 if p_perf_rtng_cd is null then
8379 ben_elp_cache.elpepr_getdets
8380 (p_effective_date => p_effective_date
8381 ,p_eligy_prfl_id => p_eligy_prfl_id
8382 --
8383 ,p_inst_set => l_inst_set
8384 );
8385 else
8386 l_inst_set(1).v230_val := p_perf_rtng_cd;
8387 if p_event_type is null then
8388 l_inst_set(1).v230_val1 := '-1';
8389 else
8390 l_inst_set(1).v230_val1 := p_event_type;
8391 end if;
8392 l_inst_set(1).excld_flag := 'N';
8393
8394 end if;
8395 --
8396 if l_inst_set.count > 0 then
8397 --
8398 l_ele_num := 1;
8399 --
8400 for i in l_inst_set.first .. l_inst_set.last loop
8401 --
8402 l_rows_found := true;
8403 --
8404 /* Bug 4031314
8405 * - When BEN_ELIG_PERF_RTNG_PRTE_F.EVENT_TYPE = '-1', then fetch performance reviews
8406 * that have Performance (Interview) Type as NULL.
8407 * - When BEN_ELIG_PERF_RTNG_PRTE_F.EVENT_TYPE is not '-1', then fetch performanc reviews
8408 * with Performance Type as defined in ELPRO criteria
8409 */
8410 if l_inst_set(l_ele_num).v230_val1 = '-1'
8411 then
8412 --
8413 if p_perf_rtng_cd is not null then
8414 if p_perf_rtng_cd =l_inst_set(l_ele_num).v230_val
8415 then
8416 --
8417 l_ok := true;
8418 --
8419 else
8420 --
8421 l_ok := false;
8422 --
8423 end if;
8424 --
8425 else
8426 open c2_without_events(
8427 p_person_id => p_person_id
8428 ,p_effective_date => nvl(p_lf_evt_ocrd_dt, p_effective_date)
8429 );
8430 --
8431 fetch c2_without_events into l_performance_rating;
8432 --
8433 if c2_without_events%found and l_performance_rating =l_inst_set(l_ele_num).v230_val
8434 then
8435 --
8436 l_ok := true;
8437 --
8438 else
8439 --
8440 l_ok := false;
8441 --
8442 end if;
8443 --
8444 close c2_without_events;
8445 end if;
8446 --
8447 else
8448 if p_perf_rtng_cd is not null then
8449 if p_perf_rtng_cd =l_inst_set(l_ele_num).v230_val and
8450 p_event_type = l_inst_set(l_ele_num).v230_val1
8451 then
8452 --
8453 l_ok := true;
8454 --
8455 else
8456 --
8457 l_ok := false;
8458 --
8459 end if;
8460 --
8461 else
8462 open c1(p_person_id => p_person_id
8463 ,p_event_type => l_inst_set(l_ele_num).v230_val1
8464 ,p_business_group_id => p_business_group_id
8465 ,p_effective_date => nvl(p_lf_evt_ocrd_dt, p_effective_date) );
8466 fetch c1 into l_performance_rating;
8467 --
8468 if c1%found and l_performance_rating = l_inst_set(l_ele_num).v230_val then
8469 l_ok := true;
8470 else
8471 l_ok := false;
8472 end if;
8473 --
8474 close c1 ;
8475 --
8476 end if;
8477 end if;
8478 --
8479 if l_ok and l_inst_set(l_ele_num).excld_flag = 'N' then
8480 --
8481 hr_utility.set_location('Exclude Flag = N, Performance Rating ' || l_inst_set(l_ele_num).num_val || ' and Rating level ' || l_inst_set(l_ele_num).num_val1 || ' found ', 20 );
8482 if p_score_compute_mode then
8483 if l_crit_passed is null then
8484 l_crit_passed := true;
8485 end if;
8486 write(l_score_tab,
8487 l_inst_set(l_ele_num).eligy_prfl_id,
8488 l_inst_set(l_ele_num).short_code,
8489 l_inst_set(l_ele_num).pk_id,
8490 nvl(l_inst_set(l_ele_num).criteria_score,
8491 l_inst_set(l_ele_num).criteria_weight));
8492 else
8493 exit;
8494 end if;
8495 --
8496 elsif l_ok and l_inst_set(l_ele_num).excld_flag = 'Y' then
8497 --
8498 hr_utility.set_location('Exclude Flag = Y, Performance Rating ' || l_inst_set(l_ele_num).num_val || ' and Rating level ' || l_inst_set(l_ele_num).num_val1 || ' found ', 20 );
8499 l_ok := false;
8500 exit;
8501 --
8502 elsif (not l_ok) and l_inst_set(l_ele_num).excld_flag = 'Y' then
8503 --
8504 l_ok := true;
8505 --
8506 if p_score_compute_mode then
8507 write(l_score_tab,
8508 l_inst_set(l_ele_num).eligy_prfl_id,
8509 l_inst_set(l_ele_num).short_code,
8510 l_inst_set(l_ele_num).pk_id,
8511 nvl(l_inst_set(l_ele_num).criteria_score,
8512 l_inst_set(l_ele_num).criteria_weight));
8513 end if;
8514 end if;
8515 --
8516 l_ele_num := l_ele_num+1;
8517 --
8518 end loop;
8519 --
8520 end if;
8521 --
8522 if l_crit_passed is null
8523 then
8524 if l_rows_found and not l_ok
8525 then
8526 --
8527 g_inelg_rsn_cd := 'ERG';
8528 fnd_message.set_name('BEN','BEN_93108_PERF_RTNG_PRFL_FAIL');
8529 hr_utility.set_location('Criteria Failed: '||l_proc,40);
8530 raise g_criteria_failed;
8531 --
8532 end if;
8533 end if;
8534 --
8535 if p_score_compute_mode
8536 then
8537 hr_utility.set_location('count '||l_score_tab.count,20);
8538 write(p_profile_score_tab,l_score_tab);
8539 end if;
8540 hr_utility.set_location('Leaving: '||l_proc,50);
8541 --
8542 end check_perf_rtng_elig;
8543 --
8544 -- --------------------------------------------------
8545 -- Quartile in Grade
8546 -- --------------------------------------------------
8547 procedure check_qua_in_gr_elig( p_eligy_prfl_id in number,
8548 p_business_group_id in number,
8549 p_person_id in number,
8550 p_grade_id in number,
8551 p_assignment_id in number,
8552 p_score_compute_mode in boolean default false,
8553 p_profile_score_tab in out nocopy scoreTab,
8554 p_effective_date date,
8555 p_lf_evt_ocrd_dt date,
8556 p_pay_basis_id number) is
8557 --
8558 l_proc varchar2(100) := g_package||' check_qua_in_gr_elig';
8559 l_inst_set ben_elp_cache.g_elp_cache := ben_elp_cache.g_elp_cache();
8560 l_ele_num pls_integer;
8561 --
8562 l_dummy varchar2(10) ;
8563 --
8564 l_ok boolean := false;
8565 l_rows_found boolean := false;
8566 l_max_val number;
8567 l_min_val number;
8568 l_max_qualifier number;
8569 l_min_qualifier number;
8570 l_in_quartile boolean;
8571 l_person_sal number := 0;
8572 l_crit_passed boolean;
8573 l_score_tab scoreTab;
8574 l_quar_grad VARCHAR2 (30); -- added for bug: 4558945
8575 --
8576 cursor c1(p_grade_id number
8577 ,p_business_group_id number
8578 ,p_lf_evt_ocrd_dt date
8579 ,p_pay_basis_id number) is
8580 select (maximum * grade_annualization_factor) maximum ,
8581 (minimum * grade_annualization_factor) minimum
8582 from pay_grade_rules_f pgr,
8583 per_pay_bases ppb -- 2594204
8584 where ppb.pay_basis_id = p_pay_basis_id
8585 and ppb.business_group_id = p_business_group_id
8586 and pgr.rate_id = ppb.rate_id
8587 and pgr.business_group_id = p_business_group_id
8588 and pgr.grade_or_spinal_point_id = p_grade_id
8589 and p_lf_evt_ocrd_dt between nvl(pgr.effective_start_date, p_lf_evt_ocrd_dt)
8590 and nvl(pgr.effective_end_date, p_lf_evt_ocrd_dt);
8591
8592 /*
8593 Bug 4031314 : We need
8594 (1) Pay Annualization Factor of Salary Basis
8595 (2) Person's Approved Pay Proposal
8596 Splitting the following cursor :
8597 cursor c2(p_assignment_id number
8598 ,p_business_group_id number
8599 ,p_lf_evt_ocrd_dt date
8600 ,p_pay_basis_id number) is
8601 select ppp.proposed_salary_n * ppb.pay_annualization_factor annual_salary
8602 from per_pay_bases ppb,
8603 per_pay_proposals ppp
8604 where ppb.pay_basis_id = p_pay_basis_id
8605 and ppb.business_group_id = p_business_group_id
8606 and ppp.assignment_id = p_assignment_id
8607 and ppp.change_date <= p_lf_evt_ocrd_dt
8608 order by ppp.change_date desc ;
8609 */
8610 cursor c_salary ( p_assignment_id number
8611 ,p_business_group_id number
8612 ,p_lf_evt_ocrd_dt date
8613 ) is
8614 select ppp.proposed_salary_n
8615 from per_pay_proposals ppp
8616 where ppp.assignment_id = p_assignment_id
8617 and ppp.business_group_id = p_business_group_id
8618 and ppp.approved = 'Y'
8619 and ppp.change_date <= p_lf_evt_ocrd_dt
8620 order by ppp.change_date desc;
8621 --
8622 cursor c_pay_bas_ann_fctr ( p_pay_basis_id number
8623 ,p_business_group_id number
8624 ) is
8625 select ppb.pay_annualization_factor
8626 from per_pay_bases ppb
8627 where ppb.pay_basis_id = p_pay_basis_id
8628 and ppb.business_group_id = ppb.business_group_id;
8629 --
8630 l_ann_fctr number := 0;
8631 l_ann_sal number := 0;
8632 -- Bug 4031314
8633 --
8634
8635 procedure get_quartile(p_min IN number default 0
8636 ,p_max IN number default 0
8637 ,p_code IN varchar2
8638 ,p_min_qualifier OUT NOCOPY number
8639 ,p_max_qualifier OUT NOCOPY number
8640 ) is
8641 l_divisor number := 4;
8642 l_addition_factor number;
8643 l_multiplication_factor number;
8644 begin
8645 if p_code not in ('ABV' , 'BLW' , 'NA' ) then
8646 l_multiplication_factor := to_number(p_code);
8647 l_addition_factor := (p_max - p_min)/l_divisor;
8648 p_min_qualifier := p_max - l_addition_factor * (l_multiplication_factor ) ;
8649 p_max_qualifier := p_max - l_addition_factor * (l_multiplication_factor - 1 ) ;
8650 --
8651 if l_multiplication_factor <> 4 then
8652 p_min_qualifier := p_min_qualifier + 1;
8653 end if;
8654 end if;
8655 end;
8656 --
8657 begin
8658 --
8659 hr_utility.set_location('Entering: '||l_proc, 10);
8660 --
8661 ben_elp_cache.elpeqg_getdets
8662 (p_effective_date => nvl(l_fonm_cvg_strt_dt,p_effective_date)
8663 ,p_eligy_prfl_id => p_eligy_prfl_id
8664 --
8665 ,p_inst_set => l_inst_set
8666 );
8667 --
8668 if l_inst_set.count > 0 then
8669 --
8670 l_ele_num := 1;
8671 --
8672 -- get min , max limits from grade scale
8673 --
8674 open c1(p_grade_id
8675 ,p_business_group_id
8676 ,nvl(l_fonm_cvg_strt_dt,nvl(p_lf_evt_ocrd_dt, p_effective_date))
8677 ,p_pay_basis_id);
8678 fetch c1 into l_max_val, l_min_val;
8679 close c1;
8680 --
8681 -- get persons salary by applying the annual factor
8682 --
8683 /* Bug 4031314
8684 open c2(p_assignment_id
8685 ,p_business_group_id
8686 ,nvl(l_fonm_cvg_strt_dt,nvl(p_lf_evt_ocrd_dt, p_effective_date))
8687 ,p_pay_basis_id) ;
8688 fetch c2 into l_person_sal;
8689 close c2;
8690 */
8691 open c_salary ( p_assignment_id => p_assignment_id,
8692 p_business_group_id => p_business_group_id,
8693 p_lf_evt_ocrd_dt => nvl( l_fonm_cvg_strt_dt,
8694 nvl(p_lf_evt_ocrd_dt, p_effective_date
8695 )
8696 )
8697 );
8698 fetch c_salary into l_person_sal;
8699 close c_salary;
8700 --
8701 open c_pay_bas_ann_fctr ( p_pay_basis_id => p_pay_basis_id,
8702 p_business_group_id => p_business_group_id );
8703 fetch c_pay_bas_ann_fctr into l_ann_fctr;
8704 close c_pay_bas_ann_fctr;
8705 --
8706 l_ann_sal := l_person_sal * l_ann_fctr;
8707 --
8708 -- added for bug: 4558945
8709 l_quar_grad :=
8710 ben_cwb_person_info_pkg.get_grd_quartile (p_salary => l_ann_sal,
8711 p_min => NVL
8712 (l_min_val,
8713 0
8714 ),
8715 p_max => NVL
8716 (l_max_val,
8717 0
8718 ),
8719 p_mid => ( NVL
8720 (l_min_val,
8721 0
8722 )
8723 + NVL
8724 (l_max_val,
8725 0
8726 )
8727 )
8728 / 2
8729 );
8730 for i in l_inst_set.first..l_inst_set.last loop
8731 l_rows_found := true;
8732 --
8733 -- commented for bug: 4558945
8734 /*
8735 get_quartile(p_min => nvl(l_min_val,0)
8736 ,p_max => nvl(l_max_val,0)
8737 ,p_code => l_inst_set(l_ele_num).v230_val
8738 ,p_min_qualifier => l_min_qualifier
8739 ,p_max_qualifier => l_max_qualifier );
8740 hr_utility.set_location('ACE l_min_qualifier = ' || l_min_qualifier, 9999);
8741 hr_utility.set_location('ACE l_max_qualifier = ' || l_max_qualifier, 9999);
8742
8743 --
8744 if l_inst_set(l_ele_num).v230_val = 'ABV' then
8745 l_in_quartile := l_ann_sal > nvl(l_max_val,0);
8746 elsif l_inst_set(l_ele_num).v230_val = 'BLW' then
8747 l_in_quartile := l_ann_sal < nvl(l_min_val,0);
8748 else
8749 l_in_quartile := l_ann_sal between l_min_qualifier and l_max_qualifier;
8750 end if;
8751 --
8752 */
8753 -- commented for bug: 4558945
8754 -- if l_inst_set(l_ele_num).excld_flag = 'N' and l_in_quartile then
8755 IF l_inst_set (l_ele_num).excld_flag = 'N' AND l_inst_set (l_ele_num).v230_val = l_quar_grad then
8756 l_ok := true;
8757 if p_score_compute_mode then
8758 if l_crit_passed is null then
8759 l_crit_passed := true;
8760 end if;
8761 write(l_score_tab,
8762 l_inst_set(l_ele_num).eligy_prfl_id,
8763 l_inst_set(l_ele_num).short_code,
8764 l_inst_set(l_ele_num).pk_id,
8765 nvl(l_inst_set(l_ele_num).criteria_score,
8766 l_inst_set(l_ele_num).criteria_weight));
8767 else
8768 exit;
8769 end if;
8770 -- commented for bug: 4558945
8771 -- elsif l_inst_set(l_ele_num).excld_flag = 'N' and not l_in_quartile then
8772 ELSIF l_inst_set (l_ele_num).excld_flag = 'N' AND l_inst_set (l_ele_num).v230_val <> l_quar_grad then
8773 l_ok := false;
8774 -- commented for bug: 4558945
8775 -- elsif l_inst_set(l_ele_num).excld_flag = 'Y' and not l_in_quartile then
8776 ELSIF l_inst_set (l_ele_num).excld_flag = 'Y' AND l_inst_set (l_ele_num).v230_val <> l_quar_grad then
8777 l_ok := true;
8778 if p_score_compute_mode then
8779 write(l_score_tab,
8780 l_inst_set(l_ele_num).eligy_prfl_id,
8781 l_inst_set(l_ele_num).short_code,
8782 l_inst_set(l_ele_num).pk_id,
8783 nvl(l_inst_set(l_ele_num).criteria_score,
8784 l_inst_set(l_ele_num).criteria_weight));
8785 end if;
8786 -- commented for bug: 4558945
8787 -- elsif l_inst_set(l_ele_num).excld_flag = 'Y' and l_in_quartile then
8788 ELSIF l_inst_set (l_ele_num).excld_flag = 'Y' AND l_inst_set (l_ele_num).v230_val = l_quar_grad THEN
8789 l_ok := false;
8790 exit;
8791 end if;
8792 --
8793 l_ele_num := l_ele_num+1;
8794 --
8795 end loop;
8796 --
8797 end if;
8798 --
8799 if l_crit_passed is null
8800 then
8801 if l_rows_found and not l_ok
8802 then
8803 --
8804 g_inelg_rsn_cd := 'EQG';
8805 fnd_message.set_name('BEN','BEN_93107_QUA_IN_GR_PRFL_FAIL');
8806 hr_utility.set_location('Criteria Failed: '||l_proc,40);
8807 raise g_criteria_failed;
8808 --
8809 end if;
8810 end if;
8811 --
8812 if p_score_compute_mode
8813 then
8814 hr_utility.set_location('count '||l_score_tab.count,20);
8815 write(p_profile_score_tab,l_score_tab);
8816 end if;
8817 hr_utility.set_location('Leaving: '||l_proc,50);
8818 --
8819 end check_qua_in_gr_elig;
8820 --
8821 -- Public Function
8822 --
8823 -- -----------------------------------------------------------------------------
8824 -- |-----------------------< eligible >-------------------------------|
8825 -- -----------------------------------------------------------------------------
8826 function eligible
8827 (p_person_id in number
8828 ,p_assignment_id in number default null
8829 ,p_business_group_id in number
8830 ,p_effective_date in date
8831 ,p_eligprof_tab in proftab default t_prof_tbl
8832 ,p_vrbl_rt_prfl_id in number default null
8833 ,p_lf_evt_ocrd_dt in date default null
8834 ,p_dpr_rec in ben_derive_part_and_rate_facts.g_cache_structure default l_dpr_rec
8835 ,p_per_in_ler_id in number default null
8836 ,p_ler_id in number default null
8837 ,p_pgm_id in number default null
8838 ,p_ptip_id in number default null
8839 ,p_plip_id in number default null
8840 ,p_pl_id in number default null
8841 ,p_oipl_id in number default null
8842 ,p_oiplip_id in number default null
8843 ,p_pl_typ_id in number default null
8844 ,p_opt_id in number default null
8845 ,p_par_pgm_id in number default null
8846 ,p_par_plip_id in number default null
8847 ,p_par_pl_id in number default null
8848 ,p_par_opt_id in number default null
8849 ,p_currepe_row in ben_determine_rates.g_curr_epe_rec default ben_determine_rates.g_def_curr_epe_rec
8850 ,p_asg_status in varchar2 default 'EMP'
8851 ,p_ttl_prtt in number default null
8852 ,p_ttl_cvg in number default null
8853 ,p_all_prfls in boolean default false
8854 ,p_eval_typ in varchar2 default 'E' -- V for Vapro
8855 ,p_comp_obj_mode in boolean default true
8856 ,p_score_tab out nocopy scoreTab
8857 ) return boolean is
8858
8859 --
8860 l_proc varchar2(100):= g_package||'eligible';
8861 --
8862 l_eligprof_dets ben_cep_cache.g_cobcep_odcache;
8863 l_tmpelp_dets ben_cep_cache.g_cobcep_odcache := ben_cep_cache.g_cobcep_odcache();
8864 --
8865 l_elptorrw_num binary_integer;
8866 l_inst_count number;
8867 l_elig_flag boolean := false;
8868 l_elig_per_id number;
8869 l_prtn_ovridn_thru_dt date;
8870 l_effective_date date;
8871 l_prtn_ovridn_flag ben_elig_per_f.prtn_ovridn_flag%type;
8872 l_rl_count number;
8873 l_match_one boolean := false;
8874 l_match_one_rl varchar2(15) := 'FALSE';
8875 l_outputs ff_exec.outputs_t;
8876 l_ok_so_far varchar2(1);
8877 l_mx_wtg_perd_prte_elig boolean := false;
8878 l_elig_apls_flag varchar2(30);
8879 l_dpnt_elig_flag varchar2(1) := 'Y';
8880 l_dependent_elig_flag varchar2(1) := 'Y';
8881 l_dpnt_inelig_rsn_cd ben_elig_dpnt.inelg_rsn_cd%type;
8882 l_per_in_ler_id ben_per_in_ler.per_in_ler_id%type;
8883 l_per_cvrd_cd ben_pl_f.per_cvrd_cd%type;
8884 l_elig_inelig_cd ben_elig_to_prte_rsn_f.elig_inelig_cd%type;
8885 l_dpnt_pl_id ben_pl_f.pl_id%type;
8886 l_exists varchar2(30);
8887 --
8888 l_terminated per_assignment_status_types.per_system_status%type ;
8889 l_assignment_id per_all_assignments_f.assignment_id%type;
8890 l_found_profile varchar2(1) := 'N';
8891 l_pl_rec ben_pl_f%rowtype;
8892 l_pl3_rec ben_pl_f%rowtype;
8893 l_ptip2_rec ben_ptip_f%rowtype;
8894 l_oipl_rec ben_oipl_f%rowtype;
8895 l_plip_rec ben_plip_f%rowtype;
8896 l_ptip_rec ben_ptip_f%rowtype;
8897 --
8898 l_inst_set ben_elig_rl_cache.g_elig_rl_inst_tbl;
8899 l_elig_rl_cnt number := 0;
8900 l_ctr_count number := 0;
8901 l_jurisdiction_code varchar2(30);
8902 --
8903 l_per_rec per_all_people_f%rowtype;
8904 l_ass_rec per_all_assignments_f%rowtype;
8905 l_ass_rec1 per_all_assignments_f%rowtype; -- Bug 6399423
8906 l_hsc_rec hr_soft_coding_keyflex%rowtype;
8907 l_org_rec hr_all_organization_units%rowtype;
8908 l_loop_count number;
8909 --
8910 l_empasg_row per_all_assignments_f%rowtype;
8911 l_benasg_row per_all_assignments_f%rowtype;
8912 l_pil_row ben_per_in_ler%rowtype;
8913 --
8914 l_cagrelig_cnt pls_integer;
8915 l_pl_typ_id number;
8916 l_typ_rec ben_person_object.g_cache_typ_table;
8917 l_appass_rec ben_person_object.g_cache_ass_table;
8918 l_comp_obj_tree_row ben_manage_life_events.g_cache_proc_objects_rec;
8919 l_comp_rec ben_derive_part_and_rate_facts.g_cache_structure;
8920 l_oiplip_rec ben_derive_part_and_rate_facts.g_cache_structure;
8921 --
8922 l_ff_use_asg_id_flag varchar2(1);
8923 l_vrfy_fmly_mmbr_cd varchar2(30);
8924 l_vrfy_fmly_mmbr_rl number;
8925 l_pl_id number;
8926 l_env ben_env_object.g_global_env_rec_type;
8927 --
8928 l_age_val number;
8929 l_los_val number;
8930 l_comb_age number;
8931 l_comb_los number;
8932 l_cmbn_age_n_los_val number;
8933 l_comp_ref_amt number;
8934 l_once_r_cntug_cd varchar2(30);
8935 l_pct_fl_tm_val number;
8936 l_hrs_wkd_val number;
8937 l_comp_elig_flag varchar2(1);
8938 l_asg_found boolean;
8939 --FONM
8940 -- l_fonm_cvg_strt_dt DATE ;
8941 --END FONM
8942 l_age_fctr_id number;
8943 l_comp_lvl_fctr_id number;
8944 l_cmbn_age_los_fctr_id number;
8945 l_los_fctr_id number;
8946 l_pct_fl_tm_fctr_id number;
8947 l_hrs_wkd_in_perd_fctr_id number;
8948 l_competence_id number;
8949 l_rating_level_id number;
8950 l_absence_attendance_type_id number;
8951 l_absence_attendance_reason_id number;
8952 l_quar_in_grade_cd varchar2(30);
8953 l_qualification_type_id number;
8954 l_title varchar2(255);
8955 l_event_type varchar2(255);
8956 l_perf_rtng_cd varchar2(255);
8957 l_leaving_reason varchar2(255);
8958 l_postal_code varchar2(255);
8959 l_crit_ovrrd_val_rec pqh_popl_criteria_ovrrd.g_crit_ovrrd_val_rec;
8960 l_crit_ovrrd_val_tab pqh_popl_criteria_ovrrd.g_crit_ovrrd_val_tbl;
8961 l_profile_score_tab scoreTab;
8962 l_prof_score_compute boolean := false;
8963
8964 cursor c_elgy_prfl(p_eligy_prfl_id number,
8965 c_effective_date date) is
8966 select null,
8967 p_pgm_id,
8968 p_ptip_id,
8969 p_plip_id,
8970 p_pl_id,
8971 p_oipl_id,
8972 null,
8973 null, -- prtn_elig_id
8974 null, -- mndtry_flag
8975 'N',
8976 'N',
8977 tab3.eligy_prfl_id,
8978 tab3.asmt_to_use_cd,
8979 tab3.elig_enrld_plip_flag,
8980 tab3.elig_cbr_quald_bnf_flag,
8981 tab3.elig_enrld_ptip_flag,
8982 tab3.elig_dpnt_cvrd_plip_flag,
8983 tab3.elig_dpnt_cvrd_ptip_flag,
8984 tab3.elig_dpnt_cvrd_pgm_flag,
8985 tab3.elig_job_flag,
8986 tab3.elig_hrly_slrd_flag,
8987 tab3.elig_pstl_cd_flag,
8988 tab3.elig_lbr_mmbr_flag,
8989 tab3.elig_lgl_enty_flag,
8990 tab3.elig_benfts_grp_flag,
8991 tab3.elig_wk_loc_flag,
8992 tab3.elig_brgng_unit_flag,
8993 tab3.elig_age_flag,
8994 tab3.elig_los_flag,
8995 tab3.elig_per_typ_flag,
8996 tab3.elig_fl_tm_pt_tm_flag,
8997 tab3.elig_ee_stat_flag,
8998 tab3.elig_grd_flag,
8999 tab3.elig_pct_fl_tm_flag,
9000 tab3.elig_asnt_set_flag,
9001 tab3.elig_hrs_wkd_flag,
9002 tab3.elig_comp_lvl_flag,
9003 tab3.elig_org_unit_flag,
9004 tab3.elig_loa_rsn_flag,
9005 tab3.elig_pyrl_flag,
9006 tab3.elig_schedd_hrs_flag,
9007 tab3.elig_py_bss_flag,
9008 tab3.eligy_prfl_rl_flag,
9009 tab3.elig_cmbn_age_los_flag,
9010 tab3.cntng_prtn_elig_prfl_flag,
9011 tab3.elig_prtt_pl_flag,
9012 tab3.elig_ppl_grp_flag,
9013 tab3.elig_svc_area_flag,
9014 tab3.elig_ptip_prte_flag,
9015 tab3.elig_no_othr_cvg_flag,
9016 tab3.elig_enrld_pl_flag,
9017 tab3.elig_enrld_oipl_flag,
9018 tab3.elig_enrld_pgm_flag,
9019 tab3.elig_dpnt_cvrd_pl_flag,
9020 tab3.elig_lvg_rsn_flag,
9021 tab3.elig_optd_mdcr_flag,
9022 tab3.elig_tbco_use_flag,
9023 tab3.elig_dpnt_othr_ptip_flag,
9024 tab3.ELIG_GNDR_FLAG,
9025 tab3.ELIG_MRTL_STS_FLAG,
9026 tab3.ELIG_DSBLTY_CTG_FLAG,
9027 tab3.ELIG_DSBLTY_RSN_FLAG,
9028 tab3.ELIG_DSBLTY_DGR_FLAG,
9029 tab3.ELIG_SUPPL_ROLE_FLAG,
9030 tab3.ELIG_QUAL_TITL_FLAG,
9031 tab3.ELIG_PSTN_FLAG,
9032 tab3.ELIG_PRBTN_PERD_FLAG,
9033 tab3.ELIG_SP_CLNG_PRG_PT_FLAG,
9034 tab3.BNFT_CAGR_PRTN_CD,
9035 tab3.ELIG_DSBLD_FLAG,
9036 tab3.ELIG_TTL_CVG_VOL_FLAG,
9037 tab3.ELIG_TTL_PRTT_FLAG,
9038 tab3.ELIG_COMPTNCY_FLAG,
9039 tab3.ELIG_HLTH_CVG_FLAG,
9040 tab3.ELIG_ANTHR_PL_FLAG,
9041 tab3.elig_qua_in_gr_flag,
9042 tab3.elig_perf_rtng_flag,
9043 tab3.elig_crit_values_flag
9044 from ben_eligy_prfl_f tab3
9045 where tab3.eligy_prfl_id = p_eligy_prfl_id
9046 and tab3.stat_cd = 'A'
9047 and c_effective_date between tab3.effective_start_date
9048 and tab3.effective_end_date;
9049
9050 cursor c_ptip_pl_typ(c_effective_date date) is
9051 select pl_typ_id
9052 from ben_ptip_f
9053 where ptip_id = p_ptip_id
9054 and c_effective_date
9055 between effective_start_date
9056 and effective_end_date;
9057 --
9058 cursor c_plip_pl_typ(c_effective_date date) is
9059 select pln.pl_typ_id
9060 from ben_plip_f plip,
9061 ben_pl_f pln
9062 where plip_id = p_plip_id
9063 and c_effective_date
9064 between plip.effective_start_date and plip.effective_end_date
9065 and pln.pl_id = plip.pl_id
9066 and c_effective_date
9067 between pln.effective_start_date and pln.effective_end_date ;
9068 --
9069 cursor c_oipl_pl_typ(c_effective_date date) is
9070 select pln.pl_typ_id
9071 from ben_oipl_f oipl,
9072 ben_pl_f pln
9073 where oipl_id = p_oipl_id
9074 and c_effective_date
9075 between oipl.effective_start_date and oipl.effective_end_date
9076 and pln.pl_id = oipl.pl_id
9077 and c_effective_date
9078 between pln.effective_start_date and pln.effective_end_date ;
9079 --
9080 cursor c_ff_use_asg(cv_formula_id in number) is
9081 select 'Y'
9082 from ff_fdi_usages_f
9083 where FORMULA_ID = cv_formula_id
9084 and ITEM_NAME = 'ASSIGNMENT_ID'
9085 and usage = 'U';
9086 -- 4958846
9087 l_env_rec ben_env_object.g_global_env_rec_type;
9088 l_benmngle_parm_rec benutils.g_batch_param_rec;
9089 -- Procedure to assign overridden values
9090 --
9091 procedure assign_overriden_values
9092 (p_per_rec in out nocopy per_all_people_f%rowtype,
9093 p_asg_rec in out nocopy per_all_assignments_f%rowtype)
9094 is
9095
9096 cursor check_gen_criteria(p_short_code varchar2) is
9097 select 'x'
9098 from ben_eligy_criteria
9099 where short_code = p_short_code;
9100
9101 l_dummy varchar2(1);
9102 l_proc varchar2(30) := 'assign_overriden_values';
9103
9104 begin
9105
9106 hr_utility.set_location('Entering :'||l_proc,10);
9107
9108 if not (pqh_popl_criteria_ovrrd.g_criteria_count>0) then
9109 hr_utility.set_location('No overridden values',10);
9110 hr_utility.set_location('Leaving :'||l_proc,10);
9111 return;
9112 end if;
9113
9114 hr_utility.set_location('Overridden count '||pqh_popl_criteria_ovrrd.g_criteria_override_val.count,10);
9115
9116 for i in 1..pqh_popl_criteria_ovrrd.g_criteria_override_val.count
9117 loop
9118 l_crit_ovrrd_val_rec := pqh_popl_criteria_ovrrd.g_criteria_override_val(i);
9119 hr_utility.set_location('Short code '||l_crit_ovrrd_val_rec.criteria_short_code,10);
9120 if l_crit_ovrrd_val_rec.criteria_short_code is null then
9121 exit;
9122 end if;
9123
9124 if l_crit_ovrrd_val_rec.criteria_short_code = 'EAN' then
9125 -- p_asg_rec.assignment_set_id := l_crit_ovrrd_val_rec.number_value1;
9126 null;
9127 elsif l_crit_ovrrd_val_rec.criteria_short_code = 'EES' then
9128 p_asg_rec.assignment_status_type_id := l_crit_ovrrd_val_rec.number_value1;
9129 elsif l_crit_ovrrd_val_rec.criteria_short_code = 'EAP' then
9130 l_age_fctr_id := l_crit_ovrrd_val_rec.number_value1;
9131 elsif l_crit_ovrrd_val_rec.criteria_short_code = 'EBN' then
9132 p_per_rec.benefit_group_id := l_crit_ovrrd_val_rec.number_value1;
9133 elsif l_crit_ovrrd_val_rec.criteria_short_code = 'EBU' then
9134 p_asg_rec.bargaining_unit_code := l_crit_ovrrd_val_rec.char_value1;
9135 elsif l_crit_ovrrd_val_rec.criteria_short_code = 'ECL' then
9136 l_comp_lvl_fctr_id := l_crit_ovrrd_val_rec.number_value1;
9137 elsif l_crit_ovrrd_val_rec.criteria_short_code = 'ECP' then
9138 l_cmbn_age_los_fctr_id := l_crit_ovrrd_val_rec.number_value1;
9139 elsif l_crit_ovrrd_val_rec.criteria_short_code = 'ECY' then
9140 l_competence_id := l_crit_ovrrd_val_rec.number_value1;
9141 l_rating_level_id := l_crit_ovrrd_val_rec.number_value2;
9142 elsif l_crit_ovrrd_val_rec.criteria_short_code = 'EDB' then
9143 p_per_rec.registered_disabled_flag := l_crit_ovrrd_val_rec.char_value1;
9144 elsif l_crit_ovrrd_val_rec.criteria_short_code = 'EFP' then
9145 p_asg_rec.employment_category := l_crit_ovrrd_val_rec.char_value1;
9146 elsif l_crit_ovrrd_val_rec.criteria_short_code = 'EPF' then
9147 l_pct_fl_tm_fctr_id := l_crit_ovrrd_val_rec.number_value1;
9148 elsif l_crit_ovrrd_val_rec.criteria_short_code = 'EGN' then
9149 p_per_rec.sex := l_crit_ovrrd_val_rec.char_value1;
9150 elsif l_crit_ovrrd_val_rec.criteria_short_code = 'EGR' then
9151 p_asg_rec.grade_id := l_crit_ovrrd_val_rec.number_value1;
9152 elsif l_crit_ovrrd_val_rec.criteria_short_code = 'EHS' then
9153 p_asg_rec.hourly_salaried_code := l_crit_ovrrd_val_rec.char_value1;
9154 elsif l_crit_ovrrd_val_rec.criteria_short_code = 'EHW' then
9155 l_hrs_wkd_in_perd_fctr_id := l_crit_ovrrd_val_rec.number_value1;
9156 elsif l_crit_ovrrd_val_rec.criteria_short_code = 'EJP' then
9157 p_asg_rec.job_id := l_crit_ovrrd_val_rec.number_value1;
9158 elsif l_crit_ovrrd_val_rec.criteria_short_code = 'ELN' then
9159 p_asg_rec.organization_id := l_crit_ovrrd_val_rec.number_value1;
9160 elsif l_crit_ovrrd_val_rec.criteria_short_code = 'ELR' then
9161 l_absence_attendance_type_id := l_crit_ovrrd_val_rec.number_value1;
9162 l_absence_attendance_reason_id := l_crit_ovrrd_val_rec.number_value2;
9163 elsif l_crit_ovrrd_val_rec.criteria_short_code = 'ELS' then
9164 l_los_fctr_id := l_crit_ovrrd_val_rec.number_value1;
9165 elsif l_crit_ovrrd_val_rec.criteria_short_code = 'ELU' then
9166 p_asg_rec.labour_union_member_flag := l_crit_ovrrd_val_rec.char_value1;
9167 elsif l_crit_ovrrd_val_rec.criteria_short_code = 'ELV' then
9168 l_leaving_reason := l_crit_ovrrd_val_rec.char_value1;
9169 elsif l_crit_ovrrd_val_rec.criteria_short_code = 'EOM' then
9170 p_per_rec.per_information10 := l_crit_ovrrd_val_rec.char_value1;
9171 elsif l_crit_ovrrd_val_rec.criteria_short_code = 'EOU' then
9172 p_asg_rec.organization_id := l_crit_ovrrd_val_rec.number_value1;
9173 elsif l_crit_ovrrd_val_rec.criteria_short_code = 'EPB' then
9174 p_asg_rec.pay_basis_id := l_crit_ovrrd_val_rec.number_value1;
9175 elsif l_crit_ovrrd_val_rec.criteria_short_code = 'EPG' then
9176 p_asg_rec.people_group_id := l_crit_ovrrd_val_rec.number_value1;
9177 elsif l_crit_ovrrd_val_rec.criteria_short_code = 'EPS' then
9178 p_asg_rec.position_id := l_crit_ovrrd_val_rec.number_value1;
9179 elsif l_crit_ovrrd_val_rec.criteria_short_code = 'EPT' then
9180 p_per_rec.person_type_id := l_crit_ovrrd_val_rec.number_value1;
9181 elsif l_crit_ovrrd_val_rec.criteria_short_code = 'EPY' then
9182 p_asg_rec.payroll_id := l_crit_ovrrd_val_rec.number_value1;
9183 elsif l_crit_ovrrd_val_rec.criteria_short_code = 'EPZ' then
9184 l_postal_code := l_crit_ovrrd_val_rec.char_value1;
9185 elsif l_crit_ovrrd_val_rec.criteria_short_code = 'EQG' then
9186 l_quar_in_grade_cd := l_crit_ovrrd_val_rec.char_value1;
9187 elsif l_crit_ovrrd_val_rec.criteria_short_code = 'EQT' then
9188 l_qualification_type_id := l_crit_ovrrd_val_rec.number_value1;
9189 l_title := l_crit_ovrrd_val_rec.char_value1;
9190 elsif l_crit_ovrrd_val_rec.criteria_short_code = 'ERG' then
9191 l_event_type := l_crit_ovrrd_val_rec.char_value1;
9192 l_perf_rtng_cd := l_crit_ovrrd_val_rec.char_value2;
9193 elsif l_crit_ovrrd_val_rec.criteria_short_code = 'ESA' then
9194 l_postal_code := l_crit_ovrrd_val_rec.char_value1;
9195 elsif l_crit_ovrrd_val_rec.criteria_short_code = 'ESH' then
9196 null;
9197 elsif l_crit_ovrrd_val_rec.criteria_short_code = 'ETU' then
9198 p_per_rec.uses_tobacco_flag := l_crit_ovrrd_val_rec.char_value1;
9199 elsif l_crit_ovrrd_val_rec.criteria_short_code = 'EWL' then
9200 p_asg_rec.location_id := l_crit_ovrrd_val_rec.number_value1;
9201 else
9202 open check_gen_criteria(l_crit_ovrrd_val_rec.criteria_short_code);
9203 fetch check_gen_criteria into l_dummy;
9204 if check_gen_criteria%found then
9205 l_crit_ovrrd_val_tab(l_crit_ovrrd_val_tab.count+1) := l_crit_ovrrd_val_rec;
9206 else
9207 hr_utility.set_location('Unknown criteria '||l_crit_ovrrd_val_rec.criteria_short_code,10);
9208 end if;
9209 close check_gen_criteria;
9210
9211 end if;
9212
9213 end loop;
9214
9215 hr_utility.set_location('Leaving :'||l_proc,10);
9216
9217 end assign_overriden_values;
9218
9219 begin
9220 --
9221 hr_utility.set_location('Entering :'||l_proc,10);
9222 --
9223 -- intialize the global
9224 --
9225 l_fonm_cvg_strt_dt := null ;
9226 if ben_manage_life_events.fonm = 'Y'
9227 and ben_manage_life_events.g_fonm_cvg_strt_dt is not null then
9228 --
9229 if p_eval_typ = 'E' then
9230 --
9231 l_fonm_cvg_strt_dt := nvl(ben_manage_life_events.g_fonm_cvg_strt_dt,nvl(p_lf_evt_ocrd_dt,p_effective_date));
9232 --
9233 else
9234 --
9235 l_fonm_cvg_strt_dt :=nvl(ben_manage_life_events.g_fonm_rt_strt_dt,
9236 nvl(ben_manage_life_events.g_fonm_cvg_strt_dt,
9237 nvl(p_lf_evt_ocrd_dt, p_effective_date)));
9238 --
9239 end if;
9240 --
9241 end if;
9242 hr_utility.set_location('l_fonm_cvg_strt_dt :'||l_fonm_cvg_strt_dt,10);
9243 l_effective_date := nvl(p_lf_evt_ocrd_dt,p_effective_date);
9244 -- Start of Bug 3520054
9245 if p_plip_id is not null then
9246 --
9247 hr_utility.set_location('PLIP_ID '||p_plip_id,11);
9248 --
9249 ben_comp_object.get_object(p_plip_id => p_plip_id
9250 ,p_rec => l_plip_rec);
9251 --
9252 elsif p_ptip_id is not null then
9253 --
9254 hr_utility.set_location('PTIP_ID '||p_ptip_id,12);
9255 --
9256 ben_comp_object.get_object(p_ptip_id => p_ptip_id
9257 ,p_rec => l_ptip_rec);
9258 --
9259 -- End of Bug 3520054
9260 elsif p_pl_id is not null then
9261 --
9262 hr_utility.set_location('PL_ID '||p_pl_id,14);
9263 --
9264 ben_comp_object.get_object(p_pl_id => p_pl_id
9265 ,p_rec => l_pl_rec);
9266 --
9267 elsif p_oipl_id is not null then
9268 --
9269 hr_utility.set_location('OIPL_ID '||p_oipl_id,16);
9270 --
9271 ben_comp_object.get_object(p_oipl_id => p_oipl_id
9272 ,p_rec => l_oipl_rec);
9273
9274 end if;
9275
9276 if p_eval_typ = 'E' and
9277 p_comp_obj_mode then
9278
9279 l_age_val := p_dpr_rec.age_val;
9280 l_los_val := p_dpr_rec.los_val;
9281 l_comb_age := p_dpr_rec.comb_age;
9282 l_comb_los := p_dpr_rec.comb_los;
9283 l_cmbn_age_n_los_val := p_dpr_rec.cmbn_age_n_los_val;
9284 l_comp_ref_amt := p_dpr_rec.comp_ref_amt;
9285 l_once_r_cntug_cd := p_dpr_rec.once_r_cntug_cd;
9286 l_pct_fl_tm_val := p_dpr_rec.pct_fl_tm_val;
9287 l_hrs_wkd_val := p_dpr_rec.hrs_wkd_val;
9288 l_comp_elig_flag := p_dpr_rec.elig_flag;
9289
9290 end if;
9291
9292 if nvl(p_eligprof_tab.count,0) = 0 then
9293
9294 if p_vrbl_rt_prfl_id is null then
9295
9296 ben_cep_cache.cobcep_odgetdets
9297 (p_effective_date => nvl(l_fonm_cvg_strt_dt,l_effective_date)
9298 ,p_pgm_id => p_pgm_id
9299 ,p_pl_id => p_pl_id
9300 ,p_oipl_id => p_oipl_id
9301 ,p_plip_id => p_plip_id
9302 ,p_ptip_id => p_ptip_id
9303 ,p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
9304 ,p_inst_set => l_eligprof_dets
9305 );
9306 else
9307
9308 ben_cep_cache.cobcep_odgetdets
9309 (p_effective_date => nvl(l_fonm_cvg_strt_dt,l_effective_date)
9310 ,p_pgm_id => null
9311 ,p_pl_id => null
9312 ,p_oipl_id => null
9313 ,p_plip_id => null
9314 ,p_ptip_id => null
9315 ,p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
9316 ,p_inst_set => l_eligprof_dets
9317 );
9318 end if;
9319
9320 else
9321
9322 l_eligprof_dets := ben_cep_cache.g_cobcep_odcache();
9323 l_eligprof_dets.extend(p_eligprof_tab.count);
9324 for i in 1..p_eligprof_tab.count
9325 loop
9326
9327 hr_utility.set_location('prfl count'||p_eligprof_tab.count,99);
9328 hr_utility.set_location('prfl id'||p_eligprof_tab(i).eligy_prfl_id,99);
9329 open c_elgy_prfl(p_eligprof_tab(i).eligy_prfl_id,
9330 nvl(l_fonm_cvg_strt_dt,l_effective_date));
9331 fetch c_elgy_prfl into l_eligprof_dets(i);
9332 close c_elgy_prfl;
9333 l_eligprof_dets(i).mndtry_flag := nvl(p_eligprof_tab(i).mndtry_flag,'N');
9334 l_eligprof_dets(i).compute_score_flag := nvl(p_eligprof_tab(i).compute_score_flag,'N');
9335 l_eligprof_dets(i).trk_scr_for_inelg_flag := nvl(p_eligprof_tab(i).trk_scr_for_inelg_flag,'N');
9336
9337 end loop;
9338
9339 end if;
9340
9341 hr_utility.set_location(l_proc||' After Cache call ',46);
9342 --
9343 -- Filter out non CAGR profiles in collective agreement mode
9344 --
9345 -- Get the environment details
9346 --
9347 ben_env_object.get(p_rec => l_env);
9348 --
9349 if l_env.mode_cd = 'A'
9350 and l_eligprof_dets.count > 0 then
9351 --
9352 l_cagrelig_cnt := 1; -- varray index start from 1 bug 2431869
9353 l_tmpelp_dets.delete;
9354 --
9355 for elenum in l_eligprof_dets.first..l_eligprof_dets.last
9356 loop
9357 --
9358 if nvl(l_eligprof_dets(elenum).BNFT_CAGR_PRTN_CD,'ZZZZ') = 'CAGR'
9359 then
9360 --
9361 l_tmpelp_dets.extend(1);
9362 l_tmpelp_dets(l_cagrelig_cnt) := l_eligprof_dets(elenum);
9363 l_cagrelig_cnt := l_cagrelig_cnt+1;
9364 --
9365 end if;
9366 --
9367 end loop;
9368 --
9369 if l_cagrelig_cnt = 1 then
9370 --
9371 g_inelg_rsn_cd := 'NOCAGRELP';
9372 fnd_message.set_name('BEN','BEN_92844_NOCAGRELP_NOT_ELIG');
9373 return false;
9374 --
9375 end if;
9376 hr_utility.set_location('l_cagrelig_cnt = '|| l_cagrelig_cnt,1687);
9377 --
9378 l_eligprof_dets.delete;
9379 l_eligprof_dets := l_tmpelp_dets;
9380 --
9381 end if;
9382 --
9383 -- Bug 4454878
9384 -- Reset g_per_eligible to TRUE
9385 --
9386 g_per_eligible := true;
9387 --
9388 -- Check if any eligibility profiles exist
9389 --
9390 if l_eligprof_dets.count > 0 then
9391 --
9392 if p_person_id is not null then
9393 ben_person_object.get_object(p_person_id => p_person_id,
9394 p_rec => l_typ_rec);
9395 --
9396 ben_person_object.get_object(p_person_id => p_person_id,
9397 p_rec => l_per_rec);
9398 --
9399 -- if the person cache is not in the date range, clear the cahce
9400 --
9401 if not nvl(l_fonm_cvg_strt_dt,l_effective_date)
9402 between l_per_rec.effective_start_date and l_per_rec.effective_end_date then
9403
9404 hr_utility.set_location('clearing cache'||nvl(l_fonm_cvg_strt_dt,l_effective_date) ,10);
9405 hr_utility.set_location('cache start'||l_per_rec.effective_start_date ,10);
9406 hr_utility.set_location('cache end'||l_per_rec.effective_end_date ,10);
9407
9408 ben_use_cvg_rt_date.fonm_clear_down_cache;
9409 --
9410 ben_person_object.get_object(p_person_id => p_person_id,
9411 p_rec => l_typ_rec);
9412 --
9413 ben_person_object.get_object(p_person_id => p_person_id,
9414 p_rec => l_per_rec);
9415
9416 hr_utility.set_location('nw cache start'||l_per_rec.effective_start_date ,10);
9417 hr_utility.set_location('nw cache end'||l_per_rec.effective_end_date ,10);
9418 else
9419
9420 -- Bug 6399423
9421 /* ben_person_object.get_object(p_person_id => p_person_id,
9422 p_rec => l_ass_rec);
9423 */
9424
9425 ben_person_object.get_object(p_person_id => p_person_id,
9426 p_rec => l_ass_rec1);
9427 -- Bug 6399423
9428
9429 hr_utility.set_location('cache asg start'||l_ass_rec1.effective_start_date ,10);
9430 hr_utility.set_location('cache asg end'||l_ass_rec1.effective_end_date ,10);
9431
9432 if not nvl(l_fonm_cvg_strt_dt,l_effective_date)
9433 between l_ass_rec1.effective_start_date and l_ass_rec1.effective_end_date then
9434
9435 hr_utility.set_location('clearing asg cache'||nvl(l_fonm_cvg_strt_dt,l_effective_date) ,10);
9436 ben_use_cvg_rt_date.fonm_clear_down_cache;
9437
9438 end if ;
9439 end if ;
9440 end if ;
9441 --
9442 -- First determine if score is to be computed for any profile
9443 --
9444 g_score_compute_mode := false;
9445 for l_elptorrw_num in l_eligprof_dets.first..l_eligprof_dets.last loop
9446 g_trk_scr_for_inelg_flag := (l_eligprof_dets(l_elptorrw_num).trk_scr_for_inelg_flag = 'Y');
9447 if l_eligprof_dets(l_elptorrw_num).compute_score_flag = 'Y' then
9448 g_score_compute_mode := true;
9449 exit;
9450 end if;
9451 end loop;
9452 --
9453 if g_score_compute_mode then
9454 hr_utility.set_location('in score compute mode',10);
9455 end if;
9456 if g_trk_scr_for_inelg_flag then
9457 hr_utility.set_location('track score for inelig flag on',10);
9458 end if;
9459
9460 g_per_eligible := null;
9461 --
9462 for l_elptorrw_num in l_eligprof_dets.first..l_eligprof_dets.last loop
9463 --
9464 l_found_profile := 'Y';
9465 --
9466 -- if eligibility profiles do exists for program, plan or option:
9467 --
9468 hr_utility.set_location('ELigibility Profile ID = '||l_eligprof_dets(l_elptorrw_num).eligy_prfl_id,10);
9469 hr_utility.set_location('Number of profiles = '||l_eligprof_dets.count,10);
9470 begin
9471 if g_score_compute_mode then
9472 if g_per_eligible is not null then --per already found elig/inelig
9473 if nvl(l_eligprof_dets(l_elptorrw_num).compute_score_flag,'N')='N' then
9474 hr_utility.set_location('skipping prof '||
9475 l_eligprof_dets(l_elptorrw_num).eligy_prfl_id,45);
9476 raise g_skip_profile;
9477 end if;
9478 end if;
9479 end if;
9480 --
9481 l_profile_score_tab.delete;
9482 l_prof_score_compute := (l_eligprof_dets(l_elptorrw_num).compute_score_flag = 'Y');
9483 hr_utility.set_location(l_proc||' St ELP loop ',46);
9484 --
9485 g_inelg_rsn_cd := null;
9486 --
9487 if l_eligprof_dets(l_elptorrw_num).elig_per_typ_flag = 'Y' then
9488 check_per_typ_elig
9489 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
9490 eligy_prfl_id,
9491 p_business_group_id => p_business_group_id,
9492 p_score_compute_mode=> l_prof_score_compute,
9493 p_profile_score_tab => l_profile_score_tab,
9494 p_effective_date => nvl(l_fonm_cvg_strt_dt,l_effective_date),
9495 p_per_per_typ => l_typ_rec);
9496 end if;
9497 --
9498 -- Now we check these profiles using the required assignment type
9499 --
9500 l_loop_count := 1;
9501 --
9502 if p_person_id is not null then
9503 if l_eligprof_dets(l_elptorrw_num).asmt_to_use_cd = 'EAO' then
9504 --
9505 -- Employee assignment only
9506 --
9507 ben_person_object.get_object(p_person_id => p_person_id,
9508 p_rec => l_ass_rec);
9509 --
9510 elsif l_eligprof_dets(l_elptorrw_num).asmt_to_use_cd = 'BAO' then
9511 --
9512 -- Benefit assignment only
9513 --
9514 ben_person_object.get_benass_object(p_person_id => p_person_id,
9515 p_rec => l_ass_rec);
9516 --
9517 elsif l_eligprof_dets(l_elptorrw_num).asmt_to_use_cd = 'AAO' then
9518 --
9519 -- Applicant assignment only
9520 --
9521 -- Bug 6509099
9522 ben_env_object.get(p_rec => l_env_rec);
9523 benutils.get_batch_parameters(p_benefit_action_id => l_env_rec.benefit_action_id
9524 ,p_rec => l_benmngle_parm_rec);
9525
9526 if l_benmngle_parm_rec.mode_cd = 'I' then
9527 --
9528 l_appass_rec.delete;
9529 l_appass_rec(1) := ben_manage_life_events.g_irec_ass_rec ;
9530 else
9531 --
9532 ben_person_object.get_object(p_person_id => p_person_id,
9533 p_rec => l_appass_rec);
9534 --
9535 end if;
9536 --
9537 -- Bug 6509099
9538 --
9539 if not l_appass_rec.exists(1) then
9540 --
9541 -- Initialize first record so that one time test works
9542 --
9543 l_appass_rec(1).person_id := p_person_id;
9544 --
9545 end if;
9546 --
9547 l_ass_rec := l_appass_rec(1);
9548 l_loop_count := l_appass_rec.count;
9549 --
9550 elsif l_eligprof_dets(l_elptorrw_num).asmt_to_use_cd = 'ANY' then
9551 --
9552 -- First assignment only
9553 --
9554 hr_utility.set_location('Getting all assignments',10);
9555 -- 4958846 ssarkar for irec
9556 ben_env_object.get(p_rec => l_env_rec);
9557 benutils.get_batch_parameters(p_benefit_action_id => l_env_rec.benefit_action_id
9558 ,p_rec => l_benmngle_parm_rec);
9559
9560 hr_utility.set_location('l_benmngle_parm_rec.mode_cd :' || l_benmngle_parm_rec.mode_cd,99);
9561
9562 if l_benmngle_parm_rec.mode_cd = 'I' then
9563
9564
9565 l_appass_rec.delete;
9566
9567 l_appass_rec(1) := ben_manage_life_events.g_irec_ass_rec ;
9568
9569 hr_utility.set_location(' p_assignment_id :' || l_appass_rec(1).assignment_id,99);
9570 hr_utility.set_location(' location_id :' || l_appass_rec(1).location_id,99);
9571 hr_utility.set_location(' p_effective_date :' || p_effective_date,99);
9572
9573
9574 else
9575 ben_person_object.get_allass_object(p_person_id => p_person_id,
9576 p_rec => l_appass_rec);
9577 end if; -- 4958846 :irec
9578 --
9579 if not l_appass_rec.exists(1) then
9580 --
9581 -- Initialize first record so that one time test works
9582 --
9583 l_appass_rec(1).person_id := p_person_id;
9584 --
9585 hr_utility.set_location('NO RECS',10);
9586 --
9587 end if;
9588 --
9589 l_loop_count := l_appass_rec.count;
9590 --
9591 l_ass_rec := l_appass_rec(1);
9592 hr_utility.set_location('NUMRECS'||l_appass_rec.count,10);
9593 hr_utility.set_location('GRADE'||l_appass_rec(1).grade_id,10);
9594 elsif l_eligprof_dets(l_elptorrw_num).asmt_to_use_cd = 'ETB' then
9595 --
9596 -- Employee then Benefits assignment only
9597 --
9598 ben_person_object.get_object(p_person_id => p_person_id,
9599 p_rec => l_ass_rec);
9600 --
9601 if l_ass_rec.assignment_id is null then
9602 --
9603 -- Get Benefits Assignment
9604 --
9605 ben_person_object.get_benass_object(p_person_id => p_person_id,
9606 p_rec => l_ass_rec);
9607 --
9608 end if;
9609 --
9610 elsif l_eligprof_dets(l_elptorrw_num).asmt_to_use_cd = 'BTE' then
9611 --
9612 -- Benefits then Employee assignment only
9613 --
9614 ben_person_object.get_benass_object(p_person_id => p_person_id,
9615 p_rec => l_ass_rec);
9616 --
9617 if l_ass_rec.assignment_id is null then
9618 --
9619 -- Get Employee Assignment
9620 --
9621 ben_person_object.get_object(p_person_id => p_person_id,
9622 p_rec => l_ass_rec);
9623 --
9624 end if;
9625 --
9626 elsif l_eligprof_dets(l_elptorrw_num).asmt_to_use_cd = 'EBA' then
9627 --
9628 -- Employee then Benefits then Applicant assignment only
9629 --
9630 ben_person_object.get_object(p_person_id => p_person_id,
9631 p_rec => l_ass_rec);
9632 --
9633 if l_ass_rec.assignment_id is null then
9634 --
9635 -- Get Benefits Assignment
9636 --
9637 ben_person_object.get_benass_object(p_person_id => p_person_id,
9638 p_rec => l_ass_rec);
9639 --
9640 if l_ass_rec.assignment_id is null then
9641 --
9642 -- Applicant assignment only
9643 --
9644 -- Bug 6509099
9645 ben_env_object.get(p_rec => l_env_rec);
9646 benutils.get_batch_parameters(p_benefit_action_id => l_env_rec.benefit_action_id
9647 ,p_rec => l_benmngle_parm_rec);
9648
9649 if l_benmngle_parm_rec.mode_cd = 'I' then
9650 --
9651 l_appass_rec.delete;
9652 l_appass_rec(1) := ben_manage_life_events.g_irec_ass_rec ;
9653 else
9654 --
9655 ben_person_object.get_object(p_person_id => p_person_id,
9656 p_rec => l_appass_rec);
9657 --
9658 end if;
9659 --
9660 -- Bug 6509099
9661 if not l_appass_rec.exists(1) then
9662 --
9663 -- Initialize first record so that one time test works
9664 --
9665 l_appass_rec(1).person_id := p_person_id;
9666 --
9667 end if;
9668 --
9669 l_loop_count := l_appass_rec.count;
9670 l_ass_rec := l_appass_rec(1);
9671 --
9672 end if;
9673 --
9674 end if;
9675 --
9676 end if;
9677 --
9678 -- bug fix 2431776 - 27-AUG-2002 - hnarayan
9679 --
9680 -- Now assignment type is also considered a criteria. Hence,
9681 -- if Assignment Type is set to any thing other than "ANY' => any assignment
9682 -- i.e. any one of (EAO, BAO, AAO, ETB, BTE, EBA) then validate the assignment
9683 -- record retreived. If a person does not have an assignment matching the
9684 -- assignment type given in the ELPRO then he is considered ineligible.
9685 -- The only exclusion is ANY (Any Assignment)
9686 --
9687 -- For customers who have already set up their assignment type without
9688 -- considering it as a criteria, the workaround will be to change the
9689 -- assignment type as 'ANY', so that their ELPROs get checked during
9690 -- eligibilty determination
9691 --
9692 -- At this stage the assignment record would have been retreived
9693 -- as per the assignment type code given in the ELPRO for this person
9694 --
9695 hr_utility.set_location(l_proc || ' Start Check Asst Type' , 10) ;
9696 --
9697 if (l_eligprof_dets(l_elptorrw_num).asmt_to_use_cd <> 'ANY' and
9698 l_ass_rec.assignment_id is null) then
9699 --
9700 g_inelg_rsn_cd := 'AST';
9701 fnd_message.set_name('BEN','BEN_93193_ASGN_TYPE_PRFL_FAIL');
9702 hr_utility.set_location('Criteria Failed: Assignment Type',20);
9703 raise g_criteria_failed;
9704 --
9705 end if;
9706 --
9707 hr_utility.set_location(l_proc || ' End Check Asst Type' , 10) ;
9708 --
9709 -- end fix 2431776 - 27-AUG-2002 - hnarayan
9710 --
9711 -- if assignment_id is passed in, make sure eligibility profile's
9712 -- asmt_to_use_cd matches with that value
9713 --
9714 if p_assignment_id is not null then
9715
9716 l_asg_found := false;
9717 for l_count in 1..l_loop_count loop
9718 if l_loop_count > 1 then
9719 l_ass_rec := l_appass_rec(l_count);
9720 end if;
9721 if l_ass_rec.assignment_id = p_assignment_id then
9722 l_asg_found := true;
9723 l_appass_rec.delete;
9724 l_appass_rec(l_count) := l_ass_rec;
9725 l_loop_count := 1;
9726 exit;
9727 end if;
9728 end loop;
9729
9730 if not l_asg_found then
9731 --
9732 g_inelg_rsn_cd := 'AST';
9733 fnd_message.set_name('BEN','BEN_93193_ASGN_TYPE_PRFL_FAIL');
9734 hr_utility.set_location('Criteria Failed: Assignment Type',20);
9735 raise g_criteria_failed;
9736 --
9737 end if;
9738 end if;
9739 end if; --p_person_id not null
9740
9741 hr_utility.set_location(l_proc||' Asg ELPs ',46);
9742 for l_count in 1..l_loop_count loop
9743 --
9744 begin
9745 --
9746 if p_person_id is not null and
9747 l_loop_count > 1 then
9748 --
9749 -- Make sure that we pass in the correct assignment
9750 --
9751 l_ass_rec := l_appass_rec(l_count);
9752 --
9753 end if;
9754 --
9755 assign_overriden_values(l_per_rec,l_ass_rec);
9756 --
9757 hr_utility.set_location(' here ',999);
9758 if l_eligprof_dets(l_elptorrw_num).elig_ee_stat_flag = 'Y' then
9759 check_ee_stat_elig
9760 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
9761 eligy_prfl_id,
9762 p_business_group_id => p_business_group_id,
9763 p_score_compute_mode=> l_prof_score_compute,
9764 p_profile_score_tab => l_profile_score_tab,
9765 p_effective_date => nvl(l_fonm_cvg_strt_dt,l_effective_date),
9766 p_assignment_status_type_id => l_ass_rec.assignment_status_type_id);
9767 end if;
9768 --
9769 if l_eligprof_dets(l_elptorrw_num).elig_wk_loc_flag = 'Y' then
9770 check_wk_location_elig
9771 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
9772 eligy_prfl_id,
9773 p_business_group_id => p_business_group_id,
9774 p_score_compute_mode=> l_prof_score_compute,
9775 p_profile_score_tab => l_profile_score_tab,
9776 p_effective_date => nvl(l_fonm_cvg_strt_dt,l_effective_date),
9777 p_location_id => l_ass_rec.location_id);
9778 end if;
9779 --
9780 if l_eligprof_dets(l_elptorrw_num).elig_org_unit_flag = 'Y' then
9781 check_org_unit_elig
9782 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
9783 eligy_prfl_id,
9784 p_business_group_id => p_business_group_id,
9785 p_score_compute_mode=> l_prof_score_compute,
9786 p_profile_score_tab => l_profile_score_tab,
9787 p_effective_date => nvl(l_fonm_cvg_strt_dt,l_effective_date),
9788 p_organization_id => l_ass_rec.organization_id);
9789 end if;
9790 --
9791 if l_eligprof_dets(l_elptorrw_num).elig_ppl_grp_flag = 'Y' then
9792 check_people_group_elig
9793 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
9794 eligy_prfl_id,
9795 p_business_group_id => p_business_group_id,
9796 p_score_compute_mode=> l_prof_score_compute,
9797 p_profile_score_tab => l_profile_score_tab,
9798 p_effective_date => nvl(l_fonm_cvg_strt_dt,l_effective_date),
9799 p_people_group_id => l_ass_rec.people_group_id);
9800 end if;
9801 --
9802 if l_eligprof_dets(l_elptorrw_num).elig_schedd_hrs_flag = 'Y' then
9803 --
9804 if p_pgm_id is not null then
9805 -- pl_typ_id is not available at pgm level
9806 null;
9807 elsif p_pl_id is not null then
9808 -- pl_typ_id is available in plan record
9809 l_pl_typ_id := l_pl_rec.pl_typ_id;
9810 elsif p_oipl_id is not null then
9811 --
9812 if l_pl_typ_id is null then
9813 --
9814 ben_comp_object.get_object(p_pl_id => l_oipl_rec.pl_id
9815 ,p_rec => l_pl3_rec);
9816 l_pl_typ_id := l_pl3_rec.pl_typ_id;
9817 --
9818 end if;
9819 --
9820 elsif p_plip_id is not null then
9821 --
9822 if l_pl_typ_id is null then
9823 --
9824 ben_comp_object.get_object(p_pl_id => l_plip_rec.pl_id
9825 ,p_rec => l_pl3_rec);
9826 l_pl_typ_id := l_pl3_rec.pl_typ_id;
9827 --
9828 end if;
9829 --
9830 elsif p_ptip_id is not null then
9831 --
9832 if l_pl_typ_id is null then
9833 --
9834 ben_comp_object.get_object(p_ptip_id => l_ptip_rec.ptip_id
9835 ,p_rec => l_ptip2_rec);
9836 l_pl_typ_id := l_ptip2_rec.pl_typ_id;
9837 --
9838 end if;
9839 --
9840 end if;
9841 --
9842 check_sched_hrs_elig
9843 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
9844 eligy_prfl_id,
9845 p_business_group_id => p_business_group_id,
9846 p_effective_date => l_effective_date,
9847 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
9848 p_person_id => p_person_id,
9849 p_pgm_id => p_par_pgm_id,
9850 p_pl_id => nvl(p_pl_id,p_par_pl_id),
9851 p_oipl_id => p_oipl_id,
9852 p_pl_typ_id => l_pl_typ_id,
9853 p_opt_id => l_oipl_rec.opt_id,
9854 p_comp_obj_mode => p_comp_obj_mode,
9855 p_per_in_ler_id => p_per_in_ler_id,
9856 p_score_compute_mode=> l_prof_score_compute,
9857 p_profile_score_tab => l_profile_score_tab,
9858 p_ler_id => p_ler_id,
9859 p_jurisdiction_code => l_jurisdiction_code,
9860 p_assignment_id => l_ass_rec.assignment_id,
9861 p_organization_id => l_ass_rec.organization_id);
9862 end if;
9863 --
9864 if l_eligprof_dets(l_elptorrw_num).elig_fl_tm_pt_tm_flag = 'Y' then
9865 check_fl_tm_pt_elig
9866 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
9867 eligy_prfl_id,
9868 p_business_group_id => p_business_group_id,
9869 p_score_compute_mode=> l_prof_score_compute,
9870 p_profile_score_tab => l_profile_score_tab,
9871 p_effective_date => nvl(l_fonm_cvg_strt_dt,l_effective_date),
9872 p_employment_category => l_ass_rec.employment_category) ;
9873 end if;
9874 --
9875 if l_eligprof_dets(l_elptorrw_num).elig_grd_flag = 'Y' then
9876 check_grade_elig
9877 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
9878 eligy_prfl_id,
9879 p_business_group_id => p_business_group_id,
9880 p_score_compute_mode=> l_prof_score_compute,
9881 p_profile_score_tab => l_profile_score_tab,
9882 p_effective_date => nvl(l_fonm_cvg_strt_dt,l_effective_date),
9883 p_grade_id => l_ass_rec.grade_id);
9884 end if;
9885 --
9886 if l_eligprof_dets(l_elptorrw_num).elig_job_flag = 'Y' then
9887 check_job_elig
9888 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
9889 eligy_prfl_id,
9890 p_business_group_id => p_business_group_id,
9891 p_score_compute_mode=> l_prof_score_compute,
9892 p_profile_score_tab => l_profile_score_tab,
9893 p_effective_date => nvl(l_fonm_cvg_strt_dt,l_effective_date),
9894 p_job_id => l_ass_rec.job_id);
9895 end if;
9896 --
9897 if l_eligprof_dets(l_elptorrw_num).elig_py_bss_flag = 'Y' then
9898 check_py_bss_elig
9899 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
9900 eligy_prfl_id,
9901 p_business_group_id => p_business_group_id,
9902 p_score_compute_mode=> l_prof_score_compute,
9903 p_profile_score_tab => l_profile_score_tab,
9904 p_effective_date => nvl(l_fonm_cvg_strt_dt,l_effective_date),
9905 p_pay_basis_id => l_ass_rec.pay_basis_id);
9906 end if;
9907 --
9908 if l_eligprof_dets(l_elptorrw_num).elig_pyrl_flag = 'Y' then
9909 check_pyrl_elig
9910 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
9911 eligy_prfl_id,
9912 p_business_group_id => p_business_group_id,
9913 p_score_compute_mode=> l_prof_score_compute,
9914 p_profile_score_tab => l_profile_score_tab,
9915 p_effective_date => nvl(l_fonm_cvg_strt_dt,l_effective_date),
9916 p_payroll_id => l_ass_rec.payroll_id);
9917 end if;
9918 --
9919 if l_eligprof_dets(l_elptorrw_num).elig_brgng_unit_flag = 'Y' then
9920 check_brgng_unit_elig
9921 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
9922 eligy_prfl_id,
9923 p_business_group_id => p_business_group_id,
9924 p_score_compute_mode=> l_prof_score_compute,
9925 p_profile_score_tab => l_profile_score_tab,
9926 p_effective_date => nvl(l_fonm_cvg_strt_dt,l_effective_date),
9927 p_bargaining_unit_code => l_ass_rec.bargaining_unit_code);
9928 end if;
9929 --
9930 if l_eligprof_dets(l_elptorrw_num).elig_lbr_mmbr_flag = 'Y' then
9931 check_lbr_union_elig
9932 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
9933 eligy_prfl_id,
9934 p_business_group_id => p_business_group_id,
9935 p_score_compute_mode=> l_prof_score_compute,
9936 p_profile_score_tab => l_profile_score_tab,
9937 p_effective_date => nvl(l_fonm_cvg_strt_dt,l_effective_date),
9938 p_labour_union_member_flag => l_ass_rec.labour_union_member_flag);
9939 end if;
9940 --
9941 if l_eligprof_dets(l_elptorrw_num).elig_hrly_slrd_flag = 'Y' then
9942 check_py_freq_elig
9943 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
9944 eligy_prfl_id,
9945 p_business_group_id => p_business_group_id,
9946 p_score_compute_mode=> l_prof_score_compute,
9947 p_profile_score_tab => l_profile_score_tab,
9948 p_effective_date => nvl(l_fonm_cvg_strt_dt,l_effective_date),
9949 p_hourly_salaried_code => l_ass_rec.hourly_salaried_code);
9950 end if;
9951 --
9952 if l_eligprof_dets(l_elptorrw_num).elig_loa_rsn_flag = 'Y' then
9953 check_loa_rsn_elig
9954 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
9955 eligy_prfl_id,
9956 p_person_id => p_person_id,
9957 p_business_group_id => p_business_group_id,
9958 p_score_compute_mode=> l_prof_score_compute,
9959 p_profile_score_tab => l_profile_score_tab,
9960 p_assignment_id => l_ass_rec.assignment_id,
9961 p_assignment_type => l_ass_rec.assignment_type,
9962 p_abs_attd_type_id => l_absence_attendance_type_id,
9963 p_abs_attd_reason_id => l_absence_attendance_reason_id,
9964 p_effective_date => nvl(l_fonm_cvg_strt_dt,l_effective_date));
9965 end if;
9966 --
9967 hr_utility.set_location(' here 2 ',999);
9968 if l_ass_rec.soft_coding_keyflex_id is not null then
9969 --
9970 ben_person_object.get_object
9971 (p_soft_coding_keyflex_id => l_ass_rec.soft_coding_keyflex_id,
9972 p_rec => l_hsc_rec);
9973 --
9974 if l_hsc_rec.segment1 is not null and
9975 hr_api.return_legislation_code(p_business_group_id) = 'US'
9976 then
9977 --
9978 ben_org_object.get_object
9979 (p_organization_id => l_hsc_rec.segment1,
9980 p_rec => l_org_rec);
9981 --
9982 end if;
9983 --
9984 end if;
9985 --
9986 if l_eligprof_dets(l_elptorrw_num).elig_lgl_enty_flag = 'Y'
9987 and hr_api.return_legislation_code(p_business_group_id) = 'US'
9988 then
9989 check_lgl_enty_elig
9990 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
9991 eligy_prfl_id,
9992 p_business_group_id => p_business_group_id,
9993 p_score_compute_mode=> l_prof_score_compute,
9994 p_profile_score_tab => l_profile_score_tab,
9995 p_effective_date => nvl(l_fonm_cvg_strt_dt,l_effective_date),
9996 p_gre_name => l_org_rec.name);
9997 end if;
9998 -- RBC
9999
10000 if l_eligprof_dets(l_elptorrw_num).elig_crit_values_flag = 'Y' then
10001
10002 ben_evaluate_elig_criteria.main
10003 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).eligy_prfl_id,
10004 p_person_id => p_person_id,
10005 p_assignment_id => nvl(p_assignment_id,l_ass_rec.assignment_id),
10006 p_business_group_id => p_business_group_id,
10007 p_pgm_id => p_par_pgm_id,
10008 p_pl_id => nvl(p_pl_id,p_par_pl_id),
10009 p_opt_id => l_oipl_rec.opt_id,
10010 p_oipl_id => p_oipl_id,
10011 p_ler_id => p_ler_id,
10012 p_pl_typ_id => l_pl_typ_id,
10013 p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date),
10014 p_fonm_cvg_strt_date => ben_manage_life_events.g_fonm_cvg_strt_dt,
10015 p_fonm_rt_strt_date => ben_manage_life_events.g_fonm_cvg_strt_dt,
10016 p_crit_ovrrd_val_tbl => l_crit_ovrrd_val_tab) ;
10017
10018 end if ;
10019
10020 if l_eligprof_dets(l_elptorrw_num).eligy_prfl_rl_flag = 'Y' then
10021 hr_utility.set_location(l_proc||' Chk Rule',48);
10022
10023 -- Bug# 2424041 pl_typ_id context is not being passed to the formula
10024 if p_pgm_id is not null then
10025 -- pl_typ_id is not available at pgm level
10026 null;
10027 elsif p_pl_id is not null then
10028 -- pl_typ_id is available in plan record
10029 l_pl_typ_id := l_pl_rec.pl_typ_id;
10030 elsif p_oipl_id is not null then
10031 open c_oipl_pl_typ(nvl(l_fonm_cvg_strt_dt,
10032 nvl(p_lf_evt_ocrd_dt,p_effective_date)));
10033 fetch c_oipl_pl_typ into l_pl_typ_id;
10034 close c_oipl_pl_typ;
10035 elsif p_plip_id is not null then
10036 open c_plip_pl_typ(nvl(l_fonm_cvg_strt_dt,
10037 nvl(p_lf_evt_ocrd_dt,p_effective_date)));
10038 fetch c_plip_pl_typ into l_pl_typ_id;
10039 close c_plip_pl_typ;
10040 elsif p_ptip_id is not null then
10041 open c_ptip_pl_typ(nvl(l_fonm_cvg_strt_dt,
10042 nvl(p_lf_evt_ocrd_dt,p_effective_date)));
10043 fetch c_ptip_pl_typ into l_pl_typ_id;
10044 close c_ptip_pl_typ;
10045 end if;
10046 -- End bug# 2424041
10047 --
10048 check_rule_elig
10049 (p_person_id => p_person_id
10050 ,p_business_group_id => p_business_group_id
10051 ,p_pgm_id => p_par_pgm_id
10052 ,p_pl_id => nvl(p_pl_id,p_par_pl_id)
10053 ,p_oipl_id => p_oipl_id
10054 ,p_ler_id => p_ler_id
10055 ,p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10056 eligy_prfl_id
10057 ,p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date)
10058 ,p_score_compute_mode=> l_prof_score_compute
10059 ,p_profile_score_tab => l_profile_score_tab
10060 ,p_assignment_id => l_ass_rec.assignment_id
10061 ,p_pl_typ_id => l_pl_typ_id
10062 ,p_organization_id => l_ass_rec.organization_id
10063 );
10064 end if;
10065 --
10066 -- Assignment must have been successful so exit and carry on
10067 -- checking profiles.
10068 --
10069 exit;
10070 --
10071 exception
10072 --
10073 when g_skip_profile then
10074 hr_utility.set_location('skip 1',20);
10075 raise g_skip_profile;
10076 when g_criteria_failed then
10077 --
10078 -- Handle case where we want an error if we are dealing with
10079 -- the last assignment to be processed. If it is the last
10080 -- assignment then we want to error the profile.
10081 --
10082 -- # bug - 3270301
10083 --
10084 if (l_count = l_loop_count and l_eligprof_dets.count = 1 ) then
10085 --
10086 -- Raise error to main exception handler
10087 --
10088 if g_score_compute_mode then
10089 g_per_eligible := false;
10090 raise g_criteria_failed ;
10091 else
10092 return false;
10093 end if;
10094 --
10095 else
10096 -- continue dont error, chk for other profiles
10097 -- if all assignments have been checked
10098 --
10099 if l_count = l_loop_count then
10100 raise g_criteria_failed ;
10101 end if ;
10102 --
10103 end if;
10104 --
10105 hr_utility.set_location(l_proc||' Crit Failed ',48);
10106 when others then
10107 --
10108 -- Catch any unhandled exceptions
10109 --
10110 hr_utility.set_location(l_proc||' Crit Failed ',49);
10111 return false;
10112 --
10113 end;
10114 --
10115 end loop;
10116 --
10117 -- Check these criteria only if the person is an employee who is
10118 -- not terminated:
10119 --
10120 hr_utility.set_location(' here 3 ',999);
10121 if p_person_id is not null and
10122 l_typ_rec(1).system_person_type = 'EMP' and
10123 nvl(p_asg_status,hr_api.g_varchar2) <> 'TERM_ASSIGN' then
10124
10125 hr_utility.set_location(l_proc||' Not TERM ASSIGN',48);
10126
10127 if l_eligprof_dets(l_elptorrw_num).elig_pct_fl_tm_flag = 'Y' then
10128 --
10129 -- for Vapros, get the values from elig_per and elig_per_opt ??
10130 --
10131 if p_comp_obj_mode and
10132 p_eval_typ <> 'E' then
10133 l_pct_fl_tm_val := get_rt_pct_fltm
10134 (p_person_id => p_person_id
10135 ,p_business_group_id => p_business_group_id
10136 ,p_effective_date => p_effective_date
10137 ,p_opt_id => p_opt_id
10138 ,p_plip_id => p_plip_id
10139 ,p_pl_id => p_pl_id
10140 ,p_pgm_id => p_pgm_id);
10141 end if;
10142
10143 check_pct_fltm_elig
10144 (p_person_id => p_person_id,
10145 p_assignment_id => p_assignment_id,
10146 p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10147 eligy_prfl_id,
10148 p_business_group_id => p_business_group_id,
10149 p_evl_typ => p_eval_typ,
10150 p_comp_obj_mode => p_comp_obj_mode,
10151 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
10152 p_score_compute_mode=> l_prof_score_compute,
10153 p_profile_score_tab => l_profile_score_tab,
10154 p_effective_date => l_effective_date,
10155 p_per_pct_ft_val => l_pct_fl_tm_val);
10156 end if;
10157 --
10158 if l_eligprof_dets(l_elptorrw_num).elig_asnt_set_flag = 'Y' then
10159 check_asnt_set
10160 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10161 eligy_prfl_id,
10162 p_business_group_id => p_business_group_id,
10163 p_score_compute_mode=> l_prof_score_compute,
10164 p_profile_score_tab => l_profile_score_tab,
10165 p_person_id => p_person_id,
10166 p_effective_date => nvl(l_fonm_cvg_strt_dt,l_effective_date));
10167 end if;
10168 end if;
10169 --
10170 --
10171 hr_utility.set_location(' here 4 ',999);
10172 if l_eligprof_dets(l_elptorrw_num).elig_los_flag = 'Y' then
10173 check_los_elig
10174 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10175 eligy_prfl_id,
10176 p_person_id => p_person_id,
10177 p_business_group_id => p_business_group_id,
10178 p_effective_date => l_effective_date,
10179 p_eval_typ => p_eval_typ,
10180 p_comp_obj_mode => p_comp_obj_mode,
10181 p_currepe_row => p_currepe_row,
10182 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
10183 p_per_in_ler_id => p_per_in_ler_id,
10184 p_score_compute_mode=> l_prof_score_compute,
10185 p_profile_score_tab => l_profile_score_tab,
10186 p_pl_id => p_pl_id,
10187 p_pgm_id => p_pgm_id,
10188 p_oipl_id => p_oipl_id,
10189 p_plip_id => p_plip_id,
10190 p_opt_id => p_opt_id,
10191 p_per_los => l_los_val);
10192 end if;
10193 --
10194 if l_eligprof_dets(l_elptorrw_num).elig_cmbn_age_los_flag = 'Y' then
10195 check_age_los_elig
10196 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10197 eligy_prfl_id,
10198 p_person_id => p_person_id,
10199 p_business_group_id => p_business_group_id,
10200 p_effective_date => l_effective_date,
10201 p_per_cmbn_age_los => l_cmbn_age_n_los_val,
10202 p_per_cmbn_age => l_comb_age,
10203 p_per_cmbn_los => l_comb_los,
10204 p_dob => l_per_rec.date_of_birth,
10205 p_eval_typ => p_eval_typ,
10206 p_comp_obj_mode => p_comp_obj_mode,
10207 p_currepe_row => p_currepe_row,
10208 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
10209 p_score_compute_mode=> l_prof_score_compute,
10210 p_profile_score_tab => l_profile_score_tab,
10211 p_per_in_ler_id => p_per_in_ler_id,
10212 p_pl_id => p_pl_id,
10213 p_pgm_id => p_pgm_id,
10214 p_oipl_id => p_oipl_id,
10215 p_plip_id => p_plip_id,
10216 p_opt_id => p_opt_id);
10217 end if;
10218 --
10219 hr_utility.set_location(l_proc||' check_comp_level_elig',50);
10220 if l_eligprof_dets(l_elptorrw_num).elig_comp_lvl_flag = 'Y' then
10221 check_comp_level_elig
10222 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10223 eligy_prfl_id,
10224 p_business_group_id => p_business_group_id,
10225 p_effective_date => l_effective_date,
10226 p_comp_obj_mode => p_comp_obj_mode,
10227 p_pgm_id => nvl(p_pgm_id, p_par_pgm_id), --Bug 2424654
10228 p_pl_id => nvl(p_pl_id,p_par_pl_id),
10229 p_oipl_id => p_oipl_id,
10230 p_person_id => p_person_id,
10231 p_per_in_ler_id => l_per_in_ler_id,
10232 p_score_compute_mode=> l_prof_score_compute,
10233 p_profile_score_tab => l_profile_score_tab,
10234 p_per_comp_val => l_comp_ref_amt);
10235 end if;
10236 --
10237 if l_eligprof_dets(l_elptorrw_num).elig_comp_lvl_flag = 'Y' then
10238 check_comp_level_rl_elig
10239 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10240 eligy_prfl_id,
10241 p_person_id => p_person_id,
10242 p_business_group_id => p_business_group_id,
10243 p_effective_date => l_effective_date,
10244 p_per_comp_val => l_comp_ref_amt,
10245 p_eval_typ => p_eval_typ,
10246 p_comp_obj_mode => p_comp_obj_mode,
10247 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
10248 p_per_in_ler_id => p_per_in_ler_id,
10249 p_score_compute_mode=> l_prof_score_compute,
10250 p_profile_score_tab => l_profile_score_tab,
10251 p_pl_id => p_pl_id,
10252 p_pgm_id => p_pgm_id,
10253 p_oipl_id => p_oipl_id,
10254 p_plip_id => p_plip_id,
10255 p_opt_id => p_opt_id);
10256 end if;
10257 --
10258 if l_eligprof_dets(l_elptorrw_num).elig_comp_lvl_flag = 'Y' then
10259 check_person_ben_bal
10260 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10261 eligy_prfl_id,
10262 p_person_id => p_person_id,
10263 p_business_group_id => p_business_group_id,
10264 p_effective_date => l_effective_date,
10265 p_per_comp_val => l_comp_ref_amt,
10266 p_eval_typ => p_eval_typ,
10267 p_comp_obj_mode => p_comp_obj_mode,
10268 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
10269 p_per_in_ler_id => p_per_in_ler_id,
10270 p_score_compute_mode=> l_prof_score_compute,
10271 p_profile_score_tab => l_profile_score_tab,
10272 p_pl_id => p_pl_id,
10273 p_pgm_id => p_pgm_id,
10274 p_oipl_id => p_oipl_id,
10275 p_plip_id => p_plip_id,
10276 p_opt_id => p_opt_id);
10277 end if;
10278 --
10279 hr_utility.set_location(l_proc||' check_person_balance',52);
10280 if l_eligprof_dets(l_elptorrw_num).elig_comp_lvl_flag = 'Y' then
10281 check_person_balance
10282 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10283 eligy_prfl_id,
10284 p_person_id => p_person_id,
10285 p_business_group_id => p_business_group_id,
10286 p_effective_date => l_effective_date,
10287 p_per_comp_val => l_comp_ref_amt,
10288 p_eval_typ => p_eval_typ,
10289 p_comp_obj_mode => p_comp_obj_mode,
10290 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
10291 p_per_in_ler_id => p_per_in_ler_id,
10292 p_score_compute_mode=> l_prof_score_compute,
10293 p_profile_score_tab => l_profile_score_tab,
10294 p_pl_id => p_pl_id,
10295 p_pgm_id => p_pgm_id,
10296 p_oipl_id => p_oipl_id,
10297 p_plip_id => p_plip_id,
10298 p_opt_id => p_opt_id);
10299 end if;
10300 --
10301 if l_eligprof_dets(l_elptorrw_num).elig_hrs_wkd_flag = 'Y' then
10302 hr_utility.set_location(l_proc||' check_hrs_wkd_ben_bal',54);
10303
10304 if p_comp_obj_mode and
10305 p_eval_typ <> 'E' then
10306 --
10307 -- for Vapros, get the values from elig_per and elig_per_opt ??
10308 --
10309 l_hrs_wkd_val := get_rt_hrs_wkd
10310 (p_person_id => p_person_id
10311 ,p_business_group_id => p_business_group_id
10312 ,p_effective_date =>
10313 nvl(l_fonm_cvg_strt_dt,l_effective_date)
10314 ,p_opt_id => p_opt_id
10315 ,p_plip_id => p_plip_id
10316 ,p_pl_id => p_pl_id
10317 ,p_pgm_id => p_pgm_id);
10318 end if;
10319
10320 check_hrs_wkd_ben_bal
10321 (p_person_id => p_person_id,
10322 p_assignment_id => p_assignment_id,
10323 p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10324 eligy_prfl_id,
10325 p_once_r_cntug_cd => l_once_r_cntug_cd,
10326 p_elig_flag => l_comp_elig_flag,
10327 p_business_group_id => p_business_group_id,
10328 p_comp_obj_mode => p_comp_obj_mode,
10329 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
10330 p_score_compute_mode=> l_prof_score_compute,
10331 p_profile_score_tab => l_profile_score_tab,
10332 p_effective_date => nvl(l_fonm_cvg_strt_dt,l_effective_date),
10333 p_per_hrs_wkd => l_hrs_wkd_val);
10334 --
10335 check_hrs_wkd_balance
10336 (p_person_id => p_person_id,
10337 p_assignment_id => p_assignment_id,
10338 p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10339 eligy_prfl_id,
10340 p_once_r_cntug_cd => l_once_r_cntug_cd,
10341 p_elig_flag => l_comp_elig_flag,
10342 p_business_group_id => p_business_group_id,
10343 p_score_compute_mode=> l_prof_score_compute,
10344 p_profile_score_tab => l_profile_score_tab,
10345 p_comp_obj_mode => p_comp_obj_mode,
10346 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
10347 p_effective_date => nvl(l_fonm_cvg_strt_dt,l_effective_date),
10348 p_per_hrs_wkd => l_hrs_wkd_val);
10349 --
10350 check_hrs_wkd_rl_balance
10351 (p_person_id => p_person_id,
10352 p_assignment_id => p_assignment_id,
10353 p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10354 eligy_prfl_id,
10355 p_once_r_cntug_cd => l_once_r_cntug_cd,
10356 p_elig_flag => l_comp_elig_flag,
10357 p_business_group_id => p_business_group_id,
10358 p_score_compute_mode=> l_prof_score_compute,
10359 p_profile_score_tab => l_profile_score_tab,
10360 p_comp_obj_mode => p_comp_obj_mode,
10361 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
10362 p_effective_date => nvl(l_fonm_cvg_strt_dt,l_effective_date),
10363 p_per_hrs_wkd => l_hrs_wkd_val);
10364 --
10365 end if;
10366 --
10367 hr_utility.set_location(l_proc||' check_age_elig',56);
10368 if l_eligprof_dets(l_elptorrw_num).elig_age_flag = 'Y' then
10369 check_age_elig
10370 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10371 eligy_prfl_id,
10372 p_business_group_id => p_business_group_id,
10373 p_effective_date => l_effective_date,
10374 p_person_id => p_person_id,
10375 p_per_age => l_age_val,
10376 p_per_dob => l_per_rec.date_of_birth,
10377 p_eval_typ => p_eval_typ,
10378 p_comp_obj_mode => p_comp_obj_mode,
10379 p_currepe_row => p_currepe_row,
10380 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
10381 p_per_in_ler_id => p_per_in_ler_id,
10382 p_score_compute_mode => l_prof_score_compute,
10383 p_profile_score_tab => l_profile_score_tab,
10384 p_pl_id => p_pl_id,
10385 p_pgm_id => p_pgm_id,
10386 p_oipl_id => p_oipl_id,
10387 p_plip_id => p_plip_id,
10388 p_opt_id => p_opt_id);
10389 end if;
10390 --
10391 hr_utility.set_location(l_proc||' Zip Code',48);
10392 if l_eligprof_dets(l_elptorrw_num).elig_pstl_cd_flag = 'Y' then
10393 check_zip_code_rng_elig
10394 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10395 eligy_prfl_id,
10396 p_person_id => p_person_id,
10397 p_business_group_id => p_business_group_id,
10398 p_score_compute_mode=> l_prof_score_compute,
10399 p_profile_score_tab => l_profile_score_tab,
10400 p_postal_code => l_postal_code,
10401 p_effective_date => nvl(l_fonm_cvg_strt_dt,l_effective_date));
10402 end if;
10403 hr_utility.set_location(l_proc||' check_service_a',60);
10404 --
10405 if l_eligprof_dets(l_elptorrw_num).elig_svc_area_flag = 'Y' then
10406 check_service_area_elig
10407 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10408 eligy_prfl_id,
10409 p_person_id => p_person_id,
10410 p_business_group_id => p_business_group_id,
10411 p_score_compute_mode=> l_prof_score_compute,
10412 p_profile_score_tab => l_profile_score_tab,
10413 p_postal_code => l_postal_code,
10414 p_effective_date => nvl(l_fonm_cvg_strt_dt,l_effective_date));
10415 end if;
10416 --
10417 hr_utility.set_location(l_proc||' check_benefits_grp_elig',62);
10418 if l_eligprof_dets(l_elptorrw_num).elig_benfts_grp_flag = 'Y' then
10419 check_benefits_grp_elig
10420 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10421 eligy_prfl_id,
10422 p_business_group_id => p_business_group_id,
10423 p_score_compute_mode=> l_prof_score_compute,
10424 p_profile_score_tab => l_profile_score_tab,
10425 p_effective_date => nvl(l_fonm_cvg_strt_dt,l_effective_date),
10426 p_benefit_group_id => l_per_rec.benefit_group_id);
10427 end if;
10428 --
10429 if l_eligprof_dets(l_elptorrw_num).elig_prtt_pl_flag = 'Y' then
10430 check_prtt_in_anthr_pl_elig
10431 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10432 eligy_prfl_id,
10433 p_person_id => p_person_id,
10434 p_business_group_id => p_business_group_id,
10435 p_effective_date => nvl(l_fonm_cvg_strt_dt,p_effective_date),
10436 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt);
10437 end if;
10438 --
10439 -- start -- new criteria checks
10440 -- ----------------------------------------------------------------------
10441 --
10442 -- competency
10443 --
10444 if l_eligprof_dets(l_elptorrw_num).elig_comptncy_flag = 'Y' then
10445 check_comptncy_elig
10446 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10447 eligy_prfl_id,
10448 p_business_group_id => p_business_group_id,
10449 p_score_compute_mode=> l_prof_score_compute,
10450 p_profile_score_tab => l_profile_score_tab,
10451 p_person_id => p_person_id,
10452 p_competence_id => l_competence_id,
10453 p_rating_level_id => l_rating_level_id,
10454 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
10455 p_effective_date => p_effective_date);
10456 end if;
10457 --
10458 -- health coverage
10459 --
10460 if l_eligprof_dets(l_elptorrw_num).elig_hlth_cvg_flag = 'Y' then
10461 check_hlth_cvg_elig
10462 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10463 eligy_prfl_id,
10464 p_business_group_id => p_business_group_id,
10465 p_person_id => p_person_id,
10466 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
10467 p_effective_date => p_effective_date);
10468 end if;
10469 --
10470 -- participation in another plan
10471 --
10472 if l_eligprof_dets(l_elptorrw_num).elig_anthr_pl_flag = 'Y' then
10473 check_anthr_pl_elig
10474 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10475 eligy_prfl_id,
10476 p_business_group_id => p_business_group_id,
10477 p_person_id => p_person_id,
10478 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
10479 p_effective_date => p_effective_date);
10480 end if;
10481
10482 if not p_all_prfls then
10483 --
10484 -- total participants
10485 --
10486 if l_eligprof_dets(l_elptorrw_num).elig_ttl_prtt_flag = 'Y' then
10487 check_ttl_prtt_elig
10488 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10489 eligy_prfl_id,
10490 p_business_group_id => p_business_group_id,
10491 p_person_id => p_person_id ,
10492 p_ttl_prtt => p_ttl_prtt,
10493 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
10494 p_effective_date => p_effective_date);
10495 end if;
10496 --
10497 -- total coverage volume
10498 --
10499 if l_eligprof_dets(l_elptorrw_num).elig_ttl_cvg_vol_flag = 'Y' then
10500 check_ttl_cvg_vol_elig
10501 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10502 eligy_prfl_id,
10503 p_business_group_id => p_business_group_id,
10504 p_person_id => p_person_id ,
10505 p_ttl_cvg => p_ttl_cvg,
10506 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
10507 p_effective_date => p_effective_date);
10508
10509 end if;
10510 end if;
10511 --
10512 -- tobacco use
10513 --
10514 if l_eligprof_dets(l_elptorrw_num).elig_tbco_use_flag = 'Y' then
10515 check_tbco_use_elig
10516 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10517 eligy_prfl_id,
10518 p_effective_date => nvl(l_fonm_cvg_strt_dt,p_effective_date),
10519 p_score_compute_mode=> l_prof_score_compute,
10520 p_profile_score_tab => l_profile_score_tab,
10521 p_tbco_use_flag => l_per_rec.uses_tobacco_flag );
10522 end if ;
10523 --
10524 -- disabled
10525 --
10526 if l_eligprof_dets(l_elptorrw_num).elig_dsbld_flag = 'Y' then
10527 check_dsbld_elig
10528 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).eligy_prfl_id,
10529 p_effective_date => nvl(l_fonm_cvg_strt_dt,p_effective_date),
10530 p_score_compute_mode=> l_prof_score_compute,
10531 p_profile_score_tab => l_profile_score_tab,
10532 p_dsbld_cd => l_per_rec.registered_disabled_flag);
10533 end if ;
10534 --
10535 -- Performance rating
10536 --
10537 if l_eligprof_dets(l_elptorrw_num).elig_perf_rtng_flag = 'Y' then
10538 check_perf_rtng_elig
10539 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).eligy_prfl_id,
10540 p_business_group_id => p_business_group_id ,
10541 p_person_id => p_person_id ,
10542 p_perf_rtng_cd => l_perf_rtng_cd,
10543 p_event_type => l_event_type,
10544 p_score_compute_mode=> l_prof_score_compute,
10545 p_profile_score_tab => l_profile_score_tab,
10546 p_lf_evt_ocrd_dt => nvl(l_fonm_cvg_strt_dt,p_lf_evt_ocrd_dt),
10547 p_effective_date => nvl(l_fonm_cvg_strt_dt,p_effective_date) );
10548 end if ;
10549 --
10550 -- Quartile in grade
10551 --
10552 if l_eligprof_dets(l_elptorrw_num).elig_qua_in_gr_flag = 'Y' then
10553 check_qua_in_gr_elig
10554 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).eligy_prfl_id,
10555 p_effective_date => nvl(l_fonm_cvg_strt_dt,p_effective_date),
10556 p_business_group_id => p_business_group_id ,
10557 p_person_id => p_person_id ,
10558 p_assignment_id => l_ass_rec.assignment_id ,
10559 p_grade_id => l_ass_rec.grade_id ,
10560 p_lf_evt_ocrd_dt => nvl(l_fonm_cvg_strt_dt,p_lf_evt_ocrd_dt) ,
10561 p_score_compute_mode=> l_prof_score_compute,
10562 p_profile_score_tab => l_profile_score_tab,
10563 p_pay_basis_id => l_ass_rec.pay_basis_id);
10564 end if ;
10565 --
10566 -- end - new criteria checks
10567 -- ----------------------------------------------------------------------
10568 -- Only check these profiles if we are dealing with a cobra program
10569 --
10570 -- Bug 7411918: moved out leaving reason elig criteria out of the if condition for cobra program
10571
10572 if l_eligprof_dets(l_elptorrw_num).elig_lvg_rsn_flag = 'Y' then
10573 check_elig_lvg_rsn_prte
10574 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10575 eligy_prfl_id,
10576 p_person_id => p_person_id,
10577 p_business_group_id => p_business_group_id,
10578 p_score_compute_mode => l_prof_score_compute,
10579 p_profile_score_tab => l_profile_score_tab,
10580 p_leaving_reason => l_leaving_reason,
10581 p_effective_date => nvl(l_fonm_cvg_strt_dt,l_effective_date));
10582 end if;
10583 --
10584
10585 hr_utility.set_location(l_proc||' cobra',64);
10586 if p_par_pgm_id is not null or
10587 p_eval_typ <> 'E' then
10588 --
10589 -- We are dealing with a program hierarchy
10590 --
10591 if l_eligprof_dets(l_elptorrw_num).elig_ptip_prte_flag = 'Y' then
10592 ben_elpro_check_eligibility.check_elig_othr_ptip_prte
10593 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10594 eligy_prfl_id
10595 ,p_business_group_id => p_business_group_id
10596 ,p_effective_date => p_effective_date
10597 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
10598 ,p_person_id => p_person_id
10599 --
10600 ,p_per_in_ler_id => p_per_in_ler_id
10601 );
10602 end if;
10603 --
10604 if l_eligprof_dets(l_elptorrw_num).elig_dpnt_othr_ptip_flag = 'Y' then
10605 ben_elpro_check_eligibility.check_elig_dpnt_othr_ptip
10606 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10607 eligy_prfl_id
10608 ,p_business_group_id => p_business_group_id
10609 ,p_effective_date => p_effective_date
10610 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
10611 ,p_person_id => p_person_id
10612 --
10613 ,p_per_in_ler_id => p_per_in_ler_id
10614 );
10615 end if;
10616 --
10617 --
10618 if l_eligprof_dets(l_elptorrw_num).elig_no_othr_cvg_flag = 'Y' then
10619 check_elig_no_othr_cvg_prte
10620 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10621 eligy_prfl_id,
10622 p_person_id => p_person_id,
10623 p_business_group_id => p_business_group_id,
10624 p_effective_date => nvl(l_fonm_cvg_strt_dt,l_effective_date));
10625 end if;
10626 --
10627 --
10628 if l_eligprof_dets(l_elptorrw_num).elig_optd_mdcr_flag = 'Y' then
10629 check_elig_optd_mdcr_prte
10630 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10631 eligy_prfl_id,
10632 p_person_id => p_person_id,
10633 p_business_group_id => p_business_group_id,
10634 p_effective_date => nvl(l_fonm_cvg_strt_dt,l_effective_date));
10635 end if;
10636 --
10637 if l_eligprof_dets(l_elptorrw_num).elig_enrld_pl_flag = 'Y' then
10638 check_elig_enrld_anthr_pl
10639 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10640 eligy_prfl_id,
10641 p_business_group_id => p_business_group_id,
10642 p_pl_id => p_pl_id,
10643 p_person_id => p_person_id,
10644 p_effective_date => p_effective_date,
10645 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt);
10646 end if;
10647 --
10648 if l_eligprof_dets(l_elptorrw_num).elig_enrld_oipl_flag = 'Y' then
10649 check_elig_enrld_anthr_oipl
10650 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10651 eligy_prfl_id,
10652 p_business_group_id => p_business_group_id,
10653 p_oipl_id => p_oipl_id,
10654 p_person_id => p_person_id,
10655 p_effective_date => p_effective_date,
10656 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt);
10657 end if;
10658 --
10659 if l_eligprof_dets(l_elptorrw_num).elig_enrld_pgm_flag = 'Y' then
10660 check_elig_enrld_anthr_pgm
10661 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10662 eligy_prfl_id,
10663 p_business_group_id => p_business_group_id,
10664 p_pgm_id => p_pgm_id,
10665 p_person_id => p_person_id,
10666 p_effective_date => p_effective_date,
10667 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt);
10668 end if;
10669 --
10670 if l_eligprof_dets(l_elptorrw_num).elig_dpnt_cvrd_pl_flag = 'Y' then
10671 check_elig_dpnt_cvrd_othr_pl
10672 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10673 eligy_prfl_id,
10674 p_business_group_id => p_business_group_id,
10675 p_pl_id => p_pl_id,
10676 p_person_id => p_person_id,
10677 p_effective_date => p_effective_date,
10678 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt);
10679 end if;
10680 --
10681 if l_eligprof_dets(l_elptorrw_num).elig_enrld_plip_flag = 'Y' then
10682 check_elig_enrld_anthr_plip
10683 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10684 eligy_prfl_id,
10685 p_business_group_id => p_business_group_id,
10686 p_person_id => p_person_id,
10687 p_effective_date => p_effective_date,
10688 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt);
10689 end if;
10690 --
10691 if l_eligprof_dets(l_elptorrw_num).elig_dpnt_cvrd_plip_flag = 'Y' then
10692 check_elig_dpnt_cvrd_othr_plip
10693 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10694 eligy_prfl_id,
10695 p_business_group_id => p_business_group_id,
10696 p_person_id => p_person_id,
10697 p_effective_date => p_effective_date,
10698 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt);
10699 end if;
10700 --
10701 if l_eligprof_dets(l_elptorrw_num).elig_enrld_ptip_flag = 'Y' then
10702 check_elig_enrld_anthr_ptip
10703 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10704 eligy_prfl_id,
10705 p_business_group_id => p_business_group_id,
10706 p_effective_date => p_effective_date,
10707 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt);
10708 end if;
10709 --
10710 if l_eligprof_dets(l_elptorrw_num).elig_dpnt_cvrd_ptip_flag = 'Y' then
10711 check_elig_dpnt_cvrd_othr_ptip
10712 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10713 eligy_prfl_id,
10714 p_business_group_id => p_business_group_id,
10715 p_person_id => p_person_id,
10716 p_effective_date => p_effective_date,
10717 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt);
10718 end if;
10719 --
10720 if l_eligprof_dets(l_elptorrw_num).elig_dpnt_cvrd_pgm_flag = 'Y' then
10721 check_elig_dpnt_cvrd_othr_pgm
10722 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10723 eligy_prfl_id,
10724 p_business_group_id => p_business_group_id,
10725 p_person_id => p_person_id,
10726 p_effective_date => p_effective_date,
10727 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt);
10728 end if;
10729 --
10730 if l_eligprof_dets(l_elptorrw_num).elig_cbr_quald_bnf_flag = 'Y' then
10731 check_elig_cbr_quald_bnf
10732 (p_eligy_prfl_id => l_eligprof_dets(l_elptorrw_num).
10733 eligy_prfl_id,
10734 p_person_id => p_person_id,
10735 p_business_group_id => p_business_group_id,
10736 p_lf_evt_ocrd_dt => nvl(l_fonm_cvg_strt_dt,p_lf_evt_ocrd_dt),
10737 p_effective_date => p_effective_date);
10738 end if;
10739 --
10740 end if;
10741 hr_utility.set_location(l_proc||' Done cobra',66);
10742 hr_utility.set_location(l_eligprof_dets(l_elptorrw_num).eligy_prfl_id,99);
10743 --
10744 ben_cagr_check_eligibility.check_cagr_elig_profiles
10745 (p_eligprof_dets => l_eligprof_dets(l_elptorrw_num)
10746 ,p_effective_date => nvl(l_fonm_cvg_strt_dt,p_effective_date)
10747 --
10748 ,p_person_id => p_person_id
10749 ,p_score_compute_mode=> l_prof_score_compute
10750 ,p_profile_score_tab => l_profile_score_tab
10751 ,p_per_sex => l_per_rec.sex
10752 ,p_per_mar_status => l_per_rec.marital_status
10753 ,p_per_qualification_type_id => l_qualification_type_id
10754 ,p_per_title => l_title
10755 ,p_asg_job_id => l_ass_rec.job_id
10756 ,p_asg_position_id => l_ass_rec.position_id
10757 ,p_asg_prob_perd => l_ass_rec.probation_period
10758 ,p_asg_prob_unit => l_ass_rec.probation_unit
10759 ,p_asg_sps_id => l_ass_rec.special_ceiling_step_id
10760 );
10761 --
10762 -- If we get here, then all the criteria of the profile passed.
10763 -- That means profile passed.
10764 --
10765 if l_eligprof_dets(l_elptorrw_num).mndtry_flag = 'N' then
10766 --
10767 -- If we are in a optional profile, that means we passed all
10768 -- the mandatory profiles.
10769 -- If the mt_one flag = 'Y', then we only need to meet one of
10770 -- the optional
10771 -- profiles for the person to be eligible. Go on to check rules.
10772 --
10773 l_ok_so_far := 'Y';
10774 if g_score_compute_mode then
10775 if g_per_eligible is null then
10776 g_per_eligible := true;
10777 end if;
10778 else
10779 g_per_eligible := true;
10780 exit;
10781 end if;
10782 --
10783 end if;
10784 --
10785 -- Person satisified the profile. Need to store the Scores so far
10786 --
10787 if l_prof_score_compute then
10788 write(p_score_tab,l_profile_score_tab);
10789 end if;
10790 exception
10791 --
10792 when g_skip_profile then
10793 hr_utility.set_location('skip 2',20);
10794 null;
10795 when g_criteria_failed then
10796 --
10797 -- when one of the criteria of the profile fail, they raise
10798 -- this exception.
10799 -- This means the profile failed.
10800 --
10801 if l_eligprof_dets(l_elptorrw_num).mndtry_flag = 'Y' then
10802 --
10803 -- if the profile is a mandatory one,
10804 -- then person is not eligible for
10805 -- this program, plan or option in plan. Skip checking the rules.
10806 --
10807 if g_score_compute_mode then
10808 g_per_eligible := false;
10809 else
10810 return false;
10811 end if;
10812 --
10813 else
10814 --
10815 -- If profile isn't mandatory, it's ok to fail it,
10816 -- go onto next profile but keep track of the fact that the
10817 -- last profile failed.
10818 --
10819 if l_ok_so_far is null then
10820 l_ok_so_far := 'N';
10821 end if;
10822 --
10823 end if;
10824 --
10825 end;
10826 --
10827 hr_utility.set_location(l_proc||' End ELP loop ',68);
10828 end loop; -- elig_prfls
10829 --
10830 end if; -- inst_count
10831 --
10832 --
10833 hr_utility.set_location(l_proc||' After profile loop',70);
10834 --
10835 -- If we are here, either:
10836 -- there were no profiles or
10837 -- all mandatory profiles passed
10838 --
10839 -- there were no optional profiles
10840 -- or there are optional ones, but mt_one flag is off
10841 -- so we don't care and didn't check the optional profiles
10842 --
10843 -- or there are optional ones, mt_one flag is on and ONE
10844 -- optional profile passed or there are optional ones, mt_one flag is
10845 -- off and ALL optional profiles failed.
10846 --
10847 if l_ok_so_far = 'N' then
10848 --
10849 -- there are optional profiles, mt_one flag is off
10850 -- and all optional profiles failed
10851 --
10852 -- 5173693 Truncate the String, if too long.
10853 ben_manage_life_events.g_output_string :=
10854 SUBSTR(ben_manage_life_events.g_output_string,1,900) ||
10855 'Elg: No '||
10856 'Rsn: Opt Prfl No Pass';
10857
10858 --
10859 -- Person failed the comp object. Decide if we need to trash the Scores
10860 --
10861 if g_score_compute_mode and
10862 not g_trk_scr_for_inelg_flag
10863 then
10864 l_profile_score_tab.delete;
10865 p_score_tab.delete;
10866 end if;
10867 return false;
10868 --
10869 end if;
10870 --
10871 if not g_per_eligible then
10872 --
10873 -- Person failed the comp object. Decide if we need to trash the Scores
10874 --
10875 if g_score_compute_mode and
10876 not g_trk_scr_for_inelg_flag
10877 then
10878 l_profile_score_tab.delete;
10879 p_score_tab.delete;
10880 end if;
10881 return false;
10882 end if;
10883 --
10884 hr_utility.set_location('Leaving: '||l_proc,99);
10885 --
10886 return true;
10887 --
10888 end eligible;
10889
10890 end ben_evaluate_elig_profiles;