[Home] [Help]
PACKAGE BODY: APPS.BEN_EVALUATE_RATE_PROFILES
Source
1 package body BEN_EVALUATE_RATE_PROFILES as
2 /* $Header: benrtprf.pkb 120.5.12010000.4 2008/08/05 14:54:27 ubhat ship $ */
3 --------------------------------------------------------------------------------
4 --------------------------------------------------------------------------------
5 --
6 -- Global exception handler
7 --
8 g_criteria_failed exception;
9 g_package varchar2(80) := 'ben_evaluate_rate_profiles';
10 --
11 -- ---------------------------------------------------------------
12 -- People Group
13 -- ---------------------------------------------------------------
14 --
15 procedure check_people_group
16 (p_vrbl_rt_prfl_id in number
17 ,p_business_group_id in number
18 ,p_effective_date in date
19 ,p_lf_evt_ocrd_dt in date
20 ,p_people_group_id in varchar2) is
21 --
22 l_inst_set ben_rt_prfl_cache.g_pg_inst_tbl;
23 l_inst_count number;
24 l_ok boolean := false;
25 l_rows_found boolean := false;
26 l_seg_ok boolean := true;
27 --
28 l_const varchar2(50) := hr_api.g_varchar2;
29 --
30 cursor c_ppl_grp is
31 select ppg.people_group_id , ppg.segment1 ,ppg.segment2 ,ppg.segment3 ,ppg.segment4 ,
32 ppg.segment5 , ppg.segment6 ,ppg.segment7 ,ppg.segment8 ,ppg.segment9 , ppg.segment10 ,
33 ppg.segment11 , ppg.segment12 ,ppg.segment13 ,ppg.segment14 ,ppg.segment15 ,
34 ppg.segment16 , ppg.segment17 ,ppg.segment18 ,ppg.segment19 ,ppg.segment20 ,
35 ppg.segment21 , ppg.segment22 ,ppg.segment23 ,ppg.segment24 ,ppg.segment25 ,
36 ppg.segment26 , ppg.segment27 ,ppg.segment28 ,ppg.segment29 ,ppg.segment30
37 from pay_people_groups ppg
38 where ppg.people_group_id = p_people_group_id ;
39
40 --
41 l_ppl_grp_rec c_ppl_grp%ROWTYPE ;
42 l_match boolean ;
43 --
44 begin
45 --
46 -- Get the data from the cache.
47 --
48 ben_rt_prfl_cache.get_rt_prfl_cache
49 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
50 ,p_effective_date => p_effective_date
51 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
52 ,p_business_group_id => p_business_group_id
53 ,p_inst_set => l_inst_set
54 ,p_inst_count => l_inst_count);
55 --
56 if l_inst_count > 0 then
57 --
58 -- Data found. Loop through to see if excld flag is on or off.
59 l_rows_found := true;
60 --
61 for i in l_inst_set.first..l_inst_set.last loop
62 --
63 -- case 1 : id's of profile and ppl grp match, indicating perfect match.
64 --
65 l_ok := l_inst_set(i).people_group_id = p_people_group_id;
66 --
67 if l_ok is null or p_people_group_id is null then
68 --
69 l_ok := false;
70 --
71 end if;
72 --
73 if l_ok and l_inst_set(i).excld_flag = 'N' then
74 --
75 exit;
76 --
77 elsif l_ok and l_inst_set(i).excld_flag = 'Y' then
78 --
79 -- raise g_criteria_failed;
80 l_seg_ok := false;
81 l_ok := false;
82 exit ;
83 --
84 elsif (not l_ok) and l_inst_set(i).excld_flag = 'Y' then
85 l_ok := true ;
86 -- exit ;
87 --
88 elsif l_inst_set(i).excld_flag = 'N' then
89 --
90 l_rows_found := true;
91 --
92 end if;
93 --
94 --
95 -- case 2 : id's do not match so search for a match.
96 --
97
98 open c_ppl_grp ;
99 fetch c_ppl_grp into l_ppl_grp_rec ;
100 close c_ppl_grp ;
101
102 -- Bug 3241479 If there are multiple segments enabled
103 -- we need to return false even if one condition fails.
104 -- appending l_seg_ok to all the conditions.
105
106 -- To enter we are first setting the l_seg_ok to true.
107
108 -- Start of Bug 3241479
109 l_seg_ok := true;
110 if l_seg_ok and l_inst_set(i).segment1 is not null then
111 if l_inst_set(i).segment1 <> nvl(l_ppl_grp_rec.segment1,l_const) then
112 l_seg_ok := false ;
113 else
114 l_seg_ok := true;
115 end if;
116 end if ;
117
118 if l_seg_ok and l_inst_set(i).segment2 is not null then
119 if l_inst_set(i).segment2 <> nvl(l_ppl_grp_rec.segment2,l_const) then
120 l_seg_ok := false ;
121 else
122 l_seg_ok := true;
123 end if;
124 end if ;
125
126
127 if l_seg_ok and l_inst_set(i).segment3 is not null then
128 if l_inst_set(i).segment3 <> nvl(l_ppl_grp_rec.segment3,l_const) then
129 l_seg_ok := false ;
130 else
131 l_seg_ok := true;
132 end if;
133 end if ;
134
135
136 if l_seg_ok and l_inst_set(i).segment4 is not null then
137 if l_inst_set(i).segment4 <> nvl(l_ppl_grp_rec.segment4,l_const) then
138 l_seg_ok := false ;
139 else
140 l_seg_ok := true;
141 end if;
142 end if ;
143
144 if l_seg_ok and l_inst_set(i).segment5 is not null then
145 if l_inst_set(i).segment5 <> nvl(l_ppl_grp_rec.segment5,l_const) then
146 l_seg_ok := false ;
147 else
148 l_seg_ok := true;
149 end if;
150 end if ;
151
152
153 if l_seg_ok and l_inst_set(i).segment6 is not null then
154 if l_inst_set(i).segment6 <> nvl(l_ppl_grp_rec.segment6,l_const) then
155 l_seg_ok := false ;
156 else
157 l_seg_ok := true;
158 end if;
159 end if ;
160
161 if l_seg_ok and l_inst_set(i).segment7 is not null then
162 if l_inst_set(i).segment7 <> nvl(l_ppl_grp_rec.segment7,l_const) then
163 l_seg_ok := false ;
164 else
165 l_seg_ok := true;
166 end if;
167 end if ;
168
169 if l_seg_ok and l_inst_set(i).segment8 is not null then
170 if l_inst_set(i).segment8 <> nvl(l_ppl_grp_rec.segment8,l_const) then
171 l_seg_ok := false ;
172 else
173 l_seg_ok := true;
174 end if;
175 end if ;
176
177
178 if l_seg_ok and l_inst_set(i).segment9 is not null then
179 if l_inst_set(i).segment9 <> nvl(l_ppl_grp_rec.segment9,l_const) then
180 l_seg_ok := false ;
181 else
182 l_seg_ok := true;
183 end if;
184 end if ;
185
186 if l_seg_ok and l_inst_set(i).segment10 is not null then
187 if l_inst_set(i).segment10 <> nvl(l_ppl_grp_rec.segment10,l_const) then
188 l_seg_ok := false ;
189 else
190 l_seg_ok := true;
191 end if;
192 end if ;
193
194 if l_seg_ok and l_inst_set(i).segment11 is not null then
195 if l_inst_set(i).segment11 <> nvl(l_ppl_grp_rec.segment11,l_const) then
196 l_seg_ok := false ;
197 else
198 l_seg_ok := true;
199 end if;
200 end if ;
201
202
203 if l_seg_ok and l_inst_set(i).segment12 is not null then
204 if l_inst_set(i).segment12 <> nvl(l_ppl_grp_rec.segment12,l_const) then
205 l_seg_ok := false ;
206 else
207 l_seg_ok := true;
208 end if;
209 end if ;
210
211
212 if l_seg_ok and l_inst_set(i).segment13 is not null then
213 if l_inst_set(i).segment13 <> nvl(l_ppl_grp_rec.segment13,l_const) then
214 l_seg_ok := false ;
215 else
216 l_seg_ok := true;
217 end if;
218 end if ;
219
220 if l_seg_ok and l_inst_set(i).segment14 is not null then
221 if l_inst_set(i).segment14 <> nvl(l_ppl_grp_rec.segment14,l_const) then
222 l_seg_ok := false ;
223 else
224 l_seg_ok := true;
225 end if;
226 end if ;
227
228
229 if l_seg_ok and l_inst_set(i).segment15 is not null then
230 if l_inst_set(i).segment15 <> nvl(l_ppl_grp_rec.segment15,l_const) then
231 l_seg_ok := false ;
232 else
233 l_seg_ok := true;
234 end if;
235 end if ;
236
237
238 if l_seg_ok and l_inst_set(i).segment16 is not null then
239 if l_inst_set(i).segment16 <> nvl(l_ppl_grp_rec.segment16,l_const) then
240 l_seg_ok := false ;
241 else
242 l_seg_ok := true;
243 end if;
244 end if ;
245
246 if l_seg_ok and l_inst_set(i).segment17 is not null then
247 if l_inst_set(i).segment17 <> nvl(l_ppl_grp_rec.segment17,l_const) then
248 l_seg_ok := false ;
249 else
250 l_seg_ok := true;
251 end if;
252 end if ;
253
254
255 if l_seg_ok and l_inst_set(i).segment18 is not null then
256 if l_inst_set(i).segment18 <> nvl(l_ppl_grp_rec.segment18,l_const) then
257 l_seg_ok := false ;
258 else
259 l_seg_ok := true;
260 end if;
261 end if ;
262
263 if l_seg_ok and l_inst_set(i).segment19 is not null then
264 if l_inst_set(i).segment19 <> nvl(l_ppl_grp_rec.segment19,l_const) then
265 l_seg_ok := false ;
266 else
267 l_seg_ok := true;
268 end if;
269 end if ;
270
271 if l_seg_ok and l_inst_set(i).segment20 is not null then
272 if l_inst_set(i).segment20 <> nvl(l_ppl_grp_rec.segment20,l_const) then
273 l_seg_ok := false ;
274 else
275 l_seg_ok := true;
276 end if;
277 end if ;
278
279
280 if l_seg_ok and l_inst_set(i).segment21 is not null then
281 if l_inst_set(i).segment21 <> nvl(l_ppl_grp_rec.segment21,l_const) then
282 l_seg_ok := false ;
283 else
284 l_seg_ok := true;
285 end if;
286 end if ;
287
288 if l_seg_ok and l_inst_set(i).segment22 is not null then
289 if l_inst_set(i).segment22 <> nvl(l_ppl_grp_rec.segment22,l_const) then
290 l_seg_ok := false ;
291 else
292 l_seg_ok := true;
293 end if;
294 end if ;
295
296 if l_seg_ok and l_inst_set(i).segment23 is not null then
297 if l_inst_set(i).segment23 <> nvl(l_ppl_grp_rec.segment23,l_const) then
298 l_seg_ok := false ;
299 else
300 l_seg_ok := true;
301 end if;
302 end if ;
303
304
305 if l_seg_ok and l_inst_set(i).segment24 is not null then
306 if l_inst_set(i).segment24 <> nvl(l_ppl_grp_rec.segment24,l_const) then
307 l_seg_ok := false ;
308 else
309 l_seg_ok := true;
310 end if;
311 end if ;
312
313
314 if l_seg_ok and l_inst_set(i).segment25 is not null then
315 if l_inst_set(i).segment25 <> nvl(l_ppl_grp_rec.segment25,l_const) then
316 l_seg_ok := false ;
317 else
318 l_seg_ok := true;
319 end if;
320 end if ;
321
322 if l_seg_ok and l_inst_set(i).segment26 is not null then
323 if l_inst_set(i).segment26 <> nvl(l_ppl_grp_rec.segment26,l_const) then
324 l_seg_ok := false ;
325 else
326 l_seg_ok := true;
327 end if;
328 end if ;
329
330 if l_seg_ok and l_inst_set(i).segment27 is not null then
331 if l_inst_set(i).segment27 <> nvl(l_ppl_grp_rec.segment27,l_const) then
332 l_seg_ok := false ;
333 else
334 l_seg_ok := true;
335 end if;
336 end if ;
337
338
339 if l_seg_ok and l_inst_set(i).segment28 is not null then
340 if l_inst_set(i).segment28 <> nvl(l_ppl_grp_rec.segment28,l_const) then
341 l_seg_ok := false ;
342 else
343 l_seg_ok := true;
344 end if;
345 end if ;
346
347 if l_seg_ok and l_inst_set(i).segment29 is not null then
348 if l_inst_set(i).segment29 <> nvl(l_ppl_grp_rec.segment29,l_const) then
349 l_seg_ok := false ;
350 else
351 l_seg_ok := true;
352 end if;
353 end if ;
354
355 if l_seg_ok and l_inst_set(i).segment30 is not null then
356 if l_inst_set(i).segment30 <> nvl(l_ppl_grp_rec.segment30,l_const) then
357 l_seg_ok := false ;
358 else
359 l_seg_ok := true;
360 end if;
361 end if ;
362
363 -- End of bug 3241479
364
365 if l_inst_set(i).excld_flag = 'Y' and l_seg_ok and not l_ok then
366 l_ok := false ;
367 l_seg_ok := false;
368 exit;
369 elsif l_inst_set(i).excld_flag = 'Y' and l_seg_ok and l_ok then
370 l_ok := false ;
371 l_seg_ok := false;
372 exit;
373 elsif l_seg_ok and l_inst_set(i).excld_flag = 'N' then
374 exit;
375 end if;
376 --
377
378 end loop;
379 --
380 end if;
381 --
382 if l_rows_found and not l_ok and not l_seg_ok then
383 --
384 raise g_criteria_failed;
385 --
386 end if;
387 --
388 end check_people_group;
389 --
390 -- ---------------------------------------------------------------
391 -- Formula
392 -- ---------------------------------------------------------------
393 --
394 procedure check_rules
395 (p_vrbl_rt_prfl_id in number
396 ,p_business_group_id in number
397 ,p_effective_date in date
398 ,p_lf_evt_ocrd_dt in date
399 ,p_assignment_id in number
400 ,p_organization_id in number
401 ,p_pgm_id in number
402 ,p_pl_id in number
403 ,p_pl_typ_id in number
404 ,p_opt_id in number
405 ,p_ler_id in number
406 ,p_acty_base_rt_id in number default null
407 ,p_elig_per_elctbl_chc_id in number default null
408 ,p_jurisdiction_code in varchar2)
409 is
410 --
411 l_outputs ff_exec.outputs_t;
412 l_inst_set ben_rt_prfl_cache.g_rl_inst_tbl;
413 l_inst_count number;
414 l_ok boolean := false;
415 l_rows_found boolean := false;
416 l_ben_vapro_rul_cond varchar2(30) := 'A' ;
417 --
418 begin
419 --
420 -- Get the data from the cache.
421 --
422 ben_rt_prfl_cache.get_rt_prfl_cache
423 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
424 ,p_effective_date => p_effective_date
425 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
426 ,p_business_group_id => p_business_group_id
427 ,p_inst_set => l_inst_set
428 ,p_inst_count => l_inst_count);
429 --
430 if l_inst_count > 0 then
431 --- get the profile setup it can be either AND or OR # 2508757
432 l_ben_vapro_rul_cond := fnd_profile.value('BEN_VAPRO_RL_COND');
433
434 hr_utility.set_location(' l_ben_vapro_rul_cond ' || l_ben_vapro_rul_cond, 757 );
435 --
436 for i in l_inst_set.first..l_inst_set.last loop
437 --
438 hr_utility.set_location(' p_vrbl_rt_prfl_id ' || p_vrbl_rt_prfl_id, 757 );
439 l_outputs := benutils.formula
440 (p_formula_id => l_inst_set(i).formula_id
441 ,p_effective_date => nvl(p_lf_evt_ocrd_dt
442 ,p_effective_date)
443 ,p_business_group_id => p_business_group_id
444 ,p_assignment_id => p_assignment_id
445 ,p_organization_id => p_organization_id
446 ,p_pgm_id => p_pgm_id
447 ,p_pl_id => p_pl_id
448 ,p_pl_typ_id => p_pl_typ_id
449 ,p_opt_id => p_opt_id
450 ,p_ler_id => p_ler_id
451 ,p_acty_base_rt_id => p_acty_base_rt_id
452 ,p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id
453 ,p_jurisdiction_code => p_jurisdiction_code
454 ,p_param1 => 'BEN_VPF_I_VRBL_RT_PRFL_ID'
455 ,p_param1_value => to_char(nvl(p_vrbl_rt_prfl_id, -1))
456 -- FONM
457 ,p_param2 => 'BEN_IV_RT_STRT_DT'
458 ,p_param2_value => fnd_date.date_to_canonical(ben_manage_life_events.g_fonm_rt_strt_dt)
459 ,p_param3 => 'BEN_IV_CVG_STRT_DT'
460 ,p_param3_value => fnd_date.date_to_canonical(ben_manage_life_events.g_fonm_cvg_strt_dt)
461 );
462 -- if the profile is AND and one of the rule fails #2508757
463 if nvl(l_ben_vapro_rul_cond,'A') = 'A' then
464
465 hr_utility.set_location(' result ' || l_outputs(l_outputs.first).value, 758 );
466 if l_outputs(l_outputs.first).value <> 'Y' then
467 raise g_criteria_failed;
468 End if ;
469 Else
470 -- if the profile is OR and one of the rule pass then exit
471 hr_utility.set_location(' result ' || l_outputs(l_outputs.first).value, 759 );
472 if l_outputs(l_outputs.first).value = 'Y' then
473 --
474 exit;
475 --
476 end if;
477 End if ;
478 --
479 end loop;
480 -- if the profile is OR and exit with value 'N' raise the error
481 if nvl(l_ben_vapro_rul_cond,'A') = 'O' and l_outputs(l_outputs.first).value <> 'Y' then
482 hr_utility.set_location(' error on OR and N ', 757 );
483 raise g_criteria_failed;
484 end if ;
485 --
486 end if;
487 --
488 end check_rules;
489 --
490 -- ---------------------------------------------------------------
491 -- Tobacco check
492 -- ---------------------------------------------------------------
493 --
494 procedure check_tobacco
495 (p_vrbl_rt_prfl_id in number
496 ,p_business_group_id in number
497 ,p_effective_date in date
498 ,p_lf_evt_ocrd_dt in date
499 ,p_tobacco in varchar2) is
500 --
501 l_inst_set ben_rt_prfl_cache.g_tbco_inst_tbl;
502 l_inst_count number;
503 l_ok boolean := false;
504 l_rows_found boolean := false;
505 --
506 begin
507 --
508 -- Get the data from the cache.
509 --
510 ben_rt_prfl_cache.get_rt_prfl_cache
511 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
512 ,p_effective_date => p_effective_date
513 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
514 ,p_business_group_id => p_business_group_id
515 ,p_inst_set => l_inst_set
516 ,p_inst_count => l_inst_count);
517 --
518 if l_inst_count > 0 then
519 --
520 -- Data found. Loop through to see if excld flag is on or off.
521 l_rows_found := true;
522 --
523 for i in l_inst_set.first..l_inst_set.last loop
524 --
525 l_ok := l_inst_set(i).uses_tbco_flag = nvl(p_tobacco,'-1');
526 --
527 --Removing the code for the bug : 6525934.
528 /* if l_ok is null or p_tobacco is null then
529 --
530 l_ok := false;
531 --
532 end if; */
533 --
534 if l_ok and l_inst_set(i).excld_flag = 'N' then
535 --
536 exit;
537 --
538 elsif (not l_ok) and l_inst_set(i).excld_flag = 'Y' then
539 -- Bug 2100564
540 l_ok := true ;
541 --exit ;
542 --
543 elsif l_ok and l_inst_set(i).excld_flag = 'Y' then
544 --
545 -- raise ben_evaluate_rate_profiles.g_profile_failed;
546 l_ok := false;
547 exit ;
548 --
549 elsif l_inst_set(i).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_rows_found and not l_ok then
560 --
561 raise ben_evaluate_rate_profiles.g_profile_failed;
562 --
563 end if;
564 --
565 end check_tobacco;
566 --
567 -- ---------------------------------------------------------------
568 -- Gender check
569 -- ---------------------------------------------------------------
570 --
571 procedure check_gender
572 (p_vrbl_rt_prfl_id in number
573 ,p_business_group_id in number
574 ,p_effective_date in date
575 ,p_lf_evt_ocrd_dt in date
576 ,p_sex in varchar2) is
577 --
578 l_inst_set ben_rt_prfl_cache.g_gndr_inst_tbl;
579 l_inst_count number;
580 l_ok boolean := false;
581 l_rows_found boolean := false;
582 --
583 begin
584 --
585 -- Get the data from the cache.
586 --
587 ben_rt_prfl_cache.get_rt_prfl_cache
588 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
589 ,p_effective_date => p_effective_date
590 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
591 ,p_business_group_id => p_business_group_id
592 ,p_inst_set => l_inst_set
593 ,p_inst_count => l_inst_count);
594 --
595 if l_inst_count > 0 then
596 --
597 -- Data found. Loop through to see if excld flag is on or off.
598 --
599 l_rows_found := true;
600 --
601 for i in l_inst_set.first..l_inst_set.last loop
602 --
603 hr_utility.set_location(' l_inst_set(i).gndr_cd '||l_inst_set(i).gndr_cd , 12);
604 hr_utility.set_location(' l_inst_set(i).excld_flag '|| l_inst_set(i).excld_flag ,12);
605 --
606 l_ok := l_inst_set(i).gndr_cd = p_sex;
607 --
608 if l_ok is null or p_sex is null then
609 --
610 l_ok := false;
611 --
612 end if;
613 --
614 if l_ok and l_inst_set(i).excld_flag = 'N' then
615 --
616 exit;
617 --
618 elsif l_ok and l_inst_set(i).excld_flag = 'Y' then
619 --
620 -- raise ben_evaluate_rate_profiles.g_profile_failed;
621 l_ok := false ;
622 exit ;
623 --
624 elsif (not l_ok) and l_inst_set(i).excld_flag = 'Y' then
625 -- Bug 2100564
626 l_ok := true ;
627 --exit ;
628 --
629 elsif l_inst_set(i).excld_flag = 'N' then
630 --
631 l_rows_found := true;
632 --
633 end if;
634 --
635 end loop;
636 --
637 end if;
638 --
639 if l_rows_found and not l_ok then
640 --
641 raise ben_evaluate_rate_profiles.g_profile_failed;
642 --
643 end if;
644 --
645 end check_gender;
646 --
647 -- ---------------------------------------------------------------
648 -- Disabled Code check
649 -- ---------------------------------------------------------------
650 --
651
652 procedure check_dsbld_cd
653 (p_vrbl_rt_prfl_id in number
654 ,p_business_group_id in number
655 ,p_effective_date in date
656 ,p_lf_evt_ocrd_dt in date
657 ,p_dsbld_cd in varchar2) is
658 --
659 l_inst_set ben_rt_prfl_cache.g_dsbld_inst_tbl;
660 l_inst_count number;
661 l_ok boolean := false;
662 l_rows_found boolean := false;
663 --
664 begin
665 --
666 -- Get the data from the cache.
667 --
668 ben_rt_prfl_cache.get_rt_prfl_cache
669 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
670 ,p_effective_date => p_effective_date
671 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
672 ,p_business_group_id => p_business_group_id
673 ,p_inst_set => l_inst_set
674 ,p_inst_count => l_inst_count);
675 --
676 if l_inst_count > 0 then
677 --
678 -- Data found. Loop through to see if excld flag is on or off.
679 l_rows_found := true;
680 --
681 for i in l_inst_set.first..l_inst_set.last loop
682 --
683 l_ok := l_inst_set(i).dsbld_cd = p_dsbld_cd;
684 --
685 if l_ok is null or p_dsbld_cd is null then
686 --
687 l_ok := false;
688 --
689 end if;
690 --
691 if l_ok and l_inst_set(i).excld_flag = 'N' then
692 --
693 exit;
694 --
695 elsif l_ok and l_inst_set(i).excld_flag = 'Y' then
696 --
697 -- raise ben_evaluate_rate_profiles.g_profile_failed;
698 l_ok := false;
699 exit ;
700 --
701 elsif (not l_ok) and l_inst_set(i).excld_flag = 'Y' then
702 -- Bug 2100564
703 l_rows_found := true;
704 l_ok := true ;
705 --exit ;
706 --
707 elsif l_inst_set(i).excld_flag = 'N' then
708 --
709 l_rows_found := true;
710 --
711 end if;
712 --
713 end loop;
714 --
715 end if;
716 --
717 if l_rows_found and not l_ok then
718 --
719 raise ben_evaluate_rate_profiles.g_profile_failed;
720 --
721 end if;
722 --
723 end check_dsbld_cd;
724 --
725 -- ---------------------------------------------------------------
726 -- Bargaining Unit check
727 -- ---------------------------------------------------------------
728 --
729 procedure check_brgng_unit
730 (p_vrbl_rt_prfl_id in number
731 ,p_business_group_id in number
732 ,p_effective_date in date
733 ,p_lf_evt_ocrd_dt in date
734 ,p_bargaining_unit_code in varchar2) is
735 --
736 l_inst_set ben_rt_prfl_cache.g_brgng_inst_tbl;
737 l_inst_count number;
738 l_ok boolean := false;
739 l_rows_found boolean := false;
740 --
741 begin
742 --
743 -- Get the data from the cache.
744 --
745 ben_rt_prfl_cache.get_rt_prfl_cache
746 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
747 ,p_effective_date => p_effective_date
748 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
749 ,p_business_group_id => p_business_group_id
750 ,p_inst_set => l_inst_set
751 ,p_inst_count => l_inst_count);
752 --
753 if l_inst_count > 0 then
754 --
755 -- Data found. Loop through to see if excld flag is on or off.
756 --
757 l_rows_found := true;
758 --
759 for i in l_inst_set.first..l_inst_set.last loop
760 --
761 l_ok := l_inst_set(i).brgng_unit_cd = p_bargaining_unit_code;
762 --
763 if l_ok is null or p_bargaining_unit_code is null then
764 --
765 l_ok := false;
766 --
767 end if;
768 --
769 if l_ok and l_inst_set(i).excld_flag = 'N' then
770 --
771 exit;
772 --
773 elsif l_ok and l_inst_set(i).excld_flag = 'Y' then
774 --
775 -- raise g_criteria_failed;
776 l_ok := false;
777 exit ;
778 --
779 elsif (not l_ok) and l_inst_set(i).excld_flag = 'Y' then
780 -- Bug 2100564
781 l_ok := true ;
782 -- exit ;
783 --
784 elsif l_inst_set(i).excld_flag = 'N' then
785 --
786 l_rows_found := true;
787 --
788 end if;
789 --
790 end loop;
791 --
792 end if;
793 --
794 if l_rows_found and not l_ok then
795 --
796 raise g_criteria_failed;
797 --
798 end if;
799 --
800 end check_brgng_unit;
801 --
802 -- ---------------------------------------------------------------
803 -- Benefits group check.
804 -- ---------------------------------------------------------------
805 --
806 procedure check_benefits_grp
807 (p_vrbl_rt_prfl_id in number
808 ,p_person_id in number
809 ,p_business_group_id in number
810 ,p_effective_date in date
811 ,p_lf_evt_ocrd_dt in date
812 ,p_benefit_group_id in number) is
813 --
814 l_inst_set ben_rt_prfl_cache.g_bnfgrp_inst_tbl;
815 l_inst_count number;
816 l_ok boolean := false;
817 l_rows_found boolean := false;
818 --
819 begin
820 --
821 -- Get the data from the cache.
822 --
823 ben_rt_prfl_cache.get_rt_prfl_cache
824 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
825 ,p_effective_date => p_effective_date
826 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
827 ,p_business_group_id => p_business_group_id
828 ,p_inst_set => l_inst_set
829 ,p_inst_count => l_inst_count);
830 --
831 if l_inst_count > 0 then
832 --
833 -- Data found. Loop through to see if excld flag is on or off.
834 --
835 l_rows_found := true;
836 --
837 for i in l_inst_set.first..l_inst_set.last loop
838 --
839 l_ok := l_inst_set(i).benfts_grp_id = p_benefit_group_id;
840 --
841 if l_ok is null or p_benefit_group_id is null then
842 --
843 l_ok := false;
844 --
845 end if;
846 --
847 if l_ok and l_inst_set(i).excld_flag = 'N' then
848 --
849 exit;
850 --
851 elsif l_ok and l_inst_set(i).excld_flag = 'Y' then
852 --
853 -- raise ben_evaluate_rate_profiles.g_profile_failed;
854 l_ok := false;
855 exit;
856 --
857 elsif (not l_ok) and l_inst_set(i).excld_flag = 'Y' then
858 -- Bug 2100564
859 l_rows_found := true;
860 l_ok := true ;
861 -- exit ;
862 --
863 elsif l_inst_set(i).excld_flag = 'N' then
864 --
865 l_rows_found := true;
866 --
867 end if;
868 --
869 end loop;
870 --
871 end if;
872 --
873 if l_rows_found and not l_ok then
874 --
875 raise ben_evaluate_rate_profiles.g_profile_failed;
876 --
877 end if;
878 --
879 end check_benefits_grp;
880 --
881 -- --------------------------------------------------
882 -- Employee status check.
883 -- --------------------------------------------------
884 --
885 procedure check_ee_stat
886 (p_vrbl_rt_prfl_id in number
887 ,p_person_id in number
888 ,p_business_group_id in number
889 ,p_effective_date in date
890 ,p_lf_evt_ocrd_dt in date
891 ,p_assignment_status_type_id in number) is
892 --
893 l_inst_set ben_rt_prfl_cache.g_eestat_inst_tbl;
894 l_inst_count number;
895 l_ok boolean := false;
896 l_rows_found boolean := false;
897 --
898 begin
899 --
900 -- Get the data from the cache.
901 --
902 ben_rt_prfl_cache.get_rt_prfl_cache
903 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
904 ,p_effective_date => p_effective_date
905 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
906 ,p_business_group_id => p_business_group_id
907 ,p_inst_set => l_inst_set
908 ,p_inst_count => l_inst_count);
909 --
910 if l_inst_count > 0 then
911 --
912 -- Data found. Loop through to see if excld flag is on or off.
913 --
914 l_rows_found := true;
915 --
916 for i in l_inst_set.first..l_inst_set.last loop
917 --
918 l_ok := l_inst_set(i).assignment_status_type_id = p_assignment_status_type_id;
919 --
920 if l_ok is null or p_assignment_status_type_id is null then
921 --
922 l_ok := false;
923 --
924 end if;
925 --
926 if l_ok and l_inst_set(i).excld_flag = 'N' then
927 --
928 exit;
929 --
930 elsif l_ok and l_inst_set(i).excld_flag = 'Y' then
931 --
932 -- raise g_criteria_failed;
933 l_ok := false;
934 exit ;
935 --
936 elsif (not l_ok) and l_inst_set(i).excld_flag = 'Y' then
937 -- Bug 2100564
938 l_rows_found := true;
939 l_ok := true ;
940 --exit ;
941 --
942 elsif l_inst_set(i).excld_flag = 'N' then
943 --
944 l_rows_found := true;
945 --
946 end if;
947 --
948 end loop;
949 --
950 end if;
951 --
952 if l_rows_found and not l_ok then
953 --
954 raise g_criteria_failed;
955 --
956 end if;
957 --
958 end check_ee_stat;
959 --
960 -- ---------------------------------------------------------------
961 -- Full time/part time check.
962 -- ---------------------------------------------------------------
963 --
964 procedure check_fl_tm_pt
965 (p_vrbl_rt_prfl_id in number
966 ,p_person_id in number
967 ,p_business_group_id in number
968 ,p_effective_date in date
969 ,p_lf_evt_ocrd_dt in date
970 ,p_employment_category in varchar2) is
971 --
972 l_inst_set ben_rt_prfl_cache.g_ftpt_inst_tbl;
973 l_inst_count number;
974 l_ok boolean := false;
975 l_rows_found boolean := false;
976 --
977 begin
978 --
979 -- Get the data from the cache.
980 --
981 ben_rt_prfl_cache.get_rt_prfl_cache
982 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
983 ,p_effective_date => p_effective_date
984 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
985 ,p_business_group_id => p_business_group_id
986 ,p_inst_set => l_inst_set
987 ,p_inst_count => l_inst_count);
988 --
989 if l_inst_count > 0 then
990 --
991 -- Data found. Loop through to see if excld flag is on or off.
992 --
993 l_rows_found := true;
994 --
995 for i in l_inst_set.first..l_inst_set.last loop
996 --
997 l_ok := l_inst_set(i).fl_tm_pt_tm_cd = p_employment_category;
998 --
999 if l_ok is null or p_employment_category is null then
1000 --
1001 l_ok := false;
1002 --
1003 end if;
1004 --
1005 if l_ok and l_inst_set(i).excld_flag = 'N' then
1006 --
1007 exit;
1008 --
1009 elsif l_ok and l_inst_set(i).excld_flag = 'Y' then
1010 --
1011 -- raise g_criteria_failed;
1012 l_ok := false;
1013 exit ;
1014 --
1015 elsif (not l_ok) and l_inst_set(i).excld_flag = 'Y' then
1016 -- Bug 2100564
1017 l_rows_found := true;
1018 l_ok := true ;
1019 -- exit ;
1020 --
1021 elsif l_inst_set(i).excld_flag = 'N' then
1022 --
1023 l_rows_found := true;
1024 --
1025 end if;
1026 --
1027 end loop;
1028 --
1029 end if;
1030 --
1031 if l_rows_found and not l_ok then
1032 --
1033 raise g_criteria_failed;
1034 --
1035 end if;
1036 --
1037 end check_fl_tm_pt;
1038 --
1039 -- ------------------------------------------------------
1040 -- Grade check
1041 -- ------------------------------------------------------
1042 --
1043 procedure check_grade
1044 (p_vrbl_rt_prfl_id in number
1045 ,p_person_id in number
1046 ,p_business_group_id in number
1047 ,p_effective_date in date
1048 ,p_lf_evt_ocrd_dt in date
1049 ,p_grade_id in number) is
1050 --
1051 l_inst_set ben_rt_prfl_cache.g_grd_inst_tbl;
1052 l_inst_count number;
1053 l_ok boolean := false;
1054 l_rows_found boolean := false;
1055 --
1056 begin
1057 --
1058 -- Get the data from the cache.
1059 --
1060 ben_rt_prfl_cache.get_rt_prfl_cache
1061 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
1062 ,p_effective_date => p_effective_date
1063 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
1064 ,p_business_group_id => p_business_group_id
1065 ,p_inst_set => l_inst_set
1066 ,p_inst_count => l_inst_count);
1067 --
1068 if l_inst_count > 0 then
1069 --
1070 -- Data found. Loop through to see if excld flag is on or off.
1071 --
1072 l_rows_found := true;
1073 --
1074 for i in l_inst_set.first..l_inst_set.last loop
1075 --
1076 l_ok := l_inst_set(i).grade_id = p_grade_id;
1077 --
1078 if l_ok is null or p_grade_id is null then
1079 --
1080 l_ok := false;
1081 --
1082 end if;
1083 --
1084 if l_ok and l_inst_set(i).excld_flag = 'N' then
1085 --
1086 exit;
1087 --
1088 elsif l_ok and l_inst_set(i).excld_flag = 'Y' then
1089 --
1090 -- raise g_criteria_failed;
1091 l_ok := false;
1092 exit ;
1093 --
1094 elsif (not l_ok) and l_inst_set(i).excld_flag = 'Y' then
1095 -- Bug 2100564
1096 l_ok := true ;
1097 --exit ;
1098 --
1099 elsif l_inst_set(i).excld_flag = 'N' then
1100 --
1101 l_rows_found := true;
1102 --
1103 end if;
1104 --
1105 end loop;
1106 --
1107 end if;
1108 --
1109 if l_rows_found and not l_ok then
1110 --
1111 raise g_criteria_failed;
1112 --
1113 end if;
1114 --
1115 end check_grade;
1116 --
1117 -- -----------------------------------------------------------------
1118 -- Percent fulltime check.
1119 -- -----------------------------------------------------------------
1120 --
1121 procedure check_pct_fltm
1122 (p_vrbl_rt_prfl_id in number
1123 ,p_person_id in number
1124 ,p_business_group_id in number
1125 ,p_effective_date in date
1126 ,p_lf_evt_ocrd_dt in date
1127 ,p_opt_id in number default null
1128 ,p_plip_id in number default null
1129 ,p_pl_id in number default null
1130 ,p_pgm_id in number default null) is
1131 --
1132 l_ok boolean := false;
1133 l_opt_id number(15);
1134 l_rt_pct_fl_tm_val ben_elig_per_f.rt_pct_fl_tm_val%type := null;
1135
1136 cursor c_pct_ft is
1137 select bep.rt_pct_fl_tm_val
1138 from ben_elig_per_f bep,
1139 ben_per_in_ler pil
1140 where bep.person_id = p_person_id
1141 and nvl(bep.pgm_id,-1) = nvl(p_pgm_id,-1)
1142 and nvl(bep.pl_id,-1) = nvl(p_pl_id,-1)
1143 and p_effective_date
1144 between bep.effective_start_date
1145 and bep.effective_end_date
1146 and pil.per_in_ler_id(+)=bep.per_in_ler_id
1147 and pil.business_group_id(+)=bep.business_group_id+0
1148 and (pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT') -- found row condition
1149 or pil.per_in_ler_stat_cd is null -- outer join condition
1150 );
1151
1152 cursor c_pct_ft_opt is
1153 select epo.rt_pct_fl_tm_val
1154 from ben_elig_per_f bep, ben_elig_per_opt_f epo,
1155 ben_per_in_ler pil
1156 where bep.person_id = p_person_id
1157 and bep.elig_per_id = epo.elig_per_id
1158 and epo.opt_id = p_opt_id
1159 and nvl(bep.pgm_id,-1) = nvl(p_pgm_id,-1)
1160 and nvl(bep.pl_id,-1) = nvl(p_pl_id,-1)
1161 and p_effective_date between epo.effective_start_date
1162 and epo.effective_end_date
1163 and p_effective_date between bep.effective_start_date
1164 and bep.effective_end_date
1165 and pil.per_in_ler_id(+)=bep.per_in_ler_id
1166 and pil.business_group_id(+)=bep.business_group_id
1167 and (pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT') -- found row condition
1168 or pil.per_in_ler_stat_cd is null); -- outer join condition
1169
1170 cursor c_pct_ft_plip is
1171 select epo.rt_pct_fl_tm_val
1172 from ben_elig_per_f bep, ben_elig_per_opt_f epo,
1173 ben_per_in_ler pil
1174 where bep.person_id = p_person_id
1175 and bep.elig_per_id = epo.elig_per_id
1176 and epo.opt_id = p_opt_id
1177 and nvl(bep.pgm_id,-1) = nvl(p_pgm_id,-1)
1178 and nvl(bep.plip_id,-1) = nvl(p_plip_id,-1)
1179 and p_effective_date between epo.effective_start_date
1180 and epo.effective_end_date
1181 and p_effective_date between bep.effective_start_date
1182 and bep.effective_end_date
1183 and pil.per_in_ler_id(+)=bep.per_in_ler_id
1184 and pil.business_group_id(+)=bep.business_group_id
1185 and (pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT') -- found row condition
1186 or pil.per_in_ler_stat_cd is null); -- outer join condition
1187
1188 l_inst_set ben_rt_prfl_cache.g_pctft_inst_tbl;
1189 l_inst_count number;
1190 l_rows_found boolean := false;
1191 l_mx_pct_val number ;
1192 --
1193 begin
1194 hr_utility.set_location ('Entering check_pct_fltm',01);
1195 hr_utility.set_location ('opt' || p_opt_id ,01);
1196 hr_utility.set_location ('plip'|| p_plip_id ,01);
1197 hr_utility.set_location ('pl' || p_pl_id ,01);
1198 hr_utility.set_location ('pgm' || p_pgm_id ,01);
1199 --
1200
1201 if p_opt_id is not null then
1202 -- Look for oiplip first. oiplip elig_per_opt rows hang off plip elig_per
1203 -- records.
1204 if p_plip_id is not null then
1205 open c_pct_ft_plip;
1206 fetch c_pct_ft_plip into l_rt_pct_fl_tm_val;
1207 hr_utility.set_location ('oiplip '||to_char(l_rt_pct_fl_tm_val),01);
1208 close c_pct_ft_plip;
1209 end if;
1210
1211 -- If there is no oiplip, check for oipl
1212 if l_rt_pct_fl_tm_val is null then
1213 open c_pct_ft_opt;
1214 fetch c_pct_ft_opt into l_rt_pct_fl_tm_val;
1215 hr_utility.set_location ('oipl '||to_char(l_rt_pct_fl_tm_val),01);
1216 close c_pct_ft_opt;
1217 end if;
1218 else
1219 -- just look for pl elig per record.
1220 open c_pct_ft;
1221 fetch c_pct_ft into l_rt_pct_fl_tm_val;
1222 hr_utility.set_location ('pl '||to_char(l_rt_pct_fl_tm_val),01);
1223 close c_pct_ft;
1224 end if;
1225
1226 -- Get the rate profile data from the cache.
1227 --
1228 ben_rt_prfl_cache.get_rt_prfl_cache
1229 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
1230 ,p_effective_date => p_effective_date
1231 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
1232 ,p_business_group_id => p_business_group_id
1233 ,p_inst_set => l_inst_set
1234 ,p_inst_count => l_inst_count);
1235 --
1236 if l_inst_count > 0 then
1237 --
1238 -- Data found. Loop through to see if excld flag is on or off.
1239 --
1240 l_rows_found := true;
1241 --
1242 for i in l_inst_set.first..l_inst_set.last loop
1243 --
1244 --
1245 --- if there is fraction compare in differtn way
1246 -- Bug 2101937 fixes
1247 l_mx_pct_val := l_inst_set(i).mx_pct_val ;
1248 --
1249 if ( l_inst_set(i).mx_pct_val <> trunc(l_inst_set(i).mx_pct_val) OR
1250 l_inst_set(i).mn_pct_val <> trunc(l_inst_set(i).mn_pct_val) ) then
1251 -- Decimal Case
1252 l_mx_pct_val := l_inst_set(i).mx_pct_val + 0.000000001 ;
1253 --
1254 else
1255 --
1256 l_mx_pct_val := l_inst_set(i).mx_pct_val + 1 ;
1257 --
1258 end if;
1259 --
1260 hr_utility.set_location('if' , 610) ;
1261 --
1262 l_ok := ((l_rt_pct_fl_tm_val >=
1263 l_inst_set(i).mn_pct_val
1264 and l_rt_pct_fl_tm_val < l_mx_pct_val )
1265 or
1266 (l_inst_set(i).no_mn_pct_val_flag = 'Y' and
1267 l_rt_pct_fl_tm_val < l_mx_pct_val )
1268 or
1269 (l_rt_pct_fl_tm_val >= l_inst_set(i).mn_pct_val and
1270 l_inst_set(i).no_mx_pct_val_flag = 'Y'));
1271
1272 if l_ok Then
1273 hr_utility.set_location('success ' ,610);
1274 end if ;
1275 --
1276 if l_ok is null or l_rt_pct_fl_tm_val is null then
1277 --
1278 l_ok := false;
1279 --
1280 end if;
1281 --
1282 if l_ok and l_inst_set(i).excld_flag = 'N' then
1283 --
1284 exit;
1285 --
1286 elsif l_ok and l_inst_set(i).excld_flag = 'Y' then
1287 --
1288 -- raise ben_evaluate_rate_profiles.g_profile_failed;
1289 l_ok := false;
1290 exit ;
1291 --
1292 elsif (not l_ok) and l_inst_set(i).excld_flag = 'Y' then
1293 -- Bug 2100564
1294 l_ok := true ;
1295 --exit ;
1296 --
1297 elsif l_inst_set(i).excld_flag = 'N' then
1298 --
1299 l_rows_found := true;
1300 --
1301 end if;
1302 --
1303 end loop;
1304 --
1305 end if;
1306 --
1307 if l_rows_found and not l_ok then
1308 --
1309 raise ben_evaluate_rate_profiles.g_profile_failed;
1310 --
1311 end if;
1312 --
1313 end check_pct_fltm;
1314 --
1315 -- ------------------------------
1316 -- Assignment set
1317 -- ------------------------------
1318 --
1319
1320 procedure check_asnt_set
1321 (p_VRBL_RT_PRFL_ID in number,
1322 p_business_group_id in number,
1323 p_person_id in number,
1324 p_lf_evt_ocrd_dt in date,
1325 p_effective_date in date) is
1326 --
1327 l_proc varchar2(100):=g_package||'check_asnt_set';
1328 l_inst_dets ben_rt_asnt_cache.g_rt_asnt_inst_tbl;
1329 l_inst_count number;
1330 l_insttorrw_num binary_integer;
1331 l_ok boolean := false;
1332 l_rows_found boolean := false;
1333 l_ass_rec per_all_assignments_f%rowtype;
1334 l_outputs ff_exec.outputs_t;
1335 l_include_flag varchar2(80);
1336 --
1337 begin
1338 --
1339 hr_utility.set_location('Entering: '||l_proc, 10);
1340 --
1341 -- Getting eligibility profile compensation level by eligibility profile
1342 --
1343 ben_rt_asnt_cache.get_rt_asnt_cache
1344 (p_effective_date => p_effective_date
1345 ,p_business_group_id => p_business_group_id
1346 ,p_VRBL_RT_PRFL_ID => p_VRBL_RT_PRFL_ID
1347 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
1348 ,p_inst_set => l_inst_dets
1349 ,p_inst_count => l_inst_count);
1350 --
1351 hr_utility.set_location('Int COunt'||l_inst_count,11);
1352 if l_inst_count > 0 then
1353 --
1354 ben_person_object.get_object(p_person_id => p_person_id,
1355 p_rec => l_ass_rec);
1356 --
1357 for l_count in l_inst_dets.first .. l_inst_dets.last loop
1358 --
1359 -- Error if someone hasn't built the formula as this will
1360 -- cause an error. In this case kill the run.
1361 --
1362 hr_utility.set_location('COunt'||l_count,11);
1363 if l_inst_dets(l_count).formula_id is null then
1364 --
1365 fnd_message.set_name('BEN','BEN_92460_ASS_SET_FORMULA');
1366 fnd_message.set_token('PROC',l_proc);
1367 fnd_message.set_token('VARIABLE_RT_PRFL_ID',to_char(p_VRBL_RT_PRFL_ID));
1368 fnd_message.raise_error;
1369 --
1370 end if;
1371 --
1372 hr_utility.set_location('Bef Formula',11);
1373 l_outputs := benutils.formula
1374 (p_formula_id => l_inst_dets(l_count).formula_id,
1375 p_assignment_id => l_ass_rec.assignment_id,
1376 p_effective_date => nvl(p_lf_evt_ocrd_dt, p_effective_date), -- FONM
1377 p_param1 => 'BEN_IV_RT_STRT_DT',
1378 p_param1_value => fnd_date.date_to_canonical(ben_manage_life_events.g_fonm_rt_strt_dt),
1379 p_param2 => 'BEN_IV_CVG_STRT_DT',
1380 p_param2_value => fnd_date.date_to_canonical(ben_manage_life_events.g_fonm_cvg_strt_dt));
1381 --
1382 begin
1383 --
1384 if l_outputs(l_outputs.first).name = 'INCLUDE_FLAG' then
1385 --
1386 hr_utility.set_location('Incl Flag ',11);
1387 l_include_flag := l_outputs(l_outputs.first).value;
1388 --
1389 else
1390 --
1391 -- Account for cases where formula returns an unknown
1392 -- variable name
1393 --
1394 fnd_message.set_name('BEN','BEN_92310_FORMULA_RET_PARAM_');
1395 fnd_message.set_token('PROC',l_proc);
1396 fnd_message.set_token('FORMULA',l_inst_dets(l_count).formula_id);
1397 fnd_message.set_token('PARAMETER',l_outputs(l_outputs.first).name);
1398 fnd_message.raise_error;
1399 --
1400 end if;
1401 --
1402 -- Code for type casting errors from formula return variables
1403 --
1404 exception
1405 --
1406 when others then
1407 --
1408 fnd_message.set_name('BEN','BEN_92311_FORMULA_VAL_PARAM');
1409 fnd_message.set_token('PROC',l_proc);
1410 fnd_message.set_token('FORMULA',l_inst_dets(l_count).formula_id);
1411 fnd_message.set_token('PARAMETER',l_outputs(l_outputs.first).name);
1412 fnd_message.raise_error;
1413 --
1414 end;
1415 --
1416 hr_utility.set_location('Include Flag '||l_include_flag,10);
1417 --
1418 l_ok := nvl((l_include_flag = 'Y'),FALSE);
1419 --if l_ok is null then
1420 -- l_ok:=false;
1421 --end if;
1422 --
1423 if l_ok and l_inst_dets(l_count).excld_flag = 'N' then
1424 --
1425 exit;
1426 --
1427 elsif l_ok and l_inst_dets(l_count).excld_flag = 'Y' then
1428 --
1429 l_rows_found := true;
1430 l_ok := false;
1431 exit;
1432 --
1433 elsif (not l_ok) and l_inst_dets(l_count).excld_flag = 'Y' then
1434 --
1435 l_rows_found := true;
1436 l_ok := true;
1437 -- exit;
1438 --
1439 elsif l_inst_dets(l_count).excld_flag = 'N' then
1440 --
1441 l_rows_found := true;
1442 --
1443 end if;
1444 --
1445 end loop;
1446 --
1447 end if;
1448 --
1449 if l_rows_found and
1450 not l_ok then
1451 --
1452 fnd_message.set_name('BEN','BEN_92459_ASS_SET_PRFL_FAIL');
1453 hr_utility.set_location('Criteria Failed: '||l_proc,20);
1454 raise g_criteria_failed;
1455 --
1456 end if;
1457 --
1458 hr_utility.set_location('Leaving :'||l_proc,20);
1459 --
1460 end check_asnt_set;
1461 -- --------------------------------------------------------------------
1462 -- Hours worked in a period check.
1463 -- --------------------------------------------------------------------
1464 --
1465 procedure check_hrs_wkd
1466 (p_vrbl_rt_prfl_id in number
1467 ,p_person_id in number
1468 ,p_business_group_id in number
1469 ,p_effective_date in date
1470 ,p_lf_evt_ocrd_dt in date
1471 ,p_opt_id in number default null
1472 ,p_plip_id in number default null
1473 ,p_pl_id in number default null
1474 ,p_pgm_id in number default null) is
1475 --
1476 l_ok boolean := false;
1477 l_opt_id number(15);
1478 l_rt_hrs_wkd_val ben_elig_per_f.rt_hrs_wkd_val%type;
1479
1480
1481 cursor c_hrs_wkd is
1482 select bep.rt_hrs_wkd_val
1483 from ben_elig_per_f bep,
1484 ben_per_in_ler pil
1485 where bep.person_id = p_person_id
1486 and nvl(bep.pgm_id,-1) = nvl(p_pgm_id,-1)
1487 and nvl(bep.pl_id,-1) = nvl(p_pl_id,-1)
1488 and p_effective_date between bep.effective_start_date
1489 and bep.effective_end_date
1490 and pil.per_in_ler_id(+)=bep.per_in_ler_id
1491 and pil.business_group_id(+)=bep.business_group_id
1492 and (pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT') -- found row condition
1493 or pil.per_in_ler_stat_cd is null); -- outer join condition
1494
1495 cursor c_hrs_wkd_opt is
1496 select epo.rt_hrs_wkd_val
1497 from ben_elig_per_f bep, ben_elig_per_opt_f epo,
1498 ben_per_in_ler pil
1499 where bep.person_id = p_person_id
1500 and bep.elig_per_id = epo.elig_per_id
1501 and epo.opt_id = p_opt_id
1502 and nvl(bep.pgm_id,-1) = nvl(p_pgm_id,-1)
1503 and nvl(bep.pl_id,-1) = nvl(p_pl_id,-1)
1504 and p_effective_date between epo.effective_start_date
1505 and epo.effective_end_date
1506 and p_effective_date between bep.effective_start_date
1507 and bep.effective_end_date
1508 and pil.per_in_ler_id(+)=bep.per_in_ler_id
1509 and pil.business_group_id(+)=bep.business_group_id
1510 and (pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT') -- found row condition
1511 or pil.per_in_ler_stat_cd is null); -- outer join condition
1512
1513 cursor c_hrs_wkd_plip is
1514 select epo.rt_hrs_wkd_val
1515 from ben_elig_per_f bep, ben_elig_per_opt_f epo,
1516 ben_per_in_ler pil
1517 where bep.person_id = p_person_id
1518 and bep.elig_per_id = epo.elig_per_id
1519 and epo.opt_id = p_opt_id
1520 and nvl(bep.pgm_id,-1) = nvl(p_pgm_id,-1)
1521 and nvl(bep.plip_id,-1) = nvl(p_plip_id,-1)
1522 and p_effective_date between epo.effective_start_date
1523 and epo.effective_end_date
1524 and p_effective_date between bep.effective_start_date
1525 and bep.effective_end_date
1526 and pil.per_in_ler_id(+)=bep.per_in_ler_id
1527 and pil.business_group_id(+)=bep.business_group_id
1528 and (pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT') -- found row condition
1529 or pil.per_in_ler_stat_cd is null); -- outer join condition
1530
1531 l_inst_set ben_rt_prfl_cache.g_hrswkd_inst_tbl;
1532 l_inst_count number;
1533 l_rows_found boolean := false;
1534 l_mx_hrs_num number ;
1535
1536 begin
1537 hr_utility.set_location ('Entering check_hrs_wkd',01);
1538 if p_opt_id is not null then
1539 -- Look for oiplip first. oiplip elig_per_opt rows hang off plip elig_per
1540 -- records.
1541 if p_plip_id is not null then
1542 open c_hrs_wkd_plip;
1543 fetch c_hrs_wkd_plip into l_rt_hrs_wkd_val;
1544 hr_utility.set_location ('oiplip '||to_char(l_rt_hrs_wkd_val),01);
1545 close c_hrs_wkd_plip;
1546 end if;
1547
1548 -- If there is no oiplip, check for oipl
1549 if l_rt_hrs_wkd_val is null then
1550 open c_hrs_wkd_opt;
1551 fetch c_hrs_wkd_opt into l_rt_hrs_wkd_val;
1552 hr_utility.set_location ('oipl '||to_char(l_rt_hrs_wkd_val),01);
1553 close c_hrs_wkd_opt;
1554 end if;
1555 else
1556 -- just look for pl elig per record.
1557 open c_hrs_wkd;
1558 fetch c_hrs_wkd into l_rt_hrs_wkd_val;
1559 hr_utility.set_location ('pl '||to_char(l_rt_hrs_wkd_val),01);
1560 close c_hrs_wkd;
1561 end if;
1562
1563
1564 --
1565 -- Get the rate profile data from the cache.
1566 --
1567 ben_rt_prfl_cache.get_rt_prfl_cache
1568 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
1569 ,p_effective_date => p_effective_date
1570 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
1571 ,p_business_group_id => p_business_group_id
1572 ,p_inst_set => l_inst_set
1573 ,p_inst_count => l_inst_count);
1574
1575 if l_inst_count > 0 then
1576 --
1577 -- Data found. Loop through to see if excld flag is on or off.
1578 --
1579 l_rows_found := true;
1580 --
1581 for i in l_inst_set.first..l_inst_set.last loop
1582 hr_utility.set_location ('hrx criteria'||l_rt_hrs_wkd_val || ' min:'||
1583 to_char(l_inst_set(i).mn_hrs_num)||' mx:'||to_char(l_inst_set(i).mx_hrs_num),610.2);
1584 --
1585 -- Bug 2101937 fixes
1586 l_mx_hrs_num := l_inst_set(i).mx_hrs_num ;
1587 --
1588 if ( l_inst_set(i).mx_hrs_num <> trunc(l_inst_set(i).mx_hrs_num) OR
1589 l_inst_set(i).mn_hrs_num <> trunc(l_inst_set(i).mn_hrs_num) ) then
1590 -- Decimal Case
1591 l_mx_hrs_num := l_inst_set(i).mx_hrs_num + 0.000000001 ;
1592 --
1593 else
1594 --
1595 l_mx_hrs_num := l_inst_set(i).mx_hrs_num + 1 ;
1596 --
1597 end if;
1598 --
1599
1600 l_ok := ((l_rt_hrs_wkd_val >= l_inst_set(i).mn_hrs_num
1601 and l_rt_hrs_wkd_val < l_mx_hrs_num )
1602 or
1603 (l_inst_set(i).no_mn_hrs_wkd_flag = 'Y' and
1604 l_rt_hrs_wkd_val < l_mx_hrs_num )
1605 or
1606 (l_rt_hrs_wkd_val >= l_inst_set(i).mn_hrs_num and
1607 l_inst_set(i).no_mx_hrs_wkd_flag = 'Y'));
1608 --
1609 if l_ok is null or l_rt_hrs_wkd_val is null then
1610 l_ok := false;
1611 end if;
1612
1613 if l_ok and l_inst_set(i).excld_flag = 'N' then
1614 exit;
1615 elsif l_ok and l_inst_set(i).excld_flag = 'Y' then
1616 --
1617 -- raise ben_evaluate_rate_profiles.g_profile_failed;
1618 l_ok := false;
1619 exit ;
1620 --
1621 elsif (not l_ok) and l_inst_set(i).excld_flag = 'Y' then
1622 -- Bug 2100564
1623 l_ok := true ;
1624 --exit ;
1625 --
1626 elsif l_inst_set(i).excld_flag = 'N' then
1627 l_rows_found := true;
1628 end if;
1629
1630 end loop;
1631
1632 end if;
1633
1634 if l_rows_found and not l_ok then
1635 raise ben_evaluate_rate_profiles.g_profile_failed;
1636 end if;
1637
1638 end check_hrs_wkd;
1639 --
1640 -- ----------------------------------------------------------
1641 -- Labor union membership check.
1642 -- ----------------------------------------------------------
1643 procedure check_lbr_union
1644 (p_vrbl_rt_prfl_id in number
1645 ,p_person_id in number
1646 ,p_business_group_id in number
1647 ,p_effective_date in date
1648 ,p_lf_evt_ocrd_dt in date
1649 ,p_labour_union_member_flag in varchar2) is
1650 --
1651 l_inst_set ben_rt_prfl_cache.g_lbrmmbr_inst_tbl;
1652 l_inst_count number;
1653 l_ok boolean := false;
1654 l_rows_found boolean := false;
1655 --
1656 begin
1657 --
1658 -- Get the data from the cache.
1659 --
1660 ben_rt_prfl_cache.get_rt_prfl_cache
1661 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
1662 ,p_effective_date => p_effective_date
1663 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
1664 ,p_business_group_id => p_business_group_id
1665 ,p_inst_set => l_inst_set
1666 ,p_inst_count => l_inst_count);
1667 --
1668 if l_inst_count > 0 then
1669 --
1670 -- Data found. Loop through to see if excld flag is on or off.
1671 --
1672 l_rows_found := true;
1673 --
1674 for i in l_inst_set.first..l_inst_set.last loop
1675 --
1676 l_ok := l_inst_set(i).lbr_mmbr_flag = p_labour_union_member_flag;
1677 --
1678 if l_ok is null or p_labour_union_member_flag is null then
1679 --
1680 l_ok := false;
1681 --
1682 end if;
1683 --
1684 if l_ok and l_inst_set(i).excld_flag = 'N' then
1685 --
1686 exit;
1687 --
1688 elsif l_ok and l_inst_set(i).excld_flag = 'Y' then
1689 --
1690 -- raise g_criteria_failed;
1691 l_ok := false;
1692 exit ;
1693 --
1694 elsif (not l_ok) and l_inst_set(i).excld_flag = 'Y' then
1695 -- Bug 2100564
1696 l_ok := true ;
1697 --exit ;
1698 --
1699 elsif l_inst_set(i).excld_flag = 'N' then
1700 --
1701 l_rows_found := true;
1702 --
1703 end if;
1704 --
1705 end loop;
1706 --
1707 end if;
1708 --
1709 if l_rows_found and not l_ok then
1710 --
1711 raise g_criteria_failed;
1712 --
1713 end if;
1714 --
1715 end check_lbr_union;
1716 --
1717 -- -----------------------------------------------
1718 -- Legal entity check.
1719 -- -----------------------------------------------
1720 --
1721 procedure check_lgl_enty
1722 (p_vrbl_rt_prfl_id in number
1723 ,p_person_id in number
1724 ,p_business_group_id in number
1725 ,p_effective_date in date
1726 ,p_lf_evt_ocrd_dt in date
1727 ,p_gre_id in varchar2) is
1728 --
1729 l_inst_set ben_rt_prfl_cache.g_lglenty_inst_tbl;
1730 l_inst_count number;
1731 l_ok boolean := false;
1732 l_rows_found boolean := false;
1733 --
1734 begin
1735 --
1736 -- Get the data from the cache.
1737 --
1738 ben_rt_prfl_cache.get_rt_prfl_cache
1739 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
1740 ,p_effective_date => p_effective_date
1741 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
1742 ,p_business_group_id => p_business_group_id
1743 ,p_inst_set => l_inst_set
1744 ,p_inst_count => l_inst_count);
1745 --
1746 if l_inst_count > 0 then
1747 --
1748 -- Data found. Loop through to see if excld flag is on or off.
1749 --
1750 l_rows_found := true;
1751 --
1752 for i in l_inst_set.first..l_inst_set.last loop
1753 --
1754 l_ok := l_inst_set(i).organization_id = p_gre_id;
1755 --
1756 if l_ok is null or p_gre_id is null then
1757 --
1758 l_ok := false;
1759 --
1760 end if;
1761 --
1762 if l_ok and l_inst_set(i).excld_flag = 'N' then
1763 --
1764 exit;
1765 --
1766 elsif l_ok and l_inst_set(i).excld_flag = 'Y' then
1767 --
1768 -- raise g_criteria_failed;
1769 l_ok := false;
1770 exit ;
1771 --
1772 elsif (not l_ok) and l_inst_set(i).excld_flag = 'Y' then
1773 -- Bug 2100564
1774 l_ok := true ;
1775 -- exit ;
1776 --
1777 elsif l_inst_set(i).excld_flag = 'N' then
1778 --
1779 l_rows_found := true;
1780 --
1781 end if;
1782 --
1783 end loop;
1784 --
1785 end if;
1786 --
1787 if l_rows_found and not l_ok then
1788 --
1789 raise g_criteria_failed;
1790 --
1791 end if;
1792 --
1793 end check_lgl_enty;
1794 --
1795 -- ---------------------------------------------------
1796 -- Leave of absence check.
1797 -- ---------------------------------------------------
1798 --
1799 procedure check_loa_rsn
1800 (p_vrbl_rt_prfl_id in number
1801 ,p_person_id in number
1802 ,p_business_group_id in number
1803 ,p_effective_date in date
1804 ,p_lf_evt_ocrd_dt in date) is
1805 --
1806 l_inst_set ben_rt_prfl_cache.g_loa_inst_tbl;
1807 l_inst_count number;
1808 l_ok boolean := false;
1809 l_rows_found boolean := false;
1810 l_effective_date date;
1811 l_dummy varchar2(1);
1812 --
1813 -- FONM : No need to modify
1814 --
1815 cursor c_get_absence_type(p_absence_attendance_type_id in number,
1816 p_abs_attendance_reason_id in number) is
1817 select null
1818 from per_absence_attendances abs
1819 where abs.person_id = p_person_id
1820 and abs.absence_attendance_type_id = p_absence_attendance_type_id
1821 and nvl(abs.abs_attendance_reason_id,-1) =
1822 nvl(p_abs_attendance_reason_id,nvl(abs.abs_attendance_reason_id,-1))
1823 and l_effective_date
1824 between nvl(abs.date_start,l_effective_date) and
1825 nvl(abs.date_end,l_effective_date)
1826 and abs.business_group_id = p_business_group_id;
1827 --
1828 begin
1829 --
1830 -- Get the data from the cache.
1831 --
1832 ben_rt_prfl_cache.get_rt_prfl_cache
1833 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
1834 ,p_effective_date => p_effective_date
1835 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
1836 ,p_business_group_id => p_business_group_id
1837 ,p_inst_set => l_inst_set
1838 ,p_inst_count => l_inst_count);
1839 --
1840 if l_inst_count > 0 then
1841 --
1842 -- FONM
1843 if ben_manage_life_events.fonm = 'Y' then
1844 --
1845 l_effective_date := nvl(ben_manage_life_events.g_fonm_rt_strt_dt,
1846 nvl(ben_manage_life_events.g_fonm_cvg_strt_dt,
1847 nvl(p_lf_evt_ocrd_dt, p_effective_date)));
1848 else
1849 --
1850 l_effective_date := nvl(p_lf_evt_ocrd_dt, p_effective_date);
1851 --
1852 end if;
1853 --
1854 l_rows_found:=true;
1855 --
1856 for i in l_inst_set.first..l_inst_set.last loop
1857 --
1858 open c_get_absence_type(l_inst_set(i).absence_attendance_type_id,
1859 l_inst_set(i).abs_attendance_reason_id);
1860 --
1861 fetch c_get_absence_type into l_dummy;
1862 --
1863 if c_get_absence_type%found then
1864 --
1865 hr_utility.set_location ('c_get_absence_type found',88);
1866 --
1867 if l_inst_set(i).excld_flag = 'N' then
1868 --
1869 l_ok:=true;
1870 exit;
1871 --
1872 elsif l_inst_set(i).excld_flag = 'Y' then
1873 --
1874 close c_get_absence_type;
1875 -- raise g_criteria_failed;
1876 l_ok:= false ;
1877 exit ;
1878 --
1879 end if;
1880 --
1881 else
1882 --
1883 hr_utility.set_location ('c_get_absence_type not found',88);
1884 --
1885 if l_inst_set(i).excld_flag = 'N' then
1886 --
1887 l_rows_found:=true;
1888 --
1889 elsif l_inst_set(i).excld_flag = 'Y' then
1890 -- Bug 2100564
1891 l_ok := true ;
1892 -- exit ;
1893 --
1894 end if;
1895 --
1896 end if;
1897 --
1898 close c_get_absence_type;
1899 --
1900 end loop;
1901 --
1902 if l_rows_found and not l_ok then
1903 --
1904 raise g_criteria_failed;
1905 --
1906 end if;
1907 --
1908 end if;
1909 --
1910 end check_loa_rsn;
1911 --
1912 -- ---------------------------------------------------------
1913 -- Organization unit check.
1914 -- ---------------------------------------------------------
1915 --
1916 procedure check_org_unit
1917 (p_vrbl_rt_prfl_id in number
1918 ,p_person_id in number
1919 ,p_business_group_id in number
1920 ,p_effective_date in date
1921 ,p_lf_evt_ocrd_dt in date
1922 ,p_org_id in number) is
1923 --
1924 l_inst_set ben_rt_prfl_cache.g_org_inst_tbl;
1925 l_inst_count number;
1926 l_ok boolean := false;
1927 l_rows_found boolean := false;
1928 --
1929 begin
1930 --
1931 -- Get the data from the cache.
1932 --
1933 ben_rt_prfl_cache.get_rt_prfl_cache
1934 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
1935 ,p_effective_date => p_effective_date
1936 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
1937 ,p_business_group_id => p_business_group_id
1938 ,p_inst_set => l_inst_set
1939 ,p_inst_count => l_inst_count);
1940 --
1941 if l_inst_count > 0 then
1942 --
1943 -- Data found. Loop through to see if excld flag is on or off.
1944 --
1945 l_rows_found := true;
1946 --
1947 for i in l_inst_set.first..l_inst_set.last loop
1948 --
1949 l_ok := l_inst_set(i).organization_id = p_org_id;
1950 --
1951 if l_ok is null or p_org_id is null then
1952 --
1953 l_ok := false;
1954 --
1955 end if;
1956 --
1957 if l_ok and l_inst_set(i).excld_flag = 'N' then
1958 --
1959 exit;
1960 --
1961 elsif l_ok and l_inst_set(i).excld_flag = 'Y' then
1962 --
1963 -- raise g_criteria_failed;
1964 l_ok := false;
1965 exit ;
1966 --
1967 elsif (not l_ok) and l_inst_set(i).excld_flag = 'Y' then
1968 -- Bug 2100564
1969 l_ok := true ;
1970 -- exit ;
1971 --
1972 elsif l_inst_set(i).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_rows_found and not l_ok then
1983 --
1984 raise g_criteria_failed;
1985 --
1986 end if;
1987 --
1988 end check_org_unit;
1989 --
1990 -- -----------------------------------------------------------
1991 -- Person type check.
1992 -- -----------------------------------------------------------
1993 --
1994 procedure check_per_typ
1995 (p_vrbl_rt_prfl_id in number
1996 ,p_person_id in number
1997 ,p_business_group_id in number
1998 ,p_effective_date in date
1999 ,p_lf_evt_ocrd_dt in date
2000 ,p_person_type in ben_person_object.
2001 g_cache_typ_table) is
2002 --
2003 l_inst_set ben_rt_prfl_cache.g_pertyp_inst_tbl;
2004 l_inst_count number;
2005 l_ok boolean := false;
2006 l_rows_found boolean := false;
2007 --
2008 begin
2009 --
2010 -- Get the data from the cache.
2011 --
2012 hr_utility.set_location('p_vrbl_rt_prfl_id -> '||p_vrbl_rt_prfl_id,11);
2013
2014 ben_rt_prfl_cache.get_rt_prfl_cache
2015 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
2016 ,p_effective_date => p_effective_date
2017 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
2018 ,p_business_group_id => p_business_group_id
2019 ,p_inst_set => l_inst_set
2020 ,p_inst_count => l_inst_count);
2021 --
2022 if l_inst_count > 0 then
2023 --
2024 -- Data found. Loop through to see if excld flag is on or off.
2025 --
2026 <<outer>>
2027 --
2028 for i in l_inst_set.first..l_inst_set.last loop
2029 --
2030 l_rows_found := true;
2031 --
2032 for l_count in p_person_type.first..p_person_type.last loop
2033 --
2034 hr_utility.set_location(l_inst_set(i).person_type_id,10);
2035 --
2036 -- To support user creatd person type use person_type_id instead of per_typ_cd
2037 --
2038 /*l_ok := l_inst_set(i).per_typ_cd =
2039 p_person_type(l_count).system_person_type;*/
2040 l_ok := l_inst_set(i).person_type_id =
2041 p_person_type(l_count).person_type_id;
2042 --
2043 -- To support user creatd person type use person_type_id instead of per_typ_cd
2044 --
2045 /*if l_ok is null or p_person_type(l_count).system_person_type is null then */
2046 if l_ok is null or p_person_type(l_count).person_type_id is null then
2047 --
2048 l_ok := false;
2049 --
2050 end if;
2051 --
2052 if l_ok and l_inst_set(i).excld_flag = 'N' then
2053 --
2054 exit outer;
2055 --
2056 elsif l_ok and l_inst_set(i).excld_flag = 'Y' then
2057 --
2058 l_rows_found := true;
2059 l_ok := false;
2060 exit outer;
2061 --
2062 elsif (not l_ok) and l_inst_set(i).excld_flag = 'Y' then
2063 -- Bug 2100564
2064 l_rows_found := true;
2065 l_ok := true ;
2066 -- exit outer;
2067 --
2068 elsif l_inst_set(i).excld_flag = 'N' then
2069 --
2070 l_rows_found := true;
2071 --
2072 end if;
2073 --
2074 end loop;
2075 --
2076 end loop;
2077 --
2078 end if;
2079 --
2080 if l_rows_found and not l_ok then
2081 --
2082 raise ben_evaluate_rate_profiles.g_profile_failed;
2083 --
2084 end if;
2085 --
2086 end check_per_typ;
2087 --
2088 -- ---------------------------------------------------------------
2089 -- Zip code range check.
2090 -- ---------------------------------------------------------------
2091 --
2092 PROCEDURE check_zip_code_rng
2093 (p_vrbl_rt_prfl_id IN NUMBER
2094 ,p_person_id IN NUMBER
2095 ,p_business_group_id IN NUMBER
2096 ,p_effective_date IN DATE
2097 ,p_lf_evt_ocrd_dt IN DATE
2098 ,p_postal_code IN VARCHAR2) IS
2099 --
2100 --
2101 -- FONM
2102 --
2103 CURSOR get_elig_zip(p_vrbl_rt_prfl_id IN NUMBER
2104 ,cv_effective_date IN DATE) IS
2105 SELECT epz.pstl_zip_rng_id,epz.excld_flag
2106 FROM ben_pstl_zip_rt_f epz
2107 WHERE epz.vrbl_rt_prfl_id = p_vrbl_rt_prfl_id
2108 AND cv_effective_date -- FONM NVL(p_lf_evt_ocrd_dt, p_effective_date)
2109 BETWEEN epz.effective_start_date
2110 AND epz.effective_end_date;
2111 --
2112 CURSOR get_zip_ranges(p_pstl_zip_rng_id IN NUMBER
2113 ,p_postal_code IN VARCHAR2
2114 ,cv_effective_date in date) IS
2115 SELECT zip.from_value, zip.to_value
2116 FROM ben_pstl_zip_rng_f zip
2117 WHERE zip.pstl_zip_rng_id = p_pstl_zip_rng_id
2118 AND LENGTH(p_postal_code) >= LENGTH(zip.from_value)
2119 AND (SUBSTR( nvl(p_postal_code,'-1'),1,LENGTH(zip.from_value))
2120 BETWEEN zip.from_value AND NVL(zip.to_value,p_postal_code)
2121 OR NVL(p_postal_code,'-1') = zip.from_value
2122 OR nvl(p_postal_code,'-1') = zip.to_value)
2123 AND cv_effective_date
2124 BETWEEN zip.effective_start_date
2125 AND zip.effective_end_date;
2126
2127 l_rows_found BOOLEAN := FALSE;
2128 l_pstl_zip_rng_id NUMBER(15);
2129 l_excld_flag VARCHAR2(1);
2130 l_from_value VARCHAR2(10);
2131 l_to_value VARCHAR2(10);
2132 --
2133 -- FONM
2134 l_fonm_cvg_strt_dt date;
2135 --
2136 BEGIN
2137 --
2138 -- Get the data from the cache.
2139 hr_utility.set_location('entering chck_zip_code', 10);
2140 --
2141 -- FONM
2142 if ben_manage_life_events.fonm = 'Y' then
2143 --
2144 l_fonm_cvg_strt_dt := nvl(ben_manage_life_events.g_fonm_rt_strt_dt,
2145 ben_manage_life_events.g_fonm_cvg_strt_dt);
2146 --
2147 end if;
2148 --
2149 -- FONM
2150 --
2151 OPEN get_elig_zip(p_vrbl_rt_prfl_id,nvl(l_fonm_cvg_strt_dt, nvl(p_lf_evt_ocrd_dt, p_effective_date)));
2152 <<range_loop>>
2153 LOOP
2154 FETCH get_elig_zip into l_pstl_zip_rng_id,l_excld_flag;
2155 EXIT WHEN get_elig_zip%NOTFOUND;
2156 l_rows_found := FALSE;
2157 OPEN get_zip_ranges(l_pstl_zip_rng_id,p_postal_code,
2158 nvl(l_fonm_cvg_strt_dt, nvl(p_lf_evt_ocrd_dt, p_effective_date)));
2159 <<zip_loop>>
2160 LOOP
2161 FETCH get_zip_ranges INTO l_from_value,l_to_value;
2162 EXIT WHEN get_zip_ranges%NOTFOUND;
2163 --
2164 hr_utility.set_location('person zip '||p_postal_code ,2219.3);
2165 hr_utility.set_location('from zip '||l_from_value ,2219.3);
2166 hr_utility.set_location('to zip '||l_to_value ,2219.3);
2167 --
2168 l_rows_found := TRUE;
2169 EXIT;
2170 --
2171 END LOOP zip_loop;
2172 --
2173 IF (p_postal_code is null)
2174 OR (l_rows_found AND l_excld_flag = 'N')
2175 THEN
2176 --
2177 close get_zip_ranges;
2178 l_rows_found := TRUE;
2179 exit;
2180 --
2181 ELSIF ( not l_rows_found AND l_excld_flag = 'Y' ) THEN
2182 --
2183 l_rows_found := TRUE;
2184 --
2185 ELSIF ( l_rows_found AND l_excld_flag = 'Y') THEN
2186 --
2187 l_rows_found := FALSE ;
2188 close get_zip_ranges;
2189 exit;
2190 --
2191 END IF;
2192 --
2193 CLOSE get_zip_ranges;
2194 --
2195 END LOOP range_loop;
2196 --
2197 CLOSE get_elig_zip;
2198 --
2199 if not l_rows_found then
2200 --
2201 RAISE ben_evaluate_rate_profiles.g_profile_failed;
2202 --
2203 end if;
2204 --
2205 hr_utility.set_location('leaving chck_zip_code', 10);
2206 --
2207 END check_zip_code_rng;
2208 --
2209 -- --------------------------------------------------------
2210 -- Payroll check.
2211 -- --------------------------------------------------------
2212 --
2213 procedure check_pyrl
2214 (p_vrbl_rt_prfl_id in number
2215 ,p_person_id in number
2216 ,p_business_group_id in number
2217 ,p_effective_date in date
2218 ,p_lf_evt_ocrd_dt in date
2219 ,p_payroll_id in number) is
2220 --
2221 l_inst_set ben_rt_prfl_cache.g_pyrl_inst_tbl;
2222 l_inst_count number;
2223 l_ok boolean := false;
2224 l_rows_found boolean := false;
2225 --
2226 begin
2227 --
2228 -- Get the data from the cache.
2229 --
2230 ben_rt_prfl_cache.get_rt_prfl_cache
2231 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
2232 ,p_effective_date => p_effective_date
2233 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
2234 ,p_business_group_id => p_business_group_id
2235 ,p_inst_set => l_inst_set
2236 ,p_inst_count => l_inst_count);
2237 --
2238 if l_inst_count > 0 then
2239 --
2240 -- Data found. Loop through to see if excld flag is on or off.
2241 --
2242 l_rows_found := true;
2243 --
2244 for i in l_inst_set.first..l_inst_set.last loop
2245 --
2246 l_ok := p_payroll_id = l_inst_set(i).payroll_id;
2247 --
2248 if l_ok is null or p_payroll_id is null then
2249 --
2250 l_ok := false;
2251 --
2252 end if;
2253 --
2254 if l_ok and l_inst_set(i).excld_flag = 'N' then
2255 --
2256 exit;
2257 --
2258 elsif l_ok and l_inst_set(i).excld_flag = 'Y' then
2259 --
2260 -- raise g_criteria_failed;
2261 l_ok := false;
2262 exit ;
2263 --
2264 elsif (not l_ok) and l_inst_set(i).excld_flag = 'Y' then
2265 -- Bug 2100564
2266 l_ok := true ;
2267 -- exit ;
2268 --
2269 elsif l_inst_set(i).excld_flag = 'N' then
2270 --
2271 l_rows_found := true;
2272 --
2273 end if;
2274 --
2275 end loop;
2276 --
2277 end if;
2278 --
2279 if l_rows_found and not l_ok then
2280 --
2281 raise g_criteria_failed;
2282 --
2283 end if;
2284 --
2285 end check_pyrl;
2286 --
2287 -- ----------------------------------------------------------
2288 -- Pay basis check.
2289 -- ----------------------------------------------------------
2290 --
2291 procedure check_py_bss
2292 (p_vrbl_rt_prfl_id in number
2293 ,p_person_id in number
2294 ,p_business_group_id in number
2295 ,p_effective_date in date
2296 ,p_lf_evt_ocrd_dt in date
2297 ,p_pay_basis_id in number) is
2298 --
2299 l_inst_set ben_rt_prfl_cache.g_py_bss_inst_tbl;
2300 l_inst_count number;
2301 l_ok boolean := false;
2302 l_rows_found boolean := false;
2303 --
2304 begin
2305 --
2306 -- Get the data from the cache.
2307 --
2308 ben_rt_prfl_cache.get_rt_prfl_cache
2309 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
2310 ,p_effective_date => p_effective_date
2311 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
2312 ,p_business_group_id => p_business_group_id
2313 ,p_inst_set => l_inst_set
2314 ,p_inst_count => l_inst_count);
2315 --
2316 if l_inst_count > 0 then
2317 --
2318 -- Data found. Loop through to see if excld flag is on or off.
2319 --
2320 l_rows_found := true;
2321 --
2322 for i in l_inst_set.first..l_inst_set.last loop
2323 --
2324 l_ok := p_pay_basis_id = l_inst_set(i).pay_basis_id;
2325 --
2326 if l_ok is null or p_pay_basis_id is null then
2327 --
2328 l_ok := false;
2329 --
2330 end if;
2331 --
2332 if l_ok and l_inst_set(i).excld_flag = 'N' then
2333 --
2334 exit;
2335 --
2336 elsif l_ok and l_inst_set(i).excld_flag = 'Y' then
2337 --
2338 -- raise g_criteria_failed;
2339 l_ok := false;
2340 exit ;
2341 --
2342 elsif (not l_ok) and l_inst_set(i).excld_flag = 'Y' then
2343 -- Bug 2100564
2344 l_ok := true ;
2345 --exit ;
2346 --
2347 elsif l_inst_set(i).excld_flag = 'N' then
2348 --
2349 l_rows_found := true;
2350 --
2351 end if;
2352 --
2353 end loop;
2354 --
2355 end if;
2356 --
2357 if l_rows_found and not l_ok then
2358 --
2359 raise g_criteria_failed;
2360 --
2361 end if;
2362 --
2363 end check_py_bss;
2364 --
2365 -- ---------------------------------------------------------
2366 -- Scheduled hours check.
2367 -- ---------------------------------------------------------
2368 --
2369 procedure check_sched_hrs
2370 (p_vrbl_rt_prfl_id in number
2371 ,p_person_id in number
2372 ,p_business_group_id in number
2373 ,p_effective_date in date
2374 ,p_lf_evt_ocrd_dt in date
2375 ,p_normal_hrs in number
2376 ,p_frequency in varchar2
2377 ,p_per_in_ler_id in number
2378 ,p_assignment_id in number
2379 ,p_organization_id in number
2380 ,p_pgm_id in number
2381 ,p_pl_id in number
2382 ,p_pl_typ_id in number
2383 ,p_opt_id in number
2384 ,p_oipl_id in number
2385 ,p_ler_id in number
2386 ,p_jurisdiction_code in varchar2
2387 ) is
2388 --
2389 l_inst_set ben_rt_prfl_cache.g_scdhrs_inst_tbl;
2390 l_inst_count number;
2391 l_ok boolean := false;
2392 l_rows_found boolean := false;
2393
2394 l_min_hours ben_schedd_hrs_rt_f.hrs_num%type;
2395 l_max_hours ben_schedd_hrs_rt_f.max_hrs_num%type;
2396 l_freq_cd ben_schedd_hrs_rt_f.freq_cd%type;
2397 l_person_freq_cd ben_schedd_hrs_rt_f.freq_cd%type;
2398 l_person_hours number;
2399 l_det_dt date;
2400 l_output ff_exec.outputs_t;
2401 l_pl_rec ben_pl_f%rowtype;
2402 l_pgm_rec ben_pgm_f%rowtype;
2403 l_package varchar2(80) := g_package||'.check_sched_hrs';
2404 --
2405 cursor c_scheduled_hours
2406 (c_effective_date date,
2407 c_person_id number,
2408 c_freq_cd varchar2,
2409 c_business_group_id number) is
2410 select sum(normal_hours)
2411 from per_all_assignments_f
2412 where person_id = c_person_id
2413 and c_effective_date between effective_start_date and effective_end_date
2414 and frequency = c_freq_cd
2415 and business_group_id = c_business_group_id;
2416
2417 cursor c_asg_scheduled_hours
2418 (c_effective_date date,
2419 c_assignment_id number,
2420 c_business_group_id number) is
2421 select normal_hours, frequency
2422 from per_all_assignments_f
2423 where assignment_id = c_assignment_id
2424 and c_effective_date between effective_start_date and effective_end_date
2425 and business_group_id = c_business_group_id;
2426 --
2427 begin
2428 --
2429 -- Get the data from the cache.
2430 --
2431 ben_rt_prfl_cache.get_rt_prfl_cache
2432 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
2433 ,p_effective_date => p_effective_date
2434 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
2435 ,p_business_group_id => p_business_group_id
2436 ,p_inst_set => l_inst_set
2437 ,p_inst_count => l_inst_count);
2438 --
2439 if l_inst_count > 0 then
2440 --
2441 -- Data found. Loop through to see if excld flag is on or off.
2442 --
2443 l_rows_found := true;
2444 --
2445 for i in l_inst_set.first..l_inst_set.last loop
2446 --
2447 -- If there is a rule evaluate the rule
2448 if l_inst_set(i).schedd_hrs_rl is not null then
2449 l_output := benutils.formula
2450 (p_formula_id => l_inst_set(i).schedd_hrs_rl
2451 ,p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date)
2452 ,p_business_group_id => p_business_group_id
2453 ,p_assignment_id => p_assignment_id
2454 ,p_organization_id => p_organization_id
2455 ,p_pgm_id => p_pgm_id
2456 ,p_pl_id => p_pl_id
2457 ,p_pl_typ_id => p_pl_typ_id
2458 ,p_opt_id => p_opt_id
2459 ,p_ler_id => p_ler_id
2460 ,p_jurisdiction_code => p_jurisdiction_code -- FONM
2461 ,p_param1 => 'BEN_IV_RT_STRT_DT'
2462 ,p_param1_value => fnd_date.date_to_canonical(ben_manage_life_events.g_fonm_rt_strt_dt)
2463 ,p_param2 => 'BEN_IV_CVG_STRT_DT'
2464 ,p_param2_value => fnd_date.date_to_canonical(ben_manage_life_events.g_fonm_cvg_strt_dt));
2465
2466 --
2467 for l_count in l_output.first..l_output.last loop
2468 --
2469 declare
2470 invalid_param exception;
2471 begin
2472 --
2473 if l_output(l_count).name = 'MIN_HOURS' then
2474 --
2475 l_min_hours := to_number(l_output(l_count).value);
2476 --
2477 elsif l_output(l_count).name = 'MAX_HOURS' then
2478 --
2479 l_max_hours := to_number(l_output(l_count).value);
2480 --
2481 elsif l_output(l_count).name = 'FREQUENCY' then
2482 --
2483 l_freq_cd := l_output(l_count).value;
2484 --
2485 else
2486 --
2487 -- Account for cases where formula returns an unknown
2488 -- variable name
2489 --
2490 fnd_message.set_name('BEN','BEN_92310_FORMULA_RET_PARAM_');
2491 fnd_message.set_token('PROC',l_package);
2492 fnd_message.set_token('FORMULA', l_inst_set(i).schedd_hrs_rl);
2493 fnd_message.set_token('PARAMETER',l_output(l_count).name);
2494
2495 -- Handling this particular exception seperately.
2496 raise invalid_param;
2497 --
2498 end if;
2499 --
2500 -- Code for type casting errors from formula return variables
2501 --
2502 exception
2503 --
2504 -- Code appended for bug# 2620550
2505 when invalid_param then
2506 fnd_message.raise_error;
2507 when others then
2508 --
2509 fnd_message.set_name('BEN','BEN_92311_FORMULA_VAL_PARAM');
2510 fnd_message.set_token('PROC',l_package);
2511 fnd_message.set_token('FORMULA', l_inst_set(i).schedd_hrs_rl);
2512 fnd_message.set_token('PARAMETER',l_output(l_count).name);
2513 fnd_message.raise_error;
2514 --
2515 end;
2516 end loop;
2517 --
2518 if l_min_hours is null and l_max_hours is null then
2519 fnd_message.set_name('BEN','BEN_92310_FORMULA_RET_PARAM_');
2520 fnd_message.set_token('PROC',l_package);
2521 fnd_message.set_token('FORMULA', l_inst_set(i).schedd_hrs_rl);
2522 fnd_message.set_token('PARAMETER','MIN_HOURS');
2523 fnd_message.raise_error;
2524 end if;
2525
2526 if l_freq_cd is null then
2527 fnd_message.set_name('BEN','BEN_92310_FORMULA_RET_PARAM_');
2528 fnd_message.set_token('PROC',l_package);
2529 fnd_message.set_token('FORMULA', l_inst_set(i).schedd_hrs_rl);
2530 fnd_message.set_token('PARAMETER','FREQUENCY');
2531 fnd_message.raise_error;
2532 end if;
2533 else
2534 l_min_hours := l_inst_set(i).hrs_num;
2535 l_max_hours := l_inst_set(i).max_hrs_num;
2536 l_freq_cd := l_inst_set(i).freq_cd;
2537 end if;
2538 -- Get the determination date from determination_cd
2539 if l_inst_set(i).determination_cd is not null or l_inst_set(i).determination_rl is not null then
2540 ben_determine_date.main
2541 (p_date_cd => l_inst_set(i).determination_cd,
2542 p_per_in_ler_id => p_per_in_ler_id,
2543 p_person_id => p_person_id,
2544 p_pgm_id => p_pgm_id,
2545 p_pl_id => p_pl_id,
2546 p_oipl_id => p_oipl_id,
2547 p_business_group_id => p_business_group_id,
2548 p_formula_id => l_inst_set(i).determination_rl,
2549 p_effective_date => p_effective_date,
2550 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
2551 p_fonm_cvg_strt_dt => ben_manage_life_events.g_fonm_cvg_strt_dt,
2552 p_fonm_rt_strt_dt => ben_manage_life_events.g_fonm_rt_strt_dt,
2553 p_returned_date => l_det_dt );
2554 end if;
2555
2556
2557 --
2558
2559
2560 --
2561 if l_det_dt is null then
2562 -- FONM
2563 l_det_dt := nvl(ben_manage_life_events.g_fonm_rt_strt_dt,
2564 nvl(ben_manage_life_events.g_fonm_cvg_strt_dt,
2565 nvl(p_lf_evt_ocrd_dt,p_effective_date)));
2566 end if;
2567
2568 -- get Scheduled hour details from the assignment records
2569 if p_pl_id is not null then
2570 ben_comp_object.get_object(p_pl_id => p_pl_id
2571 ,p_rec => l_pl_rec);
2572 end if;
2573
2574 if p_pgm_id is not null then
2575 ben_comp_object.get_object(p_pgm_id => p_pgm_id
2576 ,p_rec => l_pgm_rec);
2577 end if;
2578 --
2579 if l_pl_rec.use_all_asnts_for_rt_flag = 'Y' or l_pgm_rec.uses_all_asmts_for_rts_flag = 'Y' then
2580 open c_scheduled_hours
2581 (l_det_dt,p_person_id,
2582 l_freq_cd, p_business_group_id);
2583 fetch c_scheduled_hours into l_person_hours;
2584 close c_scheduled_hours;
2585
2586 l_person_freq_cd := l_freq_cd;
2587 else
2588 open c_asg_scheduled_hours
2589 (l_det_dt,p_assignment_id,
2590 p_business_group_id);
2591 fetch c_asg_scheduled_hours into l_person_hours, l_person_freq_cd;
2592 close c_asg_scheduled_hours;
2593 end if;
2594
2595 -- Applying the rounding code
2596 if (l_inst_set(i).rounding_cd is not null or l_inst_set(i).rounding_rl is not null)
2597 and l_person_hours is not null then
2598 l_person_hours := benutils.do_rounding
2599 (p_rounding_cd => l_inst_set(i).rounding_cd,
2600 p_rounding_rl => l_inst_set(i).rounding_rl,
2601 p_value => l_person_hours,
2602 p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date));
2603 end if;
2604
2605 -- Evaluate
2606 if l_min_hours is not null and l_max_hours is null then
2607 l_ok := (l_person_hours >= l_min_hours) and l_person_freq_cd = l_freq_cd;
2608 elsif l_min_hours is null and l_max_hours is not null then
2609 l_ok := l_person_hours <= l_max_hours and l_person_freq_cd = l_freq_cd;
2610 else
2611 l_ok := l_person_hours between l_min_hours and l_max_hours
2612 and l_person_freq_cd = l_freq_cd;
2613 end if;
2614
2615 --
2616 if l_ok is null or p_normal_hrs is null or p_frequency is null then
2617 --
2618 l_ok := false;
2619 --
2620 end if;
2621 --
2622 if l_ok and l_inst_set(i).excld_flag = 'N' then
2623 --
2624 exit;
2625 --
2626 elsif l_ok and l_inst_set(i).excld_flag = 'Y' then
2627 --
2628 -- raise g_criteria_failed;
2629 l_ok := false;
2630 exit ;
2631 --
2632 elsif (not l_ok) and l_inst_set(i).excld_flag = 'Y' then
2633 -- Bug 2100564
2634 l_ok := true ;
2635 -- exit ;
2636 --
2637 elsif l_inst_set(i).excld_flag = 'N' then
2638 --
2639 l_rows_found := true;
2640 --
2641 end if;
2642 --
2643 end loop;
2644 --
2645 end if;
2646 --
2647 if l_rows_found and not l_ok then
2648 --
2649 raise g_criteria_failed;
2650 --
2651 end if;
2652 --
2653 end check_sched_hrs;
2654 --
2655 -- --------------------------------------------------------------
2656 -- Work location check.
2657 -- --------------------------------------------------------------
2658 --
2659 procedure check_wk_location
2660 (p_vrbl_rt_prfl_id in number
2661 ,p_person_id in number
2662 ,p_business_group_id in number
2663 ,p_effective_date in date
2664 ,p_lf_evt_ocrd_dt in date
2665 ,p_location_id in number) is
2666 --
2667 l_inst_set ben_rt_prfl_cache.g_wkloc_inst_tbl;
2668 l_inst_count number;
2669 l_ok boolean := false;
2670 l_rows_found boolean := false;
2671 --
2672 begin
2673 --
2674 ben_rt_prfl_cache.get_rt_prfl_cache
2675 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
2676 ,p_effective_date => p_effective_date
2677 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
2678 ,p_business_group_id => p_business_group_id
2679 ,p_inst_set => l_inst_set
2680 ,p_inst_count => l_inst_count);
2681 --
2682 if l_inst_count > 0 then
2683 -- Data found. Loop through to see if excld flag is on or off.
2684 l_rows_found := true;
2685 --
2686 for i in l_inst_set.first..l_inst_set.last loop
2687 --
2688 l_ok := p_location_id = l_inst_set(i).location_id;
2689 --
2690 if l_ok is null or p_location_id is null then
2691 --
2692 l_ok := false;
2693 --
2694 end if;
2695 --
2696 if l_ok and l_inst_set(i).excld_flag = 'N' then
2697 --
2698 exit;
2699 --
2700 elsif l_ok and l_inst_set(i).excld_flag = 'Y' then
2701 --
2702 -- raise g_criteria_failed;
2703 l_ok := false;
2704 exit ;
2705 --
2706 elsif (not l_ok) and l_inst_set(i).excld_flag = 'Y' then
2707 -- Bug 2100564
2708 l_rows_found := true;
2709 l_ok := true ;
2710 -- exit ;
2711 --
2712 elsif l_inst_set(i).excld_flag = 'N' then
2713 --
2714 l_rows_found := true;
2715 --
2716 end if;
2717 --
2718 end loop;
2719 --
2720 end if;
2721 --
2722 if l_rows_found and not l_ok then
2723 --
2724 raise g_criteria_failed;
2725 --
2726 end if;
2727 --
2728 end check_wk_location;
2729 --
2730 -- ---------------------------------------------------------------
2731 -- Service area check.
2732 -- ---------------------------------------------------------------
2733 --
2734
2735 PROCEDURE check_service_area
2736 (p_vrbl_rt_prfl_id IN NUMBER
2737 ,p_person_id IN NUMBER
2738 ,p_business_group_id IN NUMBER
2739 ,p_effective_date IN DATE
2740 ,p_lf_evt_ocrd_dt IN DATE
2741 ,p_postal_code IN VARCHAR2) IS
2742 --
2743 --
2744 -- FONM
2745 --
2746 CURSOR get_elig_svc (p_vrbl_rt_prfl_id IN NUMBER
2747 ,cv_effective_date IN DATE) IS
2748 SELECT sar.svc_area_id, sar.excld_flag
2749 FROM ben_svc_area_rt_f sar
2750 WHERE sar.vrbl_rt_prfl_id = p_vrbl_rt_prfl_id
2751 AND cv_effective_date -- FONM NVL(p_lf_evt_ocrd_dt, p_effective_date)
2752 BETWEEN sar.effective_start_date
2753 AND sar.effective_end_date;
2754 --
2755 /* NOT USED
2756 CURSOR get_zip_ranges(p_svc_area_id IN NUMBER
2757 ,p_postal_code in VARCHAR2
2758 ,cv_effective_date in date) IS
2759 SELECT zip.from_value, zip.to_value
2760 FROM ben_pstl_zip_rng_f zip
2761 WHERE zip.pstl_zip_rng_id IN (
2762 SELECT pstl_zip_rng_id
2763 FROM ben_svc_area_pstl_zip_rng_f rng
2764 WHERE rng.SVC_AREA_ID = p_svc_area_id
2765 AND cv_effective_date BETWEEN rng.effective_start_date
2766 AND rng.effective_end_date)
2767 AND LENGTH(p_postal_code) >= LENGTH(zip.from_value)
2768 AND (SUBSTR( NVL(p_postal_code,'-1'),1,LENGTH(zip.from_value))
2769 BETWEEN zip.from_value and NVL(zip.to_value,p_postal_code)
2770 OR NVL(p_postal_code,'-1') = zip.from_value
2771 OR NVL(p_postal_code,'-1') = zip.to_value)
2772 AND cv_effective_date BETWEEN zip.effective_start_date
2773 AND zip.effective_end_date;
2774 */
2775
2776 l_rows_found BOOLEAN := false;
2777 l_svc_area_id NUMBER(15);
2778 l_excld_flag VARCHAR2(1);
2779 l_from_value VARCHAR2(10);
2780 l_to_value VARCHAR2(10);
2781 l_ok BOOLEAN := false;
2782 --
2783 -- FONM
2784 l_fonm_cvg_strt_dt date;
2785 --
2786 BEGIN
2787 --
2788 -- FONM
2789 --
2790 if ben_manage_life_events.fonm = 'Y' then
2791 --
2792 l_fonm_cvg_strt_dt := nvl(ben_manage_life_events.g_fonm_rt_strt_dt,
2793 ben_manage_life_events.g_fonm_cvg_strt_dt);
2794 --
2795 end if;
2796 --
2797 -- Get the data from the cache.
2798 --
2799 -- Getting eligibility profile service area range by eligibility profile
2800 --
2801 OPEN get_elig_svc(p_vrbl_rt_prfl_id,
2802 nvl(l_fonm_cvg_strt_dt, nvl(p_lf_evt_ocrd_dt,p_effective_date)));
2803 <<range_loop>>
2804 LOOP
2805 FETCH get_elig_svc INTO l_svc_area_id,l_excld_flag;
2806 EXIT WHEN get_elig_svc%NOTFOUND;
2807 l_rows_found := FALSE;
2808 --
2809 ben_saz_cache.SAZRZR_Exists -- 9999 FONM
2810 (p_svc_area_id => l_svc_area_id
2811 ,p_zip_code => p_postal_code
2812 ,p_eff_date => p_effective_date -- FONM why not lf_evt_ocrd_dt passed?
2813 --
2814 ,p_exists => l_rows_found
2815 );
2816 --
2817 IF (l_rows_found AND l_excld_flag = 'N') THEN
2818 --
2819 l_rows_found := TRUE;
2820 l_ok := true;
2821 exit;
2822 --
2823 ELSIF ( NOT l_rows_found AND l_excld_flag = 'Y' ) then
2824 --
2825 l_rows_found := TRUE;
2826 l_ok := true;
2827 --
2828 ELSIF ( l_rows_found AND l_excld_flag = 'Y' ) then
2829 -- close get_elig_svc ;
2830 fnd_message.set_name('BEN','BEN_92225_SVC_AREA_PRFL_FAIL');
2831 -- raise g_criteria_failed;
2832 l_rows_found :=FALSE ;
2833 l_ok := false ;
2834 exit ;
2835 END IF;
2836 --
2837 END LOOP range_loop;
2838 CLOSE get_elig_svc;
2839 --
2840 if (NOT l_rows_found) and (not l_ok) then
2841 --
2842 RAISE ben_evaluate_rate_profiles.g_profile_failed;
2843 --
2844 End if;
2845 --
2846 --
2847 END check_service_area;
2848 --
2849 -- ---------------------------------------------------------------
2850 -- Hourly/Salary Code check
2851 -- ---------------------------------------------------------------
2852 --
2853 procedure check_hourly_salary
2854 (p_vrbl_rt_prfl_id in number
2855 ,p_business_group_id in number
2856 ,p_effective_date in date
2857 ,p_lf_evt_ocrd_dt in date
2858 ,p_hrly_slry in varchar2) is
2859 --
2860 l_inst_set ben_rt_prfl_cache.g_hrlyslrd_inst_tbl;
2861 l_inst_count number;
2862 l_ok boolean := false;
2863 l_rows_found boolean := false;
2864 --
2865 begin
2866 --
2867 -- Get the data from the cache.
2868 --
2869 ben_rt_prfl_cache.get_rt_prfl_cache
2870 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
2871 ,p_effective_date => p_effective_date
2872 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
2873 ,p_business_group_id => p_business_group_id
2874 ,p_inst_set => l_inst_set
2875 ,p_inst_count => l_inst_count);
2876 --
2877 if l_inst_count > 0 then
2878 --
2879 -- Data found. Loop through to see if excld flag is on or off.
2880 --
2881 l_rows_found := true;
2882 --
2883 for i in l_inst_set.first..l_inst_set.last loop
2884 --
2885 l_ok := p_hrly_slry = l_inst_set(i).hrly_slrd_cd;
2886 --
2887 if l_ok is null or p_hrly_slry is null then
2888 --
2889 l_ok := false;
2890 --
2891 end if;
2892 --
2893 if l_ok and l_inst_set(i).excld_flag = 'N' then
2894 --
2895 exit;
2896 --
2897 elsif l_ok and l_inst_set(i).excld_flag = 'Y' then
2898 --
2899 -- raise g_criteria_failed;
2900 l_ok := false;
2901 exit ;
2902 --
2903 elsif (not l_ok) and l_inst_set(i).excld_flag = 'Y' then
2904 -- Bug 2100564
2905 l_rows_found := true;
2906 l_ok := true ;
2907 -- exit ;
2908 --
2909 elsif l_inst_set(i).excld_flag = 'N' then
2910 --
2911 l_rows_found := true;
2912 --
2913 end if;
2914 --
2915 end loop;
2916 --
2917 end if;
2918 --
2919 if l_rows_found and not l_ok then
2920 --
2921 raise g_criteria_failed;
2922 --
2923 end if;
2924 --
2925 end check_hourly_salary;
2926 --
2927 -- ----------------------------------------------------
2928 -- Age check.
2929 -- ----------------------------------------------------
2930 --
2931 procedure check_age
2932 (p_vrbl_rt_prfl_id in number
2933 ,p_person_id in number
2934 ,p_per_dob in date
2935 ,p_business_group_id in number
2936 ,p_effective_date in date
2937 ,p_lf_evt_ocrd_dt in date
2938 ,p_elig_per_elctbl_chc_id in number
2939 ,p_pl_id in number default null
2940 ,p_pgm_id in number default null
2941 ,p_oipl_id in number default null
2942 ,p_plip_id in number default null
2943 ,p_opt_id in number default null
2944 ,p_per_in_ler_id in number default null
2945 ,p_currepe_row in ben_determine_rates.g_curr_epe_rec)
2946 is
2947 --
2948 l_proc varchar2(80) := g_package||'.check_age';
2949 --
2950 l_pl_id number;
2951 l_pgm_id number;
2952 l_per_in_ler_id number;
2953 l_oipl_id number;
2954 l_per_age number;
2955 l_dummy_date date;
2956 l_prtn_ovridn_flag varchar2(30);
2957 l_prtn_ovridn_thru_dt date;
2958 l_epo_row ben_derive_part_and_rate_facts.g_cache_structure;
2959 l_effective_date date ;
2960 --
2961
2962 --
2963 -- Grab needed parameters for passing into determin_age procedure.
2964 --
2965 cursor c_age_param is
2966 select epe.pl_id, epe.pgm_id, epe.oipl_id, epe.per_in_ler_id
2967 from ben_elig_per_elctbl_chc epe
2968 where epe.elig_per_elctbl_chc_id = p_elig_per_elctbl_chc_id;
2969 --
2970 l_inst_set ben_rt_prfl_cache.g_age_inst_tbl;
2971 l_inst_count number;
2972 l_ok boolean := false;
2973 l_rows_found boolean := false;
2974 --RCHASE
2975 l_dob date:=p_per_dob;
2976 l_mx_age_num number ;
2977 --
2978 begin
2979 --
2980 --- fonm2
2981 l_effective_date := nvl( p_lf_evt_ocrd_dt, p_effective_date ) ;
2982 if ben_manage_life_events.fonm = 'Y' then
2983 --
2984 l_effective_date := nvl(ben_manage_life_events.g_fonm_rt_strt_dt,
2985 nvl(ben_manage_life_events.g_fonm_cvg_strt_dt,
2986 l_effective_date));
2987 --
2988 end if;
2989
2990
2991 --hr_utility.set_location(l_proc||' Entering ',10);
2992 if p_elig_per_elctbl_chc_id is not null then
2993 --
2994 open c_age_param;
2995 --
2996 fetch c_age_param into l_pl_id, l_pgm_id, l_oipl_id, l_per_in_ler_id;
2997 --
2998 close c_age_param;
2999 --
3000 else
3001 --
3002 l_pl_id := p_pl_id;
3003 l_pgm_id := p_pgm_id;
3004 l_oipl_id := p_oipl_id;
3005 l_per_in_ler_id := p_per_in_ler_id;
3006 --
3007 end if;
3008 --
3009 -- Get the data from the cache.
3010 --
3011 ben_rt_prfl_cache.get_rt_prfl_cache
3012 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
3013 ,p_effective_date => p_effective_date
3014 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
3015 ,p_business_group_id => p_business_group_id
3016 ,p_inst_set => l_inst_set
3017 ,p_inst_count => l_inst_count);
3018 --hr_utility.set_location(l_proc||' Dn GRP Cac ',10);
3019 --
3020 if l_inst_count > 0 then
3021 --
3022 -- plan in program is overriden, capture the data from cache by passing plip_id
3023 if p_opt_id is null and p_pgm_id is not null then
3024 ben_pep_cache.get_pilpep_dets(
3025 p_person_id => p_person_id,
3026 p_business_group_id => p_business_group_id,
3027 p_effective_date => l_effective_date,
3028 p_pgm_id => p_pgm_id,
3029 p_plip_id => p_plip_id,
3030 p_inst_row => l_epo_row);
3031 l_prtn_ovridn_flag := l_epo_row.prtn_ovridn_flag;
3032 l_prtn_ovridn_thru_dt := l_epo_row.prtn_ovridn_thru_dt;
3033 l_per_age := l_epo_row.rt_age_val;
3034 elsif p_opt_id is not null and p_pgm_id is not null then
3035 ben_pep_cache.get_pilepo_dets(
3036 p_person_id => p_person_id,
3037 p_business_group_id => p_business_group_id,
3038 p_effective_date => l_effective_date,
3039 p_pgm_id => p_pgm_id,
3040 p_plip_id => p_plip_id,
3041 p_opt_id => p_opt_id,
3042 p_inst_row => l_epo_row);
3043 l_prtn_ovridn_flag := l_epo_row.prtn_ovridn_flag;
3044 l_prtn_ovridn_thru_dt := l_epo_row.prtn_ovridn_thru_dt;
3045 l_per_age := l_epo_row.rt_age_val;
3046 else
3047 hr_utility.set_location('Plan not in Program',10);
3048 l_prtn_ovridn_flag := p_currepe_row.prtn_ovridn_flag;
3049 l_prtn_ovridn_thru_dt := p_currepe_row.prtn_ovridn_thru_dt;
3050 l_per_age := p_currepe_row.rt_age_val;
3051 end if;
3052
3053 -- Data found. Loop through to see if excld flag is on or off.
3054 --
3055 l_rows_found := true;
3056 --
3057 for i in l_inst_set.first..l_inst_set.last loop
3058 --
3059 if l_inst_set(i).age_fctr_id is null then
3060 --
3061 fnd_message.set_name('BEN','BEN_91520_BERP_AGE_FCTR_ID');
3062 fnd_message.set_token('L_PROC',l_proc);
3063 fnd_message.set_token('PERSON_ID',to_char(p_person_id));
3064 fnd_message.set_token('VRBL_RT_PRFL_ID',to_char(p_vrbl_rt_prfl_id));
3065 fnd_message.set_token('PGM_ID',to_char(p_pgm_id));
3066 fnd_message.set_token('PL_ID',to_char(p_pl_id));
3067 fnd_message.set_token('OIPL_ID',to_char(p_oipl_id));
3068 fnd_message.set_token('LF_EVT_OCRD_DT',p_lf_evt_ocrd_dt);
3069 fnd_message.set_token('PER_IN_LER_ID',to_char(p_per_in_ler_id));
3070 fnd_message.set_token('ELIG_PER_ELCTBL_CHC_ID',to_char(p_elig_per_elctbl_chc_id));
3071 fnd_message.set_token('EFFECTIVE_DATE',p_effective_date);
3072 fnd_message.raise_error;
3073 --
3074 end if;
3075 --
3076 --RCHASE - v115.57 wrap l_prtn_ovridn_flag with NVL,
3077 -- possible NULL return instead of expected TRUE or FALSE
3078 if not (nvl(l_prtn_ovridn_flag,'N') = 'Y' and
3079 nvl(l_prtn_ovridn_thru_dt,hr_api.g_eot) > p_effective_date)
3080 then
3081 --
3082 ben_derive_factors.determine_age
3083 (p_person_id => p_person_id
3084 --RCHASE changed p_per_dob to l_dob
3085 ,p_per_dob => l_dob
3086 ,p_age_fctr_id => l_inst_set(i).age_fctr_id
3087 ,p_pgm_id => l_pgm_id
3088 ,p_pl_id => l_pl_id
3089 ,p_oipl_id => l_oipl_id
3090 ,p_per_in_ler_id => l_per_in_ler_id
3091 ,p_effective_date => p_effective_date
3092 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
3093 --fonm
3094 ,p_fonm_cvg_strt_dt => ben_manage_life_events.g_fonm_cvg_strt_dt
3095 ,p_fonm_rt_strt_dt => ben_manage_life_events.g_fonm_rt_strt_dt
3096 ,p_business_group_id => p_business_group_id
3097 ,p_perform_rounding_flg => TRUE
3098 ,p_value => l_per_age
3099 ,p_change_date => l_dummy_date);
3100 --
3101 end if;
3102 hr_utility.set_location(' age ' || l_per_age , 610.2);
3103 hr_utility.set_location(' mn age ' || l_inst_set(i).mn_age_num , 610.2);
3104 --
3105 l_mx_age_num := l_inst_set(i).mx_age_num ;
3106 --
3107 if ( l_inst_set(i).mx_age_num <> trunc(l_inst_set(i).mx_age_num) OR
3108 l_inst_set(i).mn_age_num <> trunc(l_inst_set(i).mn_age_num) ) then
3109 -- Decimal Case
3110 l_mx_age_num := l_inst_set(i).mx_age_num + 0.000000001 ;
3111 --
3112 else
3113 --
3114 l_mx_age_num := l_inst_set(i).mx_age_num + 1 ;
3115 --
3116 end if;
3117 --
3118 hr_utility.set_location(' l_mx_age_num '||l_mx_age_num , 610.10);
3119 --
3120 l_ok := (l_per_age >= l_inst_set(i).mn_age_num and
3121 l_per_age < l_mx_age_num )
3122 or
3123 (l_inst_set(i).no_mn_age_flag = 'Y' and
3124 l_per_age < l_mx_age_num )
3125 or
3126 (l_inst_set(i).no_mx_age_flag = 'Y' and
3127 l_per_age >= l_inst_set(i).mn_age_num);
3128 --
3129 if l_ok is null or l_per_age is null then
3130 --
3131 --hr_utility.set_location(' Step 1' ,99);
3132 l_ok := false;
3133 --
3134 end if;
3135 --
3136 if l_ok and l_inst_set(i).excld_flag = 'N' then
3137 --
3138 --hr_utility.set_location(' Step 2' ,99);
3139 exit;
3140 --
3141 elsif l_ok and l_inst_set(i).excld_flag = 'Y' then
3142 --
3143 --hr_utility.set_location(' Step 3' ,99);
3144 -- raise ben_evaluate_rate_profiles.g_profile_failed;
3145 l_ok := false;
3146 exit ;
3147 --
3148 elsif (not l_ok) and l_inst_set(i).excld_flag = 'Y' then
3149 -- Bug 2100564
3150 l_ok := true ;
3151 -- exit ;
3152 --
3153 elsif l_inst_set(i).excld_flag = 'N' then
3154 --
3155 --hr_utility.set_location(' Step 4' ,99);
3156 l_rows_found := true;
3157 --
3158 end if;
3159 --
3160 end loop;
3161 --
3162 end if;
3163 --
3164 if l_rows_found and not l_ok then
3165 --
3166 --hr_utility.set_location(' Step 5 ' ,99);
3167 raise ben_evaluate_rate_profiles.g_profile_failed;
3168 --
3169 end if;
3170 --
3171 end check_age;
3172 --
3173 -- -----------------------------------------------------------
3174 -- Comp level check.
3175 -- -----------------------------------------------------------
3176 --
3177 procedure check_comp_level
3178 (p_vrbl_rt_prfl_id in number
3179 ,p_person_id in number
3180 ,p_business_group_id in number
3181 ,p_effective_date in date
3182 ,p_lf_evt_ocrd_dt in date
3183 ,p_elig_per_elctbl_chc_id in number
3184 ,p_pl_id in number default null
3185 ,p_pgm_id in number default null
3186 ,p_oipl_id in number default null
3187 ,p_per_in_ler_id in number default null)
3188 is
3189 --
3190 l_pl_id number;
3191 l_pgm_id number;
3192 l_per_in_ler_id number;
3193 l_oipl_id number;
3194 l_compensation_value number;
3195 l_mx_comp_val number;
3196 l_effective_date date ;
3197 --
3198 -- Grab needed parameters for passing into determin_age procedure.
3199 --
3200 cursor c_comp_param is
3201 select epe.pl_id, epe.pgm_id, epe.oipl_id, epe.per_in_ler_id
3202 from ben_elig_per_elctbl_chc epe
3203 where epe.elig_per_elctbl_chc_id = p_elig_per_elctbl_chc_id;
3204 --
3205 l_proc varchar2(80) := g_package||'.check_comp_level';
3206 l_inst_set ben_rt_prfl_cache.g_complvl_inst_tbl;
3207 l_inst_count number;
3208 l_ok boolean := false;
3209 l_rows_found boolean := false;
3210 --
3211 begin
3212 --
3213 --- fonm2
3214 l_effective_date := nvl( p_lf_evt_ocrd_dt, p_effective_date ) ;
3215 if ben_manage_life_events.fonm = 'Y' then
3216 --
3217 l_effective_date := nvl(ben_manage_life_events.g_fonm_rt_strt_dt,
3218 nvl(ben_manage_life_events.g_fonm_cvg_strt_dt,
3219 l_effective_date));
3220 --
3221 end if;
3222
3223 if p_elig_per_elctbl_chc_id is not null then
3224 --
3225 open c_comp_param;
3226 --
3227 fetch c_comp_param into l_pl_id, l_pgm_id, l_oipl_id, l_per_in_ler_id;
3228 --
3229 close c_comp_param;
3230 --
3231 else
3232 --
3233 l_pl_id := p_pl_id;
3234 l_pgm_id := p_pgm_id;
3235 l_oipl_id := p_oipl_id;
3236 l_per_in_ler_id := p_per_in_ler_id;
3237 --
3238 end if;
3239 --
3240 -- Get the data from the cache.
3241 --
3242 ben_rt_prfl_cache.get_rt_prfl_cache
3243 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
3244 ,p_effective_date => p_effective_date
3245 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
3246 ,p_business_group_id => p_business_group_id
3247 ,p_inst_set => l_inst_set
3248 ,p_inst_count => l_inst_count);
3249 --
3250 if l_inst_count > 0 then
3251 --
3252 -- Data found. Loop through to see if excld flag is on or off.
3253 --
3254 l_rows_found := true;
3255 --
3256 for i in l_inst_set.first..l_inst_set.last loop
3257 --
3258 if l_inst_set(i).comp_lvl_fctr_id is null then
3259 --
3260 fnd_message.set_name('BEN','BEN_91526_BERP_CMP_LVL_FCTR_ID');
3261 fnd_message.set_token('L_PROC',l_proc);
3262 fnd_message.set_token('PERSON_ID',to_char(p_person_id));
3263 fnd_message.set_token('VRBL_RT_PRFL_ID',to_char(p_vrbl_rt_prfl_id));
3264 fnd_message.set_token('PGM_ID',to_char(p_pgm_id));
3265 fnd_message.set_token('PL_ID',to_char(p_pl_id));
3266 fnd_message.set_token('OIPL_ID',to_char(p_oipl_id));
3267 fnd_message.set_token('LF_EVT_OCRD_DT',p_lf_evt_ocrd_dt);
3268 fnd_message.set_token('PER_IN_LER_ID',to_char(p_per_in_ler_id));
3269 fnd_message.set_token('ELIG_PER_ELCTBL_CHC_ID',to_char(p_elig_per_elctbl_chc_id));
3270 fnd_message.set_token('EFFECTIVE_DATE',p_effective_date);
3271 fnd_message.raise_error;
3272 --
3273 end if;
3274 --
3275 ben_derive_factors.determine_compensation
3276 (p_comp_lvl_fctr_id => l_inst_set(i).comp_lvl_fctr_id
3277 ,p_person_id => p_person_id
3278 ,p_pgm_id => l_pgm_id
3279 ,p_pl_id => l_pl_id
3280 ,p_oipl_id => l_oipl_id
3281 ,p_per_in_ler_id => l_per_in_ler_id
3282 ,p_business_group_id => p_business_group_id
3283 ,p_perform_rounding_flg => true
3284 ,p_effective_date => p_effective_date
3285 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
3286
3287 ,p_fonm_cvg_strt_dt => ben_manage_life_events.g_fonm_cvg_strt_dt
3288 ,p_fonm_rt_strt_dt => ben_manage_life_events.g_fonm_rt_strt_dt
3289 ,p_value => l_compensation_value);
3290
3291 hr_utility.set_location( ' compen ' || l_compensation_value , 610.2) ;
3292 hr_utility.set_location( ' mn compen ' || l_inst_set(i).mn_comp_val , 610.2) ;
3293 --
3294 -- Bug 2101937 fixes
3295 l_mx_comp_val := l_inst_set(i).mx_comp_val ;
3296 --
3297 if ( l_inst_set(i).mx_comp_val <> trunc(l_inst_set(i).mx_comp_val) OR
3298 l_inst_set(i).mn_comp_val <> trunc(l_inst_set(i).mn_comp_val) ) then
3299 -- Decimal Case
3300 l_mx_comp_val := l_inst_set(i).mx_comp_val + 0.000000001 ;
3301 --
3302 else
3303 --
3304 l_mx_comp_val := l_inst_set(i).mx_comp_val + 1 ;
3305 --
3306 end if;
3307 --
3308 hr_utility.set_location('if' , 610) ;
3309 --
3310 l_ok := (nvl(l_compensation_value,-1) >= l_inst_set(i).mn_comp_val and
3311 nvl(l_compensation_value,9999999) < l_mx_comp_val )
3312 or
3313 (l_inst_set(i).no_mn_comp_flag = 'Y' and
3314 nvl(l_compensation_value,9999999) < l_mx_comp_val )
3315 or
3316 (l_inst_set(i).no_mx_comp_flag = 'Y' and
3317 nvl(l_compensation_value,-1) >= l_inst_set(i).mn_comp_val);
3318
3319
3320 --
3321 if l_ok is null or l_compensation_value is null then
3322 --
3323 l_ok := false;
3324 --
3325 end if;
3326 --
3327 if l_ok and l_inst_set(i).excld_flag = 'N' then
3328 --
3329 exit;
3330 --
3331 elsif l_ok and l_inst_set(i).excld_flag = 'Y' then
3332 --
3333 -- raise ben_evaluate_rate_profiles.g_profile_failed;
3334 l_ok := false;
3335 exit ;
3336 --
3337 elsif (not l_ok) and l_inst_set(i).excld_flag = 'Y' then
3338 -- Bug 2100564
3339 l_ok := true ;
3340 -- exit ;
3341 --
3342 elsif l_inst_set(i).excld_flag = 'N' then
3343 --
3344 l_rows_found := true;
3345 --
3346 end if;
3347 --
3348 end loop;
3349 --
3350 end if;
3351 --
3352 if l_rows_found and not l_ok then
3353 --
3354 raise ben_evaluate_rate_profiles.g_profile_failed;
3355 --
3356 end if;
3357 --
3358 end check_comp_level;
3359 --
3360 -- -----------------------------------------------------------
3361 -- LOS check.
3362 -- -----------------------------------------------------------
3363 --
3364 procedure check_los
3365 (p_vrbl_rt_prfl_id in number
3366 ,p_person_id in number
3367 ,p_business_group_id in number
3368 ,p_effective_date in date
3369 ,p_lf_evt_ocrd_dt in date
3370 ,p_elig_per_elctbl_chc_id in number
3371 ,p_pl_id in number default null
3372 ,p_pgm_id in number default null
3373 ,p_oipl_id in number default null
3374 ,p_plip_id in number default null
3375 ,p_opt_id in number default null
3376 ,p_per_in_ler_id in number default null
3377 ,p_currepe_row in ben_determine_rates.g_curr_epe_rec)
3378 is
3379 --
3380 l_rows_found boolean := false;
3381 l_pl_id number;
3382 l_oipl_id number;
3383 l_pgm_id number;
3384 l_plip_id number;
3385 l_per_los number;
3386 l_per_in_ler_id number;
3387 l_dummy_date date;
3388 l_prtn_ovridn_flag varchar2(30);
3389 l_prtn_ovridn_thru_dt date;
3390 l_epo_row ben_derive_part_and_rate_facts.g_cache_structure;
3391 l_effective_date date ;
3392 --
3393 -- Grab needed parameters for accessing LOS_VAL.
3394 --
3395 cursor c_elect is
3396 select epe.pl_id, epe.pgm_id, epe.oipl_id, epe.per_in_ler_id
3397 from ben_elig_per_elctbl_chc epe
3398 where epe.elig_per_elctbl_chc_id = p_elig_per_elctbl_chc_id;
3399 --
3400 l_inst_set ben_rt_prfl_cache.g_los_inst_tbl;
3401 l_inst_count number;
3402 l_ok boolean := false;
3403 l_mx_los_num number ;
3404 --
3405 begin
3406 --
3407 -- retrieve electble choice data needed
3408 --
3409
3410 --- fonm2
3411 l_effective_date := nvl( p_lf_evt_ocrd_dt, p_effective_date ) ;
3412 if ben_manage_life_events.fonm = 'Y' then
3413 --
3414 l_effective_date := nvl(ben_manage_life_events.g_fonm_rt_strt_dt,
3415 nvl(ben_manage_life_events.g_fonm_cvg_strt_dt,
3416 l_effective_date));
3417 --
3418 end if;
3419
3420
3421
3422 if p_elig_per_elctbl_chc_id is not null then
3423 --
3424 open c_elect;
3425 --
3426 fetch c_elect into l_pl_id,
3427 l_pgm_id,
3428 l_oipl_id,
3429 l_per_in_ler_id;
3430 --
3431 close c_elect;
3432 --
3433 else
3434 --
3435 l_pl_id := p_pl_id;
3436 l_pgm_id := p_pgm_id;
3437 l_oipl_id := p_oipl_id;
3438 l_per_in_ler_id := p_per_in_ler_id;
3439 --
3440 end if;
3441 --
3442 -- Get the data from the cache.
3443 --
3444 hr_utility.set_location('p_vrbl_rt_prfl_id rate level '||p_vrbl_rt_prfl_id,10);
3445 --
3446 ben_rt_prfl_cache.get_rt_prfl_cache
3447 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
3448 ,p_effective_date => p_effective_date
3449 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
3450 ,p_business_group_id => p_business_group_id
3451 ,p_inst_set => l_inst_set
3452 ,p_inst_count => l_inst_count);
3453 --
3454 hr_utility.set_location('l_per_los rate level '||l_per_los,10);
3455 hr_utility.set_location('l_inst_count '||l_inst_count,10);
3456 --
3457 if l_inst_count > 0 then
3458 --
3459 -- plan in program is overriden, capture the data from cache by passing plip_id
3460 if p_opt_id is null and p_pgm_id is not null then
3461 ben_pep_cache.get_pilpep_dets(
3462 p_person_id => p_person_id,
3463 p_business_group_id => p_business_group_id,
3464 p_effective_date => l_effective_date,
3465 p_pgm_id => p_pgm_id,
3466 p_plip_id => p_plip_id,
3467 p_inst_row => l_epo_row);
3468 l_prtn_ovridn_flag := l_epo_row.prtn_ovridn_flag;
3469 l_prtn_ovridn_thru_dt := l_epo_row.prtn_ovridn_thru_dt;
3470 l_per_los := l_epo_row.rt_los_val;
3471 elsif p_opt_id is not null and p_pgm_id is not null then
3472 ben_pep_cache.get_pilepo_dets(
3473 p_person_id => p_person_id,
3474 p_business_group_id => p_business_group_id,
3475 p_effective_date => l_effective_date,
3476 p_pgm_id => p_pgm_id,
3477 p_plip_id => p_plip_id,
3478 p_opt_id => p_opt_id,
3479 p_inst_row => l_epo_row);
3480 l_prtn_ovridn_flag := l_epo_row.prtn_ovridn_flag;
3481 l_prtn_ovridn_thru_dt := l_epo_row.prtn_ovridn_thru_dt;
3482 l_per_los := l_epo_row.rt_los_val;
3483 else
3484 hr_utility.set_location('Plan not in Program',10);
3485 l_prtn_ovridn_flag := p_currepe_row.prtn_ovridn_flag;
3486 l_prtn_ovridn_thru_dt := p_currepe_row.prtn_ovridn_thru_dt;
3487 l_per_los := p_currepe_row.rt_los_val;
3488 end if;
3489
3490 -- Data found. Loop through to see if excld flag is on or off.
3491 --
3492 l_rows_found := true;
3493 --
3494 for i in l_inst_set.first..l_inst_set.last loop
3495 -- if the variable rate is overriden then don't call determine_los
3496 --RCHASE - v115.57 wrap l_prtn_ovridn_flag with NVL,
3497 -- possible NULL return instead of expected TRUE or FALSE
3498 if not (nvl(l_prtn_ovridn_flag,'N') = 'Y' and
3499 nvl(l_prtn_ovridn_thru_dt,hr_api.g_eot) > p_effective_date)
3500 then
3501 --
3502 ben_derive_factors.determine_los
3503 (p_person_id => p_person_id
3504 ,p_los_fctr_id => l_inst_set(i).los_fctr_id
3505 ,p_per_in_ler_id => l_per_in_ler_id
3506 ,p_pgm_id => l_pgm_id
3507 ,p_pl_id => l_pl_id
3508 ,p_oipl_id => l_oipl_id
3509 ,p_effective_date => p_effective_date
3510 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
3511 --fonm
3512 ,p_fonm_cvg_strt_dt => ben_manage_life_events.g_fonm_cvg_strt_dt
3513 ,p_fonm_rt_strt_dt => ben_manage_life_events.g_fonm_rt_strt_dt
3514 ,p_business_group_id => p_business_group_id
3515 ,p_perform_rounding_flg => TRUE
3516 ,p_value => l_per_los
3517 ,p_start_date => l_dummy_date);
3518 --
3519 end if;
3520 hr_utility.set_location( ' los ' || l_per_los , 610.2);
3521 -- Bug 2101937 fixes
3522 l_mx_los_num := l_inst_set(i).mx_los_num ;
3523 --
3524 if ( l_inst_set(i).mx_los_num <> trunc(l_inst_set(i).mx_los_num) OR
3525 l_inst_set(i).mn_los_num <> trunc(l_inst_set(i).mn_los_num) ) then
3526 -- Decimal Case
3527 l_mx_los_num := l_inst_set(i).mx_los_num + 0.000000001 ;
3528 --
3529 else
3530 --
3531 l_mx_los_num := l_inst_set(i).mx_los_num + 1 ;
3532 --
3533 end if;
3534 --
3535 l_ok := (nvl(l_per_los,-1) >= l_inst_set(i).mn_los_num and
3536 nvl(l_per_los,999999) < l_mx_los_num )
3537 or
3538 (l_inst_set(i).no_mn_los_num_apls_flag = 'Y' and
3539 nvl(l_per_los,999999) < l_mx_los_num )
3540
3541 or
3542 (l_inst_set(i).no_mx_los_num_apls_flag = 'Y' and
3543 nvl(l_per_los,-1) >= l_inst_set(i).mn_los_num);
3544 --
3545 if l_ok and l_inst_set(i).excld_flag = 'N' then
3546 --
3547 exit;
3548 --
3549 elsif l_ok and l_inst_set(i).excld_flag = 'Y' then
3550 --
3551 l_rows_found := true;
3552 l_ok := false;
3553 exit;
3554 --
3555 elsif (not l_ok) and l_inst_set(i).excld_flag = 'Y' then
3556 -- Bug 2100564
3557 l_rows_found := true;
3558 l_ok := true ;
3559 -- exit ;
3560 --
3561 elsif l_inst_set(i).excld_flag = 'N' then
3562 --
3563 l_rows_found := true;
3564 --
3565 end if;
3566 --
3567 end loop;
3568 --
3569 end if;
3570 --
3571 if l_rows_found and not l_ok then
3572 --
3573 raise ben_evaluate_rate_profiles.g_profile_failed;
3574 --
3575 end if;
3576 --
3577 end check_los;
3578 --
3579 -- --------------------------------------------------------------------
3580 -- Combination age/los check.
3581 -- --------------------------------------------------------------------
3582 --
3583 procedure check_age_los
3584 (p_vrbl_rt_prfl_id in number
3585 ,p_person_id in number
3586 ,p_business_group_id in number
3587 ,p_effective_date in date
3588 ,p_lf_evt_ocrd_dt in date
3589 ,p_elig_per_elctbl_chc_id in number
3590 ,p_pl_id in number default null
3591 ,p_pgm_id in number default null
3592 ,p_oipl_id in number default null
3593 ,p_plip_id in number default null
3594 ,p_opt_id in number default null
3595 ,p_per_in_ler_id in number default null
3596 ,p_currepe_row in ben_determine_rates.g_curr_epe_rec)
3597 is
3598 --
3599 l_pl_id number;
3600 l_pgm_id number;
3601 l_per_in_ler_id number;
3602 l_oipl_id number;
3603 l_cmbn_age_n_los_val number;
3604 l_dummy_date date;
3605 l_prtn_ovridn_flag varchar2(30);
3606 l_prtn_ovridn_thru_dt date;
3607 l_epo_row ben_derive_part_and_rate_facts.g_cache_structure;
3608 l_effective_date date ;
3609 --
3610
3611
3612 --
3613 -- Grab needed parameters for accessing CMBN_AGE_N_LOS_VAL .
3614 --
3615 cursor c_elect is
3616 select epe.pl_id, epe.pgm_id, epe.oipl_id, epe.per_in_ler_id
3617 from ben_elig_per_elctbl_chc epe
3618 where epe.elig_per_elctbl_chc_id = p_elig_per_elctbl_chc_id;
3619 --
3620 l_inst_set ben_rt_prfl_cache.g_age_los_inst_tbl;
3621 l_inst_count number;
3622 l_ok boolean := false;
3623 l_rows_found boolean := false;
3624 --
3625 begin
3626 --
3627 --- fonm2
3628 l_effective_date := nvl( p_lf_evt_ocrd_dt, p_effective_date ) ;
3629 if ben_manage_life_events.fonm = 'Y' then
3630 --
3631 l_effective_date := nvl(ben_manage_life_events.g_fonm_rt_strt_dt,
3632 nvl(ben_manage_life_events.g_fonm_cvg_strt_dt,
3633 l_effective_date));
3634 --
3635 end if;
3636
3637
3638 -- retrieve electble choice data needed
3639 --
3640 if p_elig_per_elctbl_chc_id is not null then
3641 --
3642 open c_elect;
3643 --
3644 fetch c_elect into l_pl_id,
3645 l_pgm_id,
3646 l_oipl_id,
3647 l_per_in_ler_id;
3648 --
3649 close c_elect;
3650 --
3651 else
3652 --
3653 l_pl_id := p_pl_id;
3654 l_pgm_id := p_pgm_id;
3655 l_oipl_id := p_oipl_id;
3656 l_per_in_ler_id := p_per_in_ler_id;
3657 --
3658 end if;
3659 --
3660 -- Get the data from the cache.
3661 --
3662 ben_rt_prfl_cache.get_rt_prfl_cache
3663 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
3664 ,p_effective_date => p_effective_date
3665 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
3666 ,p_business_group_id => p_business_group_id
3667 ,p_inst_set => l_inst_set
3668 ,p_inst_count => l_inst_count);
3669 --
3670 if l_inst_count > 0 then
3671 --
3672 -- plan in program is overriden, capture the data from cache by passing plip_id
3673 if p_opt_id is null and p_pgm_id is not null then
3674 ben_pep_cache.get_pilpep_dets(
3675 p_person_id => p_person_id,
3676 p_business_group_id => p_business_group_id,
3677 p_effective_date => l_effective_date,
3678 p_pgm_id => p_pgm_id,
3679 p_plip_id => p_plip_id,
3680 p_inst_row => l_epo_row);
3681 l_prtn_ovridn_flag := l_epo_row.prtn_ovridn_flag;
3682 l_prtn_ovridn_thru_dt := l_epo_row.prtn_ovridn_thru_dt;
3683 l_cmbn_age_n_los_val := l_epo_row.rt_cmbn_age_n_los_val;
3684 elsif p_opt_id is not null and p_pgm_id is not null then
3685 ben_pep_cache.get_pilepo_dets(
3686 p_person_id => p_person_id,
3687 p_business_group_id => p_business_group_id,
3688 p_effective_date => l_effective_date,
3689 p_pgm_id => p_pgm_id,
3690 p_plip_id => p_plip_id,
3691 p_opt_id => p_opt_id,
3692 p_inst_row => l_epo_row);
3693 l_prtn_ovridn_flag := l_epo_row.prtn_ovridn_flag;
3694 l_prtn_ovridn_thru_dt := l_epo_row.prtn_ovridn_thru_dt;
3695 l_cmbn_age_n_los_val := l_epo_row.rt_cmbn_age_n_los_val;
3696 else
3697 hr_utility.set_location('Plan not in Program',10);
3698 l_prtn_ovridn_flag := p_currepe_row.prtn_ovridn_flag;
3699 l_prtn_ovridn_thru_dt := p_currepe_row.prtn_ovridn_thru_dt;
3700 l_cmbn_age_n_los_val := p_currepe_row.rt_cmbn_age_n_los_val;
3701 end if;
3702
3703 -- Data found. Loop through to see if excld flag is on or off.
3704 --
3705 l_rows_found := true;
3706 --
3707 for i in l_inst_set.first..l_inst_set.last loop
3708 --
3709 -- if the variable rate is overriden then don't call determine_los
3710 --RCHASE - v115.57 wrap l_prtn_ovridn_flag with NVL,
3711 -- possible NULL return instead of expected TRUE or FALSE
3712 if not (nvl(l_prtn_ovridn_flag,'N') = 'Y' and
3713 nvl(l_prtn_ovridn_thru_dt,hr_api.g_eot) > p_effective_date)
3714 then
3715 --BBULUSU - changed determine_los to determine_comb_age_los below
3716 ben_derive_factors.determine_comb_age_los
3717 (p_person_id => p_person_id
3718 ,p_cmbn_age_los_fctr_id => l_inst_set(i).cmbn_age_los_fctr_id
3719 ,p_per_in_ler_id => l_per_in_ler_id
3720 ,p_pgm_id => l_pgm_id
3721 ,p_pl_id => l_pl_id
3722 ,p_oipl_id => l_oipl_id
3723 ,p_effective_date => p_effective_date
3724 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
3725 -- fonm
3726 ,p_fonm_cvg_strt_dt => ben_manage_life_events.g_fonm_cvg_strt_dt
3727 ,p_fonm_rt_strt_dt => ben_manage_life_events.g_fonm_rt_strt_dt
3728 ,p_business_group_id => p_business_group_id
3729 ,p_value => l_cmbn_age_n_los_val);
3730 --
3731 end if;
3732 l_ok := nvl(l_cmbn_age_n_los_val,-1)
3733 between nvl(l_inst_set(i).cmbnd_min_val,0)
3734 and nvl(l_inst_set(i).cmbnd_max_val,99999999);
3735 --
3736 if l_ok is null then
3737 --
3738 l_ok := false ;
3739 --
3740 end if;
3741 --
3742 if l_ok and l_inst_set(i).excld_flag = 'N' then
3743 --
3744 exit;
3745 --
3746 elsif l_ok and l_inst_set(i).excld_flag = 'Y' then
3747 --
3748 -- raise ben_evaluate_rate_profiles.g_profile_failed;
3749 l_ok := false ;
3750 exit ;
3751 --
3752 elsif (not l_ok) and l_inst_set(i).excld_flag = 'Y' then
3753 -- Bug 2100564
3754 l_ok := true ;
3755 --exit ;
3756 --
3757 elsif l_inst_set(i).excld_flag = 'N' then
3758 --
3759 l_rows_found := true;
3760 --
3761 end if;
3762 --
3763 end loop;
3764 --
3765 end if;
3766 --
3767 if l_rows_found and not l_ok then
3768 --
3769 raise ben_evaluate_rate_profiles.g_profile_failed;
3770 --
3771 end if;
3772 --
3773 end check_age_los;
3774 --
3775 -- ---------------------------------------------------------------
3776 -- Period of enrollment
3777 -- Note: This profile is only for COBRA. It will be changed later
3778 -- for general use.
3779 -- ---------------------------------------------------------------
3780 --
3781 procedure check_period_of_enrollment
3782 (p_vrbl_rt_prfl_id in number
3783 ,p_business_group_id in number
3784 ,p_effective_date in date
3785 ,p_lf_evt_ocrd_dt in date
3786 ,p_person_id in number
3787 ,p_pgm_id in number default null
3788 ,p_pl_typ_id in number default null
3789 ,p_ler_id in number default null) is
3790 --
3791 l_inst_set ben_rt_prfl_cache.g_poe_inst_tbl;
3792 l_init_lf_evt_ocrd_dt date;
3793 l_inst_count number;
3794 l_strt_dt date;
3795 l_end_dt date;
3796 l_exists varchar2(1);
3797 l_dsbld boolean := false;
3798 l_mn_poe_num ben_poe_rt_f.mn_poe_num%type;
3799 --
3800 cursor c_get_quald_bnf is
3801 select cqb.*, crp.per_in_ler_id
3802 from ben_cbr_quald_bnf cqb
3803 ,ben_cbr_per_in_ler crp
3804 ,ben_per_in_ler pil
3805 where cqb.quald_bnf_person_id = p_person_id
3806 and cqb.quald_bnf_flag = 'Y'
3807 and nvl(p_lf_evt_ocrd_dt,p_effective_date)
3808 between cqb.cbr_elig_perd_strt_dt and
3809 cqb.cbr_elig_perd_end_dt
3810 and cqb.business_group_id = p_business_group_id
3811 and cqb.cbr_quald_bnf_id = crp.cbr_quald_bnf_id
3812 and cqb.pgm_id = nvl(p_pgm_id,cqb.pgm_id)
3813 and nvl(cqb.pl_typ_id,nvl(p_pl_typ_id,-1)) = nvl(p_pl_typ_id,-1)
3814 and crp.per_in_ler_id = pil.per_in_ler_id
3815 and crp.business_group_id = cqb.business_group_id
3816 and pil.business_group_id = crp.business_group_id
3817 and crp.init_evt_flag = 'Y'
3818 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT');
3819 --
3820 cursor c_get_all_quald_bnf(p_cvrd_emp_person_id in number) is
3821 select cqb.*
3822 from ben_cbr_quald_bnf cqb
3823 ,ben_cbr_per_in_ler crp
3824 ,ben_per_in_ler pil
3825 where cqb.cvrd_emp_person_id = p_cvrd_emp_person_id
3826 and cqb.quald_bnf_flag = 'Y'
3827 and nvl(p_lf_evt_ocrd_dt,p_effective_date)
3828 between cqb.cbr_elig_perd_strt_dt and
3829 cqb.cbr_elig_perd_end_dt
3830 and cqb.business_group_id = p_business_group_id
3831 and cqb.cbr_quald_bnf_id = crp.cbr_quald_bnf_id
3832 and cqb.pgm_id = nvl(p_pgm_id,cqb.pgm_id)
3833 and nvl(cqb.pl_typ_id,nvl(p_pl_typ_id,-1)) = nvl(p_pl_typ_id,-1)
3834 and crp.per_in_ler_id = pil.per_in_ler_id
3835 and crp.business_group_id = cqb.business_group_id
3836 and pil.business_group_id = crp.business_group_id
3837 and crp.init_evt_flag = 'Y'
3838 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT');
3839 --
3840 cursor c_get_dsblity_evt(p_cbr_quald_bnf_id number) is
3841 select null
3842 from ben_cbr_per_in_ler crp
3843 , ben_ler_f ler
3844 , ben_per_in_ler pil
3845 where crp.cbr_quald_bnf_id = p_cbr_quald_bnf_id
3846 and crp.per_in_ler_id = pil.per_in_ler_id
3847 and pil.ler_id = ler.ler_id
3848 and ler.typ_cd = 'DSBLTY'
3849 and ler.qualg_evt_flag = 'Y'
3850 and nvl(p_lf_evt_ocrd_dt,p_effective_date)
3851 between ler.effective_start_date and
3852 ler.effective_end_date
3853 and ler.business_group_id = p_business_group_id
3854 and ler.business_group_id = pil.business_group_id
3855 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
3856 and crp.cnt_num = (select max(cnt_num)
3857 from ben_cbr_per_in_ler crp2
3858 ,ben_per_in_ler pil2
3859 where crp2.cbr_quald_bnf_id = p_cbr_quald_bnf_id
3860 and crp2.per_in_ler_id = pil2.per_in_ler_id
3861 and pil2.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
3862 and crp2.business_group_id = p_business_group_id
3863 and crp2.business_group_id = pil2.business_group_id);
3864 cursor c_ler is
3865 select null
3866 from
3867 ben_ler_f ler
3868 where
3869 ler.ler_id = p_ler_id
3870 and ler.QUALG_EVT_FLAG = 'Y'
3871 and p_effective_date between
3872 ler.effective_start_date and ler.effective_end_date
3873 and ler.business_group_id = p_business_group_id ;
3874 --
3875 l_ler_rec c_ler%rowtype;
3876
3877 --
3878 l_cqb_rec c_get_quald_bnf%rowtype;
3879 l_cqb2_rec c_get_all_quald_bnf%rowtype;
3880 begin
3881 --
3882 -- Get the data from the cache.
3883 --
3884 ben_rt_prfl_cache.get_rt_prfl_cache
3885 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
3886 ,p_effective_date => p_effective_date
3887 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
3888 ,p_business_group_id => p_business_group_id
3889 ,p_inst_set => l_inst_set
3890 ,p_inst_count => l_inst_count);
3891 --
3892 hr_utility.set_location ('l_inst_count:'||l_inst_count,10);
3893 if l_inst_count > 0 then
3894 --
3895 -- Data found. Loop through to see if excld flag is on or off.
3896 --
3897 for i in l_inst_set.first..l_inst_set.last loop
3898 --
3899 -- This profile is only applicable to COBRA qualified
3900 -- beneficiary.
3901 --
3902 open c_get_quald_bnf;
3903 fetch c_get_quald_bnf into l_cqb_rec;
3904 if c_get_quald_bnf%notfound then
3905 hr_utility.set_location ('did not find quald bnf:',10);
3906 close c_get_quald_bnf;
3907 --
3908 -- Bug 1566944 Check for new terminations with qualifying event
3909 -- New a termination life event is processes, system can't find
3910 -- any rows for the person in ben_cbr_quald_bnf. So we are checking the
3911 -- Cobra qualifying event flag for the life event.
3912
3913 --
3914 open c_ler;
3915 fetch c_ler into l_ler_rec ;
3916 if c_ler%notfound then
3917 hr_utility.set_location ('not a new qualifying termination event:',10);
3918 close c_ler;
3919 raise ben_evaluate_rate_profiles.g_profile_failed;
3920 else
3921 close c_ler;
3922 -- Calculate the start date.
3923 --
3924 if l_inst_set(i).no_mn_poe_flag = 'N' then
3925 --
3926 -- We need to get the first day of the period of enrollment.
3927 --
3928 if l_inst_set(i).mn_poe_num > 1 then
3929 l_mn_poe_num := l_inst_set(i).mn_poe_num - 1;
3930 end if;
3931 --
3932 l_strt_dt := (benutils.derive_date
3933 (p_date => nvl(p_lf_evt_ocrd_dt,p_effective_date) -- l_cqb_rec.cbr_elig_perd_strt_dt
3934 ,p_uom => l_inst_set(i).poe_nnmntry_uom
3935 ,p_min => null
3936 ,p_max => l_mn_poe_num
3937 ,p_value => null
3938 )) + 1;
3939 else
3940 l_strt_dt := hr_api.g_sot;
3941 end if;
3942 --
3943 hr_utility.set_location ('l_strt_dt '||l_strt_dt, 199);
3944 -- Calculate the end date.
3945 --
3946 if l_inst_set(i).no_mx_poe_flag = 'N' then
3947 l_end_dt := benutils.derive_date
3948 (p_date => nvl(p_lf_evt_ocrd_dt,p_effective_date) -- l_cqb_rec.cbr_elig_perd_strt_dt
3949 ,p_uom => l_inst_set(i).poe_nnmntry_uom
3950 ,p_min => null
3951 ,p_max => l_inst_set(i).mx_poe_num
3952 ,p_value => null
3953 );
3954 else
3955 l_end_dt := hr_api.g_eot;
3956 end if;
3957 --
3958 hr_utility.set_location ('l_end_dt '||l_end_dt , 199);
3959 --
3960 if nvl(p_lf_evt_ocrd_dt, p_effective_date) not between
3961 l_strt_dt and l_end_dt then
3962 raise ben_evaluate_rate_profiles.g_profile_failed;
3963 end if;
3964 --
3965 goto l_ler ;
3966 --
3967 end if ;
3968
3969
3970 raise ben_evaluate_rate_profiles.g_profile_failed;
3971 else
3972 close c_get_quald_bnf;
3973 --
3974 -- Calculate the start date.
3975 --
3976 if l_inst_set(i).no_mn_poe_flag = 'N' then
3977 --
3978 -- We need to get the first day of the period of enrollment.
3979 --
3980 if l_inst_set(i).mn_poe_num > 1 then
3981 l_mn_poe_num := l_inst_set(i).mn_poe_num - 1;
3982 end if;
3983 --
3984 l_strt_dt := (benutils.derive_date
3985 (p_date => l_cqb_rec.cbr_elig_perd_strt_dt
3986 ,p_uom => l_inst_set(i).poe_nnmntry_uom
3987 ,p_min => null
3988 ,p_max => l_mn_poe_num
3989 ,p_value => null
3990 ));
3991 hr_utility.set_location ('l_strt_dt '||l_strt_dt, 200);
3992 else
3993 l_strt_dt := hr_api.g_sot;
3994 end if;
3995 --
3996 -- Calculate the end date.
3997 --
3998 if l_inst_set(i).no_mx_poe_flag = 'N' then
3999 l_end_dt := benutils.derive_date
4000 (p_date => l_cqb_rec.cbr_elig_perd_strt_dt
4001 ,p_uom => l_inst_set(i).poe_nnmntry_uom
4002 ,p_min => null
4003 ,p_max => l_inst_set(i).mx_poe_num
4004 ,p_value => null
4005 );
4006 else
4007 l_end_dt := hr_api.g_eot;
4008 end if;
4009 --
4010 -- Disability rates applies if:
4011 -- 1) if the last qualifying event that the person experienced
4012 -- is disability. He/she has not experience another event within
4013 -- the 18 month period that entitles them to a longer eligibility
4014 -- period.
4015 --
4016 -- 2) If the person was disabled at the time of
4017 -- the qualifying event.
4018 -- Disability rates does not apply if the disabled person
4019 -- is no longer covered. All other qualified beneficiary cannot
4020 -- be charge more than the 102%
4021 --
4022 if l_inst_set(i).cbr_dsblty_apls_flag = 'Y' then
4023 --
4024 -- Check if one of the qualified beneficiaries
4025 -- is disabled.
4026 --
4027 l_dsbld := false;
4028 --
4029 for l_cqb2_rec in c_get_all_quald_bnf(l_cqb_rec.cvrd_emp_person_id)
4030 loop
4031 if ben_cobra_requirements.chk_dsbld
4032 (p_person_id => l_cqb2_rec.quald_bnf_person_id
4033 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
4034 ,p_effective_date => p_effective_date
4035 ,p_business_group_id => p_business_group_id) = true then
4036 --
4037 -- Check if person was disabled at the time of the qualifying
4038 -- event.
4039 --
4040 l_init_lf_evt_ocrd_dt
4041 := ben_cobra_requirements.get_lf_evt_ocrd_dt
4042 (p_per_in_ler_id => l_cqb_rec.per_in_ler_id
4043 ,p_business_group_id => p_business_group_id
4044 );
4045 if ben_cobra_requirements.chk_dsbld
4046 (p_person_id => l_cqb2_rec.quald_bnf_person_id
4047 ,p_lf_evt_ocrd_dt => l_init_lf_evt_ocrd_dt
4048 ,p_effective_date => p_effective_date
4049 ,p_business_group_id => p_business_group_id) = false then
4050 --
4051 -- Check if person was disabled within the first 60
4052 -- days of the qualifying event.
4053 --
4054 open c_get_dsblity_evt(l_cqb_rec.cbr_quald_bnf_id);
4055 fetch c_get_dsblity_evt into l_exists;
4056 if c_get_dsblity_evt%notfound then
4057 close c_get_dsblity_evt;
4058 --
4059 else
4060 hr_utility.set_location ('disability rate applies 60 :',10);
4061 close c_get_dsblity_evt;
4062 l_dsbld := true;
4063 exit;
4064 end if;
4065 else
4066 hr_utility.set_location ('disability rate applies tom :',10);
4067 l_dsbld := true;
4068 exit;
4069 end if;
4070 end if;
4071 end loop;
4072 --
4073 if l_dsbld = false then
4074 raise ben_evaluate_rate_profiles.g_profile_failed;
4075 end if;
4076 end if;
4077 --
4078 if nvl(p_lf_evt_ocrd_dt, p_effective_date) not between
4079 l_strt_dt and l_end_dt then
4080 raise ben_evaluate_rate_profiles.g_profile_failed;
4081 end if;
4082 end if; -- qualified beneficiary
4083 --
4084 <<l_ler>>
4085 null;
4086 end loop;
4087 --
4088 end if;
4089 --
4090 end check_period_of_enrollment;
4091 --
4092 -- ---------------------------------------------------------------
4093 -- ttl_prtt check
4094 -- ---------------------------------------------------------------
4095 --
4096 procedure check_ttl_prtt
4097 (p_vrbl_rt_prfl_id in number
4098 ,p_business_group_id in number
4099 ,p_effective_date in date
4100 ,p_lf_evt_ocrd_dt in date
4101 ,p_ttl_prtt in number default null)
4102 is
4103 --
4104 l_proc varchar2(80) := g_package||'.check_ttl_prtt';
4105 l_inst_set ben_rt_prfl_cache.g_ttl_prtt_inst_tbl;
4106 l_inst_count number;
4107 l_profile_match varchar2(1);
4108 --
4109 begin
4110 hr_utility.set_location ('check_ttl_prtt:'||to_char(p_ttl_prtt),10);
4111
4112 --
4113 -- Get the data from the cache.
4114 --
4115 ben_rt_prfl_cache.get_rt_prfl_cache
4116 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
4117 ,p_effective_date => p_effective_date
4118 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
4119 ,p_business_group_id => p_business_group_id
4120 ,p_inst_set => l_inst_set
4121 ,p_inst_count => l_inst_count);
4122
4123
4124 l_profile_match := 'N';
4125 if l_inst_count > 0 then
4126 if p_ttl_prtt is null then
4127 -- there are variable profile criteria for total number of participants
4128 -- attached, but the process did not pass in a the number of prtts.
4129 fnd_message.set_name('BEN','BEN_92244_TTL_PRTT_REQUIRED');
4130 fnd_message.set_token('L_PROC',l_proc);
4131 fnd_message.set_token('VRBL_RT_PRFL_ID',to_char(p_vrbl_rt_prfl_id));
4132 fnd_message.set_token('LF_EVT_OCRD_DT',p_lf_evt_ocrd_dt);
4133 fnd_message.set_token('EFFECTIVE_DATE',p_effective_date);
4134 fnd_message.raise_error;
4135 end if;
4136 --
4137 -- Data found. Loop through to see we match the total number of prtts.
4138 --
4139 for i in l_inst_set.first..l_inst_set.last loop
4140 hr_utility.set_location ('p_ttl:'||to_char(p_ttl_prtt)||
4141 ' min:'||to_char(l_inst_set(i).mn_prtt_num)||' max:'||
4142 to_char(l_inst_set(i).mx_prtt_num),33);
4143
4144 if p_ttl_prtt between nvl(l_inst_set(i).mn_prtt_num,0)
4145 and nvl(l_inst_set(i).mx_prtt_num,999999999999999) then
4146 -- we match one of the ranges, exit with success.
4147 l_profile_match := 'Y';
4148 exit;
4149 end if;
4150 end loop;
4151
4152 if l_profile_match = 'N' then
4153 raise ben_evaluate_rate_profiles.g_profile_failed;
4154 end if;
4155
4156 end if;
4157 end check_ttl_prtt;
4158
4159 -- --------------------------------------------------
4160 -- JOB RATE.
4161 -- --------------------------------------------------
4162 procedure check_job(p_vrbl_rt_prfl_id in number,
4163 p_business_group_id in number,
4164 p_effective_date in date,
4165 p_lf_evt_ocrd_dt in date,
4166 p_job_id in number) is
4167 --
4168 l_proc varchar2(100) := g_package||'check_job';
4169 l_inst_set ben_rt_prfl_cache.g_job_inst_tbl;
4170 l_inst_count number;
4171 l_ok boolean := false;
4172 l_rows_found boolean := false;
4173 --
4174 begin
4175 --
4176 hr_utility.set_location('Entering : '||l_proc,10);
4177 --
4178 -- Get the data from the cache.
4179 --
4180 ben_rt_prfl_cache.get_rt_prfl_cache
4181 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
4182 ,p_effective_date => p_effective_date
4183 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
4184 ,p_business_group_id => p_business_group_id
4185 ,p_inst_set => l_inst_set
4186 ,p_inst_count => l_inst_count);
4187
4188 --
4189 if l_inst_count > 0 then
4190 --
4191 -- Data found. Loop through to see if excld flag is on or off.
4192 --
4193 l_rows_found := true;
4194 --
4195 for i in l_inst_set.first..l_inst_set.last loop
4196 --
4197 l_ok := l_inst_set(i).job_id = p_job_id;
4198 --
4199 if l_ok is null or p_job_id is null then
4200 --
4201 l_ok := false;
4202 --
4203 end if;
4204 --
4205 if l_ok and l_inst_set(i).excld_flag = 'N' then
4206 --
4207 exit;
4208 --
4209 elsif l_ok and l_inst_set(i).excld_flag = 'Y' then
4210 --
4211 -- raise g_criteria_failed;
4212 l_ok := false;
4213 exit ;
4214 --
4215 elsif (not l_ok) and l_inst_set(i).excld_flag = 'Y' then
4216 --
4217 l_ok := true ;
4218 --
4219 elsif l_inst_set(i).excld_flag = 'N' then
4220 --
4221 l_rows_found := true;
4222 --
4223 end if;
4224 --
4225 end loop;
4226 --
4227 end if;
4228 --
4229 if l_rows_found and not l_ok then
4230 --
4231 raise g_criteria_failed;
4232 --
4233 end if;
4234 --
4235 end check_job;
4236
4237
4238 -- --------------------------------------------------
4239 -- OPTED FOR MEDICARE.
4240 -- --------------------------------------------------
4241 procedure check_optd_mdcr(p_vrbl_rt_prfl_id in number,
4242 p_business_group_id in number,
4243 p_effective_date in date,
4244 p_lf_evt_ocrd_dt in date,
4245 p_person_id in number) is
4246 --
4247 l_proc varchar2(100) := g_package||'check_optd_for_medicare';
4248 l_inst_set ben_rt_prfl_cache.g_optd_mdcr_inst_tbl;
4249 l_inst_count number;
4250 l_ok boolean := false;
4251 l_rows_found boolean := false;
4252 l_rec per_all_people_f%rowtype;
4253 --
4254 begin
4255 --
4256 hr_utility.set_location('Entering : '||l_proc,10);
4257 --
4258 -- Get the data from the cache.
4259 --
4260 ben_rt_prfl_cache.get_rt_prfl_cache
4261 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
4262 ,p_effective_date => p_effective_date
4263 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
4264 ,p_business_group_id => p_business_group_id
4265 ,p_inst_set => l_inst_set
4266 ,p_inst_count => l_inst_count);
4267
4268 --
4269 if l_inst_count > 0 then
4270 ben_person_object.get_object(p_person_id => p_person_id,
4271 p_rec => l_rec);
4272 --
4273 for l_num in l_inst_set.first .. l_inst_set.last loop
4274 --
4275 l_rows_found := true;
4276 l_ok := nvl((nvl(l_rec.per_information10,'N') =
4277 l_inst_set(l_num).optd_mdcr_flag),FALSE);
4278 --
4279 -- There is only one row so there is no need to do further checking.
4280 --
4281 end loop;
4282 end if;
4283 --
4284 if l_rows_found and not l_ok then
4285 --
4286 raise g_criteria_failed;
4287 --
4288 end if;
4289 --
4290 end check_optd_mdcr;
4291
4292 -- --------------------------------------------------
4293 -- LEAVING REASON
4294 -- --------------------------------------------------
4295 procedure check_lvg_rsn(p_vrbl_rt_prfl_id in number,
4296 p_business_group_id in number,
4297 p_effective_date in date,
4298 p_lf_evt_ocrd_dt in date,
4299 p_person_id in number) is
4300 --
4301 l_proc varchar2(100) := g_package||'check_lvg_rsn';
4302 l_inst_set ben_rt_prfl_cache.g_lvg_rsn_inst_tbl;
4303 l_inst_count number;
4304 l_ok boolean := false;
4305 l_rows_found boolean := false;
4306 l_rec per_periods_of_service%rowtype;
4307 --
4308 begin
4309 --
4310 hr_utility.set_location('Entering : '||l_proc,10);
4311 --
4312 -- Get the data from the cache.
4313 --
4314 ben_rt_prfl_cache.get_rt_prfl_cache
4315 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
4316 ,p_effective_date => p_effective_date
4317 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
4318 ,p_business_group_id => p_business_group_id
4319 ,p_inst_set => l_inst_set
4320 ,p_inst_count => l_inst_count);
4321
4322 --
4323 if l_inst_count > 0 then
4324 ben_person_object.get_object(p_person_id => p_person_id,
4325 p_rec => l_rec);
4326 --
4327 for i in l_inst_set.first..l_inst_set.last loop
4328 --
4329 l_rows_found := true;
4330 l_ok := nvl((nvl(l_rec.leaving_reason,'-1') =
4331 l_inst_set(i).lvg_rsn_cd),FALSE);
4332 --
4333 if l_ok = true then
4334 if l_inst_set(i).excld_flag = 'Y' then
4335 --
4336 l_ok := false;
4337 exit ;
4338 --
4339 else
4340 --
4341 exit;
4342 --
4343 end if;
4344 elsif l_inst_set(i).excld_flag = 'Y' then
4345 --
4346 l_ok := true;
4347 -- exit;
4348 --
4349 end if;
4350 --
4351 end loop;
4352 end if;
4353 --
4354 if l_rows_found and not l_ok then
4355 --
4356 raise g_criteria_failed;
4357 --
4358 end if;
4359 --
4360 end check_lvg_rsn;
4361
4362
4363 -- --------------------------------------------------
4364 -- COBRA QUALIFIED BENEFICIARY
4365 -- --------------------------------------------------
4366 procedure check_cbr_quald_bnf(p_vrbl_rt_prfl_id in number,
4367 p_business_group_id in number,
4368 p_effective_date in date,
4369 p_person_id in number,
4370 p_lf_evt_ocrd_dt in date) is
4371 --
4372 l_proc varchar2(100) := g_package||'check_cbr_quald_bnf';
4373 l_inst_set ben_rt_prfl_cache.g_cbr_qual_bnf_inst_tbl;
4374 l_inst_count number;
4375 l_ok boolean := false;
4376 l_rows_found boolean := false;
4377 l_rec per_all_people_f%rowtype;
4378 l_quald_bnf_flag ben_cbr_quald_bnf.quald_bnf_flag%type;
4379 --
4380 cursor c1(p_person_id in number
4381 ,p_lf_evt_ocrd_dt in date
4382 ,p_pgm_id in number
4383 ,p_ptip_id in number) is
4384 select cqb.quald_bnf_flag
4385 from ben_cbr_quald_bnf cqb
4386 ,ben_cbr_per_in_ler crp
4387 ,ben_per_in_ler pil
4388 where cqb.quald_bnf_person_id = p_person_id
4389 and cqb.pgm_id = nvl(p_pgm_id,cqb.pgm_id)
4390 and nvl(cqb.ptip_id,-1) = nvl(p_ptip_id, -1)
4391 and p_lf_evt_ocrd_dt
4392 between nvl(cqb.cbr_elig_perd_strt_dt , p_lf_evt_ocrd_dt)
4393 and nvl(cqb.cbr_elig_perd_end_dt , p_lf_evt_ocrd_dt)
4394 and cqb.business_group_id = p_business_group_id
4395 and cqb.cbr_quald_bnf_id = crp.cbr_quald_bnf_id
4396 and crp.per_in_ler_id = pil.per_in_ler_id
4397 and crp.business_group_id = cqb.business_group_id
4398 and crp.init_evt_flag = 'Y'
4399 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT');
4400
4401 begin
4402 --
4403 hr_utility.set_location('Entering : '||l_proc,10);
4404 --
4405 -- Get the data from the cache.
4406 --
4407 ben_rt_prfl_cache.get_rt_prfl_cache
4408 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
4409 ,p_effective_date => p_effective_date
4410 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
4411 ,p_business_group_id => p_business_group_id
4412 ,p_inst_set => l_inst_set
4413 ,p_inst_count => l_inst_count);
4414
4415 --
4416 if l_inst_count > 0 then
4417 ben_person_object.get_object(p_person_id => p_person_id,
4418 p_rec => l_rec);
4419 --
4420 for i in l_inst_set.first..l_inst_set.last loop
4421 --
4422 l_rows_found := true;
4423 -- FONM
4424 open c1(p_person_id
4425 ,nvl(ben_manage_life_events.g_fonm_rt_strt_dt,
4426 nvl(ben_manage_life_events.g_fonm_cvg_strt_dt,
4427 nvl(p_lf_evt_ocrd_dt,p_effective_date)))
4428 ,l_inst_set(i).pgm_id
4429 ,l_inst_set(i).ptip_id);
4430 fetch c1 into l_quald_bnf_flag;
4431 if c1%found then
4432 l_ok := nvl((nvl(l_quald_bnf_flag,'-1') = l_inst_set(i).quald_bnf_flag),FALSE);
4433 else
4434 l_ok := nvl((l_inst_set(i).quald_bnf_flag = 'N'),FALSE);
4435 end if;
4436 close c1;
4437
4438 if l_ok then
4439 exit;
4440 end if;
4441 --
4442 end loop;
4443 end if;
4444 --
4445 if l_rows_found and not l_ok then
4446 --
4447 raise g_criteria_failed;
4448 --
4449 end if;
4450 --
4451 end check_cbr_quald_bnf;
4452
4453
4454 -- --------------------------------------------------
4455 -- DEPENDENT COVERED OTHER PLAN
4456 -- --------------------------------------------------
4457 procedure check_dpnt_cvrd_othr_pl(p_vrbl_rt_prfl_id in number,
4458 p_business_group_id in number,
4459 p_effective_date in date,
4460 p_person_id in number ,
4461 p_lf_evt_ocrd_dt in date) is
4462 --
4463 l_proc varchar2(100) := g_package||'check_dpnt_cvrd_othr_pl';
4464 l_inst_set ben_rt_prfl_cache.g_dpnt_cvrd_othr_pl_inst_tbl;
4465 l_inst_count number;
4466 l_ok boolean := false;
4467 l_rows_found boolean := false;
4468
4469 l_date_to_use date;
4470 l_dummy varchar2(1);
4471 --
4472 cursor c1(p_pl_id in number) is
4473 select null
4474 from ben_elig_cvrd_dpnt_f pdp,
4475 ben_prtt_enrt_rslt_f pen
4476 where pen.business_group_id = p_business_group_id
4477 and pen.pl_id = p_pl_id
4478 and pdp.dpnt_person_id = p_person_id
4479 and l_date_to_use
4480 between pen.enrt_cvg_strt_dt
4481 and pen.enrt_cvg_thru_dt
4482 and pen.enrt_cvg_thru_dt <= pen.effective_end_date
4483 and pdp.business_group_id = pen.business_group_id
4484 and pdp.prtt_enrt_rslt_id = pen.prtt_enrt_rslt_id
4485 --and pen.prtt_enrt_rslt_stat_cd not in ('BCKDT', 'VOIDD')
4486 and pen.prtt_enrt_rslt_stat_cd is null
4487 and l_date_to_use
4488 between pdp.cvg_strt_dt
4489 and pdp.cvg_thru_dt
4490 and pdp.effective_end_date = hr_api.g_eot;
4491
4492 begin
4493 --
4494 hr_utility.set_location('Entering : '||l_proc,10);
4495 --
4496 -- Get the data from the cache.
4497 --
4498 ben_rt_prfl_cache.get_rt_prfl_cache
4499 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
4500 ,p_effective_date => p_effective_date
4501 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
4502 ,p_business_group_id => p_business_group_id
4503 ,p_inst_set => l_inst_set
4504 ,p_inst_count => l_inst_count);
4505
4506 --
4507 if l_inst_count > 0 then
4508 for i in l_inst_set.first..l_inst_set.last loop
4509 --
4510 l_rows_found := true;
4511 --
4512 --
4513 -- Apply the date logic to the life event occurred date.
4514 --
4515 ben_determine_date.main
4516 (p_date_cd => l_inst_set(i).cvg_det_dt_cd,
4517 p_effective_date => p_effective_date,
4518 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
4519 p_fonm_cvg_strt_dt => ben_manage_life_events.g_fonm_cvg_strt_dt,
4520 p_fonm_rt_strt_dt => ben_manage_life_events.g_fonm_rt_strt_dt,
4521 p_returned_date => l_date_to_use);
4522 --
4523 open c1(l_inst_set(i).pl_id);
4524 fetch c1 into l_dummy;
4525 --
4526 if c1%found then
4527 --
4528 close c1;
4529 --
4530 if l_inst_set(i).excld_flag = 'N' then
4531 l_ok := true;
4532 exit;
4533 end if;
4534 --
4535 if l_inst_set(i).excld_flag = 'Y' then
4536 l_ok := false;
4537 exit;
4538 end if;
4539 --
4540 else
4541 --
4542 close c1;
4543 if l_inst_set(i).excld_flag = 'Y' then
4544 l_ok := true;
4545 -- exit;
4546 end if;
4547 end if;
4548 --
4549 end loop;
4550 end if;
4551 --
4552 if l_rows_found and not l_ok then
4553 --
4554 raise g_criteria_failed;
4555 --
4556 end if;
4557 --
4558 end check_dpnt_cvrd_othr_pl;
4559
4560
4561 -- --------------------------------------------------
4562 -- DEPENDENT COVERED OTHER PLAN IN PROGRAM
4563 -- --------------------------------------------------
4564 procedure check_dpnt_cvrd_othr_plip (p_vrbl_rt_prfl_id in number,
4565 p_business_group_id in number,
4566 p_effective_date in date,
4567 p_person_id in number ,
4568 p_lf_evt_ocrd_dt in date) is
4569 --
4570 l_proc varchar2(100) := g_package||'check_dpnt_cvrd_othr_plip';
4571 l_inst_set ben_rt_prfl_cache.g_dpnt_cvrd_othr_plip_inst_tbl;
4572 l_inst_count number;
4573 l_ok boolean := false;
4574 l_rows_found boolean := false;
4575
4576 l_date_to_use date;
4577 l_dummy varchar2(1);
4578 --
4579 cursor c1(p_plip_id in number) is
4580 select null
4581 from ben_prtt_enrt_rslt_f pen
4582 ,ben_elig_cvrd_dpnt_f pdp
4583 ,ben_plip_f cpp
4584 where pen.prtt_enrt_rslt_id = pdp.prtt_enrt_rslt_id
4585 --and pen.prtt_enrt_rslt_stat_cd not in ('BCKDT', 'VOIDD')
4586 and pen.prtt_enrt_rslt_stat_cd is null
4587 and pdp.dpnt_person_id = p_person_id
4588 and pen.pgm_id = cpp.pgm_id
4589 and pen.pl_id = cpp.pl_id
4590 and cpp.plip_id = p_plip_id
4591 and l_date_to_use
4592 between cpp.effective_start_date
4593 and cpp.effective_end_date
4594 and cpp.business_group_id = pen.business_group_id
4595 and l_date_to_use
4596 between pen.enrt_cvg_strt_dt
4597 and pen.enrt_cvg_thru_dt
4598 and pen.business_group_id = p_business_group_id
4599 and pen.enrt_cvg_thru_dt <= pen.effective_end_date
4600 and pen.prtt_enrt_rslt_stat_cd is null
4601 and pdp.business_group_id = pen.business_group_id
4602 and l_date_to_use
4603 between pdp.cvg_strt_dt
4604 and pdp.cvg_thru_dt
4605 and pdp.effective_end_date = hr_api.g_eot;
4606 begin
4607 --
4608 hr_utility.set_location('Entering : '||l_proc,10);
4609 --
4610 -- Get the data from the cache.
4611 --
4612 ben_rt_prfl_cache.get_rt_prfl_cache
4613 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
4614 ,p_effective_date => p_effective_date
4615 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
4616 ,p_business_group_id => p_business_group_id
4617 ,p_inst_set => l_inst_set
4618 ,p_inst_count => l_inst_count);
4619
4620 --
4621 if l_inst_count > 0 then
4622 for i in l_inst_set.first..l_inst_set.last loop
4623 --
4624 l_rows_found := true;
4625 --
4626 --
4627 -- Apply the date logic to the life event occurred date.
4628 --
4629 ben_determine_date.main
4630 (p_date_cd => l_inst_set(i).enrl_det_dt_cd,
4631 p_effective_date => p_effective_date,
4632 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
4633 p_fonm_cvg_strt_dt => ben_manage_life_events.g_fonm_cvg_strt_dt,
4634 p_fonm_rt_strt_dt => ben_manage_life_events.g_fonm_rt_strt_dt,
4635 p_returned_date => l_date_to_use);
4636 --
4637 open c1(l_inst_set(i).plip_id);
4638 fetch c1 into l_dummy;
4639 --
4640 if c1%found then
4641 --
4642 close c1;
4643 --
4644 if l_inst_set(i).excld_flag = 'N' then
4645 l_ok := true;
4646 exit;
4647 end if;
4648 --
4649 if l_inst_set(i).excld_flag = 'Y' then
4650 l_ok := false;
4651 exit;
4652 end if;
4653 --
4654 else
4655 --
4656 close c1;
4657 if l_inst_set(i).excld_flag = 'Y' then
4658 l_ok := true;
4659 -- exit;
4660 end if;
4661 end if;
4662 --
4663 end loop;
4664 end if;
4665 --
4666 if l_rows_found and not l_ok then
4667 --
4668 raise g_criteria_failed;
4669 --
4670 end if;
4671 --
4672 end check_dpnt_cvrd_othr_plip;
4673
4674
4675 -- --------------------------------------------------
4676 -- DEPENDENT COVERED OTHER PLAN TYPE IN PROGRAM
4677 -- --------------------------------------------------
4678 procedure check_dpnt_cvrd_othr_ptip(p_vrbl_rt_prfl_id in number,
4679 p_business_group_id in number,
4680 p_effective_date in date,
4681 p_person_id in number,
4682 p_lf_evt_ocrd_dt in date) is
4683 --
4684 l_proc varchar2(100) := g_package||'check_dpnt_cvrd_othr_ptip';
4685 l_inst_set ben_rt_prfl_cache.g_dpnt_cvrd_othr_ptip_inst_tbl;
4686 l_inst_count number;
4687 l_ok boolean := false;
4688 l_rows_found boolean := false;
4689
4690 l_continue boolean := true;
4691 l_found_ptip boolean := false;
4692 l_date_to_use date;
4693 l_dummy varchar2(1);
4694 --
4695 cursor c1(p_ptip_id in number) is
4696 select pen.pl_id
4697 from ben_prtt_enrt_rslt_f pen
4698 ,ben_elig_cvrd_dpnt_f pdp
4699 where pen.prtt_enrt_rslt_id = pdp.prtt_enrt_rslt_id
4700 --and pen.prtt_enrt_rslt_stat_cd not in ('BCKDT', 'VOIDD')
4701 and pen.prtt_enrt_rslt_stat_cd is null
4702 and pdp.dpnt_person_id = p_person_id
4703 and pen.ptip_id = p_ptip_id
4704 and l_date_to_use
4705 between pen.enrt_cvg_strt_dt
4706 and pen.enrt_cvg_thru_dt
4707 and pen.business_group_id = p_business_group_id
4708 and pen.enrt_cvg_thru_dt <= pen.effective_end_date
4709 and pen.prtt_enrt_rslt_stat_cd is null
4710 and pdp.business_group_id = pen.business_group_id
4711 and l_date_to_use
4712 between pdp.cvg_strt_dt
4713 and pdp.cvg_thru_dt
4714 and pdp.effective_end_date = hr_api.g_eot;
4715 --
4716 cursor c2(p_pl_id in number) is
4717 select null
4718 from ben_pl_regn_f prg
4719 ,ben_regn_f reg
4720 where prg.pl_id = p_pl_id
4721 and prg.regn_id = reg.regn_id
4722 and reg.sttry_citn_name = 'COBRA'
4723 and prg.business_group_id = p_business_group_id
4724 and l_date_to_use
4725 between prg.effective_start_date
4726 and prg.effective_end_date
4727 and prg.business_group_id = reg.business_group_id
4728 and l_date_to_use
4729 between reg.effective_start_date
4730 and reg.effective_end_date;
4731
4732 begin
4733 --
4734 hr_utility.set_location('Entering : '||l_proc,10);
4735 --
4736 -- Get the data from the cache.
4737 --
4738 ben_rt_prfl_cache.get_rt_prfl_cache
4739 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
4740 ,p_effective_date => p_effective_date
4741 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
4742 ,p_business_group_id => p_business_group_id
4743 ,p_inst_set => l_inst_set
4744 ,p_inst_count => l_inst_count);
4745
4746 --
4747 if l_inst_count > 0 then
4748 <<prfl>>
4749 for i in l_inst_set.first..l_inst_set.last loop
4750 --
4751 l_rows_found := true;
4752 --
4753 --
4754 -- Apply the date logic to the life event occurred date.
4755 --
4756 ben_determine_date.main
4757 (p_date_cd => l_inst_set(i).enrl_det_dt_cd,
4758 p_effective_date => p_effective_date,
4759 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
4760 p_fonm_cvg_strt_dt => ben_manage_life_events.g_fonm_cvg_strt_dt,
4761 p_fonm_rt_strt_dt => ben_manage_life_events.g_fonm_rt_strt_dt,
4762 p_returned_date => l_date_to_use);
4763 --
4764 <<dpnt>>
4765 for l_pdp_rec in c1(l_inst_set(i).ptip_id) loop
4766 --
4767 -- Check if the dependent have to be covered in the ptip where
4768 -- there are plans subject to cobra.
4769 --
4770 l_continue := true;
4771 --
4772 if l_inst_set(i).only_pls_subj_cobra_flag = 'Y' then
4773 open c2(l_pdp_rec.pl_id);
4774 fetch c2 into l_dummy;
4775 if c2%notfound then
4776 l_continue := false;
4777 end if;
4778 close c2;
4779 end if;
4780 --
4781 if l_continue then
4782 l_found_ptip := true;
4783 --
4784 if l_inst_set(i).excld_flag = 'N' then
4785 l_ok := true;
4786 exit prfl;
4787 end if;
4788 --
4789 if l_inst_set(i).excld_flag = 'Y' then
4790 l_ok := false;
4791 exit prfl;
4792 end if;
4793 --
4794 end if;
4795 --
4796 end loop dpnt;
4797 --
4798 if (l_found_ptip = false
4799 and l_inst_set(i).excld_flag = 'Y') then
4800 l_ok := true;
4801 exit;
4802 end if;
4803 --
4804 end loop prfl;
4805 end if;
4806 --
4807 if l_rows_found and not l_ok then
4808 --
4809 raise g_criteria_failed;
4810 --
4811 end if;
4812 --
4813 end check_dpnt_cvrd_othr_ptip;
4814
4815
4816 -- --------------------------------------------------
4817 -- DEPENDENT COVERED OTHER PROGRAM
4818 -- --------------------------------------------------
4819 procedure check_dpnt_cvrd_othr_pgm(p_vrbl_rt_prfl_id in number,
4820 p_business_group_id in number,
4821 p_effective_date in date,
4822 p_person_id in number,
4823 p_lf_evt_ocrd_dt in date) is
4824 --
4825 l_proc varchar2(100) := g_package||'check_dpnt_cvrd_othr_pgm';
4826 l_inst_set ben_rt_prfl_cache.g_dpnt_cvrd_othr_pgm_inst_tbl;
4827 l_inst_count number;
4828 l_ok boolean := false;
4829 l_rows_found boolean := false;
4830
4831 l_date_to_use date;
4832 l_dummy varchar2(1);
4833 --
4834 cursor c1(p_pgm_id in number) is
4835 select null
4836 from ben_elig_cvrd_dpnt_f pdp,
4837 ben_prtt_enrt_rslt_f pen
4838 where pen.business_group_id = p_business_group_id
4839 and pen.pgm_id = p_pgm_id
4840 and pdp.dpnt_person_id = p_person_id
4841 and l_date_to_use
4842 between pen.enrt_cvg_strt_dt
4843 and pen.enrt_cvg_thru_dt
4844 and pen.enrt_cvg_thru_dt <= pen.effective_end_date
4845 and pdp.business_group_id = pen.business_group_id
4846 and pdp.prtt_enrt_rslt_id = pen.prtt_enrt_rslt_id
4847 --and pen.prtt_enrt_rslt_stat_cd not in ('BCKDT', 'VOIDD')
4848 and pen.prtt_enrt_rslt_stat_cd is null
4849 and l_date_to_use
4850 between pdp.cvg_strt_dt
4851 and pdp.cvg_thru_dt
4852 and pdp.effective_end_date = hr_api.g_eot;
4853
4854
4855 begin
4856 --
4857 hr_utility.set_location('Entering : '||l_proc,10);
4858 --
4859 -- Get the data from the cache.
4860 --
4861 ben_rt_prfl_cache.get_rt_prfl_cache
4862 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
4863 ,p_effective_date => p_effective_date
4864 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
4865 ,p_business_group_id => p_business_group_id
4866 ,p_inst_set => l_inst_set
4867 ,p_inst_count => l_inst_count);
4868
4869 --
4870 if l_inst_count > 0 then
4871 for i in l_inst_set.first..l_inst_set.last loop
4872 --
4873 l_rows_found := true;
4874 --
4875 --
4876 -- Apply the date logic to the life event occurred date.
4877 --
4878 ben_determine_date.main
4879 (p_date_cd => l_inst_set(i).enrl_det_dt_cd,
4880 p_effective_date => p_effective_date,
4881 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
4882 p_fonm_cvg_strt_dt => ben_manage_life_events.g_fonm_cvg_strt_dt,
4883 p_fonm_rt_strt_dt => ben_manage_life_events.g_fonm_rt_strt_dt,
4884 p_returned_date => l_date_to_use);
4885 --
4886 open c1(l_inst_set(i).pgm_id);
4887 fetch c1 into l_dummy;
4888 --
4889 if c1%found then
4890 --
4891 close c1;
4892 --
4893 if l_inst_set(i).excld_flag = 'N' then
4894 l_ok := true;
4895 exit;
4896 end if;
4897 --
4898 if l_inst_set(i).excld_flag = 'Y' then
4899 l_ok := false;
4900 exit;
4901 end if;
4902 --
4903 else
4904 --
4905 close c1;
4906 if l_inst_set(i).excld_flag = 'Y' then
4907 l_ok := true;
4908 --exit ;
4909 end if;
4910 end if;
4911 --
4912 end loop;
4913 --
4914 end if;
4915 --
4916 if l_rows_found and not l_ok then
4917 --
4918 raise g_criteria_failed;
4919 --
4920 end if;
4921 --
4922 end check_dpnt_cvrd_othr_pgm;
4923
4924
4925 -- --------------------------------------------------
4926 -- ELIGIBLE FOR ANOTHER PLAN
4927 -- --------------------------------------------------
4928 procedure check_prtt_anthr_pl(p_vrbl_rt_prfl_id in number,
4929 p_business_group_id in number,
4930 p_person_id in number,
4931 -- FONM overloaded eff date is fine.
4932 p_effective_date in date,
4933 p_lf_evt_ocrd_dt in date) is
4934 --
4935 l_proc varchar2(100) := g_package||'check_prtt_anthr_pl';
4936 l_inst_set ben_rt_prfl_cache.g_prtt_anthr_pl_inst_tbl;
4937 l_inst_count number;
4938 l_ok boolean := false;
4939 l_rows_found boolean := false;
4940
4941 l_dummy varchar2(1);
4942 --
4943 cursor c1(p_pl_id in number) is
4944 select null
4945 from ben_elig_per_f epo,
4946 ben_per_in_ler pil
4947 where epo.person_id = p_person_id
4948 and epo.pl_id = p_pl_id
4949 and p_effective_date
4950 between epo.effective_start_date
4951 and epo.effective_end_date
4952 and epo.business_group_id = p_business_group_id
4953 and pil.per_in_ler_id(+)=epo.per_in_ler_id
4954 -- and pil.business_group_id(+)=epo.business_group_id
4955 and ( pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT') -- found row condition
4956 or pil.per_in_ler_stat_cd is null -- outer join condition
4957 );
4958
4959
4960 begin
4961 --
4962 hr_utility.set_location('Entering : '||l_proc,10);
4963 --
4964 -- Get the data from the cache.
4965 --
4966 ben_rt_prfl_cache.get_rt_prfl_cache
4967 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
4968 ,p_effective_date => p_effective_date
4969 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
4970 ,p_business_group_id => p_business_group_id
4971 ,p_inst_set => l_inst_set
4972 ,p_inst_count => l_inst_count);
4973
4974 --
4975 if l_inst_count > 0 then
4976 for i in l_inst_set.first..l_inst_set.last loop
4977 --
4978 l_rows_found := true;
4979 --
4980 open c1(l_inst_set(i).pl_id);
4981 fetch c1 into l_dummy;
4982 if c1%found then
4983 --
4984 close c1;
4985 --
4986 if l_inst_set(i).excld_flag = 'N' then
4987 l_ok := true;
4988 exit;
4989 end if;
4990 --
4991 if l_inst_set(i).excld_flag = 'Y' then
4992 l_ok := false;
4993 exit;
4994 end if;
4995 --
4996 else
4997 --
4998 close c1;
4999 --
5000 if l_inst_set(i).excld_flag = 'Y' then
5001 l_ok := true;
5002 -- exit;
5003 end if;
5004 end if;
5005 --
5006 end loop;
5007 --
5008 end if;
5009 --
5010 if l_rows_found and not l_ok then
5011 --
5012 raise g_criteria_failed;
5013 --
5014 end if;
5015 --
5016 end check_prtt_anthr_pl;
5017
5018 -- --------------------------------------------------
5019 -- ELIGIBLE FOR ANOTHER PLAN TYPE IN PROGRAM
5020 -- --------------------------------------------------
5021 procedure check_othr_ptip
5022 (p_vrbl_rt_prfl_id in number
5023 ,p_business_group_id in number
5024 ,p_effective_date in date
5025 ,p_lf_evt_ocrd_dt in date
5026 ,p_person_id in number
5027 ,p_per_in_ler_id in number default null
5028 )
5029 is
5030 --
5031 l_proc varchar2(100):='check_othr_ptip';
5032 --
5033 l_inst_set ben_rt_prfl_cache.g_othr_ptip_inst_tbl;
5034 l_inst_count number;
5035 i binary_integer;
5036 l_ok boolean := false;
5037 l_rows_found boolean := false;
5038 l_dummy varchar2(1);
5039 l_pl_rec ben_comp_object.g_cache_pl_rec_table;
5040 --
5041 l_cur_found boolean := false;
5042 --
5043 cursor pilc1
5044 (c_effective_date date
5045 ,c_per_in_ler_id number
5046 ,c_ptip_id number
5047 ,c_only_pls_subj_cobra_flag varchar2
5048 )
5049 is
5050 select /*+ bendtlep.check_othr_ptip.pilc1 */
5051 null
5052 from ben_pl_f pln,
5053 ben_plip_f cpp,
5054 ben_ptip_f ctp,
5055 ben_elig_per_f epo
5056 where pln.pl_id = cpp.pl_id
5057 and c_effective_date
5058 between pln.effective_start_date
5059 and pln.effective_end_date
5060 and c_effective_date
5061 between cpp.effective_start_date
5062 and cpp.effective_end_date
5063 and cpp.pgm_id = ctp.pgm_id
5064 and pln.pl_typ_id = ctp.pl_typ_id
5065 and ctp.ptip_id = c_ptip_id
5066 and c_effective_date
5067 between ctp.effective_start_date
5068 and ctp.effective_end_date
5069 and epo.per_in_ler_id = c_per_in_ler_id
5070 and epo.pgm_id = ctp.pgm_id
5071 and epo.pl_id = pln.pl_id
5072 and c_effective_date
5073 between epo.effective_start_date
5074 and epo.effective_end_date
5075 and epo.elig_flag = 'Y'
5076 and ( c_only_pls_subj_cobra_flag = 'N'
5077 or exists (select null
5078 from ben_pl_regn_f prg,
5079 ben_regn_f reg
5080 where prg.pl_id = pln.pl_id
5081 and c_effective_date between prg.effective_start_date
5082 and prg.effective_end_date
5083 and reg.regn_id = prg.regn_id
5084 and c_effective_date between reg.effective_start_date
5085 and reg.effective_end_date
5086 and reg.sttry_citn_name = 'COBRA') ); -- 2443719
5087 --
5088 cursor c1
5089 (c_business_group_id in number
5090 ,c_effective_date in date
5091 ,c_person_id in number
5092 ,c_ptip_id in number
5093 ,c_only_pls_subj_cobra_flag in varchar2
5094 )
5095 is
5096 select /*+ bendtlep.check_othr_ptip.c1 */
5097 null
5098 from ben_pl_f pln,
5099 ben_plip_f cpp,
5100 ben_ptip_f ctp,
5101 ben_pl_regn_f prg,
5102 ben_regn_f reg,
5103 ben_elig_per_f epo,
5104 ben_per_in_ler pil
5105 where pln.pl_id = cpp.pl_id
5106 and pln.business_group_id = c_business_group_id
5107 and c_effective_date
5108 between pln.effective_start_date
5109 and pln.effective_end_date
5110 and cpp.business_group_id = pln.business_group_id
5111 and c_effective_date
5112 between cpp.effective_start_date
5113 and cpp.effective_end_date
5114 and cpp.pgm_id = ctp.pgm_id
5115 and pln.pl_typ_id = ctp.pl_typ_id
5116 and ctp.ptip_id = c_ptip_id
5117 and ctp.business_group_id = pln.business_group_id
5118 and c_effective_date
5119 between ctp.effective_start_date
5120 and ctp.effective_end_date
5121 and epo.person_id = c_person_id
5122 and epo.pgm_id = ctp.pgm_id
5123 and epo.pl_id = pln.pl_id
5124 and epo.business_group_id = c_business_group_id
5125 and p_effective_date
5126 between epo.effective_start_date
5127 and epo.effective_end_date
5128 and epo.elig_flag = 'Y'
5129 and ( c_only_pls_subj_cobra_flag = 'N' -- cobra regulation needed only when the flag is set
5130 or exists (select null
5131 from ben_pl_regn_f prg,
5132 ben_regn_f reg
5133 where prg.pl_id = pln.pl_id
5134 and c_effective_date between prg.effective_start_date
5135 and prg.effective_end_date
5136 and prg.business_group_id = pln.business_group_id
5137 and reg.regn_id = prg.regn_id
5138 and c_effective_date between reg.effective_start_date
5139 and reg.effective_end_date
5140 and reg.sttry_citn_name = 'COBRA') ) -- 2443719
5141 and pil.per_in_ler_id(+)=epo.per_in_ler_id
5142 --and pil.business_group_id(+)=epo.business_group_id
5143 and ( pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT') -- found row condition
5144 or pil.per_in_ler_stat_cd is null -- outer join condition
5145 ) ;
5146 --
5147 begin
5148 --
5149 hr_utility.set_location('Entering: '||l_proc, 10);
5150 --
5151 -- Getting variable profile compensation level by variable profile
5152 --
5153 ben_rt_prfl_cache.get_rt_prfl_cache
5154 (p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date),
5155 p_business_group_id => p_business_group_id,
5156 p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id,
5157 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
5158 p_inst_set => l_inst_set,
5159 p_inst_count => l_inst_count);
5160 --
5161 if l_inst_count > 0 then
5162 --
5163 -- Operation
5164 -- =========
5165 -- 1) Grab all profiles for this variable rate profile id
5166 -- 2) Look only at profiles for this PTIP_ID
5167 -- 3) if program is not null then, get all the ptip and check if
5168 --
5169 -- 4) Derive set of plans for the pgm that the ptip refers to
5170 -- 5) Set must be derived based on whether the plans are subject
5171 -- to COBRA or not.
5172 -- 6) If person eligible for any of the plans and exclude flag = 'Y'
5173 -- then no problem.
5174 -- 7) If person eligible for any of the plans and exclude flag = 'N'
5175 -- then fail criteria.
5176 --
5177 for i in l_inst_set.first..l_inst_set.last loop
5178 --
5179 l_rows_found := true;
5180 --
5181 if p_per_in_ler_id is not null then
5182 --
5183 open pilc1
5184 (c_effective_date => nvl(ben_manage_life_events.g_fonm_rt_strt_dt,
5185 nvl(ben_manage_life_events.g_fonm_cvg_strt_dt,
5186 nvl(p_lf_evt_ocrd_dt,p_effective_date)))
5187 ,c_per_in_ler_id => p_per_in_ler_id
5188 ,c_ptip_id => l_inst_set(i).ptip_id
5189 ,c_only_pls_subj_cobra_flag => l_inst_set(i).only_pls_subj_cobra_flag
5190 );
5191 fetch pilc1 into l_dummy;
5192 if pilc1%found then
5193 --
5194 l_cur_found := TRUE;
5195 --
5196 else
5197 --
5198 l_cur_found := FALSE;
5199 --
5200 end if;
5201 close pilc1;
5202 --
5203 else
5204 --
5205 open c1
5206 (c_business_group_id => p_business_group_id
5207 ,c_effective_date => nvl(ben_manage_life_events.g_fonm_rt_strt_dt,
5208 nvl(ben_manage_life_events.g_fonm_cvg_strt_dt, nvl(p_lf_evt_ocrd_dt,p_effective_date)))
5209 ,c_person_id => p_person_id
5210 ,c_ptip_id => l_inst_set(i).ptip_id
5211 ,c_only_pls_subj_cobra_flag => l_inst_set(i).only_pls_subj_cobra_flag
5212 );
5213 fetch c1 into l_dummy;
5214 if c1%found then
5215 --
5216 l_cur_found := TRUE;
5217 --
5218 else
5219 --
5220 l_cur_found := FALSE;
5221 --
5222 end if;
5223 close c1;
5224 end if;
5225 --
5226 if l_cur_found then
5227 --
5228 if l_inst_set(i).excld_flag = 'N' then
5229 --
5230 l_ok := true;
5231 exit;
5232 --
5233 end if;
5234 --
5235 if l_inst_set(i).excld_flag = 'Y' then
5236 --
5237 l_ok := false;
5238 exit;
5239 --
5240 end if;
5241 --
5242 else
5243 --
5244 if l_inst_set(i).excld_flag = 'Y' then
5245 --
5246 l_ok := true;
5247 --
5248 end if;
5249 --
5250 end if;
5251 --
5252 end loop;
5253 --
5254 end if;
5255 --
5256 if l_rows_found and
5257 not l_ok then
5258 --
5259 raise g_criteria_failed;
5260 --
5261 end if;
5262 --
5263 hr_utility.set_location('Leaving :'||l_proc,20);
5264 --
5265 end check_othr_ptip ;
5266
5267 --
5268 -- --------------------------------------------------------------------------
5269 -- ENROLLED IN ANOTHER PLAN
5270 -- --------------------------------------------------------------------------
5271 --
5272 procedure check_enrld_anthr_pl(p_vrbl_rt_prfl_id in number,
5273 p_business_group_id in number,
5274 p_pl_id in number,
5275 p_person_id in number,
5276 p_effective_date in date,
5277 p_lf_evt_ocrd_dt in date) is
5278 --
5279 l_proc varchar2(100):=g_package||'check_enrld_anthr_pl';
5280 l_inst_set ben_rt_prfl_cache.g_enrld_anthr_pl_inst_tbl;
5281 l_inst_count number;
5282 i binary_integer;
5283 l_ok boolean := false;
5284 l_rows_found boolean := false;
5285 l_found_plan boolean := false;
5286 l_date_to_use date;
5287 l_dummy varchar2(1);
5288 --
5289 begin
5290 --
5291 hr_utility.set_location('Entering: '||l_proc, 10);
5292
5293 --
5294 ben_rt_prfl_cache.get_rt_prfl_cache
5295 (p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date),
5296 p_business_group_id => p_business_group_id,
5297 p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id,
5298 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
5299 p_inst_set => l_inst_set,
5300 p_inst_count => l_inst_count);
5301 --
5302 if l_inst_count > 0 then
5303 --
5304 -- Operation
5305 -- =========
5306 -- 1) Grab all profiles for this variable profile profile id
5307 -- 2) If the plan id is the same then check if the person was covered
5308 -- the day before the life event.
5309 --
5310 <<prfl>>
5311 for i in l_inst_set.first..l_inst_set.last loop
5312 --
5313 l_rows_found := true;
5314 --
5315 -- 9999 FONM : how is this cache rebuilt.
5316 <<rslt>>
5317 for l_count in nvl(ben_manage_life_events.g_cache_person_prtn.first,0)..
5318 nvl(ben_manage_life_events.g_cache_person_prtn.last,-1) loop
5319 if ben_manage_life_events.g_cache_person_prtn(l_count).pl_id =
5320 l_inst_set(i).pl_id then
5321 --
5322 -- Apply the date logic to the life event occurred date.
5323 --
5324 ben_determine_date.main
5325 (p_date_cd => l_inst_set(i).enrl_det_dt_cd,
5326 p_effective_date => p_effective_date,
5327 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
5328 p_fonm_cvg_strt_dt => ben_manage_life_events.g_fonm_cvg_strt_dt,
5329 p_fonm_rt_strt_dt => ben_manage_life_events.g_fonm_rt_strt_dt,
5330 p_returned_date => l_date_to_use);
5331 --
5332
5333 if (l_date_to_use
5334 between ben_manage_life_events.g_cache_person_prtn(l_count).enrt_cvg_strt_dt
5335 and ben_manage_life_events.g_cache_person_prtn(l_count).enrt_cvg_thru_dt) then
5336 l_found_plan := true;
5337 --
5338 if l_inst_set(i).excld_flag = 'N'then
5339 --
5340 l_ok := true;
5341 exit prfl;
5342 --
5343 end if;
5344 --
5345 if l_inst_set(i).excld_flag = 'Y'then
5346 --
5347 l_ok := false;
5348 exit prfl;
5349 --
5350 end if;
5351 --
5352 end if;
5353 --
5354 end if;
5355 end loop rslt;
5356 --
5357 -- If person is not enrolled in plan and exclude flag = 'Y',
5358 -- person is eligible.
5359 --
5360 if (l_found_plan = false
5361 and l_inst_set(i).excld_flag = 'Y') then
5362 l_ok := true;
5363 exit;
5364 end if;
5365 --
5366 end loop prfl;
5367 --
5368 end if;
5369 --
5370 if l_rows_found and not l_ok then
5371 --
5372 raise g_criteria_failed;
5373 --
5374 end if;
5375 --
5376 hr_utility.set_location('Leaving :'||l_proc,20);
5377 --
5378 end check_enrld_anthr_pl;
5379 --
5380 -- --------------------------------------------------------------------------
5381 -- ENROLLED IN ANOTHER OPTION IN PLAN.
5382 -- --------------------------------------------------------------------------
5383 --
5384 procedure check_enrld_anthr_oipl(p_vrbl_rt_prfl_id in number,
5385 p_business_group_id in number,
5386 p_oipl_id in number,
5387 p_person_id in number,
5388 p_effective_date in date,
5389 p_lf_evt_ocrd_dt in date) is
5390 --
5391 l_proc varchar2(100):=g_package||'check_enrld_anthr_oipl';
5392 l_inst_set ben_rt_prfl_cache.g_enrld_anthr_oipl_inst_tbl;
5393 l_inst_count number;
5394 i binary_integer;
5395 l_ok boolean := false;
5396 l_rows_found boolean := false;
5397 l_found_oipl boolean := false;
5398 l_date_to_use date;
5399 l_dummy varchar2(1);
5400 --
5401 cursor c1 is
5402 select null
5403 from ben_prtt_enrt_rslt_f pen
5404 where pen.business_group_id = p_business_group_id
5405 and pen.oipl_id = p_oipl_id
5406 and pen.person_id = p_person_id
5407 and l_date_to_use
5408 between pen.enrt_cvg_strt_dt
5409 and pen.enrt_cvg_thru_dt
5410 and pen.enrt_cvg_thru_dt <= pen.effective_end_date
5411 and pen.prtt_enrt_rslt_stat_cd is null;
5412 --
5413 begin
5414 --
5415 hr_utility.set_location('Entering: '||l_proc, 10);
5416 --
5417 -- Getting variable rate profile compensation level by variable profile
5418 --
5419 ben_rt_prfl_cache.get_rt_prfl_cache
5420 (p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date),
5421 p_business_group_id => p_business_group_id,
5422 p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id,
5423 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
5424 p_inst_set => l_inst_set,
5425 p_inst_count => l_inst_count);
5426 --
5427 if l_inst_count > 0 then
5428 --
5429 -- Operation
5430 -- =========
5431 -- 1) Grab all profiles for this variable profile id
5432 -- 2) If the plan id is the same then check if the person was covered
5433 -- the day before the life event.
5434 --
5435 <<prfl>>
5436 for i in l_inst_set.first..l_inst_set.last loop
5437 --
5438 l_rows_found := true;
5439 --
5440 -- 9999 FONM : how is this cache rebuilt.
5441 <<rslt>>
5442 for l_count in nvl(ben_manage_life_events.g_cache_person_prtn.first,0)..
5443 nvl(ben_manage_life_events.g_cache_person_prtn.last,-1) loop
5444 if ben_manage_life_events.
5445 g_cache_person_prtn(l_count).oipl_id =
5446 l_inst_set(i).oipl_id then
5447 --
5448 -- Apply the date logic to the life event occurred date.
5449 --
5450 ben_determine_date.main
5451 (p_date_cd => l_inst_set(i).enrl_det_dt_cd,
5452 p_effective_date => p_effective_date,
5453 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
5454 p_fonm_cvg_strt_dt => ben_manage_life_events.g_fonm_cvg_strt_dt,
5455 p_fonm_rt_strt_dt => ben_manage_life_events.g_fonm_rt_strt_dt,
5456 p_returned_date => l_date_to_use);
5457 --
5458 if (l_date_to_use
5459 between ben_manage_life_events.g_cache_person_prtn(l_count).enrt_cvg_strt_dt
5460 and ben_manage_life_events.g_cache_person_prtn(l_count).enrt_cvg_thru_dt) then
5461 --
5462 l_found_oipl := true;
5463 --
5464 if l_inst_set(i).excld_flag = 'N'then
5465 --
5466 l_ok := true;
5467 exit prfl;
5468 --
5469 end if;
5470 --
5471 if l_inst_set(i).excld_flag = 'Y'then
5472 --
5473 l_ok := false;
5474 exit prfl;
5475 --
5476 end if;
5477 --
5478 end if;
5479 --
5480 end if;
5481 --
5482 end loop rslt;
5483 --
5484 if (l_found_oipl = false
5485 and l_inst_set(i).excld_flag = 'Y') then
5486 --
5487 l_ok := true;
5488 exit;
5489 --
5490 end if;
5491 --
5492 end loop prfl;
5493 --
5494 end if;
5495 --
5496 if l_rows_found and
5497 not l_ok then
5498 --
5499 raise g_criteria_failed;
5500 --
5501 end if;
5502 --
5503 hr_utility.set_location('Leaving :'||l_proc,20);
5504 --
5505 end check_enrld_anthr_oipl;
5506
5507
5508 --
5509 -- --------------------------------------------------------------------------
5510 -- ENROLLED OTHER PLAN TYPE IN PROGRAM.
5511 -- --------------------------------------------------------------------------
5512 --
5513 procedure check_enrld_anthr_ptip(p_vrbl_rt_prfl_id in number,
5514 p_business_group_id in number,
5515 p_effective_date in date,
5516 p_lf_evt_ocrd_dt in date) is
5517 --
5518 l_proc varchar2(100):=g_package||'check_enrld_anthr_ptip';
5519 --
5520 l_inst_set ben_rt_prfl_cache.g_enrld_anthr_ptip_inst_tbl;
5521 l_inst_count number;
5522 i binary_integer;
5523 l_ok boolean := false;
5524 l_rows_found boolean := false;
5525 l_found_ptip boolean := false;
5526 l_continue boolean := true;
5527 l_date_to_use date;
5528 l_dummy varchar2(1);
5529 l_pl_rec ben_comp_object.g_cache_pl_rec_table;
5530 --
5531 cursor c1(p_pl_id in number) is
5532 select null
5533 from ben_pl_f pln,
5534 ben_pl_regn_f prg,
5535 ben_regn_f reg
5536 where pln.pl_id = p_pl_id
5537 and pln.business_group_id = p_business_group_id
5538 and l_date_to_use
5539 between pln.effective_start_date
5540 and pln.effective_end_date
5541 and pln.pl_id = prg.pl_id
5542 and prg.business_group_id = pln.business_group_id
5543 and l_date_to_use
5544 between prg.effective_start_date
5545 and prg.effective_end_date
5546 and prg.regn_id = reg.regn_id
5547 and reg.business_group_id = prg.business_group_id
5548 and l_date_to_use
5549 between reg.effective_start_date
5550 and reg.effective_end_date
5551 and reg.sttry_citn_name = 'COBRA';
5552
5553 --
5554 begin
5555 --
5556 hr_utility.set_location('Entering: '||l_proc, 10);
5557 --
5558 -- Getting variable rate profile compensation level
5559 --
5560 ben_rt_prfl_cache.get_rt_prfl_cache
5561 (p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date),
5562 p_business_group_id => p_business_group_id,
5563 p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id,
5564 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
5565 p_inst_set => l_inst_set,
5566 p_inst_count => l_inst_count);
5567 --
5568 if l_inst_count > 0 then
5569 --
5570 -- Operation
5571 -- =========
5572 -- 1) Grab all profiles for this variable profile id
5573 -- 2) Look only at profiles for this PTIP_ID
5574 -- 3) Set must be derived based on whether the plans are subject
5575 -- to COBRA or not.
5576 -- 4) If person eligible for any of the plans and exclude flag = 'Y'
5577 -- then no problem.
5578 -- 5) If person eligible for any of the plans and exclude flag = 'N'
5579 -- then fail criteria.
5580 --
5581 hr_utility.set_location('Getting profiles',10);
5582 <<prfl>>
5583 for i in l_inst_set.first..l_inst_set.last loop
5584 --
5585 l_rows_found := true;
5586 --
5587 hr_utility.set_location('Getting results',10);
5588 <<rslt>>
5589 for l_count in nvl(ben_manage_life_events.g_cache_person_prtn.first,0)..
5590 nvl(ben_manage_life_events.g_cache_person_prtn.last,-1) loop
5591 if ben_manage_life_events.
5592 g_cache_person_prtn(l_count).ptip_id =
5593 l_inst_set(i).ptip_id then
5594 --
5595 -- Apply the date logic to the life event occurred date.
5596 --
5597 ben_determine_date.main
5598 (p_date_cd => l_inst_set(i).enrl_det_dt_cd,
5599 p_effective_date => p_effective_date,
5600 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
5601 p_fonm_cvg_strt_dt => ben_manage_life_events.g_fonm_cvg_strt_dt,
5602 p_fonm_rt_strt_dt => ben_manage_life_events.g_fonm_rt_strt_dt,
5603 p_returned_date => l_date_to_use);
5604 --
5605 -- If only check plans that are subject to COBRA.
5606 --
5607 l_continue := true;
5608 --
5609 hr_utility.set_location('Getting cobra plans',10);
5610 --
5611 if l_inst_set(i).only_pls_subj_cobra_flag = 'Y' then
5612 --
5613 open c1(ben_manage_life_events.g_cache_person_prtn(l_count).pl_id);
5614 --
5615 fetch c1 into l_dummy;
5616 --
5617 if c1%notfound then
5618 --
5619 hr_utility.set_location('Cobra plans not found',10);
5620 l_continue := false;
5621 --
5622 end if;
5623 --
5624 close c1;
5625 --
5626 end if;
5627 --
5628 if l_continue then
5629 --
5630 hr_utility.set_location('Cobra plans found',10);
5631 --
5632 if (l_date_to_use
5633 between ben_manage_life_events.
5634 g_cache_person_prtn(l_count).enrt_cvg_strt_dt
5635 and ben_manage_life_events.
5636 g_cache_person_prtn(l_count).enrt_cvg_thru_dt) then
5637 --
5638 l_found_ptip := true;
5639 --
5640 if l_inst_set(i).excld_flag = 'N' then
5641 --
5642 hr_utility.set_location('Exclude flags = N Cobra plans found',10);
5643 l_ok := true;
5644 exit prfl;
5645 --
5646 end if;
5647 --
5648 if l_inst_set(i).excld_flag = 'Y' then
5649 --
5650 hr_utility.set_location('Exclude flags = Y Cobra plans found',10);
5651 l_ok := false;
5652 exit prfl;
5653 --
5654 end if;
5655 --
5656 end if;
5657 --
5658 end if;
5659 --
5660 end if;
5661 --
5662 end loop rslt;
5663 --
5664 if l_found_ptip = false
5665 and l_inst_set(i).excld_flag = 'Y' then
5666 --
5667 l_ok := true;
5668 exit;
5669 --
5670 end if;
5671 --
5672 end loop prfl;
5673 --
5674 end if;
5675 --
5676 if l_rows_found and
5677 not l_ok then
5678 --
5679 raise g_criteria_failed;
5680 --
5681 end if;
5682 --
5683 hr_utility.set_location('Leaving :'||l_proc,20);
5684 --
5685 end check_enrld_anthr_ptip;
5686
5687
5688 --
5689 -- --------------------------------------------------------------------------
5690 -- ENROLLED IN ANOTHER PLAN IN PROGRAM.
5691 -- --------------------------------------------------------------------------
5692 --
5693 procedure check_enrld_anthr_plip(p_vrbl_rt_prfl_id in number,
5694 p_business_group_id in number,
5695 p_person_id in number,
5696 p_effective_date in date,
5697 p_lf_evt_ocrd_dt in date) is
5698 --
5699 l_proc varchar2(100):=g_package||'check_enrld_anthr_plip';
5700 l_inst_set ben_rt_prfl_cache.g_enrld_anthr_plip_inst_tbl;
5701 l_inst_count number;
5702 i binary_integer;
5703 l_ok boolean := false;
5704 l_rows_found boolean := false;
5705 l_date_to_use date;
5706 l_dummy varchar2(1);
5707 --
5708 cursor c1(p_plip_id in number) is
5709 select null
5710 from ben_prtt_enrt_rslt_f pen
5711 ,ben_plip_f cpp
5712 where pen.business_group_id = p_business_group_id
5713 and pen.pgm_id = cpp.pgm_id
5714 and pen.pl_id = cpp.pl_id
5715 and cpp.plip_id = p_plip_id
5716 and l_date_to_use
5717 between cpp.effective_start_date
5718 and cpp.effective_end_date
5719 and cpp.business_group_id = pen.business_group_id
5720 and pen.person_id = p_person_id
5721 and l_date_to_use
5722 between pen.enrt_cvg_strt_dt
5723 and pen.enrt_cvg_thru_dt
5724 and pen.enrt_cvg_thru_dt <= pen.effective_end_date
5725 and pen.prtt_enrt_rslt_stat_cd is null;
5726 --
5727 begin
5728 --
5729 hr_utility.set_location('Entering: '||l_proc, 10);
5730 --
5731 -- Getting variable profile compensation level by variable profile
5732 --
5733 ben_rt_prfl_cache.get_rt_prfl_cache
5734 (p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date),
5735 p_business_group_id => p_business_group_id,
5736 p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id,
5737 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
5738 p_inst_set => l_inst_set,
5739 p_inst_count => l_inst_count);
5740 --
5741 if l_inst_count > 0 then
5742 --
5743 -- Operation
5744 -- =========
5745 -- 1) Grab all profiles for this variable profile id
5746 -- 2) If the plan id is the same then check if the person was covered
5747 -- the day before the life event.
5748 --
5749 for i in l_inst_set.first..l_inst_set.last loop
5750 --
5751 l_rows_found := true;
5752 --
5753 --
5754 -- Apply the date logic to the life event occurred date.
5755 --
5756 ben_determine_date.main
5757 (p_date_cd => l_inst_set(i).enrl_det_dt_cd,
5758 p_effective_date => p_effective_date,
5759 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
5760 p_fonm_cvg_strt_dt => ben_manage_life_events.g_fonm_cvg_strt_dt,
5761 p_fonm_rt_strt_dt => ben_manage_life_events.g_fonm_rt_strt_dt,
5762 p_returned_date => l_date_to_use);
5763 --
5764 open c1(l_inst_set(i).plip_id);
5765 fetch c1 into l_dummy;
5766 --
5767 if c1%found then
5768 --
5769 close c1;
5770 --
5771 if l_inst_set(i).excld_flag = 'N' then
5772 l_ok := true;
5773 exit;
5774 end if;
5775 --
5776 if l_inst_set(i).excld_flag = 'Y' then
5777 l_ok := false;
5778 exit;
5779 end if;
5780 --
5781 else
5782 --
5783 close c1;
5784 if l_inst_set(i).excld_flag = 'Y' then
5785 l_ok := true;
5786 -- exit;
5787 end if;
5788 end if;
5789 --
5790 end loop;
5791 --
5792 end if;
5793 --
5794 if l_rows_found and
5795 not l_ok then
5796 --
5797 raise g_criteria_failed;
5798 --
5799 end if;
5800 --
5801 hr_utility.set_location('Leaving :'||l_proc,20);
5802 --
5803 end check_enrld_anthr_plip;
5804
5805
5806 --
5807 -- --------------------------------------------------------------------------
5808 -- ENROLLED IN ANOTHER PROGRAM.
5809 -- --------------------------------------------------------------------------
5810 --
5811 procedure check_enrld_anthr_pgm
5812 (
5813 p_vrbl_rt_prfl_id in number
5814 ,p_business_group_id in number
5815 ,p_pgm_id in number
5816 ,p_person_id in number
5817 ,p_effective_date in date
5818 ,p_lf_evt_ocrd_dt in date )
5819 is
5820 --
5821 l_proc varchar2(100):=g_package||'check_enrld_anthr_pgm';
5822 l_inst_set ben_rt_prfl_cache.g_enrld_anthr_pgm_inst_tbl;
5823 l_inst_count number;
5824 i binary_integer;
5825 l_ok boolean := false;
5826 l_rows_found boolean := false;
5827 l_found_pgm boolean := false;
5828 l_date_to_use date;
5829 l_dummy varchar2(1);
5830 --
5831 begin
5832 --
5833 hr_utility.set_location('Entering: '||l_proc, 10);
5834 hr_utility.set_location('prfl_id: '||p_vrbl_rt_prfl_id, 10);
5835 --
5836 -- Getting variable profile compensation level
5837 --
5838 ben_rt_prfl_cache.get_rt_prfl_cache
5839 (p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date),
5840 p_business_group_id => p_business_group_id,
5841 p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id,
5842 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
5843 p_inst_set => l_inst_set,
5844 p_inst_count => l_inst_count);
5845 --
5846 if l_inst_count > 0 then
5847 --
5848 -- Operation
5849 -- =========
5850 -- 1) Grab all profiles for this variable profile id
5851 -- 2) If the plan id is the same then check if the person was covered
5852 -- the day before the life event.
5853 --
5854 <<prfl>>
5855 for i in l_inst_set.first..l_inst_set.last loop
5856 --
5857 l_rows_found := true;
5858 --
5859 <<rslt>>
5860 for l_count in nvl(ben_manage_life_events.g_cache_person_prtn.first,0)..
5861 nvl(ben_manage_life_events.g_cache_person_prtn.last,-1) loop
5862 if ben_manage_life_events.g_cache_person_prtn(l_count).pgm_id =
5863 l_inst_set(i).pgm_id then
5864 l_found_pgm := true;
5865 --
5866 -- Apply the date logic to the life event occurred date.
5867 --
5868 ben_determine_date.main
5869 (p_date_cd => l_inst_set(i).enrl_det_dt_cd,
5870 p_effective_date => p_effective_date,
5871 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
5872 p_fonm_cvg_strt_dt => ben_manage_life_events.g_fonm_cvg_strt_dt,
5873 p_fonm_rt_strt_dt => ben_manage_life_events.g_fonm_rt_strt_dt,
5874 p_returned_date => l_date_to_use);
5875 --
5876 if (l_date_to_use
5877 between ben_manage_life_events.g_cache_person_prtn(l_count).enrt_cvg_strt_dt
5878 and ben_manage_life_events.g_cache_person_prtn(l_count).enrt_cvg_thru_dt) then
5879 --
5880 if l_inst_set(i).excld_flag = 'N'then
5881 --
5882 l_ok := true;
5883 exit prfl;
5884 --
5885 end if;
5886 --
5887 if l_inst_set(i).excld_flag = 'Y'then
5888 --
5889 l_ok := false;
5890 exit prfl;
5891 --
5892 end if;
5893 --
5894 end if;
5895 --
5896 end if;
5897 --
5898 end loop rslt;
5899 --
5900 -- If person is not enrolled in the program and exclude flag = "Y"
5901 -- person is eligible.
5902 --
5903 if (l_found_pgm = false
5904 and l_inst_set(i).excld_flag = 'Y') then
5905 --
5906 l_ok := true;
5907 exit;
5908 --
5909 end if;
5910
5911 --
5912 end loop prfl;
5913 --
5914 end if;
5915 --
5916 if l_rows_found and
5917 not l_ok then
5918 --
5919 raise g_criteria_failed;
5920 --
5921 end if;
5922 --
5923 hr_utility.set_location('Leaving :'||l_proc,20);
5924 --
5925 end check_enrld_anthr_pgm;
5926
5927 --
5928 -- --------------------------------------------------------------------------
5929 -- DEPENDENT OTHER PLAN TYPE IN PROGRAM
5930 -- --------------------------------------------------------------------------
5931 --
5932 procedure check_dpnt_othr_ptip
5933 (p_vrbl_rt_prfl_id in number
5934 ,p_business_group_id in number
5935 ,p_effective_date in date
5936 ,p_lf_evt_ocrd_dt in date
5937 ,p_person_id in number
5938 ,p_per_in_ler_id in number
5939 )
5940 is
5941 --
5942 l_proc varchar2(100):=g_package||'check_dpnt_other_ptip';
5943 --
5944 l_inst_set ben_rt_prfl_cache.g_dpnt_othr_ptip_inst_tbl;
5945 l_inst_count number;
5946 i binary_integer;
5947 l_ok boolean := false;
5948 l_rows_found boolean := false;
5949 l_dummy varchar2(1);
5950 l_pl_rec ben_comp_object.g_cache_pl_rec_table;
5951 --
5952 cursor c1
5953 (c_ptip_id in number
5954 ,c_bgp_id in number
5955 ,c_eff_date in date
5956 ,c_dpnt_person_id in number
5957 )
5958 is
5959 select null
5960 from ben_pl_f pln,
5961 ben_plip_f cpp,
5962 ben_ptip_f ctp,
5963 ben_elig_per_f epo,
5964 ben_elig_dpnt edp,
5965 ben_per_in_ler pil
5966 where pln.pl_id = cpp.pl_id
5967 and pln.business_group_id = c_bgp_id
5968 and c_eff_date
5969 between pln.effective_start_date and pln.effective_end_date
5970 and cpp.business_group_id = pln.business_group_id
5971 and c_eff_date
5972 between cpp.effective_start_date and cpp.effective_end_date
5973 and cpp.pgm_id = ctp.pgm_id
5974 and pln.pl_typ_id = ctp.pl_typ_id
5975 and ctp.ptip_id = c_ptip_id
5976 and ctp.business_group_id = pln.business_group_id
5977 and c_eff_date
5978 between ctp.effective_start_date and ctp.effective_end_date
5979 and edp.dpnt_person_id = c_dpnt_person_id
5980 and epo.pgm_id = ctp.pgm_id
5981 and epo.pl_id = pln.pl_id
5982 and epo.business_group_id = c_bgp_id
5983 and c_eff_date
5984 between epo.effective_start_date and epo.effective_end_date
5985 and epo.elig_flag = 'Y'
5986 and edp.dpnt_inelig_flag = 'N'
5987 and edp.create_dt = (select max(edp2.create_dt)
5988 from ben_elig_dpnt edp2
5989 ,ben_per_in_ler pil2
5990 where edp2.dpnt_person_id = edp.dpnt_person_id
5991 and edp2.elig_per_id = epo.elig_per_id
5992 and pil2.per_in_ler_id(+)=edp2.per_in_ler_id
5993 and pil2.business_group_id(+)=edp2.business_group_id
5994 and (pil2.per_in_ler_stat_cd
5995 not in ('VOIDD','BCKDT')
5996 or pil2.per_in_ler_stat_cd is null))
5997 and epo.elig_per_id = edp.elig_per_id
5998 and pil.per_in_ler_id(+)=edp.per_in_ler_id
5999 and (pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
6000 or pil.per_in_ler_stat_cd is null
6001 )
6002 and epo.per_in_ler_id = edp.per_in_ler_id
6003 and c_eff_date
6004 between epo.effective_start_date and epo.effective_end_date;
6005 --
6006 begin
6007 --
6008 hr_utility.set_location('Entering: '||l_proc, 10);
6009 --
6010 -- Getting variable profile compensation level by variable profile
6011 --
6012 ben_rt_prfl_cache.get_rt_prfl_cache
6013 (p_effective_date => nvl(p_lf_evt_ocrd_dt,p_effective_date),
6014 p_business_group_id => p_business_group_id,
6015 p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id,
6016 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
6017 p_inst_set => l_inst_set,
6018 p_inst_count => l_inst_count);
6019
6020
6021 --
6022 hr_utility.set_location('l_inst_count: '||l_inst_count, 10);
6023 --
6024 if l_inst_count > 0 then
6025 --
6026 -- Operation
6027 -- =========
6028 -- 1) Grab all profiles for this variable profile
6029 -- 2) Look only at profiles for this PTIP_ID
6030 -- 3) if program is not null then, get all the ptip and check if
6031 --
6032 -- 4) Derive set of plans for the pgm that the ptip refers to
6033 -- 5) If person eligible for any of the plans and exclude flag = 'Y'
6034 -- then no problem.
6035 -- 6) If person eligible for any of the plans and exclude flag = 'N'
6036 -- then fail criteria.
6037 --
6038 for i in l_inst_set.first..l_inst_set.last loop
6039 --
6040 l_rows_found := true;
6041 --
6042 -- Removed the nvls to resolve execute waiting problems for
6043 --
6044 open c1
6045 (c_ptip_id => l_inst_set(i).ptip_id
6046 ,c_bgp_id => p_business_group_id
6047 ,c_eff_date => nvl(ben_manage_life_events.g_fonm_rt_strt_dt,
6048 nvl(ben_manage_life_events.g_fonm_cvg_strt_dt,
6049 nvl(p_lf_evt_ocrd_dt,p_effective_date)))
6050 ,c_dpnt_person_id => p_person_id
6051 );
6052 fetch c1 into l_dummy;
6053 if c1%found then
6054 --
6055 close c1;
6056 if l_inst_set(i).excld_flag = 'N' then
6057 --
6058 l_ok := true;
6059 exit;
6060 --
6061 end if;
6062 --
6063 if l_inst_set(i).excld_flag = 'Y' then
6064 --
6065 l_ok := false;
6066 exit;
6067 --
6068 end if;
6069 --
6070 else
6071 --
6072 close c1;
6073 if l_inst_set(i).excld_flag = 'Y' then
6074 --
6075 l_ok := true;
6076 -- exit ;
6077 --
6078 end if;
6079 end if;
6080 --
6081 end loop;
6082 --
6083 end if;
6084 --
6085 if l_rows_found and
6086 not l_ok then
6087 --
6088 raise g_criteria_failed;
6089 --
6090 end if;
6091 --
6092 hr_utility.set_location('Leaving :'||l_proc,20);
6093 --
6094 end check_dpnt_othr_ptip;
6095
6096
6097 -- --------------------------------------------------
6098 -- NO OTHER COVERAGE
6099 -- --------------------------------------------------
6100 procedure check_no_othr_cvg(p_vrbl_rt_prfl_id in number,
6101 p_business_group_id in number,
6102 p_person_id in number,
6103 p_effective_date in date,
6104 p_lf_evt_ocrd_dt in date) is
6105 --
6106 l_proc varchar2(100) := g_package||'check_no_othr_cvg';
6107 l_inst_set ben_rt_prfl_cache.g_no_othr_cvg_inst_tbl;
6108 l_inst_count number;
6109 l_ok boolean := false;
6110 l_rows_found boolean := false;
6111 l_dummy varchar2(1);
6112 l_rec per_all_people_f%rowtype;
6113 --
6114
6115
6116 begin
6117 --
6118 hr_utility.set_location('Entering : '||l_proc,10);
6119 --
6120 -- Get the data from the cache.
6121 --
6122 ben_rt_prfl_cache.get_rt_prfl_cache
6123 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
6124 ,p_effective_date => p_effective_date
6125 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
6126 ,p_business_group_id => p_business_group_id
6127 ,p_inst_set => l_inst_set
6128 ,p_inst_count => l_inst_count);
6129
6130 --
6131 if l_inst_count > 0 then
6132 ben_person_object.get_object(p_person_id => p_person_id,
6133 p_rec => l_rec);
6134 --
6135 for i in l_inst_set.first..l_inst_set.last loop
6136 --
6137 l_rows_found := true;
6138 l_ok := nvl((nvl(l_rec.coord_ben_no_cvg_flag,'N') =
6139 l_inst_set(i).coord_ben_no_cvg_flag),FALSE);
6140 --
6141 --
6142 end loop;
6143 --
6144 end if;
6145 --
6146 if l_rows_found and not l_ok then
6147 --
6148 raise g_criteria_failed;
6149 --
6150 end if;
6151 --
6152 end check_no_othr_cvg;
6153
6154 -- --------------------------------------------------
6155 -- POSITION
6156 -- --------------------------------------------------
6157 procedure check_pstn(p_vrbl_rt_prfl_id in number,
6158 p_business_group_id in number,
6159 p_asg_position_id in number,
6160 p_effective_date in date,
6161 p_lf_evt_ocrd_dt in date) is
6162 --
6163 l_proc varchar2(100) := g_package||'check_pstn';
6164 l_inst_set ben_rt_prfl_cache.g_pstn_inst_tbl;
6165 l_inst_count number;
6166 l_ok boolean := false;
6167 l_rows_found boolean := false;
6168 l_dummy varchar2(1);
6169 l_rec per_all_people_f%rowtype;
6170 --
6171
6172
6173 begin
6174 --
6175 hr_utility.set_location('Entering : '||l_proc,10);
6176 --
6177 -- Get the data from the cache.
6178 --
6179 ben_rt_prfl_cache.get_rt_prfl_cache
6180 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
6181 ,p_effective_date => p_effective_date
6182 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
6183 ,p_business_group_id => p_business_group_id
6184 ,p_inst_set => l_inst_set
6185 ,p_inst_count => l_inst_count);
6186
6187 --
6188 if l_inst_count > 0 then
6189
6190 for i in l_inst_set.first..l_inst_set.last loop
6191 --
6192 l_ok := nvl((nvl(p_asg_position_id,'-1') = l_inst_set(i).position_id),FALSE);
6193 --
6194 if l_ok and l_inst_set(i).excld_flag = 'N' then
6195 --
6196 exit;
6197 --
6198 elsif l_ok and l_inst_set(i).excld_flag = 'Y' then
6199 --
6200 l_rows_found := true;
6201 l_ok := false;
6202 exit;
6203 --
6204 elsif (not l_ok) and l_inst_set(i).excld_flag = 'Y' then
6205 --
6206 l_rows_found := true;
6207 l_ok := true;
6208 --
6209 elsif l_inst_set(i).excld_flag = 'N' then
6210 --
6211 l_rows_found := true;
6212 --
6213 end if;
6214 --
6215 end loop;
6216 --
6217 end if;
6218 --
6219 if l_rows_found and not l_ok then
6220 --
6221 raise g_criteria_failed;
6222 --
6223 end if;
6224 --
6225 end check_pstn;
6226
6227 -- --------------------------------------------------
6228 -- COMPETENCE
6229 -- --------------------------------------------------
6230 procedure check_comptncy(p_vrbl_rt_prfl_id in number,
6231 p_business_group_id in number,
6232 p_person_id in number,
6233 p_effective_date date,
6234 p_lf_evt_ocrd_dt date) is
6235 --
6236 l_proc varchar2(100) := g_package||'check_comptncy';
6237 l_inst_set ben_rt_prfl_cache.g_comptncy_inst_tbl;
6238 l_inst_count number;
6239 l_ok boolean := false;
6240 l_rows_found boolean := false;
6241 l_dummy varchar2(1);
6242 --
6243
6244 cursor c1(p_person_id number
6245 ,p_competence_id number
6246 ,p_rating_level_id number
6247 ,p_lf_evt_ocrd_dt date) is
6248 select null
6249 from per_competence_elements pce
6250 where pce.person_id = p_person_id
6251 and type = 'PERSONAL'
6252 and pce.competence_id = p_competence_id
6253 and pce.proficiency_level_id = p_rating_level_id
6254 and p_lf_evt_ocrd_dt between nvl(pce.effective_date_from, p_lf_evt_ocrd_dt)
6255 and nvl(pce.effective_date_to, p_lf_evt_ocrd_dt)
6256 and pce.business_group_id = p_business_group_id ;
6257
6258 begin
6259 --
6260 hr_utility.set_location('Entering : '||l_proc,10);
6261 --
6262 -- Get the data from the cache.
6263 --
6264 ben_rt_prfl_cache.get_rt_prfl_cache
6265 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
6266 ,p_effective_date => p_effective_date
6267 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
6268 ,p_business_group_id => p_business_group_id
6269 ,p_inst_set => l_inst_set
6270 ,p_inst_count => l_inst_count);
6271
6272 --
6273 if l_inst_count > 0 then
6274
6275 for i in l_inst_set.first..l_inst_set.last loop
6276 l_rows_found := true;
6277 --
6278 open c1(p_person_id
6279 ,l_inst_set(i).competence_id
6280 ,l_inst_set(i).rating_level_id
6281 ,nvl(ben_manage_life_events.g_fonm_rt_strt_dt,
6282 nvl(ben_manage_life_events.g_fonm_cvg_strt_dt,
6283 nvl(p_lf_evt_ocrd_dt, p_effective_date))) );
6284 fetch c1 into l_dummy;
6285 if c1%found then
6286 --
6287 close c1;
6288 --
6289 if l_inst_set(i).excld_flag = 'N' then
6290 l_ok := true;
6291 exit;
6292 end if;
6293 --
6294 if l_inst_set(i).excld_flag = 'Y' then
6295 l_ok := false;
6296 exit;
6297 end if;
6298 --
6299 else
6300 --
6301 close c1;
6302 if l_inst_set(i).excld_flag = 'Y' then
6303 l_ok := true;
6304 -- exit;
6305 end if;
6306 end if;
6307 --
6308 end loop;
6309 --
6310 end if;
6311 --
6312 if l_rows_found and not l_ok then
6313 --
6314 raise g_criteria_failed;
6315 --
6316 end if;
6317 --
6318 end check_comptncy;
6319
6320
6321
6322 -- --------------------------------------------------
6323 -- QUALIFICATION TITLE
6324 -- --------------------------------------------------
6325 procedure check_qual_titl(p_vrbl_rt_prfl_id in number,
6326 p_business_group_id in number,
6327 p_person_id in number,
6328 p_effective_date date,
6329 p_lf_evt_ocrd_dt date) is
6330 --
6331 l_proc varchar2(100) := g_package||'check_qual_titl';
6332 l_inst_set ben_rt_prfl_cache.g_qual_titl_inst_tbl;
6333 l_inst_count number;
6334 l_ok boolean := false;
6335 l_rows_found boolean := false;
6336 l_dummy varchar2(1);
6337 --
6338
6339 cursor c1(p_person_id number
6340 ,p_qualification_type_id number
6341 ,p_title varchar2
6342 ,p_lf_evt_ocrd_dt date) is
6343 select null
6344 from per_qualifications pqt
6345 where pqt.person_id = p_person_id
6346 and pqt.qualification_type_id = p_qualification_type_id
6347 and nvl(pqt.title,'NULL' ) = NVL(p_title , 'NULL')
6348 and p_lf_evt_ocrd_dt between nvl(pqt.start_date , p_lf_evt_ocrd_dt)
6349 and nvl(pqt.end_date ,p_lf_evt_ocrd_dt)
6350 and pqt.business_group_id = p_business_group_id ;
6351
6352 begin
6353 --
6354 hr_utility.set_location('Entering : '||l_proc,10);
6355 --
6356 -- Get the data from the cache.
6357 --
6358 ben_rt_prfl_cache.get_rt_prfl_cache
6359 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
6360 ,p_effective_date => p_effective_date
6361 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
6362 ,p_business_group_id => p_business_group_id
6363 ,p_inst_set => l_inst_set
6364 ,p_inst_count => l_inst_count);
6365
6366 --
6367 if l_inst_count > 0 then
6368
6369 for i in l_inst_set.first..l_inst_set.last loop
6370 l_rows_found := true;
6371 --
6372 open c1(p_person_id
6373 ,l_inst_set(i).qualification_type_id
6374 ,l_inst_set(i).title
6375 ,nvl(ben_manage_life_events.g_fonm_rt_strt_dt,
6376 nvl(ben_manage_life_events.g_fonm_cvg_strt_dt,
6377 nvl(p_lf_evt_ocrd_dt, p_effective_date))));
6378 fetch c1 into l_dummy;
6379 if c1%found then
6380 --
6381 close c1;
6382 --
6383 if l_inst_set(i).excld_flag = 'N' then
6384 l_ok := true;
6385 exit;
6386 end if;
6387 --
6388 if l_inst_set(i).excld_flag = 'Y' then
6389 l_ok := false;
6390 exit;
6391 end if;
6392 --
6393 else
6394 --
6395 close c1;
6396 if l_inst_set(i).excld_flag = 'Y' then
6397 l_ok := true;
6398 -- exit;
6399 end if;
6400 end if;
6401 --
6402 end loop;
6403 --
6404 end if;
6405 --
6406 if l_rows_found and not l_ok then
6407 --
6408 raise g_criteria_failed;
6409 --
6410 end if;
6411 --
6412 end check_qual_titl;
6413
6414
6415 --
6416 -- ---------------------------------------------------------------
6417 -- ttl_cvg check
6418 -- ---------------------------------------------------------------
6419 --
6420 procedure check_ttl_cvg
6421 (p_vrbl_rt_prfl_id in number
6422 ,p_business_group_id in number
6423 ,p_effective_date in date
6424 ,p_lf_evt_ocrd_dt in date
6425 ,p_ttl_cvg in number default null)
6426 is
6427 --
6428 l_proc varchar2(80) := g_package||'.check_ttl_cvg';
6429 l_inst_set ben_rt_prfl_cache.g_ttl_cvg_inst_tbl;
6430 l_inst_count number;
6431 l_profile_match varchar2(1);
6432 --
6433 begin
6434 hr_utility.set_location ('check_ttl_cvg:'||to_char(p_ttl_cvg),10);
6435
6436 --
6437 -- Get the data from the cache.
6438 --
6439 ben_rt_prfl_cache.get_rt_prfl_cache
6440 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
6441 ,p_effective_date => p_effective_date
6442 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
6443 ,p_business_group_id => p_business_group_id
6444 ,p_inst_set => l_inst_set
6445 ,p_inst_count => l_inst_count);
6446
6447
6448 l_profile_match := 'N';
6449 if l_inst_count > 0 then
6450 if p_ttl_cvg is null then
6451 -- there are variable profile criteria for total coverage attached, but
6452 -- the process did not pass in a coverage volumn amount.
6453 fnd_message.set_name('BEN','BEN_92245_TTL_CVG_REQUIRED');
6454 fnd_message.set_token('L_PROC',l_proc);
6455 fnd_message.set_token('VRBL_RT_PRFL_ID',to_char(p_vrbl_rt_prfl_id));
6456 fnd_message.set_token('LF_EVT_OCRD_DT',p_lf_evt_ocrd_dt);
6457 fnd_message.set_token('EFFECTIVE_DATE',p_effective_date);
6458 fnd_message.raise_error;
6459 end if;
6460 --
6461 -- Data found. Loop through to see we match the total amount of cvg.
6462 --
6463 for i in l_inst_set.first..l_inst_set.last loop
6464 hr_utility.set_location ('min:'||to_char(l_inst_set(i).mn_cvg_vol_amt)||
6465 ' max:'||to_char(l_inst_set(i).mx_cvg_vol_amt),14);
6466 if p_ttl_cvg between nvl(l_inst_set(i).mn_cvg_vol_amt,0)
6467 and nvl(l_inst_set(i).mx_cvg_vol_amt,999999999999999) then
6468 -- we match one of the ranges, exit with success.
6469 l_profile_match := 'Y';
6470 exit;
6471 end if;
6472 end loop;
6473
6474 if l_profile_match = 'N' then
6475 raise ben_evaluate_rate_profiles.g_profile_failed;
6476 end if;
6477
6478 end if;
6479 end check_ttl_cvg;
6480
6481
6482 -- --------------------------------------------------
6483 -- Quartile in Grade
6484 -- --------------------------------------------------
6485 procedure check_qua_in_gr(p_vrbl_rt_prfl_id in number,
6486 p_business_group_id in number,
6487 p_person_id in number,
6488 p_grade_id in number,
6489 p_assignment_id in number,
6490 p_effective_date date,
6491 p_lf_evt_ocrd_dt date,
6492 p_pay_basis_id in number) is
6493 --
6494 l_proc varchar2(100) := g_package||'check_qua_in_gr';
6495 l_inst_set ben_rt_prfl_cache.g_qua_in_gr_inst_tbl;
6496 l_inst_count number;
6497 l_ok boolean := false;
6498 l_rows_found boolean := false;
6499 l_max_val number;
6500 l_min_val number;
6501 l_max_qualifier number;
6502 l_min_qualifier number;
6503 l_in_quartile boolean;
6504 l_person_sal number := 0;
6505 l_ann_fctr number := 0; /* Bug 4031314 */
6506 l_ann_sal number := 0; /* Bug 4031314 */
6507 l_quar_grad VARCHAR2 (30); -- added for bug: 4558945
6508
6509 --
6510
6511 cursor c1(p_grade_id number
6512 ,p_business_group_id number
6513 ,p_lf_evt_ocrd_dt date
6514 ,p_pay_basis_id number) is
6515 select (maximum * grade_annualization_factor) maximum ,
6516 (minimum * grade_annualization_factor) minimum
6517 from pay_grade_rules_f pgr,
6518 per_pay_bases ppb -- 2594204
6519 where ppb.pay_basis_id = p_pay_basis_id
6520 and ppb.business_group_id = p_business_group_id
6521 and pgr.rate_id = ppb.rate_id
6522 and pgr.business_group_id = p_business_group_id
6523 and pgr.grade_or_spinal_point_id = p_grade_id
6524 and p_lf_evt_ocrd_dt between nvl(pgr.effective_start_date, p_lf_evt_ocrd_dt)
6525 and nvl(pgr.effective_end_date, p_lf_evt_ocrd_dt);
6526
6527 /*
6528 Bug 4031314 : We need
6529 (1) Pay Annualization Factor of Salary Basis
6530 (2) Person's Approved Pay Proposal
6531 Splitting the following cursor :
6532
6533 cursor c2(p_assignment_id number
6534 ,p_business_group_id number
6535 ,p_lf_evt_ocrd_dt date
6536 ,p_pay_basis_id number) is
6537 select ppp.proposed_salary_n * ppb.pay_annualization_factor annual_salary
6538 from per_pay_bases ppb,
6539 per_pay_proposals ppp
6540 where ppb.pay_basis_id = p_pay_basis_id
6541 and ppb.business_group_id = p_business_group_id
6542 and ppp.assignment_id = p_assignment_id
6543 and ppp.change_date <= p_lf_evt_ocrd_dt
6544 order by ppp.change_date desc ;
6545 */
6546
6547 cursor c_salary ( p_assignment_id number
6548 ,p_business_group_id number
6549 ,p_lf_evt_ocrd_dt date
6550 ) is
6551 select ppp.proposed_salary_n
6552 from per_pay_proposals ppp
6553 where ppp.assignment_id = p_assignment_id
6554 and ppp.business_group_id = p_business_group_id
6555 and ppp.approved = 'Y'
6556 and ppp.change_date <= p_lf_evt_ocrd_dt
6557 order by ppp.change_date desc;
6558 --
6559 cursor c_pay_bas_ann_fctr ( p_pay_basis_id number
6560 ,p_business_group_id number
6561 ) is
6562 select ppb.pay_annualization_factor
6563 from per_pay_bases ppb
6564 where ppb.pay_basis_id = p_pay_basis_id
6565 and ppb.business_group_id = ppb.business_group_id;
6566 --
6567 procedure get_quartile(p_min IN number default 0
6568 ,p_max IN number default 0
6569 ,p_code IN varchar2
6570 ,p_min_qualifier OUT NOCOPY number
6571 ,p_max_qualifier OUT NOCOPY number
6572 )
6573 is
6574 l_divisor number := 4;
6575 l_addition_factor number;
6576 l_multiplication_factor number;
6577 BEGIN
6578 IF p_code not in ('ABV' , 'BLW' , 'NA') then
6579 l_multiplication_factor := to_number(p_code);
6580 l_addition_factor := (p_max - p_min)/l_divisor;
6581 p_min_qualifier := p_max - l_addition_factor * (l_multiplication_factor ) ;
6582 p_max_qualifier := p_max - l_addition_factor * (l_multiplication_factor - 1 ) ;
6583 if l_multiplication_factor <> 4 THEN
6584 p_min_qualifier := p_min_qualifier + 1;
6585 end if;
6586 END IF;
6587 END;
6588 --
6589 begin
6590 --
6591 hr_utility.set_location('Entering : '||l_proc,10);
6592 --
6593 -- Get the data from the cache.
6594 --
6595 ben_rt_prfl_cache.get_rt_prfl_cache
6596 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
6597 ,p_effective_date => p_effective_date
6598 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
6599 ,p_business_group_id => p_business_group_id
6600 ,p_inst_set => l_inst_set
6601 ,p_inst_count => l_inst_count);
6602
6603 --
6604 if l_inst_count > 0 then
6605 open c1(p_grade_id
6606 ,p_business_group_id
6607 ,nvl(ben_manage_life_events.g_fonm_rt_strt_dt,
6608 nvl(ben_manage_life_events.g_fonm_cvg_strt_dt,
6609 nvl(p_lf_evt_ocrd_dt, p_effective_date)))
6610 ,p_pay_basis_id);
6611 fetch c1 into l_max_val, l_min_val;
6612 close c1;
6613 /* Bug 4031314
6614 open c2(p_assignment_id
6615 ,p_business_group_id
6616 ,nvl(ben_manage_life_events.g_fonm_rt_strt_dt,
6617 nvl(ben_manage_life_events.g_fonm_cvg_strt_dt,
6618 nvl(p_lf_evt_ocrd_dt, p_effective_date)))
6619 ,p_pay_basis_id) ;
6620 fetch c2 into l_person_sal;
6621 close c2;
6622 */
6623 open c_salary ( p_assignment_id => p_assignment_id,
6624 p_business_group_id => p_business_group_id,
6625 p_lf_evt_ocrd_dt => nvl( ben_manage_life_events.g_fonm_rt_strt_dt,
6626 nvl(ben_manage_life_events.g_fonm_cvg_strt_dt,
6627 nvl(p_lf_evt_ocrd_dt, p_effective_date
6628 )
6629 )
6630 )
6631 );
6632 fetch c_salary into l_person_sal;
6633 close c_salary;
6634 --
6635 open c_pay_bas_ann_fctr ( p_pay_basis_id => p_pay_basis_id,
6636 p_business_group_id => p_business_group_id );
6637 fetch c_pay_bas_ann_fctr into l_ann_fctr;
6638 close c_pay_bas_ann_fctr;
6639 --
6640 l_ann_sal := l_person_sal * l_ann_fctr;
6641 --
6642 -- added for bug: 4558945
6643 l_quar_grad :=
6644 ben_cwb_person_info_pkg.get_grd_quartile (p_salary => l_ann_sal,
6645 p_min => NVL(l_min_val,0),
6646 p_max => NVL(l_max_val,0),
6647 p_mid => (NVL(l_min_val,0)+ NVL(l_max_val,0))/ 2
6648 );
6649
6650 for i in l_inst_set.first..l_inst_set.last loop
6651 l_rows_found := true;
6652 --
6653 /*
6654 -- commented for bug: 4558945
6655 get_quartile(p_min => nvl(l_min_val,0)
6656 ,p_max => nvl(l_max_val,0)
6657 ,p_code => l_inst_set(i).quar_in_grade_cd
6658 ,p_min_qualifier => l_min_qualifier
6659 ,p_max_qualifier => l_max_qualifier );
6660
6661 --
6662 IF l_inst_set(i).quar_in_grade_cd = 'ABV' THEN
6663 l_in_quartile := l_ann_sal > nvl(l_max_val,0);
6664 ELSIF l_inst_set(i).quar_in_grade_cd = 'BLW' THEN
6665 l_in_quartile := l_ann_sal < nvl(l_min_val,0);
6666 ELSE
6667 l_in_quartile := l_ann_sal between l_min_qualifier and l_max_qualifier;
6668 END IF;
6669 */
6670 --
6671
6672 -- if l_inst_set(i).excld_flag = 'N' and l_in_quartile then
6673 -- commented for bug: 4558945
6674 IF l_inst_set (i).excld_flag = 'N' AND l_inst_set (i).quar_in_grade_cd = l_quar_grad then
6675 l_ok := true;
6676 exit;
6677 -- elsif l_inst_set(i).excld_flag = 'N' and not l_in_quartile then
6678 -- commented for bug: 4558945
6679 ELSIF l_inst_set (i).excld_flag = 'N' AND l_inst_set (i).quar_in_grade_cd <> l_quar_grad then
6680 l_ok := false;
6681 -- elsif l_inst_set(i).excld_flag = 'Y' and not l_in_quartile then
6682 -- commented for bug: 4558945
6683 ELSIF l_inst_set (i).excld_flag = 'Y' AND l_inst_set (i).quar_in_grade_cd <> l_quar_grad then
6684 l_ok := true;
6685 -- exit;
6686 -- elsif l_inst_set(i).excld_flag = 'Y' and l_in_quartile then
6687 -- commented for bug: 4558945
6688 ELSIF l_inst_set (i).excld_flag = 'Y' AND l_inst_set (i).quar_in_grade_cd = l_quar_grad then
6689
6690 l_ok := false;
6691 exit;
6692 end if;
6693 --
6694 end loop;
6695 --
6696 end if;
6697 --
6698 if l_rows_found and not l_ok then
6699 --
6700 raise g_criteria_failed;
6701 --
6702 end if;
6703 --
6704 end check_qua_in_gr;
6705 --
6706
6707 -- --------------------------------------------------
6708 -- Performance Rating
6709 -- --------------------------------------------------
6710 procedure check_perf_rtng(p_vrbl_rt_prfl_id in number,
6711 p_business_group_id in number,
6712 p_assignment_id in number,
6713 p_person_id in number,
6714 p_effective_date date,
6715 p_lf_evt_ocrd_dt date) is
6716 --
6717 l_proc varchar2(100) := g_package||'check_perf_rtng';
6718 l_inst_set ben_rt_prfl_cache.g_perf_rtng_inst_tbl;
6719 l_inst_count number;
6720 l_ok boolean := false;
6721 l_rows_found boolean := false;
6722 l_dummy varchar2(1);
6723 l_performance_rating varchar2(80);
6724 --
6725 CURSOR c1 (
6726 p_person_id NUMBER,
6727 p_event_type VARCHAR2,
6728 p_business_group_id NUMBER,
6729 p_assignment_id NUMBER,
6730 p_lf_evt_ocrd_dt DATE
6731 )
6732 IS
6733 SELECT ppr.performance_rating
6734 FROM per_performance_reviews ppr, per_events pev
6735 WHERE pev.assignment_id = p_assignment_id
6736 AND pev.TYPE = p_event_type
6737 AND pev.business_group_id = p_business_group_id
6738 AND p_lf_evt_ocrd_dt BETWEEN NVL (date_start, p_lf_evt_ocrd_dt)
6739 AND NVL (date_end, p_lf_evt_ocrd_dt)
6740 AND ppr.event_id = pev.event_id
6741 AND ppr.person_id = p_person_id
6742 -- AND ppr.performance_rating = p_performance_rating
6743 ORDER BY pev.date_start desc, ppr.review_date desc;
6744 --
6745 /* Bug 4031314
6746 * If ELPRO criteria does not specify Performance Type then we would select
6747 * only those performance reviews which do have Performance (Interview) Type
6748 * as NULL i.e PPR.EVENT_ID IS NULL
6749 */
6750 CURSOR c2_without_events (
6751 p_person_id NUMBER,
6752 p_effective_date DATE
6753 )
6754 IS
6755 SELECT ppr.performance_rating
6756 FROM per_performance_reviews ppr
6757 WHERE ppr.person_id = p_person_id
6758 -- AND ppr.performance_rating = p_performance_rating
6759 AND ppr.review_date <= p_effective_date
6760 AND ppr.event_id IS NULL
6761 ORDER BY ppr.review_date desc;
6762 --
6763
6764 begin
6765 --
6766 hr_utility.set_location('Entering : '||l_proc,10);
6767 --
6768 -- Get the data from the cache.
6769 --
6770 ben_rt_prfl_cache.get_rt_prfl_cache
6771 (p_vrbl_rt_prfl_id => p_vrbl_rt_prfl_id
6772 ,p_effective_date => p_effective_date
6773 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
6774 ,p_business_group_id => p_business_group_id
6775 ,p_inst_set => l_inst_set
6776 ,p_inst_count => l_inst_count);
6777
6778 --
6779 if l_inst_count > 0 then
6780
6781 for i in l_inst_set.first..l_inst_set.last
6782 loop
6783 --
6784 l_rows_found := true;
6785 --
6786 /* Bug 4031314
6787 * - When BEN_ELIG_PERF_RTNG_PRTE_F.EVENT_TYPE = '-1', then fetch performance reviews
6788 * that have Performance (Interview) Type as NULL.
6789 * - When BEN_ELIG_PERF_RTNG_PRTE_F.EVENT_TYPE is not '-1', then fetch performanc reviews
6790 * with Performance Type as defined in ELPRO criteria
6791 */
6792 if l_inst_set (i).event_type = '-1'
6793 then
6794 --
6795 OPEN c2_without_events (
6796 p_person_id => p_person_id,
6797 p_effective_date => NVL (ben_manage_life_events.g_fonm_rt_strt_dt,
6798 NVL (ben_manage_life_events.g_fonm_cvg_strt_dt,
6799 NVL (p_lf_evt_ocrd_dt,
6800 p_effective_date
6801 )
6802 )
6803 )
6804 );
6805 --
6806 fetch c2_without_events into l_performance_rating;
6807 --
6808 if c2_without_events%found and l_performance_rating = l_inst_set (i).perf_rtng_cd
6809 then
6810 --
6811 close c2_without_events;
6812 --
6813 if l_inst_set(i).excld_flag = 'N' then
6814 l_ok := true;
6815 exit;
6816 end if;
6817 --
6818 if l_inst_set(i).excld_flag = 'Y' then
6819 l_ok := false;
6820 exit;
6821 end if;
6822 --
6823 else
6824 --
6825 close c2_without_events;
6826 if l_inst_set(i).excld_flag = 'Y' then
6827 l_ok := true;
6828 -- exit;
6829 end if;
6830 --
6831 end if;
6832 --
6833 --
6834 else
6835 --
6836 OPEN c1 (p_person_id => p_person_id,
6837 p_event_type => l_inst_set (i).event_type,
6838 p_business_group_id => p_business_group_id,
6839 p_assignment_id => p_assignment_id,
6840 p_lf_evt_ocrd_dt => NVL (ben_manage_life_events.g_fonm_rt_strt_dt,
6841 NVL (ben_manage_life_events.g_fonm_cvg_strt_dt,
6842 NVL (p_lf_evt_ocrd_dt,
6843 p_effective_date
6844 )
6845 )
6846 )
6847 );
6848 --
6849 fetch c1 into l_performance_rating;
6850 --
6851 if c1%found and l_performance_rating = l_inst_set (i).perf_rtng_cd
6852 then
6853 --
6854 close c1;
6855 --
6856 if l_inst_set(i).excld_flag = 'N' then
6857 l_ok := true;
6858 exit;
6859 end if;
6860 --
6861 if l_inst_set(i).excld_flag = 'Y' then
6862 l_ok := false;
6863 exit;
6864 end if;
6865 --
6866 else
6867 --
6868 close c1;
6869 if l_inst_set(i).excld_flag = 'Y' then
6870 l_ok := true;
6871 -- exit;
6872 end if;
6873 --
6874 end if;
6875 --
6876 end if;
6877 --
6878 end loop;
6879 --
6880 end if;
6881 --
6882 if l_rows_found and not l_ok then
6883 --
6884 raise g_criteria_failed;
6885 --
6886 end if;
6887 --
6888 end check_perf_rtng;
6889
6890
6891 -- ---------------------------------------------------------------------------
6892 -- init_globals
6893 -- ---------------------------------------------------------------------------
6894 procedure init_globals is
6895 begin
6896 ben_evaluate_rate_profiles.g_no_match_cnt := 0 ;
6897 ben_evaluate_rate_profiles.g_no_match_cvg := 0 ;
6898 ben_evaluate_rate_profiles.g_all_prfls.delete;
6899
6900 ben_evaluate_rate_profiles.g_num_of_prfls_used := 0 ;
6901 ben_evaluate_rate_profiles.g_use_prfls.delete;
6902
6903 end init_globals;
6904 -- ---------------------------------------------------------------------------
6905 -- load_globals
6906 -- ---------------------------------------------------------------------------
6907 procedure load_globals
6908 (p_all_prfls in boolean default false,
6909 p_use_prfls in boolean default false,
6910 p_bnft_amt in number default null,
6911 p_vrbl_rt_prfl_id in number,
6912 p_ordr_num in number,
6913 p_asmt_to_use_cd in varchar,
6914 p_rt_hrly_slrd_flag in varchar,
6915 p_rt_pstl_cd_flag in varchar,
6916 p_rt_lbr_mmbr_flag in varchar,
6917 p_rt_lgl_enty_flag in varchar,
6918 p_rt_benfts_grp_flag in varchar,
6919 p_rt_wk_loc_flag in varchar,
6920 p_rt_brgng_unit_flag in varchar,
6921 p_rt_age_flag in varchar,
6922 p_rt_los_flag in varchar,
6923 p_rt_per_typ_flag in varchar,
6924 p_rt_fl_tm_pt_tm_flag in varchar,
6925 p_rt_ee_stat_flag in varchar,
6926 p_rt_grd_flag in varchar,
6927 p_rt_pct_fl_tm_flag in varchar,
6928 p_rt_asnt_set_flag in varchar,
6929 p_rt_hrs_wkd_flag in varchar,
6930 p_rt_comp_lvl_flag in varchar,
6931 p_rt_org_unit_flag in varchar,
6932 p_rt_loa_rsn_flag in varchar,
6933 p_rt_pyrl_flag in varchar,
6934 p_rt_schedd_hrs_flag in varchar,
6935 p_rt_py_bss_flag in varchar,
6936 p_rt_prfl_rl_flag in varchar,
6937 p_rt_cmbn_age_los_flag in varchar,
6938 p_rt_prtt_pl_flag in varchar,
6939 p_rt_svc_area_flag in varchar,
6940 p_rt_ppl_grp_flag in varchar,
6941 p_rt_dsbld_flag in varchar,
6942 p_rt_hlth_cvg_flag in varchar,
6943 p_rt_poe_flag in varchar,
6944 p_rt_ttl_cvg_vol_flag in varchar,
6945 p_rt_ttl_prtt_flag in varchar,
6946 p_rt_gndr_flag in varchar,
6947 p_rt_tbco_use_flag in varchar,
6948 p_rt_cntng_prtn_prfl_flag in varchar,
6949 p_rt_cbr_quald_bnf_flag in varchar,
6950 p_rt_optd_mdcr_flag in varchar,
6951 p_rt_lvg_rsn_flag in varchar,
6952 p_rt_pstn_flag in varchar,
6953 p_rt_comptncy_flag in varchar,
6954 p_rt_job_flag in varchar,
6955 p_rt_qual_titl_flag in varchar,
6956 p_rt_dpnt_cvrd_pl_flag in varchar,
6957 p_rt_dpnt_cvrd_plip_flag in varchar,
6958 p_rt_dpnt_cvrd_ptip_flag in varchar,
6959 p_rt_dpnt_cvrd_pgm_flag in varchar,
6960 p_rt_enrld_oipl_flag in varchar,
6961 p_rt_enrld_pl_flag in varchar,
6962 p_rt_enrld_plip_flag in varchar,
6963 p_rt_enrld_ptip_flag in varchar,
6964 p_rt_enrld_pgm_flag in varchar,
6965 p_rt_prtt_anthr_pl_flag in varchar,
6966 p_rt_othr_ptip_flag in varchar,
6967 p_rt_no_othr_cvg_flag in varchar,
6968 p_rt_dpnt_othr_ptip_flag in varchar,
6969 p_rt_qua_in_gr_flag in varchar,
6970 p_rt_perf_rtng_flag in varchar,
6971 p_rt_elig_prfl_flag in varchar2
6972 ) is
6973
6974 l_package varchar2(80) := g_package||'.load_globals';
6975 l_insert_record varchar2(1);
6976 l_ctr number;
6977 begin
6978 -- hr_utility.set_location ('Entering '||l_package,10);
6979
6980 if p_all_prfls then
6981 -- load the 'all prfls' globals. These globals use the actl_prem_vrbl_rt.ordr_num
6982 -- as it's index, because the second time we loop thru them, we need them in
6983 -- that order.
6984
6985 l_insert_record := 'Y';
6986 if g_all_prfls.count > 0 then
6987 -- it's not the first, loop thru the table to see if we've already
6988 -- matched this profile for a person.
6989 l_ctr := g_all_prfls.first;
6990 loop
6991 if g_all_prfls(l_ctr).vrbl_rt_prfl_id = p_vrbl_rt_prfl_id then
6992 g_all_prfls(l_ctr).match_cnt := g_all_prfls(l_ctr).match_cnt+1;
6993 g_all_prfls(l_ctr).match_cvg := g_all_prfls(l_ctr).match_cvg+p_bnft_amt;
6994 l_insert_record := 'N';
6995 hr_utility.set_location ('added to profile:'||
6996 to_char(p_vrbl_rt_prfl_id)||
6997 ' new num:'||to_char(g_all_prfls(l_ctr).match_cnt)||
6998 ' new cvg:'||to_char(g_all_prfls(l_ctr).match_cvg),16);
6999
7000 exit;
7001 end if;
7002 if l_ctr = g_all_prfls.last then
7003 exit;
7004 else
7005 l_ctr := g_all_prfls.next(l_ctr);
7006 end if;
7007 end loop;
7008 end if;
7009
7010 if l_insert_record = 'Y' then
7011 -- We didn't find a match in the table, add a row to table.
7012 -- increase the total number of profiles matched
7013 g_all_prfls(p_ordr_num).vrbl_rt_prfl_id :=
7014 p_vrbl_rt_prfl_id;
7015 g_all_prfls(p_ordr_num).match_cnt := 1;
7016 g_all_prfls(p_ordr_num).match_cvg := p_bnft_amt;
7017 hr_utility.set_location ('added new profile '||
7018 to_char(p_vrbl_rt_prfl_id)||
7019 ' cvg:'||to_char(p_bnft_amt)||
7020 ' p_ordr_num:'||to_char(p_ordr_num),18);
7021
7022 g_all_prfls(p_ordr_num).asmt_to_use_cd := p_asmt_to_use_cd ;
7023 g_all_prfls(p_ordr_num).rt_hrly_slrd_flag := p_rt_hrly_slrd_flag ;
7024 g_all_prfls(p_ordr_num).rt_pstl_cd_flag := p_rt_pstl_cd_flag ;
7025 g_all_prfls(p_ordr_num).rt_lbr_mmbr_flag := p_rt_lbr_mmbr_flag ;
7026 g_all_prfls(p_ordr_num).rt_lgl_enty_flag := p_rt_lgl_enty_flag ;
7027 g_all_prfls(p_ordr_num).rt_benfts_grp_flag := p_rt_benfts_grp_flag ;
7028 g_all_prfls(p_ordr_num).rt_wk_loc_flag := p_rt_wk_loc_flag ;
7029 g_all_prfls(p_ordr_num).rt_brgng_unit_flag := p_rt_brgng_unit_flag ;
7030 g_all_prfls(p_ordr_num).rt_age_flag := p_rt_age_flag ;
7031 g_all_prfls(p_ordr_num).rt_los_flag := p_rt_los_flag ;
7032 g_all_prfls(p_ordr_num).rt_per_typ_flag := p_rt_per_typ_flag ;
7033 g_all_prfls(p_ordr_num).rt_fl_tm_pt_tm_flag:= p_rt_fl_tm_pt_tm_flag ;
7034 g_all_prfls(p_ordr_num).rt_ee_stat_flag := p_rt_ee_stat_flag ;
7035 g_all_prfls(p_ordr_num).rt_grd_flag := p_rt_grd_flag ;
7036 g_all_prfls(p_ordr_num).rt_pct_fl_tm_flag := p_rt_pct_fl_tm_flag ;
7037 g_all_prfls(p_ordr_num).rt_asnt_set_flag := p_rt_asnt_set_flag ;
7038 g_all_prfls(p_ordr_num).rt_hrs_wkd_flag := p_rt_hrs_wkd_flag ;
7039 g_all_prfls(p_ordr_num).rt_comp_lvl_flag := p_rt_comp_lvl_flag ;
7040 g_all_prfls(p_ordr_num).rt_org_unit_flag := p_rt_org_unit_flag ;
7041 g_all_prfls(p_ordr_num).rt_loa_rsn_flag := p_rt_loa_rsn_flag ;
7042 g_all_prfls(p_ordr_num).rt_pyrl_flag := p_rt_pyrl_flag ;
7043 g_all_prfls(p_ordr_num).rt_schedd_hrs_flag := p_rt_schedd_hrs_flag ;
7044 g_all_prfls(p_ordr_num).rt_py_bss_flag := p_rt_py_bss_flag ;
7045 g_all_prfls(p_ordr_num).rt_prfl_rl_flag := p_rt_prfl_rl_flag ;
7046 g_all_prfls(p_ordr_num).rt_cmbn_age_los_flag := p_rt_cmbn_age_los_flag ;
7047 g_all_prfls(p_ordr_num).rt_prtt_pl_flag := p_rt_prtt_pl_flag ;
7048 g_all_prfls(p_ordr_num).rt_svc_area_flag := p_rt_svc_area_flag ;
7049 g_all_prfls(p_ordr_num).rt_ppl_grp_flag := p_rt_ppl_grp_flag ;
7050 g_all_prfls(p_ordr_num).rt_dsbld_flag := p_rt_dsbld_flag ;
7051 g_all_prfls(p_ordr_num).rt_hlth_cvg_flag := p_rt_hlth_cvg_flag ;
7052 g_all_prfls(p_ordr_num).rt_poe_flag := p_rt_poe_flag ;
7053 g_all_prfls(p_ordr_num).rt_ttl_cvg_vol_flag:= p_rt_ttl_cvg_vol_flag ;
7054 g_all_prfls(p_ordr_num).rt_ttl_prtt_flag := p_rt_ttl_prtt_flag ;
7055 g_all_prfls(p_ordr_num).rt_gndr_flag := p_rt_gndr_flag ;
7056 g_all_prfls(p_ordr_num).rt_tbco_use_flag := p_rt_tbco_use_flag ;
7057 g_all_prfls(p_ordr_num).rt_cntng_prtn_prfl_flag := p_rt_cntng_prtn_prfl_flag ;
7058 g_all_prfls(p_ordr_num).rt_cbr_quald_bnf_flag := p_rt_cbr_quald_bnf_flag;
7059 g_all_prfls(p_ordr_num).rt_optd_mdcr_flag := p_rt_optd_mdcr_flag;
7060 g_all_prfls(p_ordr_num).rt_lvg_rsn_flag := p_rt_lvg_rsn_flag ;
7061 g_all_prfls(p_ordr_num).rt_pstn_flag := p_rt_pstn_flag ;
7062 g_all_prfls(p_ordr_num).rt_comptncy_flag := p_rt_comptncy_flag ;
7063 g_all_prfls(p_ordr_num).rt_job_flag := p_rt_job_flag ;
7064 g_all_prfls(p_ordr_num).rt_qual_titl_flag := p_rt_qual_titl_flag ;
7065 g_all_prfls(p_ordr_num).rt_dpnt_cvrd_pl_flag := p_rt_dpnt_cvrd_pl_flag;
7066 g_all_prfls(p_ordr_num).rt_dpnt_cvrd_plip_flag := p_rt_dpnt_cvrd_plip_flag;
7067 g_all_prfls(p_ordr_num).rt_dpnt_cvrd_ptip_flag := p_rt_dpnt_cvrd_ptip_flag;
7068 g_all_prfls(p_ordr_num).rt_dpnt_cvrd_pgm_flag := p_rt_dpnt_cvrd_pgm_flag;
7069 g_all_prfls(p_ordr_num).rt_enrld_oipl_flag := p_rt_enrld_oipl_flag;
7070 g_all_prfls(p_ordr_num).rt_enrld_pl_flag := p_rt_enrld_pl_flag;
7071 g_all_prfls(p_ordr_num).rt_enrld_plip_flag := p_rt_enrld_plip_flag;
7072 g_all_prfls(p_ordr_num).rt_enrld_ptip_flag := p_rt_enrld_ptip_flag;
7073 g_all_prfls(p_ordr_num).rt_enrld_pgm_flag := p_rt_enrld_pgm_flag;
7074 g_all_prfls(p_ordr_num).rt_prtt_anthr_pl_flag := p_rt_prtt_anthr_pl_flag;
7075 g_all_prfls(p_ordr_num).rt_othr_ptip_flag := p_rt_othr_ptip_flag;
7076 g_all_prfls(p_ordr_num).rt_no_othr_cvg_flag := p_rt_no_othr_cvg_flag;
7077 g_all_prfls(p_ordr_num).rt_dpnt_othr_ptip_flag := p_rt_dpnt_othr_ptip_flag;
7078 g_all_prfls(p_ordr_num).rt_qua_in_gr_flag := p_rt_qua_in_gr_flag;
7079 g_all_prfls(p_ordr_num).rt_perf_rtng_flag := p_rt_perf_rtng_flag;
7080 g_all_prfls(p_ordr_num).rt_elig_prfl_flag := p_rt_elig_prfl_flag;
7081
7082 end if;
7083 else
7084 -- load the 'use prfls' globals. These can use a regular count for
7085 -- index number and avoid gaps.
7086 l_insert_record := 'Y';
7087 if g_num_of_prfls_used <> 0 then
7088 -- it's not the first, loop thru the table to see if we've already
7089 -- matched this profile for a person.
7090 for y in 1..g_num_of_prfls_used loop
7091 if g_use_prfls(y).vrbl_rt_prfl_id = p_vrbl_rt_prfl_id then
7092 g_use_prfls(y).match_cnt := g_use_prfls(y).match_cnt+1;
7093 g_use_prfls(y).match_cvg := g_use_prfls(y).match_cvg+p_bnft_amt;
7094 l_insert_record := 'N';
7095 hr_utility.set_location ('added to profile:'||
7096 to_char(p_vrbl_rt_prfl_id)||
7097 ' new num:'||to_char(g_use_prfls(y).match_cnt)||
7098 ' new cvg:'||to_char(g_use_prfls(y).match_cvg),26);
7099 exit;
7100 end if;
7101 end loop;
7102 end if;
7103 if l_insert_record = 'Y' then
7104 -- We didn't find a match in the table, add a row to table.
7105 -- increase the total number of profiles matched
7106 g_num_of_prfls_used := g_num_of_prfls_used + 1;
7107 g_use_prfls(g_num_of_prfls_used).vrbl_rt_prfl_id :=
7108 p_vrbl_rt_prfl_id;
7109 g_use_prfls(g_num_of_prfls_used).match_cnt := 1;
7110 g_use_prfls(g_num_of_prfls_used).match_cvg := p_bnft_amt;
7111 hr_utility.set_location ('added new profile '||
7112 to_char(p_vrbl_rt_prfl_id)||
7113 ' cvg:'||to_char(p_bnft_amt),28);
7114 end if;
7115 end if;
7116 -- hr_utility.set_location ('Leaving '||l_package,99);
7117 end load_globals;
7118 --
7119 --
7120 -- ---------------------------------------------------------------------------
7121 -- Main
7122 -- ---------------------------------------------------------------------------
7123 procedure main
7124 (p_currepe_row in ben_determine_rates.g_curr_epe_rec
7125 := ben_determine_rates.g_def_curr_epe_rec
7126 ,p_per_row in per_all_people_F%rowtype
7127 := ben_determine_rates.g_def_curr_per_rec
7128 ,p_asg_row in per_all_assignments_f%rowtype
7129 := ben_determine_rates.g_def_curr_asg_rec
7130 ,p_ast_row in per_assignment_status_types%rowtype
7131 := ben_determine_rates.g_def_curr_ast_rec
7132 ,p_adr_row in per_addresses%rowtype
7133 := ben_determine_rates.g_def_curr_adr_rec
7134 ,p_person_id in number
7135 ,p_elig_per_elctbl_chc_id in number
7136 ,p_acty_base_rt_id in number default null
7137 ,p_actl_prem_id in number default null
7138 ,p_cvg_amt_calc_mthd_id in number default null
7139 ,p_effective_date in date
7140 ,p_lf_evt_ocrd_dt in date default null
7141 ,p_calc_only_rt_val_flag in boolean default false
7142 ,p_pgm_id in number default null
7143 ,p_pl_id in number default null
7144 ,p_pl_typ_id in number default null
7145 ,p_oipl_id in number default null
7146 ,p_per_in_ler_id in number default null
7147 ,p_ler_id in number default null
7148 ,p_business_group_id in number default null
7149 ,p_ttl_prtt in number default null
7150 ,p_ttl_cvg in number default null
7151 ,p_all_prfls in boolean default false
7152 ,p_use_globals in boolean default false
7153 ,p_use_prfls in boolean default false
7154 ,p_bnft_amt in number default null
7155 ,p_vrbl_rt_prfl_id out nocopy number
7156 )
7157 is
7158 --
7159 l_package varchar2(80) := g_package||'.main';
7160 --
7161 cursor c_gre
7162 (c_soft_coding_keyflex_id number
7163 )
7164 is
7165 select sck.segment1 gre_id
7166 from hr_soft_coding_keyflex sck
7167 where sck.soft_coding_keyflex_id = c_soft_coding_keyflex_id;
7168 --
7169 cursor c_epe
7170 is
7171 select epe.pgm_id,
7172 epe.pl_id,
7173 epe.pl_typ_id,
7174 epe.oipl_id,
7175 epe.business_group_id,
7176 epe.plip_id,
7177 epe.ptip_id,
7178 epe.oiplip_id,
7179 pil.ler_id,
7180 pil.per_in_ler_id
7181 from ben_elig_per_elctbl_chc epe,
7182 ben_per_in_ler pil
7183 where epe.elig_per_elctbl_chc_id = p_elig_per_elctbl_chc_id
7184 and epe.per_in_ler_id = pil.per_in_ler_id;
7185 --
7186 l_epe c_epe%rowtype;
7187 --
7188 l_profile ben_rtp_cache.g_cobcep_cache_rec;
7189 l_vrbl_rt_prfl_id ben_vrbl_rt_prfl_f.vrbl_rt_prfl_id%type := NULL;
7190 l_oipl_rec ben_oipl_f%rowtype;
7191 l_gre_id number(15);
7192 l_person_type varchar2(30);
7193 l_per_rec per_all_people_f%rowtype;
7194 l_asg_rec per_all_assignments_f%rowtype;
7195 l_adr_rec per_addresses%rowtype;
7196 l_loc_rec hr_locations_all%rowtype;
7197 l_jurisdiction_code varchar2(30);
7198 l_matched_vrbl_prfl varchar2(1) := 'N';
7199 l_all_ctr number := 0;
7200 l_ttl_cvg number;
7201 l_ttl_prtt number;
7202 l_loop_count number;
7203 l_typ_rec ben_person_object.g_cache_typ_table;
7204 l_ast_rec per_assignment_status_types%rowtype;
7205 l_appass_rec ben_person_object.g_cache_ass_table;
7206 --
7207 l_effective_date date;
7208 l_eligible boolean;
7209 -- FONM
7210 l_fonm_cvg_strt_dt date;
7211 l_score_tab ben_evaluate_elig_profiles.scoreTab;
7212 l_inst_set ben_rtp_cache.g_cobcep_odcache;
7213 --
7214 --
7215 begin
7216 --
7217 hr_utility.set_location ('Entering '||l_package,10);
7218 hr_utility.set_location( 'elig per elect id ' || p_elig_per_elctbl_chc_id, 610.3);
7219 --Bug 5077452
7220 if fnd_global.conc_request_id = -1 then
7221 --
7222 ben_env_object.init(p_business_group_id => p_business_group_id,
7223 p_effective_date => p_effective_date,
7224 p_thread_id => 1,
7225 p_chunk_size => 1,
7226 p_threads => 1,
7227 p_max_errors => 1,
7228 p_benefit_action_id => null);
7229 --
7230 end if;
7231 --
7232 -- FONM
7233 if ben_manage_life_events.fonm = 'Y' then
7234 --
7235 l_fonm_cvg_strt_dt := nvl(ben_manage_life_events.g_fonm_rt_strt_dt,
7236 ben_manage_life_events.g_fonm_cvg_strt_dt);
7237 --
7238 end if;
7239 --
7240 l_effective_date := nvl(p_lf_evt_ocrd_dt,p_effective_date);
7241 --
7242 if p_all_prfls then
7243 hr_utility.set_location('p_all_prfls -> true',11);
7244 else hr_utility.set_location('p_all_prfls -> false',11); end if;
7245 if p_use_globals then
7246 hr_utility.set_location('p_use_globals -> true',11);
7247 else hr_utility.set_location('p_use_globals -> false',11); end if;
7248
7249 if p_person_id is NULL then
7250 fnd_message.set_name('BEN','BEN_91521_BERP_PERSON_ID');
7251 fnd_message.set_token('PACKAGE',l_package);
7252 fnd_message.set_token('PGM_ID',to_char(p_pgm_id));
7253 fnd_message.set_token('PL_TYP_ID',to_char(p_pl_typ_id));
7254 fnd_message.set_token('PL_ID',to_char(p_pl_id));
7255 fnd_message.set_token('OIPL_ID',to_char(p_oipl_id));
7256 fnd_message.set_token('LF_EVT_OCRD_DT',p_lf_evt_ocrd_dt);
7257 fnd_message.set_token('PER_IN_LER_ID',to_char(p_per_in_ler_id));
7258 fnd_message.set_token('ELIG_PER_ELCTBL_CHC_ID',p_elig_per_elctbl_chc_id);
7259 fnd_message.set_token('EFFECTIVE_DATE',p_effective_date);
7260 fnd_message.raise_error;
7261 elsif p_effective_date is NULL then
7262 fnd_message.set_name('BEN','BEN_91522_BERP_EFF_DATE');
7263 fnd_message.set_token('PACKAGE',l_package);
7264 fnd_message.set_token('PERSON_ID',p_person_id);
7265 fnd_message.set_token('PGM_ID',to_char(p_pgm_id));
7266 fnd_message.set_token('PL_TYP_ID',to_char(p_pl_typ_id));
7267 fnd_message.set_token('PL_ID',to_char(p_pl_id));
7268 fnd_message.set_token('OIPL_ID',to_char(p_oipl_id));
7269 fnd_message.set_token('LF_EVT_OCRD_DT',p_lf_evt_ocrd_dt);
7270 fnd_message.set_token('PER_IN_LER_ID',to_char(p_per_in_ler_id));
7271 fnd_message.set_token('ELIG_PER_ELCTBL_CHC_ID',p_elig_per_elctbl_chc_id);
7272 fnd_message.raise_error;
7273 elsif p_elig_per_elctbl_chc_id is NULL and
7274 p_calc_only_rt_val_flag = FALSE then
7275 fnd_message.set_name('BEN','BEN_91523_BERP_ELECTBL_CHC');
7276 fnd_message.set_token('PACKAGE',l_package);
7277 fnd_message.set_token('PERSON_ID',p_person_id);
7278 fnd_message.set_token('PGM_ID',to_char(p_pgm_id));
7279 fnd_message.set_token('PL_TYP_ID',to_char(p_pl_typ_id));
7280 fnd_message.set_token('PL_ID',to_char(p_pl_id));
7281 fnd_message.set_token('OIPL_ID',to_char(p_oipl_id));
7282 fnd_message.set_token('LF_EVT_OCRD_DT',p_lf_evt_ocrd_dt);
7283 fnd_message.set_token('PER_IN_LER_ID',to_char(p_per_in_ler_id));
7284 fnd_message.set_token('EFFECTIVE_DATE',p_effective_date);
7285 fnd_message.raise_error;
7286 elsif (p_acty_base_rt_id is NULL and
7287 p_actl_prem_id is NULL and
7288 p_cvg_amt_calc_mthd_id is NULL) then
7289 fnd_message.set_name('BEN','BEN_91524_BERP_MISS_PRFL_ID');
7290 fnd_message.set_token('PACKAGE',l_package);
7291 fnd_message.set_token('PERSON_ID',p_person_id);
7292 fnd_message.set_token('PGM_ID',to_char(p_pgm_id));
7293 fnd_message.set_token('PL_TYP_ID',to_char(p_pl_typ_id));
7294 fnd_message.set_token('PL_ID',to_char(p_pl_id));
7295 fnd_message.set_token('OIPL_ID',to_char(p_oipl_id));
7296 fnd_message.set_token('LF_EVT_OCRD_DT',p_lf_evt_ocrd_dt);
7297 fnd_message.set_token('PER_IN_LER_ID',to_char(p_per_in_ler_id));
7298 fnd_message.set_token('EFFECTIVE_DATE',p_effective_date);
7299 fnd_message.raise_error;
7300 elsif (p_acty_base_rt_id is not NULL and
7301 p_actl_prem_id is not NULL) or
7302 (p_acty_base_rt_id is not NULL and
7303 p_cvg_amt_calc_mthd_id is not NULL) or
7304 (p_actl_prem_id is not NULL and
7305 p_cvg_amt_calc_mthd_id is not NULL) then
7306 fnd_message.set_name('BEN','BEN_91525_BERP_MULTI_PRFL_ID');
7307 fnd_message.set_token('PACKAGE',l_package);
7308 fnd_message.set_token('PERSON_ID',p_person_id);
7309 fnd_message.set_token('PGM_ID',to_char(p_pgm_id));
7310 fnd_message.set_token('PL_TYP_ID',to_char(p_pl_typ_id));
7311 fnd_message.set_token('PL_ID',to_char(p_pl_id));
7312 fnd_message.set_token('OIPL_ID',to_char(p_oipl_id));
7313 fnd_message.set_token('LF_EVT_OCRD_DT',p_lf_evt_ocrd_dt);
7314 fnd_message.set_token('PER_IN_LER_ID',to_char(p_per_in_ler_id));
7315 fnd_message.set_token('EFFECTIVE_DATE',p_effective_date);
7316 fnd_message.raise_error;
7317 end if;
7318
7319 if p_per_row.person_id is null then
7320 --
7321 ben_person_object.get_object -- FONM : 9999 do we need to rebuild the cache
7322 (p_person_id => p_person_id
7323 ,p_rec => l_per_rec
7324 );
7325 --
7326 else
7327 --
7328 l_per_rec := p_per_row;
7329 --
7330 end if;
7331
7332 -- fonm check the date of the person cache
7333 if not nvl(l_fonm_cvg_strt_dt,l_effective_date)
7334 between l_per_rec.effective_start_date and l_per_rec.effective_end_date then
7335
7336 hr_utility.set_location('clearing cache' || nvl(l_fonm_cvg_strt_dt,l_effective_date) ,10);
7337 hr_utility.set_location('cache start ' || l_per_rec.effective_start_date ,10);
7338 hr_utility.set_location('cache end ' || l_per_rec.effective_end_date ,10);
7339
7340 ben_use_cvg_rt_date.fonm_clear_down_cache;
7341 --
7342 ben_person_object.get_object(p_person_id => p_person_id,
7343 p_rec => l_per_rec);
7344
7345 hr_utility.set_location('nw cache start ' || l_per_rec.effective_start_date ,10);
7346 hr_utility.set_location('nw cache end ' || l_per_rec.effective_end_date ,10);
7347 end if ;
7348
7349
7350
7351 if p_asg_row.assignment_id is null then
7352 --
7353 ben_person_object.get_object -- FONM : 9999 do we need to rebuild the cache
7354 (p_person_id => p_person_id
7355 ,p_rec => l_asg_rec );
7356 --
7357 else
7358 --
7359 l_asg_rec := p_asg_row;
7360 --
7361 end if;
7362
7363
7364
7365 --
7366
7367 if l_asg_rec.assignment_id is null then
7368 --
7369 ben_person_object.get_benass_object -- FONM : 9999 do we need to rebuild the cache
7370 (p_person_id => p_person_id
7371 ,p_rec => l_asg_rec );
7372 --
7373 -- If benefit assignment not found, get applicant assignment.
7374 --
7375 if l_asg_rec.assignment_id is null then
7376 --
7377 ben_person_object.get_object(p_person_id => p_person_id, -- FONM : 9999 do we need to rebuild the cache
7378 p_rec => l_appass_rec );
7379 --
7380 else
7381 --
7382 ben_person_object.get_object
7383 (p_assignment_status_type_id => l_asg_rec.assignment_status_type_id -- FONM : 9999 do we need to rebuild the cache
7384 ,p_rec => l_ast_rec );
7385 --
7386 end if;
7387 --
7388 else
7389 --
7390 if p_ast_row.assignment_status_type_id is null then
7391 --
7392 ben_person_object.get_object -- FONM : 9999 do we need to rebuild the cache
7393 (p_assignment_status_type_id => l_asg_rec.assignment_status_type_id
7394 ,p_rec => l_ast_rec
7395 );
7396 --
7397 else
7398 --
7399 l_ast_rec := p_ast_row;
7400 --
7401 end if;
7402 --
7403 end if;
7404 --
7405 -- Check if the address row is passed in
7406 --
7407 if p_adr_row.address_id is null then
7408 --
7409 ben_person_object.get_object -- FONM : 9999 do we need to rebuild the cache
7410 (p_person_id => p_person_id
7411 ,p_rec => l_adr_rec
7412 );
7413 --
7414 else
7415 --
7416 l_adr_rec := p_adr_row;
7417 --
7418 end if;
7419 --
7420 if l_asg_rec.location_id is not null then
7421 --
7422 ben_location_object.get_object -- FONM : 9999 do we need to rebuild the cache
7423 (p_location_id => l_asg_rec.location_id
7424 ,p_rec => l_loc_rec);
7425 --
7426 -- if l_loc_rec.region_2 is not null then
7427 --
7428 -- l_jurisdiction_code :=
7429 -- pay_mag_utils.lookup_jurisdiction_code
7430 -- (p_state => l_loc_rec.region_2);
7431 --
7432 -- end if;
7433 --
7434 end if;
7435 --
7436 if p_calc_only_rt_val_flag then
7437 --
7438 l_epe.pgm_id := p_pgm_id;
7439 l_epe.pl_id := p_pl_id;
7440 l_epe.pl_typ_id := p_pl_typ_id;
7441 l_epe.oipl_id := p_oipl_id;
7442 l_epe.per_in_ler_id := p_per_in_ler_id;
7443 l_epe.ler_id := p_ler_id;
7444 l_epe.business_group_id := p_business_group_id;
7445 --
7446 -- Check if the context row is populated
7447 --
7448 elsif p_currepe_row.elig_per_elctbl_chc_id is not null
7449 then
7450 --
7451 hr_utility.set_location( ' else if ',610);
7452 hr_utility.set_location( ' PLIP ID '|| p_currepe_row.plip_id ,610);
7453 l_epe.pgm_id := p_currepe_row.pgm_id;
7454 l_epe.pl_id := p_currepe_row.pl_id;
7455 l_epe.pl_typ_id := p_currepe_row.pl_typ_id;
7456 l_epe.oipl_id := p_currepe_row.oipl_id;
7457 l_epe.oiplip_id := p_currepe_row.oiplip_id; --9999
7458 l_epe.per_in_ler_id := p_currepe_row.per_in_ler_id;
7459 l_epe.ler_id := p_currepe_row.ler_id;
7460 l_epe.plip_id := p_currepe_row.plip_id;
7461 l_epe.business_group_id := p_currepe_row.business_group_id;
7462 --
7463 else
7464 hr_utility.set_location( ' in cursor ',610) ;
7465 open c_epe;
7466 fetch c_epe into l_epe;
7467 close c_epe;
7468 end if;
7469 --
7470 hr_utility.set_location(' oipl id ' || l_epe.oipl_id , 610.3);
7471 hr_utility.set_location( ' PLIP ID '|| l_epe.plip_id ,610);
7472 if l_epe.oipl_id is not null then
7473 ben_comp_object.get_object(p_oipl_id => l_epe.oipl_id
7474 ,p_rec => l_oipl_rec);
7475 end if;
7476 --
7477 if p_use_globals then
7478 l_all_ctr := g_all_prfls.first;
7479 end if;
7480 --
7481 -- Mallik: Removed the cursors and introduced the call to vapro cache
7482 --
7483 if not (p_actl_prem_id is not NULL and p_use_globals) then
7484 ben_rtp_cache.abravr_odgetdets
7485 (p_effective_date => nvl(l_fonm_cvg_strt_dt,l_effective_date)
7486 ,p_acty_base_rt_id => p_acty_base_rt_id
7487 ,p_cvg_amt_calc_mthd_id => p_cvg_amt_calc_mthd_id
7488 ,p_actl_prem_id => p_actl_prem_id
7489 ,p_inst_set => l_inst_set
7490 );
7491 end if;
7492
7493 hr_utility.set_location ('Prof loop '||l_package,10);
7494 for i in 1..l_inst_set.count
7495 loop
7496 --
7497 begin
7498
7499 l_profile := l_inst_set(i);
7500
7501 if p_actl_prem_id is not NULL then
7502
7503 if p_use_globals then
7504 if l_all_ctr is null then
7505 exit;
7506 end if;
7507
7508 -- load fields that process will use from globals instead of cursor:
7509 l_profile.vrbl_rt_prfl_id := g_all_prfls(l_all_ctr).vrbl_rt_prfl_id;
7510 l_profile.asmt_to_use_cd := g_all_prfls(l_all_ctr).asmt_to_use_cd ;
7511 l_profile.rt_hrly_slrd_flag := g_all_prfls(l_all_ctr).rt_hrly_slrd_flag ;
7512 l_profile.rt_pstl_cd_flag := g_all_prfls(l_all_ctr).rt_pstl_cd_flag ;
7513 l_profile.rt_lbr_mmbr_flag := g_all_prfls(l_all_ctr).rt_lbr_mmbr_flag ;
7514 l_profile.rt_lgl_enty_flag := g_all_prfls(l_all_ctr).rt_lgl_enty_flag ;
7515 l_profile.rt_benfts_grp_flag := g_all_prfls(l_all_ctr).rt_benfts_grp_flag ;
7516 l_profile.rt_wk_loc_flag := g_all_prfls(l_all_ctr).rt_wk_loc_flag ;
7517 l_profile.rt_brgng_unit_flag := g_all_prfls(l_all_ctr).rt_brgng_unit_flag ;
7518 l_profile.rt_age_flag := g_all_prfls(l_all_ctr).rt_age_flag ;
7519 l_profile.rt_los_flag := g_all_prfls(l_all_ctr).rt_los_flag ;
7520 l_profile.rt_per_typ_flag := g_all_prfls(l_all_ctr).rt_per_typ_flag ;
7521 l_profile.rt_fl_tm_pt_tm_flag:= g_all_prfls(l_all_ctr).rt_fl_tm_pt_tm_flag ;
7522 l_profile.rt_ee_stat_flag := g_all_prfls(l_all_ctr).rt_ee_stat_flag ;
7523 l_profile.rt_grd_flag := g_all_prfls(l_all_ctr).rt_grd_flag ;
7524 l_profile.rt_pct_fl_tm_flag := g_all_prfls(l_all_ctr).rt_pct_fl_tm_flag ;
7525 l_profile.rt_asnt_set_flag := g_all_prfls(l_all_ctr).rt_asnt_set_flag ;
7526 l_profile.rt_hrs_wkd_flag := g_all_prfls(l_all_ctr).rt_hrs_wkd_flag ;
7527 l_profile.rt_comp_lvl_flag := g_all_prfls(l_all_ctr).rt_comp_lvl_flag ;
7528 l_profile.rt_org_unit_flag := g_all_prfls(l_all_ctr).rt_org_unit_flag ;
7529 l_profile.rt_loa_rsn_flag := g_all_prfls(l_all_ctr).rt_loa_rsn_flag ;
7530 l_profile.rt_pyrl_flag := g_all_prfls(l_all_ctr).rt_pyrl_flag ;
7531 l_profile.rt_schedd_hrs_flag := g_all_prfls(l_all_ctr).rt_schedd_hrs_flag ;
7532 l_profile.rt_py_bss_flag := g_all_prfls(l_all_ctr).rt_py_bss_flag ;
7533 l_profile.rt_prfl_rl_flag := g_all_prfls(l_all_ctr).rt_prfl_rl_flag ;
7534 l_profile.rt_cmbn_age_los_flag := g_all_prfls(l_all_ctr).rt_cmbn_age_los_flag ;
7535 l_profile.rt_prtt_pl_flag := g_all_prfls(l_all_ctr).rt_prtt_pl_flag ;
7536 l_profile.rt_svc_area_flag := g_all_prfls(l_all_ctr).rt_svc_area_flag ;
7537 l_profile.rt_ppl_grp_flag := g_all_prfls(l_all_ctr).rt_ppl_grp_flag ;
7538 l_profile.rt_dsbld_flag := g_all_prfls(l_all_ctr).rt_dsbld_flag ;
7539 l_profile.rt_hlth_cvg_flag := g_all_prfls(l_all_ctr).rt_hlth_cvg_flag ;
7540 l_profile.rt_poe_flag := g_all_prfls(l_all_ctr).rt_poe_flag ;
7541 l_profile.rt_ttl_cvg_vol_flag:= g_all_prfls(l_all_ctr).rt_ttl_cvg_vol_flag ;
7542 l_profile.rt_ttl_prtt_flag := g_all_prfls(l_all_ctr).rt_ttl_prtt_flag ;
7543 l_profile.rt_gndr_flag := g_all_prfls(l_all_ctr).rt_gndr_flag ;
7544 l_profile.rt_tbco_use_flag := g_all_prfls(l_all_ctr).rt_tbco_use_flag ;
7545 l_profile.rt_cntng_prtn_prfl_flag := g_all_prfls(l_all_ctr).rt_cntng_prtn_prfl_flag;
7546 l_profile.rt_cbr_quald_bnf_flag := g_all_prfls(l_all_ctr).rt_cbr_quald_bnf_flag;
7547 l_profile.rt_optd_mdcr_flag := g_all_prfls(l_all_ctr).rt_optd_mdcr_flag;
7548 l_profile.rt_lvg_rsn_flag := g_all_prfls(l_all_ctr).rt_lvg_rsn_flag;
7549 l_profile.rt_pstn_flag := g_all_prfls(l_all_ctr).rt_pstn_flag;
7550 l_profile.rt_comptncy_flag := g_all_prfls(l_all_ctr).rt_comptncy_flag;
7551 l_profile.rt_job_flag := g_all_prfls(l_all_ctr).rt_job_flag;
7552 l_profile.rt_qual_titl_flag := g_all_prfls(l_all_ctr).rt_qual_titl_flag;
7553 l_profile.rt_dpnt_cvrd_pl_flag := g_all_prfls(l_all_ctr).rt_dpnt_cvrd_pl_flag;
7554 l_profile.rt_dpnt_cvrd_plip_flag := g_all_prfls(l_all_ctr).rt_dpnt_cvrd_plip_flag;
7555 l_profile.rt_dpnt_cvrd_ptip_flag := g_all_prfls(l_all_ctr).rt_dpnt_cvrd_ptip_flag;
7556 l_profile.rt_dpnt_cvrd_pgm_flag := g_all_prfls(l_all_ctr).rt_dpnt_cvrd_pgm_flag;
7557 l_profile.rt_enrld_oipl_flag := g_all_prfls(l_all_ctr).rt_enrld_oipl_flag;
7558 l_profile.rt_enrld_pl_flag := g_all_prfls(l_all_ctr).rt_enrld_pl_flag;
7559 l_profile.rt_enrld_plip_flag := g_all_prfls(l_all_ctr).rt_enrld_plip_flag;
7560 l_profile.rt_enrld_ptip_flag := g_all_prfls(l_all_ctr).rt_enrld_ptip_flag;
7561 l_profile.rt_enrld_pgm_flag := g_all_prfls(l_all_ctr).rt_enrld_pgm_flag;
7562 l_profile.rt_prtt_anthr_pl_flag := g_all_prfls(l_all_ctr).rt_prtt_anthr_pl_flag;
7563 l_profile.rt_othr_ptip_flag := g_all_prfls(l_all_ctr).rt_othr_ptip_flag;
7564 l_profile.rt_no_othr_cvg_flag := g_all_prfls(l_all_ctr).rt_no_othr_cvg_flag;
7565 l_profile.rt_dpnt_othr_ptip_flag := g_all_prfls(l_all_ctr).rt_dpnt_othr_ptip_flag;
7566 l_profile.rt_qua_in_gr_flag := g_all_prfls(l_all_ctr).rt_qua_in_gr_flag;
7567 l_profile.rt_perf_rtng_flag := g_all_prfls(l_all_ctr).rt_perf_rtng_flag;
7568 l_profile.rt_elig_prfl_flag := g_all_prfls(l_all_ctr).rt_elig_prfl_flag;
7569
7570 --
7571 -- use total counts for all prtts in this plan or oipl that match
7572 -- this particular vrbl rate's criteria.
7573 --
7574 l_ttl_prtt := g_all_prfls(l_all_ctr).match_cnt;
7575 l_ttl_cvg := g_all_prfls(l_all_ctr).match_cvg;
7576 -- get ready for next loop
7577 l_all_ctr := g_all_prfls.next(l_all_ctr);
7578 --
7579 else
7580 --
7581 -- use total counts for all prtts in this plan or oipl
7582 --
7583 l_ttl_prtt := p_ttl_prtt;
7584 l_ttl_cvg := p_ttl_cvg;
7585 --
7586 end if;
7587 --
7588 end if;
7589 --
7590 ben_person_object.get_object(p_person_id => p_person_id, -- FONM 9999
7591 p_rec => l_typ_rec);
7592 --
7593 hr_utility.set_location('l_profile.vrbl_rt_prfl_id -> '||l_profile.vrbl_rt_prfl_id,11);
7594 hr_utility.set_location('l_profile.rt_per_typ_flag -> '||l_profile.rt_per_typ_flag,11);
7595 --
7596 if l_profile.rt_elig_prfl_flag = 'Y' then
7597 hr_utility.set_location('elig_for_profiles',10);
7598
7599 l_eligible :=
7600 ben_evaluate_elig_profiles.eligible
7601 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id
7602 ,p_person_id => p_person_id
7603 ,p_business_group_id => p_business_group_id
7604 ,p_effective_date => p_effective_date
7605 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt
7606 ,p_per_in_ler_id => p_per_in_ler_id
7607 ,p_ler_id => p_ler_id
7608 ,p_pgm_id => l_epe.pgm_id
7609 ,p_ptip_id => l_epe.ptip_id
7610 ,p_plip_id => nvl(p_currepe_row.plip_id,l_epe.plip_id)
7611 ,p_pl_id => l_epe.pl_id
7612 ,p_oipl_id => l_epe.oipl_id
7613 ,p_oiplip_id => l_epe.oiplip_id
7614 ,p_pl_typ_id => l_epe.pl_typ_id
7615 ,p_opt_id => nvl(p_currepe_row.opt_id,l_oipl_rec.opt_id)
7616 ,p_par_pgm_id => p_currepe_row.pgm_id
7617 ,p_par_plip_id => p_currepe_row.plip_id
7618 ,p_par_pl_id => p_currepe_row.pl_id
7619 ,p_par_opt_id => p_currepe_row.opt_id
7620 ,p_currepe_row => p_currepe_row
7621 ,p_ttl_prtt => l_ttl_prtt
7622 ,p_ttl_cvg => l_ttl_cvg
7623 ,p_all_prfls => p_all_prfls
7624 ,p_score_tab => l_score_tab
7625 ,p_eval_typ => 'V'
7626 );
7627 --
7628 if not l_eligible then
7629 --
7630 raise g_profile_failed;
7631 --
7632 end if;
7633 end if;
7634 hr_utility.set_location ('Dn elig_for_profiles '||l_package,10);
7635
7636 if l_profile.rt_per_typ_flag = 'Y' then
7637 hr_utility.set_location('check_per_typ',10);
7638 check_per_typ
7639 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
7640 p_person_id => p_person_id,
7641 p_business_group_id => p_business_group_id,
7642 p_effective_date => p_effective_date,
7643 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
7644 p_person_type => l_typ_rec);
7645 end if;
7646 hr_utility.set_location ('Dn check_per_typ '||l_package,10);
7647 --
7648 -- Now we check these profiles using the required assignment type
7649 --
7650 l_loop_count := 1;
7651 --
7652 if l_profile.asmt_to_use_cd = 'EAO' then
7653 --
7654 -- Employee assignment only
7655 --
7656 l_asg_rec := NULL; --Bug 6399423
7657 ben_person_object.get_object(p_person_id => p_person_id,
7658 p_rec => l_asg_rec);
7659 --
7660 elsif l_profile.asmt_to_use_cd = 'BAO' then
7661 --
7662 -- Benefit assignment only
7663 --
7664 l_asg_rec := NULL; --Bug 6399423
7665 ben_person_object.get_benass_object(p_person_id => p_person_id,
7666 p_rec => l_asg_rec);
7667 --
7668 elsif l_profile.asmt_to_use_cd = 'ANY' then
7669 --
7670 -- First assignment only
7671 --
7672 ben_person_object.get_allass_object(p_person_id => p_person_id,
7673 p_rec => l_appass_rec);
7674 --
7675 if not l_appass_rec.exists(1) then
7676 --
7677 -- Initialize first record so that one time test works
7678 --
7679 l_appass_rec(1).person_id := p_person_id;
7680 --
7681 end if;
7682 --
7683 l_asg_rec := l_appass_rec(1);
7684 l_loop_count := l_appass_rec.count;
7685 --
7686 elsif l_profile.asmt_to_use_cd = 'AAO' then
7687 --
7688 -- Applicant assignment only
7689 --
7690 ben_person_object.get_object(p_person_id => p_person_id,
7691 p_rec => l_appass_rec);
7692 --
7693 if not l_appass_rec.exists(1) then
7694 --
7695 -- Initialize first record so that one time test works
7696 --
7697 l_appass_rec(1).person_id := p_person_id;
7698 --
7699 end if;
7700 --
7701 l_asg_rec := l_appass_rec(1);
7702 l_loop_count := l_appass_rec.count;
7703 --
7704 elsif l_profile.asmt_to_use_cd = 'ETB' then
7705 --
7706 -- Employee then Benefits assignment only
7707 --
7708 ben_person_object.get_object(p_person_id => p_person_id,
7709 p_rec => l_asg_rec);
7710 --
7711 if l_asg_rec.assignment_id is null then
7712 --
7713 -- Get Benefits Assignment
7714 --
7715 ben_person_object.get_benass_object(p_person_id => p_person_id,
7716 p_rec => l_asg_rec);
7717 --
7718 end if;
7719 --
7720 elsif l_profile.asmt_to_use_cd = 'BTE' then
7721 --
7722 -- Benefits then Employee assignment only
7723 --
7724 ben_person_object.get_benass_object(p_person_id => p_person_id,
7725 p_rec => l_asg_rec);
7726 --
7727 if l_asg_rec.assignment_id is null then
7728 --
7729 -- Get Employee Assignment
7730 --
7731 ben_person_object.get_object(p_person_id => p_person_id,
7732 p_rec => l_asg_rec);
7733 --
7734 end if;
7735 --
7736 elsif l_profile.asmt_to_use_cd = 'EBA' then
7737 --
7738 -- Employee then Benefits then Applicant assignment only
7739 --
7740 ben_person_object.get_object(p_person_id => p_person_id,
7741 p_rec => l_asg_rec);
7742 --
7743 if l_asg_rec.assignment_id is null then
7744 --
7745 -- Get Benefits Assignment
7746 --
7747 ben_person_object.get_benass_object(p_person_id => p_person_id,
7748 p_rec => l_asg_rec);
7749 --
7750 if l_asg_rec.assignment_id is null then
7751 --
7752 -- Applicant assignment only
7753 --
7754 ben_person_object.get_object(p_person_id => p_person_id,
7755 p_rec => l_appass_rec);
7756 --
7757 if not l_appass_rec.exists(1) then
7758 --
7759 -- Initialize first record so that one time test works
7760 --
7761 l_appass_rec(1).person_id := p_person_id;
7762 --
7763 end if;
7764 --
7765 l_asg_rec := l_appass_rec(1);
7766 l_loop_count := l_appass_rec.count;
7767 --
7768 end if;
7769 --
7770 end if;
7771 --
7772 end if;
7773 --
7774 -- Bug 6399423
7775 hr_utility.set_location ('l_asg_rec'|| l_asg_rec.assignment_id,534511234);
7776 --
7777 if (l_profile.asmt_to_use_cd <> 'ANY' and
7778 l_asg_rec.assignment_id is null) then
7779 --
7780 raise ben_evaluate_rate_profiles.g_profile_failed;
7781 end if;
7782 --
7783 -- Bug 6399423
7784 hr_utility.set_location ('ASG Profs '||l_package,10);
7785 for l_count in 1..l_loop_count loop
7786 --
7787 begin
7788 --
7789 if l_loop_count > 1 then
7790 --
7791 -- Make sure that we pass in the correct assignment
7792 --
7793 l_asg_rec := l_appass_rec(l_count);
7794 --
7795 end if;
7796 --
7797 -- Employee Status
7798 --
7799 if l_profile.rt_ee_stat_flag = 'Y' then
7800 hr_utility.set_location('check_ee_stat',10);
7801 check_ee_stat
7802 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
7803 p_person_id => p_person_id,
7804 p_business_group_id => p_business_group_id,
7805 p_effective_date => p_effective_date,
7806 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
7807 p_assignment_status_type_id => l_asg_rec.assignment_status_type_id);
7808 end if;
7809 --
7810 -- People Group
7811 --
7812 if l_profile.rt_ppl_grp_flag = 'Y' then
7813 hr_utility.set_location('check_people_group',10);
7814 check_people_group
7815 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
7816 p_business_group_id => p_business_group_id,
7817 p_effective_date => p_effective_date,
7818 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
7819 p_people_group_id => l_asg_rec.people_group_id);
7820 end if;
7821 --
7822 -- Hourly/Salary Code
7823 --
7824 if l_profile.rt_hrly_slrd_flag = 'Y' then
7825 hr_utility.set_location('check_hourly_salary',10);
7826 check_hourly_salary
7827 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
7828 p_business_group_id => p_business_group_id,
7829 p_effective_date => p_effective_date,
7830 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
7831 p_hrly_slry => l_asg_rec.hourly_salaried_code);
7832 end if;
7833 --
7834 -- Bargaining Unit
7835 --
7836 if l_profile.rt_brgng_unit_flag = 'Y' then
7837 hr_utility.set_location('check_brgng_unit',10);
7838 check_brgng_unit
7839 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
7840 p_business_group_id => p_business_group_id,
7841 p_effective_date => p_effective_date,
7842 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
7843 p_bargaining_unit_code => l_asg_rec.bargaining_unit_code);
7844 end if;
7845 --
7846 -- Labor Union
7847 --
7848 if l_profile.rt_lbr_mmbr_flag = 'Y' then
7849 hr_utility.set_location('check_lbr_union',10);
7850 check_lbr_union
7851 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
7852 p_person_id => p_person_id,
7853 p_business_group_id => p_business_group_id,
7854 p_effective_date => p_effective_date,
7855 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
7856 p_labour_union_member_flag => l_asg_rec.labour_union_member_flag);
7857 end if;
7858 --
7859 -- Full Time / Part Time
7860 --
7861 if l_profile.rt_fl_tm_pt_tm_flag = 'Y' then
7862 hr_utility.set_location('check_fl_tm_pt',10);
7863 check_fl_tm_pt
7864 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
7865 p_person_id => p_person_id,
7866 p_business_group_id => p_business_group_id,
7867 p_effective_date => p_effective_date,
7868 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
7869 p_employment_category => l_asg_rec.employment_category);
7870 end if;
7871 --
7872 -- Work Location
7873 --
7874 if l_profile.rt_wk_loc_flag = 'Y' then
7875 hr_utility.set_location('check_wk_location',10);
7876 check_wk_location
7877 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
7878 p_person_id => p_person_id,
7879 p_business_group_id => p_business_group_id,
7880 p_effective_date => p_effective_date,
7881 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
7882 p_location_id => l_asg_rec.location_id);
7883 end if;
7884 --
7885 -- Organization
7886 --
7887 if l_profile.rt_org_unit_flag = 'Y' then
7888 hr_utility.set_location('check_org_unit',10);
7889 check_org_unit
7890 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
7891 p_person_id => p_person_id,
7892 p_business_group_id => p_business_group_id,
7893 p_effective_date => p_effective_date,
7894 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
7895 p_org_id => l_asg_rec.organization_id);
7896 end if;
7897 --
7898 -- LOA
7899 --
7900 if l_profile.rt_loa_rsn_flag = 'Y' then
7901 hr_utility.set_location('check_loa_rsn',10);
7902 check_loa_rsn
7903 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
7904 p_person_id => p_person_id,
7905 p_business_group_id => p_business_group_id,
7906 p_effective_date => p_effective_date,
7907 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt);
7908 end if;
7909 --
7910 -- Scheduled Hours
7911 --
7912 if l_profile.rt_schedd_hrs_flag = 'Y' then
7913 hr_utility.set_location('check_sched_hrs',10);
7914 check_sched_hrs
7915 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
7916 p_person_id => p_person_id,
7917 p_business_group_id => p_business_group_id,
7918 p_effective_date => p_effective_date,
7919 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
7920 p_normal_hrs => l_asg_rec.normal_hours,
7921 p_frequency => l_asg_rec.frequency,
7922 p_per_in_ler_id => l_epe.per_in_ler_id,
7923 p_assignment_id => l_asg_rec.assignment_id,
7924 p_organization_id => l_asg_rec.organization_id,
7925 p_pgm_id => l_epe.pgm_id,
7926 p_pl_id => l_epe.pl_id,
7927 p_pl_typ_id => l_epe.pl_typ_id,
7928 p_opt_id => l_oipl_rec.opt_id,
7929 p_oipl_id => l_epe.oipl_id,
7930 p_ler_id => l_epe.ler_id,
7931 p_jurisdiction_code => l_jurisdiction_code);
7932 end if;
7933 --
7934 -- Pay Basis
7935 --
7936 if l_profile.rt_py_bss_flag = 'Y' then
7937 hr_utility.set_location('check_py_bss',10);
7938 check_py_bss
7939 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
7940 p_person_id => p_person_id,
7941 p_business_group_id => p_business_group_id,
7942 p_effective_date => p_effective_date,
7943 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
7944 p_pay_basis_id => l_asg_rec.pay_basis_id);
7945 end if;
7946 --
7947 -- Grade
7948 --
7949 if l_profile.rt_grd_flag = 'Y' then
7950 hr_utility.set_location('check_grade',10);
7951 check_grade
7952 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
7953 p_person_id => p_person_id,
7954 p_business_group_id => p_business_group_id,
7955 p_effective_date => p_effective_date,
7956 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
7957 p_grade_id => l_asg_rec.grade_id);
7958 end if;
7959 --
7960 -- Legal Entity
7961 --
7962 if l_profile.rt_lgl_enty_flag = 'Y' then
7963 hr_utility.set_location('check_lgl_enty',10);
7964 open c_gre(l_asg_rec.soft_coding_keyflex_id);
7965 --
7966 fetch c_gre into l_gre_id;
7967 --
7968 close c_gre;
7969 --
7970 check_lgl_enty
7971 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
7972 p_person_id => p_person_id,
7973 p_business_group_id => p_business_group_id,
7974 p_effective_date => p_effective_date,
7975 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
7976 p_gre_id => l_gre_id);
7977 end if;
7978 --
7979 -- Payroll
7980 --
7981 if l_profile.rt_pyrl_flag = 'Y' then
7982 hr_utility.set_location('check_pyrl',10);
7983 check_pyrl
7984 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
7985 p_person_id => p_person_id,
7986 p_business_group_id => p_business_group_id,
7987 p_effective_date => p_effective_date,
7988 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
7989 p_payroll_id => l_asg_rec.payroll_id);
7990 end if;
7991
7992 --
7993 -- Job
7994 --
7995 if l_profile.rt_job_flag = 'Y' then
7996 hr_utility.set_location('check_job',10);
7997 check_job
7998 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
7999 p_business_group_id => p_business_group_id,
8000 p_effective_date => p_effective_date,
8001 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
8002 p_job_id => l_asg_rec.job_id);
8003 end if;
8004
8005 --
8006 -- Postion
8007 --
8008 if l_profile.rt_pstn_flag = 'Y' then
8009 hr_utility.set_location('check_pstn',10);
8010 check_pstn
8011 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
8012 p_business_group_id => p_business_group_id,
8013 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
8014 p_effective_date => p_effective_date,
8015 p_asg_position_id => l_asg_rec.position_id);
8016 end if;
8017
8018 --
8019 -- Quartile in Grade
8020 --
8021 if l_profile.rt_qua_in_gr_flag = 'Y' then
8022 hr_utility.set_location('check_qua_in_gr',10);
8023 check_qua_in_gr(p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
8024 p_business_group_id => p_business_group_id,
8025 p_person_id => p_person_id,
8026 p_grade_id => l_asg_rec.grade_id,
8027 p_assignment_id => l_asg_rec.assignment_id,
8028 p_effective_date => p_effective_date,
8029 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
8030 p_pay_basis_id => l_asg_rec.pay_basis_id);
8031 end if;
8032
8033 --
8034 -- Performance Rating
8035 --
8036 if l_profile.rt_perf_rtng_flag = 'Y' then
8037 hr_utility.set_location('check_perf_rtng',10);
8038 check_perf_rtng(p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
8039 p_business_group_id => p_business_group_id,
8040 p_assignment_id => l_asg_rec.assignment_id,
8041 p_person_id => p_person_id,
8042 p_effective_date => p_effective_date,
8043 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt);
8044 end if;
8045
8046 --
8047 -- Rules
8048 --
8049 if l_profile.rt_prfl_rl_flag = 'Y' then
8050 hr_utility.set_location('check_rules',10);
8051 check_rules
8052 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
8053 p_business_group_id => p_business_group_id,
8054 p_effective_date => p_effective_date,
8055 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
8056 p_assignment_id => l_asg_rec.assignment_id,
8057 p_organization_id => l_asg_rec.organization_id,
8058 p_pgm_id => l_epe.pgm_id,
8059 p_pl_id => l_epe.pl_id,
8060 p_pl_typ_id => l_epe.pl_typ_id,
8061 p_opt_id => l_oipl_rec.opt_id,
8062 p_ler_id => l_epe.ler_id,
8063 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
8064 p_acty_base_rt_id => p_acty_base_rt_id,
8065 p_jurisdiction_code => l_jurisdiction_code);
8066 end if;
8067 --
8068 -- all criteria passed for this profile thus far so exit this
8069 -- loop and check remaining criteria
8070 --
8071 exit;
8072 --
8073 exception
8074 --
8075 when g_criteria_failed then
8076 --
8077 -- Handle case where we want an error if we are dealing with
8078 -- the last assignment to be processed. If it is the last
8079 -- assignment then we want to error the profile.
8080 --
8081 if l_count = l_loop_count then
8082 --
8083 -- Raise error to main exception handler
8084 --
8085 raise ben_evaluate_rate_profiles.g_profile_failed;
8086 --
8087 end if;
8088 --
8089 end;
8090 --
8091 end loop;
8092 --
8093 -- now check remaining criteria
8094 --
8095 --
8096 --
8097 -- PCT Fulltime
8098 --
8099 hr_utility.set_location ('Person Profs '||l_package,10);
8100 if l_profile.rt_pct_fl_tm_flag = 'Y' then
8101 hr_utility.set_location('check_pct_fltm',10);
8102 check_pct_fltm
8103 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
8104 p_person_id => p_person_id,
8105 p_business_group_id => p_business_group_id,
8106 -- FONM : as lf_evt_ocrd_dt is not used, it's fine to overload the
8107 -- p_effective_date.
8108 p_effective_date => nvl(ben_manage_life_events.g_fonm_rt_strt_dt,
8109 nvl(ben_manage_life_events.g_fonm_cvg_strt_dt,
8110 nvl(p_lf_evt_ocrd_dt, p_effective_date))),
8111 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
8112 p_pgm_id => l_epe.pgm_id,
8113 p_pl_id => l_epe.pl_id,
8114 p_opt_id => l_oipl_rec.opt_id,
8115 p_plip_id => l_epe.plip_id);
8116 end if;
8117 --
8118 -- Benefits Group
8119 --
8120 if l_profile.rt_benfts_grp_flag = 'Y' then
8121 hr_utility.set_location('check_benefits_group',10);
8122 check_benefits_grp
8123 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
8124 p_person_id => p_person_id,
8125 p_business_group_id => p_business_group_id,
8126 p_effective_date => p_effective_date,
8127 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
8128 p_benefit_group_id => l_per_rec.benefit_group_id);
8129 end if;
8130 --
8131 -- Age
8132 --
8133 hr_utility.set_location ('DF Profs '||l_package,10);
8134 if l_profile.rt_age_flag = 'Y' then
8135 hr_utility.set_location('check_age',10);
8136 check_age
8137 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id
8138 ,p_per_dob => l_per_rec.date_of_birth
8139 ,p_person_id => p_person_id
8140 ,p_business_group_id => p_business_group_id
8141 ,p_effective_date => p_effective_date
8142 ,p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt -- fonm taken care in procedure
8143 ,p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id
8144 ,p_pl_id => l_epe.pl_id
8145 ,p_pgm_id => l_epe.pgm_id
8146 ,p_oipl_id => l_epe.oipl_id
8147 ,p_per_in_ler_id => l_epe.per_in_ler_id
8148 ,p_opt_id => p_currepe_row.opt_id
8149 ,p_plip_id => p_currepe_row.plip_id
8150 ,p_currepe_row => p_currepe_row
8151 );
8152 end if;
8153 --
8154 -- Tobacco
8155 --
8156 hr_utility.set_location ('Tobacco '||l_package,10);
8157 if l_profile.rt_tbco_use_flag = 'Y' then
8158 hr_utility.set_location('check_tobacco',10);
8159 check_tobacco
8160 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
8161 p_business_group_id => p_business_group_id,
8162 p_effective_date => p_effective_date,
8163 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
8164 --Handling NULL value for uses_tobacco_flag .Refer Bug : 6525934
8165 p_tobacco => NVL(l_per_rec.uses_tobacco_flag,'N'));
8166 end if;
8167 --
8168 -- LOS
8169 --
8170 hr_utility.set_location ('LOS Prof '||l_package,10);
8171 if l_profile.rt_los_flag = 'Y' then
8172 hr_utility.set_location('check_los',10);
8173 check_los
8174 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
8175 p_person_id => p_person_id,
8176 p_business_group_id => p_business_group_id,
8177 p_effective_date => p_effective_date,
8178 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
8179 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
8180 p_pgm_id => l_epe.pgm_id,
8181 p_oipl_id => l_epe.oipl_id,
8182 p_opt_id => p_currepe_row.opt_id,
8183 p_plip_id => p_currepe_row.plip_id,
8184 p_pl_id => l_epe.pl_id,
8185 p_currepe_row => p_currepe_row);
8186 end if;
8187 --
8188 -- Assignment set
8189 if l_profile.rt_asnt_set_flag = 'Y' then
8190 hr_utility.set_location('Assn Set Flag',10);
8191 check_asnt_set
8192 (p_VRBL_RT_PRFL_ID => l_profile.vrbl_rt_prfl_id,
8193 p_business_group_id => p_business_group_id,
8194 p_person_id => p_person_id,
8195 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
8196 p_effective_date => p_effective_date );
8197 end if;
8198 -- Hours worked
8199 --
8200 if l_profile.rt_hrs_wkd_flag = 'Y' then
8201 hr_utility.set_location('check_hrs_wkd',10);
8202 check_hrs_wkd
8203 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
8204 p_person_id => p_person_id,
8205 p_business_group_id => p_business_group_id,
8206 -- FONM : as lf_evt_ocrd_dt is not used, it's fine to overload the
8207 -- p_effective_date.
8208 p_effective_date => nvl(ben_manage_life_events.g_fonm_rt_strt_dt,
8209 nvl(ben_manage_life_events.g_fonm_cvg_strt_dt,
8210 nvl(p_lf_evt_ocrd_dt, p_effective_date))),
8211 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
8212 p_pgm_id => l_epe.pgm_id,
8213 p_pl_id => l_epe.pl_id,
8214 p_opt_id => l_oipl_rec.opt_id,
8215 p_plip_id => l_epe.plip_id);
8216 end if;
8217 --
8218 -- Postal Code
8219 --
8220 if l_profile.rt_pstl_cd_flag = 'Y' then
8221 hr_utility.set_location('check_zip_code_rng',10);
8222 check_zip_code_rng
8223 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
8224 p_person_id => p_person_id,
8225 p_business_group_id => p_business_group_id,
8226 p_effective_date => p_effective_date,
8227 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
8228 p_postal_code => l_adr_rec.postal_code);
8229 end if;
8230 --
8231 -- Service Area
8232 --
8233 if l_profile.rt_svc_area_flag = 'Y' then
8234 hr_utility.set_location('check_service_area',10);
8235 check_service_area
8236 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
8237 p_person_id => p_person_id,
8238 p_business_group_id => p_business_group_id,
8239 p_effective_date => p_effective_date,
8240 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
8241 p_postal_code => l_adr_rec.postal_code);
8242 end if;
8243 --
8244 -- Comp Level
8245 --
8246 hr_utility.set_location ('DF profs '||l_package,10);
8247 if l_profile.rt_comp_lvl_flag = 'Y' then
8248 hr_utility.set_location('check_comp_level',10);
8249 check_comp_level
8250 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
8251 p_person_id => p_person_id,
8252 p_business_group_id => p_business_group_id,
8253 p_effective_date => p_effective_date, --fonm taken care in the function
8254 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
8255 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
8256 p_pgm_id => l_epe.pgm_id,
8257 p_pl_id => l_epe.pl_id,
8258 p_oipl_id => l_epe.oipl_id,
8259 p_per_in_ler_id => l_epe.per_in_ler_id);
8260 end if;
8261 --
8262 -- Combine Age and LOS
8263 --
8264 if l_profile.rt_cmbn_age_los_flag = 'Y' then
8265 hr_utility.set_location('check_age_los',10);
8266 check_age_los
8267 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
8268 p_person_id => p_person_id,
8269 p_business_group_id => p_business_group_id,
8270 p_effective_date => p_effective_date,
8271 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
8272 p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id,
8273 p_pgm_id => l_epe.pgm_id,
8274 p_pl_id => l_epe.pl_id,
8275 p_opt_id => p_currepe_row.opt_id,
8276 p_plip_id => p_currepe_row.plip_id,
8277 p_currepe_row => p_currepe_row);
8278 end if;
8279 --
8280 -- Gender
8281 --
8282 if l_profile.rt_gndr_flag = 'Y' then
8283 hr_utility.set_location('check_gender',10);
8284 check_gender
8285 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
8286 p_business_group_id => p_business_group_id,
8287 p_effective_date => p_effective_date,
8288 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
8289 p_sex => l_per_rec.sex);
8290 end if;
8291 --
8292 -- Check period of enrollment. This is
8293 -- currently only for COBRA.
8294 --
8295 hr_utility.set_location ('COBRA profs '||l_package,10);
8296 if l_profile.rt_poe_flag = 'Y' then
8297 hr_utility.set_location('check_period_of_enrollment',10);
8298 check_period_of_enrollment
8299 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
8300 p_business_group_id => p_business_group_id,
8301 p_effective_date => p_effective_date,
8302 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
8303 p_person_id => p_person_id,
8304 p_pgm_id => p_pgm_id,
8305 p_pl_typ_id => p_pl_typ_id,
8306 p_ler_id => p_ler_id );
8307 end if;
8308 --
8309 -- Disabled
8310 --
8311 if l_profile.rt_dsbld_flag = 'Y' then
8312 hr_utility.set_location('check_dsbld_cd' || l_per_rec.registered_disabled_flag,10);
8313 check_dsbld_cd
8314 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
8315 p_business_group_id => p_business_group_id,
8316 p_effective_date => p_effective_date,
8317 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
8318 p_dsbld_cd => l_per_rec.registered_disabled_flag);
8319 end if;
8320
8321 --
8322 -- Opted for Medicare
8323 --
8324 if l_profile.rt_optd_mdcr_flag = 'Y' then
8325 hr_utility.set_location('check_optd_mdcr',10);
8326 check_optd_mdcr
8327 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
8328 p_business_group_id => p_business_group_id,
8329 p_effective_date => p_effective_date,
8330 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
8331 p_person_id => p_person_id );
8332 end if;
8333
8334 --
8335 -- Leaving Reason
8336 --
8337 if l_profile.rt_lvg_rsn_flag = 'Y' then
8338 hr_utility.set_location('check_lvg_rsn',10);
8339 check_lvg_rsn
8340 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
8341 p_business_group_id => p_business_group_id,
8342 p_effective_date => p_effective_date,
8343 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
8344 p_person_id => p_person_id );
8345 end if;
8346
8347 --
8348 -- Cobra Qualified Beneficiary
8349 --
8350 if l_profile.rt_cbr_quald_bnf_flag = 'Y' then
8351 hr_utility.set_location('check_cbr_quald_bnf',10);
8352 check_cbr_quald_bnf
8353 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
8354 p_business_group_id => p_business_group_id,
8355 p_effective_date => p_effective_date,
8356 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
8357 p_person_id => p_person_id );
8358 end if;
8359
8360 --
8361 -- Competency
8362 --
8363 if l_profile.rt_comptncy_flag = 'Y' then
8364 hr_utility.set_location('check_comptncy',10);
8365 check_comptncy
8366 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
8367 p_business_group_id => p_business_group_id,
8368 p_person_id => p_person_id ,
8369 p_effective_date => p_effective_date,
8370 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt );
8371 end if;
8372
8373 --
8374 -- Qualification title
8375 --
8376 if l_profile.rt_qual_titl_flag = 'Y' then
8377 hr_utility.set_location('check_qual_titl',10);
8378 check_qual_titl
8379 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
8380 p_business_group_id => p_business_group_id,
8381 p_person_id => p_person_id ,
8382 p_effective_date => p_effective_date,
8383 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt );
8384 end if;
8385
8386 --
8387 -- Dependent Covered Other Plan
8388 --
8389 if l_profile.rt_dpnt_cvrd_pl_flag = 'Y' then
8390 hr_utility.set_location('check_dpnt_cvrd_othr_pl',10);
8391 check_dpnt_cvrd_othr_pl
8392 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
8393 p_business_group_id => p_business_group_id,
8394 p_effective_date => p_effective_date,
8395 p_person_id => p_person_id,
8396 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt );
8397 end if;
8398
8399
8400 --
8401 -- Dependent Covered Other Plan in Program
8402 --
8403 if l_profile.rt_dpnt_cvrd_plip_flag = 'Y' then
8404 hr_utility.set_location('check_dpnt_cvrd_othr_plip',10);
8405 check_dpnt_cvrd_othr_plip
8406 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
8407 p_business_group_id => p_business_group_id,
8408 p_effective_date => p_effective_date,
8409 p_person_id => p_person_id,
8410 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt );
8411 end if;
8412
8413 --
8414 -- Dependent Covered Other Plan Type in Program
8415 --
8416 if l_profile.rt_dpnt_cvrd_ptip_flag = 'Y' then
8417 hr_utility.set_location('check_dpnt_cvrd_othr_ptip',10);
8418 check_dpnt_cvrd_othr_ptip
8419 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
8420 p_business_group_id => p_business_group_id,
8421 p_effective_date => p_effective_date,
8422 p_person_id => p_person_id,
8423 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt );
8424 end if;
8425
8426
8427 --
8428 -- Dependent Covered Other Program
8429 --
8430 if l_profile.rt_dpnt_cvrd_pgm_flag = 'Y' then
8431 hr_utility.set_location('check_dpnt_cvrd_othr_pgm',10);
8432 check_dpnt_cvrd_othr_pgm
8433 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
8434 p_business_group_id => p_business_group_id,
8435 p_effective_date => p_effective_date,
8436 p_person_id => p_person_id,
8437 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt );
8438 end if;
8439
8440
8441
8442 --
8443 -- Eligible for Another Plan
8444 --
8445 if l_profile.rt_prtt_anthr_pl_flag = 'Y' then
8446 hr_utility.set_location('check_prtt_anthr_pl',10);
8447 check_prtt_anthr_pl
8448 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
8449 p_business_group_id => p_business_group_id,
8450 -- FONM : as lf_evt_ocrd_dt is not used, it's fine to overload the
8451 -- p_effective_date.
8452 p_effective_date => nvl(ben_manage_life_events.g_fonm_rt_strt_dt,
8453 nvl(ben_manage_life_events.g_fonm_cvg_strt_dt,
8454 nvl(p_lf_evt_ocrd_dt, p_effective_date))),
8455 p_person_id => p_person_id,
8456 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt );
8457 end if;
8458
8459
8460
8461 --
8462 -- Eligible for Another Plan Type in Program
8463 --
8464 if l_profile.rt_othr_ptip_flag = 'Y' then
8465 hr_utility.set_location('check_othr_ptip',10);
8466 check_othr_ptip
8467 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
8468 p_business_group_id => p_business_group_id,
8469 -- FONM : do not overload as the lf_evt_ocrd_dt takes precedence over eff dt.
8470 p_effective_date => p_effective_date,
8471 p_person_id => p_person_id,
8472 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt );
8473 end if;
8474
8475
8476 --
8477 -- Enrolled in Another Plan
8478 --
8479 if l_profile.rt_enrld_pl_flag = 'Y' then
8480 hr_utility.set_location('check_enrld_anthr_pl',10);
8481 check_enrld_anthr_pl
8482 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
8483 p_business_group_id => p_business_group_id,
8484 -- FONM : do not overload eff date as determine_date is called.
8485 p_effective_date => p_effective_date,
8486 p_person_id => p_person_id,
8487 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
8488 p_pl_id => p_pl_id);
8489 end if;
8490
8491
8492 --
8493 -- Enrolled in Another Option In Plan
8494 --
8495 if l_profile.rt_enrld_oipl_flag = 'Y' then
8496 hr_utility.set_location('check_enrld_anthr_oipl',10);
8497 check_enrld_anthr_oipl
8498 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
8499 p_business_group_id => p_business_group_id,
8500 -- FONM : do not overload eff date as determine_date is called.
8501 p_effective_date => p_effective_date,
8502 p_person_id => p_person_id,
8503 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
8504 p_oipl_id => p_oipl_id);
8505 end if;
8506
8507
8508 --
8509 -- Enrolled in Another Plan in Program
8510 --
8511 if l_profile.rt_enrld_plip_flag = 'Y' then
8512 hr_utility.set_location('check_enrld_anthr_plip',10);
8513 check_enrld_anthr_plip
8514 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
8515 p_business_group_id => p_business_group_id,
8516 -- FONM : do not overload eff date as determine_date is called.
8517 p_effective_date => p_effective_date,
8518 p_person_id => p_person_id,
8519 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt);
8520 end if;
8521
8522
8523 --
8524 -- Enrolled in Another Plan Type in Program
8525 --
8526 if l_profile.rt_enrld_ptip_flag = 'Y' then
8527 hr_utility.set_location('check_enrld_anthr_ptip',10);
8528 check_enrld_anthr_ptip
8529 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
8530 p_business_group_id => p_business_group_id,
8531 -- FONM : do not overload eff date as determine_date is called.
8532 p_effective_date => p_effective_date,
8533 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt);
8534 end if;
8535
8536 --
8537 -- Enrolled in Another Program
8538 --
8539 if l_profile.rt_enrld_pgm_flag = 'Y' then
8540 hr_utility.set_location('check_enrld_anthr_pgm',10);
8541 check_enrld_anthr_pgm
8542 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
8543 p_business_group_id => p_business_group_id,
8544 p_pgm_id => p_pgm_id ,
8545 p_person_id => p_person_id,
8546 -- FONM : do not overload eff date as determine_date is called.
8547 p_effective_date => p_effective_date,
8548 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt );
8549 end if;
8550
8551 --
8552 -- Dependent Other Plan Type in Program
8553 --
8554 if l_profile.rt_dpnt_othr_ptip_flag = 'Y' then
8555 hr_utility.set_location('check_dpnt_othr_ptip',10);
8556 check_dpnt_othr_ptip
8557 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
8558 p_business_group_id => p_business_group_id,
8559 -- FONM : as lf_evt_ocrd_dt is used, do not overload the
8560 -- p_effective_date.
8561 p_effective_date => p_effective_date,
8562 p_person_id => p_person_id,
8563 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
8564 p_per_in_ler_id => p_per_in_ler_id);
8565 end if;
8566
8567 --
8568 -- No Other Coverage
8569 --
8570 if l_profile.rt_no_othr_cvg_flag = 'Y' then
8571 hr_utility.set_location('check_no_othr_cvg',10);
8572 check_no_othr_cvg
8573 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
8574 p_business_group_id => p_business_group_id,
8575 p_person_id => p_person_id,
8576 p_effective_date => p_effective_date,
8577 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt);
8578 end if;
8579
8580 --
8581 if not(p_all_prfls) then
8582 --
8583 -- when g_all_prfls is set, we want to determine all the profiles
8584 -- a person matches without considering the total-type criteria.
8585 -- then we'll call this procedure again, with those totals.
8586 -- When g_all_prfls is set, the totals passed in are the total
8587 -- number of people participating in the comp object that match
8588 -- the other criteria in the vrbl prfl.
8589 -- When it's not set, the totals are the total number
8590 -- of people participating in the comp object.
8591 --
8592 -- Total Number of Participants
8593 --
8594 hr_utility.set_location ('Total profs '||l_package,10);
8595 if l_profile.rt_ttl_prtt_flag = 'Y' then
8596 hr_utility.set_location('check_ttl_prtt',10);
8597 check_ttl_prtt
8598 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
8599 p_business_group_id => p_business_group_id,
8600 p_effective_date => p_effective_date,
8601 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
8602 p_ttl_prtt => l_ttl_prtt);
8603 end if;
8604 --
8605 -- Total Amount of Coverage
8606 --
8607 if l_profile.rt_ttl_cvg_vol_flag = 'Y' then
8608 hr_utility.set_location('check_ttl_cvg',10);
8609 check_ttl_cvg
8610 (p_vrbl_rt_prfl_id => l_profile.vrbl_rt_prfl_id,
8611 p_business_group_id => p_business_group_id,
8612 p_effective_date => p_effective_date,
8613 p_lf_evt_ocrd_dt => p_lf_evt_ocrd_dt,
8614 p_ttl_cvg => l_ttl_cvg);
8615 end if;
8616 --
8617 end if;
8618 --
8619 -- If we get this far then everything passed.
8620 -- Assign Variable Rate Id and get out -
8621 -- unless we want to find
8622 -- all the profiles a person matches.
8623 --
8624 l_vrbl_rt_prfl_id := l_profile.vrbl_rt_prfl_id;
8625 l_matched_vrbl_prfl := 'Y';
8626 --
8627 hr_utility.set_location ('Load globals '||l_package,10);
8628 if p_all_prfls then
8629 --
8630 hr_utility.set_location ('p_all_prfls on ',20);
8631 --
8632 -- first time thru procedure where we are keeping track of all
8633 -- the profiles a person matches, without running the ttl-cvg
8634 -- and ttl-prtt's profiles.
8635 -- Using a table, keep track of the variable profiles matched and
8636 -- how many people matched the profiles.
8637 --
8638 load_globals (p_vrbl_rt_prfl_id => l_vrbl_rt_prfl_id
8639 ,p_all_prfls => true
8640 ,p_use_prfls => false
8641 ,p_bnft_amt => p_bnft_amt
8642 ,p_ordr_num => l_profile.ordr_num
8643 ,p_asmt_to_use_cd => l_profile.asmt_to_use_cd
8644 ,p_rt_hrly_slrd_flag => l_profile.rt_hrly_slrd_flag
8645 ,p_rt_pstl_cd_flag => l_profile.rt_pstl_cd_flag
8646 ,p_rt_lbr_mmbr_flag => l_profile.rt_lbr_mmbr_flag
8647 ,p_rt_lgl_enty_flag => l_profile.rt_lgl_enty_flag
8648 ,p_rt_benfts_grp_flag => l_profile.rt_benfts_grp_flag
8649 ,p_rt_wk_loc_flag => l_profile.rt_wk_loc_flag
8650 ,p_rt_brgng_unit_flag => l_profile.rt_brgng_unit_flag
8651 ,p_rt_age_flag => l_profile.rt_age_flag
8652 ,p_rt_los_flag => l_profile.rt_los_flag
8653 ,p_rt_per_typ_flag => l_profile.rt_per_typ_flag
8654 ,p_rt_fl_tm_pt_tm_flag=> l_profile.rt_fl_tm_pt_tm_flag
8655 ,p_rt_ee_stat_flag => l_profile.rt_ee_stat_flag
8656 ,p_rt_grd_flag => l_profile.rt_grd_flag
8657 ,p_rt_pct_fl_tm_flag => l_profile.rt_pct_fl_tm_flag
8658 ,p_rt_asnt_set_flag => l_profile.rt_asnt_set_flag
8659 ,p_rt_hrs_wkd_flag => l_profile.rt_hrs_wkd_flag
8660 ,p_rt_comp_lvl_flag => l_profile.rt_comp_lvl_flag
8661 ,p_rt_org_unit_flag => l_profile.rt_org_unit_flag
8662 ,p_rt_loa_rsn_flag => l_profile.rt_loa_rsn_flag
8663 ,p_rt_pyrl_flag => l_profile.rt_pyrl_flag
8664 ,p_rt_schedd_hrs_flag => l_profile.rt_schedd_hrs_flag
8665 ,p_rt_py_bss_flag => l_profile.rt_py_bss_flag
8666 ,p_rt_prfl_rl_flag => l_profile.rt_prfl_rl_flag
8667 ,p_rt_cmbn_age_los_flag => l_profile.rt_cmbn_age_los_flag
8668 ,p_rt_prtt_pl_flag => l_profile.rt_prtt_pl_flag
8669 ,p_rt_svc_area_flag => l_profile.rt_svc_area_flag
8670 ,p_rt_ppl_grp_flag => l_profile.rt_ppl_grp_flag
8671 ,p_rt_dsbld_flag => l_profile.rt_dsbld_flag
8672 ,p_rt_hlth_cvg_flag => l_profile.rt_hlth_cvg_flag
8673 ,p_rt_poe_flag => l_profile.rt_poe_flag
8674 ,p_rt_ttl_cvg_vol_flag=> l_profile.rt_ttl_cvg_vol_flag
8675 ,p_rt_ttl_prtt_flag => l_profile.rt_ttl_prtt_flag
8676 ,p_rt_gndr_flag => l_profile.rt_gndr_flag
8677 ,p_rt_tbco_use_flag => l_profile.rt_tbco_use_flag
8678 ,p_rt_cntng_prtn_prfl_flag => l_profile.rt_cntng_prtn_prfl_flag
8679 ,p_rt_cbr_quald_bnf_flag => l_profile.rt_cbr_quald_bnf_flag
8680 ,p_rt_optd_mdcr_flag => l_profile.rt_optd_mdcr_flag
8681 ,p_rt_lvg_rsn_flag => l_profile.rt_lvg_rsn_flag
8682 ,p_rt_pstn_flag => l_profile.rt_pstn_flag
8683 ,p_rt_comptncy_flag => l_profile.rt_comptncy_flag
8684 ,p_rt_job_flag => l_profile.rt_job_flag
8685 ,p_rt_qual_titl_flag => l_profile.rt_qual_titl_flag
8686 ,p_rt_dpnt_cvrd_pl_flag => l_profile.rt_dpnt_cvrd_pl_flag
8687 ,p_rt_dpnt_cvrd_plip_flag => l_profile.rt_dpnt_cvrd_plip_flag
8688 ,p_rt_dpnt_cvrd_ptip_flag => l_profile.rt_dpnt_cvrd_ptip_flag
8689 ,p_rt_dpnt_cvrd_pgm_flag => l_profile.rt_dpnt_cvrd_pgm_flag
8690 ,p_rt_enrld_oipl_flag => l_profile.rt_enrld_oipl_flag
8691 ,p_rt_enrld_pl_flag => l_profile.rt_enrld_pl_flag
8692 ,p_rt_enrld_plip_flag => l_profile.rt_enrld_plip_flag
8693 ,p_rt_enrld_ptip_flag => l_profile.rt_enrld_ptip_flag
8694 ,p_rt_enrld_pgm_flag => l_profile.rt_enrld_pgm_flag
8695 ,p_rt_prtt_anthr_pl_flag => l_profile.rt_prtt_anthr_pl_flag
8696 ,p_rt_othr_ptip_flag => l_profile.rt_othr_ptip_flag
8697 ,p_rt_no_othr_cvg_flag => l_profile.rt_no_othr_cvg_flag
8698 ,p_rt_dpnt_othr_ptip_flag => l_profile.rt_dpnt_othr_ptip_flag
8699 ,p_rt_qua_in_gr_flag => l_profile.rt_qua_in_gr_flag
8700 ,p_rt_perf_rtng_flag => l_profile.rt_perf_rtng_flag
8701 ,p_rt_elig_prfl_flag => l_profile.rt_elig_prfl_flag
8702 );
8703 --
8704 else
8705 -- Bug 1211317: changed to use new parm.
8706 if p_use_prfls then
8707 --
8708 hr_utility.set_location ('p_use_globals on ',21);
8709 --
8710 -- our second time thru this procedure where we are
8711 -- determining which profile a person matches with
8712 -- ttl_cvg and ttl_prtt taken into account. Keep track
8713 -- of number of people that match the profiles.
8714 --
8715 load_globals (p_vrbl_rt_prfl_id => l_vrbl_rt_prfl_id
8716 ,p_all_prfls => false
8717 ,p_use_prfls => true
8718 ,p_bnft_amt => p_bnft_amt
8719 ,p_ordr_num => null
8720 ,p_asmt_to_use_cd => l_profile.asmt_to_use_cd
8721 ,p_rt_hrly_slrd_flag => l_profile.rt_hrly_slrd_flag
8722 ,p_rt_pstl_cd_flag => l_profile.rt_pstl_cd_flag
8723 ,p_rt_lbr_mmbr_flag => l_profile.rt_lbr_mmbr_flag
8724 ,p_rt_lgl_enty_flag => l_profile.rt_lgl_enty_flag
8725 ,p_rt_benfts_grp_flag => l_profile.rt_benfts_grp_flag
8726 ,p_rt_wk_loc_flag => l_profile.rt_wk_loc_flag
8727 ,p_rt_brgng_unit_flag => l_profile.rt_brgng_unit_flag
8728 ,p_rt_age_flag => l_profile.rt_age_flag
8729 ,p_rt_los_flag => l_profile.rt_los_flag
8730 ,p_rt_per_typ_flag => l_profile.rt_per_typ_flag
8731 ,p_rt_fl_tm_pt_tm_flag=> l_profile.rt_fl_tm_pt_tm_flag
8732 ,p_rt_ee_stat_flag => l_profile.rt_ee_stat_flag
8733 ,p_rt_grd_flag => l_profile.rt_grd_flag
8734 ,p_rt_pct_fl_tm_flag => l_profile.rt_pct_fl_tm_flag
8735 ,p_rt_asnt_set_flag => l_profile.rt_asnt_set_flag
8736 ,p_rt_hrs_wkd_flag => l_profile.rt_hrs_wkd_flag
8737 ,p_rt_comp_lvl_flag => l_profile.rt_comp_lvl_flag
8738 ,p_rt_org_unit_flag => l_profile.rt_org_unit_flag
8739 ,p_rt_loa_rsn_flag => l_profile.rt_loa_rsn_flag
8740 ,p_rt_pyrl_flag => l_profile.rt_pyrl_flag
8741 ,p_rt_schedd_hrs_flag => l_profile.rt_schedd_hrs_flag
8742 ,p_rt_py_bss_flag => l_profile.rt_py_bss_flag
8743 ,p_rt_prfl_rl_flag => l_profile.rt_prfl_rl_flag
8744 ,p_rt_cmbn_age_los_flag => l_profile.rt_cmbn_age_los_flag
8745 ,p_rt_prtt_pl_flag => l_profile.rt_prtt_pl_flag
8746 ,p_rt_svc_area_flag => l_profile.rt_svc_area_flag
8747 ,p_rt_ppl_grp_flag => l_profile.rt_ppl_grp_flag
8748 ,p_rt_dsbld_flag => l_profile.rt_dsbld_flag
8749 ,p_rt_hlth_cvg_flag => l_profile.rt_hlth_cvg_flag
8750 ,p_rt_poe_flag => l_profile.rt_poe_flag
8751 ,p_rt_ttl_cvg_vol_flag=> l_profile.rt_ttl_cvg_vol_flag
8752 ,p_rt_ttl_prtt_flag => l_profile.rt_ttl_prtt_flag
8753 ,p_rt_gndr_flag => l_profile.rt_gndr_flag
8754 ,p_rt_tbco_use_flag => l_profile.rt_tbco_use_flag
8755 ,p_rt_cntng_prtn_prfl_flag => l_profile.rt_cntng_prtn_prfl_flag
8756 ,p_rt_cbr_quald_bnf_flag => l_profile.rt_cbr_quald_bnf_flag
8757 ,p_rt_optd_mdcr_flag => l_profile.rt_optd_mdcr_flag
8758 ,p_rt_lvg_rsn_flag => l_profile.rt_lvg_rsn_flag
8759 ,p_rt_pstn_flag => l_profile.rt_pstn_flag
8760 ,p_rt_comptncy_flag => l_profile.rt_comptncy_flag
8761 ,p_rt_job_flag => l_profile.rt_job_flag
8762 ,p_rt_qual_titl_flag => l_profile.rt_qual_titl_flag
8763 ,p_rt_dpnt_cvrd_pl_flag => l_profile.rt_dpnt_cvrd_pl_flag
8764 ,p_rt_dpnt_cvrd_plip_flag => l_profile.rt_dpnt_cvrd_plip_flag
8765 ,p_rt_dpnt_cvrd_ptip_flag => l_profile.rt_dpnt_cvrd_ptip_flag
8766 ,p_rt_dpnt_cvrd_pgm_flag => l_profile.rt_dpnt_cvrd_pgm_flag
8767 ,p_rt_enrld_oipl_flag => l_profile.rt_enrld_oipl_flag
8768 ,p_rt_enrld_pl_flag => l_profile.rt_enrld_pl_flag
8769 ,p_rt_enrld_plip_flag => l_profile.rt_enrld_plip_flag
8770 ,p_rt_enrld_ptip_flag => l_profile.rt_enrld_ptip_flag
8771 ,p_rt_enrld_pgm_flag => l_profile.rt_enrld_pgm_flag
8772 ,p_rt_prtt_anthr_pl_flag => l_profile.rt_prtt_anthr_pl_flag
8773 ,p_rt_othr_ptip_flag => l_profile.rt_othr_ptip_flag
8774 ,p_rt_no_othr_cvg_flag => l_profile.rt_no_othr_cvg_flag
8775 ,p_rt_dpnt_othr_ptip_flag => l_profile.rt_dpnt_othr_ptip_flag
8776 ,p_rt_qua_in_gr_flag => l_profile.rt_qua_in_gr_flag
8777 ,p_rt_perf_rtng_flag => l_profile.rt_perf_rtng_flag
8778 ,p_rt_elig_prfl_flag => l_profile.rt_elig_prfl_flag
8779 );
8780
8781 --
8782 end if;
8783 --
8784 exit;
8785 --
8786 end if;
8787 --
8788 exception
8789 --
8790 when ben_evaluate_rate_profiles.g_profile_failed then
8791 --
8792 -- If profile failed one of the criteria,
8793 -- go onto next profile.
8794 --
8795 hr_utility.set_location ('g_profile_failed '||l_package,10);
8796 NULL;
8797 --
8798 -- begin bug # 2436338
8799 when g_criteria_failed then
8800 --
8801 -- If profile failed one of the criteria,
8802 -- go onto next profile.
8803 --
8804 hr_utility.set_location ('g_profile_failed '||l_package,10);
8805 NULL;
8806 --
8807 -- end bug # 2436338
8808 end;
8809 --
8810 end loop;
8811 hr_utility.set_location ('Dn Prof loop '||l_package,10);
8812 --
8813 if l_matched_vrbl_prfl = 'N' then
8814 --
8815 if p_all_prfls or p_use_globals then
8816 --
8817 -- the person didn't match any variable profiles,
8818 -- add to no-match count. This doesn't count people twice,
8819 -- because the second time thru we only loop thru those people
8820 -- who did match profiles the first time thru.
8821 --
8822 g_no_match_cnt := g_no_match_cnt + 1;
8823 g_no_match_cvg := g_no_match_cvg + p_bnft_amt;
8824 --
8825 hr_utility.set_location ('did not match profile :'||
8826 to_char(p_person_id)||' cnt:'||
8827 to_char(g_no_match_cnt),88);
8828 --
8829 end if;
8830 --
8831 end if;
8832 --
8833 p_vrbl_rt_prfl_id := l_vrbl_rt_prfl_id;
8834 --
8835 hr_utility.set_location ('Leaving '||l_package,99);
8836 --
8837 end main;
8838 --
8839 end ben_evaluate_rate_profiles;