[Home] [Help]
PACKAGE BODY: APPS.BEN_ELEMENT_ENTRY
Source
1 Package Body ben_element_entry as
2 /* $Header: benelmen.pkb 120.33.12010000.15 2008/09/15 11:02:19 sallumwa ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 -- Package Variables
9 --
10 g_debug boolean := hr_utility.debug_enabled;
11 g_package varchar2(33) := ' ben_element_entry.'; -- Global package name
12 g_skip_element varchar2(30);
13 --
14 g_hash_jump number := ben_hash_utility.get_hash_jump;
15 --
16 g_msg_displayed number :=0; --2530582
17 g_acty_base_rt_name ben_acty_base_rt_f.name%type := null;
18 --
19
20 type g_get_link_row is record
21 (assignment_id number
22 ,element_type_id number
23 ,session_date date
24 ,element_link_id number
25 );
26 --
27 type g_get_link_tbl is table of g_get_link_row
28 index by binary_integer;
29 --
30 type abr_asg_rec is record
31 (person_id number,
32 assignment_id number,
33 payroll_id number,
34 organization_id number,
35 asmt_to_use_cd varchar2(30),
36 effective_start_date date,
37 effective_end_date date);
38
39 type per_pay_rec is record
40 (assignment_id number,
41 end_date date,
42 payroll_was_ever_run boolean);
43
44 g_ext_inpval_tab ext_inpval_tab_typ;
45 g_outputs ff_exec.outputs_t;
46 g_get_link_cache g_get_link_tbl;
47 g_get_link_cached pls_integer := 0;
48 g_param_rec benutils.g_batch_param_rec;
49 g_abr_asg_rec abr_asg_rec;
50 g_per_pay_rec per_pay_rec;
51 g_max_end_date date := null;
52 --
53 -- Package cursors
54 --
55 cursor c_plan_year_end_for_pen
56 (c_prtt_enrt_rslt_id in number
57 ,c_rate_start_or_end_dt in date
58 ,c_effective_date in date
59 )
60 is
61 select distinct
62 yp.start_date,yp.end_date
63 from ben_prtt_enrt_rslt_f pen,
64 ben_popl_yr_perd pyp,
65 ben_yr_perd yp
66 where pen.prtt_enrt_rslt_id = c_prtt_enrt_rslt_id
67 and pen.prtt_enrt_rslt_stat_cd is null
68 and c_effective_date <= pen.effective_end_date
69 and pyp.pl_id=pen.pl_id
70 and yp.yr_perd_id=pyp.yr_perd_id
71 and c_rate_start_or_end_dt
72 between yp.start_date and yp.end_date;
73 --
74 cursor c_plan_year_end_for_pl
75 (c_pl_id in number
76 ,c_rate_start_or_end_dt in date
77 )
78 is
79 select distinct
80 yp.start_date,yp.end_date
81 from ben_popl_yr_perd pyp,
82 ben_yr_perd yp
83 where pyp.pl_id=c_pl_id
84 and yp.yr_perd_id=pyp.yr_perd_id
85 and c_rate_start_or_end_dt
86 between yp.start_date and yp.end_date;
87 --
88 -- current result info
89 --
90 cursor c_current_result_info
91 (c_prtt_enrt_rslt_id in number
92 )
93 is
94 select pen.prtt_enrt_rslt_id,
95 pen.pl_id,
96 opt.opt_id,
97 pen.pgm_id,
98 pen.ler_id,
99 pen.pl_typ_id,
100 pen.person_id,
101 pen.effective_start_date,
102 pen.effective_end_date,
103 pen.uom
104 from ben_prtt_enrt_rslt_f pen,
105 ben_oipl_f opt
106 where pen.prtt_enrt_rslt_id = c_prtt_enrt_rslt_id
107 and pen.prtt_enrt_rslt_stat_cd is null
108 and opt.oipl_id(+)=pen.oipl_id
109 and pen.enrt_cvg_strt_dt between opt.effective_start_date(+)
110 and opt.effective_end_date(+)
111 order by pen.effective_start_date desc;
112 --
113 g_result_rec c_current_result_info%rowtype;
114 --
115 -- prtt rt info
116 --
117 cursor c_get_prtt_rt_val
118 (c_prtt_rt_val_id in number
119 )
120 is
121 select prv.prtt_rt_val_id,
122 prv.acty_base_rt_id,
123 prv.prtt_enrt_rslt_id,
124 prv.rt_strt_dt,
125 prv.rt_end_dt,
126 prv.business_group_id,
127 prv.mlt_cd,
128 prv.acty_ref_perd_cd,
129 prv.rt_val,
130 prv.cmcd_rt_val,
131 prv.ann_rt_val,
132 prv.per_in_ler_id,
133 prv.element_entry_value_id,
134 prv.prtt_reimbmt_rqst_id,
135 prv.object_version_number
136 from ben_prtt_rt_val prv
137 where prtt_rt_val_id = c_prtt_rt_val_id;
138 --
139 l_prv_rec c_get_prtt_rt_val%ROWTYPE;
140 --
141 -- -------------------------------------------------------------
142 -- This cursor determines if any payroll actions exist because
143 -- of running payroll. Action type 'X' corresponds to payroll
144 -- actions that are not a result of payroll run. This is a
145 -- precursor to get_max_end_dt()
146 -- -------------------------------------------------------------
147 --
148 cursor c_payroll_was_ever_run
149 (c_assignment_id in number
150 )
151 is
152 select 'Y'
153 from pay_assignment_actions d,
154 pay_payroll_actions e
155 where d.assignment_id = c_assignment_id
156 and d.payroll_action_id = e.payroll_action_id
157 and e.action_type <> 'X';
158 --
159 -- This func replaces the cursor c_get_end_dt
160 --
161 -- ----------------------------------------------------------------------------
162 -- |-----------------------< get_max_end_dt >----------------------------|
163 -- ----------------------------------------------------------------------------
164 --
165 function get_max_end_dt (
166 p_assignment_id number,
167 p_payroll_id number,
168 p_element_type_id number,
169 p_effective_date date)
170 return date is
171 --
172 cursor c_asgact
173 (c_assignment_id in number
174 ,c_payroll_id in number
175 ) is
176 select d.assignment_action_id,
177 g.end_date
178 from pay_assignment_actions d,
179 pay_payroll_actions e,
180 per_time_periods g
181 where d.assignment_id = c_assignment_id
182 and g.payroll_id = c_payroll_id
183 and g.payroll_id = e.payroll_id
184 and d.payroll_action_id = e.payroll_action_id
185 and e.action_type in ('R','Q')
186 and e.time_period_id = g.time_period_id
187 and e.date_earned between g.start_date and g.end_date
188 order by g.end_date desc;
189
190 cursor c_chk_pac
191 (c_assignment_action_id in number
192 ,c_element_type_id in number
193 ) is
194 select 'x'
195 from pay_run_results h
196 where h.element_type_id = c_element_type_id
197 and h.assignment_action_id = c_assignment_action_id
198 and h.status in ('P', 'PA')
199 and h.source_type = 'E';
200
201 l_proc varchar2(72) := g_package||'get_max_end_dt';
202 l_v2dummy varchar2(30);
203 l_assignment_action_id number;
204 l_end_date date;
205 l_max_end_date date;
206
207 begin
208 --
209 if g_debug then
210 hr_utility.set_location('Entering: '||l_proc,5);
211 end if;
212 --
213 open c_asgact(p_assignment_id,
214 p_payroll_id);
215 loop
216 --
217 fetch c_asgact into l_assignment_action_id,
218 l_end_date;
219 if c_asgact%notfound then
220 exit;
221 end if;
222 --
223 open c_chk_pac(l_assignment_action_id,
224 p_element_type_id);
225 fetch c_chk_pac into l_v2dummy;
226 --
227 if c_chk_pac%found then
228 l_max_end_date := l_end_date;
229 close c_chk_pac;
230 exit;
231 end if;
232 --
233 close c_chk_pac;
234 --
235 end loop;
236 close c_asgact;
237 --
238 if g_debug then
239 hr_utility.set_location('Leaving: '||l_proc,5);
240 end if;
241 --
242 return l_max_end_date;
243 --
244 end get_max_end_dt;
245 --
246 -- ----------------------------------------------------------------------------
247 -- |-----------------------< chk_ele_processed >----------------------------|
248 -- ----------------------------------------------------------------------------
249 -- Returns 'Y' if the element entry has already been processed in a payroll
250 -- run.
251 --
252 function chk_ele_processed (
253 p_element_entry_id number,
254 p_original_entry_id number,
255 p_processing_type varchar2,
256 p_entry_type varchar2,
257 p_business_group_id number,
258 p_effective_date date)
259 return varchar2 is
260 --
261 --
262 -- Define how to determine if the entry is processed
263 --
264 cursor nonrecurring_entries (adjust_ee_source in varchar2) is
265 select 'Y'
266 from pay_run_results prr,
267 pay_element_entries_f pee
268 where pee.element_entry_id = p_element_entry_id
269 and p_effective_date between pee.effective_start_date
270 and pee.effective_end_date
271 and prr.source_id = decode(pee.entry_type,
272 'A', decode (adjust_ee_source,
273 'T', pee.target_entry_id,
274 pee.element_entry_id),
275 'R', decode (adjust_ee_source,
276 'T', pee.target_entry_id,
277 pee.element_entry_id),
278 pee.element_entry_id)
279 and prr.entry_type = pee.entry_type
280 and prr.source_type = 'E'
281 and prr.status <> 'U'
282 and not exists
283 (select 1
284 from pay_run_results sub_rr
285 where sub_rr.source_id = prr.run_result_id
286 and sub_rr.source_type in ('R', 'V')) ;
287 --
288 -- Bug 522510, recurring entries are considered as processed in the Date Earned
289 -- period, not Date Paid period - where run results exists.
290 --
291
292 cursor recurring_entries is
293 select 'Y'
294 from pay_run_results result,
295 pay_assignment_actions asgt_action,
296 pay_payroll_actions pay_action,
297 per_time_periods period
298 where result.source_id = nvl (p_original_entry_id, p_element_entry_id)
299 and result.status <> 'U'
300 and result.source_type = 'E'
301 and result.assignment_action_id = asgt_action.assignment_action_id
302 and asgt_action.payroll_action_id = pay_action.payroll_action_id
303 and pay_action.payroll_id = period.payroll_id
304 and pay_action.date_earned between period.start_date
305 and period.end_date
306 and not exists
307 (select 1
308 from pay_run_results rev_result
309 where rev_result.source_id = result.run_result_id
310 and rev_result.source_type in ('R', 'V'));
311 --
312 l_proc varchar2(72) := g_package||'chk_ele_processed';
313 l_processed varchar2(1) := 'N';
314 l_adjust_ee_source varchar2(1);
315
316 begin
317 --
318 if g_debug then
319 hr_utility.set_location('Entering: '||l_proc,5);
320 end if;
321 --
322 if (p_entry_type in ('S','D','A','R') or p_processing_type = 'N') then
323 --
324 begin
325 --
326 select plr.rule_mode
327 into l_adjust_ee_source
328 from pay_legislation_rules plr
329 , per_business_groups_perf pbgf
330 where plr.rule_type = 'ADJUSTMENT_EE_SOURCE'
331 and pbgf.legislation_code = plr.legislation_code
332 and pbgf.business_group_id = p_business_group_id;
333 --
334 exception
335 when no_data_found then
336 l_adjust_ee_source := 'A';
337 end;
338 --
339 open nonrecurring_entries(l_adjust_ee_source);
340 fetch nonrecurring_entries into l_processed;
341 close nonrecurring_entries;
342 --
343 else
344 --
345 open recurring_entries;
346 fetch recurring_entries into l_processed;
347 close recurring_entries;
348 --
349 end if;
350 --
351 if g_debug then
352 hr_utility.set_location('Leaving: '||l_proc,5);
353 end if;
354 --
355 return l_processed;
356 --
357 end chk_ele_processed;
358 --
359 -- ----------------------------------------------------------------------------
360 -- |-----------------------< clear_ext_inpval_tab>----------------------------|
361 -- ----------------------------------------------------------------------------
362 --
363 procedure clear_ext_inpval_tab is
364 l_proc varchar2(72) ;
365 begin
366 if g_debug then
367 l_proc := g_package||'clear_ext_inpval_tab';
368 hr_utility.set_location('Entering: '||l_proc,5);
369 end if;
370 --
371 -- Clear the pl/sql extra inputs cache
372 --
373 g_ext_inpval_tab.delete;
374
375 -- Reset g_ext_inpval_tab to null
376 for i in 1..14 loop
377 g_ext_inpval_tab(i).extra_input_value_id := null;
378 g_ext_inpval_tab(i).upd_when_ele_ended_cd := null;
379 g_ext_inpval_tab(i).input_value_id := null;
380 g_ext_inpval_tab(i).return_var_name := null;
381 g_ext_inpval_tab(i).return_value := null;
382 end loop;
383 --
384 if g_debug then
385 hr_utility.set_location('Leaving: '||l_proc,5);
386 end if;
387 end clear_ext_inpval_tab;
388 --
389 -- ----------------------------------------------------------------------------
390 -- |-----------------------< get_extra_ele_inputs>----------------------------|
391 -- ----------------------------------------------------------------------------
392 --
393 procedure get_extra_ele_inputs
394 (
395 p_effective_date in date
396 ,p_person_id in number
397 ,p_business_group_id in number
398 ,p_assignment_id in number
399 ,p_element_link_id in number
400 ,p_entry_type in varchar2
401 ,p_input_value_id1 in number
402 ,p_entry_value1 in varchar2
403 ,p_element_entry_id in number
404 ,p_acty_base_rt_id in number
405 ,p_input_va_calc_rl in number
406 ,p_abs_ler in boolean
407 ,p_organization_id in number
408 ,p_payroll_id in number
409 ,p_pgm_id in number
410 ,p_pl_id in number
411 ,p_pl_typ_id in number
412 ,p_opt_id in number
413 ,p_ler_id in number
414 ,p_dml_typ in varchar2
415 ,p_jurisdiction_code in varchar2
416 ,p_ext_inpval_tab out nocopy ext_inpval_tab_typ
417 ,p_subpriority out nocopy number
418 ) is
419
420 cursor c_ext_inpval
421 is
422 select eiv.extra_input_value_id,
423 eiv.input_value_id,
424 eiv.acty_base_rt_id,
425 eiv.input_text,
426 eiv.return_var_name,
427 eiv.upd_when_ele_ended_cd
428 from ben_extra_input_values eiv,
429 pay_input_values_f piv
430 where eiv.acty_base_rt_id = p_acty_base_rt_id
431 and eiv.business_group_id = p_business_group_id
432 and piv.input_value_id = eiv.input_value_id
433 and p_effective_date between piv.effective_start_date
434 and piv.effective_end_date
435 order by piv.display_sequence;
436 --
437 l_ext_inpval_rec c_ext_inpval%rowtype;
438 --
439 cursor c_abs_att is
440 select
441 aba.*, pil.per_in_ler_id
442 from per_absence_attendances aba,
443 ben_per_in_ler pil,
444 ben_ler_f ler
445 where aba.person_id = p_person_id
446 and pil.person_id = p_person_id
447 and aba.absence_attendance_id = pil.trgr_table_pk_id
448 and pil.ler_id = ler.ler_id
449 and ler.typ_cd = 'ABS'
450 and pil.per_in_ler_stat_cd = 'STRTD'
451 and p_effective_date between
452 ler.effective_start_date and ler.effective_end_date;
453 --
454 cursor c_inp_name is
455 select upper(replace(name,' ','_'))
456 from pay_input_values_f
457 where input_value_id = p_input_value_id1
458 and p_effective_date between
459 effective_start_date and effective_end_date;
460
461 l_per_abs_att_rec c_abs_att%rowtype;
462 --
463 l_param_tab ff_exec.outputs_t;
464 l_ext_inpval_tab ext_inpval_tab_typ;
465 l_counter number;
466 l_inp_name pay_input_values_f.name%type;
467 l_proc varchar2(72) := g_package||' get_extra_ele_inputs';
468
469 procedure populate_param_tab
470 (p_name in varchar2,
471 p_value in varchar2) is
472 l_next_index number;
473 begin
474
475 l_next_index := nvl(l_param_tab.count,0) + 1;
476 l_param_tab(l_next_index).name := p_name;
477 l_param_tab(l_next_index).value := p_value;
478
479 end;
480
481 begin
482 if g_debug then
483 hr_utility.set_location('Entering: '||l_proc,5);
484 hr_utility.set_location('p_input_va_calc_rl : '||p_input_va_calc_rl ,5);
485 end if;
486
487 clear_ext_inpval_tab;
488
489 if p_input_va_calc_rl is null
490 then
491 if p_input_value_id1 is not null and
492 p_abs_ler then
493
494 open c_inp_name;
495 fetch c_inp_name into l_inp_name;
496 close c_inp_name;
497
498 g_outputs(nvl(g_outputs.count,0)+1).name :=
499 nvl(l_inp_name,'LENGTH_OF_SERVICE');
500 g_outputs(g_outputs.count).value := p_entry_value1;
501 end if;
502 if g_debug then
503 hr_utility.set_location('Extra Input value RL not defined.Leaving ..',5);
504 end if;
505 return;
506 else
507 --
508 --
509 open c_abs_att;
510 fetch c_abs_att into l_per_abs_att_rec;
511 close c_abs_att;
512 --
513 -- Evaluate the formula and store the returned values into a pl/sql structure.
514 --
515 if g_debug then
516 hr_utility.set_location('Before formula executing : ',5);
517 hr_utility.set_location('Eff Date '||to_char(p_effective_date,'dd-mon-rrrr'),20);
518 end if;
519
520 populate_param_tab('BEN_ABS_IV_ABSENCE_ATTENDANCE_ID',
521 to_char(l_per_abs_att_rec.ABSENCE_ATTENDANCE_ID));
522 populate_param_tab('BEN_ABS_IV_PERSON_ID',to_char(l_per_abs_att_rec.PERSON_ID));
523 populate_param_tab('BEN_ABS_IV_DATE_START', to_char(l_per_abs_att_rec.DATE_START, 'YYYY/MM/DD HH24:MI:SS'));
524 populate_param_tab('BEN_ABS_IV_DATE_END', to_char(l_per_abs_att_rec.DATE_END, 'YYYY/MM/DD HH24:MI:SS'));
525 populate_param_tab('BEN_ABS_IV_ABSENCE_ATTENDANCE_TYPE_ID',
526 to_char(l_per_abs_att_rec.ABSENCE_ATTENDANCE_TYPE_ID));
527 populate_param_tab('BEN_ABS_IV_ABS_ATTENDANCE_REASON_ID',
528 to_char(l_per_abs_att_rec.ABS_ATTENDANCE_REASON_ID));
529 populate_param_tab('BEN_ABS_IV_SICKNESS_START_DATE',
530 to_char(l_per_abs_att_rec.SICKNESS_START_DATE, 'YYYY/MM/DD HH24:MI:SS'));
531 populate_param_tab('BEN_ABS_IV_SICKNESS_END_DATE',
532 to_char(l_per_abs_att_rec.SICKNESS_END_DATE, 'YYYY/MM/DD HH24:MI:SS'));
533 populate_param_tab('BEN_ABS_IV_ABSENCE_DAYS', to_char(l_per_abs_att_rec.ABSENCE_DAYS));
534 populate_param_tab('BEN_ABS_IV_ABSENCE_HOURS', to_char(l_per_abs_att_rec.ABSENCE_HOURS));
535 populate_param_tab('BEN_ABS_IV_DATE_NOTIFICATION',
536 to_char(l_per_abs_att_rec.DATE_NOTIFICATION, 'YYYY/MM/DD HH24:MI:SS'));
537 populate_param_tab('BEN_ABS_IV_DATE_PROJECTED_END',
538 to_char(l_per_abs_att_rec.DATE_PROJECTED_END, 'YYYY/MM/DD HH24:MI:SS'));
539 populate_param_tab('BEN_ABS_IV_DATE_PROJECTED_START',
540 to_char(l_per_abs_att_rec.DATE_PROJECTED_START, 'YYYY/MM/DD HH24:MI:SS'));
541 populate_param_tab('BEN_ABS_IV_TIME_END', l_per_abs_att_rec.TIME_END);
542 populate_param_tab('BEN_ABS_IV_TIME_PROJECTED_END', l_per_abs_att_rec.TIME_PROJECTED_END);
543 populate_param_tab('BEN_ABS_IV_TIME_PROJECTED_START', l_per_abs_att_rec.TIME_PROJECTED_START);
544 populate_param_tab('BEN_PIL_IV_PER_IN_LER_ID', to_char(l_per_abs_att_rec.PER_IN_LER_ID));
545 populate_param_tab('BEN_ABS_IV_SSP1_ISSUED', l_per_abs_att_rec.SSP1_ISSUED);
546 populate_param_tab('BEN_ABS_IV_LINKED_ABSENCE_ID',
547 to_char(l_per_abs_att_rec.LINKED_ABSENCE_ID));
548 populate_param_tab('BEN_ABS_IV_PREGNANCY_RELATED_ILLNESS',
549 l_per_abs_att_rec.PREGNANCY_RELATED_ILLNESS);
550 populate_param_tab('BEN_ABS_IV_MATERNITY_ID',to_char(l_per_abs_att_rec.MATERNITY_ID));
551 populate_param_tab('BEN_ABS_IV_ABS_INFORMATION_CATEGORY', l_per_abs_att_rec.abs_information_category);
552 populate_param_tab('BEN_ABS_IV_ABS_INFORMATION1', l_per_abs_att_rec.abs_information1);
553 populate_param_tab('BEN_ABS_IV_ABS_INFORMATION2', l_per_abs_att_rec.abs_information2);
554 populate_param_tab('BEN_ABS_IV_ABS_INFORMATION3', l_per_abs_att_rec.abs_information3);
555 populate_param_tab('BEN_ABS_IV_ABS_INFORMATION4', l_per_abs_att_rec.abs_information4);
556 populate_param_tab('BEN_ABS_IV_ABS_INFORMATION5', l_per_abs_att_rec.abs_information5);
557 populate_param_tab('BEN_ABS_IV_ABS_INFORMATION6', l_per_abs_att_rec.abs_information6);
558 populate_param_tab('BEN_ABS_IV_ABS_INFORMATION7', l_per_abs_att_rec.abs_information7);
559 populate_param_tab('BEN_ABS_IV_ABS_INFORMATION8', l_per_abs_att_rec.abs_information8);
560 populate_param_tab('BEN_ABS_IV_ABS_INFORMATION9', l_per_abs_att_rec.abs_information9);
561 populate_param_tab('BEN_ABS_IV_ABS_INFORMATION10', l_per_abs_att_rec.abs_information10);
562 populate_param_tab('BEN_ABS_IV_ABS_INFORMATION11', l_per_abs_att_rec.abs_information11);
563 populate_param_tab('BEN_ABS_IV_ABS_INFORMATION12', l_per_abs_att_rec.abs_information12);
564 populate_param_tab('BEN_ABS_IV_ABS_INFORMATION13', l_per_abs_att_rec.abs_information13);
565 populate_param_tab('BEN_ABS_IV_ABS_INFORMATION14', l_per_abs_att_rec.abs_information14);
566 populate_param_tab('BEN_ABS_IV_ABS_INFORMATION15', l_per_abs_att_rec.abs_information15);
567 populate_param_tab('BEN_ABS_IV_ABS_INFORMATION16', l_per_abs_att_rec.abs_information16);
568 populate_param_tab('BEN_ABS_IV_ABS_INFORMATION17', l_per_abs_att_rec.abs_information17);
569 populate_param_tab('BEN_ABS_IV_ABS_INFORMATION18', l_per_abs_att_rec.abs_information18);
570 populate_param_tab('BEN_ABS_IV_ABS_INFORMATION19', l_per_abs_att_rec.abs_information19);
571 populate_param_tab('BEN_ABS_IV_ABS_INFORMATION20', l_per_abs_att_rec.abs_information20);
572 populate_param_tab('BEN_ABS_IV_ABS_INFORMATION21', l_per_abs_att_rec.abs_information21);
573 populate_param_tab('BEN_ABS_IV_ABS_INFORMATION22', l_per_abs_att_rec.abs_information22);
574 populate_param_tab('BEN_ABS_IV_ABS_INFORMATION23', l_per_abs_att_rec.abs_information23);
575 populate_param_tab('BEN_ABS_IV_ABS_INFORMATION24', l_per_abs_att_rec.abs_information24);
576 populate_param_tab('BEN_ABS_IV_ABS_INFORMATION25', l_per_abs_att_rec.abs_information25);
577 populate_param_tab('BEN_ABS_IV_ABS_INFORMATION26', l_per_abs_att_rec.abs_information26);
578 populate_param_tab('BEN_ABS_IV_ABS_INFORMATION27', l_per_abs_att_rec.abs_information27);
579 populate_param_tab('BEN_ABS_IV_ABS_INFORMATION28', l_per_abs_att_rec.abs_information28);
580 populate_param_tab('BEN_ABS_IV_ABS_INFORMATION29', l_per_abs_att_rec.abs_information29);
581 populate_param_tab('BEN_ABS_IV_ABS_INFORMATION30', l_per_abs_att_rec.abs_information30);
582 populate_param_tab('BEN_ABS_IV_ATTRIBUTE_CATEGORY', l_per_abs_att_rec.attribute_category);
583 populate_param_tab('BEN_ABS_IV_ATTRIBUTE1', l_per_abs_att_rec.attribute1);
584 populate_param_tab('BEN_ABS_IV_ATTRIBUTE2', l_per_abs_att_rec.attribute2);
585 populate_param_tab('BEN_ABS_IV_ATTRIBUTE3', l_per_abs_att_rec.attribute3);
586 populate_param_tab('BEN_ABS_IV_ATTRIBUTE4', l_per_abs_att_rec.attribute4);
587 populate_param_tab('BEN_ABS_IV_ATTRIBUTE5', l_per_abs_att_rec.attribute5);
588 populate_param_tab('BEN_ABS_IV_ATTRIBUTE6', l_per_abs_att_rec.attribute6);
589 populate_param_tab('BEN_ABS_IV_ATTRIBUTE7', l_per_abs_att_rec.attribute7);
590 populate_param_tab('BEN_ABS_IV_ATTRIBUTE8', l_per_abs_att_rec.attribute8);
591 populate_param_tab('BEN_ABS_IV_ATTRIBUTE9', l_per_abs_att_rec.attribute9);
592 populate_param_tab('BEN_ABS_IV_ATTRIBUTE10', l_per_abs_att_rec.attribute10);
593 populate_param_tab('BEN_ABS_IV_ATTRIBUTE11', l_per_abs_att_rec.attribute11);
594 populate_param_tab('BEN_ABS_IV_ATTRIBUTE12', l_per_abs_att_rec.attribute12);
595 populate_param_tab('BEN_ABS_IV_ATTRIBUTE13', l_per_abs_att_rec.attribute13);
596 populate_param_tab('BEN_ABS_IV_ATTRIBUTE14', l_per_abs_att_rec.attribute14);
597 populate_param_tab('BEN_ABS_IV_ATTRIBUTE15', l_per_abs_att_rec.attribute15);
598 populate_param_tab('BEN_ABS_IV_ATTRIBUTE16', l_per_abs_att_rec.attribute16);
599 populate_param_tab('BEN_ABS_IV_ATTRIBUTE17', l_per_abs_att_rec.attribute17);
600 populate_param_tab('BEN_ABS_IV_ATTRIBUTE18', l_per_abs_att_rec.attribute18);
601 populate_param_tab('BEN_ABS_IV_ATTRIBUTE19', l_per_abs_att_rec.attribute19);
602 populate_param_tab('BEN_ABS_IV_ATTRIBUTE20', l_per_abs_att_rec.attribute20);
603
604 g_outputs.delete;
605 g_outputs := benutils.formula
606 (p_formula_id => p_input_va_calc_rl,
607 p_effective_date => p_effective_date,
608 p_business_group_id => p_business_group_id,
609 p_ler_id => p_ler_id,
610 p_assignment_id => p_assignment_id,
611 p_organization_id => p_organization_id,
612 p_pgm_id => p_pgm_id,
613 p_pl_typ_id => p_pl_typ_id,
614 p_pl_id => p_pl_id,
615 p_opt_id => p_opt_id,
616 p_acty_base_rt_id => p_acty_base_rt_id,
617 p_jurisdiction_code => p_jurisdiction_code,
618 p_param_tab => l_param_tab);
619
620 if g_debug then
621 hr_utility.set_location('formula count :'||g_outputs.count,5);
622 end if;
623
624 if p_input_value_id1 is not null and
625 p_abs_ler then
626
627 open c_inp_name;
628 fetch c_inp_name into l_inp_name;
629 close c_inp_name;
630
631 g_outputs(nvl(g_outputs.count,0)+1).name :=
632 nvl(l_inp_name,'LENGTH_OF_SERVICE');
633 g_outputs(g_outputs.count).value := p_entry_value1;
634 end if;
635
636 if g_debug then
637 hr_utility.set_location('After formula executing : ',5);
638 end if;
639 --
640 --
641 -- Loop through the returned table and make sure that the returned
642 -- values have been found
643
644 l_counter := 0;
645 --
646 for l_count in g_outputs.first..g_outputs.last loop
647 --
648 begin
649 --
650 -- order c_ext_inpval by pay_input_values.display_seq_number
651 -- While updating the element entry need to update the proper
652 -- input values. Ex., may be reuired to update 3, 8, 13th input's
653 -- All other's should be defaulted to what is on api definition.
654 --
655 for l_ext_inpval_rec in c_ext_inpval loop
656 --
657 -- Loop through ben_ext_inpval table and map the
658 -- formula output's to rows.
659 --
660 if g_outputs(l_count).name = l_ext_inpval_rec.return_var_name then
661 if ((p_dml_typ = 'C') or
662 (p_dml_typ = l_ext_inpval_rec.upd_when_ele_ended_cd)) then
663 --
664 -- Put in a pl/sql structure for extra inputs cache.
665 --
666 l_counter := l_counter + 1;
667 if g_debug then
668 hr_utility.set_location('Before assign extra inputs cache',11);
669 end if;
670 --
671 l_ext_inpval_tab(l_counter).extra_input_value_id
672 := l_ext_inpval_rec.extra_input_value_id;
673 l_ext_inpval_tab(l_counter).upd_when_ele_ended_cd
674 := l_ext_inpval_rec.upd_when_ele_ended_cd;
675 l_ext_inpval_tab(l_counter).input_value_id
676 := l_ext_inpval_rec.input_value_id;
677 l_ext_inpval_tab(l_counter).return_var_name
678 := l_ext_inpval_rec.return_var_name;
679 l_ext_inpval_tab(l_counter).return_value
680 := g_outputs(l_count).value;
681 end if;
682 --
683 elsif g_outputs(l_count).name = 'SUBPRIORITY' then
684 --
685 p_subpriority := to_number(g_outputs(l_count).value);
686 --
687 end if;
688 end loop;
689 exception
690 --
691 when others then
692 --
693 fnd_message.set_name('BEN','BEN_92311_FORMULA_VAL_PARAM');
694 fnd_message.set_token('PROC',l_proc);
695 --fnd_message.set_token('FORMULA',l_input_va_calc_rl_rec.input_va_calc_rl);
696 fnd_message.set_token('PARAMETER',g_outputs(l_count).name);
697 fnd_message.raise_error;
698 --
699 end;
700 --
701 end loop;
702 --
703 end if;
704 --
705 p_ext_inpval_tab := l_ext_inpval_tab;
706
707 for i in p_ext_inpval_tab.count+1..14
708 loop
709 p_ext_inpval_tab(i).extra_input_value_id := null;
710 p_ext_inpval_tab(i).upd_when_ele_ended_cd := null;
711 p_ext_inpval_tab(i).input_value_id := null;
712 p_ext_inpval_tab(i).return_var_name := null;
713 p_ext_inpval_tab(i).return_value := null;
714 end loop;
715
716 if g_debug then
717 hr_utility.set_location('Leaving: '||l_proc,5);
718 end if;
719 exception
720 --
721 when others then
722 if g_debug then
723 hr_utility.set_location('Error in get_extra_ele '||sqlerrm,5);
724 end if;
725 raise;
726
727 end get_extra_ele_inputs;
728 --
729 -- ----------------------------------------------------------------------------
730 -- |-----------------------< get_legislation_code>----------------------------|
731 -- ----------------------------------------------------------------------------
732 --
733 -- Gets the legislation code for a bg
734 --
735 function get_legislation_code
736 (p_business_group_id in number)
737 return varchar2 is
738
739 l_leg_code per_business_groups.legislation_code%type;
740 cursor c_leg is
741 select bg.legislation_code
742 from per_business_groups bg
743 where bg.business_group_id = p_business_group_id;
744
745 begin
746
747 open c_leg;
748 fetch c_leg into l_leg_code;
749 close c_leg;
750
751 return l_leg_code;
752
753 end;
754 --
755 -- ----------------------------------------------------------------------------
756 -- |-----------------------------< get_inpval_tab >---------------------------|
757 -- ----------------------------------------------------------------------------
758 --
759 procedure get_inpval_tab
760 (p_element_entry_id in number,
761 p_effective_date in date,
762 p_inpval_tab out nocopy inpval_tab_typ) is
763
764 /*
765 -- commented for bug 5721053
766 cursor c_inpval is
767 select input_value_id,
768 screen_entry_value
769 from pay_element_entry_values_f
770 where element_entry_id = p_element_entry_id
771 and p_effective_date between effective_start_date
772 and effective_end_date;
773 */
774 -- changed for bug 5721053
775 cursor c_inpval is
776 select peev.input_value_id,
777 peev.screen_entry_value,
778 piv.UOM
779 from pay_element_entry_values_f peev, pay_input_values_f piv
780 where peev.element_entry_id = p_element_entry_id
781 and p_effective_date between peev.effective_start_date and peev.effective_end_date
782 and piv.input_value_id = peev.input_value_id
783 and p_effective_date between piv.effective_start_date and piv.effective_end_date;
784
785 type t_input_value_id is table of number(15);
786 type t_value is table of varchar2(60);
787 type t_uom is table of VARCHAR2(30);
788
789 l_input_value_id t_input_value_id;
790 l_value t_value;
791 l_uom t_uom;
792 l_canonical_date date;
793
794
795 begin
796
797
798 open c_inpval;
799 fetch c_inpval bulk collect into l_input_value_id, l_value, l_uom;
800 close c_inpval;
801
802 for i in 1..l_input_value_id.count
803 loop
804 p_inpval_tab(i).input_value_id := l_input_value_id(i);
805 -- bug 5721053
806 IF l_uom (i) = 'D' OR l_uom (i) = 'DATE'
807 THEN
808 l_canonical_date := fnd_date.canonical_to_date (l_value (i));
809 p_inpval_tab (i).VALUE :=
810 fnd_date.date_to_displaydate (l_canonical_date);
811 -- Bug 6820098
812 ELSE
813 p_inpval_tab(i).value := l_value(i);
814 -- Bug 6820098
815 END IF;
816 -- end bug 5721053
817 end loop;
818
819 for i in (l_input_value_id.count + 1)..15
820 loop
821 p_inpval_tab(i).input_value_id := null;
822 p_inpval_tab(i).value := null;
823 end loop;
824
825 end get_inpval_tab;
826 -- ----------------------------------------------------------------------------
827 -- |---------------------------------< get_uom>-------------------------------|
828 -- ----------------------------------------------------------------------------
829 --
830 function get_uom
831 (p_business_group_id in number,
832 p_effective_date in date)
833 return varchar2 is
834
835 cursor get_pgm_curr_code (c_pgm_id number,
836 c_effective_date date,
837 c_business_group_id number) is
838 select pgm_uom
839 from ben_pgm_f
840 where pgm_id = c_pgm_id
841 and c_effective_date between effective_start_date
842 and effective_end_date
843 and business_group_id = c_business_group_id;
844
845 -- For plans not in progarms
846 cursor get_pl_curr_code (c_pl_id number,
847 c_effective_date date,
848 c_business_group_id number) is
849 select nip_pl_uom
850 from ben_pl_f
851 where pl_id = c_pl_id
852 and c_effective_date between effective_start_date
853 and effective_end_date
854 and business_group_id = c_business_group_id;
855
856 l_uom varchar2(30);
857
858 begin
859
860 if g_debug then
861 hr_utility.set_location('g_result_rec.pgm_id='|| g_result_rec.pgm_id,5);
862 hr_utility.set_location('g_result_rec.pl_id='|| g_result_rec.pl_id,5);
863 end if;
864
865 if g_result_rec.pgm_id is not null then
866
867 open get_pgm_curr_code
868 ( g_result_rec.pgm_id
869 ,p_effective_date
870 ,p_business_group_id);
871 fetch get_pgm_curr_code into l_uom;
872 close get_pgm_curr_code;
873
874 elsif g_result_rec.pl_id is not null then
875
876 open get_pl_curr_code
877 ( g_result_rec.pl_id
878 ,p_effective_date
879 ,p_business_group_id);
880 fetch get_pl_curr_code into l_uom;
881 close get_pl_curr_code;
882
883 end if;
884
885 if g_debug then
886 hr_utility.set_location('l_uom ='||l_uom,432);
887 end if;
888
889 return l_uom;
890
891 end;
892 --
893 -- ----------------------------------------------------------------------------
894 -- |------------------------------< chkformat>--------------------------------|
895 -- ----------------------------------------------------------------------------
896 --
897 function chkformat(p_value in varchar2
898 ,p_curr_code in varchar2)
899 return number is
900
901 changed_val varchar2(60);
902 nvalue number;
903
904 begin
905
906 nvalue := fnd_number.canonical_to_number(p_value);
907
908 if p_curr_code is null then
909 return to_number(p_value);
910 end if;
911
912 SELECT LTRIM
913 ( TO_CHAR
914 ( DECODE --round to min acct limits if available.
915 ( fc.minimum_accountable_unit,
916 NULL, ROUND( nvalue, fc.precision ),
917 ROUND( nvalue / fc.minimum_accountable_unit ) * fc.minimum_accountable_unit
918 )
919 , CONCAT --construct NLS format mask.
920 ( '99999999999999999990', --currencies formatted without NLS 'G'.
921 DECODE( fc.precision, 0, '', RPAD( 'D', fc.precision+1, '9' ) )
922 )
923 ), ' ' --left trim white space.
924 )
925 INTO changed_val
926 FROM fnd_currencies fc
927 WHERE fc.currency_code = p_curr_code;
928
929 return to_number(changed_val);
930
931 exception
932 when others then
933 return to_number(p_value);
934
935 end chkformat;
936 --
937 -- ----------------------------------------------------------------------------
938 -- |-------------------------< get_ele_dt_upd_mode>---------------------------|
939 -- ----------------------------------------------------------------------------
940 --
941 function get_ele_dt_upd_mode
942 (p_effective_date in date,
943 p_base_key_value in number)
944 return varchar2 is
945
946 l_correction boolean;
947 l_update boolean;
948 l_update_override boolean;
949 l_update_change_insert boolean;
950 l_upd_mode varchar2(30);
951
952 begin
953
954 dt_api.find_dt_upd_modes
955 (p_effective_date => p_effective_date,
956 p_base_table_name => 'PAY_ELEMENT_ENTRIES_F',
957 p_base_key_column => 'element_entry_id',
958 p_base_key_value => p_base_key_value,
959 p_correction => l_correction,
960 p_update => l_update,
961 p_update_override => l_update_override,
962 p_update_change_insert => l_update_change_insert);
963
964 if l_update then
965 l_upd_mode := hr_api.g_update;
966 elsif l_update_override then
967 l_upd_mode := hr_api.g_update_override;
968 else
969 l_upd_mode := hr_api.g_correction;
970 end if;
971
972 return l_upd_mode;
973
974 end;
975 --
976 -- ----------------------------------------------------------------------------
977 -- |-------------------------< cache_quick_pay_run>---------------------------|
978 -- ----------------------------------------------------------------------------
979 --
980 -- Retro pay process for Quick pay run
981 procedure cache_quick_pay_run
982 (p_person_id number,
983 p_element_type_id number,
984 p_assignment_id number,
985 p_element_entry_id number,
986 p_effective_date date,
987 p_start_date date,
988 p_end_date date,
989 p_payroll_id number)
990 is
991 --
992 cursor c_quick_pay_inclusion (p_assignment_id number,
993 p_effective_date date,
994 p_element_type_id number) is
995 select qi.assignment_action_id,
996 qi.element_entry_id,
997 tp.end_date
998 from pay_assignment_actions aa,
999 pay_payroll_actions pa,
1000 pay_quickpay_inclusions qi,
1001 pay_element_links_f el,
1002 pay_element_entries_f ee,
1003 per_time_periods tp
1004 where aa.assignment_id = p_assignment_id
1005 and pa.payroll_action_id = aa.payroll_action_id
1006 and pa.action_type = 'Q'
1007 and pa.time_period_id = tp.time_period_id
1008 and p_effective_date between tp.start_date and tp.end_date
1009 and aa.assignment_action_id = qi.assignment_action_id
1010 and ee.element_entry_id = qi.element_entry_id
1011 and aa.assignment_id = ee.assignment_id
1012 and el.element_link_id = ee.element_link_id
1013 and el.element_type_id = p_element_type_id
1014 and pa.effective_date between el.effective_start_date and
1015 el.effective_end_date
1016 and pa.effective_date between ee.effective_start_date and
1017 ee.effective_end_date;
1018 --
1019 cursor c_periods(v_payroll_id in number,
1020 v_start_date in date,
1021 v_end_date in date) is
1022 select end_date
1023 from per_time_periods ptp
1024 where ptp.payroll_id = v_payroll_id
1025 and ptp.end_date between
1026 v_start_date and v_end_date;
1027 l_quick_pay_inclusion c_quick_pay_inclusion%rowtype;
1028 l_end_date date;
1029 l_count number;
1030
1031 --
1032 begin
1033 --
1034 hr_utility.set_location('Enter : Cache quick pay',111);
1035 open c_periods (p_payroll_id, p_start_date,p_end_date);
1036 loop
1037 fetch c_periods into l_end_date;
1038 if c_periods%notfound then
1039 exit;
1040 --
1041 else
1042 --
1043 hr_utility.set_location('End date : '||l_end_date,112);
1044 open c_quick_pay_inclusion (p_assignment_id,
1045 l_end_date,
1046 p_element_type_id);
1047 fetch c_quick_pay_inclusion into l_quick_pay_inclusion;
1048 if c_quick_pay_inclusion%found then
1049 --pop cache
1050 if g_cache_quick_payrun_object.count > 0 then
1051 if g_cache_quick_payrun_object(1).person_id <> p_person_id then
1052 g_cache_quick_payrun_object.delete;
1053 hr_utility.set_location('Delete : Cache quick pay',113);
1054 end if;
1055 end if;
1056 l_count := nvl(g_cache_quick_payrun_object.last,0) + 1;
1057 -- assign the values into cache
1058 g_cache_quick_payrun_object(l_count).person_id := p_person_id;
1059 g_cache_quick_payrun_object(l_count).element_type_id := p_element_type_id;
1060 g_cache_quick_payrun_object(l_count).assignment_id := p_assignment_id;
1061 g_cache_quick_payrun_object(l_count).assignment_action_id :=
1062 l_quick_pay_inclusion.assignment_action_id;
1063 g_cache_quick_payrun_object(l_count).payroll_end_date :=
1064 l_quick_pay_inclusion.end_date;
1065 hr_utility.set_location('Assignment Action id'||g_cache_quick_payrun_object(l_count).assignment_action_id, 113);
1066 end if;
1067 close c_quick_pay_inclusion;
1068 end if;
1069 end loop;
1070 close c_periods;
1071 --
1072 end;
1073 --
1074 --
1075 -- ----------------------------------------------------------------------------
1076 -- |--------------------------< insert_into_quick_pay>------------------------|
1077 -- ----------------------------------------------------------------------------
1078 --
1079 procedure insert_into_quick_pay
1080 (p_person_id number,
1081 p_element_type_id number,
1082 p_assignment_id number,
1083 p_element_entry_id number,
1084 p_effective_date date,
1085 p_start_date date,
1086 p_end_date date,
1087 p_payroll_id number) is
1088 --
1089 cursor c_periods(v_payroll_id in number,
1090 v_start_date in date,
1091 v_end_date in date) is
1092 select end_date
1093 from per_time_periods ptp
1094 where ptp.payroll_id = v_payroll_id
1095 and ptp.end_date between
1096 v_start_date and v_end_date;
1097 l_end_date date;
1098 l_count number;
1099 --
1100 begin
1101 --
1102 hr_utility.set_location('Enter : insert into quick pay',111);
1103 open c_periods (p_payroll_id, p_start_date,p_end_date);
1104 loop
1105 fetch c_periods into l_end_date;
1106 if c_periods%notfound then
1107 --
1108 exit;
1109 --
1110 else
1111 --
1112 if g_cache_quick_payrun_object.count > 0 then
1113 for j in g_cache_quick_payrun_object.first .. g_cache_quick_payrun_object.last
1114 loop
1115 if g_cache_quick_payrun_object(j).person_id = p_person_id and
1116 g_cache_quick_payrun_object(j).element_type_id = p_element_type_id and
1117 g_cache_quick_payrun_object(j).payroll_end_date = l_end_date then
1118 hr_utility.set_location('Insert quick pay'||p_element_entry_id,11);
1119 hr_utility.set_location('Assignment action Id'||g_cache_quick_payrun_object(j).assignment_action_id, 12);
1120 insert into pay_quickpay_inclusions (element_entry_id, assignment_action_id)
1121 values (p_element_entry_id,g_cache_quick_payrun_object(j).assignment_action_id);
1122 end if;
1123 end loop;
1124 end if;
1125 end if;
1126 end loop;
1127 close c_periods;
1128 End;
1129
1130 -- ----------------------------------------------------------------------------
1131 -- |-----------------------< get_abr_assignment >-----------------------------|
1132 -- ----------------------------------------------------------------------------
1133 procedure get_abr_assignment
1134 (p_person_id in number
1135 ,p_effective_date in date
1136 ,p_acty_base_rt_id in number
1137 ,p_organization_id out nocopy number
1138 ,p_payroll_id out nocopy number
1139 ,p_assignment_id out nocopy number
1140 )
1141 is
1142 --
1143 cursor get_asmt_to_use_cd
1144 (c_acty_base_rt_id in number
1145 ,c_effective_date in date
1146 )
1147 is
1148 select abr.asmt_to_use_cd
1149 from ben_acty_base_rt_f abr
1150 where abr.acty_base_rt_id = c_acty_base_rt_id
1151 and c_effective_date between
1152 abr.effective_start_date and abr.effective_end_date;
1153 --
1154 -- Cursor to get assignment_id
1155 --
1156 CURSOR get_assignment (
1157 c_person_id IN NUMBER,
1158 c_assignment_type IN VARCHAR2,
1159 c_effective_date IN DATE
1160 )
1161 IS
1162 SELECT asg.assignment_id, asg.payroll_id, asg.organization_id,
1163 asg.effective_start_date, asg.effective_end_date
1164 FROM per_all_assignments_f asg, per_assignment_status_types ast
1165 WHERE asg.person_id = c_person_id
1166 AND asg.assignment_type <> 'C'
1167 AND asg.primary_flag = 'Y'
1168 AND asg.assignment_status_type_id = ast.assignment_status_type_id
1169 -- AND ast.per_system_status <> 'TERM_ASSIGN' /* Bug 5655933 */
1170 AND asg.assignment_type =
1171 NVL (c_assignment_type, asg.assignment_type)
1172 AND c_effective_date BETWEEN asg.effective_start_date
1173 AND asg.effective_end_date
1174 ORDER BY asg.assignment_type DESC ; -- Bug 4463077 : Look for employee assignment and then for benefits asg
1175 --
1176 l_effective_start_date date;
1177 l_effective_end_date date;
1178 l_asmt_to_use_cd VARCHAR2(30);
1179 l_proc VARCHAR2(72) := g_package||'get_abr_assignment';
1180 --
1181 begin
1182 --
1183 g_debug := hr_utility.debug_enabled;
1184 if g_debug then
1185 hr_utility.set_location('Entering: '||l_proc,5);
1186 hr_utility.set_location('p_effective_date: '||p_effective_date,5);
1187 end if;
1188 --
1189 -- get assignment to use code.
1190 --
1191 open get_asmt_to_use_cd
1192 (c_acty_base_rt_id => p_acty_base_rt_id
1193 ,c_effective_date => p_effective_date
1194 );
1195 fetch get_asmt_to_use_cd into l_asmt_to_use_cd;
1196 if get_asmt_to_use_cd%notfound then
1197 close get_asmt_to_use_cd;
1198 if g_debug then
1199 hr_utility.set_location('BEN_91723_NO_ENRT_RT_ABR_FOUND',30);
1200 end if;
1201 fnd_message.set_name('BEN','BEN_91723_NO_ENRT_RT_ABR_FOUND');
1202 fnd_message.set_token('PROC',l_proc);
1203 fnd_message.set_token('ACTY_BASE_RT_ID',to_char(p_acty_base_rt_id));
1204 fnd_message.set_token('EFFECTIVE_DATE',to_char(p_effective_date));
1205 fnd_message.raise_error;
1206 else
1207 close get_asmt_to_use_cd;
1208 end if;
1209 --
1210 -- check if this info is already cached
1211 --
1212 if g_abr_asg_rec.person_id = p_person_id and
1213 nvl(g_abr_asg_rec.asmt_to_use_cd,'ETB') = nvl(l_asmt_to_use_cd,'ETB') and
1214 (p_effective_date between g_abr_asg_rec.effective_start_date and
1215 g_abr_asg_rec.effective_end_date) then
1216
1217 p_assignment_id := g_abr_asg_rec.assignment_id;
1218 p_payroll_id := g_abr_asg_rec.payroll_id;
1219 p_organization_id := g_abr_asg_rec.organization_id;
1220
1221 if g_debug then
1222 hr_utility.set_location('asmt_to_use_cd: '||l_asmt_to_use_cd,5);
1223 hr_utility.set_location('organization_id: '||p_organization_id,5);
1224 hr_utility.set_location('payroll_id: '||p_payroll_id,5);
1225 hr_utility.set_location('assignment_id: '||p_assignment_id,5);
1226 hr_utility.set_location('Leaving: '||l_proc,5);
1227 end if;
1228 return;
1229 else
1230 g_abr_asg_rec.person_id := null;
1231 g_abr_asg_rec.assignment_id := null;
1232 g_abr_asg_rec.payroll_id := null;
1233 g_abr_asg_rec.organization_id := null;
1234 g_abr_asg_rec.effective_start_date := null;
1235 g_abr_asg_rec.effective_end_date := null;
1236 end if;
1237 --
1238 -- Check the assigment to use code to get the assignment id
1239 -- for the element entry.
1240 --
1241 if (l_asmt_to_use_cd = 'EAO') then
1242 --
1243 -- Employee assignment only.
1244 --
1245 open get_assignment
1246 (c_person_id => p_person_id
1247 ,c_assignment_type => 'E'
1248 ,c_effective_date => p_effective_date
1249 );
1250 fetch get_assignment into p_assignment_id
1251 ,p_payroll_id
1252 ,p_organization_id
1253 ,l_effective_start_date
1254 ,l_effective_end_date;
1255 close get_assignment;
1256 --
1257 elsif l_asmt_to_use_cd = 'BAO' then
1258 --
1259 -- Benefit assignment only.
1260 --
1261 open get_assignment
1262 (c_person_id => p_person_id
1263 ,c_assignment_type => 'B'
1264 ,c_effective_date => p_effective_date
1265 );
1266 fetch get_assignment into p_assignment_id
1267 ,p_payroll_id
1268 ,p_organization_id
1269 ,l_effective_start_date
1270 ,l_effective_end_date;
1271 close get_assignment;
1272 --
1273 elsif l_asmt_to_use_cd = 'BTE' then
1274 --
1275 -- Benefit assignment then employee assignment.
1276 --
1277 open get_assignment
1278 (c_person_id => p_person_id
1279 ,c_assignment_type => 'B'
1280 ,c_effective_date => p_effective_date
1281 );
1282 fetch get_assignment into p_assignment_id
1283 ,p_payroll_id
1284 ,p_organization_id
1285 ,l_effective_start_date
1286 ,l_effective_end_date;
1287 if get_assignment%notfound then
1288 close get_assignment;
1289 if g_debug then
1290 hr_utility.set_location('Benefit assignment not found- BTE',5);
1291 end if;
1292 --
1293 -- Get employee assignment.
1294 --
1295 open get_assignment
1296 (c_person_id => p_person_id
1297 ,c_assignment_type => 'E'
1298 ,c_effective_date => p_effective_date
1299 );
1300 fetch get_assignment into p_assignment_id
1301 ,p_payroll_id
1302 ,p_organization_id
1303 ,l_effective_start_date
1304 ,l_effective_end_date;
1305 close get_assignment;
1306 else
1307 close get_assignment;
1308 end if;
1309 --
1310 /* elsif l_asmt_to_use_cd = 'ANY' then
1311 --
1312 -- Any assignment only.
1313 --
1314 open get_assignment
1315 (c_person_id => p_person_id
1316 ,c_assignment_type => null
1317 ,c_effective_date => p_effective_date
1318 );
1319 fetch get_assignment into p_assignment_id
1320 ,p_payroll_id
1321 ,p_organization_id
1322 ,l_effective_start_date
1323 ,l_effective_end_date;
1324 close get_assignment;
1325 --
1326 */
1327 elsif (l_asmt_to_use_cd = 'EBA' or l_asmt_to_use_cd = 'ANY' ) then
1328 --
1329 -- Employee assignment then benefit assignment.
1330 --
1331 open get_assignment
1332 (c_person_id => p_person_id
1333 ,c_assignment_type => 'E'
1334 ,c_effective_date => p_effective_date
1335 );
1336 fetch get_assignment into p_assignment_id
1337 ,p_payroll_id
1338 ,p_organization_id
1339 ,l_effective_start_date
1340 ,l_effective_end_date;
1341 if get_assignment%notfound then
1342 close get_assignment;
1343 --
1344 -- Get benefit assignment.
1345 --
1346 open get_assignment
1347 (c_person_id => p_person_id
1348 ,c_assignment_type => 'B'
1349 ,c_effective_date => p_effective_date
1350 );
1351 fetch get_assignment into p_assignment_id
1352 ,p_payroll_id
1353 ,p_organization_id
1354 ,l_effective_start_date
1355 ,l_effective_end_date;
1356 if get_assignment%notfound then
1357 close get_assignment;
1358 --
1359 -- Get applicant assignment.
1360 --
1361 open get_assignment
1362 (c_person_id => p_person_id
1363 ,c_assignment_type => 'A'
1364 ,c_effective_date => p_effective_date
1365 );
1366 fetch get_assignment into p_assignment_id
1367 ,p_payroll_id
1368 ,p_organization_id
1369 ,l_effective_start_date
1370 ,l_effective_end_date;
1371 close get_assignment;
1372 else
1373 close get_assignment;
1374 end if;
1375 else
1376 close get_assignment;
1377 end if;
1378 --
1379 elsif (l_asmt_to_use_cd = 'ETB' or l_asmt_to_use_cd is null) then
1380 --
1381 -- Employee assignment then benefit assignment. - Default
1382 --
1383 open get_assignment
1384 (c_person_id => p_person_id
1385 ,c_assignment_type => 'E'
1386 ,c_effective_date => p_effective_date
1387 );
1388 fetch get_assignment into p_assignment_id
1389 ,p_payroll_id
1390 ,p_organization_id
1391 ,l_effective_start_date
1392 ,l_effective_end_date;
1393 if get_assignment%notfound then
1394 if g_debug then
1395 hr_utility.set_location('Employee assignment not found- ETB',5);
1396 end if;
1397 close get_assignment;
1398 --
1399 -- Get benefit assignment.
1400 --
1401 open get_assignment
1402 (c_person_id => p_person_id
1403 ,c_assignment_type => 'B'
1404 ,c_effective_date => p_effective_date
1405 );
1406 fetch get_assignment into p_assignment_id
1407 ,p_payroll_id
1408 ,p_organization_id
1409 ,l_effective_start_date
1410 ,l_effective_end_date;
1411 close get_assignment;
1412 else
1413 close get_assignment;
1414 end if;
1415 --
1416 elsif l_asmt_to_use_cd = 'AAO' then
1417 --
1418 -- Applicant assignment only.
1419 --
1420 open get_assignment
1421 (c_person_id => p_person_id
1422 ,c_assignment_type => 'A'
1423 ,c_effective_date => p_effective_date
1424 );
1425 fetch get_assignment into p_assignment_id
1426 ,p_payroll_id
1427 ,p_organization_id
1428 ,l_effective_start_date
1429 ,l_effective_end_date;
1430 close get_assignment;
1431 --
1432 end if;
1433 --
1434 g_abr_asg_rec.person_id := p_person_id;
1435 g_abr_asg_rec.assignment_id := p_assignment_id;
1436 g_abr_asg_rec.payroll_id := p_payroll_id;
1437 g_abr_asg_rec.organization_id := p_organization_id;
1438 g_abr_asg_rec.effective_start_date := l_effective_start_date;
1439 g_abr_asg_rec.effective_end_date := l_effective_end_date;
1440 -- added for bug 5909589
1441 g_abr_asg_rec.asmt_to_use_cd := l_asmt_to_use_cd;
1442
1443 if g_debug then
1444 hr_utility.set_location('asmt_to_use_cd: '||l_asmt_to_use_cd,60);
1445 hr_utility.set_location('organization_id: '||p_organization_id,60);
1446 hr_utility.set_location('payroll_id: '||p_payroll_id,60);
1447 hr_utility.set_location('assignment_id: '||p_assignment_id,60);
1448 hr_utility.set_location('Leaving: '||l_proc,60);
1449 end if;
1450 --
1451 end get_abr_assignment;
1452 --
1453 -- ----------------------------------------------------------------------------
1454 -- |-----------------------< get_default_payroll >----------------------------|
1455 -- ----------------------------------------------------------------------------
1456 --
1457 function get_default_payroll
1458 (p_business_group_id in number
1459 ,p_effective_date in date
1460 ) return number
1461 is
1462 --
1463 l_payroll_id number;
1464 l_proc varchar2(72) := g_package||'get_default_payroll';
1465 --
1466 cursor c_get_default_payroll
1467 (c_business_group_id in number
1468 ,c_effective_date in date
1469 )
1470 is
1471 select payroll_id
1472 from pay_payrolls_f
1473 where business_group_id = c_business_group_id
1474 and period_type = 'Calendar Month'
1475 and c_effective_date
1476 between effective_start_date and effective_end_date;
1477 --
1478 begin
1479
1480 if g_debug then
1481 hr_utility.set_location('Entering:' ||l_proc,5);
1482 end if;
1483
1484 open c_get_default_payroll
1485 (c_business_group_id => p_business_group_id
1486 ,c_effective_date => p_effective_date
1487 );
1488 fetch c_get_default_payroll into l_payroll_id;
1489 close c_get_default_payroll;
1490
1491 if g_debug then
1492 hr_utility.set_location('Leaving:' ||l_proc,5);
1493 end if;
1494
1495 return l_payroll_id;
1496
1497 end get_default_payroll;
1498
1499 -- ----------------------------------------------------------------------------
1500 -- |-----------------------< chk_assign_exists >-----------------------------|
1501 -- ----------------------------------------------------------------------------
1502 -- This Function checks the existence of a current
1503 -- Employee or Benefits assignment
1504 -- and returns the assignment_id and payroll_id
1505 --
1506 function chk_assign_exists
1507 (p_person_id IN NUMBER
1508 ,p_business_group_id IN NUMBER
1509 ,p_effective_date IN DATE
1510 ,p_rate_date IN DATE
1511 ,p_acty_base_rt_id IN number
1512 ,p_assignment_id IN OUT NOCOPY NUMBER
1513 ,p_organization_id in out nocopy number
1514 ,p_payroll_id IN OUT NOCOPY NUMBER
1515 ) RETURN BOOLEAN
1516 is
1517 --
1518 l_proc varchar2(72) := g_package||'chk_assign_exists';
1519 --
1520 cursor c1 is
1521 select nvl(abr.ele_entry_val_cd,'PP') ele_entry_val_cd,
1522 abr.name
1523 from ben_acty_base_rt_f abr
1524 where abr.acty_base_rt_id = p_acty_base_rt_id
1525 and p_rate_date between abr.effective_start_date
1526 and abr.effective_end_date;
1527 --
1528 l_ele_entry_val_cd varchar2(30);
1529 l_name ben_acty_base_rt_f.name%TYPE ;
1530 --
1531 begin
1532 g_debug := hr_utility.debug_enabled;
1533 if g_debug then
1534 hr_utility.set_location('Entering:' ||l_proc,5);
1535 end if;
1536
1537 -- First look for an assignment based on the date the rate is being
1538 -- started or ended. We need to do this so that we pick up the correct
1539 -- assignment that the EE should be attached to. For example: if we are
1540 -- processing a termination event on 5/15 and we want to end a person's
1541 -- EE from prior enrollments, we need to pick up the Employee assignment
1542 -- that exists on 5/14 (rate end date), not the benefit's assignment that
1543 -- is created on 5/15.
1544
1545 if g_debug then
1546 hr_utility.set_location('p_assignment_id:' ||p_assignment_id,5);
1547 end if;
1548 get_abr_assignment (p_person_id => p_person_id
1549 ,p_effective_date => p_rate_date
1550 ,p_acty_base_rt_id => p_acty_base_rt_id
1551 ,p_organization_id => p_organization_id
1552 ,p_payroll_id => p_payroll_id
1553 ,p_assignment_id => p_assignment_id);
1554 if g_debug then
1555 hr_utility.set_location('p_assignment_id:' ||p_assignment_id,10);
1556 end if;
1557 --Bug 3151737 and 3063518
1558 open c1 ;
1559 fetch c1 into l_ele_entry_val_cd,l_name ;
1560 close c1 ;
1561 --
1562 if p_assignment_id is NOT NULL then
1563 --
1564 -- Bug 3151737 and 3063518 Why we do we care this for non EPP / PP cases.
1565 -- User needs explicitly mention communicated or defined value in the value passed
1566 -- to payroll if they are not using the payroll .
1567 -- Then we don't need to care for payroll and also we don't need to compute
1568 -- the pp amount using the bendisrt routines
1569 --
1570 if l_ele_entry_val_cd = 'PP' or
1571 l_ele_entry_val_cd = 'EPP' then
1572 --
1573 if p_payroll_id is null then
1574 /*
1575 if g_debug then
1576 hr_utility.set_location('BEN_92458_NO_ASG_PAYROLL PERSON:'|| to_char(p_person_id),5);
1577 end if;
1578 fnd_message.set_name('BEN', 'BEN_92458_NO_ASG_PAYROLL');
1579 fnd_message.set_token('PROC',l_proc);
1580 fnd_message.set_token('PERSON_ID',to_char(p_person_id));
1581 fnd_message.set_token('ASSIGNMENT_ID',to_char(p_assignment_id));
1582 fnd_message.raise_error;
1583 */
1584 if g_debug then
1585 hr_utility.set_location('BEN_93606_NO_ASG_PAYROLL PERSON:'|| to_char(p_person_id),5);
1586 end if;
1587 fnd_message.set_name('BEN', 'BEN_93606_NO_ASG_PAYROLL');
1588 fnd_message.set_token('ABR_NAME', l_name);
1589 fnd_message.set_token('PROC',l_proc);
1590 fnd_message.set_token('PERSON_ID',to_char(p_person_id));
1591 fnd_message.set_token('ASSIGNMENT_ID',to_char(p_assignment_id));
1592 fnd_message.raise_error;
1593 end if;
1594 --
1595 end if;
1596 --
1597 return TRUE;
1598 else
1599
1600 -- If there is no assignment on the date the rate is to be started or ended,
1601 -- look for an assignment on the effective date. Example: A new hire event
1602 -- is processsed on 5/15, enrollments are made. On 5/18, the enrollment is
1603 -- changed, the new enrollment is started on 5/15 (as of event date),
1604 -- the old one is ended on 5/14 (one day before event date), there is no
1605 -- assignment on 5/14 (because it was a new hire on 5/15).
1606 --
1607 get_abr_assignment (p_person_id => p_person_id
1608 ,p_effective_date => p_effective_date
1609 ,p_acty_base_rt_id => p_acty_base_rt_id
1610 ,p_organization_id => p_organization_id
1611 ,p_payroll_id => p_payroll_id
1612 ,p_assignment_id => p_assignment_id);
1613 if p_assignment_id is NOT NULL then
1614 --
1615 if l_ele_entry_val_cd = 'PP' or
1616 l_ele_entry_val_cd = 'EPP' then
1617 --
1618 if p_payroll_id is null then
1619 /*
1620 if g_debug then
1621 hr_utility.set_location('BEN_92458_NO_ASG_PAYROLL PERSON:'|| to_char(p_person_id),5);
1622 end if;
1623 fnd_message.set_name('BEN', 'BEN_92458_NO_ASG_PAYROLL');
1624 fnd_message.set_token('PROC',l_proc);
1625 fnd_message.set_token('PERSON_ID',to_char(p_person_id));
1626 fnd_message.set_token('ASSIGNMENT_ID',to_char(p_assignment_id));
1627 fnd_message.raise_error;
1628 */
1629 if g_debug then
1630 hr_utility.set_location('BEN_93606_NO_ASG_PAYROLL PERSON:'|| to_char(p_person_id),5);
1631 end if;
1632 fnd_message.set_name('BEN', 'BEN_93606_NO_ASG_PAYROLL');
1633 fnd_message.set_token('ABR_NAME', l_name);
1634 fnd_message.set_token('PROC',l_proc);
1635 fnd_message.set_token('PERSON_ID',to_char(p_person_id));
1636 fnd_message.set_token('ASSIGNMENT_ID',to_char(p_assignment_id));
1637 fnd_message.raise_error;
1638 end if;
1639 end if;
1640 return TRUE;
1641 --
1642 else
1643
1644 p_payroll_id := get_default_payroll
1645 (p_business_group_id => p_business_group_id
1646 ,p_effective_date => p_effective_date
1647 );
1648 if p_payroll_id is null then
1649 if g_debug then
1650 hr_utility.set_location('BEN_92347_NO_DFLT_PAYROLL',25);
1651 end if;
1652 fnd_message.set_name('BEN', 'BEN_92347_NO_DFLT_PAYROLL');
1653 fnd_message.set_token('PROC',l_proc);
1654 fnd_message.set_token('PERSON_ID',to_char(p_person_id));
1655 fnd_message.set_token('EFFECTIVE_DATE',to_char(p_effective_date));
1656 fnd_message.set_token('BG_ID',to_char(p_business_group_id));
1657 fnd_message.raise_error;
1658 else
1659 if g_debug then
1660 hr_utility.set_location('Leaving-returning false:' ||l_proc,5);
1661 end if;
1662 return FALSE;
1663 end if;
1664 end if;
1665 end if;
1666 if g_debug then
1667 hr_utility.set_location('Leaving:' ||l_proc,5);
1668 end if;
1669 end chk_assign_exists;
1670
1671 -- ----------------------------------------------------------------------------
1672 -- |---------------< create_benefits_assignment >-----------------------------|
1673 -- ----------------------------------------------------------------------------
1674 -- This Procedure creates a benefits assignments
1675 -- If the participant record being enrolled does not
1676 -- have an assignment.
1677
1678 procedure create_benefits_assignment(p_person_id IN NUMBER
1679 ,p_payroll_id IN NUMBER
1680 ,p_assignment_id IN OUT NOCOPY NUMBER
1681 ,p_business_group_id IN NUMBER
1682 ,p_organization_id in out nocopy number
1683 ,p_effective_date IN DATE) is
1684 --
1685 l_assignment_id NUMBER; -- Assignment ID.
1686 l_effective_start_date DATE; -- Effective Start Date.
1687 l_effective_end_date DATE; -- Effective End Date.
1688 l_assignment_extra_info_id NUMBER; -- Assignment Extra Info ID.
1689 l_object_version_number NUMBER; -- Object version number.
1690 l_aei_object_version_number NUMBER; -- AEI Object version number.
1691 l_proc varchar2(75);
1692 begin
1693 g_debug := hr_utility.debug_enabled;
1694 if g_debug then
1695 l_proc := ' Create_Benefits_Assignment';
1696 hr_utility.set_location('Entering:' ||l_proc,5);
1697 end if;
1698 BEN_assignment_API.create_ben_asg
1699 (p_effective_date => p_effective_date
1700 ,p_PERSON_ID => p_person_id
1701 ,p_ORGANIZATION_ID => p_business_group_id
1702 ,p_PAYROLL_ID => p_payroll_id
1703 -- ,p_ASSIGNMENT_TYPE =>'A'
1704 -- ,p_PRIMARY_FLAG =>'Y'
1705 ,p_ASSIGNMENT_STATUS_TYPE_ID => 1
1706 ,p_ASSIGNMENT_ID => l_assignment_id
1707 ,p_OBJECT_VERSION_NUMBER => l_object_version_number
1708 ,p_EFFECTIVE_START_DATE => l_effective_start_date
1709 ,p_EFFECTIVE_END_DATE => l_effective_end_date
1710 ,p_ASSIGNMENT_EXTRA_INFO_ID => l_assignment_extra_info_id
1711 ,p_AEI_OBJECT_VERSION_NUMBER => l_aei_object_version_number);
1712 p_organization_id:=p_business_group_id;
1713 if g_debug then
1714 hr_utility.set_location('Leaving:' ||l_proc,5);
1715 end if;
1716 end create_benefits_assignment;
1717 --
1718 -- ----------------------------------------------------------------------------
1719 -- |---------------------< prorate_amount >-----------------------------|
1720 -- ----------------------------------------------------------------------------
1721 function prorate_amount(p_amt IN NUMBER --per month amount
1722 ,p_acty_base_rt_id IN NUMBER
1723 ,p_actl_prem_id in number
1724 ,p_cvg_amt_calc_mthd_id in number
1725 ,p_person_id in number
1726 ,p_rndg_cd in varchar2
1727 ,p_rndg_rl in number
1728 ,p_pgm_id in number
1729 ,p_pl_typ_id in number
1730 ,p_pl_id in number
1731 ,p_opt_id in number
1732 ,p_ler_id in number
1733 ,p_prorate_flag IN OUT NOCOPY VARCHAR2
1734 ,p_effective_date in DATE
1735 ,p_start_or_stop_cd in varchar2
1736 ,p_start_or_stop_date in date
1737 ,p_business_group_id in number
1738 ,p_assignment_id in number
1739 ,p_organization_id in number
1740 ,p_jurisdiction_code in varchar2
1741 ,p_wsh_rl_dy_mo_num in number
1742 ,p_prtl_mo_det_mthd_cd in out nocopy varchar2
1743 ,p_prtl_mo_det_mthd_rl in number)
1744 RETURN NUMBER
1745 IS --prorated per month amount
1746 --
1747 cursor get_prtn_row
1748 (c_acty_base_rt_id in number
1749 ,c_actl_prem_id in number
1750 ,c_cvg_amt_calc_mthd_id in number
1751 ,c_effective_date in date
1752 ,c_start_or_stop_date in date
1753 ,c_start_or_stop_cd in varchar2
1754 )
1755 is
1756 select *
1757 from BEN_PRTL_MO_RT_PRTN_VAL_F
1758 where (acty_base_rt_id = p_acty_base_rt_id or
1759 actl_prem_id = p_actl_prem_id or
1760 cvg_amt_calc_mthd_id = p_cvg_amt_calc_mthd_id
1761 )
1762 and c_effective_date
1763 between effective_start_date and effective_end_date
1764 and to_number(to_char(c_start_or_stop_date,'DD'))
1765 between from_dy_mo_num and to_dy_mo_num
1766 and (num_days_month = to_number(to_char(last_day(c_start_or_stop_date),'DD')) or
1767 num_days_month is null)
1768 and c_start_or_stop_cd=
1769 decode(nvl(strt_r_stp_cvg_cd,'ETHR'),'ETHR',c_start_or_stop_cd,strt_r_stp_cvg_cd);
1770 --
1771 --
1772 cursor get_prtn_method
1773 (c_acty_base_rt_id in number
1774 ,c_actl_prem_id in number
1775 ,c_cvg_amt_calc_mthd_id in number
1776 ,c_effective_date in date)
1777 is
1778 select 'Y'
1779 from BEN_PRTL_MO_RT_PRTN_VAL_F
1780 where (acty_base_rt_id = p_acty_base_rt_id or
1781 actl_prem_id = p_actl_prem_id or
1782 cvg_amt_calc_mthd_id = p_cvg_amt_calc_mthd_id
1783 )
1784 and prorate_by_day_to_mon_flag = 'Y'
1785 and c_effective_date
1786 between effective_start_date and effective_end_date;
1787 --
1788 l_rounded_value number;
1789 l_prorated_amt number;
1790 l_pct_val number;
1791 p_rec BEN_PRTL_MO_RT_PRTN_VAL_F%ROWTYPE;
1792 l_proc varchar2(75) := ' Prorate_amount';
1793 l_result_amt number;
1794 l_outputs ff_exec.outputs_t;
1795 l_return_amt number;
1796 l_jurisdiction_code varchar2(30);
1797 l_was_rounded boolean:=false;
1798 l_prtn_method varchar2(30);
1799 --
1800 begin
1801 --
1802 if g_debug then
1803 hr_utility.set_location('Entering:' ||l_proc,5);
1804 end if;
1805 --
1806 if p_prtl_mo_det_mthd_cd='RL' and
1807 p_prtl_mo_det_mthd_rl is not null then
1808 --
1809 l_outputs:=benutils.formula
1810 (p_opt_id =>p_opt_id,
1811 p_pl_id =>p_pl_id,
1812 p_pgm_id =>p_pgm_id,
1813 p_formula_id =>p_prtl_mo_det_mthd_rl,
1814 p_ler_id =>p_ler_id,
1815 p_pl_typ_id =>p_pl_typ_id,
1816 p_assignment_id =>p_assignment_id,
1817 p_acty_base_rt_id =>p_acty_base_rt_id,
1818 p_business_group_id =>p_business_group_id,
1819 p_organization_id =>p_organization_id,
1820 p_jurisdiction_code =>p_jurisdiction_code,
1821 p_effective_date =>p_effective_date);
1822 --
1823 begin
1824 --
1825 -- convert return value to code
1826 --
1827 p_prtl_mo_det_mthd_cd:=l_outputs(l_outputs.first).value;
1828 --
1829 exception
1830 --
1831 when others then
1832 if g_debug then
1833 hr_utility.set_location('BEN_92311_FORMULA_VAL_PARAM',5);
1834 end if;
1835 fnd_message.set_name('BEN','BEN_92311_FORMULA_VAL_PARAM');
1836 fnd_message.set_token('PROC',l_proc);
1837 fnd_message.set_token('FORMULA',p_prtl_mo_det_mthd_rl);
1838 fnd_message.set_token('PARAMETER',l_outputs(l_outputs.first).name);
1839 fnd_message.raise_error;
1840 --
1841 end;
1842 end if;
1843 --
1844 if p_prtl_mo_det_mthd_cd is null
1845 or p_prtl_mo_det_mthd_cd = 'ALL'
1846 then
1847 p_prorate_flag:='N';
1848 l_return_amt:=p_amt;
1849 elsif p_prtl_mo_det_mthd_cd='NONE' then
1850 p_prorate_flag:='Y';
1851 l_return_amt:=0;
1852 elsif p_prtl_mo_det_mthd_cd='PRTVAL' then
1853 if g_debug then
1854 hr_utility.set_location('p_start_or_stop_cd '||p_start_or_stop_cd,5);
1855 end if;
1856 --
1857 -- find proration method
1858 open get_prtn_method
1859 (c_acty_base_rt_id => p_acty_base_rt_id
1860 ,c_actl_prem_id => p_actl_prem_id
1861 ,c_cvg_amt_calc_mthd_id => p_cvg_amt_calc_mthd_id
1862 ,c_effective_date => p_effective_date);
1863 fetch get_prtn_method into l_prtn_method;
1864 close get_prtn_method;
1865 --
1866 if l_prtn_method = 'Y' then
1867 --
1868 hr_utility.set_location ('Proration by day to month',111);
1869 if p_start_or_stop_cd = 'STRT' then
1870 --
1871 l_pct_val := (to_number(to_char(last_day(p_start_or_stop_date),'DD')) -
1872 to_number(to_char(p_start_or_stop_date,'DD')) + 1 ) /
1873 to_number(to_char(last_day(p_start_or_stop_date),'DD'));
1874 elsif p_start_or_stop_cd = 'STP' then
1875 --
1876 l_pct_val := to_number(to_char(p_start_or_stop_date,'DD')) /
1877 to_number(to_char(last_day(p_start_or_stop_date),'DD'));
1878 end if;
1879 hr_utility.set_location ('Percentage value'||l_pct_val,112);
1880 if l_pct_val = 100 then
1881 --
1882 p_prorate_flag := 'N';
1883 l_return_amt:=p_amt;
1884 --
1885 else
1886 --
1887 l_prorated_amt := l_pct_val * p_amt;
1888 --
1889 -- Now we have the prorated value, do the rounding
1890 --
1891 if (p_rec.rndg_cd is not null or
1892 p_rec.rndg_rl is not null) and
1893 l_prorated_amt is not null then
1894 --
1895 l_return_amt := benutils.do_rounding
1896 (p_rounding_cd => p_rec.rndg_cd,
1897 p_rounding_rl => p_rec.rndg_rl,
1898 p_value => l_prorated_amt,
1899 p_effective_date => p_effective_date);
1900 --
1901 elsif p_amt<>0 and
1902 p_amt is not null then
1903 --
1904 -- for now later do based on currency precision.
1905 --
1906 l_return_amt:=round(l_prorated_amt,2);
1907 else
1908 l_return_amt:=nvl(l_prorated_amt,0);
1909 end if;
1910 l_was_rounded:=true;
1911 p_prorate_flag:='Y';
1912 end if;
1913 --
1914 else -- proration method is N - old setup
1915 -- Get the correct ben_prtl_mo_rt_prtn_val_f
1916 --
1917 open get_prtn_row
1918 (c_acty_base_rt_id => p_acty_base_rt_id
1919 ,c_actl_prem_id => p_actl_prem_id
1920 ,c_cvg_amt_calc_mthd_id => p_cvg_amt_calc_mthd_id
1921 ,c_effective_date => p_effective_date
1922 ,c_start_or_stop_date => p_start_or_stop_date
1923 ,c_start_or_stop_cd => p_start_or_stop_cd
1924 );
1925 fetch get_prtn_row into p_rec;
1926 if get_prtn_row%notfound
1927 then
1928 if g_debug then
1929 hr_utility.set_location('prtn not found ',5);
1930 end if;
1931 close get_prtn_row;
1932 p_prorate_flag := 'N';
1933 l_return_amt:=p_amt;
1934 else
1935 close get_prtn_row;
1936 --
1937 -- If the pct_val is null then it may be a rule
1938 -- if neither error
1939 --
1940 if p_rec.pct_val is null then
1941 if p_rec.prtl_mo_prortn_rl is null then
1942 --
1943 -- Neither, error
1944 --
1945 if g_debug then
1946 hr_utility.set_location('BEN_92343_NO_PCT_VAL_OR_RL',5);
1947 end if;
1948 fnd_message.set_name('BEN', 'BEN_92343_NO_PCT_VAL_OR_RL');
1949 fnd_message.set_token('PROC',l_proc);
1950 fnd_message.set_token('PRTL_MO_RT_PRTN_VAL_ID',
1951 to_char(p_rec.prtl_mo_rt_prtn_val_id));
1952 fnd_message.set_token('ACTY_BASE_RT_ID',to_char(p_acty_base_rt_id));
1953 fnd_message.set_token('ACTL_PREM_ID',to_char(p_actl_prem_id));
1954 fnd_message.set_token('CVG_AMT_CALC_MTHD_ID',
1955 to_char(p_cvg_amt_calc_mthd_id));
1956 fnd_message.raise_error;
1957 else
1958 --
1959 -- Get pct_val from rule execution.
1960 --
1961 l_outputs:=benutils.formula
1962 (p_opt_id =>p_opt_id,
1963 p_pl_id =>p_pl_id,
1964 p_pgm_id =>p_pgm_id,
1965 p_formula_id =>p_rec.prtl_mo_prortn_rl,
1966 p_ler_id =>p_ler_id,
1967 p_pl_typ_id =>p_pl_typ_id,
1968 p_assignment_id =>p_assignment_id,
1969 p_acty_base_rt_id =>p_acty_base_rt_id,
1970 p_business_group_id =>p_business_group_id,
1971 p_organization_id =>p_organization_id,
1972 p_jurisdiction_code =>p_jurisdiction_code,
1973 p_effective_date =>p_effective_date);
1974 --
1975 begin
1976 --
1977 -- convert return value to code
1978 --
1979 l_pct_val:=l_outputs(l_outputs.first).value;
1980 --
1981 exception
1982 --
1983 when others then
1984 if g_debug then
1985 hr_utility.set_location('BEN_92311_FORMULA_VAL_PARAM',15);
1986 end if;
1987 fnd_message.set_name('BEN','BEN_92311_FORMULA_VAL_PARAM');
1988 fnd_message.set_token('PROC',l_proc);
1989 fnd_message.set_token('FORMULA',p_rec.prtl_mo_prortn_rl);
1990 fnd_message.set_token('PARAMETER',
1991 l_outputs(l_outputs.first).name);
1992 fnd_message.raise_error;
1993 --
1994 end;
1995 --
1996 end if;
1997 else
1998 l_pct_val:=p_rec.pct_val;
1999 end if;
2000 --
2001 -- Now we have the pct_val compute the amount.
2002 --
2003 if g_debug then
2004 hr_utility.set_location('l_pct_val '||l_pct_val,5);
2005 end if;
2006 if g_debug then
2007 hr_utility.set_location('p_amt '||p_amt,5);
2008 end if;
2009 if l_pct_val = 100 then
2010 --
2011 p_prorate_flag := 'N';
2012 l_return_amt:=p_amt;
2013 --
2014 else
2015 --
2016 l_prorated_amt:=p_amt*l_pct_val/100;
2017 if g_debug then
2018 hr_utility.set_location('l_prorated_amt '||l_prorated_amt,5);
2019 end if;
2020 --
2021 --end if;
2022 -- Now we have the prorated value, do the rounding
2023 --
2024 if (p_rec.rndg_cd is not null or
2025 p_rec.rndg_rl is not null) and
2026 l_prorated_amt is not null then
2027 --
2028 l_return_amt := benutils.do_rounding
2029 (p_rounding_cd => p_rec.rndg_cd,
2030 p_rounding_rl => p_rec.rndg_rl,
2031 p_value => l_prorated_amt,
2032 p_effective_date => p_effective_date);
2033 --
2034 elsif p_amt<>0 and
2035 p_amt is not null then
2036 --
2037 -- for now later do based on currency precision.
2038 --
2039 l_return_amt:=round(l_prorated_amt,2);
2040 else
2041 l_return_amt:=nvl(l_prorated_amt,0);
2042 end if;
2043 l_was_rounded:=true;
2044 p_prorate_flag:='Y';
2045 --
2046 end if; -- pct_val = 100 -- Bug 5515166
2047 end if; --proration not found
2048 --
2049 end if; -- prorate method
2050 elsif p_prtl_mo_det_mthd_cd='WASHRULE' then
2051 if ( p_start_or_stop_cd='STRT' and
2052 to_number(to_char(p_start_or_stop_date,'DD')) > p_wsh_rl_dy_mo_num)
2053 or
2054 ( p_start_or_stop_cd='STP' and
2055 to_number(to_char(p_start_or_stop_date,'DD')) < p_wsh_rl_dy_mo_num)
2056 then
2057 p_prorate_flag := 'Y';
2058 l_return_amt:=0;
2059 else
2060 p_prorate_flag := 'Y';
2061 l_return_amt:=p_amt;
2062 end if;
2063 if g_debug then
2064 hr_utility.set_location('p_start_or_stop_cd '||p_start_or_stop_cd,5);
2065 hr_utility.set_location('p_start_or_stop_date '||p_start_or_stop_date,5);
2066 hr_utility.set_location('p_wsh_rl_dy_mo_num '||p_wsh_rl_dy_mo_num,5);
2067 hr_utility.set_location('p_prorate_flag '||p_prorate_flag,5);
2068 hr_utility.set_location('l_return_amt '||l_return_amt,5);
2069 end if;
2070 else
2071 --
2072 -- unsupported code error out
2073 --
2074 if g_debug then
2075 hr_utility.set_location('BEN_92348_UNKNOWN_PRTN_DET_CD',15);
2076 end if;
2077 fnd_message.set_name('BEN', 'BEN_92348_UNKNOWN_PRTN_DET_CD');
2078 fnd_message.set_token('PROC',l_proc);
2079 fnd_message.set_token('PRTL_MO_DET_MTHD_CD',p_prtl_mo_det_mthd_cd);
2080 fnd_message.raise_error;
2081 end if;
2082 --
2083 if (p_rndg_cd is not null or
2084 p_rndg_rl is not null) and
2085 l_was_rounded=false and
2086 l_return_amt<>0 and
2087 l_return_amt is not null then
2088 --
2089 l_return_amt := benutils.do_rounding
2090 (p_rounding_cd => p_rndg_cd,
2091 p_rounding_rl => p_rndg_rl,
2092 p_value => l_return_amt,
2093 p_effective_date => p_effective_date);
2094 end if;
2095 if g_debug then
2096 hr_utility.set_location('Leaving:' ||l_proc,80);
2097 end if;
2098 --
2099 -- just to be neat, always exit here
2100 --
2101 return l_return_amt;
2102 --
2103 end prorate_amount;
2104 --
2105 -- ----------------------------------------------------------------------------
2106 -- |------------------------------< get_link >--------------------------------|
2107 -- ----------------------------------------------------------------------------
2108 -- This is the process that gets the Element link for the EE contribution
2109 -- of the element for which the acty_base_rt is for.
2110 --
2111 procedure get_link
2112 (p_assignment_id in number
2113 ,p_element_type_id in number
2114 ,p_business_group_id in number
2115 ,p_input_value_id in number
2116 ,p_effective_date in date
2117 --
2118 ,p_element_link_id out nocopy number
2119 )
2120 is
2121 --
2122 l_proc varchar2(75) := g_package || 'Get_link';
2123 --
2124 l_hv pls_integer;
2125 --
2126 l_elk_count pls_integer;
2127 --
2128 l_link_count pls_integer;
2129 --
2130 l_joincond boolean;
2131 --
2132 l_dummy varchar2(1);
2133 --
2134 cursor c_getasgdets
2135 (c_asg_id number
2136 ,c_eff_date date
2137 )
2138 is
2139 select asg.business_group_id,
2140 asg.payroll_id,
2141 asg.job_id,
2142 asg.grade_id,
2143 asg.position_id,
2144 asg.organization_id,
2145 asg.location_id,
2146 asg.pay_basis_id,
2147 asg.employment_category
2148 from per_all_assignments_f asg
2149 where asg.assignment_id = c_asg_id
2150 and c_eff_date
2151 between asg.effective_start_date and asg.effective_end_date;
2152 --
2153 l_getasgdets c_getasgdets%rowtype;
2154 --
2155 cursor c_getelkdets
2156 (c_elt_id number
2157 ,c_eff_date date
2158 )
2159 is
2160 select elk.element_link_id,
2161 elk.business_group_id,
2162 elk.element_type_id,
2163 elk.payroll_id,
2164 elk.link_to_all_payrolls_flag,
2165 elk.job_id,
2166 elk.grade_id,
2167 elk.position_id,
2168 elk.organization_id,
2169 elk.location_id,
2170 elk.pay_basis_id,
2171 elk.employment_category,
2172 elk.people_group_id
2173 from pay_element_links_f elk
2174 where elk.element_type_id = c_elt_id
2175 and c_eff_date
2176 between elk.effective_start_date and elk.effective_end_date;
2177 --
2178 cursor c_chkalu
2179 (c_asg_id number
2180 ,c_elk_id number
2181 ,c_eff_date date
2182 )
2183 is
2184 select null
2185 from pay_assignment_link_usages_f alu
2186 where alu.assignment_id = c_asg_id
2187 and alu.element_link_id = c_elk_id
2188 and c_eff_date
2189 between alu.effective_start_date and alu.effective_end_date;
2190 --
2191 cursor c_getelk
2192 (c_asg_id number
2193 ,c_elt_id number
2194 ,c_eff_date date
2195 )
2196 is
2197 select el.element_link_id
2198 from per_all_assignments_f asg,
2199 pay_element_links_f el
2200 where asg.assignment_id = c_asg_id
2201 and el.business_group_id = asg.business_group_id
2202 and el.element_type_id = c_elt_id
2203 and c_eff_date
2204 between asg.effective_start_date and asg.effective_end_date
2205 and c_eff_date
2206 between el.effective_start_date and el.effective_end_date
2207 and
2208 (
2209 (el.payroll_id is not null and
2210 el.payroll_id = asg.payroll_id)
2211 or (el.link_to_all_payrolls_flag = 'Y' and
2212 asg.payroll_id is not null)
2213 or (el.payroll_id is null and
2214 el.link_to_all_payrolls_flag = 'N')
2215 )
2216 and (el.job_id is null or
2217 el.job_id = asg.job_id)
2218 and (el.grade_id is null or
2219 el.grade_id = asg.grade_id)
2220 and (el.position_id is null or
2221 el.position_id = asg.position_id)
2222 and (el.organization_id is null or
2223 el.organization_id = asg.organization_id)
2224 and (el.location_id is null or
2225 el.location_id = asg.location_id)
2226 and (el.pay_basis_id is null or
2227 el.pay_basis_id = asg.pay_basis_id)
2228 and (el.employment_category is null or
2229 el.employment_category = asg.employment_category)
2230 and (el.people_group_id is null or exists
2231 (select null
2232 from pay_assignment_link_usages_f alu
2233 where alu.assignment_id = asg.assignment_id
2234 and alu.element_link_id = el.element_link_id
2235 and c_eff_date between alu.effective_start_date
2236 and alu.effective_end_date)
2237 )
2238 ;
2239
2240 begin
2241 --
2242 g_debug := hr_utility.debug_enabled;
2243 if g_debug then
2244 --
2245 hr_utility.set_location('Entering:' ||l_proc,5);
2246 hr_utility.set_location('p_assignment_id:' ||p_assignment_id,44333);
2247 hr_utility.set_location('p_element_type_id:' ||p_element_type_id,44333);
2248 hr_utility.set_location('p_business_group_id:' ||p_business_group_id,44333);
2249 hr_utility.set_location('p_input_value_id:' ||p_input_value_id,44333);
2250 hr_utility.set_location('p_effective_date:' ||p_effective_date,44333);
2251 --
2252 end if;
2253 --
2254 if g_get_link_cached > 0 then
2255 --
2256 begin
2257 --
2258 l_hv := mod(nvl(p_assignment_id,1)
2259 +nvl(p_element_type_id,2)
2260 +nvl(p_effective_date-hr_api.g_sot,3)
2261 ,ben_hash_utility.get_hash_key);
2262 --
2263 if nvl(g_get_link_cache(l_hv).assignment_id,-1) = nvl(p_assignment_id,-1)
2264 and nvl(g_get_link_cache(l_hv).element_type_id,-1) = nvl(p_element_type_id,-1)
2265 and nvl(g_get_link_cache(l_hv).session_date,hr_api.g_sot) = nvl(p_effective_date,hr_api.g_sot)
2266 then
2267 --
2268 p_element_link_id := g_get_link_cache(l_hv).element_link_id;
2269 return;
2270 --
2271 else
2272 --
2273 l_hv := l_hv+g_hash_jump;
2274 --
2275 loop
2276 --
2277 if nvl(g_get_link_cache(l_hv).assignment_id,-1) = nvl(p_assignment_id,-1)
2278 and nvl(g_get_link_cache(l_hv).element_type_id,-1) = nvl(p_element_type_id,-1)
2279 and nvl(g_get_link_cache(l_hv).session_date,hr_api.g_sot) = nvl(p_effective_date,hr_api.g_sot)
2280 then
2281 --
2282 exit;
2283 --
2284 else
2285 --
2286 l_hv := l_hv+g_hash_jump;
2287 --
2288 end if;
2289 --
2290 end loop;
2291 --
2292 end if;
2293 --
2294 exception
2295 when no_data_found then
2296 --
2297 l_hv := null;
2298 --
2299 end;
2300 --
2301 end if;
2302 --
2303 -- Initialize the out parameter.
2304 --
2305 p_element_link_id := null;
2306 --
2307 open c_getasgdets
2308 (c_asg_id => p_assignment_id
2309 ,c_eff_date => p_effective_date
2310 );
2311 fetch c_getasgdets into l_getasgdets;
2312 if c_getasgdets%notfound then
2313 --
2314 close c_getasgdets;
2315 --
2316 fnd_message.set_name('BEN', 'BEN_93289_ASG_ABR_NOT_FOUND');
2317 fnd_message.set_token('ACTY_BASE_RT_NAME',g_acty_base_rt_name);
2318 fnd_message.set_token('EFFECTIVE_DATE',to_char(p_effective_date));
2319 if g_debug then
2320 hr_utility.set_location('ASG: BEN_93289_ASG_ABR_NOT_FOUND',5); -- 2105656
2321 end if;
2322 fnd_message.raise_error;
2323 --
2324 end if;
2325 if g_debug then
2326 hr_utility.set_location('c_getasgdets is not null',999);
2327 end if;
2328 close c_getasgdets;
2329 --
2330 l_elk_count := 0;
2331 l_joincond := false;
2332 l_link_count := 0;
2333 --
2334 for elkrow in c_getelkdets
2335 (c_elt_id => p_element_type_id
2336 ,c_eff_date => p_effective_date
2337 )
2338 loop
2339 --
2340 l_link_count := c_getelkdets%rowcount; -- bug 2105656
2341 --
2342 if l_getasgdets.business_group_id = elkrow.business_group_id
2343 and ((elkrow.payroll_id is not null and elkrow.payroll_id = l_getasgdets.payroll_id)
2344 or (elkrow.link_to_all_payrolls_flag = 'Y' and l_getasgdets.payroll_id is not null)
2345 or (elkrow.payroll_id is null and elkrow.link_to_all_payrolls_flag = 'N')
2346 )
2347 and
2348 (elkrow.job_id is null
2349 or elkrow.job_id = l_getasgdets.job_id
2350 )
2351 and
2352 (elkrow.grade_id is null
2353 or elkrow.grade_id = l_getasgdets.grade_id
2354 )
2355 and
2356 (elkrow.position_id is null
2357 or elkrow.position_id = l_getasgdets.position_id
2358 )
2359 and
2360 (elkrow.organization_id is null
2361 or elkrow.organization_id = l_getasgdets.organization_id
2362 )
2363 and
2364 (elkrow.location_id is null
2365 or elkrow.location_id = l_getasgdets.location_id
2366 )
2367 and
2368 (elkrow.pay_basis_id is null
2369 or elkrow.pay_basis_id = l_getasgdets.pay_basis_id
2370 )
2371 and
2372 (elkrow.employment_category is null
2373 or elkrow.employment_category = l_getasgdets.employment_category
2374 )
2375 then
2376 --
2377 l_joincond := true;
2378 --
2379 else
2380 --
2381 l_joincond := false;
2382 --
2383 end if;
2384 --
2385 if (elkrow.people_group_id is null
2386 )
2387 and l_joincond
2388 then
2389 --
2390 l_joincond := true;
2391 --
2392 elsif l_joincond
2393 then
2394 --
2395 open c_chkalu
2396 (c_asg_id => p_assignment_id
2397 ,c_elk_id => elkrow.element_link_id
2398 ,c_eff_date => p_effective_date
2399 );
2400 fetch c_chkalu into l_dummy;
2401 if c_chkalu%found then
2402 --
2403 l_joincond := true;
2404 --
2405 else
2406 --
2407 l_joincond := false;
2408 --
2409 end if;
2410 close c_chkalu;
2411 --
2412 else
2413 --
2414 l_joincond := false;
2415 --
2416 end if;
2417 --
2418 if l_joincond then
2419 --
2420 p_element_link_id := elkrow.element_link_id;
2421 l_elk_count := l_elk_count+1;
2422 exit;
2423 --
2424 end if;
2425 --
2426 end loop;
2427 --
2428 if l_link_count = 0 then
2429 --
2430 fnd_message.set_name('BEN', 'BEN_92344_NO_ELEMENT_LINK');
2431 fnd_message.set_token('PROC',l_proc);
2432 fnd_message.set_token('ASSIGNMENT_ID',to_char(p_assignment_id));
2433 fnd_message.set_token('ELEMENT_TYPE_ID',to_char(p_element_type_id));
2434 fnd_message.set_token('EFFECTIVE_DATE',to_char(p_effective_date));
2435 if g_debug then
2436 hr_utility.set_location('ELK: BEN_92344_NO_ELEMENT_LINK',5);
2437 end if;
2438 --
2439 elsif l_elk_count = 0 then -- bug 2105656
2440 --
2441 fnd_message.set_name('BEN', 'BEN_93288_ASG_ELEM_LNK_INELIG');
2442 fnd_message.set_token('ASSIGNMENT_ID',to_char(p_assignment_id));
2443 fnd_message.set_token('ELEMENT_TYPE_ID',to_char(p_element_type_id));
2444 fnd_message.set_token('EFFECTIVE_DATE',to_char(p_effective_date));
2445 if g_debug then
2446 hr_utility.set_location('ELK: BEN_93288_ASG_ELEM_LNK_INELIG',6);
2447 end if;
2448 --
2449 elsif g_get_link_cached > 0 then
2450 --
2451 -- Only store the
2452 --
2453 l_hv := mod(nvl(p_assignment_id,1)
2454 +nvl(p_element_type_id,2)
2455 +nvl(p_effective_date-hr_api.g_sot,3)
2456 ,ben_hash_utility.get_hash_key
2457 );
2458 --
2459 while g_get_link_cache.exists(l_hv)
2460 loop
2461 --
2462 l_hv := l_hv+g_hash_jump;
2463 --
2464 end loop;
2465 --
2466 g_get_link_cache(l_hv).assignment_id := p_assignment_id;
2467 g_get_link_cache(l_hv).element_type_id := p_element_type_id;
2468 g_get_link_cache(l_hv).session_date := p_effective_date;
2469 g_get_link_cache(l_hv).element_link_id := p_element_link_id;
2470 --
2471 end if;
2472 --
2473 if g_debug then
2474 hr_utility.set_location('Leaving:' ||l_proc,5);
2475 end if;
2476 --
2477 end get_link;
2478 --
2479 -- ----------------------------------------------------------------------------
2480 -- |------------------------< chk_future_entries >----------------------------|
2481 -- ----------------------------------------------------------------------------
2482 procedure chk_future_entries
2483 (p_validate in boolean,
2484 p_person_id in number,
2485 p_assignment_id in number,
2486 p_enrt_rslt_id in number,
2487 p_element_type_id in number,
2488 p_multiple_entries_flag in varchar2,
2489 p_effective_date in date) is
2490
2491 cursor c_future_ee
2492 (p_element_type_id in number
2493 ,p_assignment_id in number
2494 ,p_effective_date in date
2495 ) is
2496 select distinct
2497 elt.element_name,
2498 ele.element_entry_id,
2499 ele.effective_start_date,
2500 ele.effective_end_date,
2501 ele.object_version_number,
2502 ele.creator_id,
2503 ele.creator_type
2504 from pay_element_entries_f ele,
2505 pay_element_links_f elk,
2506 pay_element_types_f elt
2507 where ele.effective_start_date = (select min(ele2.effective_start_date)
2508 from pay_element_entries_f ele2
2509 where ele2.element_entry_id
2510 = ele.element_entry_id)
2511 and ele.effective_start_date > p_effective_date
2512 and ele.assignment_id = p_assignment_id
2513 and nvl(ele.creator_id,-1) <> p_enrt_rslt_id
2514 and ele.entry_type = 'E'
2515 and ele.element_link_id = elk.element_link_id
2516 and ele.effective_start_date between elk.effective_start_date
2517 and elk.effective_end_date
2518 and elk.element_type_id = p_element_type_id
2519 and elt.element_type_id = elk.element_type_id
2520 and elk.effective_start_date between elt.effective_start_date
2521 and elt.effective_end_date
2522 order by ele.effective_start_date desc;
2523 l_future_ee_rec c_future_ee%rowtype;
2524
2525 cursor c_chk_rt(p_person_id number,
2526 p_element_entry_id number) is
2527 select abr.name rt_name,
2528 prv.rt_strt_dt
2529 from ben_prtt_enrt_rslt_f pen,
2530 ben_prtt_rt_val prv,
2531 ben_acty_base_rt_f abr
2532 where pen.person_id = p_person_id
2533 and pen.prtt_enrt_rslt_id = prv.prtt_enrt_rslt_id
2534 and prv.prtt_rt_val_stat_cd is null
2535 and pen.prtt_enrt_rslt_stat_cd is null
2536 and abr.acty_base_rt_id = prv.acty_base_rt_id
2537 and prv.rt_strt_dt between abr.effective_start_date
2538 and abr.effective_end_date
2539 and prv.element_entry_value_id in
2540 (select elv.element_entry_value_id
2541 from pay_element_entry_values_f elv
2542 where elv.element_entry_id = p_element_entry_id);
2543 l_rt_rec c_chk_rt%rowtype;
2544
2545 l_effective_start_date date;
2546 l_effective_end_date date;
2547 l_delete_warning boolean;
2548 l_proc varchar2(72) := g_package||'chk_future_entries';
2549
2550 begin
2551
2552 if g_debug then
2553 hr_utility.set_location('Entering:' ||l_proc,5);
2554 end if;
2555 --
2556 open c_future_ee(p_element_type_id,
2557 p_assignment_id,
2558 p_effective_date);
2559 loop
2560 fetch c_future_ee into l_future_ee_rec;
2561 if c_future_ee%notfound then
2562 exit;
2563 end if;
2564
2565 if g_debug then
2566 hr_utility.set_location('future ee:'||l_future_ee_rec.element_entry_id,6);
2567 hr_utility.set_location('creator type:'||l_future_ee_rec.creator_type,6);
2568 hr_utility.set_location('creator id:'||l_future_ee_rec.creator_id,6);
2569 end if;
2570
2571 if l_future_ee_rec.creator_type ='F' and
2572 l_future_ee_rec.creator_id is not null then
2573 --
2574 -- BEN entry in the future. Something is not right.
2575 -- If there is a valid prtt rt, throw error. otherwise zap the
2576 -- entry
2577 --
2578 open c_chk_rt(p_person_id,
2579 l_future_ee_rec.element_entry_id);
2580 fetch c_chk_rt into l_rt_rec;
2581 if c_chk_rt%found then
2582 --
2583 close c_future_ee;
2584 close c_chk_rt;
2585 fnd_message.set_name('BEN','BEN_93448_FUTURE_BEN_ENTRY');
2586 fnd_message.set_token('P_RATE',l_rt_rec.rt_name);
2587 fnd_message.set_token('P_DATE',to_char(l_future_ee_rec.effective_start_date));
2588 fnd_message.raise_error;
2589 --
2590 end if;
2591 close c_chk_rt;
2592 py_element_entry_api.delete_element_entry
2593 (p_validate =>p_validate
2594 ,p_datetrack_delete_mode =>hr_api.g_zap
2595 ,p_effective_date =>l_future_ee_rec.effective_end_date
2596 ,p_element_entry_id =>l_future_ee_rec.element_entry_id
2597 ,p_object_version_number =>l_future_ee_rec.object_version_number
2598 ,p_effective_start_date =>l_effective_start_date
2599 ,p_effective_end_date =>l_effective_end_date
2600 ,p_delete_warning =>l_delete_warning);
2601
2602 else
2603 --
2604 -- User created entry. Throw error
2605 --
2606 if p_multiple_entries_flag ='N' then
2607 close c_future_ee;
2608 fnd_message.set_name('BEN','BEN_93447_FUTURE_USER_ENTRY');
2609 fnd_message.set_token('P_DATE',to_char(l_future_ee_rec.effective_start_date));
2610 fnd_message.set_token('P_ELEMENT',l_future_ee_rec.element_name);
2611 fnd_message.raise_error;
2612 end if;
2613 end if;
2614
2615 end loop;
2616 close c_future_ee;
2617
2618 if g_debug then
2619 hr_utility.set_location('Leaving:' ||l_proc,10);
2620 end if;
2621 --
2622 end chk_future_entries;
2623 --
2624 -- --------------------------------------------------------------------------
2625 -- |------------------< create_enrollment_element >-------------------------|
2626 -- --------------------------------------------------------------------------
2627 -- This procedure is used for both creating and updating element entries
2628 --
2629 procedure create_enrollment_element
2630 (p_validate in boolean default false
2631 ,p_calculate_only_mode in boolean default false
2632 ,p_person_id in number
2633 ,p_acty_base_rt_id in number
2634 ,p_acty_ref_perd in varchar2
2635 ,p_rt_start_date in date
2636 ,p_rt in number
2637 ,p_business_group_id in number
2638 ,p_effective_date in date
2639 ,p_cmncd_rt in number default null
2640 ,p_ann_rt in number default null
2641 ,p_prtt_rt_val_id in number default null
2642 ,p_enrt_rslt_id in number default null
2643 ,p_input_value_id in number default null
2644 ,p_element_type_id in number default null
2645 ,p_pl_id in number default null
2646 ,p_prv_object_version_number in out nocopy number
2647 ,p_element_entry_value_id out nocopy number
2648 ,p_eev_screen_entry_value out nocopy number
2649 )
2650 is
2651 --
2652 cursor get_abr_info
2653 (c_acty_base_rt_id in number
2654 ,c_effective_date in date
2655 )
2656 is
2657 select abr.prtl_mo_det_mthd_cd,
2658 abr.prtl_mo_det_mthd_rl,
2659 abr.wsh_rl_dy_mo_num,
2660 abr.prtl_mo_eff_dt_det_cd,
2661 abr.prtl_mo_eff_dt_det_rl,
2662 abr.rndg_cd,
2663 abr.rndg_rl,
2664 abr.ele_rqd_flag,
2665 abr.one_ann_pymt_cd,
2666 abr.entr_ann_val_flag,
2667 abr.use_calc_acty_bs_rt_flag,
2668 abr.acty_typ_cd,
2669 abr.input_va_calc_rl,
2670 abr.rt_typ_cd,
2671 abr.element_type_id,
2672 abr.input_value_id,
2673 abr.ele_entry_val_cd,
2674 abr.rt_mlt_cd,
2675 abr.parnt_chld_cd,
2676 abr.rcrrg_cd,
2677 abr.name
2678 -- bug 6441505
2679 ,abr.element_det_rl
2680 from ben_acty_base_rt_f abr
2681 where abr.acty_base_rt_id=c_acty_base_rt_id
2682 and c_effective_date between abr.effective_start_date
2683 and abr.effective_end_date;
2684 --
2685 l_get_abr_info get_abr_info%rowtype;
2686 --
2687 cursor get_element_entry(p_element_link_id in number
2688 ,p_assignment_id in number
2689 ,p_enrt_rslt_id in number
2690 ,p_input_value_id in number
2691 ,p_element_entry_id in number
2692 ,p_effective_date in date) is
2693 select ele.element_entry_id,
2694 ele.effective_start_date,
2695 ele.effective_end_date,
2696 ele.object_version_number,
2697 elv.element_entry_value_id
2698 from pay_element_entries_f ele,
2699 pay_element_entry_values_f elv
2700 where ele.element_link_id = p_element_link_id
2701 and ele.assignment_id = p_assignment_id
2702 and (p_enrt_rslt_id is null or
2703 p_enrt_rslt_id = ele.creator_id)
2704 and (p_element_entry_id is null or
2705 p_element_entry_id = ele.element_entry_id)
2706 and p_effective_date between ele.effective_start_date
2707 and ele.effective_end_date
2708 and ele.entry_type = 'E'
2709 and elv.element_entry_id = ele.element_entry_id
2710 and elv.effective_start_date between ele.effective_start_date
2711 and ele.effective_end_date
2712 and elv.input_value_id = p_input_value_id;
2713 --
2714 cursor get_element_entry_v(p_element_entry_value_id in number
2715 ,p_effective_date in date) is
2716 select ele.element_entry_id,
2717 ele.effective_start_date,
2718 ele.effective_end_date,
2719 ele.object_version_number,
2720 elv.element_entry_value_id
2721 from pay_element_entries_f ele,
2722 pay_element_entry_values_f elv
2723 where p_effective_date between ele.effective_start_date
2724 and ele.effective_end_date
2725 and elv.element_entry_id = ele.element_entry_id
2726 and elv.element_entry_value_id = p_element_entry_value_id
2727 and elv.effective_start_date between ele.effective_start_date
2728 and ele.effective_end_date;
2729 --
2730 -- 5229941: Fetch MAX end_date of the Element Entry.
2731 cursor get_max_ee_end_dt(p_element_entry_id in number) is
2732 select max(ele.effective_end_date) max_ee_end_date
2733 from pay_element_entries_f ele
2734 where ele.element_entry_id = p_element_entry_id;
2735 --
2736 --
2737 cursor get_current_value
2738 (p_element_entry_id in number
2739 ,p_input_value_id in number
2740 ,p_effective_date in date
2741 )
2742 is
2743 select eev.screen_entry_value,
2744 ee.object_version_number,
2745 ee.creator_id,
2746 ee.creator_type,
2747 ee.effective_start_date,
2748 ee.effective_end_date
2749 from pay_element_entry_values_f eev,
2750 pay_element_entries_f ee
2751 where eev.element_entry_id = p_element_entry_id
2752 and eev.input_value_id = p_input_value_id
2753 and p_effective_date between eev.effective_start_date
2754 and eev.effective_end_date
2755 and ee.element_entry_id=eev.element_entry_id
2756 and p_effective_date between ee.effective_start_date
2757 and ee.effective_end_date;
2758 --
2759 cursor c_ele_info(p_element_type_id in number,
2760 p_effective_date in date) is
2761 select pet.element_name,
2762 pet.multiple_entries_allowed_flag,
2763 pet.processing_type
2764 from pay_element_types_f pet
2765 where pet.element_type_id = p_element_type_id
2766 and p_effective_date between pet.effective_start_date
2767 and pet.effective_end_date;
2768 --
2769 cursor c_dup_prv(p_element_entry_value_id number,
2770 p_rt_strt_dt date) is
2771 select abr.name
2772 from ben_prtt_enrt_rslt_f pen,
2773 ben_acty_base_rt_f abr,
2774 ben_prtt_rt_val prv
2775 where prv.acty_base_rt_id <> p_acty_base_rt_id
2776 and prv.element_entry_value_id = p_element_entry_value_id
2777 and prv.prtt_rt_val_stat_cd is null
2778 and abr.acty_base_rt_id = prv.acty_base_rt_id
2779 and prv.rt_strt_dt between abr.effective_start_date
2780 and abr.effective_end_date
2781 --bug# 3307450 added rt end dt condition to take care of element fix script
2782 and prv.rt_end_dt > p_rt_strt_dt
2783 and pen.prtt_enrt_rslt_id = prv.prtt_enrt_rslt_id
2784 and pen.prtt_enrt_rslt_stat_cd is null
2785 and pen.person_id = p_person_id;
2786 --
2787 cursor c_dup_rslt(p_element_entry_id number,
2788 p_rt_strt_dt date) is
2789 select abr1.name
2790 from ben_prtt_enrt_rslt_f pen1,
2791 ben_prtt_enrt_rslt_f pen2,
2792 ben_acty_base_rt_f abr1,
2793 ben_prtt_rt_val prv1
2794 where pen2.prtt_enrt_rslt_id = p_enrt_rslt_id
2795 and pen1.prtt_enrt_rslt_id <> pen2.prtt_enrt_rslt_id
2796 and pen1.person_id = pen2.person_id
2797 and pen1.prtt_enrt_rslt_stat_cd is null
2798 and (nvl(pen1.pgm_id,-1) <> nvl(pen2.pgm_id,-1) or
2799 nvl(pen1.pl_id,-1) <> nvl(pen2.pl_id,-1) or
2800 nvl(pen1.oipl_id,-1) <> nvl(pen2.oipl_id,-1))
2801 and pen1.prtt_enrt_rslt_id = prv1.prtt_enrt_rslt_id
2802 and abr1.acty_base_rt_id = prv1.acty_base_rt_id
2803 and prv1.rt_strt_dt between abr1.effective_start_date
2804 and abr1.effective_end_date
2805 and p_rt_strt_dt between prv1.rt_strt_dt
2806 and prv1.rt_end_dt
2807 and prv1.prtt_rt_val_stat_cd is null
2808 and prv1.element_entry_value_id in
2809 (select pev.element_entry_value_id
2810 from pay_element_entry_values_f pev
2811 where pev.element_entry_id = p_element_entry_id);
2812
2813 cursor c_future_ee
2814 (p_element_entry_id in number
2815 ,p_element_type_id in number
2816 ,p_input_value_id in number
2817 ,p_assignment_id in number
2818 ,p_effective_date in date
2819 ) is
2820 select ele.element_entry_id,
2821 ele.element_link_id,
2822 ele.effective_start_date,
2823 ele.effective_end_date,
2824 ele.object_version_number,
2825 elv.screen_entry_value
2826 from pay_element_entries_f ele,
2827 pay_element_entry_values_f elv,
2828 pay_element_links_f elk
2829 where ele.creator_id = p_enrt_rslt_id
2830 and ele.creator_type = 'F'
2831 and ele.entry_type = 'E'
2832 and ele.effective_start_date > p_effective_date
2833 and ele.element_entry_id <> p_element_entry_id
2834 and elv.element_entry_id = ele.element_entry_id
2835 and elv.input_value_id = p_input_value_id
2836 and elv.effective_start_date between ele.effective_start_date
2837 and ele.effective_end_date
2838 and ele.assignment_id = p_assignment_id
2839 and ele.element_link_id = elk.element_link_id
2840 and ele.effective_start_date between elk.effective_start_date
2841 and elk.effective_end_date
2842 and elk.element_type_id = p_element_type_id
2843 order by ele.effective_start_date asc;
2844 l_future_ee_rec c_future_ee%rowtype;
2845 --
2846 -- Bug 2386380 fix - added default value to decode function
2847 --
2848 cursor c_next_pay_periods
2849 (p_start_date in date
2850 ,p_end_date in date
2851 ,p_prtl_mo_eff_dt_det_cd in varchar2
2852 ,p_payroll_id in number
2853 )
2854 is
2855 select start_date,end_date
2856 from per_time_periods
2857 where payroll_id = p_payroll_id
2858 and decode(p_prtl_mo_eff_dt_det_cd,'DTPD',regular_payment_date,
2859 'PPED',end_date,
2860 'DTERND',regular_payment_date,
2861 end_date)
2862 <= p_end_date
2863 and decode(p_prtl_mo_eff_dt_det_cd,'DTPD',regular_payment_date,
2864 'PPED',end_date,
2865 'DTERND',regular_payment_date,
2866 end_date)
2867 >= p_start_date
2868 order by start_date desc;
2869 --
2870 -- Bug 2386380 fix - Handling if p_prtl_mo_eff_dt_det_cd is DTERND
2871 --
2872 cursor c_pps_next_month
2873 (p_end_date in date
2874 ,p_prtl_mo_eff_dt_det_cd in varchar2
2875 ,p_payroll_id in number
2876 )
2877 is
2878 select start_date,end_date
2879 from per_time_periods
2880 where payroll_id = p_payroll_id
2881 and decode(p_prtl_mo_eff_dt_det_cd,'DTPD',regular_payment_date,
2882 'DTERND',regular_payment_date,
2883 'PPED',end_date,
2884 end_date)
2885 > p_end_date
2886 order by start_date;
2887 --
2888 cursor c_last_pp_of_cal_year
2889 (p_payroll_id in number
2890 ,p_rt_start_date in date
2891 )
2892 is
2893 select ptp.start_date,ptp.end_date
2894 from per_time_periods ptp
2895 where ptp.payroll_id = p_payroll_id
2896 and ptp.end_date<=add_months(trunc(p_rt_start_date,'YYYY'),
2897 12)-1
2898 order by ptp.end_date desc;
2899 --
2900 cursor c_first_pp_after_start
2901 (p_payroll_id in number
2902 ,p_rt_start_date in date
2903 )
2904 is
2905 select ptp.start_date,
2906 ptp.end_date
2907 from per_time_periods ptp
2908 where ptp.payroll_id = p_payroll_id
2909 and ptp.start_date > p_rt_start_date
2910 order by ptp.end_date asc;
2911 --
2912 cursor c_chk_abs_ler (c_per_in_ler_id number,
2913 c_effective_date date) is
2914 select pil.per_in_ler_id,
2915 pil.lf_evt_ocrd_dt,
2916 pil.trgr_table_pk_id,
2917 ler.ler_id,
2918 ler.typ_cd
2919 from ben_per_in_ler pil,
2920 ben_ler_f ler
2921 where pil.per_in_ler_id = c_per_in_ler_id
2922 and ler.ler_id = pil.ler_id
2923 and c_effective_date between
2924 ler.effective_start_date and ler.effective_end_date;
2925 -- Parent rate information
2926 cursor c_abr2
2927 (c_effective_date in date,
2928 c_acty_base_rt_id in number
2929 )
2930 is
2931 select abr2.rt_mlt_cd,
2932 abr2.entr_ann_val_flag
2933 from ben_acty_base_rt_f abr,
2934 ben_acty_base_rt_f abr2
2935 where abr.acty_base_rt_id = c_acty_base_rt_id
2936 and abr2.acty_base_rt_id = abr.parnt_acty_base_rt_id
2937 and abr2.parnt_chld_cd = 'PARNT'
2938 and c_effective_date
2939 between abr.effective_start_date
2940 and abr.effective_end_date
2941 and c_effective_date
2942 between abr2.effective_start_date
2943 and abr2.effective_end_date;
2944 --
2945 cursor c_current_pp_end
2946 (p_payroll_id in number
2947 ,p_rt_start_date in date
2948 )
2949 is
2950 select ptp.end_date
2951 from per_time_periods ptp
2952 where ptp.payroll_id = p_payroll_id
2953 and p_rt_start_date between
2954 ptp.start_date and ptp.end_date ;
2955 --
2956 cursor c_current_fsa_pp_end
2957 (p_payroll_id in number
2958 ,p_rt_start_date in date
2959 )
2960 is
2961 select nvl(ptp.regular_payment_date,ptp.end_date) end_date
2962 from per_time_periods ptp
2963 where ptp.payroll_id = p_payroll_id
2964 and p_rt_start_date between
2965 ptp.start_date and ptp.end_date ;
2966
2967 --
2968 l_current_pp_end_date date ;
2969 --
2970 l_prnt_abr c_abr2%rowtype ;
2971 --
2972 -- Bug 6834340
2973 -- to pass correct ler_id to the prorate_amount when subsequent life event
2974 -- offers no electability to the existing enrollments but rates get updated.
2975 --
2976
2977 cursor c_ler_with_current_prv
2978 (p_prtt_rt_val_id in number
2979 , p_rt_start_date in date
2980 )
2981 is
2982 select ler.name name, ler.ler_id ler_id
2983 from ben_prtt_rt_val prv,
2984 ben_per_in_ler pil,
2985 ben_ler_f ler
2986 where prv.per_in_ler_id = pil.per_in_ler_id
2987 and pil.ler_id = ler.ler_id
2988 and prv.prtt_rt_val_id = p_prtt_rt_val_id
2989 and prv.rt_strt_dt = p_rt_start_date;
2990
2991 l_ler_with_current_prv c_ler_with_current_prv%rowtype;
2992
2993 -- Bug 6834340
2994 --
2995 ----Bug 7196470
2996 cursor c_enrt_rt
2997 is
2998 SELECT ecr.enrt_rt_id
2999 FROM ben_enrt_rt ecr,
3000 ben_prtt_rt_val prv,
3001 ben_acty_base_rt_f abr
3002 WHERE prv.prtt_rt_val_id = ecr.prtt_rt_val_id
3003 AND prv.prtt_rt_val_stat_cd is NULL
3004 AND abr.acty_base_rt_id = prv.acty_base_rt_id
3005 AND ecr.acty_base_rt_id = prv.acty_base_rt_id
3006 AND prv.rt_strt_dt between abr.effective_start_date
3007 AND abr.effective_end_date
3008 AND prv.rt_end_dt > prv.rt_strt_dt
3009 AND ecr.business_group_id = p_business_group_id
3010 AND ecr.prtt_rt_val_id = p_prtt_rt_val_id
3011 AND ecr.acty_base_rt_id = p_acty_base_rt_id;
3012 l_enrt_rt_id ben_enrt_rt.enrt_rt_id%type;
3013
3014 l_proc varchar2(72) := g_package||'create_enrollment_element';
3015 l_start_date date;
3016 l_end_date date;
3017 l_amt NUMBER;
3018 l_curr_val NUMBER;
3019 l_curr_val_char VARCHAR2(60);
3020 l_new_val NUMBER;
3021 l_new_date DATE;
3022 l_temp_val NUMBER;
3023 l_assignment_id NUMBER;
3024 l_payroll_id NUMBER;
3025 l_element_entry_id NUMBER;
3026 l_entry_value_id NUMBER;
3027 l_element_link_id NUMBER;
3028 l_old_element_link_id number;
3029 l_ext_chg_evt_log_id NUMBER;
3030 l_object_version_number NUMBER;
3031 l_ext_object_version_number NUMBER;
3032 l_prtn_flag VARCHAR2(1):='N';
3033 l_effective_start_date DATE;
3034 l_ee_effective_start_date DATE;
3035 l_ee_effective_end_date DATE;
3036 l_upd_mode VARCHAR2(30);
3037 l_delete_warning BOOLEAN;
3038 l_create_warning BOOLEAN;
3039 l_update_warning BOOLEAN;
3040 l_per_month_amt number;
3041 l_per_pay_amt number;
3042 l_prorated_monthly_amt number;
3043 l_update_ee boolean;
3044 l_zero_pp_date date;
3045 l_special_pp_date date;
3046 l_normal_pp_date date;
3047 l_normal_pp_end_date date;
3048 l_special_amt number;
3049 l_outputs ff_exec.outputs_t;
3050 l_organization_id number;
3051 l_remainder number;
3052 l_number_in_month number;
3053 l_old_normal_pp_date date;
3054 l_jurisdiction_code varchar2(30);
3055 l_effective_end_date date;
3056 l_last_pp_strt_dt date;
3057 l_last_pp_end_dt date;
3058 l_range_start date;
3059 l_tmp_bool boolean;
3060 l_pay_periods number;
3061 l_first_pp_adjustment number;
3062 l_rt_strt_dt date := p_rt_start_date;
3063 l_real_num_periods number;
3064 l_mlt_cd varchar2(30);
3065 l_creee_calc_vals g_calculated_values;
3066 l_v2dummy varchar2(30);
3067 l_perd_cd varchar2(30) := 'PP';
3068 l_annual_target boolean ;
3069 l_uom varchar2(30);
3070 l_element_name varchar2(80);
3071 l_processing_type varchar2(30);
3072 l_multiple_entries_flag varchar2(1);
3073 l_recurring_entry boolean := false;
3074 l_dummy_varchar2 varchar2(30) := hr_api.g_varchar2;
3075 l_creator_id number;
3076 l_creator_type varchar2(30);
3077 l_dummy_date date;
3078 l_new_element_link_id number;
3079 l_effective_date date;
3080 l_element_term_rule_date date;
3081 l_element_link_end_date date;
3082 l_out_date_not_required date;
3083 l_encoded_message varchar2(2000);
3084 l_app_short_name varchar2(2000);
3085 l_message_name varchar2(2000);
3086 l_per_in_ler_id number;
3087 l_ler_id number;
3088 l_absence_attendance_id number;
3089 l_subpriority number;
3090 l_dummy varchar2(30);
3091 l_abs_ler boolean := false;
3092 l_override_user_ent_chk varchar2(30) := 'N';
3093 l_string varchar2(4000);
3094 l_err_code varchar2(10);
3095 l_err_mesg varchar2(2000);
3096 l_input_value_id1 number;
3097 l_sarec_dont_create boolean := false ;
3098 l_calculate_only_mode boolean := p_calculate_only_mode;
3099 l_prnt_ann_rt varchar2(1):= 'N';
3100 l_abr_name varchar2(240);
3101 l_inpval_tab inpval_tab_typ;
3102 l_element_type_id number;
3103 l_input_value_id number;
3104 l_pl_id number;
3105 l_lf_evt_ocrd_dt date;
3106 l_ler_typ_cd varchar2(30);
3107 l_old_assignment_id number;
3108 l_non_recurring_ee_id number;
3109 l_max_ee_end_dt DATE;
3110 l_ele_entry_val_cd VARCHAR2(30); -- Bug 5575402
3111 l_dummy_number number;
3112 l_old_asgn_id number; -- for bug 6450363
3113 --
3114 -- Bug 2675486 to skip computation for SAREC when there is
3115 -- no change in the amount and within the same plan year
3116 --
3117 function keep_same_element(p_person_id number,
3118 p_assignment_id number,
3119 p_prtt_enrt_rslt_id number,
3120 p_prtt_rt_val_id number,
3121 p_acty_base_rt_id number,
3122 p_ann_rt_val number,
3123 p_cmcd_rt_val number,
3124 p_rt_val number,
3125 p_rt_start_date date,
3126 p_mlt_cd varchar2,
3127 p_element_type_id number, -- 5401779
3128 p_input_value_id number, -- 5401779
3129 p_ele_entry_val_cd varchar2) -- Bug 5575402
3130 /*p_input_va_calc_rl number, --6716202
3131 p_organization_id number default null, -- 6716202
3132 p_payroll_id number default null) -- 6716202 */
3133 return boolean is
3134
3135 l_return boolean := false ;
3136 l_yp_start_date date;
3137 l_max_strt_dt date;
3138 l_ee_id number;
3139 l_old_assignment_id number;
3140 l_fsa_ee_effective_end_date date;
3141 l_fsa_element_entry_id number;
3142 l_fsa_ovn number;
3143 l_effective_end_date date;
3144 -- Bug 6716202
3145 /* l_ext_inpval_tab ben_element_entry.ext_inpval_tab_typ;
3146 l_inpval_tab ben_element_entry.inpval_tab_typ;
3147 l_jurisdiction_code varchar2(30);
3148 l_subpriority number;*/
3149 -- Bug 6716202
3150 cursor c_pen is
3151 select pgm_id,pl_id,oipl_id--,pl_typ_id,ler_id -- 6716202
3152 from ben_prtt_enrt_rslt_f pen
3153 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
3154 and pen.prtt_enrt_rslt_stat_cd is null
3155 and rownum = 1 ;
3156 l_pen c_pen%rowtype;
3157 --
3158 cursor c_pl_popl_yr_period_current(cv_pl_id number,
3159 cv_effective_date date ) IS
3160 select distinct yp.start_date
3161 from ben_popl_yr_perd pyp, ben_yr_perd yp
3162 where pyp.pl_id = cv_pl_id
3163 and pyp.yr_perd_id = yp.yr_perd_id
3164 and pyp.business_group_id = p_business_group_id
3165 and cv_effective_date BETWEEN yp.start_date AND yp.end_date
3166 and yp.business_group_id = p_business_group_id ;
3167 --
3168 cursor c_max_prv is
3169 select
3170 max(prv.rt_strt_dt) max_strt_dt
3171 from ben_prtt_enrt_rslt_f pen,
3172 ben_prtt_rt_val prv
3173 where pen.person_id = p_person_id
3174 and pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
3175 and pen.prtt_enrt_rslt_stat_cd is null
3176 and pen.prtt_enrt_rslt_id = prv.prtt_enrt_rslt_id
3177 and prv.acty_base_rt_id = p_acty_base_rt_id
3178 and prv.prtt_rt_val_id <> p_prtt_rt_val_id
3179 and (p_mlt_cd <> 'SAREC' OR (p_mlt_cd = 'SAREC' and prv.rt_strt_dt >= l_yp_start_date))
3180 and prv.rt_end_dt < p_rt_start_date
3181 and prv.prtt_rt_val_stat_cd is null ;
3182 --
3183 --sshetty: added this cursor to check if there are any
3184 -- mutliple rates with same element type
3185 --Reason for doing this check again here is to skip
3186 --this package totally as end enrollment call would
3187 --have updated the element entry with new temp (0)value
3188 --Skipping this call will ensure the right value in the
3189 --EE input value
3190
3191 cursor c_dup_prv_chk (c_element_entry_id number,
3192 c_effective_date date) is
3193 select count(prv.prtt_enrt_rslt_id)
3194 from ben_prtt_rt_val prv
3195 where prv.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
3196 and prv.acty_base_rt_id <> p_acty_base_rt_id
3197 and prv.rt_end_dt > c_effective_date
3198 and prv.prtt_rt_val_stat_cd is null
3199 and prv.element_entry_value_id in
3200 (select pev.element_entry_value_id
3201 from pay_element_entry_values_f pev
3202 where pev.element_entry_id = c_element_entry_id);
3203
3204 cursor c_prv is
3205 select pev.element_entry_value_id
3206 from ben_prtt_enrt_rslt_f pen,
3207 ben_prtt_rt_val prv,
3208 pay_element_entry_values_f pev
3209 where pen.person_id = p_person_id
3210 and pen.prtt_enrt_rslt_stat_cd is null
3211 and pen.prtt_enrt_rslt_id = prv.prtt_enrt_rslt_id
3212 and pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
3213 and prv.mlt_cd = 'SAREC'
3214 and prv.acty_base_rt_id = p_acty_base_rt_id
3215 and prv.prtt_rt_val_id <> p_prtt_rt_val_id
3216 and prv.rt_strt_dt = l_max_strt_dt
3217 and prv.rt_end_dt < p_rt_start_date
3218 and prv.prtt_rt_val_stat_cd is null
3219 and prv.ann_rt_val = p_ann_rt_val
3220 and pev.element_entry_value_id = prv.element_entry_value_id
3221 and p_rt_start_date between pev.effective_start_date
3222 and pev.effective_end_date ;
3223 --
3224 --BUG 3878539
3225 -- non fsa type rates.
3226 --
3227 cursor c_non_fsa_prv is
3228 select pev.element_entry_value_id
3229 from ben_prtt_enrt_rslt_f pen,
3230 ben_prtt_rt_val prv,
3231 pay_element_entry_values_f pev
3232 where pen.person_id = p_person_id
3233 and pen.prtt_enrt_rslt_stat_cd is null
3234 and pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
3235 and pen.prtt_enrt_rslt_id = prv.prtt_enrt_rslt_id
3236 and prv.acty_base_rt_id = p_acty_base_rt_id
3237 and prv.prtt_rt_val_id <> p_prtt_rt_val_id
3238 and prv.rt_strt_dt = l_max_strt_dt
3239 and prv.rt_end_dt < p_rt_start_date
3240 and prv.prtt_rt_val_stat_cd is null
3241 and prv.ann_rt_val = p_ann_rt_val
3242 and prv.rt_val = p_rt_val
3243 and prv.cmcd_rt_val = p_cmcd_rt_val
3244 and pev.element_entry_value_id = prv.element_entry_value_id
3245 and p_rt_start_date between pev.effective_start_date
3246 and pev.effective_end_date ;
3247 --
3248 --bug#3364910
3249 --
3250 cursor c_old_asg is
3251 select pee.element_entry_id,
3252 pee.effective_end_date,
3253 pee.object_version_number,
3254 pee.assignment_id,
3255 pee.element_type_id,
3256 pev.input_value_id,
3257 abr.ele_entry_val_cd -- Bug 5575402
3258 from pay_element_entries_f pee,
3259 pay_element_entry_values_f pev,
3260 ben_acty_base_rt_f abr
3261 where pev.element_entry_value_id = l_ee_id
3262 and pee.element_entry_id = pev.element_entry_id
3263 and pev.effective_start_date between pee.effective_start_date
3264 and pee.effective_end_date
3265 and abr.acty_base_rt_id = p_acty_base_rt_id
3266 and pev.effective_start_date between abr.effective_start_date
3267 and abr.effective_end_date
3268 and abr.element_type_id = pee.element_type_id
3269 and abr.input_value_id = pev.input_value_id
3270 order by pee.effective_end_date desc;
3271
3272 cursor c_payroll_type_changed(
3273 cp_person_id number,
3274 cp_business_group_id number,
3275 cp_effective_date date,
3276 cp_orig_effective_date date
3277 ) is
3278 select pay.period_type
3279 from per_all_assignments_f asg,
3280 pay_payrolls_f pay,
3281 per_all_assignments_f asg2,
3282 pay_payrolls_f pay2
3283 where asg.person_id = cp_person_id
3284 and asg.assignment_type <> 'C'
3285 and asg.business_group_id = cp_business_group_id
3286 and asg.primary_flag = 'Y'
3287 and cp_effective_date between
3288 asg.effective_start_date and asg.effective_end_date
3289 and pay.payroll_id=asg.payroll_id
3290 and pay.business_group_id = asg.business_group_id
3291 and cp_effective_date between
3292 pay.effective_start_date and pay.effective_end_date
3293 and asg2.person_id = cp_person_id
3294 and asg2.assignment_type <> 'C'
3295 and asg2.business_group_id = cp_business_group_id
3296 and asg2.primary_flag = 'Y'
3297 and cp_orig_effective_date between
3298 asg2.effective_start_date and asg2.effective_end_date
3299 and pay2.payroll_id=asg2.payroll_id
3300 and pay2.business_group_id = asg2.business_group_id
3301 and cp_orig_effective_date between
3302 pay2.effective_start_date and pay2.effective_end_date
3303 and pay2.period_type<>pay.period_type
3304 and asg.assignment_type = asg2.assignment_type ;
3305 --
3306 l_period_type varchar2(300);
3307 l_old_element_type_id NUMBER; -- 5401779
3308 l_old_input_value_id NUMBER; -- 5401779
3309 l_old_ele_entry_val_cd varchar2(30); -- Bug 5575402
3310 l_dup_rslt_num number;
3311 --
3312
3313 -- Bug 6716202
3314 /*cursor c_element_entry_values(p_input_value_id number, p_element_entry_value_id number) is
3315 select screen_entry_value,element_entry_value_id
3316 from pay_element_entry_values_f pev
3317 where pev.input_value_id = p_input_value_id
3318 and pev.element_entry_value_id = p_element_entry_value_id
3319 and p_rt_start_date between pev.effective_start_date
3320 and pev.effective_end_date ;
3321 l_element_entry_values c_element_entry_values%ROWTYPE;
3322
3323 cursor c_get_input_value(p_prtt_rt_val_id number, p_rt_start_date date) is
3324 select rt_val
3325 from ben_prtt_rt_val prv
3326 where prv.prtt_rt_val_id = p_prtt_rt_val_id
3327 and p_rt_start_date between prv.rt_strt_dt
3328 and prv.rt_end_dt;
3329
3330 l_get_input_value NUMBER;*/
3331
3332 -- Bug 6716202
3333
3334 cursor c_element_entry_v(p_input_value_id number) is
3335 --
3336 select element_entry_id
3337 from pay_element_entry_values_f pev
3338 where pev.input_value_id = p_input_value_id
3339 and l_max_strt_dt between pev.effective_start_date
3340 and pev.effective_end_date ;
3341 --
3342 l_ext_inp_changed boolean;
3343 l_element_entry_id pay_element_entry_values_f.element_entry_id%TYPE;
3344 begin
3345 --
3346 if g_debug then
3347 hr_utility.set_location('IN SAREC p_rt_start_date'||p_rt_start_date,122);
3348 hr_utility.set_location(' p_ann_rt_val '||p_ann_rt_val,122);
3349 end if;
3350
3351 open c_pen ;
3352 fetch c_pen into l_pen;
3353 close c_pen;
3354 --
3355 open c_pl_popl_yr_period_current(l_pen.pl_id,p_rt_start_date);
3356 fetch c_pl_popl_yr_period_current into l_yp_start_date ;
3357 close c_pl_popl_yr_period_current ;
3358 --
3359 open c_max_prv ;
3360 fetch c_max_prv into l_max_strt_dt ;
3361 close c_max_prv ;
3362 --
3363 if g_debug then
3364 hr_utility.set_location('l_max_strt_dt '||l_max_strt_dt,122);
3365 end if;
3366 if p_mlt_cd = 'SAREC' then
3367 --
3368 open c_prv ;
3369 fetch c_prv into l_ee_id ;
3370 if c_prv%found then
3371 --
3372 --bug#3364910
3373 l_period_type:=null;
3374 open c_payroll_type_changed(
3375 cp_person_id =>p_person_id,
3376 cp_business_group_id =>p_business_group_id,
3377 cp_effective_date =>p_rt_start_date,
3378 cp_orig_effective_date =>l_max_strt_dt);
3379 fetch c_payroll_type_changed into l_period_type;
3380 close c_payroll_type_changed;
3381 -- no change in payroll then update
3382
3383 if l_ee_id is not null then
3384 open c_old_asg;
3385 fetch c_old_asg into
3386 l_fsa_element_entry_id,
3387 l_fsa_ee_effective_end_date,
3388 l_fsa_ovn,
3389 l_old_assignment_id,
3390 l_old_element_type_id,
3391 l_old_input_value_id,
3392 l_old_ele_entry_val_cd; -- Bug 5575402
3393 close c_old_asg;
3394
3395 end if;
3396
3397 if l_ee_id is not null
3398 and l_period_type is null and
3399 nvl(p_assignment_id,-1) = nvl(l_old_assignment_id,-1)
3400 -- 5401779 : Return False if element_type or input_value changes
3401 and NVL(p_element_type_id, -1) = nvl(l_old_element_type_id,-1)
3402 and NVL(p_input_value_id, -1) = nvl(l_old_input_value_id, -1)
3403 and NVL(p_ele_entry_val_cd,'PP') = nvl(l_old_ele_entry_val_cd, 'PP') -- Bug 5575402
3404 then
3405 -- Bug 6716202
3406
3407 -- We also need to check whether the input value has been changed or not,this was not supported before
3408 -- if input value has been changed in subsequent LE,the input value wont be updated from Std Rate which
3409 -- is not proper,so if input value has been changed then we should recompute
3410 /*open c_element_entry_values(p_input_value_id,l_ee_id);
3411 fetch c_element_entry_values into l_element_entry_values;
3412 close c_element_entry_values;
3413
3414 hr_utility.set_location('screen_entry_value '|| l_element_entry_values.screen_entry_value,34534);
3415
3416 open c_get_input_value(p_prtt_rt_val_id,p_rt_start_date);
3417 fetch c_get_input_value into l_get_input_value;
3418 close c_get_input_value;
3419 --
3420 hr_utility.set_location('l_get_input_value '|| l_get_input_value,34534);
3421
3422 if nvl(l_element_entry_values.screen_entry_value,-1) <> nvl(l_get_input_value,-1) then
3423 return false;
3424 end if;
3425 -- We should also need to check whether any extra input values have been changed or not,this was not supported before
3426 -- if input value has been changed in subsequent LE,the input value wont be updated from Rule which
3427 -- is not proper,so if extra input values have been changed then we should recompute
3428
3429 if p_input_va_calc_rl is not null then
3430
3431 ben_element_entry.get_extra_ele_inputs
3432 (p_effective_date => p_rt_start_date
3433 ,p_person_id => p_person_id
3434 ,p_business_group_id => p_business_group_id
3435 ,p_assignment_id => p_assignment_id
3436 ,p_element_link_id => null
3437 ,p_entry_type => 'E'
3438 ,p_input_value_id1 => null
3439 ,p_entry_value1 => null
3440 ,p_element_entry_id => null
3441 ,p_acty_base_rt_id => p_acty_base_rt_id
3442 ,p_input_va_calc_rl => p_input_va_calc_rl
3443 ,p_abs_ler => null
3444 ,p_organization_id => p_organization_id
3445 ,p_payroll_id => p_payroll_id
3446 ,p_pgm_id => l_pen.pgm_id
3447 ,p_pl_id => l_pen.pl_id
3448 ,p_pl_typ_id => l_pen.pl_typ_id
3449 ,p_opt_id => null
3450 ,p_ler_id => l_pen.ler_id
3451 ,p_dml_typ => 'C'
3452 ,p_jurisdiction_code => l_jurisdiction_code
3453 ,p_ext_inpval_tab => l_ext_inpval_tab
3454 ,p_subpriority => l_subpriority
3455 );
3456
3457 open c_element_entry_v (l_ext_inpval_tab(1).input_value_id);
3458 fetch c_element_entry_v into l_element_entry_id;
3459 close c_element_entry_v;
3460
3461 ben_element_entry.get_inpval_tab
3462 (p_element_entry_id => l_element_entry_id
3463 ,p_effective_date => l_max_strt_dt
3464 ,p_inpval_tab => l_inpval_tab);
3465
3466 l_ext_inp_changed := false;
3467
3468 for i in 1..l_ext_inpval_tab.count
3469 loop
3470 for j in 1..l_inpval_tab.count
3471 loop
3472 if (l_ext_inpval_tab(i).input_value_id =
3473 l_inpval_tab(j).input_value_id) and
3474 (nvl(l_ext_inpval_tab(i).return_value,'-1') <>
3475 nvl(l_inpval_tab(j).value,'-1')) then
3476 l_ext_inp_changed := true;
3477 exit;
3478 end if;
3479 end loop;
3480 if l_ext_inp_changed then
3481 exit;
3482 end if;
3483 end loop;
3484
3485 if l_ext_inp_changed then
3486 return not l_ext_inp_changed;
3487 end if;
3488 end if;*/
3489
3490 -- Bug 6716202
3491 open c_dup_prv_chk (l_fsa_element_entry_id,
3492 p_rt_start_date);
3493 fetch c_dup_prv_chk into l_dup_rslt_num;
3494 close c_dup_prv_chk;
3495
3496 if l_dup_rslt_num > 0 then
3497 return false;
3498 end if;
3499
3500 --
3501 p_prv_object_version_number := nvl(p_prv_object_version_number,
3502 l_prv_rec.object_version_number);
3503
3504 ben_prtt_rt_val_api.update_prtt_rt_val
3505 (p_validate => p_validate
3506 ,p_person_id => p_person_id
3507 ,p_prtt_rt_val_id => p_prtt_rt_val_id
3508 ,p_business_group_id => p_business_group_id
3509 ,p_element_entry_value_id => l_ee_id
3510 ,p_input_value_id => p_input_value_id
3511 ,p_object_version_number => p_prv_object_version_number
3512 ,p_effective_date => p_rt_start_date
3513 );
3514 --
3515 l_return := true ;
3516 --
3517 -- reopen the entry if already ended
3518 --
3519 if l_fsa_element_entry_id is not null and
3520 l_fsa_ee_effective_end_date <> hr_api.g_eot and
3521 l_fsa_ee_effective_end_date <> l_element_term_rule_date and
3522 l_fsa_ee_effective_end_date <> l_element_link_end_date then
3523
3524 begin
3525
3526 py_element_entry_api.delete_element_entry
3527 (p_validate =>p_validate
3528 ,p_datetrack_delete_mode =>'FUTURE_CHANGE'
3529 ,p_effective_date =>l_fsa_ee_effective_end_date
3530 ,p_element_entry_id =>l_fsa_element_entry_id
3531 ,p_object_version_number =>l_fsa_ovn
3532 ,p_effective_start_date =>l_effective_start_date
3533 ,p_effective_end_date =>l_effective_end_date
3534 ,p_delete_warning =>l_delete_warning);
3535
3536 exception
3537 when others then
3538 ben_on_line_lf_evt.get_ser_message(l_encoded_message,
3539 l_app_short_name,
3540 l_message_name);
3541 l_encoded_message := fnd_message.get;
3542 --
3543 if l_message_name like '%HR_6284_ELE_ENTRY_DT_ASG_DEL%' or
3544 l_message_name like '%HR_7187_DT_CANNOT_EXTEND_END%' then
3545 -- assignment is not eligible for link beyond this date.
3546 -- Further reopening is not possible.
3547 --
3548 null;
3549 else
3550 if l_app_short_name is not null then
3551 fnd_message.set_name(l_app_short_name,l_message_name);
3552 fnd_message.raise_error;
3553 else
3554 raise;
3555 end if;
3556 end if;
3557 end;
3558 end if;
3559 end if;
3560 --
3561 end if;
3562 close c_prv ;
3563 else -- NON SAREC case -- normal recurring elements
3564 hr_utility.set_location('Non SAREC else part before opening cursor ',545);
3565 open c_non_fsa_prv ;
3566 fetch c_non_fsa_prv into l_ee_id ;
3567 if c_non_fsa_prv%found then
3568 --
3569 --hr_utility.set_location('p_input_value_id '|| p_input_value_id,3453411);
3570 --bug#3364910
3571 l_period_type:=null;
3572 open c_payroll_type_changed(
3573 cp_person_id =>p_person_id,
3574 cp_business_group_id =>p_business_group_id,
3575 cp_effective_date =>p_rt_start_date,
3576 cp_orig_effective_date =>l_max_strt_dt);
3577 fetch c_payroll_type_changed into l_period_type;
3578 close c_payroll_type_changed;
3579 -- no change in payroll then update
3580
3581 if l_ee_id is not null then
3582 open c_old_asg;
3583 fetch c_old_asg into
3584 l_fsa_element_entry_id,
3585 l_fsa_ee_effective_end_date,
3586 l_fsa_ovn,
3587 l_old_assignment_id,
3588 l_old_element_type_id,
3589 l_old_input_value_id,
3590 l_old_ele_entry_val_cd; -- Bug 5575402
3591 close c_old_asg;
3592
3593 end if;
3594
3595 if l_ee_id is not null
3596 and l_period_type is null and
3597 nvl(p_assignment_id,-1) = nvl(l_old_assignment_id,-1)
3598 -- 5401779 : Return False if element_type or input_value changes
3599 and NVL(p_element_type_id, -1) = nvl(l_old_element_type_id,-1)
3600 and NVL(p_input_value_id, -1) = nvl(l_old_input_value_id, -1)
3601 and NVL(p_ele_entry_val_cd,'PP') = nvl(l_old_ele_entry_val_cd, 'PP') -- Bug 5575402
3602 then
3603
3604 -- Bug 6716202
3605 --
3606 -- We also need to check whether the input value has been changed or not,this was not supported before
3607 -- if input value has been changed in subsequent LE,the input value wont be updated from Std Rate which
3608 -- is not proper,so if input value has been changed then we should recompute
3609 /* open c_element_entry_values(p_input_value_id,l_ee_id);
3610 fetch c_element_entry_values into l_element_entry_values;
3611 close c_element_entry_values;
3612
3613 hr_utility.set_location('screen_entry_value '|| l_element_entry_values.screen_entry_value,34534);
3614
3615 open c_get_input_value(p_prtt_rt_val_id,p_rt_start_date);
3616 fetch c_get_input_value into l_get_input_value;
3617 close c_get_input_value;
3618
3619 hr_utility.set_location('l_get_input_value '|| l_get_input_value,34534);
3620
3621 if nvl(l_element_entry_values.screen_entry_value,-1) <> nvl(l_get_input_value,-1) then
3622 return false;
3623 end if;
3624 -- We should also need to check whether any extra input values have been changed or not,this was not supported before
3625 -- if input value has been changed in subsequent LE,the input value wont be updated from Rule which
3626 -- is not proper,so if extra input values have been changed then we should recompute
3627
3628 if p_input_va_calc_rl is not null then
3629
3630 ben_element_entry.get_extra_ele_inputs
3631 (p_effective_date => p_rt_start_date
3632 ,p_person_id => p_person_id
3633 ,p_business_group_id => p_business_group_id
3634 ,p_assignment_id => p_assignment_id
3635 ,p_element_link_id => null
3636 ,p_entry_type => 'E'
3637 ,p_input_value_id1 => null
3638 ,p_entry_value1 => null
3639 ,p_element_entry_id => null
3640 ,p_acty_base_rt_id => p_acty_base_rt_id
3641 ,p_input_va_calc_rl => p_input_va_calc_rl
3642 ,p_abs_ler => null
3643 ,p_organization_id => p_organization_id
3644 ,p_payroll_id => p_payroll_id
3645 ,p_pgm_id => l_pen.pgm_id
3646 ,p_pl_id => l_pen.pl_id
3647 ,p_pl_typ_id => l_pen.pl_typ_id
3648 ,p_opt_id => null
3649 ,p_ler_id => l_pen.ler_id
3650 ,p_dml_typ => 'C'
3651 ,p_jurisdiction_code => l_jurisdiction_code
3652 ,p_ext_inpval_tab => l_ext_inpval_tab
3653 ,p_subpriority => l_subpriority
3654 );
3655
3656 open c_element_entry_v (l_ext_inpval_tab(1).input_value_id);
3657 fetch c_element_entry_v into l_element_entry_id;
3658 close c_element_entry_v;
3659
3660 ben_element_entry.get_inpval_tab
3661 (p_element_entry_id => l_element_entry_id
3662 ,p_effective_date => l_max_strt_dt
3663 ,p_inpval_tab => l_inpval_tab);
3664
3665 l_ext_inp_changed := false;
3666
3667 for i in 1..l_ext_inpval_tab.count
3668 loop
3669 for j in 1..l_inpval_tab.count
3670 loop
3671
3672 if (l_ext_inpval_tab(i).input_value_id =
3673 l_inpval_tab(j).input_value_id) and
3674 (nvl(l_ext_inpval_tab(i).return_value,'-1') <>
3675 nvl(l_inpval_tab(j).value,'-1')) then
3676 l_ext_inp_changed := true;
3677 exit;
3678 end if;
3679 end loop;
3680 if l_ext_inp_changed then
3681 exit;
3682 end if;
3683 end loop;
3684
3685 if l_ext_inp_changed then
3686 return not l_ext_inp_changed;
3687 end if;
3688 end if;*/
3689
3690 -- Bug 6716202
3691
3692 open c_dup_prv_chk (l_fsa_element_entry_id,
3693 p_rt_start_date);
3694 fetch c_dup_prv_chk into l_dup_rslt_num;
3695 close c_dup_prv_chk;
3696
3697 if l_dup_rslt_num > 0 then
3698 return false;
3699 end if;
3700 --
3701 p_prv_object_version_number := nvl(p_prv_object_version_number,
3702 l_prv_rec.object_version_number);
3703
3704 ben_prtt_rt_val_api.update_prtt_rt_val
3705 (p_validate => p_validate
3706 ,p_person_id => p_person_id
3707 ,p_prtt_rt_val_id => p_prtt_rt_val_id
3708 ,p_business_group_id => p_business_group_id
3709 ,p_element_entry_value_id => l_ee_id
3710 ,p_input_value_id => p_input_value_id
3711 ,p_object_version_number => p_prv_object_version_number
3712 ,p_effective_date => p_rt_start_date
3713 );
3714 --
3715 l_return := true ;
3716 --
3717 -- reopen the entry if already ended
3718 --
3719 if l_fsa_element_entry_id is not null and
3720 l_fsa_ee_effective_end_date <> hr_api.g_eot and
3721 l_fsa_ee_effective_end_date <> l_element_term_rule_date and
3722 l_fsa_ee_effective_end_date <> l_element_link_end_date then
3723
3724 begin
3725
3726 py_element_entry_api.delete_element_entry
3727 (p_validate =>p_validate
3728 ,p_datetrack_delete_mode =>'FUTURE_CHANGE'
3729 ,p_effective_date =>l_fsa_ee_effective_end_date
3730 ,p_element_entry_id =>l_fsa_element_entry_id
3731 ,p_object_version_number =>l_fsa_ovn
3732 ,p_effective_start_date =>l_effective_start_date
3733 ,p_effective_end_date =>l_effective_end_date
3734 ,p_delete_warning =>l_delete_warning);
3735
3736 exception
3737 when others then
3738 ben_on_line_lf_evt.get_ser_message(l_encoded_message,
3739 l_app_short_name,
3740 l_message_name);
3741 l_encoded_message := fnd_message.get;
3742 --
3743 if l_message_name like '%HR_6284_ELE_ENTRY_DT_ASG_DEL%' or
3744 l_message_name like '%HR_7187_DT_CANNOT_EXTEND_END%' then
3745 -- assignment is not eligible for link beyond this date.
3746 -- Further reopening is not possible.
3747 --
3748 null;
3749 else
3750 if l_app_short_name is not null then
3751 fnd_message.set_name(l_app_short_name,l_message_name);
3752 fnd_message.raise_error;
3753 else
3754 raise;
3755 end if;
3756 end if;
3757 end;
3758 end if;
3759 end if;
3760 --
3761 end if;
3762 close c_non_fsa_prv;
3763 end if;
3764 --
3765 return l_return ;
3766 --
3767 exception when others then
3768 if g_debug then
3769 hr_utility.set_location('in the exception ',122);
3770 end if;
3771 return false ;
3772 end keep_same_element ;
3773 --
3774 begin
3775 g_debug := hr_utility.debug_enabled;
3776 if g_debug then
3777 hr_utility.set_location('Entering:' ||l_proc,5);
3778 hr_utility.set_location('p_prtt_rt_val_id=' ||p_prtt_rt_val_id,5);
3779 hr_utility.set_location('p_rt_start_date=' ||p_rt_start_date,5);
3780 hr_utility.set_location('p_enrt_rslt_id=' ||p_enrt_rslt_id,5);
3781 hr_utility.set_location('p_rt=' ||p_rt,5);
3782 hr_utility.set_location('p_element_type_id=' ||p_element_type_id,5);
3783 hr_utility.set_location('p_input_value_id=' ||p_input_value_id,5);
3784 hr_utility.set_location('p_acty_base_rt_id=' ||p_acty_base_rt_id,5);
3785 hr_utility.set_location('p_effective_date=' ||p_effective_date,5);
3786 end if;
3787 --BUG 3167959 We need to intialize the pl/sql table
3788 clear_ext_inpval_tab ;
3789 --
3790 g_creee_calc_vals := l_creee_calc_vals;
3791 l_amt := p_rt;
3792 --
3793 -- get prtt rt information
3794 --
3795 if p_prtt_rt_val_id is not null then
3796 open c_get_prtt_rt_val
3797 (c_prtt_rt_val_id => p_prtt_rt_val_id
3798 );
3799 fetch c_get_prtt_rt_val into l_prv_rec;
3800 if c_get_prtt_rt_val%notfound
3801 then
3802 --
3803 if g_debug then
3804 hr_utility.set_location('BEN_92103_NO_PRTT_RT_VAL',170);
3805 end if;
3806 close c_get_prtt_rt_val;
3807 --
3808 fnd_message.set_name('BEN', 'BEN_92103_NO_PRTT_RT_VAL');
3809 fnd_message.set_token('PROC',l_proc);
3810 fnd_message.set_token('PRTT_RT_VAL',to_char(p_prtt_rt_val_id));
3811 fnd_message.raise_error;
3812 --
3813 end if;
3814 close c_get_prtt_rt_val;
3815 end if;
3816 --
3817 -- check if abs ler
3818 --
3819 open c_chk_abs_ler
3820 (c_per_in_ler_id => l_prv_rec.per_in_ler_id
3821 ,c_effective_date => p_effective_date
3822 );
3823 fetch c_chk_abs_ler into
3824 l_per_in_ler_id,
3825 l_lf_evt_ocrd_dt,
3826 l_absence_attendance_id,
3827 l_ler_id,
3828 l_ler_typ_cd;
3829 close c_chk_abs_ler;
3830 l_abs_ler := (nvl(l_ler_typ_cd,'xx') = 'ABS');
3831 --
3832 -- get activity base rate information
3833 --
3834 open get_abr_info
3835 (c_acty_base_rt_id => p_acty_base_rt_id
3836 ,c_effective_date => greatest(nvl(l_lf_evt_ocrd_dt,l_rt_strt_dt),l_rt_strt_dt)
3837 );
3838 fetch get_abr_info into l_get_abr_info;
3839 if get_abr_info%notfound then
3840 close get_abr_info;
3841 if g_debug then
3842 hr_utility.set_location('BEN_91723_NO_ENRT_RT_ABR_FOUND',5);
3843 end if;
3844 fnd_message.set_name('BEN','BEN_91723_NO_ENRT_RT_ABR_FOUND');
3845 fnd_message.set_token('PROC',l_proc);
3846 fnd_message.set_token('ACTY_BASE_RT_ID',to_char(p_acty_base_rt_id));
3847 fnd_message.set_token('EFFECTIVE_DATE',to_char(p_effective_date));
3848 fnd_message.raise_error;
3849 end if;
3850 close get_abr_info;
3851
3852 g_acty_base_rt_name := l_get_abr_info.name;
3853 l_element_type_id := nvl(p_element_type_id,l_get_abr_info.element_type_id);
3854 l_input_value_id := nvl(p_input_value_id,l_get_abr_info.input_value_id);
3855 l_ele_entry_val_cd := l_get_abr_info.ele_entry_val_cd; -- Bug 5575402
3856 --
3857 -- For absences, for loading historical absence balances
3858 -- we need to continue in calculate_only_mode if an ele and inp val
3859 -- are attached. inelg_action_cd stores the flag to decide historical
3860 -- load or not
3861 --
3862 if l_abs_ler and
3863 l_get_abr_info.element_type_id is not null and
3864 l_get_abr_info.input_value_id is not null then
3865
3866 if g_param_rec.inelg_action_cd is null and
3867 benutils.g_benefit_action_id is not null then
3868 benutils.get_batch_parameters
3869 (benutils.g_benefit_action_id,
3870 g_param_rec);
3871 end if;
3872
3873 if nvl(g_param_rec.inelg_action_cd,'N') = 'N' then
3874 g_param_rec.inelg_action_cd := 'N';
3875 if l_get_abr_info.ele_rqd_flag='N' then
3876 if g_debug then
3877 hr_utility.set_location('Not historical abs loading ',124);
3878 hr_utility.set_location('Leaving: '||l_proc,124);
3879 end if;
3880 return;
3881 end if;
3882 else
3883 hr_utility.set_location('Historical abs loading ',124);
3884 l_calculate_only_mode := true;
3885 end if;
3886 elsif (l_get_abr_info.ele_rqd_flag='N' AND l_get_abr_info.element_det_rl is null) OR
3887 -- l_get_abr_info.element_type_id is null or
3888 -- l_get_abr_info.input_value_id is null then
3889 -- bug 6441505
3890 l_element_type_id is null or
3891 l_input_value_id is null then
3892 if g_debug then
3893 hr_utility.set_location('ele_rqd_flag=N',124);
3894 hr_utility.set_location('Leaving: '||l_proc,124);
3895 end if;
3896 return;
3897 end if;
3898 --
3899 -- Check for Current Assignment.
3900 --
3901 if NOT (chk_assign_exists
3902 (p_person_id => p_person_id
3903 ,p_business_group_id => p_business_group_id
3904 ,p_effective_date => p_effective_date
3905 ,p_rate_date => l_rt_strt_dt
3906 ,p_acty_base_rt_id => p_acty_base_rt_id
3907 ,p_assignment_id => l_assignment_id
3908 ,p_organization_id => l_organization_id
3909 ,p_payroll_id => l_payroll_id
3910 ))
3911 then
3912 --
3913 if g_debug then
3914 hr_utility.set_location('Create Benefits Assignment ',10);
3915 end if;
3916 --
3917 if not l_calculate_only_mode then
3918 --
3919 create_benefits_assignment
3920 (p_person_id => p_person_id
3921 ,p_payroll_id => l_payroll_id
3922 ,p_assignment_id => l_assignment_id
3923 ,p_business_group_id => p_business_group_id
3924 ,p_organization_id => l_organization_id
3925 ,p_effective_date => l_rt_strt_dt
3926 );
3927 --
3928 end if;
3929 --
3930 -- After create get values back
3931 --
3932 l_tmp_bool:=chk_assign_exists
3933 (p_person_id => p_person_id
3934 ,p_business_group_id => p_business_group_id
3935 ,p_effective_date => p_effective_date
3936 ,p_rate_date => l_rt_strt_dt
3937 ,p_acty_base_rt_id => p_acty_base_rt_id
3938 ,p_assignment_id => l_assignment_id
3939 ,p_organization_id => l_organization_id
3940 ,p_payroll_id => l_payroll_id
3941 );
3942 --
3943 end if;
3944 if g_debug then
3945 hr_utility.set_location('l_assignment_id:'||l_assignment_id,50);
3946 hr_utility.set_location('l_payroll_id:'||l_payroll_id,50);
3947 end if;
3948 --
3949 -- Bug 2675486 For SAREC Code if the enrollment benefit amount has not
3950 -- changed and the old rate start is in the current yr period NO need
3951 -- to compute the element entries.
3952 --
3953 --
3954 -- get the eligible element link for the assignment and element type
3955 --
3956 get_link(p_assignment_id => l_assignment_id
3957 ,p_element_type_id => l_element_type_id
3958 ,p_business_group_id => p_business_group_id
3959 ,p_input_value_id => l_input_value_id
3960 ,p_effective_date => l_rt_strt_dt
3961 ,p_element_link_id => l_element_link_id
3962 );
3963 if l_element_link_id is null then
3964 --
3965 -- error message already set on stack.
3966 --
3967 fnd_message.raise_error;
3968 end if;
3969
3970 l_old_element_link_id := l_element_link_id;
3971
3972 --
3973 -- determine if recurring entry or not
3974 --
3975 open c_ele_info(l_get_abr_info.element_type_id,l_rt_strt_dt);
3976 fetch c_ele_info into
3977 l_element_name,
3978 l_multiple_entries_flag,
3979 l_processing_type;
3980 close c_ele_info;
3981
3982 l_recurring_entry := (nvl(l_processing_type,l_dummy_varchar2) <> 'N' and
3983 nvl(l_get_abr_info.rcrrg_cd,l_dummy_varchar2) <> 'ONCE');
3984 --
3985 -- get the term rule date and link end date for use later on
3986 --
3987 hr_entry.entry_asg_pay_link_dates (l_assignment_id,
3988 l_element_link_id,
3989 l_rt_strt_dt,
3990 l_element_term_rule_date,
3991 l_out_date_not_required,
3992 l_element_link_end_date,
3993 l_out_date_not_required,
3994 l_out_date_not_required);
3995 --
3996 -- if assignment not terminated, l_element_term_rule_date is
3997 -- populated with eot
3998 --
3999 -- Get the element entry id if it exists.
4000 -- If not found then that's ok. We will create a new one.
4001 -- If found, we will update provided it passes validation checks
4002 --
4003
4004 -- Moved this code intentionally here.
4005 -- This is to address data corruption in an earlier version
4006 --
4007 l_mlt_cd := nvl(l_prv_rec.mlt_cd,l_get_abr_info.rt_mlt_cd);
4008 --
4009 -- Bug 5075200 - Rate with enter annual value is case similar to SAREC
4010 -- where we should not recreate element entries unless
4011 -- the annual value changes.
4012 --
4013 -- if l_mlt_cd = 'SAREC' OR
4014 -- l_get_abr_info.entr_ann_val_flag = 'Y' /* Bug 5075200 */
4015 -- then
4016 -- 5401779 - Can retain same element for both fsa and non_fsa plans, if the rt_val is same
4017 -- and the element_type and input_value are same.
4018
4019 if g_debug then
4020 hr_utility.set_location('l_processing_type = '|| l_processing_type,8085);
4021 end if;
4022
4023 --6643665 : Skip keep_same_element call for non-recurring element
4024 if l_processing_type <> 'N' then
4025 if keep_same_element(p_person_id => p_person_id,
4026 p_assignment_id => l_assignment_id,
4027 p_prtt_enrt_rslt_id=> p_enrt_rslt_id,
4028 p_prtt_rt_val_id => p_prtt_rt_val_id,
4029 p_acty_base_rt_id => p_acty_base_rt_id,
4030 p_ann_rt_val => l_prv_rec.ann_rt_val,
4031 p_cmcd_rt_val => l_prv_rec.cmcd_rt_val,
4032 p_rt_val => p_rt,
4033 p_rt_start_date => l_rt_strt_dt,
4034 p_mlt_cd => l_mlt_cd,
4035 p_element_type_id => p_element_type_id,
4036 p_input_value_id => p_input_value_id,
4037 p_ele_entry_val_cd => l_ele_entry_val_cd) -- Bug 5575402
4038 /*p_input_va_calc_rl => l_get_abr_info.input_va_calc_rl,
4039 p_payroll_id => l_payroll_id,
4040 p_organization_id => l_organization_id)*/
4041 then
4042 --
4043 if g_debug then
4044 hr_utility.set_location('Leaving: Dont need to create the ee',123);
4045 end if;
4046
4047 return;
4048 --
4049 end if ;
4050 end if; --6643665
4051
4052 --end if;
4053 --
4054 if l_prv_rec.element_entry_value_id is not null then
4055
4056 open get_element_entry_v(l_prv_rec.element_entry_value_id
4057 ,l_rt_strt_dt);
4058 fetch get_element_entry_v into
4059 l_element_entry_id,
4060 l_ee_effective_start_date,
4061 l_ee_effective_end_date,
4062 l_object_version_number,
4063 l_entry_value_id;
4064 close get_element_entry_v;
4065 --
4066 if g_debug then
4067 hr_utility.set_location('l_element_enrty_id='||l_element_entry_id,50);
4068 hr_utility.set_location('l_ee start_date='||l_ee_effective_start_date,50);
4069 hr_utility.set_location('l_ee end date='||l_ee_effective_end_date,50);
4070 hr_utility.set_location('l_entry_value_id='||l_entry_value_id,50);
4071 end if;
4072
4073 end if;
4074
4075 if not l_abs_ler or
4076 (l_abs_ler and l_multiple_entries_flag <> 'Y') then
4077 --
4078 if l_element_entry_id is null and
4079 l_recurring_entry then
4080
4081 open get_element_entry(l_element_link_id
4082 ,l_assignment_id
4083 ,null
4084 ,l_input_value_id
4085 ,null
4086 ,l_rt_strt_dt);
4087 fetch get_element_entry into
4088 l_element_entry_id,
4089 l_ee_effective_start_date,
4090 l_ee_effective_end_date,
4091 l_object_version_number,
4092 l_entry_value_id;
4093 close get_element_entry;
4094 --
4095 if g_debug then
4096 hr_utility.set_location('l_element_enrty_id='||l_element_entry_id,50);
4097 hr_utility.set_location('l_ee start_date='||l_ee_effective_start_date,50);
4098 hr_utility.set_location('l_ee end date='||l_ee_effective_end_date,50);
4099 hr_utility.set_location('l_entry_value_id='||l_entry_value_id,50);
4100 end if;
4101
4102 end if;
4103 --
4104 end if;
4105 --
4106 -- Validate the entry to be used
4107 --
4108 if l_element_entry_id is not null then
4109
4110 l_effective_start_date := l_ee_effective_start_date;
4111 l_effective_end_date := l_ee_effective_end_date;
4112 --
4113 --Check if entry value is already used by another prtt rt
4114 --
4115 open c_dup_prv(l_entry_value_id, l_rt_strt_dt);
4116 fetch c_dup_prv into l_abr_name;
4117 if c_dup_prv%found then
4118 --
4119 close c_dup_prv;
4120 fnd_message.set_name('BEN','BEN_92690_ELMNT_ALRDY_USD');
4121 fnd_message.set_token('P_RATE1',l_abr_name);
4122 fnd_message.set_token('P_RATE2',g_acty_base_rt_name);
4123 fnd_message.raise_error;
4124 --
4125 end if;
4126 close c_dup_prv;
4127 --
4128 --Check if entry is already used by another enrt rslt
4129 --
4130 open c_dup_rslt (l_element_entry_id,l_rt_strt_dt);
4131 fetch c_dup_rslt into l_abr_name;
4132 if c_dup_rslt%found then
4133 --
4134 close c_dup_rslt;
4135 fnd_message.set_name('BEN','BEN_93450_ELE_MULTIPLE_RSLT');
4136 fnd_message.set_token('P_RATE1',l_abr_name);
4137 fnd_message.set_token('P_RATE2',g_acty_base_rt_name);
4138 fnd_message.raise_error;
4139 --
4140 end if;
4141 close c_dup_rslt;
4142
4143 end if;
4144 --
4145 -- handle any future entries
4146 --
4147 if not l_abs_ler and
4148 l_recurring_entry then
4149 chk_future_entries
4150 (p_validate => p_validate,
4151 p_person_id => p_person_id,
4152 p_assignment_id => l_assignment_id,
4153 p_enrt_rslt_id => p_enrt_rslt_id,
4154 p_element_type_id => l_element_type_id,
4155 p_multiple_entries_flag => l_multiple_entries_flag,
4156 p_effective_date => l_rt_strt_dt);
4157 end if;
4158 --
4159 -- reopen the entry if already ended
4160 --
4161 l_max_ee_end_dt := null;
4162 --
4163 -- 5229941 : Multiple Rates may update same Element, but different Input values.
4164 -- If the max ee end-date <> EOT, then dont delete EE in FUTURE_CHANGE mode
4165 -- as we want to retain the special/normal adjustment amounts of the first Input Value
4166 -- when we calculate the special/normal adjustment amounts for the second Input Value.
4167 --
4168 open get_max_ee_end_dt(l_element_entry_id);
4169 fetch get_max_ee_end_dt into l_max_ee_end_dt;
4170 close get_max_ee_end_dt;
4171
4172 hr_utility.set_location('Max EE End Date '|| l_max_ee_end_dt, 9999);
4173 --
4174 if l_element_entry_id is not null and
4175 l_max_ee_end_dt <> hr_api.g_eot and -- 5229941
4176 l_ee_effective_end_date <> l_element_term_rule_date and
4177 l_ee_effective_end_date <> l_element_link_end_date then
4178
4179 begin
4180 --
4181 hr_utility.set_location(' Deleting All Future Rows ', 9999);
4182 --
4183 py_element_entry_api.delete_element_entry
4184 (p_validate =>p_validate
4185 ,p_datetrack_delete_mode =>'FUTURE_CHANGE'
4186 ,p_effective_date =>l_ee_effective_end_date
4187 ,p_element_entry_id =>l_element_entry_id
4188 ,p_object_version_number =>l_object_version_number
4189 ,p_effective_start_date =>l_effective_start_date
4190 ,p_effective_end_date =>l_effective_end_date
4191 ,p_delete_warning =>l_delete_warning);
4192
4193 exception
4194 when others then
4195 ben_on_line_lf_evt.get_ser_message(l_encoded_message,
4196 l_app_short_name,
4197 l_message_name);
4198 l_encoded_message := fnd_message.get;
4199 --
4200 if l_message_name like '%HR_6284_ELE_ENTRY_DT_ASG_DEL%' or
4201 l_message_name like '%HR_7187_DT_CANNOT_EXTEND_END%' then
4202 --
4203 -- assignment is not eligible for link beyond this date.
4204 -- Further reopening is not possible.
4205 --
4206 null;
4207 else
4208 if l_app_short_name is not null then
4209 fnd_message.set_name(l_app_short_name,l_message_name);
4210 fnd_message.raise_error;
4211 else
4212 raise;
4213 end if;
4214 end if;
4215 end;
4216
4217 end if;
4218
4219 if l_get_abr_info.parnt_chld_cd = 'CHLD' then
4220 --
4221 open c_abr2 (p_effective_date, p_acty_base_rt_id);
4222 fetch c_abr2 into l_prnt_abr;
4223 if c_abr2%found then
4224 --
4225 if g_debug then
4226 hr_utility.set_location('parnt_chld_cd=CHLD',50);
4227 hr_utility.set_location('prnt rt mlt:'||l_prnt_abr.rt_mlt_cd,50);
4228 hr_utility.set_location('prnt entr ann:'||l_prnt_abr.entr_ann_val_flag,50);
4229 end if;
4230 if l_prnt_abr.rt_mlt_cd = 'SAREC' or
4231 l_prnt_abr.entr_ann_val_flag = 'Y' then
4232 l_prnt_ann_rt := 'Y';
4233 end if ;
4234 --
4235 end if;
4236 close c_abr2 ;
4237 --
4238 end if;
4239 --
4240 if nvl(g_result_rec.prtt_enrt_rslt_id,-1) <> p_enrt_rslt_id then
4241 open c_current_result_info
4242 (c_prtt_enrt_rslt_id => p_enrt_rslt_id
4243 );
4244 fetch c_current_result_info into g_result_rec;
4245 close c_current_result_info;
4246
4247 if g_debug then
4248 hr_utility.set_location('pen esd='||g_result_rec.effective_start_date,10);
4249 hr_utility.set_location('pen eed='||g_result_rec.effective_end_date,10);
4250 end if;
4251
4252 end if;
4253
4254 --
4255 -- Check the PRTL MONTH PRORATION rule
4256 -- against the effective date and payperiod
4257 -- of participants payroll.
4258 --
4259 -- ELE : By pass if the ele_entry_val_cd <> PP,EPP or null.
4260 --
4261 --
4262 if nvl(l_get_abr_info.ele_entry_val_cd, 'PP') = 'PP' or
4263 l_get_abr_info.ele_entry_val_cd = 'EPP' then
4264 --
4265 -- Get proper code from rule execution.
4266 --
4267 if l_get_abr_info.prtl_mo_eff_dt_det_cd = 'RL' and
4268 l_get_abr_info.prtl_mo_eff_dt_det_rl is not null then
4269 --
4270 -- exec rule and get code back
4271 --
4272 l_outputs:=benutils.formula
4273 (p_opt_id => g_result_rec.opt_id,
4274 p_pl_id => g_result_rec.pl_id,
4275 p_pgm_id => g_result_rec.pgm_id,
4276 p_formula_id => l_get_abr_info.prtl_mo_eff_dt_det_rl,
4277 p_ler_id => g_result_rec.ler_id,
4278 p_pl_typ_id => g_result_rec.pl_typ_id,
4279 p_assignment_id => l_assignment_id,
4280 p_acty_base_rt_id => p_acty_base_rt_id,
4281 p_business_group_id => p_business_group_id,
4282 p_organization_id => l_organization_id,
4283 p_jurisdiction_code => l_jurisdiction_code,
4284 p_effective_date => p_effective_date);
4285 --
4286 begin
4287 --
4288 -- convert return value to code
4289 --
4290 l_get_abr_info.prtl_mo_eff_dt_det_cd:=l_outputs(l_outputs.first).value;
4291 --
4292 exception
4293 --
4294 when others then
4295 if g_debug then
4296 hr_utility.set_location('BEN_92311_FORMULA_VAL_PARAM',30);
4297 end if;
4298 fnd_message.set_name('BEN','BEN_92311_FORMULA_VAL_PARAM');
4299 fnd_message.set_token('PROC',l_proc);
4300 fnd_message.set_token('FORMULA',l_get_abr_info.prtl_mo_det_mthd_rl);
4301 fnd_message.set_token('PARAMETER',
4302 l_outputs(l_outputs.first).name);
4303 fnd_message.raise_error;
4304 --
4305 end;
4306 end if;
4307 -- ELE :
4308 end if;
4309 --
4310 -- ELE : By pass if the ele_entry_val_cd <> PP, EPP, or null.
4311 --
4312 if nvl(l_get_abr_info.ele_entry_val_cd, 'PP') = 'PP' or
4313 l_get_abr_info.ele_entry_val_cd = 'EPP' then
4314 --
4315 --
4316 -- When this flag is off, we do not annualize the rate value because it's
4317 -- just a 'multiple of' value. Like the '3' in '3% of comp'
4318 --
4319 if l_get_abr_info.use_calc_acty_bs_rt_flag = 'N' then
4320 --
4321 if l_get_abr_info.rt_typ_cd = 'PERTEN' then
4322 -- divide the value by ten
4323 l_amt := l_amt/10;
4324 elsif l_get_abr_info.rt_typ_cd = 'PCT' or l_get_abr_info.rt_typ_cd = 'PERHNDRD' then
4325 -- divide the value by one hundred
4326 l_amt := l_amt/100;
4327 elsif l_get_abr_info.rt_typ_cd = 'PERTHSND' then
4328 -- divide by one thousand
4329 l_amt := l_amt/1000;
4330 elsif l_get_abr_info.rt_typ_cd = 'PERTTHSND' then
4331 -- divide by ten thousand
4332 l_amt := l_amt/10000;
4333 end if; -- if MLT or null, leave value as is.
4334 --
4335 l_per_pay_amt := l_amt;
4336 --
4337 else
4338 --
4339 -- Annualize rate.
4340 --
4341 -- get plan year
4342 --
4343 if g_debug then
4344 hr_utility.set_location('Acty Ref Perd'||p_acty_ref_perd,10);
4345 hr_utility.set_location('prv_id= '|| p_prtt_rt_val_id,10);
4346 hr_utility.set_location('payroll= '|| l_payroll_id,10);
4347 hr_utility.set_location('bg= '|| p_business_group_id,10);
4348 hr_utility.set_location('rt_start= '|| l_rt_strt_dt,10);
4349 end if;
4350 --
4351 --Bug 3430334 we need to find the year period based on the
4352 --pay priod end date or check date to get the right plan
4353 --year period. Rate may start in the previous year period but
4354 --end of pay period may fall in the current pay period.
4355 --
4356 if l_get_abr_info.entr_ann_val_flag='Y' or
4357 l_prnt_ann_rt = 'Y' or
4358 l_mlt_cd = 'SAREC' then
4359 --
4360 open c_current_fsa_pp_end
4361 ( p_payroll_id => l_payroll_id,
4362 p_rt_start_date=> l_rt_strt_dt );
4363 --
4364 fetch c_current_fsa_pp_end into l_current_pp_end_date ;
4365 close c_current_fsa_pp_end ;
4366 --
4367 else
4368 --
4369 open c_current_pp_end
4370 ( p_payroll_id => l_payroll_id,
4371 p_rt_start_date=> l_rt_strt_dt );
4372 fetch c_current_pp_end into l_current_pp_end_date ;
4373 close c_current_pp_end ;
4374 --
4375 end if;
4376 --
4377 if g_debug then
4378 hr_utility.set_location('l_current_pp_end_date '||l_current_pp_end_date,10);
4379 end if;
4380 l_pl_id := nvl(p_pl_id,g_result_rec.pl_id);
4381 if l_pl_id is not null then
4382
4383 open c_plan_year_end_for_pl
4384 (c_pl_id => l_pl_id
4385 ,c_rate_start_or_end_dt => nvl(l_current_pp_end_date,l_rt_strt_dt)
4386 );
4387 fetch c_plan_year_end_for_pl into
4388 l_last_pp_strt_dt,
4389 l_last_pp_end_dt;
4390 close c_plan_year_end_for_pl;
4391
4392 else
4393 open c_plan_year_end_for_pen
4394 (c_prtt_enrt_rslt_id => p_enrt_rslt_id
4395 ,c_rate_start_or_end_dt => nvl(l_current_pp_end_date,l_rt_strt_dt)
4396 ,c_effective_date => p_effective_date
4397 );
4398 fetch c_plan_year_end_for_pen into
4399 l_last_pp_strt_dt,
4400 l_last_pp_end_dt;
4401 close c_plan_year_end_for_pen;
4402
4403 end if;
4404
4405 if l_get_abr_info.entr_ann_val_flag='Y' or
4406 l_prnt_ann_rt = 'Y' or
4407 l_mlt_cd = 'SAREC' then
4408 --l_range_start:=l_rt_strt_dt+1;
4409 --bug#2398448 and bug#2392732
4410 l_range_start:=l_rt_strt_dt;
4411 else
4412 --
4413 --Bug 3294702 We can safely take l_last_pp_strt_dt here.
4414 --
4415 --l_range_start:=add_months(l_last_pp_end_dt,-12) + 1;
4416 l_range_start:= l_last_pp_strt_dt ;
4417 --
4418 end if;
4419 --
4420 -- Bug2843979: Raising proper error if year period not found and
4421 -- elig_per_elctbl_chc_id is not populated in the ben_epe_cache
4422 --
4423 if l_last_pp_end_dt is null and
4424 ben_epe_cache.g_currepe_row.elig_per_elctbl_chc_id is null then
4425 --
4426 fnd_message.set_name('BEN','BEN_93368_DETERMINE_PAY_PERIOD');
4427 fnd_message.raise_error;
4428 --
4429 end if;
4430 --
4431 -- Bug 2149438
4432 if l_mlt_cd = 'SAREC' or
4433 l_prnt_ann_rt = 'Y' then
4434 --
4435 ----Bug 7196470
4436 open c_enrt_rt;
4437 fetch c_enrt_rt into l_enrt_rt_id;
4438 close c_enrt_rt;
4439 l_amt:=ben_distribute_rates.period_to_annual
4440 (p_amount => l_amt
4441 ,p_enrt_rt_id => l_enrt_rt_id--------Bug 7196470
4442 ,p_acty_ref_perd_cd => p_acty_ref_perd
4443 ,p_business_group_id => p_business_group_id
4444 ,p_effective_date => l_rt_strt_dt
4445 ,p_complete_year_flag => 'N'
4446 ,p_use_balance_flag => 'Y'-------'N'----Bug 7196470
4447 ,p_element_type_id => l_element_type_id
4448 ,p_start_date => l_range_start
4449 ,p_end_date => l_last_pp_end_dt
4450 ,p_payroll_id => l_payroll_id
4451 ,p_rounding_flag => 'N' --Bug 2149438
4452 );
4453 -- Moved the rounding from the bendisrt to handle differently.
4454 --
4455 l_amt := round(l_amt,4);
4456 --
4457 else
4458 --
4459 l_amt:=ben_distribute_rates.period_to_annual
4460 (p_amount => l_amt
4461 ,p_acty_ref_perd_cd => p_acty_ref_perd
4462 ,p_business_group_id => p_business_group_id
4463 ,p_effective_date => l_rt_strt_dt
4464 ,p_complete_year_flag => 'N'
4465 ,p_use_balance_flag => 'N'
4466 ,p_element_type_id => l_element_type_id
4467 ,p_start_date => l_range_start
4468 ,p_end_date => l_last_pp_end_dt
4469 ,p_payroll_id => l_payroll_id
4470 );
4471 --
4472 end if;
4473 --
4474 -- Bug 2675486 To fix the temporary rounding issues not to get more than
4475 -- the annual amount
4476 --
4477 if g_debug then
4478 hr_utility.set_location('before l_amt '||l_amt,20);
4479 end if;
4480 --
4481 if (l_mlt_cd = 'SAREC' or l_prnt_ann_rt = 'Y') and
4482 l_amt > p_ann_rt then
4483 l_amt := p_ann_rt ;
4484 end if;
4485 --
4486 -- To do proration need monthly amount divide by 12.
4487 --
4488 l_per_month_amt := l_amt/12;
4489 if g_debug then
4490 hr_utility.set_location('p_ann_rt '||p_ann_rt,20);
4491 hr_utility.set_location('l_per_month_amt '||l_per_month_amt,20);
4492 hr_utility.set_location('l_amt '||l_amt,20);
4493 end if;
4494 --
4495 -- Compute per pay amt
4496 --
4497 if l_get_abr_info.ele_entry_val_cd = 'EPP' then
4498 l_perd_cd := 'EPP';
4499 end if;
4500 --
4501 if l_get_abr_info.entr_ann_val_flag='Y' or
4502 l_mlt_cd = 'SAREC' or
4503 l_prnt_ann_rt = 'Y' then
4504 l_annual_target := true;
4505 end if;
4506 --
4507 l_per_pay_amt:=ben_distribute_rates.annual_to_period
4508 (p_amount =>l_amt
4509 ,p_acty_ref_perd_cd =>l_perd_cd
4510 ,p_business_group_id =>p_business_group_id
4511 ,p_effective_date =>l_rt_strt_dt
4512 ,p_complete_year_flag =>'N'
4513 ,p_use_balance_flag =>'N'
4514 ,p_element_type_id => l_element_type_id
4515 ,p_start_date =>l_range_start
4516 ,p_end_date =>l_last_pp_end_dt
4517 ,p_payroll_id =>l_payroll_id
4518 ,p_annual_target =>l_annual_target
4519 ,p_rounding_flag =>'N'
4520 );
4521 --
4522 if g_debug then
4523 hr_utility.set_location(' before rounding l_per_pay_amt '||l_per_pay_amt ,122);
4524 end if;
4525 if (l_get_abr_info.rndg_cd is not null
4526 or l_get_abr_info.rndg_rl is not null)
4527 and l_per_pay_amt is not null
4528 then
4529 --
4530 l_per_pay_amt := benutils.do_rounding
4531 (p_rounding_cd => l_get_abr_info.rndg_cd
4532 ,p_rounding_rl => l_get_abr_info.rndg_rl
4533 ,p_value => l_per_pay_amt
4534 ,p_effective_date => l_rt_strt_dt
4535 );
4536 --
4537 elsif l_per_pay_amt is not null
4538 and l_per_pay_amt<>0
4539 then
4540 --
4541 -- Do this for now: in future default to rounding for currency precision
4542 --
4543 l_per_pay_amt:=round(l_per_pay_amt,2);
4544 --
4545 end if;
4546 --
4547 if g_debug then
4548 hr_utility.set_location(' after round per_pay_periodamt '||l_per_pay_amt,103);
4549 hr_utility.set_location(' l_amt ' || l_amt ,103);
4550 hr_utility.set_location(' entr_ann_val_flag ' || l_get_abr_info.entr_ann_val_flag,102);
4551 end if;
4552 -- bug#3443215 - rounding to annual amount is called for all the acty ref period
4553 /* if (l_get_abr_info.entr_ann_val_flag='Y' or
4554 p_acty_ref_perd = 'PYR' or
4555 l_mlt_cd = 'SAREC' or
4556 l_prnt_ann_rt = 'Y') and
4557 */
4558 if l_recurring_entry then
4559
4560 if g_debug then
4561 hr_utility.set_location(' entrer in condition ' ,102);
4562 end if;
4563 --
4564 -- need to match annual amount so adjust for
4565 -- rounding errors on annual basis by finding
4566 -- amount off and adding to first ee.
4567 -- Bug#2809677
4568 --
4569 if l_get_abr_info.entr_ann_val_flag='Y' or
4570 l_mlt_cd = 'SAREC' or
4571 l_prnt_ann_rt = 'Y' then
4572 --
4573 l_pay_periods:=ben_distribute_rates.get_periods_between(
4574 p_acty_ref_perd_cd =>l_perd_cd --'PP'
4575 ,p_start_date =>l_range_start
4576 ,p_end_date =>l_last_pp_end_dt
4577 ,p_payroll_id =>l_payroll_id
4578 ,p_business_group_id =>p_business_group_id
4579 ,p_element_type_id => l_element_type_id
4580 ,p_effective_date => p_effective_date
4581 --bug#2556948
4582 ,p_use_check_date => true
4583 );
4584
4585 else
4586 --
4587 l_pay_periods:=ben_distribute_rates.get_periods_between(
4588 p_acty_ref_perd_cd =>l_perd_cd --'PP'
4589 ,p_start_date =>l_range_start
4590 ,p_end_date =>l_last_pp_end_dt
4591 ,p_payroll_id =>l_payroll_id
4592 ,p_business_group_id =>p_business_group_id
4593 ,p_element_type_id => l_element_type_id
4594 ,p_effective_date => p_effective_date
4595 );
4596 end if;
4597
4598 if g_debug then
4599 hr_utility.set_location(' l_pay_periods '||l_pay_periods ,122);
4600 end if;
4601 --
4602 -- Want amount we are under to be positive so we can
4603 -- add the amount to the first ee.
4604 --
4605 -- Bear in mind that this could be for acty_ref_perd = 'PYR' but
4606 -- entr_ann_val_flag = 'N' in which case the calculation needs
4607 -- to be adjusted.
4608 --
4609 if l_get_abr_info.entr_ann_val_flag = 'Y' or
4610 l_mlt_cd = 'SAREC' or
4611 l_prnt_ann_rt = 'Y' then
4612 --
4613 l_first_pp_adjustment:=l_amt - l_pay_periods * l_per_pay_amt;
4614 --
4615 if g_debug then
4616 hr_utility.set_location(' l_first_pp_adjustment '||l_first_pp_adjustment,122);
4617 end if;
4618 --
4619 else
4620 --
4621 -- Fix for WWBUG 1263111
4622 --
4623 -- We have to do a bit of adjusting here.
4624 --
4625 -- First get the real number of periods left.
4626 --
4627 if nvl(l_lf_evt_ocrd_dt,p_effective_date) < l_last_pp_end_dt then
4628 l_real_num_periods:=ben_distribute_rates.get_periods_between
4629 (p_acty_ref_perd_cd =>l_perd_cd --PP'
4630 ,p_start_date => l_rt_strt_dt --p_effective_date
4631 ,p_end_date => l_last_pp_end_dt
4632 ,p_payroll_id => l_payroll_id
4633 ,p_business_group_id => p_business_group_id
4634 ,p_element_type_id => l_element_type_id
4635 ,p_effective_date => nvl(l_lf_evt_ocrd_dt,p_effective_date));
4636 else
4637 l_real_num_periods:=ben_distribute_rates.get_periods_between
4638 (p_acty_ref_perd_cd =>l_perd_cd --PP'
4639 ,p_start_date => nvl(l_lf_evt_ocrd_dt,p_effective_date)
4640 ,p_payroll_id => l_payroll_id
4641 ,p_business_group_id => p_business_group_id
4642 ,p_element_type_id => l_element_type_id
4643 ,p_effective_date => nvl(l_lf_evt_ocrd_dt,p_effective_date));
4644 end if;
4645 --
4646 l_first_pp_adjustment:= ((l_amt*l_real_num_periods)/l_pay_periods) - (l_real_num_periods * l_per_pay_amt);
4647 --
4648 -- End of Fix for WWBUG 1263111
4649 --
4650 end if;
4651 --
4652 if (l_get_abr_info.rndg_cd is not null or
4653 l_get_abr_info.rndg_rl is not null) and
4654 l_first_pp_adjustment is not null then
4655 l_first_pp_adjustment := benutils.do_rounding
4656 (p_rounding_cd => l_get_abr_info.rndg_cd,
4657 p_rounding_rl => l_get_abr_info.rndg_rl,
4658 p_value => l_first_pp_adjustment,
4659 p_effective_date => l_rt_strt_dt);
4660 elsif l_first_pp_adjustment is not null and
4661 l_first_pp_adjustment<>0 then
4662 --
4663 -- Do this for now: in future default to rounding for currency precision
4664 --
4665 l_first_pp_adjustment:=round(l_first_pp_adjustment,2);
4666 end if;
4667 if g_debug then
4668 hr_utility.set_location('first pp adjustment='||l_first_pp_adjustment,10);
4669 end if;
4670 --
4671 end if;
4672 --
4673 if g_debug then
4674 hr_utility.set_location(' out nocopy of condition ' ,102);
4675 end if;
4676 end if; -- use_calc_acty_base_rt_flag is 'Y'
4677
4678 if l_get_abr_info.one_ann_pymt_cd is null
4679 and l_get_abr_info.use_calc_acty_bs_rt_flag = 'Y'
4680 then
4681 --
4682 if g_debug then
4683 hr_utility.set_location(' first condition ' ,102);
4684 end if;
4685 -- Prorate the rate, if necessary
4686 -- let prorate_amount function decide then either
4687 -- l_new_val is the same as l_amount, or not for proration.
4688 -- l_prtn_val will be set.
4689 --
4690 -- Don't prorate if it's 'one annual payment' or if we didn't calc rate yet.
4691 --
4692 if g_debug then
4693 hr_utility.set_location('Prorate the rate',20);
4694 hr_utility.set_location('l_per_month_amt '||l_per_month_amt,20);
4695 end if;
4696 --
4697 -- Bug 6834340
4698 open c_ler_with_current_prv(p_prtt_rt_val_id, p_rt_start_date);
4699 fetch c_ler_with_current_prv into l_ler_with_current_prv;
4700 close c_ler_with_current_prv;
4701 -- Bug 6834340
4702 --
4703 l_prorated_monthly_amt := prorate_amount
4704 (p_amt => l_per_month_amt
4705 ,p_acty_base_rt_id => p_acty_base_rt_id
4706 ,p_prorate_flag => l_prtn_flag
4707 ,p_effective_date => l_rt_strt_dt
4708 ,p_start_or_stop_cd => 'STRT'
4709 ,p_start_or_stop_date => l_rt_strt_dt
4710 ,p_business_group_id => p_business_group_id
4711 ,p_assignment_id => l_assignment_id
4712 ,p_organization_id => l_organization_id
4713 ,p_wsh_rl_dy_mo_num => l_get_abr_info.wsh_rl_dy_mo_num
4714 ,p_prtl_mo_det_mthd_cd => l_get_abr_info.prtl_mo_det_mthd_cd
4715 ,p_prtl_mo_det_mthd_rl => l_get_abr_info.prtl_mo_det_mthd_rl
4716 ,p_person_id => g_result_rec.person_id
4717 ,p_pgm_id => g_result_rec.pgm_id
4718 ,p_pl_typ_id => g_result_rec.pl_typ_id
4719 ,p_pl_id => g_result_rec.pl_id
4720 ,p_opt_id => g_result_rec.opt_id
4721 ,p_ler_id => l_ler_with_current_prv.ler_id -- Bug 6834340
4722 ,p_jurisdiction_code => l_jurisdiction_code
4723 ,p_rndg_cd => l_get_abr_info.rndg_cd
4724 ,p_rndg_rl => l_get_abr_info.rndg_rl
4725 );
4726 if g_debug then
4727 hr_utility.set_location('l_prorated_monthly_amt='||l_prorated_monthly_amt,123);
4728 end if;
4729 --
4730 else
4731 if g_debug then
4732 hr_utility.set_location(' else condition '|| l_get_abr_info.one_ann_pymt_cd ,102);
4733 end if;
4734 l_prtn_flag:='N';
4735 if l_get_abr_info.one_ann_pymt_cd='LPPPYCFC' then
4736 l_normal_pp_date:=l_last_pp_strt_dt;
4737 l_normal_pp_end_date:=l_last_pp_end_dt;
4738 elsif l_get_abr_info.one_ann_pymt_cd='LPPCYCFC' then
4739 open c_last_pp_of_cal_year(l_payroll_id
4740 ,l_rt_strt_dt);
4741 loop
4742 fetch c_last_pp_of_cal_year into
4743 l_normal_pp_date,
4744 l_normal_pp_end_date;
4745 exit when c_last_pp_of_cal_year%notfound;
4746 hr_elements.check_element_freq(
4747 p_payroll_id =>l_payroll_id,
4748 p_bg_id =>p_business_group_id,
4749 p_pay_action_id =>to_number(null),
4750 p_date_earned =>l_normal_pp_date,
4751 p_ele_type_id =>l_element_type_id,
4752 p_skip_element =>g_skip_element
4753 );
4754 exit when g_skip_element='N';
4755 end loop;
4756 close c_last_pp_of_cal_year;
4757 elsif l_get_abr_info.one_ann_pymt_cd='FPPCFC' then
4758 open c_first_pp_after_start(l_payroll_id
4759 ,l_rt_strt_dt);
4760 loop
4761 fetch c_first_pp_after_start into
4762 l_normal_pp_date,
4763 l_normal_pp_end_date;
4764 exit when c_first_pp_after_start%notfound;
4765 hr_elements.check_element_freq(
4766 p_payroll_id =>l_payroll_id,
4767 p_bg_id =>p_business_group_id,
4768 p_pay_action_id =>to_number(null),
4769 p_date_earned =>l_normal_pp_date,
4770 p_ele_type_id =>l_element_type_id,
4771 p_skip_element =>g_skip_element
4772 );
4773 exit when g_skip_element='N';
4774 end loop;
4775 close c_first_pp_after_start;
4776 elsif l_get_abr_info.one_ann_pymt_cd is not null then
4777 --
4778 -- raise error as does not exist as lookup
4779 --
4780 if g_debug then
4781 hr_utility.set_location('BEN_91628_LOOKUP_TYPE_GENERIC',30);
4782 end if;
4783 fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
4784 fnd_message.set_token('FIELD','p_one_ann_pymt_cd');
4785 fnd_message.set_token('TYPE','BEN_ONE_ANN_PYMT');
4786 fnd_message.set_token('VALUE',l_get_abr_info.one_ann_pymt_cd);
4787 fnd_message.raise_error;
4788 end if;
4789 end if;
4790
4791 -- ELE :
4792 end if;
4793 if g_debug then
4794 hr_utility.set_location(' out of if condition' ,102);
4795 end if;
4796 --
4797 -- Create the element entries
4798 --
4799 --
4800 -- Determine prorated first pay periods
4801 -- Where amount is not the normal per pay period amount
4802 --
4803 -- ELE : By pass if the ele_entry_val_cd <> PP, EPP, or null.
4804 --
4805 --
4806 if nvl(l_get_abr_info.ele_entry_val_cd, 'PP') = 'PP' or
4807 l_get_abr_info.ele_entry_val_cd = 'EPP' then
4808 --
4809 if l_prtn_flag = 'Y' then
4810 if g_debug then
4811 hr_utility.set_location('Determine proration ',40);
4812 end if;
4813 if g_debug then
4814 hr_utility.set_location('l_prorated_monthly_amt '||l_prorated_monthly_amt,40);
4815 end if;
4816 --
4817 -- Approach/algorithm to allocating payments:
4818 --
4819 -- In Starting a new rate there are three distinct rate stages
4820 -- 1) No pay periods - pay periods during which no rate should be in effect.
4821 -- 2) Special pay period - pay period during which a rate not equal to the normal rate
4822 -- is in effect. Just one pay period. Spreading them out is outside the scope
4823 -- of this version.
4824 -- 3) Normal pay periods - Periodic rate is in place.
4825 -----------------------------------------------------------
4826 --
4827 -- Want to find the pay periods from the start date
4828 -- ending at the last day of the month or earlier
4829 -- based on the date column specified by prtl_mo_eff_dt_det_cd
4830 --
4831 -- Go backwards and keep overwriting the dates with the most
4832 -- recent one to get the first date it changes to that rate.
4833 --
4834 l_remainder:=l_prorated_monthly_amt;
4835 l_number_in_month:=0;
4836 --
4837 for l_pay_periods in c_next_pay_periods(
4838 p_start_date => l_rt_strt_dt,
4839 p_end_date => add_months(
4840 trunc(l_rt_strt_dt,'mm'),1)-1,
4841 p_prtl_mo_eff_dt_det_cd => l_get_abr_info.prtl_mo_eff_dt_det_cd,
4842 p_payroll_id => l_payroll_id) loop
4843 --
4844 hr_elements.check_element_freq(
4845 p_payroll_id =>l_payroll_id,
4846 p_bg_id =>p_business_group_id,
4847 p_pay_action_id =>to_number(null),
4848 p_date_earned =>l_pay_periods.start_date,
4849 p_ele_type_id =>l_element_type_id,
4850 p_skip_element =>g_skip_element
4851 );
4852 if g_debug then
4853 hr_utility.set_location('pay_start_date '||l_pay_periods.start_date,40);
4854 hr_utility.set_location('end_date '||l_pay_periods.end_date,40);
4855 end if;
4856 if g_skip_element='N' then
4857 l_number_in_month:=l_number_in_month+1;
4858 if l_remainder>l_per_pay_amt then
4859 if g_debug then
4860 hr_utility.set_location('l_per_pay_amt '||l_per_pay_amt,40);
4861 end if;
4862 --
4863 if l_rt_strt_dt > l_pay_periods.start_date then
4864 l_remainder := l_remainder-l_per_pay_amt;
4865 l_old_normal_pp_date:=l_normal_pp_date;
4866 l_normal_pp_date:=l_rt_strt_dt;
4867 exit;
4868 else
4869 --
4870 -- Normal pay period, may not be if have remainder left over
4871 -- In this case will revise date after loop is done
4872 --
4873 l_remainder:=l_remainder-l_per_pay_amt;
4874 l_old_normal_pp_date:=l_normal_pp_date;
4875 l_normal_pp_date:=l_pay_periods.start_date;
4876 end if;
4877 elsif l_remainder=0 then
4878 --
4879 -- Free pay period, no charge
4880 --
4881 l_zero_pp_date:=l_rt_strt_dt;
4882 else
4883 --
4884 -- Special small pay period, from here on it's free.
4885 --
4886 /* if l_zero_pp_date is null then
4887 l_special_pp_date:=l_rt_strt_dt;
4888 else */
4889 if l_rt_strt_dt <= l_pay_periods.start_date then
4890 l_special_pp_date:=l_pay_periods.start_date;
4891 else
4892 l_special_pp_date:=l_rt_strt_dt;
4893 end if;
4894 -- end if;
4895 if g_debug then
4896 hr_utility.set_location('l_special_pp_date '||l_special_pp_date,40);
4897 hr_utility.set_location('l_remainder '||l_remainder,40);
4898 end if;
4899 --
4900 l_special_amt:=l_remainder;
4901 l_remainder:=0;
4902 end if;
4903 end if;
4904 end loop;
4905 --
4906 -- Now check if loop was not entered
4907 --
4908 if l_number_in_month=0 then
4909 --
4910 -- This is the Large amount case
4911 -- where the full amount gets added to the first pp of next month
4912 --
4913 if g_debug then
4914 hr_utility.set_location('p_payroll_id'||l_payroll_id,10);
4915 end if;
4916 --
4917 open c_pps_next_month(
4918 p_end_date => add_months(
4919 trunc(l_rt_strt_dt,'mm'),1)-1,
4920 p_prtl_mo_eff_dt_det_cd => l_get_abr_info.prtl_mo_eff_dt_det_cd,
4921 p_payroll_id => l_payroll_id);
4922 loop
4923 fetch c_pps_next_month into l_start_date,l_end_date;
4924 if c_pps_next_month%notfound then
4925 close c_pps_next_month;
4926 if g_debug then
4927 hr_utility.set_location('BEN_92346_PAYROLL_NOT_DEFINED',30);
4928 end if;
4929 fnd_message.set_name('BEN', 'BEN_92346_PAYROLL_NOT_DEFINED');
4930 fnd_message.set_token('PROC',l_proc);
4931 fnd_message.raise_error;
4932 end if;
4933 hr_elements.check_element_freq(
4934 p_payroll_id =>l_payroll_id,
4935 p_bg_id =>p_business_group_id,
4936 p_pay_action_id =>to_number(null),
4937 p_date_earned =>l_start_date,
4938 p_ele_type_id =>l_element_type_id,
4939 p_skip_element =>g_skip_element
4940 );
4941 exit when g_skip_element='N';
4942 end loop;
4943
4944 --Bug 5259022 Added the below validation
4945 --element entries overlap if the below validation is absent
4946
4947 if l_start_date <= l_rt_strt_dt then
4948 l_special_pp_date:= l_rt_strt_dt;
4949 else
4950 l_special_pp_date:= l_start_date;
4951 end if;
4952 --End Bug 5259022
4953
4954 l_special_amt:=l_remainder+l_per_pay_amt;
4955 --
4956 loop
4957 fetch c_pps_next_month into l_start_date,l_end_date;
4958 if c_pps_next_month%notfound then
4959 close c_pps_next_month;
4960 if g_debug then
4961 hr_utility.set_location('BEN_92346_PAYROLL_NOT_DEFINED',32);
4962 end if;
4963 fnd_message.set_name('BEN', 'BEN_92346_PAYROLL_NOT_DEFINED');
4964 fnd_message.set_token('PROC',l_proc);
4965 fnd_message.raise_error;
4966 end if;
4967 hr_elements.check_element_freq(
4968 p_payroll_id =>l_payroll_id,
4969 p_bg_id =>p_business_group_id,
4970 p_pay_action_id =>to_number(null),
4971 p_date_earned =>l_start_date,
4972 p_ele_type_id =>l_element_type_id,
4973 p_skip_element =>g_skip_element
4974 );
4975 exit when g_skip_element='N';
4976 end loop;
4977 close c_pps_next_month;
4978 l_normal_pp_date:= l_start_date;
4979 --
4980 elsif l_remainder>0 then
4981 --
4982 -- This is case where the first pp of the current month
4983 -- should be bigger because the prorated amount could
4984 -- not fit in the month with amounts <= per_pay_amt
4985 -- In this case there will be no zero pay periods
4986 -- The first normal pp is moved forward to the second one
4987 -- The special pp is set to the first normal one
4988 --
4989 l_special_pp_date:=l_normal_pp_date;
4990 l_special_amt:=l_remainder+l_per_pay_amt;
4991 l_normal_pp_date:=l_old_normal_pp_date;
4992 end if;
4993 --
4994 -- In the cases where a normal pp was not found then it
4995 -- must be the first pp of the next month
4996 --
4997 if l_normal_pp_date is null then
4998 open c_pps_next_month(
4999 p_end_date => add_months(
5000 trunc(l_rt_strt_dt,'mm'),1)-1,
5001 p_prtl_mo_eff_dt_det_cd => l_get_abr_info.prtl_mo_eff_dt_det_cd,
5002 p_payroll_id => l_payroll_id);
5003 loop
5004 fetch c_pps_next_month into l_start_date,l_end_date;
5005 if c_pps_next_month%notfound then
5006 close c_pps_next_month;
5007 if g_debug then
5008 hr_utility.set_location('BEN_92346_PAYROLL_NOT_DEFINED',34);
5009 end if;
5010 fnd_message.set_name('BEN', 'BEN_92346_PAYROLL_NOT_DEFINED');
5011 fnd_message.set_token('PROC',l_proc);
5012 fnd_message.raise_error;
5013 end if;
5014 hr_elements.check_element_freq(
5015 p_payroll_id => l_payroll_id,
5016 p_bg_id => p_business_group_id,
5017 p_pay_action_id => to_number(null),
5018 p_date_earned => l_start_date,
5019 p_ele_type_id => l_element_type_id,
5020 p_skip_element => g_skip_element
5021 );
5022 exit when g_skip_element='N';
5023 end loop;
5024 close c_pps_next_month;
5025 l_normal_pp_date:=l_start_date;
5026 end if;
5027 elsif l_normal_pp_date is null then
5028 if nvl(l_first_pp_adjustment,0) <> 0 then
5029 --
5030 l_special_amt:=l_per_pay_amt + l_first_pp_adjustment;
5031 --
5032 -- get first pp
5033 --
5034 l_special_pp_date := l_rt_strt_dt;
5035 --
5036 --
5037 -- BEGIN OF FIX FOR WWBUG 1402696
5038 --
5039 /*
5040 loop
5041 fetch c_first_pp_after_start into
5042 l_special_pp_date,
5043 l_dummy_date;
5044 exit when c_first_pp_after_start%notfound;
5045 hr_elements.check_element_freq(
5046 p_payroll_id =>l_payroll_id,
5047 p_bg_id =>p_business_group_id,
5048 p_pay_action_id =>to_number(null),
5049 p_date_earned =>l_normal_pp_date,
5050 p_ele_type_id =>l_element_type_id,
5051 p_skip_element =>g_skip_element
5052 );
5053 exit when g_skip_element='N';
5054 end loop;
5055 --
5056 */
5057 --
5058 -- END OF FIX FOR WWBUG 1402696
5059 --
5060 -- get second pp to start normal amounts
5061 --
5062 open c_first_pp_after_start(l_payroll_id
5063 ,l_rt_strt_dt);
5064 loop
5065 fetch c_first_pp_after_start into
5066 l_normal_pp_date,
5067 l_dummy_date;
5068 exit when c_first_pp_after_start%notfound;
5069 hr_elements.check_element_freq(
5070 p_payroll_id =>l_payroll_id,
5071 p_bg_id =>p_business_group_id,
5072 p_pay_action_id =>to_number(null),
5073 p_date_earned =>l_normal_pp_date,
5074 p_ele_type_id =>l_element_type_id,
5075 p_skip_element =>g_skip_element
5076 );
5077 exit when g_skip_element='N';
5078 end loop;
5079 close c_first_pp_after_start;
5080 else
5081 l_normal_pp_date:=l_rt_strt_dt;
5082 end if;
5083 end if;
5084 -- ELE :
5085 end if;
5086
5087 -- Don't make unnecessary changes: compare old value to new one
5088 -- if ee already exists, if not compare to impossible number
5089 --
5090 if l_element_entry_id is not null then
5091 if g_debug then
5092 hr_utility.set_location('Updating if the rate has changed ',90);
5093 end if;
5094 l_update_ee:=true;
5095 else
5096 if g_debug then
5097 hr_utility.set_location('inserting mode ',90);
5098 end if;
5099 l_update_ee:=false;
5100 l_curr_val:=hr_api.g_number;
5101 end if;
5102 --
5103 -- Do the actual creates/updates to element entry
5104 --
5105 if g_debug then
5106 hr_utility.set_location('Determined rate changes ',41);
5107 hr_utility.set_location(' pp date '|| l_zero_pp_date ,41);
5108 end if;
5109
5110 if l_calculate_only_mode then
5111 if g_debug then
5112 hr_utility.set_location(' calc mode true ' ,41);
5113 end if;
5114 end if ;
5115 --
5116 -- ELE : By pass if the ele_entry_val_cd <> PP , EPP or null.
5117 --
5118 if nvl(l_get_abr_info.ele_entry_val_cd, 'PP') = 'PP' or
5119 l_get_abr_info.ele_entry_val_cd = 'EPP' then
5120 --
5121 if l_zero_pp_date is not null
5122 and l_calculate_only_mode
5123 then
5124 --
5125 -- Set screen entry value out parameter to the special value
5126 --
5127 if g_debug then
5128 hr_utility.set_location('set secreen entry value ' ,42);
5129 end if;
5130
5131 p_eev_screen_entry_value := l_per_pay_amt;
5132 --
5133 elsif l_zero_pp_date is not null and
5134 l_zero_pp_date <= least(l_element_term_rule_date,l_element_link_end_date)
5135 then
5136 --
5137 if g_debug then
5138 hr_utility.set_location('Determined rate changes ',41);
5139 end if;
5140
5141 get_extra_ele_inputs
5142 (p_effective_date => l_zero_pp_date
5143 ,p_person_id => p_person_id
5144 ,p_business_group_id => p_business_group_id
5145 ,p_assignment_id => l_assignment_id
5146 ,p_element_link_id => l_element_link_id
5147 ,p_entry_type => 'E'
5148 ,p_input_value_id1 => null
5149 ,p_entry_value1 => 0
5150 ,p_element_entry_id => null
5151 ,p_acty_base_rt_id => p_acty_base_rt_id
5152 ,p_input_va_calc_rl => l_get_abr_info.input_va_calc_rl
5153 ,p_abs_ler => l_abs_ler
5154 ,p_organization_id => l_organization_id
5155 ,p_payroll_id => l_payroll_id
5156 ,p_pgm_id => g_result_rec.pgm_id
5157 ,p_pl_id => NVL(g_result_rec.pl_id,p_pl_id)
5158 ,p_pl_typ_id => g_result_rec.pl_typ_id
5159 ,p_opt_id => g_result_rec.opt_id
5160 ,p_ler_id => l_ler_id
5161 ,p_dml_typ => 'C'
5162 ,p_jurisdiction_code => l_jurisdiction_code
5163 ,p_ext_inpval_tab => g_ext_inpval_tab
5164 ,p_subpriority => l_subpriority
5165 );
5166
5167 --
5168 -- If free pay periods exist start/create ee
5169 --
5170 if l_update_ee then
5171 open get_current_value(l_element_entry_id,l_input_value_id,
5172 l_zero_pp_date);
5173 --
5174 if g_debug then
5175 hr_utility.set_location('l_element_entry_id '||l_element_entry_id,10);
5176 hr_utility.set_location('l_input_value_id '||l_input_value_id,10);
5177 hr_utility.set_location('l_zero_pp_date '||l_zero_pp_date,10);
5178 end if;
5179 --
5180 fetch get_current_value into
5181 l_curr_val,
5182 l_object_version_number,
5183 l_creator_id,
5184 l_creator_type,
5185 l_ee_effective_start_date,
5186 l_ee_effective_end_date;
5187 if get_current_value%notfound then
5188 close get_current_value;
5189 if g_debug then
5190 hr_utility.set_location('BEN_92101_NO_RATE ',90);
5191 end if;
5192 fnd_message.set_name('BEN', 'BEN_92101_NO_RATE');
5193 fnd_message.set_token('PROC',l_proc);
5194 fnd_message.set_token('ELEMENT_ENTRY_ID',to_char(l_element_entry_id));
5195 fnd_message.set_token('INPUT_VALUE_ID',to_char(l_input_value_id));
5196 fnd_message.set_token('EFFECTIVE_DATE',to_char(l_zero_pp_date));
5197 fnd_message.set_token('ABR_NAME',l_get_abr_info.name); -- Bug 2519349
5198 fnd_message.raise_error;
5199 end if;
5200 close get_current_value;
5201
5202 --
5203 if nvl(l_curr_val,0)<>0 then
5204 /*
5205 Before :-
5206 02-JAN-1994
5207 |-A----------------------------------------------------->
5208 ED
5209
5210 After :-
5211 02-JAN-1994 15-JUL-1994
5212 |-A----------------------------|-B---------------------->
5213 ED
5214 */
5215 l_upd_mode := get_ele_dt_upd_mode(l_zero_pp_date,
5216 l_element_entry_id);
5217 py_element_entry_api.update_element_entry
5218 (p_validate =>p_validate
5219 ,p_override_user_ent_chk =>'Y'
5220 ,p_datetrack_update_mode =>l_upd_mode
5221 ,p_effective_date =>l_zero_pp_date
5222 ,p_business_group_id =>p_business_group_id
5223 ,p_element_entry_id =>l_element_entry_id
5224 ,p_object_version_number =>l_object_version_number
5225 ,p_creator_type =>'F'
5226 ,p_creator_id =>p_enrt_rslt_id
5227 ,p_input_value_id1 =>g_ext_inpval_tab(1).input_value_id
5228 ,p_entry_value1 =>g_ext_inpval_tab(1).return_value
5229 ,p_input_value_id2 =>g_ext_inpval_tab(2).input_value_id
5230 ,p_entry_value2 =>g_ext_inpval_tab(2).return_value
5231 ,p_input_value_id3 =>g_ext_inpval_tab(3).input_value_id
5232 ,p_entry_value3 =>g_ext_inpval_tab(3).return_value
5233 ,p_input_value_id4 =>g_ext_inpval_tab(4).input_value_id
5234 ,p_entry_value4 =>g_ext_inpval_tab(4).return_value
5235 ,p_input_value_id5 =>g_ext_inpval_tab(5).input_value_id
5236 ,p_entry_value5 =>g_ext_inpval_tab(5).return_value
5237 ,p_input_value_id6 =>g_ext_inpval_tab(6).input_value_id
5238 ,p_entry_value6 =>g_ext_inpval_tab(6).return_value
5239 ,p_input_value_id7 =>g_ext_inpval_tab(7).input_value_id
5240 ,p_entry_value7 =>g_ext_inpval_tab(7).return_value
5241 ,p_input_value_id8 =>g_ext_inpval_tab(8).input_value_id
5242 ,p_entry_value8 =>g_ext_inpval_tab(8).return_value
5243 ,p_input_value_id9 =>g_ext_inpval_tab(9).input_value_id
5244 ,p_entry_value9 =>g_ext_inpval_tab(9).return_value
5245 ,p_input_value_id10 =>g_ext_inpval_tab(10).input_value_id
5246 ,p_entry_value10 =>g_ext_inpval_tab(10).return_value
5247 ,p_input_value_id11 =>g_ext_inpval_tab(11).input_value_id
5248 ,p_entry_value11 =>g_ext_inpval_tab(11).return_value
5249 ,p_input_value_id12 =>g_ext_inpval_tab(12).input_value_id
5250 ,p_entry_value12 =>g_ext_inpval_tab(12).return_value
5251 ,p_input_value_id13 =>g_ext_inpval_tab(13).input_value_id
5252 ,p_entry_value13 =>g_ext_inpval_tab(13).return_value
5253 ,p_input_value_id14 =>g_ext_inpval_tab(14).input_value_id
5254 ,p_entry_value14 =>g_ext_inpval_tab(14).return_value
5255 ,p_input_value_id15 =>l_input_value_id
5256 ,p_entry_value15 =>0
5257 ,p_effective_start_date =>l_effective_start_date
5258 ,p_effective_end_date =>l_effective_end_date
5259 ,p_update_warning =>l_update_warning
5260 );
5261 --
5262 -- write to the change event log
5263 --
5264 ben_ext_chlg.log_element_chg
5265 (p_action => l_upd_mode
5266 ,p_amt => 0
5267 ,p_old_amt => l_curr_val
5268 ,p_input_value_id => l_input_value_id
5269 ,p_element_entry_id => l_element_entry_id
5270 ,p_person_id => p_person_id
5271 ,p_business_group_id => p_business_group_id
5272 ,p_effective_date => l_zero_pp_date
5273 );
5274 --
5275 -- update curr val to prevent unnecessary updates
5276 --
5277 l_curr_val:=0;
5278 l_creator_id := p_enrt_rslt_id;
5279 l_creator_type := 'F';
5280 --
5281 elsif nvl(l_creator_id,-1) <> p_enrt_rslt_id or
5282 nvl(l_creator_type,'-1') <> 'F' then
5283
5284 l_upd_mode :=get_ele_dt_upd_mode(l_zero_pp_date,
5285 l_element_entry_id);
5286 py_element_entry_api.update_element_entry
5287 (p_validate =>p_validate
5288 ,p_datetrack_update_mode =>l_upd_mode
5289 ,p_effective_date =>l_zero_pp_date
5290 ,p_business_group_id =>p_business_group_id
5291 ,p_element_entry_id =>l_element_entry_id
5292 ,p_object_version_number =>l_object_version_number
5293 ,p_override_user_ent_chk => 'Y'
5294 ,p_creator_type =>'F'
5295 ,p_creator_id =>p_enrt_rslt_id
5296 ,p_input_value_id1 =>g_ext_inpval_tab(1).input_value_id
5297 ,p_entry_value1 =>g_ext_inpval_tab(1).return_value
5298 ,p_input_value_id2 =>g_ext_inpval_tab(2).input_value_id
5299 ,p_entry_value2 =>g_ext_inpval_tab(2).return_value
5300 ,p_input_value_id3 =>g_ext_inpval_tab(3).input_value_id
5301 ,p_entry_value3 =>g_ext_inpval_tab(3).return_value
5302 ,p_input_value_id4 =>g_ext_inpval_tab(4).input_value_id
5303 ,p_entry_value4 =>g_ext_inpval_tab(4).return_value
5304 ,p_input_value_id5 =>g_ext_inpval_tab(5).input_value_id
5305 ,p_entry_value5 =>g_ext_inpval_tab(5).return_value
5306 ,p_input_value_id6 =>g_ext_inpval_tab(6).input_value_id
5307 ,p_entry_value6 =>g_ext_inpval_tab(6).return_value
5308 ,p_input_value_id7 =>g_ext_inpval_tab(7).input_value_id
5309 ,p_entry_value7 =>g_ext_inpval_tab(7).return_value
5310 ,p_input_value_id8 =>g_ext_inpval_tab(8).input_value_id
5311 ,p_entry_value8 =>g_ext_inpval_tab(8).return_value
5312 ,p_input_value_id9 =>g_ext_inpval_tab(9).input_value_id
5313 ,p_entry_value9 =>g_ext_inpval_tab(9).return_value
5314 ,p_input_value_id10 =>g_ext_inpval_tab(10).input_value_id
5315 ,p_entry_value10 =>g_ext_inpval_tab(10).return_value
5316 ,p_input_value_id11 =>g_ext_inpval_tab(11).input_value_id
5317 ,p_entry_value11 =>g_ext_inpval_tab(11).return_value
5318 ,p_input_value_id12 =>g_ext_inpval_tab(12).input_value_id
5319 ,p_entry_value12 =>g_ext_inpval_tab(12).return_value
5320 ,p_input_value_id13 =>g_ext_inpval_tab(13).input_value_id
5321 ,p_entry_value13 =>g_ext_inpval_tab(13).return_value
5322 ,p_input_value_id14 =>g_ext_inpval_tab(14).input_value_id
5323 ,p_entry_value14 =>g_ext_inpval_tab(14).return_value
5324 ,p_effective_start_date =>l_effective_start_date
5325 ,p_effective_end_date =>l_effective_end_date
5326 ,p_update_warning =>l_update_warning
5327 );
5328
5329 l_creator_id := p_enrt_rslt_id;
5330 l_creator_type := 'F';
5331 end if;
5332 else
5333 --
5334 -- create ee since there were no zero pay periods
5335 --
5336 /*
5337 02-JAN-1994
5338 |-A----------------------------------------------------->
5339 ED
5340 */
5341 --
5342 if g_debug then
5343 hr_utility.set_location('calling create ' , 2293);
5344 end if;
5345 py_element_entry_api.create_element_entry
5346 (p_validate =>p_validate
5347 ,p_effective_date =>l_zero_pp_date
5348 ,p_business_group_id =>p_business_group_id
5349 ,p_assignment_id =>l_assignment_id
5350 ,p_element_link_id =>l_element_link_id
5351 ,p_entry_type =>'E'
5352 ,p_override_user_ent_chk =>'Y'
5353 ,p_input_value_id1 =>g_ext_inpval_tab(1).input_value_id
5354 ,p_entry_value1 =>g_ext_inpval_tab(1).return_value
5355 ,p_input_value_id2 =>g_ext_inpval_tab(2).input_value_id
5356 ,p_entry_value2 =>g_ext_inpval_tab(2).return_value
5357 ,p_input_value_id3 =>g_ext_inpval_tab(3).input_value_id
5358 ,p_entry_value3 =>g_ext_inpval_tab(3).return_value
5359 ,p_input_value_id4 =>g_ext_inpval_tab(4).input_value_id
5360 ,p_entry_value4 =>g_ext_inpval_tab(4).return_value
5361 ,p_input_value_id5 =>g_ext_inpval_tab(5).input_value_id
5362 ,p_entry_value5 =>g_ext_inpval_tab(5).return_value
5363 ,p_input_value_id6 =>g_ext_inpval_tab(6).input_value_id
5364 ,p_entry_value6 =>g_ext_inpval_tab(6).return_value
5365 ,p_input_value_id7 =>g_ext_inpval_tab(7).input_value_id
5366 ,p_entry_value7 =>g_ext_inpval_tab(7).return_value
5367 ,p_input_value_id8 =>g_ext_inpval_tab(8).input_value_id
5368 ,p_entry_value8 =>g_ext_inpval_tab(8).return_value
5369 ,p_input_value_id9 =>g_ext_inpval_tab(9).input_value_id
5370 ,p_entry_value9 =>g_ext_inpval_tab(9).return_value
5371 ,p_input_value_id10 =>g_ext_inpval_tab(10).input_value_id
5372 ,p_entry_value10 =>g_ext_inpval_tab(10).return_value
5373 ,p_input_value_id11 =>g_ext_inpval_tab(11).input_value_id
5374 ,p_entry_value11 =>g_ext_inpval_tab(11).return_value
5375 ,p_input_value_id12 =>g_ext_inpval_tab(12).input_value_id
5376 ,p_entry_value12 =>g_ext_inpval_tab(12).return_value
5377 ,p_input_value_id13 =>g_ext_inpval_tab(13).input_value_id
5378 ,p_entry_value13 =>g_ext_inpval_tab(13).return_value
5379 ,p_input_value_id14 =>g_ext_inpval_tab(14).input_value_id
5380 ,p_entry_value14 =>g_ext_inpval_tab(14).return_value
5381 ,p_input_value_id15 =>l_input_value_id
5382 ,p_entry_value15 =>0
5383 ,p_effective_start_date =>l_effective_start_date
5384 ,p_effective_end_date =>l_effective_end_date
5385 ,p_element_entry_id =>l_element_entry_id
5386 ,p_object_version_number =>l_object_version_number
5387 ,p_create_warning =>l_create_warning
5388 );
5389 --
5390 -- Tell next steps to update instead of create
5391 --
5392 l_update_ee:=true;
5393 --
5394 -- write to the change event log
5395 --
5396 ben_ext_chlg.log_element_chg
5397 (p_action => 'CREATE'
5398 ,p_amt => 0
5399 ,p_input_value_id => l_input_value_id
5400 ,p_element_entry_id => l_element_entry_id
5401 ,p_person_id => p_person_id
5402 ,p_business_group_id => p_business_group_id
5403 ,p_effective_date => l_zero_pp_date
5404 );
5405 --
5406 -- Change the creator type and id from the default
5407 --
5408 if g_debug then
5409 hr_utility.set_location('Change creator type and id ',50);
5410 end if;
5411 /*
5412 Before:-
5413 02-JAN-1994
5414 |-A----------------------------------------------------->
5415 ED
5416 After:-
5417 02-JAN-1994
5418 |-A----------------------------------------------------->
5419 ED
5420 */
5421 py_element_entry_api.update_element_entry
5422 (p_validate => p_validate
5423 ,p_datetrack_update_mode => hr_api.g_correction
5424 ,p_effective_date => l_zero_pp_date
5425 ,p_business_group_id => p_business_group_id
5426 ,p_element_entry_id => l_element_entry_id
5427 ,p_override_user_ent_chk =>'Y'
5428 ,p_object_version_number => l_object_version_number
5429 ,p_creator_type => 'F'
5430 ,p_creator_id => p_enrt_rslt_id
5431 ,p_effective_start_date => l_effective_start_date
5432 ,p_effective_end_date => l_effective_end_date
5433 ,p_update_warning => l_update_warning
5434 );
5435 --
5436 -- update curr val to prevent unnecessary updates
5437 --
5438 l_curr_val:=0;
5439 l_creator_id := p_enrt_rslt_id;
5440 l_creator_type := 'F';
5441 --
5442 end if;
5443 end if;
5444 --
5445 -- Done with zero value pay periods, now do special one
5446 --
5447 -- Check for calculate only mode
5448 --
5449 if g_debug then
5450 hr_utility.set_location('l_special_pp_date '||l_special_pp_date , 2293);
5451 end if;
5452 if l_special_pp_date is not null
5453 and l_calculate_only_mode
5454 then
5455 --
5456 -- Set screen entry value out parameter to the special value
5457 --
5458 p_eev_screen_entry_value := l_special_amt;
5459 --
5460 elsif l_special_pp_date is not null and
5461 l_special_pp_date <= least(l_element_term_rule_date,l_element_link_end_date)
5462 then
5463 --
5464 get_extra_ele_inputs
5465 (p_effective_date => l_special_pp_date
5466 ,p_person_id => p_person_id
5467 ,p_business_group_id => p_business_group_id
5468 ,p_assignment_id => l_assignment_id
5469 ,p_element_link_id => l_element_link_id
5470 ,p_entry_type => 'E'
5471 ,p_input_value_id1 => null
5472 ,p_entry_value1 => l_special_amt
5473 ,p_element_entry_id => null
5474 ,p_acty_base_rt_id => p_acty_base_rt_id
5475 ,p_input_va_calc_rl => l_get_abr_info.input_va_calc_rl
5476 ,p_abs_ler => l_abs_ler
5477 ,p_organization_id => l_organization_id
5478 ,p_payroll_id => l_payroll_id
5479 ,p_pgm_id => g_result_rec.pgm_id
5480 ,p_pl_id => NVL(g_result_rec.pl_id,p_pl_id)
5481 ,p_pl_typ_id => g_result_rec.pl_typ_id
5482 ,p_opt_id => g_result_rec.opt_id
5483 ,p_ler_id => l_ler_id
5484 ,p_dml_typ => 'C'
5485 ,p_jurisdiction_code => l_jurisdiction_code
5486 ,p_ext_inpval_tab => g_ext_inpval_tab
5487 ,p_subpriority => l_subpriority
5488 );
5489
5490 if l_update_ee then
5491 --
5492 open get_current_value(l_element_entry_id,l_input_value_id,
5493 l_special_pp_date);
5494 --
5495 fetch get_current_value into
5496 l_curr_val_char,
5497 l_object_version_number,
5498 l_creator_id,
5499 l_creator_type,
5500 l_ee_effective_start_date,
5501 l_ee_effective_end_date;
5502
5503 if get_current_value%notfound then
5504 close get_current_value;
5505 if g_debug then
5506 hr_utility.set_location('BEN_92101_NO_RATE ',92);
5507 end if;
5508 fnd_message.set_name('BEN', 'BEN_92101_NO_RATE');
5509 fnd_message.set_token('PROC',l_proc);
5510 fnd_message.set_token('ELEMENT_ENTRY_ID',to_char(l_element_entry_id));
5511 fnd_message.set_token('INPUT_VALUE_ID',to_char(l_input_value_id));
5512 fnd_message.set_token('EFFECTIVE_DATE',to_char(l_special_pp_date));
5513 fnd_message.set_token('ABR_NAME',l_get_abr_info.name); -- Bug 2519349
5514 fnd_message.raise_error;
5515 end if;
5516 close get_current_value;
5517
5518 if l_uom is null then
5519 l_uom := get_uom(p_business_group_id,p_effective_date);
5520 end if;
5521 l_curr_val := chkformat(l_curr_val_char, l_uom);
5522
5523 if g_debug then
5524 hr_utility.set_location('l_uom='|| l_uom ,432);
5525 hr_utility.set_location('aft frmt chg '||l_curr_val_char,432);
5526 hr_utility.set_location('converted no. value is '||l_curr_val,432);
5527 end if;
5528
5529 if nvl(l_curr_val,hr_api.g_number) <>l_special_amt then
5530 /*
5531 Before :-
5532 02-JAN-1994
5533 |-A----------------------------------------------------->
5534 ED
5535
5536 After :-
5537 02-JAN-1994 15-JUL-1994
5538 |-A----------------------------|-B---------------------->
5539 ED
5540 */
5541 --
5542 l_upd_mode := get_ele_dt_upd_mode(l_special_pp_date,
5543 l_element_entry_id);
5544 py_element_entry_api.update_element_entry
5545 (p_validate =>p_validate
5546 ,p_datetrack_update_mode =>l_upd_mode
5547 ,p_effective_date =>l_special_pp_date
5548 ,p_business_group_id =>p_business_group_id
5549 ,p_element_entry_id =>l_element_entry_id
5550 ,p_override_user_ent_chk =>'Y'
5551 ,p_object_version_number =>l_object_version_number
5552 ,p_creator_type =>'F'
5553 ,p_creator_id =>p_enrt_rslt_id
5554 ,p_input_value_id1 =>g_ext_inpval_tab(1).input_value_id
5555 ,p_entry_value1 =>g_ext_inpval_tab(1).return_value
5556 ,p_input_value_id2 =>g_ext_inpval_tab(2).input_value_id
5557 ,p_entry_value2 =>g_ext_inpval_tab(2).return_value
5558 ,p_input_value_id3 =>g_ext_inpval_tab(3).input_value_id
5559 ,p_entry_value3 =>g_ext_inpval_tab(3).return_value
5560 ,p_input_value_id4 =>g_ext_inpval_tab(4).input_value_id
5561 ,p_entry_value4 =>g_ext_inpval_tab(4).return_value
5562 ,p_input_value_id5 =>g_ext_inpval_tab(5).input_value_id
5563 ,p_entry_value5 =>g_ext_inpval_tab(5).return_value
5564 ,p_input_value_id6 =>g_ext_inpval_tab(6).input_value_id
5565 ,p_entry_value6 =>g_ext_inpval_tab(6).return_value
5566 ,p_input_value_id7 =>g_ext_inpval_tab(7).input_value_id
5567 ,p_entry_value7 =>g_ext_inpval_tab(7).return_value
5568 ,p_input_value_id8 =>g_ext_inpval_tab(8).input_value_id
5569 ,p_entry_value8 =>g_ext_inpval_tab(8).return_value
5570 ,p_input_value_id9 =>g_ext_inpval_tab(9).input_value_id
5571 ,p_entry_value9 =>g_ext_inpval_tab(9).return_value
5572 ,p_input_value_id10 =>g_ext_inpval_tab(10).input_value_id
5573 ,p_entry_value10 =>g_ext_inpval_tab(10).return_value
5574 ,p_input_value_id11 =>g_ext_inpval_tab(11).input_value_id
5575 ,p_entry_value11 =>g_ext_inpval_tab(11).return_value
5576 ,p_input_value_id12 =>g_ext_inpval_tab(12).input_value_id
5577 ,p_entry_value12 =>g_ext_inpval_tab(12).return_value
5578 ,p_input_value_id13 =>g_ext_inpval_tab(13).input_value_id
5579 ,p_entry_value13 =>g_ext_inpval_tab(13).return_value
5580 ,p_input_value_id14 =>g_ext_inpval_tab(14).input_value_id
5581 ,p_entry_value14 =>g_ext_inpval_tab(14).return_value
5582 ,p_input_value_id15 =>l_input_value_id
5583 ,p_entry_value15 =>l_special_amt
5584 ,p_effective_start_date =>l_effective_start_date
5585 ,p_effective_end_date =>l_effective_end_date
5586 ,p_update_warning =>l_update_warning
5587 );
5588 --
5589 -- write to the change event log
5590 --
5591 ben_ext_chlg.log_element_chg
5592 (p_action => l_upd_mode
5593 ,p_amt => l_special_amt
5594 ,p_old_amt => l_curr_val
5595 ,p_input_value_id => l_input_value_id
5596 ,p_element_entry_id => l_element_entry_id
5597 ,p_person_id => p_person_id
5598 ,p_business_group_id => p_business_group_id
5599 ,p_effective_date => l_special_pp_date
5600 );
5601 --
5602 -- update curr val to prevent unnecessary updates
5603 --
5604 l_curr_val:=l_special_amt;
5605 l_creator_id := p_enrt_rslt_id;
5606 l_creator_type := 'F';
5607 --
5608 elsif nvl(l_creator_id,-1) <> p_enrt_rslt_id or
5609 nvl(l_creator_type,'-1') <> 'F' then
5610
5611 l_upd_mode :=get_ele_dt_upd_mode(l_special_pp_date,
5612 l_element_entry_id);
5613 py_element_entry_api.update_element_entry
5614 (p_validate =>p_validate
5615 ,p_datetrack_update_mode =>l_upd_mode
5616 ,p_effective_date =>l_special_pp_date
5617 ,p_business_group_id =>p_business_group_id
5618 ,p_element_entry_id =>l_element_entry_id
5619 ,p_override_user_ent_chk =>'Y'
5620 ,p_object_version_number =>l_object_version_number
5621 ,p_creator_type =>'F'
5622 ,p_creator_id =>p_enrt_rslt_id
5623 ,p_input_value_id1 =>g_ext_inpval_tab(1).input_value_id
5624 ,p_entry_value1 =>g_ext_inpval_tab(1).return_value
5625 ,p_input_value_id2 =>g_ext_inpval_tab(2).input_value_id
5626 ,p_entry_value2 =>g_ext_inpval_tab(2).return_value
5627 ,p_input_value_id3 =>g_ext_inpval_tab(3).input_value_id
5628 ,p_entry_value3 =>g_ext_inpval_tab(3).return_value
5629 ,p_input_value_id4 =>g_ext_inpval_tab(4).input_value_id
5630 ,p_entry_value4 =>g_ext_inpval_tab(4).return_value
5631 ,p_input_value_id5 =>g_ext_inpval_tab(5).input_value_id
5632 ,p_entry_value5 =>g_ext_inpval_tab(5).return_value
5633 ,p_input_value_id6 =>g_ext_inpval_tab(6).input_value_id
5634 ,p_entry_value6 =>g_ext_inpval_tab(6).return_value
5635 ,p_input_value_id7 =>g_ext_inpval_tab(7).input_value_id
5636 ,p_entry_value7 =>g_ext_inpval_tab(7).return_value
5637 ,p_input_value_id8 =>g_ext_inpval_tab(8).input_value_id
5638 ,p_entry_value8 =>g_ext_inpval_tab(8).return_value
5639 ,p_input_value_id9 =>g_ext_inpval_tab(9).input_value_id
5640 ,p_entry_value9 =>g_ext_inpval_tab(9).return_value
5641 ,p_input_value_id10 =>g_ext_inpval_tab(10).input_value_id
5642 ,p_entry_value10 =>g_ext_inpval_tab(10).return_value
5643 ,p_input_value_id11 =>g_ext_inpval_tab(11).input_value_id
5644 ,p_entry_value11 =>g_ext_inpval_tab(11).return_value
5645 ,p_input_value_id12 =>g_ext_inpval_tab(12).input_value_id
5646 ,p_entry_value12 =>g_ext_inpval_tab(12).return_value
5647 ,p_input_value_id13 =>g_ext_inpval_tab(13).input_value_id
5648 ,p_entry_value13 =>g_ext_inpval_tab(13).return_value
5649 ,p_input_value_id14 =>g_ext_inpval_tab(14).input_value_id
5650 ,p_entry_value14 =>g_ext_inpval_tab(14).return_value
5651 ,p_effective_start_date =>l_effective_start_date
5652 ,p_effective_end_date =>l_effective_end_date
5653 ,p_update_warning =>l_update_warning
5654 );
5655 l_creator_id := p_enrt_rslt_id;
5656 l_creator_type := 'F';
5657 end if;
5658 --
5659 else
5660 --
5661 -- create ee since there were no zero pay periods
5662 --
5663 /*
5664 02-JAN-1994
5665 |-A----------------------------------------------------->
5666 ED
5667 */
5668 --
5669 if g_debug then
5670 hr_utility.set_location('l_special_amt='||l_special_amt,433);
5671 end if;
5672
5673 py_element_entry_api.create_element_entry
5674 (p_validate =>p_validate
5675 ,p_effective_date =>l_special_pp_date
5676 ,p_business_group_id =>p_business_group_id
5677 ,p_assignment_id =>l_assignment_id
5678 ,p_element_link_id =>l_element_link_id
5679 ,p_entry_type =>'E'
5680 ,p_override_user_ent_chk =>'Y'
5681 ,p_input_value_id1 =>g_ext_inpval_tab(1).input_value_id
5682 ,p_entry_value1 =>g_ext_inpval_tab(1).return_value
5683 ,p_input_value_id2 =>g_ext_inpval_tab(2).input_value_id
5684 ,p_entry_value2 =>g_ext_inpval_tab(2).return_value
5685 ,p_input_value_id3 =>g_ext_inpval_tab(3).input_value_id
5686 ,p_entry_value3 =>g_ext_inpval_tab(3).return_value
5687 ,p_input_value_id4 =>g_ext_inpval_tab(4).input_value_id
5688 ,p_entry_value4 =>g_ext_inpval_tab(4).return_value
5689 ,p_input_value_id5 =>g_ext_inpval_tab(5).input_value_id
5690 ,p_entry_value5 =>g_ext_inpval_tab(5).return_value
5691 ,p_input_value_id6 =>g_ext_inpval_tab(6).input_value_id
5692 ,p_entry_value6 =>g_ext_inpval_tab(6).return_value
5693 ,p_input_value_id7 =>g_ext_inpval_tab(7).input_value_id
5694 ,p_entry_value7 =>g_ext_inpval_tab(7).return_value
5695 ,p_input_value_id8 =>g_ext_inpval_tab(8).input_value_id
5696 ,p_entry_value8 =>g_ext_inpval_tab(8).return_value
5697 ,p_input_value_id9 =>g_ext_inpval_tab(9).input_value_id
5698 ,p_entry_value9 =>g_ext_inpval_tab(9).return_value
5699 ,p_input_value_id10 =>g_ext_inpval_tab(10).input_value_id
5700 ,p_entry_value10 =>g_ext_inpval_tab(10).return_value
5701 ,p_input_value_id11 =>g_ext_inpval_tab(11).input_value_id
5702 ,p_entry_value11 =>g_ext_inpval_tab(11).return_value
5703 ,p_input_value_id12 =>g_ext_inpval_tab(12).input_value_id
5704 ,p_entry_value12 =>g_ext_inpval_tab(12).return_value
5705 ,p_input_value_id13 =>g_ext_inpval_tab(13).input_value_id
5706 ,p_entry_value13 =>g_ext_inpval_tab(13).return_value
5707 ,p_input_value_id14 =>g_ext_inpval_tab(14).input_value_id
5708 ,p_entry_value14 =>g_ext_inpval_tab(14).return_value
5709 ,p_input_value_id15 =>l_input_value_id
5710 ,p_entry_value15 =>l_special_amt
5711 ,p_effective_start_date =>l_effective_start_date
5712 ,p_effective_end_date =>l_effective_end_date
5713 ,p_element_entry_id =>l_element_entry_id
5714 ,p_object_version_number =>l_object_version_number
5715 ,p_create_warning =>l_create_warning
5716 );
5717 --
5718 -- Tell next steps to update instead of create
5719 --
5720 l_update_ee:=true;
5721 --
5722 -- write to the change event log
5723 --
5724 ben_ext_chlg.log_element_chg
5725 (p_action => 'CREATE'
5726 ,p_amt => l_special_amt
5727 ,p_input_value_id => l_input_value_id
5728 ,p_element_entry_id => l_element_entry_id
5729 ,p_person_id => p_person_id
5730 ,p_business_group_id => p_business_group_id
5731 ,p_effective_date => l_special_pp_date
5732 );
5733 --
5734 -- Change the creator type and id from the default
5735 --
5736 if g_debug then
5737 hr_utility.set_location('Change creator type and id ',50);
5738 end if;
5739 /*
5740 Before:-
5741 02-JAN-1994
5742 |-A----------------------------------------------------->
5743 ED
5744 After:-
5745 02-JAN-1994
5746 |-A----------------------------------------------------->
5747 ED
5748 */
5749 py_element_entry_api.update_element_entry
5750 (p_validate => p_validate
5751 ,p_datetrack_update_mode => hr_api.g_correction
5752 ,p_effective_date => l_special_pp_date
5753 ,p_business_group_id => p_business_group_id
5754 ,p_element_entry_id => l_element_entry_id
5755 ,p_override_user_ent_chk =>'Y'
5756 ,p_object_version_number => l_object_version_number
5757 ,p_creator_type => 'F'
5758 ,p_creator_id => p_enrt_rslt_id
5759 ,p_effective_start_date => l_effective_start_date
5760 ,p_effective_end_date => l_effective_end_date
5761 ,p_update_warning => l_update_warning
5762 );
5763 --
5764 -- update curr val to prevent unnecessary updates
5765 --
5766 l_curr_val:=l_special_amt;
5767 l_creator_id := p_enrt_rslt_id;
5768 l_creator_type := 'F';
5769 --
5770 end if;
5771 --
5772 end if;
5773 -- ELE :
5774 end if;
5775 --
5776 -- Get entry value id.
5777 --
5778 if g_debug then
5779 hr_utility.set_location('not p_calculate_only_mode ' ,41);
5780 hr_utility.set_location('normal pp date '|| l_normal_pp_date ,41);
5781 end if;
5782 --
5783 -- Done with special value pay period, now do normal one
5784 --
5785 -- ELE : By pass if the ele_entry_val_cd <> PP , EPP or null.
5786 --
5787 if nvl(l_get_abr_info.ele_entry_val_cd, 'PP') not in ('PP', 'EPP') then
5788 --
5789 l_normal_pp_date := l_rt_strt_dt;
5790 l_zero_pp_date := null;
5791 l_special_pp_date := null;
5792 --
5793 if l_get_abr_info.ele_entry_val_cd = 'DFND' then
5794 --
5795 l_per_pay_amt := p_rt;
5796 --
5797 elsif l_get_abr_info.ele_entry_val_cd = 'CMCD' then
5798 --
5799 l_per_pay_amt := p_cmncd_rt;
5800 --
5801 elsif l_get_abr_info.ele_entry_val_cd = 'PYR' then
5802 --
5803 l_per_pay_amt := p_ann_rt;
5804 --
5805 end if;
5806 end if;
5807 --
5808 if l_abs_ler then
5809 l_input_value_id1 := l_input_value_id;
5810 else
5811 l_input_value_id1 := null;
5812 end if;
5813 --
5814 get_extra_ele_inputs
5815 (p_effective_date => l_normal_pp_date
5816 ,p_person_id => p_person_id
5817 ,p_business_group_id => p_business_group_id
5818 ,p_assignment_id => l_assignment_id
5819 ,p_element_link_id => l_element_link_id
5820 ,p_entry_type => 'E'
5821 ,p_input_value_id1 => l_input_value_id1
5822 ,p_entry_value1 => l_per_pay_amt
5823 ,p_element_entry_id => null
5824 ,p_acty_base_rt_id => p_acty_base_rt_id
5825 ,p_input_va_calc_rl => l_get_abr_info.input_va_calc_rl
5826 ,p_abs_ler => l_abs_ler
5827 ,p_organization_id => l_organization_id
5828 ,p_payroll_id => l_payroll_id
5829 ,p_pgm_id => g_result_rec.pgm_id
5830 ,p_pl_id => NVL(g_result_rec.pl_id,p_pl_id)
5831 ,p_pl_typ_id => g_result_rec.pl_typ_id
5832 ,p_opt_id => g_result_rec.opt_id
5833 ,p_ler_id => l_ler_id
5834 ,p_dml_typ => 'C'
5835 ,p_jurisdiction_code => l_jurisdiction_code
5836 ,p_ext_inpval_tab => g_ext_inpval_tab
5837 ,p_subpriority => l_subpriority
5838 );
5839
5840 if g_debug then
5841 hr_utility.set_location( 'ext inp count '|| g_ext_inpval_tab.count , 30);
5842 end if;
5843
5844 --
5845 -- Check for calculate only mode
5846 --
5847 if not l_calculate_only_mode then
5848 --
5849 if l_normal_pp_date is not null and
5850 l_normal_pp_date <= least(l_element_term_rule_date,l_element_link_end_date) then
5851 if l_update_ee then
5852 open get_current_value(l_element_entry_id,
5853 l_input_value_id,
5854 l_normal_pp_date);
5855 --
5856 fetch get_current_value into
5857 l_curr_val_char,
5858 l_object_version_number,
5859 l_creator_id,
5860 l_creator_type,
5861 l_ee_effective_start_date,
5862 l_ee_effective_end_date;
5863
5864 if g_debug then
5865 hr_utility.set_location('fetched all values' ,432);
5866 end if;
5867
5868 if get_current_value%notfound then
5869 close get_current_value;
5870 if g_debug then
5871 hr_utility.set_location('BEN_92101_NO_RATE ',94);
5872 end if;
5873 fnd_message.set_name('BEN', 'BEN_92101_NO_RATE');
5874 fnd_message.set_token('PROC',l_proc);
5875 fnd_message.set_token('ELEMENT_ENTRY_ID',to_char(l_element_entry_id));
5876 fnd_message.set_token('INPUT_VALUE_ID',to_char(l_input_value_id));
5877 fnd_message.set_token('EFFECTIVE_DATE',to_char(l_normal_pp_date));
5878 fnd_message.set_token('ABR_NAME',l_get_abr_info.name); -- Bug 2519349
5879 fnd_message.raise_error;
5880 end if;
5881 close get_current_value;
5882 --
5883 if l_uom is null then
5884 l_uom := get_uom(p_business_group_id,p_effective_date);
5885 end if;
5886 l_curr_val := chkformat(l_curr_val_char, l_uom);
5887
5888 if g_debug then
5889 hr_utility.set_location('l_uom='|| l_uom ,432);
5890 hr_utility.set_location('aft frmt chg '||l_curr_val_char,432);
5891 hr_utility.set_location('converted no. value is '||l_curr_val,432);
5892 end if;
5893
5894 if nvl(l_curr_val,hr_api.g_number) <>l_per_pay_amt then
5895 /*
5896 Before :-
5897 02-JAN-1994
5898 |-A----------------------------------------------------->
5899 ED
5900
5901 After :-
5902 02-JAN-1994 15-JUL-1994
5903 |-A----------------------------|-B---------------------->
5904 ED
5905 */
5906 --
5907 l_upd_mode :=get_ele_dt_upd_mode(l_normal_pp_date,
5908 l_element_entry_id);
5909 --
5910 py_element_entry_api.update_element_entry
5911 (p_validate =>p_validate
5912 ,p_datetrack_update_mode =>l_upd_mode
5913 ,p_effective_date =>l_normal_pp_date
5914 ,p_business_group_id =>p_business_group_id
5915 ,p_element_entry_id =>l_element_entry_id
5916 ,p_override_user_ent_chk =>'Y'
5917 ,p_object_version_number =>l_object_version_number
5918 ,p_creator_type =>'F'
5919 ,p_creator_id =>p_enrt_rslt_id
5920 ,p_input_value_id1 =>g_ext_inpval_tab(1).input_value_id
5921 ,p_entry_value1 =>g_ext_inpval_tab(1).return_value
5922 ,p_input_value_id2 =>g_ext_inpval_tab(2).input_value_id
5923 ,p_entry_value2 =>g_ext_inpval_tab(2).return_value
5924 ,p_input_value_id3 =>g_ext_inpval_tab(3).input_value_id
5925 ,p_entry_value3 =>g_ext_inpval_tab(3).return_value
5926 ,p_input_value_id4 =>g_ext_inpval_tab(4).input_value_id
5927 ,p_entry_value4 =>g_ext_inpval_tab(4).return_value
5928 ,p_input_value_id5 =>g_ext_inpval_tab(5).input_value_id
5929 ,p_entry_value5 =>g_ext_inpval_tab(5).return_value
5930 ,p_input_value_id6 =>g_ext_inpval_tab(6).input_value_id
5931 ,p_entry_value6 =>g_ext_inpval_tab(6).return_value
5932 ,p_input_value_id7 =>g_ext_inpval_tab(7).input_value_id
5933 ,p_entry_value7 =>g_ext_inpval_tab(7).return_value
5934 ,p_input_value_id8 =>g_ext_inpval_tab(8).input_value_id
5935 ,p_entry_value8 =>g_ext_inpval_tab(8).return_value
5936 ,p_input_value_id9 =>g_ext_inpval_tab(9).input_value_id
5937 ,p_entry_value9 =>g_ext_inpval_tab(9).return_value
5938 ,p_input_value_id10 =>g_ext_inpval_tab(10).input_value_id
5939 ,p_entry_value10 =>g_ext_inpval_tab(10).return_value
5940 ,p_input_value_id11 =>g_ext_inpval_tab(11).input_value_id
5941 ,p_entry_value11 =>g_ext_inpval_tab(11).return_value
5942 ,p_input_value_id12 =>g_ext_inpval_tab(12).input_value_id
5943 ,p_entry_value12 =>g_ext_inpval_tab(12).return_value
5944 ,p_input_value_id13 =>g_ext_inpval_tab(13).input_value_id
5945 ,p_entry_value13 =>g_ext_inpval_tab(13).return_value
5946 ,p_input_value_id14 =>g_ext_inpval_tab(14).input_value_id
5947 ,p_entry_value14 =>g_ext_inpval_tab(14).return_value
5948 ,p_input_value_id15 =>l_input_value_id
5949 ,p_entry_value15 =>l_per_pay_amt
5950 ,p_effective_start_date =>l_effective_start_date
5951 ,p_effective_end_date =>l_effective_end_date
5952 ,p_update_warning =>l_update_warning
5953 );
5954 --
5955 -- write to the change event log
5956 --
5957 ben_ext_chlg.log_element_chg
5958 (p_action => l_upd_mode
5959 ,p_amt => l_per_pay_amt
5960 ,p_old_amt => l_curr_val
5961 ,p_input_value_id => l_input_value_id
5962 ,p_element_entry_id => l_element_entry_id
5963 ,p_person_id => p_person_id
5964 ,p_business_group_id => p_business_group_id
5965 ,p_effective_date => l_normal_pp_date
5966 );
5967 --
5968 l_ee_effective_end_date := l_effective_end_date;
5969 l_creator_id := p_enrt_rslt_id;
5970 l_creator_type := 'F';
5971
5972 elsif nvl(l_creator_id,-1) <> p_enrt_rslt_id or
5973 nvl(l_creator_type,'-1') <> 'F' then
5974
5975 l_upd_mode :=get_ele_dt_upd_mode(l_normal_pp_date,
5976 l_element_entry_id);
5977 py_element_entry_api.update_element_entry
5978 (p_validate =>p_validate
5979 ,p_datetrack_update_mode =>l_upd_mode
5980 ,p_effective_date =>l_normal_pp_date
5981 ,p_business_group_id =>p_business_group_id
5982 ,p_element_entry_id =>l_element_entry_id
5983 ,p_override_user_ent_chk =>'Y'
5984 ,p_object_version_number =>l_object_version_number
5985 ,p_creator_type =>'F'
5986 ,p_creator_id =>p_enrt_rslt_id
5987 ,p_input_value_id1 =>g_ext_inpval_tab(1).input_value_id
5988 ,p_entry_value1 =>g_ext_inpval_tab(1).return_value
5989 ,p_input_value_id2 =>g_ext_inpval_tab(2).input_value_id
5990 ,p_entry_value2 =>g_ext_inpval_tab(2).return_value
5991 ,p_input_value_id3 =>g_ext_inpval_tab(3).input_value_id
5992 ,p_entry_value3 =>g_ext_inpval_tab(3).return_value
5993 ,p_input_value_id4 =>g_ext_inpval_tab(4).input_value_id
5994 ,p_entry_value4 =>g_ext_inpval_tab(4).return_value
5995 ,p_input_value_id5 =>g_ext_inpval_tab(5).input_value_id
5996 ,p_entry_value5 =>g_ext_inpval_tab(5).return_value
5997 ,p_input_value_id6 =>g_ext_inpval_tab(6).input_value_id
5998 ,p_entry_value6 =>g_ext_inpval_tab(6).return_value
5999 ,p_input_value_id7 =>g_ext_inpval_tab(7).input_value_id
6000 ,p_entry_value7 =>g_ext_inpval_tab(7).return_value
6001 ,p_input_value_id8 =>g_ext_inpval_tab(8).input_value_id
6002 ,p_entry_value8 =>g_ext_inpval_tab(8).return_value
6003 ,p_input_value_id9 =>g_ext_inpval_tab(9).input_value_id
6004 ,p_entry_value9 =>g_ext_inpval_tab(9).return_value
6005 ,p_input_value_id10 =>g_ext_inpval_tab(10).input_value_id
6006 ,p_entry_value10 =>g_ext_inpval_tab(10).return_value
6007 ,p_input_value_id11 =>g_ext_inpval_tab(11).input_value_id
6008 ,p_entry_value11 =>g_ext_inpval_tab(11).return_value
6009 ,p_input_value_id12 =>g_ext_inpval_tab(12).input_value_id
6010 ,p_entry_value12 =>g_ext_inpval_tab(12).return_value
6011 ,p_input_value_id13 =>g_ext_inpval_tab(13).input_value_id
6012 ,p_entry_value13 =>g_ext_inpval_tab(13).return_value
6013 ,p_input_value_id14 =>g_ext_inpval_tab(14).input_value_id
6014 ,p_entry_value14 =>g_ext_inpval_tab(14).return_value
6015 ,p_effective_start_date =>l_effective_start_date
6016 ,p_effective_end_date =>l_effective_end_date
6017 ,p_update_warning =>l_update_warning
6018 );
6019 l_creator_id := p_enrt_rslt_id;
6020 l_creator_type := 'F';
6021 end if;
6022 --
6023
6024 else
6025 --
6026 -- create ee since there were no zero pay periods
6027 --
6028 /*
6029 02-JAN-1994
6030 |-A----------------------------------------------------->
6031 ED
6032 */
6033 if g_debug then
6034 hr_utility.set_location( 'entering', 30.2);
6035 hr_utility.set_location( 'amout '|| l_amt , 30.2);
6036 end if;
6037
6038 py_element_entry_api.create_element_entry
6039 (p_validate =>p_validate
6040 ,p_effective_date =>l_normal_pp_date
6041 ,p_business_group_id =>p_business_group_id
6042 ,p_assignment_id =>l_assignment_id
6043 ,p_element_link_id =>l_element_link_id
6044 ,p_entry_type =>'E'
6045 ,p_override_user_ent_chk =>'Y'
6046 ,p_subpriority =>l_subpriority
6047 ,p_input_value_id1 =>g_ext_inpval_tab(1).input_value_id
6048 ,p_entry_value1 =>g_ext_inpval_tab(1).return_value
6049 ,p_input_value_id2 =>g_ext_inpval_tab(2).input_value_id
6050 ,p_entry_value2 =>g_ext_inpval_tab(2).return_value
6051 ,p_input_value_id3 =>g_ext_inpval_tab(3).input_value_id
6052 ,p_entry_value3 =>g_ext_inpval_tab(3).return_value
6053 ,p_input_value_id4 =>g_ext_inpval_tab(4).input_value_id
6054 ,p_entry_value4 =>g_ext_inpval_tab(4).return_value
6055 ,p_input_value_id5 =>g_ext_inpval_tab(5).input_value_id
6056 ,p_entry_value5 =>g_ext_inpval_tab(5).return_value
6057 ,p_input_value_id6 =>g_ext_inpval_tab(6).input_value_id
6058 ,p_entry_value6 =>g_ext_inpval_tab(6).return_value
6059 ,p_input_value_id7 =>g_ext_inpval_tab(7).input_value_id
6060 ,p_entry_value7 =>g_ext_inpval_tab(7).return_value
6061 ,p_input_value_id8 =>g_ext_inpval_tab(8).input_value_id
6062 ,p_entry_value8 =>g_ext_inpval_tab(8).return_value
6063 ,p_input_value_id9 =>g_ext_inpval_tab(9).input_value_id
6064 ,p_entry_value9 =>g_ext_inpval_tab(9).return_value
6065 ,p_input_value_id10 =>g_ext_inpval_tab(10).input_value_id
6066 ,p_entry_value10 =>g_ext_inpval_tab(10).return_value
6067 ,p_input_value_id11 =>g_ext_inpval_tab(11).input_value_id
6068 ,p_entry_value11 =>g_ext_inpval_tab(11).return_value
6069 ,p_input_value_id12 =>g_ext_inpval_tab(12).input_value_id
6070 ,p_entry_value12 =>g_ext_inpval_tab(12).return_value
6071 ,p_input_value_id13 =>g_ext_inpval_tab(13).input_value_id
6072 ,p_entry_value13 =>g_ext_inpval_tab(13).return_value
6073 ,p_input_value_id14 =>g_ext_inpval_tab(14).input_value_id
6074 ,p_entry_value14 =>g_ext_inpval_tab(14).return_value
6075 ,p_input_value_id15 =>l_input_value_id
6076 ,p_entry_value15 =>l_per_pay_amt
6077 ,p_effective_start_date =>l_effective_start_date
6078 ,p_effective_end_date =>l_effective_end_date
6079 ,p_element_entry_id =>l_element_entry_id
6080 ,p_object_version_number =>l_object_version_number
6081 ,p_create_warning =>l_create_warning
6082 );
6083 --
6084 hr_utility.set_location('l_effective_end_date after pay.create_element_entry '||l_effective_end_date,44333);
6085 --
6086 --
6087 -- Tell next steps to update instead of create
6088 --
6089
6090 l_update_ee:=true;
6091 --
6092 -- write to the change event log
6093 --
6094 ben_ext_chlg.log_element_chg
6095 (p_action => 'CREATE'
6096 ,p_amt => l_per_pay_amt
6097 ,p_input_value_id => l_input_value_id
6098 ,p_element_entry_id => l_element_entry_id
6099 ,p_person_id => p_person_id
6100 ,p_business_group_id => p_business_group_id
6101 ,p_effective_date => l_normal_pp_date
6102 );
6103 --
6104 -- Change the creator type and id from the default
6105 --
6106 if g_debug then
6107 hr_utility.set_location('Change creator type and id ',50);
6108 end if;
6109 /*
6110 Before:-
6111 02-JAN-1994
6112 |-A----------------------------------------------------->
6113 ED
6114 After:-
6115 02-JAN-1994
6116 |-A----------------------------------------------------->
6117 ED
6118 */
6119 py_element_entry_api.update_element_entry
6120 (p_validate =>p_validate
6121 ,p_datetrack_update_mode =>hr_api.g_correction
6122 ,p_effective_date =>l_normal_pp_date
6123 ,p_business_group_id =>p_business_group_id
6124 ,p_element_entry_id =>l_element_entry_id
6125 ,p_override_user_ent_chk =>'Y'
6126 ,p_object_version_number =>l_object_version_number
6127 ,p_creator_type =>'F'
6128 ,p_creator_id =>p_enrt_rslt_id
6129 ,p_effective_start_date =>l_effective_start_date
6130 ,p_effective_end_date =>l_effective_end_date
6131 ,p_update_warning =>l_update_warning
6132 );
6133 --
6134 l_ee_effective_end_date := l_effective_end_date;
6135 l_creator_id := p_enrt_rslt_id;
6136 l_creator_type := 'F';
6137
6138 hr_utility.set_location('l_ee_effective_end_date '||l_ee_effective_end_date,44333);
6139 hr_utility.set_location('l_creator_id '||l_creator_id,44333);
6140 hr_utility.set_location('l_creator_type '||l_creator_type,44333);
6141 end if;
6142 --
6143 end if;
6144
6145 if l_normal_pp_date is not null then
6146 --
6147 hr_utility.set_location('if l_normal_pp_date is not null then ',44333);
6148 --
6149 if l_ee_effective_end_date < l_element_term_rule_date then
6150 --
6151 hr_utility.set_location('if l_ee_effective_end_date < l_element_term_rule_date then ',44333);
6152 --
6153
6154 open c_future_ee(l_element_entry_id,
6155 l_element_type_id,
6156 l_input_value_id,
6157 l_assignment_id,
6158 l_normal_pp_date);
6159 loop
6160 fetch c_future_ee into l_future_ee_rec;
6161
6162 if c_future_ee%notfound then
6163 --
6164 hr_utility.set_location('if c_future_ee%notfound then ',44333);
6165 --
6166 exit;
6167 end if;
6168
6169 l_element_link_id := l_future_ee_rec.element_link_id;
6170 l_effective_start_date := l_future_ee_rec.effective_start_date;
6171 l_effective_end_date := l_future_ee_rec.effective_end_date;
6172
6173 l_curr_val :=chkformat(l_future_ee_rec.screen_entry_value,l_uom);
6174
6175 if g_debug then
6176 hr_utility.set_location('future ee='||l_future_ee_rec.element_entry_id ,433);
6177 hr_utility.set_location('l_curr_val_char='||l_future_ee_rec.screen_entry_value ,433);
6178 hr_utility.set_location('l_curr_val='||l_curr_val ,433);
6179 hr_utility.set_location('l_per_pay_amt='||l_per_pay_amt ,433);
6180 end if;
6181
6182 if nvl(l_per_pay_amt,0) <> nvl(l_curr_val,0) then
6183 --
6184 hr_utility.set_location('if nvl(l_per_pay_amt,0) <> nvl(l_curr_val,0) then',44333);
6185 --
6186 py_element_entry_api.update_element_entry
6187 (p_validate =>p_validate
6188 ,p_datetrack_update_mode =>hr_api.g_correction
6189 ,p_effective_date =>l_future_ee_rec.effective_start_date
6190 ,p_business_group_id =>p_business_group_id
6191 ,p_element_entry_id =>l_future_ee_rec.element_entry_id
6192 ,p_override_user_ent_chk =>'Y'
6193 ,p_object_version_number =>l_future_ee_rec.object_version_number
6194 ,p_input_value_id1 =>l_input_value_id
6195 ,p_entry_value1 =>l_per_pay_amt
6196 ,p_effective_start_date =>l_effective_start_date
6197 ,p_effective_end_date =>l_effective_end_date
6198 ,p_update_warning =>l_update_warning
6199 );
6200 end if;
6201 end loop;
6202 close c_future_ee;
6203 end if;
6204
6205 loop
6206 --
6207 -- created till max possible date. exit now
6208 --
6209 if l_effective_end_date=l_element_term_rule_date then
6210 --
6211 hr_utility.set_location('if l_effective_end_date=l_element_term_rule_date then',44333);
6212 --
6213 exit;
6214 end if;
6215
6216 l_effective_date := l_effective_end_date + 1;
6217 --
6218 if g_debug then
6219 hr_utility.set_location('l_effective_date '||l_effective_date,44333);
6220 hr_utility.set_location('l_effective_end_date '||l_effective_end_date,44333);
6221 end if;
6222 --
6223 -- get the next eligible element link for the assignment and elt
6224 --
6225 -- added here for bug 6450363
6226 if l_abs_ler then -- bug # 7383673, 7390204
6227 -- bug # 7383673, 7390204 -- restricting bug 6450363 fix only for absences
6228 l_old_asgn_id := l_assignment_id;
6229 hr_utility.set_location('l_old_asgn_id '||l_old_asgn_id,44333);
6230 --
6231 get_abr_assignment (p_person_id => p_person_id
6232 ,p_effective_date => l_effective_date
6233 ,p_acty_base_rt_id => l_prv_rec.acty_base_rt_id
6234 ,p_organization_id => l_dummy_number
6235 ,p_payroll_id => l_payroll_id
6236 ,p_assignment_id => l_assignment_id);
6237 --
6238 hr_utility.set_location('l_assignment_id'||l_assignment_id,44333);
6239 if l_old_asgn_id = l_assignment_id then
6240 --
6241 hr_utility.set_location('if l_old_asgn_id = l_assignment_id then',44333);
6242 --
6243 get_link(p_assignment_id => l_assignment_id
6244 ,p_element_type_id => l_element_type_id
6245 ,p_business_group_id => p_business_group_id
6246 ,p_input_value_id => l_input_value_id
6247 ,p_effective_date => l_effective_date
6248 ,p_element_link_id => l_new_element_link_id
6249 );
6250 else
6251 --
6252 hr_utility.set_location('if l_old_asgn_id = l_assignment_id then',44333);
6253 --
6254 l_assignment_id := l_old_asgn_id;
6255 --
6256 get_link(p_assignment_id => l_assignment_id
6257 ,p_element_type_id => l_element_type_id
6258 ,p_business_group_id => p_business_group_id
6259 ,p_input_value_id => l_input_value_id
6260 ,p_effective_date => l_effective_end_date
6261 ,p_element_link_id => l_new_element_link_id
6262 );
6263 end if;
6264 --added till here for bug 6450363
6265 else
6266 get_link(p_assignment_id => l_assignment_id
6267 ,p_element_type_id => l_element_type_id
6268 ,p_business_group_id => p_business_group_id
6269 ,p_input_value_id => l_input_value_id
6270 ,p_effective_date => l_effective_date
6271 ,p_element_link_id => l_new_element_link_id
6272 );
6273
6274 end if;
6275
6276 if g_debug then
6277 hr_utility.set_location('new_elk='||l_new_element_link_id,50);
6278 end if;
6279
6280 if l_new_element_link_id = l_element_link_id or
6281 l_new_element_link_id is null then
6282 --
6283 -- No new link found. Get out of the loop
6284 --
6285 exit;
6286 end if;
6287
6288 l_element_link_id := l_new_element_link_id;
6289
6290 if nvl(l_inpval_tab.count,0) = 0 then
6291 get_inpval_tab(l_element_entry_id,
6292 l_effective_start_date,
6293 l_inpval_tab);
6294 end if;
6295 --
6296 hr_utility.set_location('again before pay.create_element',44333);
6297 --
6298 py_element_entry_api.create_element_entry
6299 (p_validate =>p_validate
6300 ,p_effective_date =>l_effective_date
6301 ,p_business_group_id =>p_business_group_id
6302 ,p_assignment_id =>l_assignment_id
6303 ,p_element_link_id =>l_element_link_id
6304 ,p_entry_type =>'E'
6305 ,p_override_user_ent_chk =>'Y'
6306 ,p_subpriority =>l_subpriority
6307 ,p_input_value_id1 =>l_inpval_tab(1).input_value_id
6308 ,p_entry_value1 =>l_inpval_tab(1).value
6309 ,p_input_value_id2 =>l_inpval_tab(2).input_value_id
6310 ,p_entry_value2 =>l_inpval_tab(2).value
6311 ,p_input_value_id3 =>l_inpval_tab(3).input_value_id
6312 ,p_entry_value3 =>l_inpval_tab(3).value
6313 ,p_input_value_id4 =>l_inpval_tab(4).input_value_id
6314 ,p_entry_value4 =>l_inpval_tab(4).value
6315 ,p_input_value_id5 =>l_inpval_tab(5).input_value_id
6316 ,p_entry_value5 =>l_inpval_tab(5).value
6317 ,p_input_value_id6 =>l_inpval_tab(6).input_value_id
6318 ,p_entry_value6 =>l_inpval_tab(6).value
6319 ,p_input_value_id7 =>l_inpval_tab(7).input_value_id
6320 ,p_entry_value7 =>l_inpval_tab(7).value
6321 ,p_input_value_id8 =>l_inpval_tab(8).input_value_id
6322 ,p_entry_value8 =>l_inpval_tab(8).value
6323 ,p_input_value_id9 =>l_inpval_tab(9).input_value_id
6324 ,p_entry_value9 =>l_inpval_tab(9).value
6325 ,p_input_value_id10 =>l_inpval_tab(10).input_value_id
6326 ,p_entry_value10 =>l_inpval_tab(10).value
6327 ,p_input_value_id11 =>l_inpval_tab(11).input_value_id
6328 ,p_entry_value11 =>l_inpval_tab(11).value
6329 ,p_input_value_id12 =>l_inpval_tab(12).input_value_id
6330 ,p_entry_value12 =>l_inpval_tab(12).value
6331 ,p_input_value_id13 =>l_inpval_tab(13).input_value_id
6332 ,p_entry_value13 =>l_inpval_tab(13).value
6333 ,p_input_value_id14 =>l_inpval_tab(14).input_value_id
6334 ,p_entry_value14 =>l_inpval_tab(14).value
6335 ,p_input_value_id15 =>l_inpval_tab(15).input_value_id
6336 ,p_entry_value15 =>l_inpval_tab(15).value
6337 ,p_effective_start_date =>l_effective_start_date
6338 ,p_effective_end_date =>l_effective_end_date
6339 ,p_element_entry_id =>l_element_entry_id
6340 ,p_object_version_number =>l_object_version_number
6341 ,p_create_warning =>l_create_warning
6342 );
6343 --
6344 --
6345 -- write to the change event log
6346 --
6347 ben_ext_chlg.log_element_chg
6348 (p_action => 'CREATE'
6349 ,p_amt => l_per_pay_amt
6350 ,p_input_value_id => l_input_value_id
6351 ,p_element_entry_id => l_element_entry_id
6352 ,p_person_id => p_person_id
6353 ,p_business_group_id => p_business_group_id
6354 ,p_effective_date => l_effective_date
6355 );
6356 --
6357 -- Change the creator type and id from the default
6358 --
6359 py_element_entry_api.update_element_entry
6360 (p_validate =>p_validate
6361 ,p_datetrack_update_mode =>hr_api.g_correction
6362 ,p_effective_date =>l_effective_date
6363 ,p_business_group_id =>p_business_group_id
6364 ,p_element_entry_id =>l_element_entry_id
6365 ,p_override_user_ent_chk =>'Y'
6366 ,p_object_version_number =>l_object_version_number
6367 ,p_creator_type =>'F'
6368 ,p_creator_id =>p_enrt_rslt_id
6369 ,p_effective_start_date =>l_effective_start_date
6370 ,p_effective_end_date =>l_effective_end_date
6371 ,p_update_warning =>l_update_warning
6372 );
6373
6374 end loop;
6375
6376 end if;
6377
6378 if l_effective_end_date <> hr_api.g_eot and
6379 l_recurring_entry then
6380
6381 if l_effective_end_date < l_element_term_rule_date then
6382 l_message_name := 'BEN_93454_NO_ELK_TILL_EOT';
6383 else
6384 l_message_name := 'BEN_93449_NO_ELE_TILL_EOT';
6385 end if;
6386 --
6387 ben_warnings.load_warning
6388 (p_application_short_name => 'BEN',
6389 p_message_name => l_message_name,
6390 p_parma => l_element_name,
6391 p_parmb => to_char(l_effective_end_date),
6392 p_person_id => p_person_id);
6393 --
6394 if fnd_global.conc_request_id not in ( 0,-1) then
6395 --
6396 fnd_message.set_name('BEN',l_message_name);
6397 fnd_message.set_token('PARMA',l_element_name);
6398 fnd_message.set_token('PARMB',to_char(l_effective_end_date));
6399 l_string := fnd_message.get;
6400 benutils.write(p_text => l_string);
6401 --
6402 end if;
6403 --
6404 end if;
6405 --
6406 -- get the fudged start date to use for the requery
6407 --
6408 if l_zero_pp_date is not null then
6409 l_rt_strt_dt:=l_zero_pp_date;
6410 elsif l_special_pp_date is not null then
6411 l_rt_strt_dt:=l_special_pp_date;
6412 elsif l_normal_pp_date is not null then
6413 l_rt_strt_dt:=l_normal_pp_date;
6414 end if;
6415 --
6416 if not l_recurring_entry then
6417 l_non_recurring_ee_id := l_element_entry_id;
6418 end if;
6419
6420 open get_element_entry(l_old_element_link_id
6421 ,l_assignment_id
6422 ,p_enrt_rslt_id
6423 ,l_input_value_id
6424 ,l_non_recurring_ee_id
6425 ,l_rt_strt_dt);
6426 fetch get_element_entry into
6427 l_element_entry_id,
6428 l_ee_effective_start_date,
6429 l_ee_effective_end_date,
6430 l_object_version_number,
6431 l_entry_value_id;
6432 if get_element_entry%notfound then
6433 --
6434 if g_debug then
6435 hr_utility.set_location('no entry created',140);
6436 end if;
6437 close get_element_entry;
6438 --
6439 if g_debug then
6440 hr_utility.set_location('BEN_92102_NO_ENTRY_CREATED',140);
6441 end if;
6442 fnd_message.set_name('BEN', 'BEN_92102_NO_ENTRY_CREATED');
6443 fnd_message.set_token('PROC',l_proc);
6444 fnd_message.set_token('ELEMENT_ENTRY_ID',to_char(l_old_element_link_id));
6445 fnd_message.set_token('INPUT_VALUE_ID',to_char(l_input_value_id));
6446 fnd_message.set_token('EFFECTIVE_DATE',to_char(l_rt_strt_dt));
6447 fnd_message.raise_error;
6448 --
6449 end if;
6450 close get_element_entry;
6451 --
6452 -- If it was a one time rate, i.e. not recurring end it
6453 --
6454 if g_debug then
6455 hr_utility.set_location ('normal_pp_end_date'||l_normal_pp_end_date,293.9);
6456 end if;
6457 if l_normal_pp_end_date is not null then
6458 --
6459 py_element_entry_api.delete_element_entry
6460 (p_validate => p_validate
6461 ,p_datetrack_delete_mode => hr_api.g_delete
6462 ,p_effective_date => l_normal_pp_end_date
6463 ,p_element_entry_id => l_element_entry_id
6464 ,p_object_version_number => l_object_version_number
6465 ,p_effective_start_date => l_effective_start_date
6466 ,p_effective_end_date => l_effective_end_date
6467 ,p_delete_warning => l_delete_warning
6468 );
6469 --
6470 -- write to the change event log
6471 --
6472 ben_ext_chlg.log_element_chg
6473 (p_action => hr_api.g_delete
6474 ,p_old_amt => l_per_pay_amt
6475 ,p_input_value_id => l_input_value_id
6476 ,p_element_entry_id => l_element_entry_id
6477 ,p_person_id => p_person_id
6478 ,p_business_group_id => p_business_group_id
6479 ,p_effective_date => l_normal_pp_end_date
6480 );
6481 --
6482 end if;
6483 --
6484 -- reset l_rt_strt_dt
6485 --
6486 l_rt_strt_dt := p_rt_start_date;
6487 --
6488 g_max_end_date := null;
6489 --
6490 --Bug 3151737 and 3063518 if there is no payroll for the assignment and if
6491 --it is not required we dont need to compute this.
6492 --
6493 if l_payroll_id is null and
6494 nvl(l_get_abr_info.ele_entry_val_cd, 'PP') not in ('PP', 'EPP') then
6495 --
6496 null;
6497 --
6498 else
6499 --
6500 if nvl(g_per_pay_rec.assignment_id,-1) <> l_assignment_id then
6501 --
6502 open c_payroll_was_ever_run
6503 (c_assignment_id => l_assignment_id
6504 );
6505 fetch c_payroll_was_ever_run into l_v2dummy;
6506 g_per_pay_rec.assignment_id := l_assignment_id;
6507 g_per_pay_rec.payroll_was_ever_run := c_payroll_was_ever_run%found;
6508 close c_payroll_was_ever_run;
6509 --
6510 end if;
6511 --
6512 if g_per_pay_rec.payroll_was_ever_run and
6513 g_per_pay_rec.end_date is null then
6514 --
6515 g_max_end_date :=
6516 get_max_end_dt (
6517 p_assignment_id => l_assignment_id,
6518 p_payroll_id => l_payroll_id,
6519 p_element_type_id => l_element_type_id,
6520 p_effective_date => l_rt_strt_dt);
6521 g_per_pay_rec.end_date := g_max_end_date;
6522 --
6523 elsif g_per_pay_rec.end_date is not null then
6524 g_max_end_date := g_per_pay_rec.end_date;
6525 end if;
6526 --
6527 end if;
6528 --
6529 --
6530 -- even if there are any run results the entry start date
6531 -- should be same as rate start date. Payroll retro process will take care
6532 --
6533 if g_max_end_date is not null and (g_max_end_date +1) > l_rt_strt_dt
6534 and not (l_abs_ler) then
6535 --
6536 if (g_msg_displayed <>1 )
6537 -- added for bug: 5607214
6538 OR fnd_global.conc_request_id not in ( 0,-1)
6539 then -- 2530582
6540 --
6541 -- Issue a warning to the user. These will display on the enrt forms.
6542 ben_warnings.load_warning
6543 (p_application_short_name => 'BEN',
6544 p_message_name => 'BEN_92455_STRT_RUN_RESULTS',
6545 p_parma => fnd_date.date_to_chardate(g_max_end_date),
6546 p_person_id => p_person_id);
6547
6548 if fnd_global.conc_request_id in ( 0,-1) then
6549 --
6550 fnd_message.set_name('BEN','BEN_92455_STRT_RUN_RESULTS');
6551 fnd_message.set_token('PARMA', fnd_date.date_to_chardate(g_max_end_date));
6552 l_string := fnd_message.get;
6553 benutils.write(p_text => l_string);
6554 --
6555 end if;
6556 g_msg_displayed := 1;
6557 end if;
6558
6559 insert_into_quick_pay
6560 (p_person_id => p_person_id,
6561 p_element_type_id => l_element_type_id,
6562 p_assignment_id => l_assignment_id,
6563 p_element_entry_id => l_element_entry_id,
6564 p_effective_date => l_rt_strt_dt,
6565 p_start_date => l_rt_strt_dt,
6566 p_end_date => g_max_end_date,
6567 p_payroll_id => l_payroll_id);
6568 --
6569 end if;
6570 --
6571 -- Update prtt_rt_val with the new element entry value id
6572 --
6573 if g_debug then
6574 hr_utility.set_location('update prtt_rt_val',180);
6575 end if;
6576 --
6577 if p_prtt_rt_val_id is not null then
6578 p_prv_object_version_number := nvl(p_prv_object_version_number,
6579 l_prv_rec.object_version_number);
6580 ben_prtt_rt_val_api.update_prtt_rt_val
6581 (p_validate => p_validate
6582 ,p_business_group_id => l_prv_rec.business_group_id
6583 ,p_prtt_rt_val_id => l_prv_rec.prtt_rt_val_id
6584 ,p_element_entry_value_id => l_entry_value_id
6585 ,p_object_version_number => p_prv_object_version_number
6586 ,p_effective_date => l_rt_strt_dt
6587 );
6588 --
6589 end if;
6590 end if;
6591 --
6592 -- call pqp routine for updating absence balances
6593 --
6594 if l_normal_pp_date is not null and
6595 l_abs_ler then
6596 if g_debug then
6597 hr_utility.set_location('Calling pqp_absence_plan_process ',189);
6598 end if;
6599 pqp_absence_plan_process.create_absence_plan_details
6600 (p_person_id => p_person_id
6601 ,p_assignment_id => l_assignment_id
6602 ,p_business_group_id => p_business_group_id
6603 ,p_legislation_code => get_legislation_code(p_business_group_id)
6604 ,p_effective_date => p_effective_date
6605 ,p_element_type_id => l_element_type_id
6606 ,p_pl_id => g_result_rec.pl_id
6607 ,p_pl_typ_id => g_result_rec.pl_typ_id
6608 ,p_ler_id => l_ler_id
6609 ,p_per_in_ler_id => l_per_in_ler_id
6610 ,p_absence_attendance_id => l_absence_attendance_id
6611 ,p_effective_start_date => l_effective_start_date
6612 ,p_effective_end_date => nvl(l_effective_end_date,hr_api.g_eot)
6613 ,p_formula_outputs => g_outputs
6614 ,p_error_code => l_err_code
6615 ,p_error_message => l_err_mesg
6616 );
6617 end if;
6618 --
6619 if g_debug then
6620 hr_utility.set_location('element_entry_id='||l_element_entry_id,189);
6621 hr_utility.set_location('Leaving: '||l_proc,190);
6622 end if;
6623 --
6624
6625 p_element_entry_value_id := l_entry_value_id;
6626 g_creee_calc_vals.element_entry_id := l_element_entry_id;
6627 g_creee_calc_vals.zero_pp_date := l_zero_pp_date;
6628 g_creee_calc_vals.special_pp_date := l_special_pp_date;
6629 g_creee_calc_vals.special_amt := l_special_amt;
6630 g_creee_calc_vals.normal_pp_date := l_normal_pp_date;
6631 g_creee_calc_vals.normal_amt := l_per_pay_amt;
6632 g_creee_calc_vals.normal_pp_end_date := l_normal_pp_end_date;
6633 g_creee_calc_vals.prtn_flag := l_prtn_flag;
6634 g_creee_calc_vals.first_pp_adjustment := l_first_pp_adjustment;
6635 g_creee_calc_vals.rt_strt_dt := l_rt_strt_dt;
6636 g_creee_calc_vals.range_start := l_range_start;
6637 g_creee_calc_vals.last_pp_end_dt := l_last_pp_end_dt;
6638 g_creee_calc_vals.payroll_id := l_payroll_id;
6639 --
6640 end create_enrollment_element;
6641 --
6642 -- ----------------------------------------------------------------------------
6643 -- |-------------------< reopen_closed_enrollment >--------------------------|
6644 -- ----------------------------------------------------------------------------
6645 procedure reopen_closed_enrollment
6646 (p_validate in boolean
6647 ,p_business_group_id in number
6648 ,p_person_id in number
6649 ,p_acty_base_rt_id in number
6650 ,p_element_type_id in number
6651 ,p_prtt_rt_val_id in number
6652 ,p_input_value_id in number
6653 ,p_rt in number
6654 ,p_rt_start_date in date
6655 ,p_effective_date in date
6656 ) is
6657
6658 cursor get_abr_info (p_acty_base_rt_id in number,
6659 p_effective_date date) is
6660 select abr.ele_rqd_flag,
6661 abr.input_va_calc_rl,
6662 abr.element_type_id,
6663 abr.input_value_id,
6664 abr.prtl_mo_det_mthd_cd
6665 from ben_acty_base_rt_f abr
6666 where abr.acty_base_rt_id=p_acty_base_rt_id
6667 and p_effective_date between
6668 abr.effective_start_date and abr.effective_end_date;
6669 --
6670 l_abr_info get_abr_info%rowtype;
6671 --
6672 cursor c_ele_info (p_person_id in number,
6673 p_prtt_enrt_rslt_id in number,
6674 p_element_entry_value_id in number) is
6675 select pee.element_entry_id,
6676 asg.assignment_id,
6677 asg.payroll_id,
6678 pet.element_name,
6679 pet.multiple_entries_allowed_flag,
6680 pel.element_type_id,
6681 pev.input_value_id
6682 from per_all_assignments_f asg,
6683 pay_element_links_f pel,
6684 pay_element_types_f pet,
6685 pay_element_entries_f pee,
6686 pay_element_entry_values_f pev
6687 where asg.person_id = p_person_id
6688 and asg.assignment_id = pee.assignment_id
6689 and pee.effective_start_date between asg.effective_start_date
6690 and asg.effective_end_date
6691 and pev.element_entry_value_id = p_element_entry_value_id
6692 and pee.element_entry_id = pev.element_entry_id
6693 and pee.creator_id = p_prtt_enrt_rslt_id
6694 and pee.creator_type = 'F'
6695 and pee.entry_type = 'E'
6696 and pev.effective_start_date between pee.effective_start_date
6697 and pee.effective_end_date
6698 and pel.element_link_id = pee.element_link_id
6699 and pee.effective_start_date between pel.effective_start_date
6700 and pel.effective_end_date
6701 and pet.element_type_id = pel.element_type_id
6702 and pel.effective_start_date between pet.effective_start_date
6703 and pet.effective_end_date;
6704 --
6705 -- Cursor to get the entry to be reopened
6706 --
6707 cursor get_last_element_entry
6708 (p_element_type_id in number
6709 ,p_input_value_id in number
6710 ,p_assignment_id in number
6711 ,p_prtt_enrt_rslt_id in number
6712 ,p_effective_date in date
6713 )
6714 is
6715 select ele.element_entry_id,
6716 ele.element_link_id,
6717 ele.effective_start_date,
6718 ele.effective_end_date,
6719 pev.screen_entry_value,
6720 ele.object_version_number
6721 from pay_element_entries_f ele,
6722 pay_element_entry_values_f pev,
6723 pay_element_links_f elk
6724 where ele.creator_id = p_prtt_enrt_rslt_id
6725 and ele.creator_type = 'F'
6726 and ele.entry_type = 'E'
6727 and ele.assignment_id = p_assignment_id
6728 and ele.element_link_id = elk.element_link_id
6729 and ele.effective_start_date between elk.effective_start_date
6730 and elk.effective_end_date
6731 and elk.element_type_id = p_element_type_id
6732 and pev.element_entry_id = ele.element_entry_id
6733 and pev.input_value_id = p_input_value_id
6734 and pev.effective_start_date between ele.effective_start_date
6735 and ele.effective_end_date
6736 order by ele.effective_start_date desc;
6737 --
6738 cursor c_current_ee
6739 (p_element_type_id in number
6740 ,p_prtt_enrt_rslt_id in number
6741 ,p_assignment_id in number
6742 ,p_effective_date in date
6743 ) is
6744 select ele.element_entry_id,
6745 ele.effective_start_date,
6746 ele.effective_end_date,
6747 ele.object_version_number
6748 from pay_element_entries_f ele,
6749 pay_element_links_f elk
6750 where p_effective_date between ele.effective_start_date
6751 and ele.effective_end_date
6752 and ele.assignment_id = p_assignment_id
6753 and ele.element_link_id = elk.element_link_id
6754 and ele.effective_start_date between elk.effective_start_date
6755 and elk.effective_end_date
6756 and elk.element_type_id = p_element_type_id
6757 and ele.creator_type ='F'
6758 and ele.entry_type = 'E'
6759 and nvl(ele.creator_id,-1) <> p_prtt_enrt_rslt_id
6760 order by ele.effective_start_date desc;
6761 l_current_ee_rec c_current_ee%rowtype;
6762 --
6763 cursor c_min_max_dt(p_element_entry_id number) is
6764 select min(effective_start_date),
6765 max(effective_end_date)
6766 from pay_element_entries_f
6767 where element_entry_id = p_element_entry_id;
6768 --
6769 cursor c_chk_abs_ler (c_per_in_ler_id number,
6770 c_effective_date date) is
6771 select pil.per_in_ler_id,
6772 pil.trgr_table_pk_id,
6773 ler.ler_id
6774 from ben_per_in_ler pil,
6775 ben_ler_f ler
6776 where pil.per_in_ler_id = c_per_in_ler_id
6777 and ler.ler_id = pil.ler_id
6778 and ler.typ_cd ='ABS'
6779 and c_effective_date between
6780 ler.effective_start_date and ler.effective_end_date;
6781 --
6782 -- bug 7206471
6783 --
6784 Cursor c_adjust_exists is
6785 select leclr.*
6786 from ben_le_clsn_n_rstr leclr
6787 ,ben_prtt_rt_val prv
6788 ,ben_acty_base_rt_f abr
6789 where bkup_tbl_typ_cd = 'BEN_PRTT_RT_VAL_ADJ'
6790 and bkup_tbl_id = prv.prtt_rt_val_id
6791 and prv.acty_base_rt_id = abr.acty_base_rt_id
6792 and abr.element_type_id = p_element_type_id;
6793 --
6794 l_adjust_exists ben_le_clsn_n_rstr%rowtype;
6795 --
6796 -- -- bug 7206471
6797 --
6798 l_prtt_enrt_rslt_id number;
6799 l_absence_attendance_id number;
6800 l_per_in_ler_id number;
6801 l_ler_id number;
6802 l_abs_ler boolean := false;
6803 l_input_value_id number;
6804 l_input_va_calc_rl number;
6805 l_element_entry_id NUMBER;
6806 l_screen_entry_value NUMBER;
6807 l_ext_chg_evt_log_id NUMBER;
6808 l_ext_object_version_number NUMBER;
6809 l_object_version_number NUMBER;
6810 l_effective_start_date DATE;
6811 l_effective_end_date DATE;
6812 l_effective_date DATE;
6813 l_assignment_id NUMBER;
6814 l_organization_id NUMBER;
6815 l_payroll_id NUMBER;
6816 l_delete_warning BOOLEAN;
6817 l_dummy_number number;
6818 l_ele_rqd_flag VARCHAR2(30);
6819 l_jurisdiction_code varchar2(30);
6820 l_subpriority number;
6821 l_err_code varchar2(10);
6822 l_err_mesg varchar2(2000);
6823 l_update_warning boolean;
6824 l_create_ee boolean := false;
6825 l_create_warning boolean;
6826 l_dummy_date date;
6827 l_out_date_not_required date;
6828 l_asg_max_eligibility_date date;
6829 l_element_term_rule_date date;
6830 l_element_link_end_date date;
6831 l_element_name varchar2(80);
6832 l_recurring_end_date date;
6833 l_element_link_id number;
6834 l_element_type_id number;
6835 l_multiple_entries_flag varchar2(1);
6836 l_new_element_link_id number;
6837 l_encoded_message varchar2(2000);
6838 l_app_short_name varchar2(2000);
6839 l_message_name varchar2(2000);
6840 l_dt_del_mode varchar2(30);
6841 l_prv_ovn number;
6842 l_inpval_tab inpval_tab_typ;
6843 l_string varchar2(4000);
6844 l_min_start_date date;
6845 l_max_end_date date;
6846 l_proc VARCHAR2(72) := g_package||'reopen_closed_enrollment';
6847
6848 -- 3266166
6849 l_uom varchar2(30);
6850 l_screen_entry_value_var varchar2(60);
6851 l_recompute_proration boolean := false;
6852 l_v2dummy varchar2(30);
6853 l_date date;
6854 --
6855
6856
6857 begin
6858 g_debug := hr_utility.debug_enabled;
6859 if g_debug then
6860 hr_utility.set_location('Entering: '||l_proc,5);
6861 hr_utility.set_location('p_eff_dt: '||to_char(p_effective_date),5);
6862 hr_utility.set_location('p_prtt_rt_val_id: '||p_prtt_rt_val_id,5);
6863 end if;
6864 --
6865 --BUG 3167959 We need to intialize the pl/sql table
6866 clear_ext_inpval_tab ;
6867 --
6868 -- get prv info
6869 --
6870 open c_get_prtt_rt_val
6871 (c_prtt_rt_val_id => p_prtt_rt_val_id
6872 );
6873 fetch c_get_prtt_rt_val into l_prv_rec;
6874 if c_get_prtt_rt_val%notfound
6875 then
6876 --
6877 if g_debug then
6878 hr_utility.set_location('BEN_92103_NO_PRTT_RT_VAL',170);
6879 end if;
6880 close c_get_prtt_rt_val;
6881 --
6882 fnd_message.set_name('BEN', 'BEN_92103_NO_PRTT_RT_VAL');
6883 fnd_message.set_token('PROC',l_proc);
6884 fnd_message.set_token('PRTT_RT_VAL',to_char(p_prtt_rt_val_id));
6885 fnd_message.raise_error;
6886 --
6887 end if;
6888 close c_get_prtt_rt_val;
6889 --
6890 -- if no element entry was created to start with, just return
6891 --
6892 if l_prv_rec.element_entry_value_id is null then
6893 if g_debug then
6894 hr_utility.set_location('No entry. Leaving: '||l_proc,60);
6895 end if;
6896 return;
6897 end if;
6898 --
6899 -- get activity base rate information
6900 --
6901 open get_abr_info(l_prv_rec.acty_base_rt_id,
6902 l_prv_rec.rt_strt_dt);
6903 fetch get_abr_info into l_abr_info;
6904 if get_abr_info%notfound then
6905 close get_abr_info;
6906 if g_debug then
6907 hr_utility.set_location('BEN_91723_NO_ENRT_RT_ABR_FOUND',30);
6908 end if;
6909 fnd_message.set_name('BEN','BEN_91723_NO_ENRT_RT_ABR_FOUND');
6910 fnd_message.set_token('PROC',l_proc);
6911 fnd_message.set_token('ACTY_BASE_RT_ID',to_char(p_acty_base_rt_id));
6912 fnd_message.set_token('EFFECTIVE_DATE',to_char(p_effective_date));
6913 fnd_message.raise_error;
6914 end if;
6915 close get_abr_info;
6916 --
6917 -- get the element type and input value based on entry value attached to
6918 -- prtt rt. Do NOT get them from abr for reopening
6919 --
6920 hr_utility.set_location('p_person_id: '||p_person_id,5);
6921 hr_utility.set_location('prtt_enrt_rslt_id: '||l_prv_rec.prtt_enrt_rslt_id,5);
6922 hr_utility.set_location('l_prv_rec.element_entry_value_id: '||l_prv_rec.element_entry_value_id,5);
6923
6924 open c_ele_info(p_person_id,
6925 l_prv_rec.prtt_enrt_rslt_id,
6926 l_prv_rec.element_entry_value_id);
6927 fetch c_ele_info into
6928 l_element_entry_id,
6929 l_assignment_id,
6930 l_payroll_id,
6931 l_element_name,
6932 l_multiple_entries_flag,
6933 l_element_type_id,
6934 l_input_value_id;
6935 close c_ele_info;
6936
6937 if g_debug then
6938 hr_utility.set_location(' l_asg_id: '||l_assignment_id,50);
6939 hr_utility.set_location(' p_elt_id: '||l_element_type_id,50);
6940 hr_utility.set_location(' p_inp_val: '||l_input_value_id,50);
6941 hr_utility.set_location(' l_ele_id: '||l_element_entry_id,50);
6942 hr_utility.set_location(' l_ele_id: '||l_element_entry_id,50);
6943 end if;
6944 --
6945 -- If the abr has proration defined we will need to recompute
6946 -- the prorated amounts
6947 --
6948 -- This still does not address the case, where there is a special pp
6949 -- because of rounding. Will address that issue in a future version
6950 --
6951 hr_utility.set_location('prtl_mo_det_mthd_cd: '||l_abr_info.prtl_mo_det_mthd_cd,50);
6952 if nvl(l_abr_info.prtl_mo_det_mthd_cd,'NONE') <> 'NONE' then
6953 l_recompute_proration := true;
6954 end if;
6955
6956 -- <ELE>
6957 if l_element_entry_id is null or
6958 l_recompute_proration then
6959 --
6960 -- This is for the case when the entry attached to prtt rt got zapped.
6961 -- Possible 1) prior to FP C when ct. could delete the entries
6962 -- 2) prior to retro pay changes
6963 --
6964 -- Also for the case when we need to recompute prorated amounts
6965 --
6966 get_abr_assignment (p_person_id => p_person_id
6967 ,p_effective_date => l_prv_rec.rt_strt_dt
6968 ,p_acty_base_rt_id => l_prv_rec.acty_base_rt_id
6969 ,p_organization_id => l_dummy_number
6970 ,p_payroll_id => l_payroll_id
6971 ,p_assignment_id => l_assignment_id);
6972
6973 open c_current_ee(l_abr_info.element_type_id,
6974 l_prv_rec.prtt_enrt_rslt_id,
6975 l_assignment_id,
6976 l_prv_rec.rt_strt_dt);
6977 fetch c_current_ee into l_current_ee_rec;
6978 close c_current_ee;
6979 --
6980 if l_element_entry_id is null and
6981 l_current_ee_rec.element_entry_id is not null then
6982 --
6983 -- Determine dt track mode.
6984 --
6985 open c_min_max_dt(l_current_ee_rec.element_entry_id);
6986 fetch c_min_max_dt into l_min_start_date,l_max_end_date;
6987 close c_min_max_dt;
6988
6989 if l_prv_rec.rt_strt_dt-1 < l_min_start_date then
6990 l_dt_del_mode := hr_api.g_zap;
6991 else
6992 l_dt_del_mode := hr_api.g_delete;
6993 end if;
6994
6995 l_effective_date :=
6996 greatest(l_current_ee_rec.effective_start_date,l_prv_rec.rt_strt_dt -1);
6997
6998 py_element_entry_api.delete_element_entry
6999 (p_validate =>p_validate
7000 ,p_datetrack_delete_mode =>l_dt_del_mode
7001 ,p_effective_date =>l_effective_date
7002 ,p_element_entry_id =>l_current_ee_rec.element_entry_id
7003 ,p_object_version_number =>l_current_ee_rec.object_version_number
7004 ,p_effective_start_date =>l_dummy_date
7005 ,p_effective_end_date =>l_dummy_date
7006 ,p_delete_warning =>l_delete_warning);
7007 --
7008 -- write to the change event log
7009 --
7010 ben_ext_chlg.log_element_chg(
7011 p_action => hr_api.g_delete,
7012 p_old_amt => null,
7013 p_input_value_id => l_abr_info.input_value_id,
7014 p_element_entry_id => l_current_ee_rec.element_entry_id,
7015 p_person_id => p_person_id,
7016 p_business_group_id => p_business_group_id,
7017 p_effective_date => l_prv_rec.rt_strt_dt -1 );
7018
7019 end if;
7020 --
7021 create_enrollment_element
7022 (p_business_group_id => p_business_group_id
7023 ,p_prtt_rt_val_id => p_prtt_rt_val_id
7024 ,p_person_id => p_person_id
7025 ,p_acty_ref_perd => l_prv_rec.acty_ref_perd_cd
7026 ,p_acty_base_rt_id => l_prv_rec.acty_base_rt_id
7027 ,p_enrt_rslt_id => l_prv_rec.prtt_enrt_rslt_id
7028 ,p_rt_start_date => l_prv_rec.rt_strt_dt
7029 ,p_rt => l_prv_rec.rt_val
7030 ,p_cmncd_rt => l_prv_rec.cmcd_rt_val
7031 ,p_ann_rt => l_prv_rec.ann_rt_val
7032 ,p_input_value_id => l_abr_info.input_value_id
7033 ,p_element_type_id => l_abr_info.element_type_id
7034 ,p_prv_object_version_number=> l_prv_ovn
7035 ,p_effective_date => l_prv_rec.rt_strt_dt
7036 ,p_eev_screen_entry_value => l_dummy_number
7037 ,p_element_entry_value_id => l_dummy_number
7038 );
7039 else
7040 --
7041 -- get the element entry that needs to be reopened. This entry could be
7042 -- different from what is attached to prtt rt
7043 --
7044 if g_debug then
7045 hr_utility.set_location('enrt_rslt_id='||l_prv_rec.prtt_enrt_rslt_id,10);
7046 hr_utility.set_location('rt_strt_dt='||l_prv_rec.rt_strt_dt,10);
7047 end if;
7048
7049 open get_last_element_entry(l_element_type_id,
7050 l_input_value_id,
7051 l_assignment_id,
7052 l_prv_rec.prtt_enrt_rslt_id,
7053 l_prv_rec.rt_strt_dt);
7054 fetch get_last_element_entry into
7055 l_element_entry_id
7056 ,l_element_link_id
7057 ,l_effective_start_date
7058 ,l_effective_end_date
7059 ,l_screen_entry_value_var
7060 ,l_object_version_number;
7061
7062 -- 3266166
7063 hr_utility.set_location('l_screen_entry_value_var='||l_screen_entry_value_var,10);
7064 --
7065 if l_uom is null then
7066 if nvl(g_result_rec.prtt_enrt_rslt_id,-1)<>l_prv_rec.prtt_enrt_rslt_id
7067 then
7068 open c_current_result_info (c_prtt_enrt_rslt_id => l_prv_rec.prtt_enrt_rslt_id);
7069 fetch c_current_result_info into g_result_rec;
7070 close c_current_result_info;
7071 end if;
7072 --
7073 if g_result_rec.uom is not null
7074 then
7075 l_uom := g_result_rec.uom;
7076 else
7077 l_uom := get_uom(p_business_group_id,p_effective_date);
7078 end if;
7079 end if;
7080 --
7081 l_screen_entry_value := chkformat(l_screen_entry_value_var, l_uom);
7082 hr_utility.set_location('l_screen_entry_value='||l_screen_entry_value,10);
7083 --
7084 if get_last_element_entry%notfound
7085 then
7086 if g_debug then
7087 hr_utility.set_location('BEN_92105_NO_PRIOR_ENROLLMENT',40);
7088 end if;
7089 close get_last_element_entry;
7090 fnd_message.set_name('BEN', 'BEN_92105_NO_PRIOR_ENROLLMENT');
7091 fnd_message.set_token('PROC',l_proc);
7092 fnd_message.set_token('ELEMENT_TYPE_ID',to_char(l_element_type_id));
7093 fnd_message.set_token('ASSGN_ID',to_char(l_assignment_id));
7094 fnd_message.set_token('PRTT_RT_VAL_ID',to_char(p_prtt_rt_val_id));
7095 fnd_message.raise_error;
7096 --
7097 end if;
7098 close get_last_element_entry;
7099
7100 if g_debug then
7101 hr_utility.set_location(' l_ele_id: '||l_element_entry_id,50);
7102 hr_utility.set_location(' l_esd: '||l_effective_start_date,50);
7103 hr_utility.set_location(' l_eed: '||l_effective_end_date,50);
7104 end if;
7105
7106 l_effective_date := l_effective_end_date;
7107 g_max_end_date := null;
7108 --
7109 -- for quick pay fix
7110 --
7111 --Bug 3151737 and 3063518 we need to do this if payroll exists for the
7112 --assignment else skip this part.
7113 --
7114 if l_payroll_id is not null then
7115 --
7116 if nvl(g_per_pay_rec.assignment_id,-1) <> l_assignment_id then
7117 --
7118 open c_payroll_was_ever_run
7119 (c_assignment_id => l_assignment_id
7120 );
7121 fetch c_payroll_was_ever_run into l_v2dummy;
7122 g_per_pay_rec.assignment_id := l_assignment_id;
7123 g_per_pay_rec.payroll_was_ever_run := c_payroll_was_ever_run%found;
7124 close c_payroll_was_ever_run;
7125 --
7126 end if;
7127 --
7128 if g_per_pay_rec.payroll_was_ever_run and
7129 g_per_pay_rec.end_date is null then
7130 --
7131 g_max_end_date :=
7132 get_max_end_dt (
7133 p_assignment_id => l_assignment_id,
7134 p_payroll_id => l_payroll_id,
7135 p_element_type_id => l_element_type_id,
7136 p_effective_date => l_effective_date);
7137 --
7138 g_per_pay_rec.end_date := g_max_end_date;
7139 --
7140 elsif g_per_pay_rec.end_date is not null then
7141 g_max_end_date := g_per_pay_rec.end_date;
7142 end if;
7143
7144 if g_max_end_date > l_effective_date then
7145 -- insert rows into pay_quickpay_inclusions
7146 insert_into_quick_pay
7147 (p_person_id => p_person_id,
7148 p_element_type_id => l_element_type_id,
7149 p_assignment_id => l_assignment_id,
7150 p_element_entry_id => l_element_entry_id,
7151 p_effective_date => l_effective_date,
7152 p_start_date => l_effective_date,
7153 p_end_date => g_max_end_date,
7154 p_payroll_id => l_payroll_id);
7155 --
7156 end if;
7157 --
7158 end if ; -- l_payroll_id
7159 --
7160 hr_entry.entry_asg_pay_link_dates (l_assignment_id,
7161 l_element_link_id,
7162 l_effective_start_date,
7163 l_element_term_rule_date,
7164 l_out_date_not_required,
7165 l_element_link_end_date,
7166 l_out_date_not_required,
7167 l_out_date_not_required);
7168
7169 --
7170 --
7171 if g_debug then
7172 hr_utility.set_location('l_element_term_rule_date '||l_element_term_rule_date,44333);
7173 hr_utility.set_location('l_element_link_end_date '||l_element_link_end_date,44333);
7174 hr_utility.set_location('l_effective_date '||l_effective_date,44333);
7175 end if;
7176 -- Call update
7177 --
7178 /*
7179 Before :-
7180 02-JAN-1994 05-FEB-1994 08-AUG-1995
7181 |-A----------|-B----------------------|
7182 ED
7183 After :-
7184 02-JAN-1994 05-FEB-1994
7185 |-A----------|-E------------------------------------------------->
7186 ED
7187 */
7188 if g_debug then
7189 hr_utility.set_location(' l_element_entry_id: '||l_element_entry_id,50);
7190 hr_utility.set_location(' l_effective_date: '||l_effective_date,50);
7191 hr_utility.set_location(' l_ovn: '||l_object_version_number,50);
7192 end if;
7193 --
7194
7195 -- <REOPEN>
7196 if l_effective_date <> hr_api.g_eot then
7197 --
7198 -- check if abs ler
7199 --
7200 open c_chk_abs_ler
7201 (c_per_in_ler_id => l_prv_rec.per_in_ler_id
7202 ,c_effective_date => p_effective_date
7203 );
7204 fetch c_chk_abs_ler into
7205 l_per_in_ler_id,
7206 l_absence_attendance_id,
7207 l_ler_id;
7208 l_abs_ler := c_chk_abs_ler%found;
7209 close c_chk_abs_ler;
7210
7211 --
7212 -- handle any future entries
7213 --
7214 open c_adjust_exists; -- bug 7206471
7215 fetch c_adjust_exists into l_adjust_exists; -- bug 7206471
7216 if c_adjust_exists%notfound then -- bug 7206471
7217 if not l_abs_ler then
7218 chk_future_entries
7219 (p_validate => p_validate,
7220 p_person_id => p_person_id,
7221 p_assignment_id => l_assignment_id,
7222 p_enrt_rslt_id => l_prv_rec.prtt_enrt_rslt_id,
7223 p_element_type_id => l_element_type_id,
7224 p_multiple_entries_flag => l_multiple_entries_flag,
7225 p_effective_date => l_effective_date);
7226 end if;
7227 end if; -- bug 7206471
7228 close c_adjust_exists; -- bug 7206471
7229
7230 if l_element_link_end_date <> l_effective_date and
7231 l_element_term_rule_date <> l_effective_date then
7232
7233 begin
7234 --
7235 hr_utility.set_location('before pay.delete l_effective_date '||l_effective_date,44333);
7236 --
7237 py_element_entry_api.delete_element_entry
7238 (p_validate =>p_validate
7239 ,p_datetrack_delete_mode =>'FUTURE_CHANGE'
7240 ,p_effective_date =>l_effective_date
7241 ,p_element_entry_id =>l_element_entry_id
7242 ,p_object_version_number =>l_object_version_number
7243 ,p_effective_start_date =>l_effective_start_date
7244 ,p_effective_end_date =>l_effective_end_date
7245 ,p_delete_warning =>l_delete_warning);
7246 --
7247 hr_utility.set_location('after pay.delete l_effective_date '||l_effective_date,44333);
7248 hr_utility.set_location('l_effective_end_date '||l_effective_end_date,44333);
7249 --
7250 l_effective_date := l_effective_end_date;
7251 --
7252 -- write to the change event log
7253 --
7254 ben_ext_chlg.log_element_chg(
7255 p_action => hr_api.g_delete,
7256 p_old_amt => null,
7257 p_input_value_id => l_input_value_id,
7258 p_element_entry_id => l_element_entry_id,
7259 p_person_id => p_person_id,
7260 p_business_group_id => p_business_group_id,
7261 p_effective_date => l_effective_date);
7262 --
7263 exception
7264 when others then
7265 ben_on_line_lf_evt.get_ser_message(l_encoded_message,
7266 l_app_short_name,
7267 l_message_name);
7268 l_encoded_message := fnd_message.get;
7269 --
7270 if l_message_name like '%HR_6284_ELE_ENTRY_DT_ASG_DEL%' or
7271 l_message_name like '%HR_7187_DT_CANNOT_EXTEND_END%' then
7272 --
7273 --asg is not eligible for link beyond l_effective_date
7274 --
7275 null;
7276 else
7277 if l_app_short_name is not null then
7278 fnd_message.set_name(l_app_short_name,l_message_name);
7279 fnd_message.raise_error;
7280 else
7281 raise;
7282 end if;
7283 end if;
7284 end;
7285 end if;
7286 --
7287 loop
7288
7289 if l_effective_date = l_element_term_rule_date then
7290 --
7291 -- Element entry created till the max possible date.
7292 --
7293 exit;
7294 end if;
7295
7296 if l_abs_ler then
7297 -- bug # 7383673, 7390204 -- restricting bug 6450363 fix only for absences
7298
7299 -- added here for bug 6450363
7300
7301 l_date := l_effective_date + 1;
7302 if g_debug then
7303 hr_utility.set_location('l_effective_date '||l_effective_date,44333);
7304 hr_utility.set_location('l_effective_date + 1 '||l_date,44333);
7305 end if;
7306
7307 get_abr_assignment (p_person_id => p_person_id
7308 ,p_effective_date => l_effective_date + 1
7309 ,p_acty_base_rt_id => l_prv_rec.acty_base_rt_id
7310 ,p_organization_id => l_dummy_number
7311 ,p_payroll_id => l_payroll_id
7312 ,p_assignment_id => l_assignment_id);
7313
7314 --added till here for bug 6450363
7315 end if;
7316
7317 get_link
7318 (p_assignment_id => l_assignment_id
7319 ,p_element_type_id => l_element_type_id
7320 ,p_business_group_id => p_business_group_id
7321 ,p_input_value_id => l_input_value_id
7322 ,p_effective_date => l_effective_date + 1
7323 ,p_element_link_id => l_new_element_link_id);
7324
7325 if l_new_element_link_id = l_element_link_id or
7326 l_new_element_link_id is null then
7327 --
7328 -- No new link found. Get out of the loop
7329 --
7330 exit;
7331 end if;
7332
7333 if nvl(l_inpval_tab.count,0) = 0 then
7334 get_inpval_tab(l_element_entry_id,
7335 l_effective_date,
7336 l_inpval_tab);
7337 end if;
7338
7339 l_element_link_id := l_new_element_link_id;
7340 l_effective_date := l_effective_date + 1;
7341
7342 py_element_entry_api.create_element_entry
7343 (p_validate =>p_validate
7344 ,p_effective_date =>l_effective_date
7345 ,p_business_group_id =>p_business_group_id
7346 ,p_assignment_id =>l_assignment_id
7347 ,p_element_link_id =>l_element_link_id
7348 ,p_entry_type =>'E'
7349 ,p_override_user_ent_chk =>'Y'
7350 ,p_subpriority =>l_subpriority
7351 ,p_input_value_id1 =>l_inpval_tab(1).input_value_id
7352 ,p_entry_value1 =>l_inpval_tab(1).value
7353 ,p_input_value_id2 =>l_inpval_tab(2).input_value_id
7354 ,p_entry_value2 =>l_inpval_tab(2).value
7355 ,p_input_value_id3 =>l_inpval_tab(3).input_value_id
7356 ,p_entry_value3 =>l_inpval_tab(3).value
7357 ,p_input_value_id4 =>l_inpval_tab(4).input_value_id
7358 ,p_entry_value4 =>l_inpval_tab(4).value
7359 ,p_input_value_id5 =>l_inpval_tab(5).input_value_id
7360 ,p_entry_value5 =>l_inpval_tab(5).value
7361 ,p_input_value_id6 =>l_inpval_tab(6).input_value_id
7362 ,p_entry_value6 =>l_inpval_tab(6).value
7363 ,p_input_value_id7 =>l_inpval_tab(7).input_value_id
7364 ,p_entry_value7 =>l_inpval_tab(7).value
7365 ,p_input_value_id8 =>l_inpval_tab(8).input_value_id
7366 ,p_entry_value8 =>l_inpval_tab(8).value
7367 ,p_input_value_id9 =>l_inpval_tab(9).input_value_id
7368 ,p_entry_value9 =>l_inpval_tab(9).value
7369 ,p_input_value_id10 =>l_inpval_tab(10).input_value_id
7370 ,p_entry_value10 =>l_inpval_tab(10).value
7371 ,p_input_value_id11 =>l_inpval_tab(11).input_value_id
7372 ,p_entry_value11 =>l_inpval_tab(11).value
7373 ,p_input_value_id12 =>l_inpval_tab(12).input_value_id
7374 ,p_entry_value12 =>l_inpval_tab(12).value
7375 ,p_input_value_id13 =>l_inpval_tab(13).input_value_id
7376 ,p_entry_value13 =>l_inpval_tab(13).value
7377 ,p_input_value_id14 =>l_inpval_tab(14).input_value_id
7378 ,p_entry_value14 =>l_inpval_tab(14).value
7379 ,p_input_value_id15 =>l_inpval_tab(15).input_value_id
7380 ,p_entry_value15 =>l_inpval_tab(15).value
7381 ,p_effective_start_date =>l_effective_start_date
7382 ,p_effective_end_date =>l_effective_end_date
7383 ,p_element_entry_id =>l_element_entry_id
7384 ,p_object_version_number =>l_object_version_number
7385 ,p_create_warning =>l_create_warning
7386 );
7387
7388 py_element_entry_api.update_element_entry
7389 (p_validate =>p_validate
7390 ,p_datetrack_update_mode =>hr_api.g_correction
7391 ,p_effective_date =>l_effective_date
7392 ,p_business_group_id =>p_business_group_id
7393 ,p_element_entry_id =>l_element_entry_id
7394 ,p_override_user_ent_chk =>'Y'
7395 ,p_object_version_number =>l_object_version_number
7396 ,p_creator_type =>'F'
7397 ,p_creator_id =>l_prv_rec.prtt_enrt_rslt_id
7398 ,p_effective_start_date =>l_effective_start_date
7399 ,p_effective_end_date =>l_effective_end_date
7400 ,p_update_warning =>l_update_warning
7401 );
7402 --
7403 -- write to the change event log
7404 --
7405 ben_ext_chlg.log_element_chg(
7406 p_action => 'CREATE',
7407 p_amt => l_screen_entry_value,
7408 p_input_value_id => l_input_value_id,
7409 p_element_entry_id => l_element_entry_id,
7410 p_person_id => p_person_id,
7411 p_business_group_id => p_business_group_id,
7412 p_effective_date => l_effective_date);
7413 --
7414
7415 l_effective_date := l_effective_end_date;
7416
7417 end loop;
7418
7419 if l_effective_date <> hr_api.g_eot then
7420
7421 if l_effective_date < l_element_term_rule_date then
7422 l_message_name := 'BEN_93454_NO_ELK_TILL_EOT';
7423 else
7424 l_message_name := 'BEN_93449_NO_ELE_TILL_EOT';
7425 end if;
7426
7427 --
7428 ben_warnings.load_warning
7429 (p_application_short_name => 'BEN',
7430 p_message_name => l_message_name,
7431 p_parma => l_element_name,
7432 p_parmb => to_char(l_effective_date),
7433 p_person_id => p_person_id);
7434 --
7435 if fnd_global.conc_request_id in ( 0,-1) then
7436 --
7437 fnd_message.set_name('BEN',l_message_name);
7438 fnd_message.set_token('PARMA',l_element_name);
7439 fnd_message.set_token('PARMB',to_char(l_effective_date));
7440 l_string := fnd_message.get;
7441 benutils.write(p_text => l_string);
7442 --
7443 end if;
7444
7445 end if;
7446 -- <ABS>
7447 if l_abs_ler then
7448
7449 if nvl(g_result_rec.prtt_enrt_rslt_id,-1)<>l_prv_rec.prtt_enrt_rslt_id then
7450 open c_current_result_info
7451 (c_prtt_enrt_rslt_id => l_prv_rec.prtt_enrt_rslt_id
7452 );
7453 fetch c_current_result_info into g_result_rec;
7454 close c_current_result_info;
7455 end if;
7456
7457 get_extra_ele_inputs
7458 (p_effective_date => l_effective_date
7459 ,p_person_id => p_person_id
7460 ,p_business_group_id => p_business_group_id
7461 ,p_assignment_id => l_assignment_id
7462 ,p_element_link_id => null
7463 ,p_entry_type => 'E'
7464 ,p_input_value_id1 => l_input_value_id
7465 ,p_entry_value1 => l_screen_entry_value
7466 ,p_element_entry_id => l_element_entry_id
7467 ,p_acty_base_rt_id => p_acty_base_rt_id
7468 ,p_input_va_calc_rl => l_abr_info.input_va_calc_rl
7469 ,p_abs_ler => l_abs_ler
7470 ,p_organization_id => l_organization_id
7471 ,p_payroll_id => l_payroll_id
7472 ,p_pgm_id => g_result_rec.pgm_id
7473 ,p_pl_id => g_result_rec.pl_id
7474 ,p_pl_typ_id => g_result_rec.pl_typ_id
7475 ,p_opt_id => g_result_rec.opt_id
7476 ,p_ler_id => l_ler_id
7477 ,p_dml_typ => 'U'
7478 ,p_jurisdiction_code => l_jurisdiction_code
7479 ,p_ext_inpval_tab => g_ext_inpval_tab
7480 ,p_subpriority => l_subpriority
7481 );
7482
7483 py_element_entry_api.update_element_entry
7484 (p_validate =>p_validate
7485 ,p_datetrack_update_mode =>hr_api.g_correction
7486 ,p_effective_date =>l_effective_date
7487 ,p_business_group_id =>p_business_group_id
7488 ,p_element_entry_id =>l_element_entry_id
7489 ,p_object_version_number =>l_object_version_number
7490 ,p_creator_type =>'F'
7491 ,p_creator_id =>l_prv_rec.prtt_enrt_rslt_id
7492 ,p_subpriority =>l_subpriority
7493 ,p_override_user_ent_chk =>'Y'
7494 ,p_input_value_id1 =>g_ext_inpval_tab(1).input_value_id
7495 ,p_entry_value1 =>g_ext_inpval_tab(1).return_value
7496 ,p_input_value_id2 =>g_ext_inpval_tab(2).input_value_id
7497 ,p_entry_value2 =>g_ext_inpval_tab(2).return_value
7498 ,p_input_value_id3 =>g_ext_inpval_tab(3).input_value_id
7499 ,p_entry_value3 =>g_ext_inpval_tab(3).return_value
7500 ,p_input_value_id4 =>g_ext_inpval_tab(4).input_value_id
7501 ,p_entry_value4 =>g_ext_inpval_tab(4).return_value
7502 ,p_input_value_id5 =>g_ext_inpval_tab(5).input_value_id
7503 ,p_entry_value5 =>g_ext_inpval_tab(5).return_value
7504 ,p_input_value_id6 =>g_ext_inpval_tab(6).input_value_id
7505 ,p_entry_value6 =>g_ext_inpval_tab(6).return_value
7506 ,p_input_value_id7 =>g_ext_inpval_tab(7).input_value_id
7507 ,p_entry_value7 =>g_ext_inpval_tab(7).return_value
7508 ,p_input_value_id8 =>g_ext_inpval_tab(8).input_value_id
7509 ,p_entry_value8 =>g_ext_inpval_tab(8).return_value
7510 ,p_input_value_id9 =>g_ext_inpval_tab(9).input_value_id
7511 ,p_entry_value9 =>g_ext_inpval_tab(9).return_value
7512 ,p_input_value_id10 =>g_ext_inpval_tab(10).input_value_id
7513 ,p_entry_value10 =>g_ext_inpval_tab(10).return_value
7514 ,p_input_value_id11 =>g_ext_inpval_tab(11).input_value_id
7515 ,p_entry_value11 =>g_ext_inpval_tab(11).return_value
7516 ,p_input_value_id12 =>g_ext_inpval_tab(12).input_value_id
7517 ,p_entry_value12 =>g_ext_inpval_tab(12).return_value
7518 ,p_input_value_id13 =>g_ext_inpval_tab(13).input_value_id
7519 ,p_entry_value13 =>g_ext_inpval_tab(13).return_value
7520 ,p_input_value_id14 =>g_ext_inpval_tab(14).input_value_id
7521 ,p_entry_value14 =>g_ext_inpval_tab(14).return_value
7522 ,p_effective_start_date =>l_effective_start_date
7523 ,p_effective_end_date =>l_effective_end_date
7524 ,p_update_warning =>l_update_warning
7525 );
7526
7527 pqp_absence_plan_process.update_absence_plan_details
7528 (p_person_id => p_person_id
7529 ,p_assignment_id => l_assignment_id
7530 ,p_business_group_id => p_business_group_id
7531 ,p_legislation_code => get_legislation_code(p_business_group_id)
7532 ,p_effective_date => l_effective_date
7533 ,p_element_type_id => l_element_type_id
7534 ,p_pl_id => g_result_rec.pl_id
7535 ,p_pl_typ_id => g_result_rec.pl_typ_id
7536 ,p_ler_id => l_ler_id
7537 ,p_per_in_ler_id => l_per_in_ler_id
7538 ,p_absence_attendance_id => l_absence_attendance_id
7539 ,p_effective_start_date => l_effective_start_date
7540 ,p_effective_end_date => l_effective_end_date
7541 ,p_formula_outputs => g_outputs
7542 ,p_error_code => l_err_code
7543 ,p_error_message => l_err_mesg
7544 );
7545 end if; -- <ABS>
7546 end if; -- <REOPEN>
7547 end if; -- <ELE>
7548 --
7549 if g_debug then
7550 hr_utility.set_location('Leaving: '||l_proc,60);
7551 end if;
7552 --
7553 end reopen_closed_enrollment;
7554 --
7555 -- ----------------------------------------------------------------------------
7556 -- |----------------------< recreate_enrollment_element >----------------------|
7557 -- ----------------------------------------------------------------------------
7558 procedure recreate_enrollment_element(p_validate IN BOOLEAN default FALSE
7559 ,p_business_group_id IN NUMBER
7560 ,p_person_id IN NUMBER
7561 ,p_enrt_rslt_id IN NUMBER
7562 ,p_acty_ref_perd in varchar2
7563 ,p_acty_base_rt_id in number
7564 ,p_element_entry_id IN NUMBER
7565 ,p_element_link_id IN NUMBER
7566 ,p_input_value_id IN NUMBER
7567 ,p_prtt_rt_val_id in number
7568 ,p_input_va_calc_rl in number
7569 ,p_abs_ler in boolean
7570 ,p_rt_strt_date in date
7571 ,p_rt_end_date IN DATE
7572 ,p_effective_date IN DATE
7573 ,p_amt in number
7574 ,p_object_version_number IN NUMBER) is
7575 cursor get_abr_info is
7576 select abr.prtl_mo_det_mthd_cd,
7577 abr.prtl_mo_det_mthd_rl,
7578 abr.wsh_rl_dy_mo_num,
7579 abr.prtl_mo_eff_dt_det_cd,
7580 abr.prtl_mo_eff_dt_det_rl,
7581 abr.acty_typ_cd,
7582 abr.element_type_id,
7583 abr.input_value_id,
7584 abr.input_va_calc_rl,
7585 abr.rndg_cd,
7586 abr.rndg_rl,
7587 abr.ele_rqd_flag,
7588 abr.one_ann_pymt_cd,
7589 abr.entr_ann_val_flag,
7590 abr.ele_entry_val_cd
7591 from ben_acty_base_rt_f abr
7592 where abr.acty_base_rt_id=p_acty_base_rt_id
7593 and abr.business_group_id=p_business_group_id
7594 and p_effective_date between
7595 abr.effective_start_date and abr.effective_end_date;
7596 --
7597 -- Get created element_entry_value_id
7598 --
7599 cursor get_created_entry_value
7600 (p_element_entry_id IN NUMBER
7601 ,p_input_value_id IN NUMBER
7602 ,p_effective_date IN DATE
7603 )
7604 is
7605 select element_entry_value_id
7606 from pay_element_entry_values_f
7607 where element_entry_id = p_element_entry_id
7608 and input_value_id = p_input_value_id
7609 and p_effective_date between effective_start_date
7610 and effective_end_date;
7611
7612 -- bug 5768050
7613 CURSOR c_ee_ovn (v_element_entry_id IN NUMBER)
7614 IS
7615 SELECT object_version_number
7616 FROM pay_element_entries_f
7617 WHERE element_entry_id = v_element_entry_id
7618 AND p_effective_date BETWEEN effective_start_date AND effective_end_date;
7619
7620 l_ovn pay_element_entries_f.object_version_number%TYPE;
7621
7622 -- end bug 5768050
7623
7624 l_per_month_amt number;
7625 l_assignment_id number;
7626 l_payroll_id number;
7627 l_element_entry_id number;
7628 l_ext_chg_evt_log_id number;
7629 l_input_value_id number;
7630 l_input_va_calc_rl number;
7631 l_screen_entry_value varchar2(60);
7632 l_prv_object_version_number number;
7633 l_object_version_number number;
7634 l_ext_object_version_number number;
7635 l_rt number;
7636 l_effective_start_date date;
7637 l_effective_end_date date;
7638 l_rt_end_dt date;
7639 l_delete_warning boolean;
7640 l_proc varchar2(72) := g_package||'recreate_enrollment_element';
7641 l_organization_id number;
7642 l_immediate_end boolean:=false;
7643 l_prtl_mo_det_mthd_cd varchar2(30);
7644 l_prtl_mo_det_mthd_rl number;
7645 l_wsh_rl_dy_mo_num number;
7646 l_prtl_mo_eff_dt_det_cd varchar2(30);
7647 l_prtl_mo_eff_dt_det_rl number;
7648 l_per_pay_amt number;
7649 l_prorated_monthly_amt number;
7650 l_amt number;
7651 l_prtn_flag varchar2(1);
7652 l_acty_typ_cd varchar2(30);
7653 l_element_type_id number;
7654 l_outputs ff_exec.outputs_t;
7655 l_remainder number;
7656 l_number_in_month number;
7657 l_old_normal_pp_date date;
7658 l_normal_pp_date date;
7659 l_special_pp_date date;
7660 l_old_normal_pp_end_date date;
7661 l_normal_pp_end_date date;
7662 l_special_pp_end_date date;
7663 l_zero_pp_date date default null;
7664 l_special_amt number;
7665 l_element_link_id number;
7666 l_entry_value_id number;
7667 l_start_date date;
7668 l_end_date date;
7669 l_update_ee boolean;
7670 l_curr_val number;
7671 l_new_date date;
7672 l_end_of_time date;
7673 l_create_warning boolean;
7674 l_update_warning boolean;
7675 l_jurisdiction_code varchar2(30);
7676 l_abr_rndg_cd varchar2(30);
7677 l_abr_rndg_rl number;
7678 l_ele_rqd_flag varchar2(30);
7679 l_one_ann_pymt_cd varchar2(30);
7680 l_entr_ann_val_flag varchar2(30);
7681 l_ele_entry_val_cd varchar2(30);
7682 l_last_pp_strt_dt date;
7683 l_last_pp_end_dt date;
7684 l_range_start date;
7685 l_ee_start_date date;
7686 l_cnt number;
7687 l_correction boolean;
7688 l_update boolean;
7689 l_update_override boolean;
7690 l_update_change_insert boolean;
7691 l_dt_upd_mode varchar2(30);
7692 l_element_entry_start_date date;
7693 l_perd_cd varchar2(30) := 'PP';
7694 l_subpriority number;
7695 l_override_user_ent_chk varchar2(30) := 'N';
7696
7697 begin
7698 if g_debug then
7699 hr_utility.set_location('Entering :'||l_proc,5);
7700 end if;
7701
7702 l_object_version_number := p_object_version_number;
7703 --
7704 if NOT (chk_assign_exists(p_person_id, p_business_group_id,
7705 p_effective_date, p_rt_end_date,
7706 p_acty_base_rt_id,
7707 l_assignment_id, l_organization_id,
7708 l_payroll_id)) then
7709
7710 if g_debug then
7711 hr_utility.set_location('BEN_92106_PRTT_NO_ASGN',5);
7712 end if;
7713 fnd_message.set_name('BEN', 'BEN_92106_PRTT_NO_ASGN');
7714 fnd_message.set_token('PROC',l_proc);
7715 fnd_message.set_token('PERSON_ID',to_char(p_person_id));
7716 fnd_message.set_token('EFFECTIVE_DATE',to_char(p_effective_date));
7717 fnd_message.raise_error;
7718
7719 end if;
7720 if g_debug then
7721 hr_utility.set_location('l_assignment_id='||l_assignment_id,6);
7722 end if;
7723 --
7724 -- get activity base rate information
7725 --
7726 open get_abr_info;
7727 fetch get_abr_info into l_prtl_mo_det_mthd_cd,
7728 l_prtl_mo_det_mthd_rl,
7729 l_wsh_rl_dy_mo_num,
7730 l_prtl_mo_eff_dt_det_cd,
7731 l_prtl_mo_eff_dt_det_rl,
7732 l_acty_typ_cd,
7733 l_element_type_id,
7734 l_input_value_id,
7735 l_input_va_calc_rl,
7736 l_abr_rndg_cd,
7737 l_abr_rndg_rl,
7738 l_ele_rqd_flag,
7739 l_one_ann_pymt_cd,
7740 l_entr_ann_val_flag,
7741 l_ele_entry_val_cd;
7742 if get_abr_info%notfound then
7743 close get_abr_info;
7744 if g_debug then
7745 hr_utility.set_location('BEN_91723_NO_ENRT_RT_ABR_FOUND',40);
7746 end if;
7747 fnd_message.set_name('BEN','BEN_91723_NO_ENRT_RT_ABR_FOUND');
7748 fnd_message.set_token('PROC',l_proc);
7749 fnd_message.set_token('ACTY_BASE_RT_ID',to_char(p_acty_base_rt_id));
7750 fnd_message.set_token('EFFECTIVE_DATE',to_char(p_effective_date));
7751 fnd_message.raise_error;
7752 end if;
7753 close get_abr_info;
7754 l_rt_end_dt := p_rt_end_date;
7755
7756 --
7757 -- ZAP the element entries
7758 --
7759 if g_debug then
7760 hr_utility.set_location('ZAP mode',10);
7761 end if;
7762
7763 py_element_entry_api.delete_element_entry
7764 (p_validate => p_validate
7765 ,p_datetrack_delete_mode => hr_api.g_zap
7766 ,p_effective_date => p_rt_strt_date
7767 ,p_element_entry_id => p_element_entry_id
7768 ,p_object_version_number => l_object_version_number
7769 ,p_effective_start_date => l_effective_start_date -- out parm
7770 ,p_effective_end_date => l_effective_end_date -- out parm
7771 ,p_delete_warning => l_delete_warning
7772 );
7773 -- write to the change event log
7774 --
7775 ben_ext_chlg.log_element_chg(
7776 p_action => hr_api.g_zap,
7777 p_old_amt => p_amt,
7778 p_input_value_id => p_input_value_id,
7779 p_element_entry_id => p_element_entry_id,
7780 p_person_id => p_person_id,
7781 p_business_group_id => p_business_group_id,
7782 p_effective_date => p_rt_strt_date);
7783 --
7784 -- recreate the element
7785 --
7786 get_extra_ele_inputs
7787 (p_effective_date => p_effective_date
7788 ,p_person_id => p_person_id
7789 ,p_business_group_id => p_business_group_id
7790 ,p_assignment_id => l_assignment_id
7791 ,p_element_link_id => p_element_link_id
7792 ,p_entry_type => 'E'
7793 ,p_input_value_id1 => p_input_value_id
7794 ,p_entry_value1 => p_amt
7795 ,p_element_entry_id => p_element_entry_id
7796 ,p_acty_base_rt_id => p_acty_base_rt_id
7797 ,p_input_va_calc_rl => p_input_va_calc_rl
7798 ,p_abs_ler => p_abs_ler
7799 ,p_organization_id => l_organization_id
7800 ,p_payroll_id => l_payroll_id
7801 ,p_pgm_id => g_result_rec.pgm_id
7802 ,p_pl_id => g_result_rec.pl_id
7803 ,p_pl_typ_id => g_result_rec.pl_typ_id
7804 ,p_opt_id => g_result_rec.opt_id
7805 ,p_ler_id => g_result_rec.ler_id
7806 ,p_dml_typ => 'C'
7807 ,p_jurisdiction_code => null
7808 ,p_ext_inpval_tab => g_ext_inpval_tab
7809 ,p_subpriority => l_subpriority
7810 );
7811
7812 if g_debug then
7813 hr_utility.set_location('Hits'||g_ext_inpval_tab.count,30);
7814 end if;
7815
7816 py_element_entry_api.create_element_entry
7817 (p_validate =>p_validate
7818 ,p_effective_date =>p_rt_strt_date
7819 ,p_business_group_id =>p_business_group_id
7820 ,p_assignment_id =>l_assignment_id
7821 ,p_element_link_id =>p_element_link_id
7822 ,p_entry_type =>'E'
7823 ,p_subpriority =>l_subpriority
7824 ,p_override_user_ent_chk =>'Y'
7825 ,p_input_value_id1 =>g_ext_inpval_tab(1).input_value_id
7826 ,p_entry_value1 =>g_ext_inpval_tab(1).return_value
7827 ,p_input_value_id2 =>g_ext_inpval_tab(2).input_value_id
7828 ,p_entry_value2 =>g_ext_inpval_tab(2).return_value
7829 ,p_input_value_id3 =>g_ext_inpval_tab(3).input_value_id
7830 ,p_entry_value3 =>g_ext_inpval_tab(3).return_value
7831 ,p_input_value_id4 =>g_ext_inpval_tab(4).input_value_id
7832 ,p_entry_value4 =>g_ext_inpval_tab(4).return_value
7833 ,p_input_value_id5 =>g_ext_inpval_tab(5).input_value_id
7834 ,p_entry_value5 =>g_ext_inpval_tab(5).return_value
7835 ,p_input_value_id6 =>g_ext_inpval_tab(6).input_value_id
7836 ,p_entry_value6 =>g_ext_inpval_tab(6).return_value
7837 ,p_input_value_id7 =>g_ext_inpval_tab(7).input_value_id
7838 ,p_entry_value7 =>g_ext_inpval_tab(7).return_value
7839 ,p_input_value_id8 =>g_ext_inpval_tab(8).input_value_id
7840 ,p_entry_value8 =>g_ext_inpval_tab(8).return_value
7841 ,p_input_value_id9 =>g_ext_inpval_tab(9).input_value_id
7842 ,p_entry_value9 =>g_ext_inpval_tab(9).return_value
7843 ,p_input_value_id10 =>g_ext_inpval_tab(10).input_value_id
7844 ,p_entry_value10 =>g_ext_inpval_tab(10).return_value
7845 ,p_input_value_id11 =>g_ext_inpval_tab(11).input_value_id
7846 ,p_entry_value11 =>g_ext_inpval_tab(11).return_value
7847 ,p_input_value_id12 =>g_ext_inpval_tab(12).input_value_id
7848 ,p_entry_value12 =>g_ext_inpval_tab(12).return_value
7849 ,p_input_value_id13 =>g_ext_inpval_tab(13).input_value_id
7850 ,p_entry_value13 =>g_ext_inpval_tab(13).return_value
7851 ,p_input_value_id14 =>g_ext_inpval_tab(14).input_value_id
7852 ,p_entry_value14 =>g_ext_inpval_tab(14).return_value
7853 ,p_input_value_id15 =>p_input_value_id
7854 ,p_entry_value15 =>p_amt
7855 ,p_effective_start_date =>l_effective_start_date
7856 ,p_effective_end_date =>l_effective_end_date
7857 ,p_element_entry_id =>l_element_entry_id
7858 ,p_object_version_number =>l_object_version_number
7859 ,p_create_warning =>l_create_warning
7860 );
7861
7862 py_element_entry_api.update_element_entry
7863 (p_validate =>p_validate
7864 ,p_datetrack_update_mode =>hr_api.g_correction
7865 ,p_effective_date =>p_rt_strt_date
7866 ,p_business_group_id =>p_business_group_id
7867 ,p_element_entry_id =>l_element_entry_id
7868 ,p_object_version_number =>l_object_version_number
7869 ,p_override_user_ent_chk =>'Y'
7870 ,p_creator_type =>'F'
7871 ,p_creator_id =>p_enrt_rslt_id
7872 ,p_effective_start_date =>l_effective_start_date
7873 ,p_effective_end_date =>l_effective_end_date
7874 ,p_update_warning =>l_update_warning
7875 );
7876
7877 if g_debug then
7878 hr_utility.set_location('Element entry Id '||l_element_entry_id,30);
7879 hr_utility.set_location('ee start date '||to_char(l_effective_start_date),30);
7880 hr_utility.set_location('ee end date '||to_char(l_effective_end_date),30);
7881 end if;
7882
7883 open get_created_entry_value(l_element_entry_id,p_input_value_id,
7884 p_rt_strt_date);
7885 --
7886 fetch get_created_entry_value into l_entry_value_id;
7887 --
7888 if get_created_entry_value%notfound then
7889 --
7890 if g_debug then
7891 hr_utility.set_location('no entry created',140);
7892 end if;
7893 close get_created_entry_value;
7894 --
7895 if g_debug then
7896 hr_utility.set_location('BEN_92102_NO_ENTRY_CREATED',140);
7897 end if;
7898 fnd_message.set_name('BEN', 'BEN_92102_NO_ENTRY_CREATED');
7899 fnd_message.set_token('PROC',l_proc);
7900 fnd_message.set_token('ELEMENT_ENTRY_ID',to_char(l_element_entry_id));
7901 fnd_message.set_token('INPUT_VALUE_ID',to_char(p_input_value_id));
7902 fnd_message.set_token('EFFECTIVE_DATE',to_char(p_rt_strt_date));
7903 fnd_message.raise_error;
7904 --
7905 end if;
7906 close get_created_entry_value;
7907 if g_debug then
7908 hr_utility.set_location('Element entry value Id '||l_entry_value_id,30);
7909 end if;
7910
7911 open c_get_prtt_rt_val
7912 (c_prtt_rt_val_id => p_prtt_rt_val_id
7913 );
7914 fetch c_get_prtt_rt_val into l_prv_rec;
7915 if c_get_prtt_rt_val%notfound
7916 then
7917 --
7918 if g_debug then
7919 hr_utility.set_location('BEN_92103_NO_PRTT_RT_VAL',170);
7920 end if;
7921 close c_get_prtt_rt_val;
7922 --
7923 fnd_message.set_name('BEN', 'BEN_92103_NO_PRTT_RT_VAL');
7924 fnd_message.set_token('PROC',l_proc);
7925 fnd_message.set_token('PRTT_RT_VAL',to_char(p_prtt_rt_val_id));
7926 fnd_message.raise_error;
7927 --
7928 end if;
7929 close c_get_prtt_rt_val;
7930 --
7931 l_prv_object_version_number := l_prv_rec.object_version_number;
7932
7933 -- update the prv with the new element_entry_id
7934 --
7935 ben_prtt_rt_val_api.update_prtt_rt_val
7936 (p_validate => p_validate
7937 ,p_person_id => p_person_id
7938 ,p_prtt_rt_val_id => l_prv_rec.prtt_rt_val_id
7939 ,p_business_group_id => l_prv_rec.business_group_id
7940 ,p_element_entry_value_id => l_entry_value_id
7941 ,p_input_value_id => p_input_value_id
7942 ,p_object_version_number => l_prv_object_version_number
7943 ,p_effective_date => p_rt_strt_date
7944 );
7945 --
7946 if g_debug then
7947 hr_utility.set_location('rt end dt '||to_char(p_rt_end_date),30);
7948 end if;
7949 if (p_rt_end_date is not null)
7950 then
7951 -- end date the element entry
7952 -- bug 5768050
7953 OPEN c_ee_ovn (l_element_entry_id);
7954
7955 FETCH c_ee_ovn
7956 INTO l_ovn;
7957
7958 IF c_ee_ovn%FOUND
7959 THEN
7960 hr_utility.set_location ('ovn found ending element', 121);
7961 py_element_entry_api.delete_element_entry
7962 (p_validate => p_validate
7963 ,p_datetrack_delete_mode => hr_api.g_delete
7964 ,p_effective_date => p_rt_end_date
7965 ,p_element_entry_id => l_element_entry_id
7966 -- ,p_object_version_number => l_object_version_number
7967 ,p_object_version_number => l_ovn
7968 ,p_effective_start_date => l_effective_start_date -- out parm
7969 ,p_effective_end_date => l_effective_end_date -- out parm
7970 ,p_delete_warning => l_delete_warning
7971 );
7972 end if;
7973 close c_ee_ovn;
7974 -- end bug 5768050
7975 if g_debug then
7976 hr_utility.set_location('ee start date '||to_char(l_effective_start_date),30);
7977 end if;
7978 if g_debug then
7979 hr_utility.set_location('ee end date '||to_char(l_effective_end_date),30);
7980 end if;
7981 -- write to the change event log
7982 --
7983 ben_ext_chlg.log_element_chg(
7984 p_action => hr_api.g_delete,
7985 p_old_amt => p_amt,
7986 p_input_value_id => p_input_value_id,
7987 p_element_entry_id => p_element_entry_id,
7988 p_person_id => p_person_id,
7989 p_business_group_id => p_business_group_id,
7990 p_effective_date => p_effective_date);
7991 end if;
7992 if g_debug then
7993 hr_utility.set_location('Leaving :'||l_proc,5);
7994 end if;
7995 --
7996 end recreate_enrollment_element;
7997 -- ----------------------------------------------------------------------------
7998 -- |----------------------< end_enrollment_element >--------------------------|
7999 -- ----------------------------------------------------------------------------
8000 procedure end_enrollment_element(p_validate IN BOOLEAN
8001 ,p_business_group_id IN NUMBER
8002 ,p_person_id IN NUMBER
8003 ,p_enrt_rslt_id IN NUMBER
8004 ,p_acty_ref_perd in varchar2
8005 ,p_acty_base_rt_id in number
8006 ,p_element_link_id IN NUMBER
8007 ,p_prtt_rt_val_id in number
8008 ,p_rt_end_date IN DATE
8009 ,p_effective_date IN DATE
8010 ,p_dt_delete_mode IN VARCHAR2
8011 ,p_amt in number) is
8012 --
8013 -- Bug 2386380 fix - added default value to decode function
8014 --
8015 cursor c_pps_prev_month(p_end_date in date,
8016 p_prtl_mo_eff_dt_det_cd in varchar2,
8017 p_payroll_id in number) is
8018 select start_date,end_date
8019 from per_time_periods
8020 where payroll_id = p_payroll_id
8021 and decode(p_prtl_mo_eff_dt_det_cd,'DTPD',regular_payment_date,
8022 'PPED',end_date,
8023 'DTERND',regular_payment_date,
8024 end_date)
8025 < p_end_date
8026 order by start_date desc;
8027 --
8028 -- Bug 2386380 fix - added default value to decode function
8029 --
8030 cursor c_get_current_pp(p_end_date in date
8031 ,p_prtl_mo_eff_dt_det_cd in varchar2
8032 ,p_payroll_id in number) is
8033 select start_date,end_date
8034 from per_time_periods
8035 where payroll_id = p_payroll_id
8036 and p_end_date between
8037 start_date
8038 and decode(p_prtl_mo_eff_dt_det_cd,'DTPD',regular_payment_date
8039 ,'PPED',end_date
8040 ,'DTERND',regular_payment_date
8041 ,end_date);
8042 --
8043 -- Bug 2386380 fix - added default value to decode function
8044 --
8045 cursor c_last_pay_periods(p_start_date in date,
8046 p_end_date in date,
8047 p_prtl_mo_eff_dt_det_cd in varchar2,
8048 p_payroll_id in number) is
8049 select start_date,end_date
8050 from per_time_periods
8051 where payroll_id = p_payroll_id
8052 and decode(p_prtl_mo_eff_dt_det_cd,'DTPD',regular_payment_date,
8053 'PPED',end_date,
8054 'DTERND',regular_payment_date,
8055 end_date)
8056 <= p_end_date
8057 and decode(p_prtl_mo_eff_dt_det_cd,'DTPD',regular_payment_date,
8058 'PPED',end_date,
8059 'DTERND',regular_payment_date,
8060 end_date)
8061 >= p_start_date
8062 order by start_date asc;
8063 --
8064 cursor get_abr_info(p_effective_date in date) is
8065 select abr.prtl_mo_det_mthd_cd,
8066 abr.prtl_mo_det_mthd_rl,
8067 abr.wsh_rl_dy_mo_num,
8068 abr.prtl_mo_eff_dt_det_cd,
8069 abr.prtl_mo_eff_dt_det_rl,
8070 abr.input_va_calc_rl,
8071 abr.rndg_cd,
8072 abr.rndg_rl,
8073 abr.rcrrg_cd,
8074 abr.ele_rqd_flag,
8075 abr.one_ann_pymt_cd,
8076 abr.entr_ann_val_flag,
8077 abr.ele_entry_val_cd,
8078 abr.name
8079 from ben_acty_base_rt_f abr
8080 where abr.acty_base_rt_id=p_acty_base_rt_id
8081 and abr.business_group_id=p_business_group_id
8082 and p_effective_date between
8083 abr.effective_start_date and abr.effective_end_date;
8084 --
8085 cursor c_ele_info(p_element_entry_value_id number) is
8086 select pel.element_link_id,
8087 pel.element_type_id,
8088 pev.input_value_id,
8089 pet.element_name,
8090 pet.processing_type
8091 from pay_element_types_f pet,
8092 pay_element_links_f pel,
8093 pay_element_entries_f pee,
8094 pay_element_entry_values_f pev
8095 where pev.element_entry_value_id = p_element_entry_value_id
8096 and pee.element_entry_id = pev.element_entry_id
8097 and pev.effective_start_date between pee.effective_start_date
8098 and pee.effective_end_date
8099 and pel.element_link_id = pee.element_link_id
8100 and pee.effective_start_date between pel.effective_start_date
8101 and pel.effective_end_date
8102 and pet.element_type_id = pel.element_type_id
8103 and pel.effective_start_date between pet.effective_start_date
8104 and pet.effective_end_date;
8105 --
8106 -- Get element entry ID
8107 --
8108 cursor get_element_entry_id (p_enrt_rslt_id in number
8109 ,p_element_type_id in number
8110 ,p_input_value_id in number
8111 ,p_element_entry_value_id in number
8112 ,p_effective_date in date)
8113 is
8114 select asg.assignment_id,
8115 asg.payroll_id,
8116 pee.element_entry_id,
8117 pee.effective_start_date,
8118 pee.effective_end_date,
8119 pee.object_version_number,
8120 pee.original_entry_id,
8121 pee.entry_type,
8122 pee.element_link_id,
8123 pev.screen_entry_value
8124 from per_all_assignments_f asg,
8125 pay_element_links_f pel,
8126 pay_element_entries_f pee,
8127 pay_element_entry_values_f pev
8128 where asg.person_id = p_person_id
8129 and pee.assignment_id = asg.assignment_id
8130 and p_effective_date between asg.effective_start_date
8131 and asg.effective_end_date
8132 and pee.creator_id = p_enrt_rslt_id
8133 and pee.creator_type = 'F'
8134 and pee.entry_type = 'E'
8135 and p_effective_date <= pee.effective_end_date
8136 and pel.element_link_id = pee.element_link_id
8137 and pee.effective_start_date between pel.effective_start_date
8138 and pel.effective_end_date
8139 and pel.element_type_id = p_element_type_id
8140 and pev.element_entry_id = pee.element_entry_id
8141 and pev.input_value_id = p_input_value_id
8142 and (p_element_entry_value_id is null or
8143 pev.element_entry_value_id = p_element_entry_value_id)
8144 and pev.effective_start_date between pee.effective_start_date
8145 and pee.effective_end_date
8146 order by pee.effective_start_date ;
8147
8148 cursor get_future_element_entry (p_enrt_rslt_id IN NUMBER
8149 ,p_assignment_id in number
8150 ,p_element_type_id in number
8151 ,p_effective_date in date) is
8152 select pee.element_entry_id,
8153 pee.effective_start_date,
8154 pee.effective_end_date,
8155 pee.object_version_number
8156 from pay_element_entries_f pee,
8157 pay_element_links_f pel
8158 where pee.assignment_id = p_assignment_id
8159 and pee.creator_id = p_enrt_rslt_id
8160 and pee.creator_type = 'F'
8161 and pee.entry_type = 'E'
8162 and pee.effective_start_date > p_effective_date
8163 and pel.element_link_id = pee.element_link_id
8164 and pee.effective_start_date between pel.effective_start_date
8165 and pel.effective_end_date
8166 and pel.element_type_id = p_element_type_id
8167 and pee.effective_start_date
8168 = (select min(pee2.effective_start_date)
8169 from pay_element_entries_f pee2
8170 where pee2.element_entry_id = pee.element_entry_id);
8171 l_future_ee_rec get_future_element_entry%rowtype;
8172 --
8173 --Added prv.rt_strt_dt <=c_effective_date condition
8174 --to fix bug 6132571. To filter our rates that are
8175 --already processed.
8176 cursor c_dup_prv(c_element_entry_id number,
8177 c_effective_date date) is
8178 select 'x'
8179 from ben_prtt_rt_val prv
8180 where prv.prtt_enrt_rslt_id = p_enrt_rslt_id
8181 and prv.acty_base_rt_id <> p_acty_base_rt_id
8182 and prv.rt_end_dt > c_effective_date
8183 -- and prv.rt_strt_dt <=c_effective_date
8184 and prv.prtt_rt_val_stat_cd is null
8185 and prv.element_entry_value_id in
8186 (select pev.element_entry_value_id
8187 from pay_element_entry_values_f pev
8188 where pev.element_entry_id = c_element_entry_id);
8189 --
8190 cursor c_chk_abs_ler (c_prtt_rt_val_id number,
8191 c_effective_date date) is
8192 select pil.lf_evt_ocrd_dt,
8193 pil.trgr_table_pk_id,
8194 pil.per_in_ler_id,
8195 ler.ler_id
8196 from ben_prtt_rt_val prt,
8197 ben_per_in_ler pil,
8198 ben_ler_f ler
8199 where prt.prtt_rt_val_id = c_prtt_rt_val_id
8200 -- ended_per_in_ler_id may be null in case of back out
8201 and pil.per_in_ler_id = nvl(prt.ended_per_in_ler_id,prt.per_in_ler_id)
8202 and ler.ler_id = pil.ler_id
8203 and ler.typ_cd ='ABS'
8204 and c_effective_date between
8205 ler.effective_start_date and ler.effective_end_date;
8206 --
8207 cursor c_min_max_dt(p_element_entry_id number) is
8208 select min(effective_start_date),
8209 max(effective_end_date)
8210 from pay_element_entries_f
8211 where element_entry_id = p_element_entry_id;
8212 --
8213 cursor c_element_ovn(p_element_entry_id number,
8214 p_effective_date date) is
8215 select object_version_number
8216 from pay_element_entries_f pee
8217 where pee.element_entry_id = p_element_entry_id
8218 and p_effective_date between pee.effective_start_date
8219 and pee.effective_end_date;
8220
8221 --
8222 -- Bug 6834340
8223 -- to pass correct ler_id to the prorate_amount when subsequent life event
8224 -- offers no electability to the existing enrollments but rates get updated.
8225 --
8226
8227 cursor c_ler_with_ended_prv
8228 (p_prtt_rt_val_id in number
8229 , p_rt_end_date in date
8230 )
8231 is
8232 select ler.name name, ler.ler_id ler_id
8233 from ben_prtt_rt_val prv,
8234 ben_per_in_ler pil,
8235 ben_ler_f ler
8236 where prv.per_in_ler_id = pil.per_in_ler_id
8237 and pil.ler_id = ler.ler_id
8238 and prv.prtt_rt_val_id = p_prtt_rt_val_id
8239 and prv.rt_end_dt = p_rt_end_date;
8240
8241 l_ler_with_ended_prv c_ler_with_ended_prv%rowtype;
8242
8243 -- Bug 6834340
8244 --
8245 --
8246 --
8247 l_per_month_amt number;
8248 l_assignment_id NUMBER;
8249 l_payroll_id NUMBER;
8250 l_element_entry_id NUMBER;
8251 l_ext_chg_evt_log_id NUMBER;
8252 l_input_value_id NUMBER;
8253 l_abr_input_value_id NUMBER;
8254 l_object_version_number NUMBER;
8255 l_ext_object_version_number NUMBER;
8256 l_effective_start_date DATE;
8257 l_effective_end_date DATE;
8258 l_rt_end_dt DATE := p_rt_end_date;
8259 l_delete_warning BOOLEAN;
8260 l_proc VARCHAR2(72) := g_package||'end_enrollment_element';
8261 l_organization_id number;
8262 l_immediate_end boolean:=false;
8263 l_prtl_mo_det_mthd_cd varchar2(30);
8264 l_prtl_mo_det_mthd_rl number;
8265 l_wsh_rl_dy_mo_num number;
8266 l_prtl_mo_eff_dt_det_cd varchar2(30);
8267 l_prtl_mo_eff_dt_det_rl number;
8268 l_per_pay_amt number;
8269 l_prorated_monthly_amt number;
8270 l_amt number;
8271 l_prtn_flag varchar2(1);
8272 l_element_type_id number;
8273 l_abr_element_type_id number;
8274 l_outputs ff_exec.outputs_t;
8275 l_remainder number;
8276 l_number_in_month number;
8277 l_old_normal_pp_date date;
8278 l_normal_pp_date date;
8279 l_special_pp_date date;
8280 l_old_normal_pp_end_date date;
8281 l_normal_pp_end_date date;
8282 l_special_pp_end_date date;
8283 l_zero_pp_date date default null;
8284 l_dt_to_use date;
8285 l_special_amt number;
8286 l_element_link_id number;
8287 l_start_date date;
8288 l_end_date date;
8289 l_update_ee boolean;
8290 l_curr_val number;
8291 l_new_date date;
8292 l_end_of_time date;
8293 l_create_warning BOOLEAN;
8294 l_update_warning BOOLEAN;
8295 l_jurisdiction_code varchar2(30);
8296 l_abr_rndg_cd varchar2(30);
8297 l_abr_rndg_rl number;
8298 l_ele_rqd_flag varchar2(30);
8299 l_one_ann_pymt_cd varchar2(30);
8300 l_entr_ann_val_flag varchar2(30);
8301 l_ele_entry_val_cd varchar2(30);
8302 l_last_pp_strt_dt date;
8303 l_last_pp_end_dt date;
8304 l_range_start date;
8305 l_dt_delete_mode varchar2(80);
8306 l_cnt number;
8307 l_absence_attendance_id number;
8308 l_per_in_ler_id number;
8309 l_ler_id number;
8310 l_input_va_calc_rl number;
8311 l_subpriority number;
8312 l_original_entry_id number;
8313 l_entry_type varchar2(30);
8314 l_processing_type varchar2(30);
8315 l_lf_evt_ocrd_dt date;
8316 l_abs_ler boolean := false;
8317 l_recreate boolean := false;
8318 l_ele_processed varchar2(1);
8319 l_err_code varchar2(10);
8320 l_err_mesg varchar2(2000);
8321 l_dummy varchar2(30);
8322 l_curr_val_char varchar2 (60);
8323 l_uom varchar2(30);
8324 l_correction boolean;
8325 l_update boolean;
8326 l_update_override boolean;
8327 l_update_change_insert boolean;
8328 l_dt_upd_mode varchar2(30);
8329 l_element_entry_start_date date;
8330 l_element_entry_end_date date;
8331 l_string varchar2(4000);
8332 l_abr_name varchar2(240); -- 2519349
8333 l_effective_date date;
8334 l_rt_strt_dt date;
8335 l_perd_cd varchar2(30) := 'PP';
8336 l_element_name varchar2(80);
8337 l_object_version_number2 number;
8338 l_another_prv_exists boolean := false;
8339 l_min_start_date date;
8340 l_max_end_date date;
8341 l_non_recurring_entry boolean := false;
8342 l_abr_rcrrg_cd varchar2(30);
8343 l_element_entry_value_id number;
8344 l_v2dummy varchar2(30);
8345 --
8346 begin
8347 g_debug := hr_utility.debug_enabled;
8348 if g_debug then
8349 hr_utility.set_location('Entering :'||l_proc,5);
8350 hr_utility.set_location('Element_link_id='||to_char(p_element_link_id),6);
8351 hr_utility.set_location('Effective_date='||to_char(p_effective_date),6);
8352 hr_utility.set_location('p_prtt_rt_val_id='||p_prtt_rt_val_id,6);
8353 hr_utility.set_location('p_enrt_rslt_id='||p_enrt_rslt_id,6);
8354 hr_utility.set_location('p_rt_end_date='||to_char(p_rt_end_date),6);
8355 end if;
8356 --
8357 --BUG 3167959 We need to intialize the pl/sql table
8358 clear_ext_inpval_tab ;
8359 --
8360 -- get prv info
8361 --
8362 open c_get_prtt_rt_val
8363 (c_prtt_rt_val_id => p_prtt_rt_val_id
8364 );
8365 fetch c_get_prtt_rt_val into l_prv_rec;
8366 if c_get_prtt_rt_val%notfound
8367 then
8368 --
8369 if g_debug then
8370 hr_utility.set_location('BEN_92103_NO_PRTT_RT_VAL',170);
8371 end if;
8372 close c_get_prtt_rt_val;
8373 --
8374 fnd_message.set_name('BEN', 'BEN_92103_NO_PRTT_RT_VAL');
8375 fnd_message.set_token('PROC',l_proc);
8376 fnd_message.set_token('PRTT_RT_VAL',to_char(p_prtt_rt_val_id));
8377 fnd_message.raise_error;
8378 --
8379 end if;
8380 close c_get_prtt_rt_val;
8381 --
8382 -- if no element entry was created to start with, return
8383 --
8384 if l_prv_rec.element_entry_value_id is null then
8385 hr_utility.set_location('no element entry '||l_proc,7);
8386 hr_utility.set_location('Leaving: '||l_proc,7);
8387 return;
8388 end if;
8389 --
8390 -- find the element type and input value based on element_entry_value_id
8391 -- attached to prtt rt.
8392 --
8393 open c_ele_info(l_prv_rec.element_entry_value_id);
8394 fetch c_ele_info into
8395 l_element_link_id,
8396 l_element_type_id,
8397 l_input_value_id,
8398 l_element_name,
8399 l_processing_type;
8400 --
8401 if c_ele_info%notfound then
8402 close c_ele_info;
8403 if g_debug then
8404 --
8405 -- entry_value_id attached to prtt rt does not exist. This is possible
8406 -- prior to FP C when ct. could delete the entries
8407 --
8408 hr_utility.set_location('Leaving: '||l_proc,7);
8409 end if;
8410 return;
8411 end if;
8412 close c_ele_info;
8413 --
8414 -- This is for the case when prtt rt is ended one day before start dt
8415 --
8416 l_effective_date := greatest(l_prv_rec.rt_strt_dt,l_rt_end_dt);
8417
8418 if g_debug then
8419 hr_utility.set_location('ele type='||l_element_type_id,7);
8420 hr_utility.set_location('inp val='||l_input_value_id,7);
8421 hr_utility.set_location('l_effective_date='||l_effective_date,7);
8422 end if;
8423 --
8424 -- get abr info
8425 --
8426 open get_abr_info(l_effective_date);
8427 fetch get_abr_info into l_prtl_mo_det_mthd_cd,
8428 l_prtl_mo_det_mthd_rl,
8429 l_wsh_rl_dy_mo_num,
8430 l_prtl_mo_eff_dt_det_cd,
8431 l_prtl_mo_eff_dt_det_rl,
8432 l_input_va_calc_rl,
8433 l_abr_rndg_cd,
8434 l_abr_rndg_rl,
8435 l_abr_rcrrg_cd,
8436 l_ele_rqd_flag,
8437 l_one_ann_pymt_cd,
8438 l_entr_ann_val_flag,
8439 l_ele_entry_val_cd,
8440 l_abr_name;
8441 if get_abr_info%notfound then
8442 close get_abr_info;
8443 if g_debug then
8444 hr_utility.set_location('BEN_91723_NO_ENRT_RT_ABR_FOUND',40);
8445 end if;
8446 fnd_message.set_name('BEN','BEN_91723_NO_ENRT_RT_ABR_FOUND');
8447 fnd_message.set_token('PROC',l_proc);
8448 fnd_message.set_token('ACTY_BASE_RT_ID',to_char(p_acty_base_rt_id));
8449 fnd_message.set_token('EFFECTIVE_DATE',to_char(p_effective_date));
8450 fnd_message.raise_error;
8451 end if;
8452 close get_abr_info;
8453
8454 hr_utility.set_location('l_abr_rcrrg_cd '||l_abr_rcrrg_cd,40);
8455 hr_utility.set_location('l_processing_type '||l_processing_type,40);
8456 l_non_recurring_entry := ((l_abr_rcrrg_cd = 'ONCE') or (l_processing_type='N'));
8457 if l_non_recurring_entry then
8458 l_element_entry_value_id := l_prv_rec.element_entry_value_id;
8459 end if;
8460 hr_utility.set_location('l_element_entry_value_id '||l_element_entry_value_id,40);
8461
8462 --
8463 -- find the element entry that needs to be deleted.
8464 -- This could be different from what is attached to prtt rt
8465 --
8466 open get_element_entry_id(p_enrt_rslt_id
8467 ,l_element_type_id
8468 ,l_input_value_id
8469 ,l_element_entry_value_id
8470 ,l_effective_date);
8471 fetch get_element_entry_id into
8472 l_assignment_id,
8473 l_payroll_id,
8474 l_element_entry_id,
8475 l_element_entry_start_date,
8476 l_element_entry_end_date,
8477 l_object_version_number,
8478 l_original_entry_id,
8479 l_entry_type,
8480 l_element_link_id,
8481 l_curr_val_char;
8482 --
8483 if get_element_entry_id%notfound then
8484 close get_element_entry_id;
8485 if g_debug then
8486 -- element entry already ended.
8487 hr_utility.set_location('element entry already ended',8);
8488 hr_utility.set_location('Leaving: '||l_proc,7);
8489 end if;
8490
8491 --
8492 ben_warnings.load_warning
8493 (p_application_short_name => 'BEN',
8494 p_message_name => 'BEN_93455_ELE_ALREADY_ENDED',
8495 p_parma => l_element_name,
8496 p_parmb => to_char(l_effective_date),
8497 p_person_id => p_person_id);
8498 --
8499 if fnd_global.conc_request_id in ( 0,-1) then
8500 --
8501 fnd_message.set_name('BEN','BEN_93455_ELE_ALREADY_ENDED');
8502 fnd_message.set_token('PARMA',l_element_name);
8503 fnd_message.set_token('PARMB',to_char(l_effective_date));
8504 l_string := fnd_message.get;
8505 benutils.write(p_text => l_string);
8506 --
8507 end if;
8508 --
8509 return;
8510 --
8511 end if;
8512 close get_element_entry_id;
8513
8514 if g_debug then
8515 hr_utility.set_location('ee id='||l_element_entry_id,9);
8516 hr_utility.set_location('ee strtdt ='||l_element_entry_start_date,9);
8517 hr_utility.set_location('ee end dt='||l_element_entry_end_date,9);
8518 hr_utility.set_location('l_ovn='||l_object_version_number,9);
8519 hr_utility.set_location('l_payroll_id='||l_payroll_id,9);
8520 hr_utility.set_location('l_assignment_id='||l_assignment_id,9);
8521 end if;
8522 --
8523 -- get prtt enrt rslt info
8524 --
8525 if nvl(g_result_rec.prtt_enrt_rslt_id,-1)<>p_enrt_rslt_id then
8526 open c_current_result_info
8527 (c_prtt_enrt_rslt_id => p_enrt_rslt_id
8528 );
8529 fetch c_current_result_info into g_result_rec;
8530 close c_current_result_info;
8531 end if;
8532 --
8533 -- check if abs ler
8534 --
8535 open c_chk_abs_ler
8536 (c_prtt_rt_val_id => p_prtt_rt_val_id
8537 ,c_effective_date => l_effective_date
8538 );
8539 fetch c_chk_abs_ler into
8540 l_lf_evt_ocrd_dt,
8541 l_absence_attendance_id,
8542 l_per_in_ler_id,
8543 l_ler_id;
8544 l_abs_ler := c_chk_abs_ler%found;
8545 close c_chk_abs_ler;
8546 --
8547 -- Get the latest payroll run date
8548 --
8549 g_max_end_date := null;
8550 --
8551 --Bug 3151737and 3063518 if there is no payroll_id on assignment means
8552 --customer might not be using the payroll so we don't need to determine
8553 --the g_max_end_date .
8554 --
8555 if l_payroll_id is not null then
8556 --
8557 if nvl(g_per_pay_rec.assignment_id,-1) <> l_assignment_id then
8558 --
8559 open c_payroll_was_ever_run
8560 (c_assignment_id => l_assignment_id
8561 );
8562 fetch c_payroll_was_ever_run into l_v2dummy;
8563 g_per_pay_rec.assignment_id := l_assignment_id;
8564 g_per_pay_rec.payroll_was_ever_run := c_payroll_was_ever_run%found;
8565 close c_payroll_was_ever_run;
8566 --
8567 end if;
8568 --
8569 if g_per_pay_rec.payroll_was_ever_run and
8570 g_per_pay_rec.end_date is null then
8571 --
8572 g_max_end_date :=
8573 get_max_end_dt (
8574 p_assignment_id => l_assignment_id,
8575 p_payroll_id => l_payroll_id,
8576 p_element_type_id => l_element_type_id,
8577 p_effective_date => l_effective_date);
8578 --
8579 g_per_pay_rec.end_date := g_max_end_date;
8580 --
8581 elsif g_per_pay_rec.end_date is not null then
8582 g_max_end_date := g_per_pay_rec.end_date;
8583 end if;
8584 --
8585 end if;
8586 --
8587 if g_debug then
8588 hr_utility.set_location('g_max_end_date='||g_max_end_date,10);
8589 end if;
8590 --
8591 -- If the entry has already been processed in the pay period
8592 -- in which it is going to be ended, show a warning
8593 --
8594 if not (l_abs_ler) and
8595 g_max_end_date is not null and
8596 g_max_end_date > l_rt_end_dt
8597 then
8598 if (g_msg_displayed <>1)
8599 -- added for bug: 5607214
8600 or fnd_global.conc_request_id not in ( 0,-1)
8601 then
8602 --l_immediate_end:=true;
8603 -- Issue a warning to the user. These will display on the enrt forms.
8604 ben_warnings.load_warning
8605 (p_application_short_name => 'BEN',
8606 p_message_name => 'BEN_92456_END_RUN_RESULTS',
8607 p_parma => fnd_date.date_to_chardate(g_max_end_date),
8608 p_person_id => p_person_id);
8609
8610 if fnd_global.conc_request_id not in ( 0,-1) then
8611 --
8612 fnd_message.set_name('BEN','BEN_92456_END_RUN_RESULTS');
8613 fnd_message.set_token('PARMA',fnd_date.date_to_chardate(g_max_end_date));
8614 l_string := fnd_message.get;
8615 benutils.write(p_text => l_string);
8616 --
8617 end if;
8618 g_msg_displayed :=1;
8619 end if;
8620 --
8621 -- cache quickpay run entries
8622 --
8623 cache_quick_pay_run
8624 (p_person_id => p_person_id,
8625 p_element_type_id => l_element_type_id,
8626 p_assignment_id => l_assignment_id,
8627 p_element_entry_id => l_element_entry_id,
8628 p_effective_date => l_rt_end_dt + 1,
8629 p_start_date => l_rt_end_dt + 1,
8630 p_end_date => g_max_end_date,
8631 p_payroll_id => l_payroll_id);
8632 end if;
8633 --
8634 -- Determine dt track mode.
8635 --
8636 open c_min_max_dt(l_element_entry_id);
8637 fetch c_min_max_dt into l_min_start_date,l_max_end_date;
8638 close c_min_max_dt;
8639
8640 if l_rt_end_dt < l_min_start_date then
8641 l_dt_delete_mode := hr_api.g_zap;
8642 elsif l_rt_end_dt < l_max_end_date then
8643 l_dt_delete_mode := hr_api.g_delete;
8644 end if;
8645 --
8646 -- if the entry is to be ended on l_rt_end_dt (or)
8647 -- has already been ended on l_rt_end_dt, then update the extra input vales
8648 --
8649 if l_rt_end_dt >= l_element_entry_start_date and
8650 l_rt_end_dt <= l_max_end_date then
8651 get_extra_ele_inputs
8652 (p_effective_date => p_effective_date
8653 ,p_person_id => p_person_id
8654 ,p_business_group_id => p_business_group_id
8655 ,p_assignment_id => l_assignment_id
8656 ,p_element_link_id => l_element_link_id
8657 ,p_entry_type => 'E'
8658 ,p_input_value_id1 => l_input_value_id
8659 ,p_entry_value1 => l_curr_val_char
8660 ,p_element_entry_id => l_element_entry_id
8661 ,p_acty_base_rt_id => p_acty_base_rt_id
8662 ,p_input_va_calc_rl => l_input_va_calc_rl
8663 ,p_abs_ler => l_abs_ler
8664 ,p_organization_id => l_organization_id
8665 ,p_payroll_id => l_payroll_id
8666 ,p_pgm_id => g_result_rec.pgm_id
8667 ,p_pl_id => g_result_rec.pl_id
8668 ,p_pl_typ_id => g_result_rec.pl_typ_id
8669 ,p_opt_id => g_result_rec.opt_id
8670 ,p_ler_id => l_ler_id
8671 ,p_dml_typ => 'U'
8672 ,p_jurisdiction_code => l_jurisdiction_code
8673 ,p_ext_inpval_tab => g_ext_inpval_tab
8674 ,p_subpriority => l_subpriority
8675 );
8676
8677 if g_ext_inpval_tab.count > 0 and
8678 /* Bug 3890546: When previous payroll periods are closed,
8679 the below update_element_entry errors out. So, restricting this call
8680 to only when atleast one extra input_value_id NOT NULL */
8681 ( g_ext_inpval_tab(1).input_value_id IS NOT NULL
8682 OR g_ext_inpval_tab(2).input_value_id IS NOT NULL
8683 OR g_ext_inpval_tab(3).input_value_id IS NOT NULL
8684 OR g_ext_inpval_tab(4).input_value_id IS NOT NULL
8685 OR g_ext_inpval_tab(5).input_value_id IS NOT NULL
8686 OR g_ext_inpval_tab(6).input_value_id IS NOT NULL
8687 OR g_ext_inpval_tab(7).input_value_id IS NOT NULL
8688 OR g_ext_inpval_tab(8).input_value_id IS NOT NULL
8689 OR g_ext_inpval_tab(9).input_value_id IS NOT NULL
8690 OR g_ext_inpval_tab(10).input_value_id IS NOT NULL
8691 OR g_ext_inpval_tab(11).input_value_id IS NOT NULL
8692 OR g_ext_inpval_tab(12).input_value_id IS NOT NULL
8693 OR g_ext_inpval_tab(13).input_value_id IS NOT NULL
8694 OR g_ext_inpval_tab(14).input_value_id IS NOT NULL)
8695 then
8696 pay_element_entry_api.update_element_entry
8697 (p_validate =>p_validate
8698 ,p_datetrack_update_mode =>hr_api.g_correction
8699 ,p_effective_date =>l_element_entry_start_date
8700 ,p_business_group_id =>p_business_group_id
8701 ,p_element_entry_id =>l_element_entry_id
8702 ,p_object_version_number =>l_object_version_number
8703 ,p_subpriority =>l_subpriority
8704 ,p_override_user_ent_chk =>'Y'
8705 ,p_input_value_id1 =>g_ext_inpval_tab(1).input_value_id
8706 ,p_entry_value1 =>g_ext_inpval_tab(1).return_value
8707 ,p_input_value_id2 =>g_ext_inpval_tab(2).input_value_id
8708 ,p_entry_value2 =>g_ext_inpval_tab(2).return_value
8709 ,p_input_value_id3 =>g_ext_inpval_tab(3).input_value_id
8710 ,p_entry_value3 =>g_ext_inpval_tab(3).return_value
8711 ,p_input_value_id4 =>g_ext_inpval_tab(4).input_value_id
8712 ,p_entry_value4 =>g_ext_inpval_tab(4).return_value
8713 ,p_input_value_id5 =>g_ext_inpval_tab(5).input_value_id
8714 ,p_entry_value5 =>g_ext_inpval_tab(5).return_value
8715 ,p_input_value_id6 =>g_ext_inpval_tab(6).input_value_id
8716 ,p_entry_value6 =>g_ext_inpval_tab(6).return_value
8717 ,p_input_value_id7 =>g_ext_inpval_tab(7).input_value_id
8718 ,p_entry_value7 =>g_ext_inpval_tab(7).return_value
8719 ,p_input_value_id8 =>g_ext_inpval_tab(8).input_value_id
8720 ,p_entry_value8 =>g_ext_inpval_tab(8).return_value
8721 ,p_input_value_id9 =>g_ext_inpval_tab(9).input_value_id
8722 ,p_entry_value9 =>g_ext_inpval_tab(9).return_value
8723 ,p_input_value_id10 =>g_ext_inpval_tab(10).input_value_id
8724 ,p_entry_value10 =>g_ext_inpval_tab(10).return_value
8725 ,p_input_value_id11 =>g_ext_inpval_tab(11).input_value_id
8726 ,p_entry_value11 =>g_ext_inpval_tab(11).return_value
8727 ,p_input_value_id12 =>g_ext_inpval_tab(12).input_value_id
8728 ,p_entry_value12 =>g_ext_inpval_tab(12).return_value
8729 ,p_input_value_id13 =>g_ext_inpval_tab(13).input_value_id
8730 ,p_entry_value13 =>g_ext_inpval_tab(13).return_value
8731 ,p_input_value_id14 =>g_ext_inpval_tab(14).input_value_id
8732 ,p_entry_value14 =>g_ext_inpval_tab(14).return_value
8733 ,p_effective_start_date =>l_effective_start_date
8734 ,p_effective_end_date =>l_effective_end_date
8735 ,p_update_warning =>l_update_warning
8736 );
8737 end if;
8738
8739 if l_abs_ler then
8740 pqp_absence_plan_process.update_absence_plan_details
8741 (p_person_id => p_person_id
8742 ,p_assignment_id => l_assignment_id
8743 ,p_business_group_id => p_business_group_id
8744 ,p_legislation_code => get_legislation_code(p_business_group_id)
8745 ,p_effective_date => p_effective_date
8746 ,p_element_type_id => l_element_type_id
8747 ,p_pl_id => g_result_rec.pl_id
8748 ,p_pl_typ_id => g_result_rec.pl_typ_id
8749 ,p_ler_id => l_ler_id
8750 ,p_per_in_ler_id => l_per_in_ler_id
8751 ,p_absence_attendance_id => l_absence_attendance_id
8752 ,p_effective_start_date => l_effective_start_date
8753 ,p_effective_end_date => l_effective_end_date
8754 ,p_formula_outputs => g_outputs
8755 ,p_error_code => l_err_code
8756 ,p_error_message => l_err_mesg
8757 );
8758 end if;
8759
8760 end if;
8761
8762 if l_abs_ler and
8763 l_dt_delete_mode = hr_api.g_delete then
8764 --
8765 -- ABSENCES: ZAP and recreate the element entry if the absence
8766 -- was processed in a payroll and is currently end dated in a
8767 -- period for which payroll has already been run.
8768 --
8769 -- This needs to be eventually merged with c_get_end_dt cursor
8770 --
8771 l_ele_processed := chk_ele_processed
8772 (p_element_entry_id => l_element_entry_id
8773 ,p_original_entry_id=> l_original_entry_id
8774 ,p_processing_type => l_processing_type
8775 ,p_entry_type => l_entry_type
8776 ,p_business_group_id => p_business_group_id
8777 ,p_effective_date => p_effective_date);
8778
8779 if l_ele_processed = 'Y' and
8780 l_lf_evt_ocrd_dt < g_max_end_date then
8781 l_recreate := true;
8782 end if;
8783
8784 end if;
8785 --
8786 --Check if entry is used by another prv. This info is used further down
8787 --
8788 open c_dup_prv(l_element_entry_id,
8789 l_rt_end_dt);
8790 fetch c_dup_prv into l_dummy;
8791 l_another_prv_exists := c_dup_prv%found;
8792 close c_dup_prv;
8793 --
8794 -- Delete the element entries
8795 --
8796 if (l_recreate) then
8797 --
8798 -- this part is called only in case of Absence processing
8799 --
8800 recreate_enrollment_element
8801 (p_validate => false
8802 ,p_business_group_id => p_business_group_id
8803 ,p_person_id => p_person_id
8804 ,p_enrt_rslt_id => p_enrt_rslt_id
8805 ,p_acty_ref_perd => p_acty_ref_perd
8806 ,p_acty_base_rt_id => p_acty_base_rt_id
8807 ,p_element_entry_id => l_element_entry_id
8808 ,p_element_link_id => l_element_link_id
8809 ,p_input_value_id => l_input_value_id
8810 ,p_prtt_rt_val_id => p_prtt_rt_val_id
8811 ,p_input_va_calc_rl => l_input_va_calc_rl
8812 ,p_abs_ler => l_abs_ler
8813 ,p_rt_strt_date => l_element_entry_start_date
8814 ,p_rt_end_date => l_rt_end_dt
8815 ,p_effective_date => p_effective_date
8816 ,p_amt =>l_curr_val_char
8817 ,p_object_version_number => l_object_version_number);
8818
8819 pqp_absence_plan_process.update_absence_plan_details
8820 (p_person_id => p_person_id
8821 ,p_assignment_id => l_assignment_id
8822 ,p_business_group_id => p_business_group_id
8823 ,p_legislation_code => get_legislation_code(p_business_group_id)
8824 ,p_effective_date => p_effective_date
8825 ,p_element_type_id => l_element_type_id
8826 ,p_pl_id => g_result_rec.pl_id
8827 ,p_pl_typ_id => g_result_rec.pl_typ_id
8828 ,p_ler_id => l_ler_id
8829 ,p_per_in_ler_id => l_per_in_ler_id
8830 ,p_absence_attendance_id => l_absence_attendance_id
8831 ,p_effective_start_date => l_effective_start_date
8832 ,p_effective_end_date => l_rt_end_dt
8833 ,p_formula_outputs => g_outputs
8834 ,p_error_code => l_err_code
8835 ,p_error_message => l_err_mesg
8836 );
8837
8838 elsif l_dt_delete_mode = hr_api.g_zap then
8839 if g_debug then
8840 hr_utility.set_location('ZAP mode',11);
8841 end if;
8842 /*
8843 Before :-
8844 02-JAN-1994 05-FEB-1994
8845 |-A--------------|-B--------------------------------------->
8846 ED
8847
8848 After :-
8849
8850 */
8851 py_element_entry_api.delete_element_entry
8852 (p_validate => p_validate
8853 ,p_datetrack_delete_mode => hr_api.g_zap
8854 ,p_effective_date => l_element_entry_start_date
8855 ,p_element_entry_id => l_element_entry_id
8856 ,p_object_version_number => l_object_version_number
8857 ,p_effective_start_date => l_effective_start_date
8858 ,p_effective_end_date => l_effective_end_date
8859 ,p_delete_warning => l_delete_warning
8860 );
8861 -- write to the change event log
8862 --
8863
8864 ben_ext_chlg.log_element_chg(
8865 p_action => 'DELETE',
8866 p_old_amt => fnd_number.canonical_to_number(l_curr_val_char),
8867 p_input_value_id => l_input_value_id,
8868 p_element_entry_id => l_element_entry_id,
8869 p_person_id => p_person_id,
8870 p_business_group_id => p_business_group_id,
8871 p_effective_date => p_effective_date);
8872 --
8873 if l_abs_ler then
8874 pqp_absence_plan_process.delete_absence_plan_details
8875 (p_assignment_id => l_assignment_id
8876 ,p_business_group_id => p_business_group_id
8877 ,p_legislation_code => get_legislation_code(p_business_group_id)
8878 ,p_effective_date => p_effective_date
8879 ,p_pl_id => g_result_rec.pl_id
8880 ,p_pl_typ_id => g_result_rec.pl_typ_id
8881 ,p_ler_id => l_ler_id
8882 ,p_per_in_ler_id => l_per_in_ler_id
8883 ,p_absence_attendance_id => l_absence_attendance_id
8884 ,p_effective_start_date => l_effective_start_date
8885 ,p_effective_end_date => l_effective_end_date
8886 ,p_formula_outputs => g_outputs
8887 ,p_error_code => l_err_code
8888 ,p_error_message => l_err_mesg
8889 );
8890 end if;
8891
8892 elsif l_dt_delete_mode = hr_api.g_delete then
8893 if g_debug then
8894 hr_utility.set_location('DELETE mode',11);
8895 end if;
8896 --
8897 -- End date as of the pre-calculated rate end date.
8898 --
8899 if g_debug then
8900 hr_utility.set_location('pre-calc rate end date',12);
8901 end if;
8902 /*
8903 Before :-
8904 02-JAN-1994 05-FEB-1994
8905 |-A--------------|-B--------------------------------------->
8906 ED
8907
8908 After :-
8909 02-JAN-1994 05-FEB-1994 15-JUL-1994
8910 |-A--------------|-B-------------------|
8911 ED
8912
8913 */
8914 if l_immediate_end=false then
8915 --
8916 -- Annualize the rate
8917 --
8918 if g_debug then
8919 hr_utility.set_location('prv_id= '|| p_prtt_rt_val_id,10);
8920 hr_utility.set_location('payroll= '|| l_payroll_id,10);
8921 hr_utility.set_location('bg= '|| p_business_group_id,10);
8922 hr_utility.set_location('rt_end= '|| l_rt_end_dt,10);
8923 hr_utility.set_location('effective_date= '|| p_effective_date,10);
8924 end if;
8925 --
8926 -- ELE : By pass if the ele_entry_val_cd <> PP , EPP or null.
8927 --
8928 if nvl(l_ele_entry_val_cd, 'PP') = 'PP' or
8929 l_ele_entry_val_cd = 'EPP' then
8930 --
8931 open c_plan_year_end_for_pen
8932 (c_prtt_enrt_rslt_id => p_enrt_rslt_id
8933 ,c_rate_start_or_end_dt => l_rt_end_dt
8934 ,c_effective_date => p_effective_date
8935 );
8936 fetch c_plan_year_end_for_pen into l_last_pp_strt_dt, l_last_pp_end_dt;
8937 close c_plan_year_end_for_pen;
8938 --
8939 -- For ending always do full year processing
8940 --
8941 --l_range_start:=add_months(l_last_pp_end_dt,-12)+1;
8942 --
8943 --BUG 3294702
8944 --l_range_start:=add_months(l_last_pp_end_dt,-12)+1;
8945 l_range_start:=l_last_pp_strt_dt ;
8946 --
8947 if g_debug then
8948 hr_utility.set_location('range start= '|| l_range_start,10);
8949 hr_utility.set_location('range end = '|| l_last_pp_end_dt,10);
8950 hr_utility.set_location('p_amt='||p_amt,100);
8951 end if;
8952 l_amt:=ben_distribute_rates.period_to_annual(
8953 p_amount =>p_amt
8954 ,p_acty_ref_perd_cd =>p_acty_ref_perd
8955 ,p_business_group_id =>p_business_group_id
8956 ,p_effective_date =>p_effective_date
8957 ,p_complete_year_flag =>'N' -- done using start
8958 ,p_use_balance_flag =>'N'
8959 ,p_element_type_id => l_element_type_id
8960 ,p_start_date =>l_range_start
8961 ,p_end_date =>l_last_pp_end_dt
8962 ,p_payroll_id =>l_payroll_id
8963 ,p_rounding_flag =>'N'
8964 );
8965 --
8966 -- to do proration need monthly amount divide by 12.
8967 --
8968 l_per_month_amt := l_amt/12;
8969 if g_debug then
8970 hr_utility.set_location('l_per_month_amt='||l_per_month_amt,100);
8971 hr_utility.set_location('l_amt='||l_amt,100);
8972 end if;
8973 --
8974 -- Compute per pay amt
8975 --
8976 if l_ele_entry_val_cd = 'EPP' then
8977 l_perd_cd := 'EPP';
8978 end if;
8979 l_per_pay_amt:=ben_distribute_rates.annual_to_period(
8980 p_amount =>l_amt
8981 ,p_acty_ref_perd_cd =>l_perd_cd --'PP' -- per pay period
8982 ,p_business_group_id =>p_business_group_id
8983 ,p_effective_date =>p_effective_date
8984 ,p_complete_year_flag =>'N'
8985 ,p_use_balance_flag =>'N'
8986 ,p_element_type_id => l_element_type_id
8987 ,p_start_date =>l_range_start
8988 ,p_end_date =>l_last_pp_end_dt
8989 ,p_payroll_id =>l_payroll_id
8990 );
8991 if g_debug then
8992 hr_utility.set_location('l_per_pay_amt'||l_per_pay_amt,293.1);
8993 end if;
8994 --
8995 if (l_abr_rndg_cd is not null or
8996 l_abr_rndg_rl is not null) and
8997 l_per_pay_amt is not null then
8998 --
8999 l_per_pay_amt := benutils.do_rounding
9000 (p_rounding_cd => l_abr_rndg_cd,
9001 p_rounding_rl => l_abr_rndg_rl,
9002 p_value => l_per_pay_amt,
9003 p_effective_date => p_effective_date);
9004 elsif l_per_pay_amt is not null and
9005 l_per_pay_amt<>0 then
9006 --
9007 -- Do this for now: in future default to rounding for currency prec
9008 --
9009 l_per_pay_amt:=round(l_per_pay_amt,2);
9010 end if;
9011 --
9012 -- Prorate the rate, if necessary
9013 -- let prorate_amount function decide then either
9014 -- l_new_val is the same as l_amount, or not for proration.
9015 -- l_prtn_val will be set.
9016 --
9017 if g_debug then
9018 hr_utility.set_location('Prorate the rate',20);
9019 hr_utility.set_location('l_per_month_amt '||l_per_month_amt,20);
9020 end if;
9021 --
9022 -- Bug 6834340
9023 open c_ler_with_ended_prv(p_prtt_rt_val_id, p_rt_end_date);
9024 fetch c_ler_with_ended_prv into l_ler_with_ended_prv;
9025 close c_ler_with_ended_prv;
9026 -- Bug 6834340
9027 --
9028 l_prorated_monthly_amt := prorate_amount(
9029 p_amt =>l_per_month_amt
9030 ,p_acty_base_rt_id =>p_acty_base_rt_id
9031 ,p_prorate_flag =>l_prtn_flag
9032 ,p_effective_date =>p_effective_date
9033 ,p_start_or_stop_cd =>'STP'
9034 ,p_start_or_stop_date =>l_rt_end_dt
9035 ,p_business_group_id =>p_business_group_id
9036 ,p_assignment_id =>l_assignment_id
9037 ,p_organization_id =>l_organization_id
9038 ,p_wsh_rl_dy_mo_num =>l_wsh_rl_dy_mo_num
9039 ,p_prtl_mo_det_mthd_cd =>l_prtl_mo_det_mthd_cd
9040 ,p_prtl_mo_det_mthd_rl =>l_prtl_mo_det_mthd_rl
9041 -- new parms below
9042 ,p_person_id =>g_result_rec.person_id
9043 ,p_pgm_id =>g_result_rec.pgm_id
9044 ,p_pl_typ_id =>g_result_rec.pl_typ_id
9045 ,p_pl_id =>g_result_rec.pl_id
9046 ,p_opt_id =>g_result_rec.opt_id
9047 ,p_ler_id =>l_ler_with_ended_prv.ler_id -- Bug 6834340
9048 ,p_jurisdiction_code =>l_jurisdiction_code
9049 ,p_rndg_cd =>l_abr_rndg_cd
9050 ,p_rndg_rl =>l_abr_rndg_rl
9051 );
9052 --
9053 -- ELE :
9054 end if;
9055 -- already have the element_entry_id
9056 --
9057 -- Check the PRTL MONTH PRORATION rule
9058 -- against the effective date and payperiod
9059 -- of participants payroll.
9060 --
9061 -- Get the Element Link ID
9062 -- and the Input value id for EE Contr.
9063 --
9064 -- ELE : By pass if the ele_entry_val_cd <> PP , EPP or null.
9065 --
9066 if nvl(l_ele_entry_val_cd, 'PP') not in ('PP','EPP') then
9067 l_prtn_flag := 'N';
9068 l_special_pp_date := null;
9069 end if;
9070 --
9071 -- Determine prorated first pay periods
9072 -- Where amount is not the normal per pay period amount
9073 --
9074 if l_prtn_flag = 'Y' then
9075 if g_debug then
9076 hr_utility.set_location('Determine proration ',40);
9077 end if;
9078 if l_prtl_mo_eff_dt_det_cd = 'RL' and
9079 l_prtl_mo_eff_dt_det_rl is not null then
9080 --
9081 -- exec rule and get code back
9082 --
9083 l_outputs:=benutils.formula
9084 (p_opt_id =>g_result_rec.opt_id,
9085 p_pl_id =>g_result_rec.pl_id,
9086 p_pgm_id =>g_result_rec.pgm_id,
9087 p_formula_id =>l_prtl_mo_eff_dt_det_rl,
9088 p_ler_id =>g_result_rec.ler_id,
9089 p_pl_typ_id =>g_result_rec.pl_typ_id,
9090 p_assignment_id =>l_assignment_id,
9091 p_acty_base_rt_id =>p_acty_base_rt_id,
9092 p_business_group_id =>p_business_group_id,
9093 p_organization_id =>l_organization_id,
9094 p_jurisdiction_code =>l_jurisdiction_code,
9095 p_effective_date =>l_rt_end_dt);
9096 --
9097 begin
9098 --
9099 -- convert return value to code
9100 --
9101 l_prtl_mo_eff_dt_det_cd:=l_outputs(l_outputs.first).value;
9102 --
9103 exception
9104 --
9105 when others then
9106 if g_debug then
9107 hr_utility.set_location('BEN_92311_FORMULA_VAL_PARAM',46);
9108 end if;
9109 fnd_message.set_name('BEN','BEN_92311_FORMULA_VAL_PARAM');
9110 fnd_message.set_token('PROC',l_proc);
9111 fnd_message.set_token('FORMULA',l_prtl_mo_det_mthd_rl);
9112 fnd_message.set_token('PARAMETER',
9113 l_outputs(l_outputs.first).name);
9114 fnd_message.raise_error;
9115 --
9116 end;
9117 end if;
9118 --
9119 -- Approach/algorithm to allocating payments:
9120 --
9121 -- In ending a rate there are three distinct rate stages
9122 -- 1) Normal pay periods - Periodic rate is still in place.
9123 -- 2) Special pay period - pay period during which a rate not equal to the normal rate
9124 -- is in effect. Just one pay period. Spreading them out is outside the scope
9125 -- of this version.
9126 -- 3) No pay periods - pay periods during which no rate should be in effect.
9127 -----------------------------------------------------------
9128 --
9129 -- Want to find the pay periods from the start date
9130 -- ending at the last day of the month or earlier
9131 -- based on the date column specified by prtl_mo_eff_dt_det_cd
9132 --
9133 -- Go backwards and keep overwriting the dates with the most
9134 -- recent one to get the first date it changes to that rate.
9135 --
9136 l_remainder:=l_prorated_monthly_amt;
9137 l_number_in_month:=0;
9138 for l_pay_periods in c_last_pay_periods(
9139 p_start_date => trunc(l_rt_end_dt,'mm'),
9140 p_end_date => add_months(
9141 trunc(l_rt_end_dt,'mm'),1)-1,
9142 p_prtl_mo_eff_dt_det_cd => l_prtl_mo_eff_dt_det_cd,
9143 p_payroll_id => l_payroll_id) loop
9144 --
9145 exit when l_pay_periods.start_date > l_rt_end_dt;
9146 --
9147 hr_elements.check_element_freq(
9148 p_payroll_id =>l_payroll_id,
9149 p_bg_id =>p_business_group_id,
9150 p_pay_action_id =>to_number(null),
9151 p_date_earned =>l_pay_periods.start_date,
9152 p_ele_type_id =>l_element_type_id,
9153 p_skip_element =>g_skip_element
9154 );
9155 if g_skip_element='N' then
9156 l_number_in_month:=l_number_in_month+1;
9157 if g_debug then
9158 hr_utility.set_location('l_zero_pp_date'||l_pay_periods.start_date,293.1);
9159 hr_utility.set_location('l_remainder'||l_remainder,293.1);
9160 hr_utility.set_location('l_pay_periods.end_date'||l_pay_periods.end_date,293.1);
9161 hr_utility.set_location('l_per_pay_amt'||l_per_pay_amt,293.1);
9162 hr_utility.set_location('l_rt_end_dt'||l_rt_end_dt,293.1);
9163 end if;
9164 if (l_remainder>l_per_pay_amt and
9165 l_rt_end_dt > l_pay_periods.end_date) then
9166 --
9167 -- Normal pay period, may not be if have remainder left over
9168 -- In this case will revise date after loop is done
9169 --
9170 l_remainder:=l_remainder-l_per_pay_amt;
9171 l_old_normal_pp_date:=l_normal_pp_date;
9172 l_old_normal_pp_end_date:=l_normal_pp_end_date;
9173 l_normal_pp_end_date:=l_pay_periods.end_date;
9174 l_normal_pp_date:=l_pay_periods.start_date;
9175 if g_debug then
9176 hr_utility.set_location('normal end date'||l_normal_pp_end_date,293.1);
9177 end if;
9178 if g_debug then
9179 hr_utility.set_location('l_per_pay_amt'||l_per_pay_amt,293.1);
9180 end if;
9181 elsif l_remainder=0 then
9182 --
9183 -- Free pay period, no charge
9184 --
9185 l_zero_pp_date := l_pay_periods.start_date;
9186 if g_debug then
9187 hr_utility.set_location('l_zero_pp_date'||l_pay_periods.start_date,293.1);
9188 end if;
9189 exit;
9190 else
9191 --
9192 -- Special small pay period, from here on it's free.
9193 --
9194 l_special_pp_end_date:=l_pay_periods.end_date;
9195 l_special_pp_date:=l_pay_periods.start_date;
9196 l_special_amt:=l_remainder;
9197 l_remainder:=0;
9198 end if;
9199 end if;
9200 end loop;
9201 --
9202 -- Now check if loop was not entered
9203 --
9204 if l_remainder > 0 then
9205 --
9206 -- This is the Large amount case where the full amount gets added
9207 -- to the last pp of prev month
9208 --
9209 --
9210 -- The remaining amount is added to the current pay period.
9211 --
9212 open c_get_current_pp
9213 (p_end_date => l_rt_end_dt
9214 ,p_prtl_mo_eff_dt_det_cd => l_prtl_mo_eff_dt_det_cd
9215 ,p_payroll_id => l_payroll_id
9216 );
9217 fetch c_get_current_pp into l_start_date,l_end_date;
9218 if c_get_current_pp%notfound then
9219 close c_get_current_pp;
9220 if g_debug then
9221 hr_utility.set_location('BEN_92346_PAYROLL_NOT_DEFINED',48);
9222 end if;
9223 fnd_message.set_name('BEN', 'BEN_92346_PAYROLL_NOT_DEFINED');
9224 fnd_message.set_token('PROC',l_proc);
9225 fnd_message.raise_error;
9226 end if;
9227 --
9228 close c_get_current_pp;
9229 --
9230 -- Prorate for the current pay period.
9231 --
9232 -- If it is a skip period, do not prorate.
9233 --
9234 hr_elements.check_element_freq(
9235 p_payroll_id =>l_payroll_id,
9236 p_bg_id =>p_business_group_id,
9237 p_pay_action_id =>to_number(null),
9238 p_date_earned =>l_start_date,
9239 p_ele_type_id =>l_element_type_id,
9240 p_skip_element =>g_skip_element
9241 );
9242 --
9243 if g_skip_element = 'N' then
9244 l_special_pp_end_date:= l_end_date;
9245 l_special_pp_date:= l_start_date;
9246 if (l_number_in_month = 0 or
9247 l_end_date = l_rt_end_dt) then
9248 l_special_amt:=l_remainder + l_per_pay_amt;
9249 else
9250 l_special_amt := l_remainder;
9251 end if;
9252 else
9253 --
9254 -- If skip element then display a informational message
9255 -- indicating that there is no proration and user will need
9256 -- to manually process a deduction.
9257 --
9258 ben_warnings.load_warning
9259 (p_application_short_name => 'BEN',
9260 p_message_name => 'BEN_92939_NO_PRORATION',
9261 p_person_id => p_person_id);
9262 --
9263 fnd_message.set_name('BEN', 'BEN_92939_NO_PRORATION');
9264 if fnd_global.conc_request_id <> -1 then
9265 benutils.write(fnd_message.get);
9266 end if;
9267 --
9268 l_immediate_end := true;
9269 end if;
9270 elsif (l_remainder = 0 and
9271 l_rt_end_dt > l_special_pp_end_date
9272 and l_zero_pp_date is null) then
9273 --
9274 -- The remaining amount is added to the current pay period.
9275 --
9276 open c_get_current_pp
9277 (p_end_date => l_rt_end_dt
9278 ,p_prtl_mo_eff_dt_det_cd => l_prtl_mo_eff_dt_det_cd
9279 ,p_payroll_id => l_payroll_id
9280 );
9281 fetch c_get_current_pp into l_zero_pp_date,l_end_date;
9282 if c_get_current_pp%notfound then
9283 close c_get_current_pp;
9284 if g_debug then
9285 hr_utility.set_location('BEN_92346_PAYROLL_NOT_DEFINED',48);
9286 end if;
9287 fnd_message.set_name('BEN', 'BEN_92346_PAYROLL_NOT_DEFINED');
9288 fnd_message.set_token('PROC',l_proc);
9289 fnd_message.raise_error;
9290 end if;
9291 --
9292 close c_get_current_pp;
9293 end if; -- l_remainder > 0
9294 --
9295 --
9296 -- In the cases where a normal pp was not found then it
9297 -- must be the last pp of the previous month but
9298 --
9299 --
9300 if l_normal_pp_date is null then
9301 open c_pps_prev_month(
9302 p_end_date => trunc(l_rt_end_dt,'mm'),
9303 p_prtl_mo_eff_dt_det_cd => l_prtl_mo_eff_dt_det_cd,
9304 p_payroll_id => l_payroll_id);
9305 loop
9306 fetch c_pps_prev_month into l_start_date,l_end_date;
9307 if c_pps_prev_month%notfound then
9308 close c_pps_prev_month;
9309 if g_debug then
9310 hr_utility.set_location('BEN_92346_PAYROLL_NOT_DEFINED',50);
9311 end if;
9312 fnd_message.set_name('BEN', 'BEN_92346_PAYROLL_NOT_DEFINED');
9313 fnd_message.set_token('PROC',l_proc);
9314 fnd_message.raise_error;
9315 end if;
9316 hr_elements.check_element_freq(
9317 p_payroll_id =>l_payroll_id,
9318 p_bg_id =>p_business_group_id,
9319 p_pay_action_id =>to_number(null),
9320 p_date_earned =>l_start_date,
9321 p_ele_type_id =>l_element_type_id,
9322 p_skip_element =>g_skip_element
9323 );
9324 exit when g_skip_element='N';
9325 end loop;
9326 close c_pps_prev_month;
9327 l_normal_pp_end_date:=l_end_date;
9328 l_normal_pp_date:=l_start_date;
9329 if g_debug then
9330 hr_utility.set_location('normal end date'||l_normal_pp_end_date,293.1);
9331 end if;
9332 end if;
9333 else
9334 --
9335 -- No proration end on rt_end date.
9336 --
9337 l_immediate_end:=true;
9338 --
9339 end if;
9340 --
9341 -- Don't make unnecessary changes: compare old value to new one
9342 --
9343 -- Do special pay period.
9344 --
9345 if g_debug then
9346 hr_utility.set_location('l_special_pp_date '||l_special_pp_date,20);
9347 hr_utility.set_location('l_special_amt '||l_special_amt,20);
9348 end if;
9349
9350 if l_special_pp_date is not null and
9351 l_immediate_end=false then
9352 --
9353 -- bug 2651153 get the currency of the program
9354
9355 --
9356 -- changes the format of the screen entry value as per the session
9357 --
9358
9359 if l_uom is null then
9360 l_uom := get_uom(p_business_group_id,p_effective_date);
9361 end if;
9362 l_curr_val := chkformat(l_curr_val_char, l_uom);
9363
9364 if g_debug then
9365 hr_utility.set_location('l_uom='|| l_uom ,432);
9366 hr_utility.set_location('aft frmt chg '||l_curr_val_char,432);
9367 hr_utility.set_location('converted no. value is '||l_curr_val,432);
9368 end if;
9369
9370 if nvl(l_curr_val,hr_api.g_number) <>l_special_amt then
9371 /*
9372 Before :-
9373 02-JAN-1994
9374 |-A----------------------------------------------------->
9375 ED
9376
9377 After :-
9378 02-JAN-1994 15-JUL-1994
9379 |-A----------------------------|-B---------------------->
9380 ED
9381 */
9382
9383 -- Bug 2331574 start
9384 -- To handle cases where the element entry start date >
9385 -- special pay period start date
9386 if g_debug then
9387 hr_utility.set_location('Updating if the rate has changed ',90);
9388 hr_utility.set_location('l_immediate_end=false ',20);
9389 end if;
9390
9391 if l_special_pp_date < l_element_entry_start_date then
9392 l_special_pp_date := l_element_entry_start_date;
9393 end if;
9394
9395 -- Determine the Date track update mode for calling
9396 -- py_element_entry_api.update_element_entry
9397
9398 l_dt_upd_mode := get_ele_dt_upd_mode(l_special_pp_date,l_element_entry_id);
9399 --
9400 open c_element_ovn (l_element_entry_id, l_special_pp_date);
9401 fetch c_element_ovn into l_object_version_number;
9402 close c_element_ovn;
9403 --
9404 if g_debug then
9405 hr_utility.set_location('Obj No.'||l_object_version_number,111);
9406 hr_utility.set_location('Special PP'||l_special_pp_date,112);
9407 hr_utility.set_location('Datetrack Mode'||l_dt_upd_mode,113);
9408 end if;
9409
9410 py_element_entry_api.update_element_entry
9411 (p_validate =>p_validate
9412 ,p_datetrack_update_mode =>l_dt_upd_mode
9413 ,p_effective_date =>l_special_pp_date
9414 ,p_business_group_id =>p_business_group_id
9415 ,p_element_entry_id =>l_element_entry_id
9416 ,p_object_version_number =>l_object_version_number
9417 ,p_creator_type =>'F'
9418 ,p_creator_id =>p_enrt_rslt_id
9419 ,p_override_user_ent_chk =>'Y'
9420 ,p_input_value_id1 =>l_input_value_id
9421 ,p_entry_value1 =>l_special_amt
9422 ,p_effective_start_date =>l_new_date
9423 ,p_effective_end_date =>l_end_of_time
9424 ,p_update_warning =>l_update_warning
9425 );
9426 --
9427 --
9428 -- write to the change event log
9429 --
9430 ben_ext_chlg.log_element_chg(
9431 p_action => l_dt_upd_mode,
9432 p_amt => l_special_amt,
9433 p_old_amt => l_curr_val,
9434 p_input_value_id => l_input_value_id,
9435 p_element_entry_id => l_element_entry_id,
9436 p_person_id => p_person_id,
9437 p_business_group_id => p_business_group_id,
9438 p_effective_date => l_special_pp_date);
9439 --
9440 --
9441 -- Set the rate end date to the earlier of the
9442 -- rate_end_date or the period end date
9443 --
9444 end if;
9445 end if;
9446 --
9447 -- Bug:2730801 - Moved the following code out from the
9448 -- special pay periods if condition.
9449 -- Because this is executing only for the special pay periods.
9450 --
9451 /*
9452 Example: When rate has a wash role as 15 days. If a employee
9453 terminated 14th of the month then he should not get charged
9454 from 1st to 14th of the month, that pay period will be
9455 zero pay period.
9456 Before :-
9457 02-JAN-1994
9458 |-A----------------------------------------------------->
9459 ED
9460
9461 After :-
9462 02-JAN-1994 01-JUL-94 14-JUL-1994
9463 |-A------------------|----------|-B---------------------->
9464 zero pp ED
9465 */
9466 if l_zero_pp_date is not null and
9467 l_immediate_end=false then
9468 --
9469 l_curr_val := l_special_amt;
9470 if g_debug then
9471 hr_utility.set_location('l_zero_pp_date '||l_zero_pp_date,20);
9472 end if;
9473
9474 l_dt_to_use := greatest(l_prv_rec.rt_strt_dt,l_zero_pp_date);
9475 open c_element_ovn (l_element_entry_id, l_dt_to_use);
9476 fetch c_element_ovn into l_object_version_number;
9477 close c_element_ovn;
9478 --
9479 l_dt_upd_mode := get_ele_dt_upd_mode(l_dt_to_use,l_element_entry_id);
9480
9481 py_element_entry_api.update_element_entry
9482 (p_validate =>p_validate
9483 ,p_datetrack_update_mode =>l_dt_upd_mode
9484 ,p_effective_date =>l_dt_to_use
9485 ,p_business_group_id =>p_business_group_id
9486 ,p_element_entry_id =>l_element_entry_id
9487 ,p_object_version_number =>l_object_version_number
9488 ,p_override_user_ent_chk =>'Y'
9489 ,p_creator_type =>'F'
9490 ,p_creator_id =>p_enrt_rslt_id
9491 ,p_input_value_id1 =>l_input_value_id
9492 ,p_entry_value1 =>0
9493 ,p_effective_start_date =>l_new_date
9494 ,p_effective_end_date =>l_end_of_time
9495 ,p_update_warning =>l_update_warning
9496 );
9497 --
9498 -- write to the change event log
9499 --
9500 ben_ext_chlg.log_element_chg
9501 (p_action => hr_api.g_update
9502 ,p_amt => 0
9503 ,p_old_amt => l_curr_val
9504 ,p_input_value_id => l_input_value_id
9505 ,p_element_entry_id => l_element_entry_id
9506 ,p_person_id => p_person_id
9507 ,p_business_group_id => p_business_group_id
9508 ,p_effective_date => l_dt_to_use
9509 );
9510 end if;
9511 end if;
9512 --
9513 -- Done with special value pay period, now end rate
9514 --
9515 if g_debug then
9516 hr_utility.set_location('DT Delete mode '||l_dt_delete_mode,30);
9517 end if;
9518 --
9519 if l_another_prv_exists then
9520 --
9521 l_dt_upd_mode := get_ele_dt_upd_mode(l_rt_end_dt+1,l_element_entry_id);
9522 --
9523 -- get the ovn
9524 --
9525 open c_element_ovn (l_element_entry_id, l_rt_end_dt+1);
9526 fetch c_element_ovn into l_object_version_number;
9527 close c_element_ovn;
9528 --
9529 py_element_entry_api.update_element_entry
9530 (p_validate =>p_validate
9531 ,p_datetrack_update_mode =>l_dt_upd_mode
9532 ,p_effective_date =>l_rt_end_dt + 1
9533 ,p_business_group_id =>p_business_group_id
9534 ,p_element_entry_id =>l_element_entry_id
9535 ,p_override_user_ent_chk =>'Y'
9536 ,p_object_version_number =>l_object_version_number
9537 ,p_input_value_id1 =>l_input_value_id
9538 ,p_entry_value1 =>0
9539 ,p_effective_start_date =>l_effective_start_date
9540 ,p_effective_end_date =>l_effective_end_date
9541 ,p_update_warning =>l_update_warning
9542 );
9543 --
9544 -- write to the change event log
9545 --
9546 ben_ext_chlg.log_element_chg
9547 (p_action => 'UPDATE'
9548 ,p_amt => 0
9549 ,p_old_amt => fnd_number.canonical_to_number(l_curr_val_char)
9550 ,p_input_value_id => l_input_value_id
9551 ,p_element_entry_id => l_element_entry_id
9552 ,p_person_id => p_person_id
9553 ,p_business_group_id=> p_business_group_id
9554 ,p_effective_date => l_rt_end_dt + 1
9555 );
9556 --
9557 else
9558 --
9559 -- get the ovn
9560 --
9561 open c_element_ovn (l_element_entry_id, l_rt_end_dt);
9562 fetch c_element_ovn into l_object_version_number;
9563 close c_element_ovn;
9564 --
9565 py_element_entry_api.delete_element_entry
9566 (p_validate => p_validate
9567 ,p_datetrack_delete_mode => l_dt_delete_mode
9568 ,p_effective_date => l_rt_end_dt
9569 ,p_element_entry_id => l_element_entry_id
9570 ,p_object_version_number => l_object_version_number
9571 ,p_effective_start_date => l_effective_start_date
9572 ,p_effective_end_date => l_effective_end_date
9573 ,p_delete_warning => l_delete_warning);
9574 --
9575 -- write to the change event log
9576 --
9577 ben_ext_chlg.log_element_chg(
9578 p_action => hr_api.g_delete,
9579 p_old_amt => fnd_number.canonical_to_number(l_curr_val_char),
9580 p_input_value_id => l_input_value_id,
9581 p_element_entry_id => l_element_entry_id,
9582 p_person_id => p_person_id,
9583 p_business_group_id => p_business_group_id,
9584 p_effective_date => l_rt_end_dt);
9585 --
9586 end if;
9587
9588 if l_abs_ler then
9589 pqp_absence_plan_process.update_absence_plan_details
9590 (p_person_id => p_person_id
9591 ,p_assignment_id => l_assignment_id
9592 ,p_business_group_id => p_business_group_id
9593 ,p_legislation_code => get_legislation_code(p_business_group_id)
9594 ,p_effective_date => p_effective_date
9595 ,p_element_type_id => l_element_type_id
9596 ,p_pl_id => g_result_rec.pl_id
9597 ,p_pl_typ_id => g_result_rec.pl_typ_id
9598 ,p_ler_id => l_ler_id
9599 ,p_per_in_ler_id => l_per_in_ler_id
9600 ,p_absence_attendance_id => l_absence_attendance_id
9601 ,p_effective_start_date => l_effective_start_date
9602 ,p_effective_end_date => l_effective_end_date
9603 ,p_formula_outputs => g_outputs
9604 ,p_error_code => l_err_code
9605 ,p_error_message => l_err_mesg
9606 );
9607 end if;
9608 --
9609 end if;
9610 --
9611 -- delete/update any future entries for the same enrt result.
9612 -- Future entries could exist if there was an update to assignment
9613 -- that affected link eligibility
9614 --
9615 open get_future_element_entry
9616 (p_enrt_rslt_id
9617 ,l_assignment_id
9618 ,l_element_type_id
9619 ,l_effective_date);
9620 loop
9621 fetch get_future_element_entry into l_future_ee_rec;
9622 if get_future_element_entry%notfound then
9623 exit;
9624 end if;
9625
9626 if l_another_prv_exists then
9627 --
9628 l_dt_upd_mode := get_ele_dt_upd_mode
9629 (l_future_ee_rec.effective_end_date,
9630 l_future_ee_rec.element_entry_id);
9631 --
9632 py_element_entry_api.update_element_entry
9633 (p_validate =>p_validate
9634 ,p_datetrack_update_mode =>l_dt_upd_mode
9635 ,p_effective_date =>l_future_ee_rec.effective_end_date
9636 ,p_business_group_id =>p_business_group_id
9637 ,p_element_entry_id =>l_future_ee_rec.element_entry_id
9638 ,p_override_user_ent_chk =>'Y'
9639 ,p_object_version_number =>l_future_ee_rec.object_version_number
9640 ,p_input_value_id1 =>l_input_value_id
9641 ,p_entry_value1 =>0
9642 ,p_effective_start_date =>l_effective_start_date
9643 ,p_effective_end_date =>l_effective_end_date
9644 ,p_update_warning =>l_update_warning
9645 );
9646 --
9647 -- write to the change event log
9648 --
9649 ben_ext_chlg.log_element_chg
9650 (p_action => l_dt_upd_mode
9651 ,p_amt => 0
9652 ,p_old_amt => fnd_number.canonical_to_number(l_curr_val_char)
9653 ,p_input_value_id => l_input_value_id
9654 ,p_element_entry_id => l_future_ee_rec.element_entry_id
9655 ,p_person_id => p_person_id
9656 ,p_business_group_id=> p_business_group_id
9657 ,p_effective_date => p_effective_date);
9658 --
9659 else
9660 py_element_entry_api.delete_element_entry
9661 (p_validate => p_validate
9662 ,p_datetrack_delete_mode => hr_api.g_zap
9663 ,p_effective_date => l_future_ee_rec.effective_start_date
9664 ,p_element_entry_id => l_future_ee_rec.element_entry_id
9665 ,p_object_version_number => l_future_ee_rec.object_version_number
9666 ,p_effective_start_date => l_effective_start_date
9667 ,p_effective_end_date => l_effective_end_date
9668 ,p_delete_warning => l_delete_warning
9669 );
9670 --
9671 -- write to the change event log
9672 --
9673 ben_ext_chlg.log_element_chg(
9674 p_action => 'DELETE',
9675 p_old_amt => fnd_number.canonical_to_number(l_curr_val_char),
9676 p_input_value_id => l_input_value_id,
9677 p_element_entry_id => l_future_ee_rec.element_entry_id,
9678 p_person_id => p_person_id,
9679 p_business_group_id => p_business_group_id,
9680 p_effective_date => p_effective_date);
9681 --
9682 end if;
9683 --
9684 end loop;
9685 close get_future_element_entry;
9686
9687 if g_debug then
9688 hr_utility.set_location('Leaving :'||l_proc,5);
9689 end if;
9690
9691 end end_enrollment_element;
9692 --
9693 -- 0 - Always refresh
9694 -- 1 - Initialise cache
9695 -- 2 - Cache hit
9696 --
9697 procedure clear_down_cache
9698 is
9699
9700 begin
9701 --
9702 g_get_link_cache.delete;
9703 g_get_link_cached := 1;
9704 g_abr_asg_rec := null;
9705 g_per_pay_rec := null;
9706 --
9707 end clear_down_cache;
9708 --
9709 procedure set_no_cache_context
9710 is
9711
9712 begin
9713 --
9714 g_get_link_cache.delete;
9715 g_get_link_cached := 0;
9716 --
9717 end set_no_cache_context;
9718 --
9719 procedure reset_msg_displayed --bug 2530582
9720 is
9721 begin
9722 g_msg_displayed := 0;
9723 end reset_msg_displayed;
9724 --
9725 procedure create_reimburse_element
9726 (p_validate in boolean default false
9727 ,p_person_id in number
9728 ,p_acty_base_rt_id in number
9729 ,p_amt in number
9730 ,p_business_group_id in number
9731 ,p_effective_date in date
9732 ,p_prtt_reimbmt_rqst_id in number default null
9733 ,p_input_value_id in number default null
9734 ,p_element_type_id in number default null
9735 ,p_pl_id in number default null
9736 ,p_prtt_rmt_aprvd_fr_pymt_id in number
9737 ,p_object_version_number in out nocopy number
9738 ) is
9739 --
9740 cursor c_element_entry (p_element_entry_id number,
9741 p_input_value_id number) is
9742 select element_entry_value_id
9743 from pay_element_entry_values_f
9744 where ELEMENT_ENTRY_ID = p_element_entry_id
9745 and input_value_id = p_input_value_id;
9746 --
9747 cursor c_ety is
9748 select processing_type
9749 from pay_element_types_f
9750 where element_type_id = p_element_type_id
9751 and p_effective_date between effective_start_date
9752 and effective_end_date ;
9753 --
9754 l_tmp_bool boolean;
9755 l_assignment_id number;
9756 l_organization_id number;
9757 l_payroll_id number;
9758 l_create_warning BOOLEAN;
9759 l_update_warning BOOLEAN;
9760 l_effective_start_date date;
9761 l_effective_end_Date date;
9762 l_object_version_number number;
9763 l_element_link_id NUMBER;
9764 l_input_value_id number;
9765 L_ELEMENT_ENTRY_ID number;
9766 l_element_entry_value_id number;
9767 l_processing_type varchar2(300);
9768 l_delete_warning boolean;
9769 --
9770
9771 begin
9772 --
9773 if g_debug then
9774 hr_utility.set_location('Entering : create_reimburse_element',50);
9775 end if;
9776 l_tmp_bool:=chk_assign_exists
9777 (p_person_id => p_person_id
9778 ,p_business_group_id => p_business_group_id
9779 ,p_effective_date => p_effective_date
9780 ,p_rate_date => p_effective_date
9781 ,p_acty_base_rt_id => p_acty_base_rt_id
9782 ,p_assignment_id => l_assignment_id
9783 ,p_organization_id => l_organization_id
9784 ,p_payroll_id => l_payroll_id
9785 );
9786 --
9787 --
9788 if g_debug then
9789 hr_utility.set_location('l_assignment_id:'||l_assignment_id,50);
9790 hr_utility.set_location('l_payroll_id:'||l_payroll_id,50);
9791 end if;
9792 --
9793 get_link(p_assignment_id => l_assignment_id
9794 ,p_element_type_id => p_element_type_id
9795 ,p_business_group_id => p_business_group_id
9796 ,p_input_value_id => l_input_value_id
9797 ,p_effective_date => p_effective_date
9798 ,p_element_link_id => l_element_link_id
9799 );
9800 if l_element_link_id is null then
9801 --
9802 -- error message already set on stack.
9803 --
9804 fnd_message.raise_error;
9805 end if;
9806 hr_utility.set_location( 'entering', 30.2);
9807 py_element_entry_api.create_element_entry
9808 (p_validate =>p_validate
9809 ,p_effective_date =>p_effective_date
9810 ,p_business_group_id =>p_business_group_id
9811 ,p_assignment_id =>l_assignment_id
9812 ,p_element_link_id =>l_element_link_id
9813 ,p_entry_type =>'E'
9814 ,p_input_value_id1 =>p_input_value_id
9815 ,p_entry_value1 =>p_amt
9816 ,p_effective_start_date =>l_effective_start_date
9817 ,p_effective_end_date =>l_effective_end_Date
9818 ,p_element_entry_id =>l_element_entry_id
9819 ,p_object_version_number =>l_object_version_number
9820 ,p_create_warning =>l_create_warning
9821 );
9822 --
9823 --
9824 hr_utility.set_location('Change creator type and id ',50);
9825 py_element_entry_api.update_element_entry
9826 (p_validate =>p_validate
9827 ,p_datetrack_update_mode =>'CORRECTION'
9828 ,p_effective_date =>p_effective_date
9829 ,p_business_group_id =>p_business_group_id
9830 ,p_element_entry_id =>l_element_entry_id
9831 ,p_object_version_number =>l_object_version_number
9832 ,p_creator_type =>'F'
9833 ,p_creator_id =>p_prtt_reimbmt_rqst_id
9834 ,p_input_value_id1 =>p_input_value_id
9835 ,p_entry_value1 =>p_amt
9836 ,p_effective_start_date =>l_effective_start_date
9837 ,p_effective_end_date =>l_effective_end_Date
9838 ,p_update_warning =>l_update_warning
9839 );
9840 --
9841 --
9842 open c_ety;
9843 fetch c_ety into l_processing_type;
9844 if l_processing_type = 'R' then
9845 -- the element should be end dated
9846 py_element_entry_api.delete_element_entry
9847 (p_validate => p_validate
9848 ,p_datetrack_delete_mode => hr_api.g_delete
9849 ,p_effective_date => p_effective_date
9850 ,p_element_entry_id => l_element_entry_id
9851 ,p_object_version_number => l_object_version_number
9852 ,p_effective_start_date => l_effective_start_date
9853 ,p_effective_end_date => l_effective_end_date
9854 ,p_delete_warning => l_delete_warning
9855 );
9856 --
9857
9858 end if;
9859 close c_ety;
9860 --
9861 open c_element_entry (l_element_entry_id,p_input_value_id);
9862 fetch c_element_entry into l_element_entry_value_id;
9863 close c_element_entry;
9864 --
9865 if l_element_entry_value_id is null then
9866 --
9867 if g_debug then
9868 hr_utility.set_location('BEN_92102_NO_ENTRY_CREATED',140);
9869 end if;
9870 fnd_message.set_name('BEN', 'BEN_92102_NO_ENTRY_CREATED');
9871 fnd_message.set_token('PROC','Create_reimburse_element');
9872 fnd_message.set_token('ELEMENT_ENTRY_ID',to_char(l_element_link_id));
9873 fnd_message.set_token('INPUT_VALUE_ID',to_char(l_input_value_id));
9874 fnd_message.set_token('EFFECTIVE_DATE',to_char(p_effective_date));
9875 fnd_message.raise_error;
9876 else
9877 --
9878 ben_prtt_rmt_aprvd_pymt_api.update_prtt_rmt_aprvd_pymt
9879 (p_prtt_rmt_aprvd_fr_pymt_id => p_prtt_rmt_aprvd_fr_pymt_id,
9880 p_effective_start_date => l_effective_start_date,
9881 p_effective_end_date => l_effective_end_date,
9882 p_element_entry_value_id => l_element_entry_value_id,
9883 p_object_version_number => p_object_version_number,
9884 p_effective_date => p_effective_date,
9885 p_aprvd_fr_pymt_amt => p_amt,
9886 p_datetrack_mode => 'CORRECTION');
9887 --
9888 end if;
9889
9890
9891 hr_utility.set_location('Leaving : Create_reimburse_element',51);
9892 --
9893 end ;
9894 --
9895 procedure end_reimburse_element(p_validate IN BOOLEAN default FALSE
9896 ,p_business_group_id IN NUMBER
9897 ,p_person_id IN NUMBER
9898 ,p_prtt_reimbmt_rqst_id IN NUMBER
9899 ,p_element_link_id IN NUMBER
9900 ,p_prtt_rmt_aprvd_fr_pymt_id in number
9901 ,p_effective_date IN DATE
9902 ,p_dt_delete_mode IN VARCHAR2
9903 ,p_element_entry_value_id in number) is
9904 --
9905 cursor c_ele_info (p_element_entry_value_id number) is
9906 select ele.element_entry_id,
9907 ele.entry_type,
9908 ele.original_entry_id,
9909 elt.processing_type,
9910 elk.element_type_id,
9911 elk.effective_end_date
9912 from pay_element_entry_values_f elv,
9913 pay_element_entries_f ele,
9914 pay_element_links_f elk,
9915 pay_element_types_f elt
9916 where elv.element_entry_value_id = p_element_entry_value_id
9917 and elv.element_entry_id = ele.element_entry_id
9918 and elv.effective_start_date between ele.effective_start_date
9919 and ele.effective_end_date
9920 and ele.element_link_id = elk.element_link_id
9921 and ele.effective_start_date between elk.effective_start_date
9922 and elk.effective_end_date
9923 and elk.element_type_id = elt.element_type_id
9924 and elk.effective_start_date between elt.effective_start_date
9925 and elt.effective_end_date ;
9926 --
9927 l_ele_rec c_ele_info%rowtype;
9928 --
9929 cursor c_element_entry (p_element_entry_id number) is
9930 select object_version_number
9931 from pay_element_entries_f
9932 where element_entry_id = p_element_entry_id;
9933 --
9934 l_object_version_number number;
9935 l_element_entry_id number;
9936 l_effective_start_date date;
9937 l_effective_end_date date;
9938 l_delete_warning boolean;
9939 l_processed_flag varchar2(300);
9940
9941 begin
9942 --
9943 open c_ele_info(p_element_entry_value_id);
9944 fetch c_ele_info into l_ele_rec;
9945 --
9946 if c_ele_info%notfound then
9947 close c_ele_info;
9948 if g_debug then
9949 --
9950 hr_utility.set_location('Leaving: End reimburse element',7);
9951 end if;
9952 return;
9953 end if;
9954 close c_ele_info;
9955 --
9956 l_processed_flag := substr(pay_paywsmee_pkg.processed(
9957 l_ele_rec.element_entry_id,
9958 l_ele_rec.original_entry_id,
9959 l_ele_rec.processing_type,
9960 l_ele_rec.entry_type,
9961 p_effective_date), 1,1) ;
9962 --
9963 if l_processed_flag = 'Y' then
9964 --
9965 fnd_message.set_name ('BEN','BEN_93341_PRCCSD_IN_PAYROLL');
9966 fnd_message.raise_error;
9967 --
9968 end if;
9969 --
9970 open c_element_entry (l_ele_rec.element_entry_id);
9971 fetch c_element_entry into l_object_version_number;
9972 close c_element_entry;
9973 --
9974 py_element_entry_api.delete_element_entry
9975 (p_validate => p_validate
9976 ,p_datetrack_delete_mode => hr_api.g_zap
9977 ,p_effective_date => p_effective_date
9978 ,p_element_entry_id => l_ele_rec.element_entry_id
9979 ,p_object_version_number => l_object_version_number
9980 ,p_effective_start_date => l_effective_start_date
9981 ,p_effective_end_date => l_effective_end_date
9982 ,p_delete_warning => l_delete_warning
9983 );
9984
9985 hr_utility.set_location('Leaving: End reimburse element',7);
9986 end;
9987
9988 --
9989 end ben_element_entry;