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