1 PACKAGE BODY pqp_gb_osp_functions AS
2 /* $Header: pqpospfn.pkb 120.23.12010000.7 2008/08/25 06:54:05 bachakra ship $ */
3 --
4 g_package_name VARCHAR2(31) := 'pqp_gb_osp_functions.';
5 g_debug BOOLEAN:= hr_utility.debug_enabled;
6
7
8 g_udt_name VARCHAR2(80):=
9 pqp_schedule_calculation_pkg.g_udt_name;
10
11 g_default_start_day VARCHAR2(30):=
12 pqp_schedule_calculation_pkg.g_default_start_day;
13
14 g_assignment_id per_all_assignments_f.assignment_id%TYPE := 0;
15 g_pl_typ_id ben_pl_f.pl_id%TYPE := 0;
16 g_balance_date DATE := hr_api.g_date;
17 g_absences_taken_to_date pqp_absval_pkg.t_entitlements;
18
19 g_scheme_calendar_type pay_element_type_extra_info.eei_information1%TYPE;
20 g_scheme_calendar_duration pay_element_type_extra_info.eei_information1%TYPE;
21 g_scheme_calendar_uom pay_element_type_extra_info.eei_information1%TYPE;
22 g_scheme_start_date_txt VARCHAR2(80);
23
24 -- Cache for get_omp_band_ent_bal_pl_typ
25 g_omp_assignment_id per_all_assignments_f.assignment_id%TYPE := 0;
26 g_omp_pl_typ_id ben_pl_f.pl_id%TYPE := 0;
27 g_omp_balance_date DATE := hr_api.g_date;
28 g_omp_absences_taken_to_date pqp_absval_pkg.t_entitlements;
29
30 -- Cache for pqp_get_plan_extra_info
31 g_element_type_id pay_element_type_extra_info.element_type_id%TYPE;
32 g_plan_id ben_pl_f.pl_id%TYPE;
33
34 -- Cache for pqp_get_los_based_entitlements
35 g_entitlement_UDT_id pay_user_tables.user_table_id%TYPE;
36 g_entitlement_UOM pay_element_type_extra_info.eei_information8%TYPE;
37
38 -- Cache for PQP_GB_GET_ABSENCE_SSP
39 --g_ssp_element_id pay_element_types_f.element_type_id%TYPE;
40 --g_ssp_correction_element_id pay_element_types_f.element_type_id%TYPE;
41 --g_max_ssp_period NUMBER(11,5);
42 --c_ssp_eit_context CONSTANT
43 -- pay_element_types_f.element_information_category%TYPE:=
44 -- 'GB_SSP NON PAYMENT';
45 --
46 --g_pattern_id_for_bg hr_patterns.pattern_id%TYPE;
47 --g_input_value_ids_ele1 t_input_value_ids; -- IVs of ssp_element
48 --g_input_value_ids_ele2 t_input_value_ids; -- IVs of ssp_correction_element
49 --g_person_id per_absence_attendances.person_id%TYPE;
50 --g_t_pat_exceptions t_pat_exceptions;
51 --g_t_per_pat_exceptions t_pat_exceptions;
52 --g_per_pattern c_per_pattern%ROWTYPE;
53
54 -- Cache for get_actual_ssp_days
55 --g_pattern c_pattern%ROWTYPE;
56 --g_t_pat_cons pat_cons_t;
57 --g_pattern_id hr_patterns.pattern_id%TYPE;
58
59
60 -- Cache for get_absence_ssp
61 g_ssp_business_group_id hr_all_organization_units.business_group_id%TYPE;
62 g_ssp_element_type_id pay_element_types_f.element_type_id%TYPE;
63 g_ssp_input_values t_input_value_ids;
64 g_ssp_retro_element_type_id pay_element_types_f.element_type_id%TYPE;
65 g_ssp_retro_input_values t_input_value_ids;
66 g_ssp_element_links t_element_links;
67 g_ssp_retro_element_links t_element_links;
68
69 -- Cache for get_absence_smp
70 g_smp_element_type_id pay_element_types_f.element_type_id%TYPE;
71 g_smp_input_values t_input_value_ids;
72 g_smp_element_links t_element_links;
73 g_smp_retro_element_type_id pay_element_types_f.element_type_id%TYPE;
74 g_smp_retro_input_values t_input_value_ids;
75 g_smp_retro_element_links t_element_links;
76 g_smp_business_group_id hr_all_organization_units.business_group_id%TYPE;
77 g_absence_category VARCHAR2(30);
78 -- Cache for rounding of factors
79 /*check it absence round_to handle*/
80
81 /* g_parttimers_entitl_round_to VARCHAR2(10):=null;
82 g_parttimers_absence_round_to VARCHAR2(10):=null;
83 g_parttimers_rounding_factor pqp_gap_daily_absences.duration%TYPE;
84 g_fulltimers_rounding_factor pqp_gap_daily_absences.duration%TYPE;
85 g_fulltimers_entitl_round_to VARCHAR2(10):=null ;
86 g_fulltimers_absence_round_to VARCHAR2(10):=null;*/
87
88 g_pt_entitl_rounding_type VARCHAR2(10):=null;
89 g_pt_rounding_precision pqp_gap_daily_absences.duration%TYPE;
90 g_ft_rounding_precision pqp_gap_daily_absences.duration%TYPE;
91 g_ft_entitl_rounding_type VARCHAR2(10):=null ;
92 g_abs_rounding_precision pqp_gap_daily_absences.duration%TYPE;
93 g_abs_rounding_type VARCHAR2(10):='ROUNDTO' ;
94 g_round_cache_plan_id NUMBER;
95
96 --
97
98 --
99 --
100 --
101 PROCEDURE debug(
102 p_trace_message IN VARCHAR2
103 ,p_trace_location IN NUMBER DEFAULT NULL
104 )
105 IS
106 BEGIN
107 pqp_utilities.debug(p_trace_message, p_trace_location);
108 END debug;
109
110 --
111 --
112 --
113 PROCEDURE debug(p_trace_number IN NUMBER)
114 IS
115 BEGIN
116 pqp_utilities.debug(p_trace_number);
117 END debug;
118
119 --
120 --
121 --
122 PROCEDURE debug(p_trace_date IN DATE)
123 IS
124 BEGIN
125 pqp_utilities.debug(p_trace_date);
126 END debug;
127
128 --
129 --
130 --
131 PROCEDURE debug_enter(
132 p_proc_name IN VARCHAR2
133 ,p_trace_on IN VARCHAR2 DEFAULT NULL
134 )
135 IS
136 BEGIN
137 pqp_utilities.debug_enter(p_proc_name, p_trace_on);
138 END debug_enter;
139
140 --
141 --
142 --
143 PROCEDURE debug_exit(
144 p_proc_name IN VARCHAR2
145 ,p_trace_off IN VARCHAR2 DEFAULT NULL
146 )
147 IS
148 BEGIN
149 pqp_utilities.debug_exit(p_proc_name, p_trace_off);
150 END debug_exit;
151
152 --
153 --
154 --
155 PROCEDURE debug_others(
156 p_proc_name IN VARCHAR2
157 ,p_proc_step IN NUMBER DEFAULT NULL
158 )
159 IS
160 BEGIN
161 pqp_utilities.debug_others(p_proc_name, p_proc_step);
162 END debug_others;
163 --
164 --
165 --
166 PROCEDURE check_error_code
167 (p_error_code IN NUMBER
168 ,p_error_message IN VARCHAR2
169 )
170 IS
171 BEGIN
172 pqp_utilities.check_error_code(p_error_code, p_error_message);
173 END;
174 --
175 --
176 --
177 PROCEDURE clear_cache
178 IS
179 --l_null_per_pattern c_per_pattern%ROWTYPE;
180 --l_null_pattern c_pattern%ROWTYPE;
181 BEGIN
182
183 g_assignment_id := NULL;--per_all_assignments_f.assignment_id%TYPE := 0
184 g_pl_typ_id := NULL;--ben_pl_f.pl_id%TYPE := 0
185 g_balance_date := NULL;--DATE := hr_api.g_date
186 g_absences_taken_to_date.DELETE; --pqp_absval_pkg.t_entitlements
187
188 g_scheme_calendar_type := NULL ;
189 g_scheme_calendar_duration := NULL ;
190 g_scheme_calendar_uom := NULL ;
191 g_scheme_start_date_txt := NULL ;
192
193 -- Cache for get_omp_band_ent_bal_pl_typ
194 g_omp_assignment_id := NULL;--per_all_assignments_f.assignment_id%TYPE := 0
195 g_omp_pl_typ_id := NULL;--ben_pl_f.pl_id%TYPE := 0
196 g_omp_balance_date := NULL;--DATE := hr_api.g_date
197 g_omp_absences_taken_to_date.DELETE; --pqp_absval_pkg.t_entitlements
198
199 -- Cache for pqp_get_plan_extra_info
200 g_element_type_id := NULL;--pay_element_type_extra_info.element_type_id%TYPE
201 g_plan_id := NULL;--ben_pl_f.pl_id%TYPE
202
203 -- Cache for pqp_get_los_based_entitlements
204 g_entitlement_UDT_id := NULL;--pay_user_tables.user_table_id%TYPE
205 g_entitlement_UOM := NULL;--pay_element_type_extra_info.eei_information8%TYPE
206
207 -- Cache for PQP_GB_GET_ABSENCE_SSP
208 --g_ssp_element_id := NULL;--pay_element_types_f.element_type_id%TYPE
209 --g_ssp_correction_element_id := NULL;--pay_element_types_f.element_type_id%TYPE
210 --g_max_ssp_period := NULL;--NUMBER(11,5)
211 --c_ssp_eit_context CONSTANT -- Constants donot need to be NULLed
212 -- pay_element_types_f.element_information_category%TYPE:=
213 -- 'GB_SSP NON PAYMENT'
214 --g_pattern_id_for_bg := NULL;--hr_patterns.pattern_id%TYPE
215 --g_input_value_ids_ele1.DELETE; --t_input_value_ids; -- IVs of ssp_element
216 --g_input_value_ids_ele2.DELETE; --t_input_value_ids; -- IVs of ssp_correction_element
217 --g_person_id := NULL;--per_absence_attendances.person_id%TYPE
218 --g_t_pat_exceptions.DELETE; --t_pat_exceptions
219 --g_t_per_pat_exceptions.DELETE; --t_pat_exceptions
220 --g_per_pattern := l_null_per_pattern;
221 --c_per_pattern%ROWTYPE
222 -- Cache for get_actual_ssp_days
223 --g_pattern := l_null_pattern;
224 --c_pattern%ROWTYPE
225 --g_t_pat_cons.DELETE; --pat_cons_t
226 --g_pattern_id := NULL; --hr_patterns.pattern_id%TYPE
227
228 -- Cache for get_absence_ssp
229 g_ssp_business_group_id := NULL; --hr_all_organization_units.business_group_id%TYPE;
230
231 g_ssp_element_type_id := NULL; --pay_element_types_f.element_type_id%TYPE;
232 g_ssp_input_values.DELETE; --t_input_value_ids;
233 g_ssp_element_links.DELETE; --t_element_links;
234
235 g_ssp_retro_element_type_id := NULL; --pay_element_types_f.element_type_id%TYPE;
236 g_ssp_retro_input_values.DELETE; --t_input_value_ids;
237 g_ssp_retro_element_links.DELETE; --t_element_links;
238
239 -- Cache for get_absence_smp
240 g_smp_business_group_id := NULL; --hr_all_organization_units.business_group_id%TYPE;
241
242 g_smp_element_type_id := NULL; --pay_element_types_f.element_type_id%TYPE;
243 g_smp_input_values.DELETE; --t_input_value_ids;
244 g_smp_element_links.DELETE; --t_element_links;
245
246 g_smp_retro_element_type_id := NULL; --pay_element_types_f.element_type_id%TYPE;
247 g_smp_retro_input_values.DELETE; --t_input_value_ids;
248 g_smp_retro_element_links.DELETE; --t_element_links;
249 g_absence_category :=NULL;
250 END clear_cache;
251 --
252 -- pqp_get_absence_attendances is the function to get the value
253 -- of the column from table per_absence_attendances
254 --
255 FUNCTION pqp_get_absence_attendances(
256 p_absence_attendance_id IN NUMBER
257 ,p_col_name IN VARCHAR2
258 ,p_error_code OUT NOCOPY NUMBER
259 ,p_message OUT NOCOPY VARCHAR2
260 )
261 RETURN VARCHAR2
262 IS
263 l_val VARCHAR2(2000);
264 l_proc_step NUMBER(38,10):=0;
265 l_proc_name VARCHAR2(61):=
266 g_package_name||'pqp_get_absence_attendances';
267 BEGIN
268
269 IF g_debug THEN
270 debug_enter(l_proc_name);
271 debug(l_proc_name,10);
272 debug('p_absence_attendance_id:'||p_absence_attendance_id);
273 debug('p_col_name:'||p_col_name);
274 END IF;
275
276 l_val :=
277 pqp_utilities.get_col_value(
278 p_col_nam => p_col_name
279 ,p_key_val => p_absence_attendance_id
280 ,p_table => 'PER_ABSENCE_ATTENDANCES'
281 ,p_key_col => 'ABSENCE_ATTENDANCE_ID'
282 ,p_where => NULL
283 ,p_error_code => p_error_code
284 ,p_message => p_message
285 );
286 IF g_debug THEN
287 debug('l_val:'||l_val);
288 debug_exit(l_proc_name);
289 END IF;
290
291 RETURN l_val;
292
293 EXCEPTION
294 WHEN OTHERS THEN
295 clear_cache;
296 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
297 debug_others(l_proc_name,l_proc_step);
298 IF g_debug THEN
299 debug('Leaving: '||l_proc_name,-999);
300 END IF;
301 fnd_message.raise_error;
302 ELSE
303 RAISE;
304 END IF;
305 END pqp_get_absence_attendances;
306
307 -- pqp_get_absence_further_info returns the value of the items
308 -- from the flex filed Additional Absence Detail Information
309 FUNCTION pqp_get_absence_further_info(
310 p_business_group_id IN NUMBER
311 ,p_effective_date IN DATE
312 ,p_absence_attendance_id IN NUMBER
313 ,p_segment_name IN VARCHAR2
314 ,p_truncated_yes_no OUT NOCOPY VARCHAR2
315 ,p_error_code OUT NOCOPY NUMBER
316 ,p_message OUT NOCOPY VARCHAR2
317 )
318 RETURN VARCHAR2
319 IS
320 l_val VARCHAR2(2000);
321 l_proc_step NUMBER(38,10):=0;
322 l_proc_name VARCHAR2(61):=
323 g_package_name||'pqp_get_absence_further_info';
324 BEGIN
325
326 IF g_debug THEN
327 debug_enter(l_proc_name);
328 debug('p_business_group_id:'||p_business_group_id);
329 debug('p_effective_date:'||fnd_date.date_to_canonical(p_effective_date));
330 debug('p_absence_attendance_id:'||p_absence_attendance_id);
331 debug('p_segment_name:'||p_segment_name);
332 END IF;
333
334 -- If the sement name passed is Concatenated then return the
335 -- Concatenated Value
336 --
337 IF p_segment_name = 'CONCATENATED'
338 THEN
339 --
340 debug(l_proc_name, 10);
341 l_val :=
342 pqp_utilities.pqp_get_concat_value(
343 p_key_col => 'ABSENCE_ATTENDANCE_ID'
344 ,p_key_val => p_absence_attendance_id
345 ,p_tab_name => 'PER_ABSENCE_ATTENDANCES'
346 ,p_view_name => 'PER_ABSENCE_ATTENDANCES_DFV'
347 ,p_message => p_message
348 );
349 --
350 ELSE
351 --
352 debug(l_proc_name, 20);
353 l_val :=
354 pqp_utilities.get_ddf_value(
355 p_flex_name => 'PER_ABS_DEVELOPER_DF'
356 ,p_flex_context => 'GB'
357 ,p_flex_field_title => p_segment_name
358 ,p_key_col => 'ABSENCE_ATTENDANCE_ID'
359 ,p_key_val => p_absence_attendance_id
360 ,p_effective_date => p_effective_date
361 ,p_eff_date_req => 'N'
362 ,p_business_group_id => p_business_group_id
363 ,p_bus_group_id_req => 'N'
364 ,p_error_code => p_error_code
365 ,p_message => p_message
366 );
367 --
368 END IF;
369
370 --
371
372
373 IF p_message IS NOT NULL
374 THEN
375 p_error_code := -1;
376 ELSE
377 p_error_code := 0;
378 END IF;
379
380 --
381 IF g_debug THEN
382 debug('l_val:'||l_val);
383 debug_exit(l_proc_name);
384 END IF;
385
386 IF LENGTH(l_val) > 250
387 THEN
388 p_truncated_yes_no := 'Y';
389 RETURN SUBSTR(l_val, 1, 250);
390 ELSE
391 p_truncated_yes_no := 'N';
392 RETURN l_val;
393 END IF;
394
395
396
397 EXCEPTION
398 WHEN OTHERS THEN
399 clear_cache;
400 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
401 debug_others(l_proc_name,l_proc_step);
402 IF g_debug THEN
403 debug('Leaving: '||l_proc_name,-999);
404 END IF;
405 fnd_message.raise_error;
406 ELSE
407 RAISE;
408 END IF;
409 END pqp_get_absence_further_info;
410
411 -- pqp_get_absence_further_info returns the value of the items
412 -- from the flex filed Additional Absence Details
413 FUNCTION pqp_get_absence_addnl_attr(
414 p_business_group_id IN NUMBER
415 ,p_effective_date IN DATE
416 ,p_absence_attendance_id IN NUMBER
417 ,p_segment_name IN VARCHAR2
418 ,p_truncated_yes_no OUT NOCOPY VARCHAR2
419 ,p_error_code OUT NOCOPY NUMBER
420 ,p_message OUT NOCOPY VARCHAR2
421 )
422 RETURN VARCHAR2
423 IS
424 l_val VARCHAR2(2000);
425 l_proc_step NUMBER(38,10):=0;
426 l_proc_name VARCHAR2(61):=
427 g_package_name||'pqp_get_absence_Addnl_attr';
428 BEGIN
429
430 IF g_debug THEN
431 debug_enter(l_proc_name);
432 debug('p_business_group_id:'||p_business_group_id);
433 debug('p_effective_date:'||p_effective_date);
434 debug('p_absence_attendance_id:'||p_absence_attendance_id);
435 debug('p_segment_name:'||p_segment_name);
436 END IF;
437
438 --
439 IF p_segment_name = 'CONCATENATED'
440 THEN
441 --
442 debug(l_proc_name, 10);
443 l_val :=
444 pqp_utilities.pqp_get_concat_value(
445 p_key_col => 'ABSENCE_ATTENDANCE_ID'
446 ,p_key_val => p_absence_attendance_id
447 ,p_tab_name => 'PER_ABSENCE_ATTENDANCES'
448 ,p_view_name => 'PER_ABSENCE_ATTENDANCES_DFV'
449 ,p_message => p_message
450 );
451 --
452 ELSE
453 --
454 debug(l_proc_name, 10);
455 l_val :=
456 pqp_utilities.get_df_value(
457 p_flex_name => 'PER_ABSENCE_ATTENDANCES'
458 ,p_flex_context => NULL
459 ,p_flex_field_title => p_segment_name
460 ,p_key_col => 'ABSENCE_ATTENDANCE_ID'
461 ,p_key_val => p_absence_attendance_id
462 ,p_tab_name => 'PER_ABSENCE_ATTENDANCES'
463 ,p_effective_date => p_effective_date
464 ,p_eff_date_req => 'N'
465 ,p_business_group_id => p_business_group_id
466 ,p_bus_group_id_req => 'N'
467 ,p_error_code => p_error_code
468 ,p_message => p_message
469 );
470 --
471 END IF;
472
473 --
474 IF g_debug THEN
475 debug('l_val:'||l_val);
476 debug_exit(l_proc_name);
477 END IF;
478
479 --
480 IF LENGTH(l_val) > 250
481 THEN
482 p_truncated_yes_no := 'Y';
483 RETURN SUBSTR(l_val, 1, 250);
484 ELSE
485 p_truncated_yes_no := 'N';
486 RETURN l_val;
487 END IF;
488 --
489
490
491
492 EXCEPTION
493 WHEN OTHERS THEN
494 clear_cache;
495 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
496 debug_others(l_proc_name,l_proc_step);
497 IF g_debug THEN
498 debug('Leaving: '||l_proc_name,-999);
499 END IF;
500 fnd_message.raise_error;
501 ELSE
502 RAISE;
503 END IF;
504 END pqp_get_absence_addnl_attr;
505
506 -- pqp_get_ssp_medicals_details is the function to get the value
507 -- of the column from table SSP_MEDICALS
508 FUNCTION pqp_get_ssp_medicals_details(
509 p_absence_attendance_id IN NUMBER
510 ,p_col_name IN VARCHAR2
511 ,p_error_code OUT NOCOPY NUMBER
512 ,p_message OUT NOCOPY VARCHAR2
513 )
514 RETURN VARCHAR2
515 IS
516 l_val VARCHAR2(2000);
517 l_proc_step NUMBER(38,10):=0;
518 l_proc_name VARCHAR2(61):=
519 g_package_name||'pqp_get_ssp_medicals_details';
520 l_medical_id ssp_medicals.medical_id%TYPE;
521 BEGIN
522
523 IF g_debug THEN
524 debug_enter(l_proc_name);
525 debug(l_proc_name,5);
526 debug('p_absence_attendance_id:'||p_absence_attendance_id);
527 debug('p_col_name:'||p_col_name);
528
529 END IF;
530 --
531 debug(l_proc_name, 10);
532 l_medical_id :=
533 pqp_gb_osp_functions.pqp_get_medical_id(p_absence_id => p_absence_attendance_id
534 ,p_message => p_message);
535
536 IF p_message IS NOT NULL
537 THEN
538 p_error_code := -1;
539 debug_exit(l_proc_name || ' ' || p_message);
540 RETURN 0;
541 END IF;
542
543 --
544 --
545 debug(l_proc_name, 20);
546 l_val :=
547 pqp_utilities.get_col_value(
548 p_col_nam => p_col_name
549 ,p_key_val => l_medical_id
550 ,p_table => 'SSP_MEDICALS'
551 ,p_key_col => 'MEDICAL_ID'
552 ,p_where => NULL
553 ,p_error_code => p_error_code
554 ,p_message => p_message
555 );
556 --
557
558 IF g_debug THEN
559 debug('l_val:'||l_val);
560 debug_exit(l_proc_name);
561 END IF;
562 RETURN l_val;
563
564
565 EXCEPTION
566 WHEN OTHERS THEN
567 clear_cache;
568 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
569 debug_others(l_proc_name,l_proc_step);
570 IF g_debug THEN
571 debug('Leaving: '||l_proc_name,-999);
572 END IF;
573 fnd_message.raise_error;
574 ELSE
575 RAISE;
576 END IF;
577 END pqp_get_ssp_medicals_details;
578
579 -- pqp_get_ssp_medical_addnl_attr returns the value of the items
580 -- from the flex filed SSP_MEDICALS
581 FUNCTION pqp_get_ssp_medical_addnl_attr(
582 p_business_group_id IN NUMBER
583 ,p_effective_date IN DATE
584 ,p_absence_attendance_id IN NUMBER
585 ,p_segment_name IN VARCHAR2
586 ,p_truncated_yes_no OUT NOCOPY VARCHAR2
587 ,p_error_code OUT NOCOPY NUMBER
588 ,p_message OUT NOCOPY VARCHAR2
589 )
590 RETURN VARCHAR2
591 IS
592 l_val VARCHAR2(2000);
593 l_proc_step NUMBER(38,10):=0;
594 l_proc_name VARCHAR2(61):=
595 g_package_name||'pqp_get_ssp_medical_addnl_attr';
596 l_medical_id ssp_medicals.medical_id%TYPE;
597 BEGIN
598
599 IF g_debug THEN
600 debug_enter(l_proc_name);
601 debug('p_business_group_id:'||p_business_group_id);
602 debug('p_effective_date'||fnd_date.date_to_canonical(p_effective_date));
603 debug('p_absence_attendance_id:'||p_absence_attendance_id);
604 debug('p_segment_name:'||p_segment_name);
605 END IF;
606 --
607 debug(l_proc_name, 10);
608
609 l_medical_id :=
610 pqp_gb_osp_functions.pqp_get_medical_id(p_absence_id => p_absence_attendance_id
611 ,p_message => p_message);
612
613 IF p_message IS NOT NULL
614 THEN
615 p_error_code := -1;
616 debug_exit(l_proc_name || ' ' || p_message);
617 RETURN NULL;
618 END IF;
619
620 --
621 --
622 IF p_segment_name = 'CONCATENATED'
623 THEN
624 --
625 debug(l_proc_name, 20);
626 l_val :=
627 pqp_utilities.pqp_get_concat_value(
628 p_key_col => 'MEDICAL_ID'
629 ,p_key_val => l_medical_id
630 ,p_tab_name => 'SSP_MEDICALS'
631 ,p_view_name => 'SSP_MEDICALS_DFV'
632 ,p_message => p_message
633 );
634 --
635 ELSE
636 --
637 debug(l_proc_name, 30);
638 l_val :=
639 pqp_utilities.get_df_value(
640 p_flex_name => 'SSP_MEDICALS'
641 ,p_flex_context => NULL
642 ,p_flex_field_title => p_segment_name
643 ,p_key_col => 'MEDICAL_ID'
644 ,p_key_val => l_medical_id
645 ,p_tab_name => 'SSP_MEDICALS'
646 ,p_effective_date => p_effective_date
647 ,p_eff_date_req => 'N'
648 ,p_business_group_id => p_business_group_id
649 ,p_bus_group_id_req => 'N'
650 ,p_error_code => p_error_code
651 ,p_message => p_message
652 );
653 --
654 END IF;
655
656 --
657
658 IF g_debug THEN
659 debug('l_val:'||l_val);
660 debug_exit(l_proc_name);
661 END IF;
662
663 --
664 IF LENGTH(l_val) > 250
665 THEN
666 p_truncated_yes_no := 'Y';
667 RETURN SUBSTR(l_val, 1, 250);
668 ELSE
669 p_truncated_yes_no := 'N';
670 RETURN l_val;
671 END IF;
672
673
674 EXCEPTION
675 WHEN OTHERS THEN
676 clear_cache;
677 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
678 debug_others(l_proc_name,l_proc_step);
679 IF g_debug THEN
680 debug('Leaving: '||l_proc_name,-999);
681 END IF;
682 fnd_message.raise_error;
683 ELSE
684 RAISE;
685 END IF;
686 --
687 END pqp_get_ssp_medical_addnl_attr;
688
689 -- pqp_get_ssp_matrnty_details is the main function to get the value
690 -- of the column from table SSP_MATERNITIES
691 FUNCTION pqp_get_ssp_matrnty_details(
692 p_absence_attendance_id IN NUMBER
693 ,p_col_name IN VARCHAR2
694 ,p_error_code OUT NOCOPY NUMBER
695 ,p_message OUT NOCOPY VARCHAR2
696 )
697 RETURN VARCHAR2
698 IS
699 l_val VARCHAR2(2000);
700 l_proc_step NUMBER(38,10):=0;
701 l_proc_name VARCHAR2(61):=
702 g_package_name||'pqp_get_ssp_matrnty_details';
703 l_maternity_id ssp_maternities.maternity_id%TYPE;
704 BEGIN
705
706 IF g_debug THEN
707 debug_enter(l_proc_name);
708 debug(l_proc_name,5);
709 debug('p_absence_attendance_id:'||p_absence_attendance_id);
710 debug('p_col_name:'||p_col_name);
711
712 END IF;
713 --
714 debug(l_proc_name, 10);
715 l_maternity_id :=
716 pqp_gb_osp_functions.pqp_get_maternity_id(p_absence_id => p_absence_attendance_id
717 ,p_message => p_message);
718
719 IF p_message IS NOT NULL
720 THEN
721 p_error_code := -1;
722 debug_exit(l_proc_name || ' ' || p_message);
723 RETURN NULL;
724 END IF;
725
726 --
727 --
728 debug(l_proc_name, 20);
729 l_val :=
730 pqp_utilities.get_col_value(
731 p_col_nam => p_col_name
732 ,p_key_val => l_maternity_id
733 ,p_table => 'SSP_MATERNITIES'
734 ,p_key_col => 'MATERNITY_ID'
735 ,p_where => NULL
736 ,p_error_code => p_error_code
737 ,p_message => p_message
738 );
739 --
740
741 IF g_debug THEN
742 debug('l_val:'||l_val);
743 debug_exit(l_proc_name);
744 END IF;
745 RETURN l_val;
746
747
748 EXCEPTION
749 WHEN OTHERS THEN
750 clear_cache;
751 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
752 debug_others(l_proc_name,l_proc_step);
753 IF g_debug THEN
754 debug('Leaving: '||l_proc_name,-999);
755 END IF;
756 fnd_message.raise_error;
757 ELSE
758 RAISE;
759 END IF;
760 END pqp_get_ssp_matrnty_details;
761
762 -- pqp_get_ssp_matrnty_addnl_attr returns the value of the items
763 -- from the flex filed SSP_MATERNITIES
764 FUNCTION pqp_get_ssp_matrnty_addnl_attr(
765 p_business_group_id IN NUMBER
766 ,p_effective_date IN DATE
767 ,p_absence_attendance_id IN NUMBER
768 ,p_segment_name IN VARCHAR2
769 ,p_truncated_yes_no OUT NOCOPY VARCHAR2
770 ,p_error_code OUT NOCOPY NUMBER
771 ,p_message OUT NOCOPY VARCHAR2
772 )
773 RETURN VARCHAR2
774 IS
775 l_val VARCHAR2(2000);
776 l_proc_step NUMBER(38,10):=0;
777 l_proc_name VARCHAR2(61):=
778 g_package_name||'pqp_get_ssp_matrnty_addnl_attr';
779 l_maternity_id ssp_maternities.maternity_id%TYPE;
780 BEGIN
781
782 IF g_debug THEN
783 debug_enter(l_proc_name);
784 debug(l_proc_name,5);
785 debug('p_business_group_id'||to_char(p_business_group_id));
786 debug('p_effective_date'||to_char(p_effective_date));
787 debug('p_absence_attendance_id'||to_char(p_absence_attendance_id));
788 debug('p_segment_name'||p_segment_name);
789
790 END IF;
791 --
792 debug(l_proc_name, 10);
793 l_maternity_id :=
794 pqp_gb_osp_functions.pqp_get_maternity_id(p_absence_id => p_absence_attendance_id
795 ,p_message => p_message);
796
797 IF p_message IS NOT NULL
798 THEN
799 p_error_code := -1;
800 debug_exit(l_proc_name || ' ' || p_message);
801 RETURN NULL;
802 END IF;
803
804 --
805 --
806 IF p_segment_name = 'CONCATENATED'
807 THEN
808 --
809 debug(l_proc_name, 20);
810 l_val :=
811 pqp_utilities.pqp_get_concat_value(
812 p_key_col => 'MATERNITY_ID'
813 ,p_key_val => l_maternity_id
814 ,p_tab_name => 'SSP_MATERNITIES'
815 ,p_view_name => 'SSP_MATERNITIES_DFV'
816 ,p_message => p_message
817 );
818 --
819 ELSE
820 --
821 debug(l_proc_name, 30);
822 l_val :=
823 pqp_utilities.get_df_value(
824 p_flex_name => 'SSP_MATERNITIES'
825 ,p_flex_context => NULL
826 ,p_flex_field_title => p_segment_name
827 ,p_key_col => 'MATERNITY_ID'
828 ,p_key_val => l_maternity_id
829 ,p_tab_name => 'SSP_MATERNITIES'
830 ,p_effective_date => p_effective_date
831 ,p_eff_date_req => 'N'
832 ,p_business_group_id => p_business_group_id
833 ,p_bus_group_id_req => 'N'
834 ,p_error_code => p_error_code
835 ,p_message => p_message
836 );
837 --
838 END IF;
839
840 --
841
842 IF g_debug THEN
843 debug('l_val:'||l_val);
844 debug_exit(l_proc_name);
845 END IF;
846 --
847 IF LENGTH(l_val) > 250
848 THEN
849 p_truncated_yes_no := 'Y';
850 RETURN SUBSTR(l_val, 1, 250);
851 ELSE
852 p_truncated_yes_no := 'N';
853 RETURN l_val;
854 END IF;
855 --
856
857 EXCEPTION
858 WHEN OTHERS THEN
859 clear_cache;
860 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
861 debug_others(l_proc_name,l_proc_step);
862 IF g_debug THEN
863 debug('Leaving: '||l_proc_name,-999);
864 END IF;
865 fnd_message.raise_error;
866 ELSE
867 RAISE;
868 END IF;
869 END pqp_get_ssp_matrnty_addnl_attr;
870
871 -- pqp_get_plan_extra_info gets the value of the segment passed for
872 -- a given information type. plan id is a context.First Element
873 -- Type id is extracted and pqp_get_extra_element_info is called
874 -- which returns the value of the segment for the given information type.
875 -- If any error -1 is returned, 0 is returned for success.
876 FUNCTION pqp_get_plan_extra_info(
877 p_pl_id IN NUMBER
878 ,p_information_type IN VARCHAR2
879 ,p_segment_name IN VARCHAR2
880 ,p_value OUT NOCOPY VARCHAR2
881 ,p_truncated_yes_no OUT NOCOPY VARCHAR2
882 ,p_error_msg OUT NOCOPY VARCHAR2
883 )
884 RETURN NUMBER
885 IS
886 -- l_element_type_id pay_element_types_f.element_type_id%TYPE ;
887 l_retval NUMBER;
888 l_proc_step NUMBER(38,10):=0;
889 l_element_type_id pay_element_types_f.element_type_id%TYPE ;
890 l_proc_name VARCHAR2(61):=
891 g_package_name||'pqp_get_plan_extra_info';
892 BEGIN
893 IF g_debug THEN
894 debug_enter(l_proc_name);
895 debug(' Plan id: ' || p_pl_id || ' Segment Name: ' || p_segment_name);
896 debug(' Caching Check: ' || g_plan_id);
897 debug(' p_information_type :'|| p_information_type );
898 END IF;
899 -- Check if Plan Id is cached.
900 IF NVL(g_plan_id, 0) <> p_pl_id
901 THEN
902 g_element_type_id := NULL ;
903 g_plan_id := NULL ;
904 debug(l_proc_name, 10);
905 OPEN csr_plan_element_type(p_pl_id => p_pl_id
906 ,p_information_type => p_information_type);
907 FETCH csr_plan_element_type INTO l_element_type_id ; --g_element_type_id;
908 CLOSE csr_plan_element_type;
909
910 IF l_element_type_id IS NULL
911 THEN
912 debug(l_proc_name, 20);
913 p_error_msg :=
914 fnd_message.get_string('PQP', 'PQP_230602_INV_INFO_TYPE');
915 debug_exit(l_proc_name || ' ' || p_error_msg);
916 RETURN -1;
917 ELSE
918 debug(l_proc_name, 30);
919 g_plan_id := p_pl_id; -- Cache Plan Id.
920 g_element_type_id := l_element_type_id ; --Cache
921
922 END IF; -- IF l_element_type_id IS NULL THEN
923 END IF; -- IF nvl(g_plan_id,0) <> p_pl_id THEN
924 --
925
926 debug(l_proc_name, 40);
927 l_retval :=
928 pqp_utilities.pqp_get_extra_element_info(
929 p_element_type_id => g_element_type_id
930 ,p_information_type => p_information_type
931 ,p_segment_name => p_segment_name
932 ,p_value => p_value
933 ,p_truncated_yes_no => p_truncated_yes_no
934 ,p_error_msg => p_error_msg
935 );
936
937 IF g_debug THEN
938 debug('l_retval:'||l_retval);
939 debug_exit(l_proc_name);
940 END IF;
941 RETURN l_retval;
942
943 EXCEPTION
944 WHEN OTHERS THEN
945 clear_cache;
946 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
947 debug_others(l_proc_name,l_proc_step);
948 IF g_debug THEN
949 debug('Leaving: '||l_proc_name,-999);
950 END IF;
951 fnd_message.raise_error;
952 ELSE
953 RAISE;
954 END IF;
955 --
956 END pqp_get_plan_extra_info;
957
958 -- pqp_get_other_plan_extra_info takes Plan Name as Input. Plan Id is
959 -- derived from plan name, business group id and effective date and is
960 -- passed to pqp_get_plan_extra_info and segment value is derived.
961 -- If any error -1 is returned, success 0 is retuned.
962 FUNCTION pqp_get_other_plan_extra_info(
963 p_business_group_id IN NUMBER
964 ,p_effective_date IN DATE
965 ,p_pl_name IN VARCHAR2
966 ,p_information_type IN VARCHAR2
967 ,p_segment_name IN VARCHAR2
968 ,p_value OUT NOCOPY VARCHAR2
969 ,p_truncated_yes_no OUT NOCOPY VARCHAR2
970 ,p_error_msg OUT NOCOPY VARCHAR2
971 )
972 RETURN NUMBER
973 IS
974 l_retval NUMBER;
975 l_pl_id ben_pl_f.pl_id%TYPE;
976 l_proc_step NUMBER(38,10):=0;
977 l_proc_name VARCHAR2(61):=
978 g_package_name||'pqp_get_other_plan_extra_info';
979 BEGIN
980
981 IF g_debug THEN
982 debug_enter(l_proc_name);
983 debug(l_proc_name,5);
984 debug('p_business_group_id'||to_char(p_business_group_id));
985 debug('p_effective_date'||to_char(p_effective_date));
986 debug('p_pl_name' ||p_pl_name);
987 debug('p_information_type'|| p_information_type);
988 debug('p_segment_name'|| p_segment_name);
989
990 END IF;
991 OPEN csr_plan_id(
992 p_business_group_id => p_business_group_id
993 ,p_effective_date => p_effective_date
994 ,p_pl_name => p_pl_name
995 );
996 FETCH csr_plan_id INTO l_pl_id;
997 CLOSE csr_plan_id;
998
999 IF l_pl_id IS NULL
1000 THEN
1001 p_error_msg :=
1002 fnd_message.get_string('PQP', 'PQP_230606_INV_PLAN_NAME');
1003 debug_exit(l_proc_name || ' ' || p_error_msg);
1004 RETURN -1;
1005 END IF;
1006
1007 debug(l_proc_name, 10);
1008 l_retval :=
1009 pqp_gb_osp_functions.pqp_get_plan_extra_info(
1010 p_pl_id => l_pl_id
1011 ,p_information_type => p_information_type
1012 ,p_segment_name => p_segment_name
1013 ,p_value => p_value
1014 ,p_truncated_yes_no => p_truncated_yes_no
1015 ,p_error_msg => p_error_msg
1016 );
1017
1018 IF g_debug THEN
1019 debug('l_retval:'||l_retval);
1020 debug_exit(l_proc_name);
1021 END IF;
1022 RETURN l_retval;
1023
1024 EXCEPTION
1025 WHEN OTHERS THEN
1026 clear_cache;
1027 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
1028 debug_others(l_proc_name,l_proc_step);
1029 IF g_debug THEN
1030 debug('Leaving: '||l_proc_name,-999);
1031 END IF;
1032 fnd_message.raise_error;
1033 ELSE
1034 RAISE;
1035 END IF;
1036 END pqp_get_other_plan_extra_info;
1037
1038 -- pqp_get_osp_pl_extra_info Returns the value of the segment
1039 -- in Plan EIT. The Information Type is PQP_GB_OSP_ABSENCE_PLAN_INFO
1040 FUNCTION pqp_get_osp_pl_extra_info(
1041 p_pl_id IN NUMBER
1042 ,p_segment_name IN VARCHAR2
1043 ,p_value OUT NOCOPY VARCHAR2
1044 ,p_truncated_yes_no OUT NOCOPY VARCHAR2
1045 ,p_error_msg OUT NOCOPY VARCHAR2
1046 )
1047 RETURN NUMBER
1048 IS
1049 l_retval NUMBER;
1050 l_proc_step NUMBER(38,10):=0;
1051 l_proc_name VARCHAR2(61):=
1052 g_package_name||'pqp_get_osp_pl_extra_info';
1053 BEGIN
1054 IF g_debug THEN
1055 debug_enter(l_proc_name);
1056 debug(l_proc_name,10);
1057 debug('p_pl_id:'||p_pl_id);
1058 debug('p_segment_name:'||p_segment_name);
1059
1060 END IF;
1061 l_retval :=
1062 pqp_gb_osp_functions.pqp_get_plan_extra_info(
1063 p_pl_id => p_pl_id
1064 ,p_information_type => 'PQP_GB_OSP_ABSENCE_PLAN_INFO'
1065 ,p_segment_name => p_segment_name
1066 ,p_value => p_value
1067 ,p_truncated_yes_no => p_truncated_yes_no
1068 ,p_error_msg => p_error_msg
1069 );
1070
1071 IF g_debug THEN
1072 debug('l_retval:'||l_retval);
1073 debug_exit(l_proc_name);
1074 END IF;
1075 RETURN l_retval;
1076
1077 EXCEPTION
1078 WHEN OTHERS THEN
1079 clear_cache;
1080 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
1081 debug_others(l_proc_name,l_proc_step);
1082 IF g_debug THEN
1083 debug('Leaving: '||l_proc_name,-999);
1084 END IF;
1085 fnd_message.raise_error;
1086 ELSE
1087 RAISE;
1088 END IF;
1089 --
1090
1091 END pqp_get_osp_pl_extra_info;
1092
1093 -- pqp_get_osp_pl_extra_info Returns the value of the segment
1094 -- in Plan EIT. Plan Name is the Input.The Information Type is
1095 -- PQP_GB_OSP_ABSENCE_PLAN_INFO
1096 FUNCTION pqp_get_osp_oth_pl_extra_info(
1097 p_business_group_id IN NUMBER
1098 ,p_effective_date IN DATE
1099 ,p_pl_name IN VARCHAR2
1100 ,p_segment_name IN VARCHAR2
1101 ,p_value OUT NOCOPY VARCHAR2
1102 ,p_truncated_yes_no OUT NOCOPY VARCHAR2
1103 ,p_error_msg OUT NOCOPY VARCHAR2
1104 )
1105 RETURN NUMBER
1106 IS
1107 l_retval NUMBER;
1108 l_proc_step NUMBER(38,10):=0;
1109 l_proc_name VARCHAR2(61):=
1110 g_package_name||'pqp_get_osp_oth_pl_extra_info';
1111 BEGIN
1112 IF g_debug THEN
1113 debug_enter(l_proc_name);
1114 debug(l_proc_name,10);
1115 debug('p_business_group_id'||to_char(p_business_group_id));
1116 debug('p_effective_date'||to_char(p_effective_date));
1117 debug('p_pl_name'|| p_pl_name);
1118 debug('p_segment_name'||p_segment_name);
1119
1120 END IF;
1121 l_retval :=
1122 pqp_gb_osp_functions.pqp_get_other_plan_extra_info(
1123 p_business_group_id => p_business_group_id
1124 ,p_effective_date => p_effective_date
1125 ,p_pl_name => p_pl_name
1126 ,p_information_type => 'PQP_GB_OSP_ABSENCE_PLAN_INFO'
1127 ,p_segment_name => p_segment_name
1128 ,p_value => p_value
1129 ,p_truncated_yes_no => p_truncated_yes_no
1130 ,p_error_msg => p_error_msg
1131 );
1132
1133 IF g_debug THEN
1134 debug('l_retval:'||l_retval);
1135 debug_exit(l_proc_name);
1136 END IF;
1137 RETURN l_retval;
1138
1139 EXCEPTION
1140 WHEN OTHERS THEN
1141 clear_cache;
1142 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
1143 debug_others(l_proc_name,l_proc_step);
1144 IF g_debug THEN
1145 debug('Leaving: '||l_proc_name,-999);
1146 END IF;
1147 fnd_message.raise_error;
1148 ELSE
1149 RAISE;
1150 END IF;
1151 --
1152
1153 END pqp_get_osp_oth_pl_extra_info;
1154
1155 -- ben_get_absence_id derives absence_attendance_id from assignment_id
1156 -- and effective_date which are contexts.
1157 FUNCTION ben_get_absence_id(
1158 p_assignment_id IN NUMBER
1159 ,p_effective_date IN DATE
1160 )
1161 RETURN NUMBER
1162 IS
1163 l_absence_id per_absence_attendances.absence_attendance_id%TYPE;
1164 l_proc_step NUMBER(38,10):=0;
1165 l_proc_name VARCHAR2(61):=
1166 g_package_name||'ben_get_absence_id';
1167 BEGIN
1168 IF g_debug THEN
1169 debug_enter(l_proc_name);
1170 debug(l_proc_name,10);
1171 debug('p_assignment_id'||to_char(p_assignment_id));
1172 debug('p_effective_date'||to_char(p_effective_date));
1173
1174 END IF;
1175 OPEN csr_absence_id(
1176 p_assignment_id => p_assignment_id
1177 ,p_effective_date => p_effective_date
1178 );
1179 FETCH csr_absence_id INTO l_absence_id;
1180 CLOSE csr_absence_id;
1181
1182 IF g_debug THEN
1183 debug('l_absence_id:'||l_absence_id);
1184 debug_exit(l_proc_name);
1185 END IF;
1186 RETURN l_absence_id;
1187 EXCEPTION
1188 WHEN OTHERS THEN
1189 clear_cache;
1190 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
1191 debug_others(l_proc_name,l_proc_step);
1192 IF g_debug THEN
1193 debug('Leaving: '||l_proc_name,-999);
1194 END IF;
1195 fnd_message.raise_error;
1196 ELSE
1197 RAISE;
1198 END IF;
1199 END ben_get_absence_id;
1200
1201 -- ben_get_per_abs_attendances is the main function to get the value
1202 -- of the column from table per_absence_attendances.Called from
1203 -- BEN where assignment_id and effective Date are contexts.
1204 FUNCTION ben_get_per_abs_attendances(
1205 p_assignment_id IN NUMBER
1206 ,p_effective_date IN DATE
1207 ,p_col_name IN VARCHAR2
1208 ,p_error_code OUT NOCOPY NUMBER
1209 ,p_message OUT NOCOPY VARCHAR2
1210 )
1211 RETURN VARCHAR2
1212 IS
1213 l_proc_step NUMBER(38,10):=0;
1214 l_proc_name VARCHAR2(61):=
1215 g_package_name||'ben_get_per_abs_attendances';
1216 l_absence_id per_absence_attendances.absence_attendance_id%TYPE;
1217 l_val VARCHAR2(2000);
1218 BEGIN
1219 IF g_debug THEN
1220 debug_enter(l_proc_name);
1221 debug(l_proc_name,10);
1222 debug('p_assignment_id'||to_char(p_assignment_id));
1223 debug(p_effective_date);
1224 debug('p_col_name'|| p_col_name);
1225
1226 END IF;
1227 l_absence_id :=
1228 pqp_gb_osp_functions.ben_get_absence_id(
1229 p_assignment_id => p_assignment_id
1230 ,p_effective_date => p_effective_date
1231 );
1232 debug(l_proc_name, 20);
1233 l_val :=
1234 pqp_gb_osp_functions.pqp_get_absence_attendances(
1235 p_absence_attendance_id => l_absence_id
1236 ,p_col_name => p_col_name
1237 ,p_error_code => p_error_code
1238 ,p_message => p_message
1239 );
1240
1241 IF g_debug THEN
1242 debug('l_val:'||l_val);
1243 debug_exit(l_proc_name);
1244 END IF;
1245 RETURN l_val;
1246
1247 EXCEPTION
1248 WHEN OTHERS THEN
1249 clear_cache;
1250 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
1251 debug_others(l_proc_name,l_proc_step);
1252 IF g_debug THEN
1253 debug('Leaving: '||l_proc_name,-999);
1254 END IF;
1255 fnd_message.raise_error;
1256 ELSE
1257 RAISE;
1258 END IF;
1259 END ben_get_per_abs_attendances;
1260
1261 -- ben_get_absence_further_info returns the value of the items
1262 -- from the flex filed Additional Absence Detail Information
1263 -- Called from BEN where businee group,assignment_id
1264 -- and effective Date are contexts.
1265 FUNCTION ben_get_absence_further_info(
1266 p_business_group_id IN NUMBER
1267 ,p_effective_date IN DATE
1268 ,p_assignment_id IN NUMBER
1269 ,p_segment_name IN VARCHAR2
1270 ,p_truncated_yes_no OUT NOCOPY VARCHAR2
1271 ,p_error_code OUT NOCOPY NUMBER
1272 ,p_message OUT NOCOPY VARCHAR2
1273 )
1274 RETURN VARCHAR2
1275 IS
1276 l_proc_step NUMBER(38,10):=0;
1277 l_proc_name VARCHAR2(61):=
1278 g_package_name||'ben_get_absence_further_info';
1279 l_absence_id per_absence_attendances.absence_attendance_id%TYPE;
1280 l_val VARCHAR2(2000);
1281 BEGIN
1282 IF g_debug THEN
1283 debug_enter(l_proc_name);
1284 debug(l_proc_name,10);
1285 debug('p_business_group_id:'||p_business_group_id);
1286 debug(p_effective_date);
1287 debug('p_assignment_id:'||p_assignment_id);
1288 debug('p_segment_name'||p_segment_name);
1289
1290 END IF;
1291 l_absence_id :=
1292 pqp_gb_osp_functions.ben_get_absence_id(
1293 p_assignment_id => p_assignment_id
1294 ,p_effective_date => p_effective_date
1295 );
1296 debug(l_proc_name, 20);
1297 l_val :=
1298 pqp_gb_osp_functions.pqp_get_absence_further_info(
1299 p_business_group_id => p_business_group_id
1300 ,p_effective_date => p_effective_date
1301 ,p_absence_attendance_id => l_absence_id
1302 ,p_segment_name => p_segment_name
1303 ,p_truncated_yes_no => p_truncated_yes_no
1304 ,p_error_code => p_error_code
1305 ,p_message => p_message
1306 );
1307
1308 IF g_debug THEN
1309 debug('l_val:'||l_val);
1310 debug_exit(l_proc_name);
1311 END IF;
1312 RETURN l_val;
1313
1314 EXCEPTION
1315 WHEN OTHERS THEN
1316 clear_cache;
1317 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
1318 debug_others(l_proc_name,l_proc_step);
1319 IF g_debug THEN
1320 debug('Leaving: '||l_proc_name,-999);
1321 END IF;
1322 fnd_message.raise_error;
1323 ELSE
1324 RAISE;
1325 END IF;
1326
1327 END ben_get_absence_further_info;
1328
1329 -- ben_get_absence_further_info returns the value of the items
1330 -- from the flex filed Additional Absence Details.
1331 FUNCTION ben_get_absence_addnl_attr(
1332 p_business_group_id IN NUMBER
1333 ,p_effective_date IN DATE
1334 ,p_assignment_id IN NUMBER
1335 ,p_segment_name IN VARCHAR2
1336 ,p_truncated_yes_no OUT NOCOPY VARCHAR2
1337 ,p_error_code OUT NOCOPY NUMBER
1338 ,p_message OUT NOCOPY VARCHAR2
1339 )
1340 RETURN VARCHAR2
1341 IS
1342 l_proc_step NUMBER(38,10):=0;
1343 l_proc_name VARCHAR2(61):=
1344 g_package_name||'ben_get_absence_addnl_attr';
1345 l_absence_id per_absence_attendances.absence_attendance_id%TYPE;
1346 l_val VARCHAR2(2000);
1347 BEGIN
1348 IF g_debug THEN
1349 debug_enter(l_proc_name);
1350 debug(l_proc_name,10);
1351 debug('p_business_group_id:'||p_business_group_id);
1352 debug(p_effective_date);
1353 debug('p_assignment_id:'||p_assignment_id);
1354 debug('p_segment_name'||p_segment_name);
1355
1356 END IF;
1357 l_absence_id :=
1358 pqp_gb_osp_functions.ben_get_absence_id(
1359 p_assignment_id => p_assignment_id
1360 ,p_effective_date => p_effective_date
1361 );
1362 debug(l_proc_name, 20);
1363 l_val :=
1364 pqp_gb_osp_functions.pqp_get_absence_addnl_attr(
1365 p_business_group_id => p_business_group_id
1366 ,p_effective_date => p_effective_date
1367 ,p_absence_attendance_id => l_absence_id
1368 ,p_segment_name => p_segment_name
1369 ,p_truncated_yes_no => p_truncated_yes_no
1370 ,p_error_code => p_error_code
1371 ,p_message => p_message
1372 );
1373
1374 IF g_debug THEN
1375 debug('l_val:'||l_val);
1376 debug_exit(l_proc_name);
1377 END IF;
1378 RETURN l_val;
1379
1380
1381 EXCEPTION
1382 WHEN OTHERS THEN
1383 clear_cache;
1384 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
1385 debug_others(l_proc_name,l_proc_step);
1386 IF g_debug THEN
1387 debug('Leaving: '||l_proc_name,-999);
1388 END IF;
1389 fnd_message.raise_error;
1390 ELSE
1391 RAISE;
1392 END IF;
1393
1394 END ben_get_absence_addnl_attr;
1395
1396 -- ben_get_ssp_medicals_details is the main function to get the value
1397 -- of the column from table SSP_MEDICALS
1398 FUNCTION ben_get_ssp_medicals_details(
1399 p_assignment_id IN NUMBER
1400 ,p_effective_date IN DATE
1401 ,p_col_name IN VARCHAR2
1402 ,p_error_code OUT NOCOPY NUMBER
1403 ,p_message OUT NOCOPY VARCHAR2
1404 )
1405 RETURN VARCHAR2
1406 IS
1407 l_proc_step NUMBER(38,10):=0;
1408 l_proc_name VARCHAR2(61):=
1409 g_package_name||'ben_get_ssp_medicals_details';
1410 l_absence_id per_absence_attendances.absence_attendance_id%TYPE;
1411 l_val VARCHAR2(2000);
1412 BEGIN
1413 IF g_debug THEN
1414 debug_enter(l_proc_name);
1415 debug(l_proc_name,10);
1416 debug('p_assignment_id:'||p_assignment_id);
1417 debug(p_effective_date);
1418 debug('p_col_name'||p_col_name);
1419 END IF;
1420 l_absence_id :=
1421 pqp_gb_osp_functions.ben_get_absence_id(
1422 p_assignment_id => p_assignment_id
1423 ,p_effective_date => p_effective_date
1424 );
1425 debug(l_proc_name, 20);
1426 l_val :=
1427 pqp_gb_osp_functions.pqp_get_ssp_medicals_details(
1428 p_absence_attendance_id => l_absence_id
1429 ,p_col_name => p_col_name
1430 ,p_error_code => p_error_code
1431 ,p_message => p_message
1432 );
1433 IF g_debug THEN
1434 debug('l_val:'||l_val);
1435 debug_exit(l_proc_name);
1436 END IF;
1437 RETURN l_val;
1438
1439
1440 EXCEPTION
1441 WHEN OTHERS THEN
1442 clear_cache;
1443 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
1444 debug_others(l_proc_name,l_proc_step);
1445 IF g_debug THEN
1446 debug('Leaving: '||l_proc_name,-999);
1447 END IF;
1448 fnd_message.raise_error;
1449 ELSE
1450 RAISE;
1451 END IF;
1452
1453 END ben_get_ssp_medicals_details;
1454
1455 -- ben_get_absence_further_info returns the value of the items
1456 -- from the flex filed SSP_MEDICALS
1457 FUNCTION ben_get_ssp_medical_addnl_attr(
1458 p_business_group_id IN NUMBER
1459 ,p_effective_date IN DATE
1460 ,p_assignment_id IN NUMBER
1461 ,p_segment_name IN VARCHAR2
1462 ,p_truncated_yes_no OUT NOCOPY VARCHAR2
1463 ,p_error_code OUT NOCOPY NUMBER
1464 ,p_message OUT NOCOPY VARCHAR2
1465 )
1466 RETURN VARCHAR2
1467 IS
1468 l_proc_step NUMBER(38,10):=0;
1469 l_proc_name VARCHAR2(61):=
1470 g_package_name||'ben_get_ssp_medical_addnl_attr';
1471 l_absence_id per_absence_attendances.absence_attendance_id%TYPE;
1472 l_val VARCHAR2(2000);
1473 BEGIN
1474 IF g_debug THEN
1475 debug_enter(l_proc_name);
1476 debug(l_proc_name,10);
1477 debug('p_business_group_id:'||p_business_group_id);
1478 debug(p_effective_date);
1479 debug('p_assignment_id:'||p_assignment_id);
1480 debug('p_segment_name'||p_segment_name);
1481 END IF;
1482 l_absence_id :=
1483 pqp_gb_osp_functions.ben_get_absence_id(
1484 p_assignment_id => p_assignment_id
1485 ,p_effective_date => p_effective_date
1486 );
1487 debug(l_proc_name, 20);
1488 l_val :=
1489 pqp_gb_osp_functions.pqp_get_ssp_medical_addnl_attr(
1490 p_business_group_id => p_business_group_id
1491 ,p_effective_date => p_effective_date
1492 ,p_absence_attendance_id => l_absence_id
1493 ,p_segment_name => p_segment_name
1494 ,p_truncated_yes_no => p_truncated_yes_no
1495 ,p_error_code => p_error_code
1496 ,p_message => p_message
1497 );
1498 IF g_debug THEN
1499 debug('l_val:'||l_val);
1500 debug_exit(l_proc_name);
1501 END IF;
1502 RETURN l_val;
1503
1504
1505 EXCEPTION
1506 WHEN OTHERS THEN
1507 clear_cache;
1508 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
1509 debug_others(l_proc_name,l_proc_step);
1510 IF g_debug THEN
1511 debug('Leaving: '||l_proc_name,-999);
1512 END IF;
1513 fnd_message.raise_error;
1514 ELSE
1515 RAISE;
1516 END IF;
1517
1518 END ben_get_ssp_medical_addnl_attr;
1519
1520 -- ben_get_ssp_matrnty_details is the main function to get the value
1521 -- of the column from table SSP_MATERNITIES
1522 FUNCTION ben_get_ssp_matrnty_details(
1523 p_assignment_id IN NUMBER
1524 ,p_effective_date IN DATE
1525 ,p_col_name IN VARCHAR2
1526 ,p_error_code OUT NOCOPY NUMBER
1527 ,p_message OUT NOCOPY VARCHAR2
1528 )
1529 RETURN VARCHAR2
1530 IS
1531 l_proc_step NUMBER(38,10):=0;
1532 l_proc_name VARCHAR2(61):=
1533 g_package_name||'ben_get_ssp_matrnty_details';
1534 l_absence_id per_absence_attendances.absence_attendance_id%TYPE;
1535 l_val VARCHAR2(2000);
1536 BEGIN
1537 IF g_debug THEN
1538 debug_enter(l_proc_name);
1539 debug(l_proc_name,10);
1540 debug('p_assignment_id:'||p_assignment_id);
1541 debug(p_effective_date);
1542 debug('p_col_name'|| p_col_name);
1543 END IF;
1544 l_absence_id :=
1545 pqp_gb_osp_functions.ben_get_absence_id(
1546 p_assignment_id => p_assignment_id
1547 ,p_effective_date => p_effective_date
1548 );
1549 debug(l_proc_name, 20);
1550 l_val :=
1551 pqp_gb_osp_functions.pqp_get_ssp_matrnty_details(
1552 p_absence_attendance_id => l_absence_id
1553 ,p_col_name => p_col_name
1554 ,p_error_code => p_error_code
1555 ,p_message => p_message
1556 );
1557 IF g_debug THEN
1558 debug('l_val:'||l_val);
1559 debug_exit(l_proc_name);
1560 END IF;
1561 RETURN l_val;
1562
1563 EXCEPTION
1564 WHEN OTHERS THEN
1565 clear_cache;
1566 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
1567 debug_others(l_proc_name,l_proc_step);
1568 IF g_debug THEN
1569 debug('Leaving: '||l_proc_name,-999);
1570 END IF;
1571 fnd_message.raise_error;
1572 ELSE
1573 RAISE;
1574 END IF;
1575 END ben_get_ssp_matrnty_details;
1576
1577 -- ben_get_ssp_matrnty_addnl_attr returns the value of the items
1578 -- from the flex filed SSP_MATERNITIES
1579 FUNCTION ben_get_ssp_matrnty_addnl_attr(
1580 p_business_group_id IN NUMBER
1581 ,p_effective_date IN DATE
1582 ,p_assignment_id IN NUMBER
1583 ,p_segment_name IN VARCHAR2
1584 ,p_truncated_yes_no OUT NOCOPY VARCHAR2
1585 ,p_error_code OUT NOCOPY NUMBER
1586 ,p_message OUT NOCOPY VARCHAR2
1587 )
1588 RETURN VARCHAR2
1589 IS
1590 l_proc_step NUMBER(38,10):=0;
1591 l_proc_name VARCHAR2(61):=
1592 g_package_name||'ben_get_ssp_matrnty_addnl_attr';
1593 l_absence_id per_absence_attendances.absence_attendance_id%TYPE;
1594 l_val VARCHAR2(2000);
1595 BEGIN
1596 IF g_debug THEN
1597 debug_enter(l_proc_name);
1598 debug(l_proc_name,10);
1599 debug('p_business_group_id:'||p_business_group_id);
1600 debug(p_effective_date);
1601 debug('p_assignment_id:'||p_assignment_id);
1602 debug('p_segment_name'|| p_segment_name);
1603 END IF;
1604 l_absence_id :=
1605 pqp_gb_osp_functions.ben_get_absence_id(
1606 p_assignment_id => p_assignment_id
1607 ,p_effective_date => p_effective_date
1608 );
1609 debug(l_proc_name, 20);
1610 l_val :=
1611 pqp_gb_osp_functions.pqp_get_ssp_matrnty_addnl_attr(
1612 p_business_group_id => p_business_group_id
1613 ,p_effective_date => p_effective_date
1614 ,p_absence_attendance_id => l_absence_id
1615 ,p_segment_name => p_segment_name
1616 ,p_truncated_yes_no => p_truncated_yes_no
1617 ,p_error_code => p_error_code
1618 ,p_message => p_message
1619 );
1620 IF g_debug THEN
1621 debug('l_val:'||l_val);
1622 debug_exit(l_proc_name);
1623 END IF;
1624 RETURN l_val;
1625
1626 EXCEPTION
1627 WHEN OTHERS THEN
1628 clear_cache;
1629 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
1630 debug_others(l_proc_name,l_proc_step);
1631 IF g_debug THEN
1632 debug('Leaving: '||l_proc_name,-999);
1633 END IF;
1634 fnd_message.raise_error;
1635 ELSE
1636 RAISE;
1637 END IF;
1638
1639 END ben_get_ssp_matrnty_addnl_attr;
1640
1641 -- function returns the values of the look up code which is the column name
1642 -- related to the prompt defined in lookup
1643 FUNCTION get_lookup_code(
1644 p_lookup_type IN VARCHAR2
1645 ,p_lookup_meaning IN VARCHAR2
1646 ,p_message OUT NOCOPY VARCHAR2
1647 )
1648 RETURN VARCHAR2
1649 IS
1650 l_lookup_code fnd_lookup_values_vl.lookup_code%TYPE;
1651 l_proc_step NUMBER(38,10):=0;
1652 l_proc_name VARCHAR2(61):=
1653 g_package_name||'get_lookup_code';
1654 BEGIN
1655 IF g_debug THEN
1656 debug_enter(l_proc_name);
1657 debug(l_proc_name,10);
1658 debug('p_lookup_type'|| p_lookup_type);
1659 debug('p_lookup_meaning'|| p_lookup_meaning);
1660 END IF;
1661 OPEN csr_lookup_code(
1662 p_lookup_type => p_lookup_type
1663 ,p_lookup_meaning => p_lookup_meaning
1664 );
1665 FETCH csr_lookup_code INTO l_lookup_code;
1666
1667 --
1668 IF csr_lookup_code%NOTFOUND
1669 THEN
1670 fnd_message.set_name('PQP', 'PQP_230598_INV_TITLE');
1671 fnd_message.set_token('LKUP_MEANING', p_lookup_meaning);
1672 p_message := fnd_message.get();
1673 -- CLOSE csr_lookup_code ;
1674 -- RETURN NULL ;
1675 END IF;
1676
1677 --
1678 CLOSE csr_lookup_code;
1679 IF g_debug THEN
1680 debug('l_lookup_code:'||l_lookup_code);
1681 debug_exit(l_proc_name);
1682 END IF;
1683 RETURN l_lookup_code;
1684
1685 EXCEPTION
1686 WHEN OTHERS THEN
1687 clear_cache;
1688 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
1689 debug_others(l_proc_name,l_proc_step);
1690 IF g_debug THEN
1691 debug('Leaving: '||l_proc_name,-999);
1692 END IF;
1693 fnd_message.raise_error;
1694 ELSE
1695 RAISE;
1696 END IF;
1697 END get_lookup_code;
1698
1699 -- get_absence_details Returns the value of the column in table
1700 -- per_absence_attendances. Inputs are absence_attendance_id and the title
1701 -- of the column in the absence form.The mapping of form title to the DB
1702 -- column is done in Lookup and the same is fetched by calling
1703 -- get_lookup_code function. For the Fields which are displayed from
1704 -- Other Tables are derived individually and those columns are ABSENCE_TYPE,
1705 -- ABSENCE_CATEGORY, ABSENCE_REASON, AUTHORIZATION PERSON,
1706 -- AUTHORIZATION PERSON EMPLOYEE NUMBER ,REPLACEMENT PERSON NAME,
1707 -- REPLACEMENT PERSON EMPLOYEE NUMBER
1708 FUNCTION get_absence_details(
1709 p_absence_attendance_id IN NUMBER
1710 ,p_title IN VARCHAR2
1711 ,p_error_code OUT NOCOPY NUMBER
1712 ,p_message OUT NOCOPY VARCHAR2
1713 )
1714 RETURN VARCHAR2
1715 IS
1716 l_proc_step NUMBER(38,10):=0;
1717 l_proc_name VARCHAR2(61):=
1718 g_package_name||'get_absence_details';
1719 l_col_name VARCHAR2(30);
1720 l_val VARCHAR2(2000);
1721 l_person_det VARCHAR2(250);
1722 BEGIN
1723 IF g_debug THEN
1724 debug_enter(l_proc_name);
1725 debug('p_absence_attendance_id:'||p_absence_attendance_id);
1726 debug('p_title:'|| p_title);
1727 END IF;
1728 -- Call get_lookup_code to get the Database column name.
1729 l_col_name :=
1730 pqp_gb_osp_functions.get_lookup_code(
1731 p_lookup_type => 'PQP_GET_ABSENCE_DETAILS'
1732 ,p_lookup_meaning => p_title
1733 ,p_message => p_message
1734 );
1735
1736 IF p_message IS NOT NULL
1737 THEN
1738 p_error_code := -1;
1739 debug_exit(l_proc_name || ' ' || p_message);
1740 RETURN NULL;
1741 ELSIF l_col_name = 'ABSENCE_TYPE'
1742 THEN
1743 --
1744 debug(l_proc_name, 10);
1745 OPEN csr_abs_type(p_absence_attendance_id => p_absence_attendance_id);
1746 FETCH csr_abs_type INTO l_val;
1747 CLOSE csr_abs_type;
1748 --
1749 ELSIF l_col_name = 'ABSENCE_CATEGORY'
1750 THEN
1751 --
1752 debug(l_proc_name, 20);
1753 OPEN csr_abs_cat(p_absence_attendance_id => p_absence_attendance_id);
1754 FETCH csr_abs_cat INTO l_val;
1755 CLOSE csr_abs_cat;
1756 --
1757 ELSIF l_col_name = 'ABSENCE_REASON'
1758 THEN
1759 --
1760 debug(l_proc_name, 30);
1761 OPEN csr_abs_rea(p_absence_attendance_id => p_absence_attendance_id);
1762 FETCH csr_abs_rea INTO l_val;
1763 CLOSE csr_abs_rea;
1764 --
1765 ELSIF l_col_name IN('AUTH_NAME', 'AUTH_NUM', 'REPL_NAME', 'REPL_NUM')
1766 THEN
1767 --
1768 IF l_col_name LIKE 'AUTH%'
1769 THEN
1770 debug(l_proc_name, 40);
1771 l_person_det :=
1772 pqp_gb_osp_functions.pqp_get_absence_attendances(
1773 p_absence_attendance_id => p_absence_attendance_id
1774 ,p_col_name => 'AUTHORISING_PERSON_ID'
1775 ,p_error_code => p_error_code
1776 ,p_message => p_message
1777 );
1778 ELSE
1779 debug(l_proc_name, 50);
1780 l_person_det :=
1781 pqp_gb_osp_functions.pqp_get_absence_attendances(
1782 p_absence_attendance_id => p_absence_attendance_id
1783 ,p_col_name => 'REPLACEMENT_PERSON_ID'
1784 ,p_error_code => p_error_code
1785 ,p_message => p_message
1786 );
1787 END IF;
1788
1789 --
1790 --
1791 IF l_person_det IS NOT NULL
1792 THEN
1793 IF l_col_name LIKE '%NAME'
1794 THEN
1795 debug(l_proc_name, 60);
1796 l_val :=
1797 pqp_utilities.get_col_value(
1798 p_col_nam => 'FULL_NAME'
1799 ,p_key_val => l_person_det
1800 ,p_table => 'PER_PEOPLE_V'
1801 ,p_key_col => 'PERSON_ID'
1802 ,p_where => NULL
1803 ,p_error_code => p_error_code
1804 ,p_message => p_message
1805 );
1806 ELSE
1807 debug(l_proc_name, 70);
1808 l_val :=
1809 pqp_utilities.get_col_value(
1810 p_col_nam => 'EMPLOYEE_NUMBER'
1811 ,p_key_val => l_person_det
1812 ,p_table => 'PER_PEOPLE_V'
1813 ,p_key_col => 'PERSON_ID'
1814 ,p_where => NULL
1815 ,p_error_code => p_error_code
1816 ,p_message => p_message
1817 );
1818 END IF;
1819 END IF;
1820 --
1821 ELSE
1822 --
1823 -- Call pqp_get_absence_details to get the value of the column.
1824 debug(l_proc_name, 80);
1825 l_val :=
1826 pqp_gb_osp_functions.pqp_get_absence_attendances(
1827 p_absence_attendance_id => p_absence_attendance_id
1828 ,p_col_name => l_col_name
1829 ,p_error_code => p_error_code
1830 ,p_message => p_message
1831 );
1832 --
1833 END IF;
1834
1835 IF g_debug THEN
1836 debug('l_val'|| l_val);
1837 debug_exit(l_proc_name);
1838 END IF;
1839
1840 IF p_message IS NOT NULL
1841 THEN
1842 p_error_code := -1;
1843 ELSE
1844 p_error_code := 0;
1845 END IF;
1846
1847 RETURN l_val;
1848
1849 EXCEPTION
1850 WHEN OTHERS THEN
1851 clear_cache;
1852 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
1853 debug_others(l_proc_name,l_proc_step);
1854 IF g_debug THEN
1855 debug('Leaving: '||l_proc_name,-999);
1856 END IF;
1857 fnd_message.raise_error;
1858 ELSE
1859 RAISE;
1860 END IF;
1861 END get_absence_details;
1862
1863 -- ben_get_absence_details is the main function to get the value
1864 -- of the column from table per_absence_attendances.Called from
1865 -- BEN where assignment_id and effective Date are contexts.
1866 FUNCTION ben_get_absence_details(
1867 p_assignment_id IN NUMBER
1868 ,p_effective_date IN DATE
1869 ,p_title IN VARCHAR2
1870 ,p_error_code OUT NOCOPY NUMBER
1871 ,p_message OUT NOCOPY VARCHAR2
1872 )
1873 RETURN VARCHAR2
1874 IS
1875 l_proc_step NUMBER(38,10):=0;
1876 l_proc_name VARCHAR2(61):=
1877 g_package_name||'ben_get_absence_details';
1878 l_absence_id per_absence_attendances.absence_attendance_id%TYPE;
1879 l_val VARCHAR2(2000);
1880 BEGIN
1881 IF g_debug THEN
1882 debug_enter(l_proc_name);
1883 debug('p_assignment_id:'||p_assignment_id);
1884 debug('p_effective_date:'||fnd_date.date_to_canonical(p_effective_date));
1885 debug('p_title:'||p_title);
1886 END IF;
1887 l_absence_id :=
1888 pqp_gb_osp_functions.ben_get_absence_id(
1889 p_assignment_id => p_assignment_id
1890 ,p_effective_date => p_effective_date
1891 );
1892 debug(l_proc_name, 20);
1893 l_val :=
1894 pqp_gb_osp_functions.get_absence_details(
1895 p_absence_attendance_id => l_absence_id
1896 ,p_title => p_title
1897 ,p_error_code => p_error_code
1898 ,p_message => p_message
1899 );
1900
1901 IF p_message IS NOT NULL
1902 THEN
1903 p_error_code := -1;
1904 ELSE
1905 p_error_code := 0;
1906 END IF;
1907
1908 IF g_debug THEN
1909 debug('l_val'|| l_val);
1910 debug_exit(l_proc_name);
1911 END IF;
1912 RETURN l_val;
1913
1914 EXCEPTION
1915 WHEN OTHERS THEN
1916 clear_cache;
1917 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
1918 debug_others(l_proc_name,l_proc_step);
1919 IF g_debug THEN
1920 debug('Leaving: '||l_proc_name,-999);
1921 END IF;
1922 fnd_message.raise_error;
1923 ELSE
1924 RAISE;
1925 END IF;
1926 END ben_get_absence_details;
1927
1928 -- get_medical_details Returns the value of the column in table
1929 -- ssp_medicals. Inputs are absence_attendance_id and the title
1930 -- of the column in the absence form.The mapping of form title to the DB
1931 -- column is done in Lookup and the same is fetched by calling
1932 -- get_lookup_code function.
1933 FUNCTION get_medical_details(
1934 p_absence_attendance_id IN NUMBER
1935 ,p_title IN VARCHAR2
1936 ,p_error_code OUT NOCOPY NUMBER
1937 ,p_message OUT NOCOPY VARCHAR2
1938 )
1939 RETURN VARCHAR2
1940 IS
1941 l_proc_step NUMBER(38,10):=0;
1942 l_proc_name VARCHAR2(61):=
1943 g_package_name||'get_medical_details';
1944 l_col_name VARCHAR2(30);
1945 l_val VARCHAR2(2000);
1946 BEGIN
1947 IF g_debug THEN
1948 debug_enter(l_proc_name);
1949 debug(l_proc_name,10);
1950 debug('p_absence_attendance_id:'||p_absence_attendance_id);
1951 debug('p_title'||p_title);
1952 END IF;
1953 -- Call get_lookup_code to get the Database column name.
1954 debug(l_proc_name, 10);
1955 l_col_name :=
1956 pqp_gb_osp_functions.get_lookup_code(
1957 p_lookup_type => 'PQP_GET_ABSENCE_EVIDENCE'
1958 ,p_lookup_meaning => p_title
1959 ,p_message => p_message
1960 );
1961
1962 IF p_message IS NOT NULL
1963 THEN
1964 p_error_code := -1;
1965 debug_exit(l_proc_name || ' ' || p_message);
1966 RETURN NULL;
1967 ELSE
1968 --
1969 debug(l_proc_name, 20);
1970 -- Call pqp_get_absence_details to get the value of the column.
1971 l_val :=
1972 pqp_gb_osp_functions.pqp_get_ssp_medicals_details(
1973 p_absence_attendance_id => p_absence_attendance_id
1974 ,p_col_name => l_col_name
1975 ,p_error_code => p_error_code
1976 ,p_message => p_message
1977 );
1978 --
1979 END IF;
1980
1981 IF g_debug THEN
1982 debug('l_val'|| l_val);
1983 debug_exit(l_proc_name);
1984 END IF;
1985 RETURN l_val;
1986
1987 EXCEPTION
1988 WHEN OTHERS THEN
1989 clear_cache;
1990 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
1991 debug_others(l_proc_name,l_proc_step);
1992 IF g_debug THEN
1993 debug('Leaving: '||l_proc_name,-999);
1994 END IF;
1995 fnd_message.raise_error;
1996 ELSE
1997 RAISE;
1998 END IF;
1999 END get_medical_details;
2000
2001 -- get_matrnty_details Returns the value of the column in table
2002 -- ssp_maternities. Inputs are absence_attendance_id and the title
2003 -- of the column in the absence form.The mapping of form title to the DB
2004 -- column is done in Lookup and the same is fetched by calling
2005 -- get_lookup_code function.
2006 FUNCTION get_matrnty_details(
2007 p_absence_attendance_id IN NUMBER
2008 ,p_title IN VARCHAR2
2009 ,p_error_code OUT NOCOPY NUMBER
2010 ,p_message OUT NOCOPY VARCHAR2
2011 )
2012 RETURN VARCHAR2
2013 IS
2014 l_proc_step NUMBER(38,10):=0;
2015 l_proc_name VARCHAR2(61):=
2016 g_package_name||'get_matrnty_details';
2017 l_col_name VARCHAR2(30);
2018 l_val VARCHAR2(2000);
2019 l_due_date VARCHAR2(200);
2020 BEGIN
2021 IF g_debug THEN
2022 debug_enter(l_proc_name);
2023 debug('p_absence_attendance_id:'||p_absence_attendance_id);
2024 debug('p_title:'||p_title);
2025 END IF;
2026 -- Call get_lookup_code to get the Database column name.
2027 debug(l_proc_name, 10);
2028 l_col_name :=
2029 pqp_gb_osp_functions.get_lookup_code(
2030 p_lookup_type => 'PQP_GET_MATERNITY'
2031 ,p_lookup_meaning => p_title
2032 ,p_message => p_message
2033 );
2034
2035 IF p_message IS NOT NULL
2036 THEN
2037 p_error_code := -1;
2038 debug_exit(l_proc_name || ' ' || p_message);
2039 RETURN NULL;
2040 ELSIF l_col_name = 'SMPQUADAT'
2041 THEN
2042 -- The Values are not directly stored but Derived.
2043 -- SMP Qualifying Date is Derived Based on Due_Date. First Due_Date is
2044 -- Fetched and Qualifying Date is Derived.
2045 debug(l_proc_name, 20);
2046 l_due_date :=
2047 pqp_gb_osp_functions.pqp_get_ssp_matrnty_details(
2048 p_absence_attendance_id => p_absence_attendance_id
2049 ,p_col_name => 'DUE_DATE'
2050 ,p_error_code => p_error_code
2051 ,p_message => p_message
2052 );
2053
2054 IF p_message IS NULL
2055 THEN
2056 BEGIN
2057 SELECT fnd_date.date_to_canonical(
2058 ssp_smp_pkg.qualifying_week(fnd_date.canonical_to_date(l_due_date))
2059 )
2060 INTO l_val
2061 FROM DUAL;
2062 EXCEPTION
2063 WHEN OTHERS
2064 THEN
2065 p_error_code := -1;
2066 p_message := SQLERRM;
2067 RETURN NULL;
2068 END;
2069 END IF;
2070 ELSIF l_col_name = 'EWC'
2071 THEN
2072 -- The Values are not directly stored but Derived.
2073 -- EWC is Derived based on Due_Date, so fetch the Due_Date and the
2074 -- Derive EWC.
2075 debug(l_proc_name, 30);
2076 debug(l_proc_name, 40);
2077 l_due_date :=
2078 pqp_gb_osp_functions.pqp_get_ssp_matrnty_details(
2079 p_absence_attendance_id => p_absence_attendance_id
2080 ,p_col_name => 'DUE_DATE'
2081 ,p_error_code => p_error_code
2082 ,p_message => p_message
2083 );
2084
2085 IF p_message IS NULL
2086 THEN
2087 BEGIN
2088 SELECT fnd_date.date_to_canonical(
2089 ssp_smp_pkg.expected_week_of_confinement(fnd_date.canonical_to_date(l_due_date))
2090 )
2091 INTO l_val
2092 FROM DUAL;
2093 EXCEPTION
2094 WHEN OTHERS
2095 THEN
2096 p_error_code := -1;
2097 p_message := SQLERRM;
2098 RETURN NULL;
2099 END;
2100 END IF;
2101 ELSE
2102 --
2103 -- Call pqp_get_absence_details to get the value of the column.
2104 debug(l_proc_name, 50);
2105 l_val :=
2106 pqp_gb_osp_functions.pqp_get_ssp_matrnty_details(
2107 p_absence_attendance_id => p_absence_attendance_id
2108 ,p_col_name => l_col_name
2109 ,p_error_code => p_error_code
2110 ,p_message => p_message
2111 );
2112 --
2113 END IF;
2114
2115 IF g_debug THEN
2116 debug('l_val'||l_val);
2117 debug_exit(l_proc_name);
2118 END IF;
2119 RETURN l_val;
2120
2121 EXCEPTION
2122 WHEN OTHERS THEN
2123 clear_cache;
2124 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
2125 debug_others(l_proc_name,l_proc_step);
2126 IF g_debug THEN
2127 debug('Leaving: '||l_proc_name,-999);
2128 END IF;
2129 fnd_message.raise_error;
2130 ELSE
2131 RAISE;
2132 END IF;
2133 END get_matrnty_details;
2134 --
2135 --
2136 --
2137 FUNCTION get_override_entitlements
2138 (p_assignment_id IN NUMBER
2139 ,p_business_group_id IN NUMBER
2140 ,p_pl_id IN NUMBER
2141 ,p_effective_date IN DATE
2142 ,p_band_entitlements OUT NOCOPY pqp_absval_pkg.t_entitlements
2143 ,p_absence_pay_plan_class IN VARCHAR2 DEFAULT 'OMP'
2144 ,p_omp_intend_to_return_to_work IN VARCHAR2 DEFAULT 'X'
2145 ,p_entitlement_bands_list_name IN VARCHAR2 DEFAULT
2146 'PQP_GAP_ENTITLEMENT_BANDS'
2147 ) RETURN BOOLEAN
2148 IS
2149
2150 CURSOR csr_override_entitlement
2151 (p_assignment_id IN NUMBER
2152 ,p_effective_date IN DATE
2153 ,p_pl_id_txt IN VARCHAR2
2154 ) IS
2155 SELECT pei_information1 override_start_date_txt
2156 ,pei_information2 override_end_date_txt
2157 ,pei_information11 band1
2158 ,pei_information12 band2
2159 ,pei_information13 band3
2160 ,pei_information14 band4
2161 FROM per_all_assignments_f asg
2162 ,per_people_extra_info pei
2163 WHERE asg.assignment_id = p_assignment_id -- index primary key
2164 AND p_effective_date
2165 BETWEEN asg.effective_start_date
2166 AND asg.effective_end_date
2167 AND pei.person_id = asg.person_id -- index PER_PEOPLE_EXTRA_INFO_N50
2168 AND pei.information_type = 'PQP_GB_GAP_ENTITLEMENT_INFO'
2169 AND pei.pei_information3 = p_pl_id_txt;
2170
2171 l_override_entitlement csr_override_entitlement%ROWTYPE;
2172
2173 l_override_entitlement_found BOOLEAN:= FALSE;
2174
2175 l_pl_id_txt per_people_extra_info.pei_information3%TYPE;
2176
2177 l_band_entitlements pqp_absval_pkg.t_entitlements;
2178
2179 i BINARY_INTEGER:= 0;
2180 l_band_entitlement NUMBER;
2181
2182 l_proc_step NUMBER(38,10);
2183 l_proc_name VARCHAR2(61):=
2184 g_package_name||'get_override_entitlements';
2185
2186 BEGIN
2187
2188 IF g_debug THEN
2189 debug_enter(l_proc_name);
2190 debug('p_assignment_id:'||p_assignment_id);
2191 debug('p_business_group_id:'||p_business_group_id);
2192 debug('p_pl_id:'||p_pl_id);
2193 debug('p_effective_date:'||fnd_date.date_to_canonical(p_effective_date));
2194 END IF;
2195
2196 -- IF p_absence_pay_plan_class = 'OSP'
2197 -- THEN -- check for an override, OMP does not yet need to support overrides
2198
2199 l_proc_step := 10;
2200 debug(l_proc_name, l_proc_step);
2201
2202 -- loop through the override entitlements and determine the first one
2203 -- in which the given effective date falls.
2204 -- NOTE: we need to do this outside the SQL query and not inlcude
2205 -- the p_effective date between clause in the SQL statement for two
2206 -- reasons
2207 -- a) performance
2208 -- b) depending on the explain plan the SQL query maybe executed
2209 -- using a different route which might cause the query to pei for
2210 -- information_types other than the one desired which might cause
2211 -- the fnd_date conversion to fail.
2212 l_override_entitlement_found := FALSE;
2213
2214 l_pl_id_txt := fnd_number.number_to_canonical(p_pl_id);
2215
2216 FOR r_override_entitlement
2217 IN csr_override_entitlement
2218 (p_assignment_id => p_assignment_id
2219 ,p_effective_date => p_effective_date
2220 ,p_pl_id_txt => l_pl_id_txt)
2221 LOOP
2222
2223 l_proc_step := 20;
2224 debug(l_proc_name, l_proc_step);
2225
2226 IF p_effective_date BETWEEN
2227 fnd_date.canonical_to_date
2228 (r_override_entitlement.override_start_date_txt)
2229 AND
2230 fnd_date.canonical_to_date
2231 (r_override_entitlement.override_end_date_txt)
2232 THEN
2233
2234 l_proc_step := 25;
2235 debug(l_proc_name, l_proc_step);
2236
2237 l_override_entitlement := r_override_entitlement;
2238 l_override_entitlement_found := TRUE;
2239
2240 END IF;
2241
2242 END LOOP;
2243
2244 IF l_override_entitlement_found
2245 THEN
2246
2247 l_proc_step := 30;
2248 debug(l_proc_name, l_proc_step);
2249
2250 -- think of a way for removing hard coded band names
2251
2252 l_band_entitlement :=
2253 fnd_number.canonical_to_number(l_override_entitlement.band1);
2254
2255 --IF l_band_entitlement > 0
2256 --THEN
2257 i := i + 1;
2258 l_band_entitlements(i).band := 'BAND1';
2259 l_band_entitlements(i).meaning :=
2260 hr_general.decode_lookup
2261 (p_entitlement_bands_list_name
2262 ,l_band_entitlements(i).band);
2263 l_band_entitlements(i).entitlement := l_band_entitlement;
2264 --END IF;
2265
2266 l_band_entitlement := fnd_number.canonical_to_number(l_override_entitlement.band2);
2267
2268 IF l_band_entitlement > 0
2269 THEN
2270 i := i + 1;
2271 l_band_entitlements(i).band := 'BAND2';
2272 l_band_entitlements(i).meaning :=
2273 hr_general.decode_lookup
2274 (p_entitlement_bands_list_name
2275 ,l_band_entitlements(i).band);
2276 l_band_entitlements(i).entitlement := l_band_entitlement;
2277 END IF;
2278
2279 l_band_entitlement := fnd_number.canonical_to_number(l_override_entitlement.band3);
2280
2281 IF l_band_entitlement > 0
2282 THEN
2283 i := i + 1;
2284 l_band_entitlements(i).band := 'BAND3';
2285 l_band_entitlements(i).meaning :=
2286 hr_general.decode_lookup
2287 (p_entitlement_bands_list_name
2288 ,l_band_entitlements(i).band);
2289 l_band_entitlements(i).entitlement := l_band_entitlement;
2290 END IF;
2291
2292 l_band_entitlement := fnd_number.canonical_to_number(l_override_entitlement.band4);
2293
2294 IF l_band_entitlement > 0
2295 THEN
2296 i := i + 1;
2297 l_band_entitlements(i).band := 'BAND4';
2298 l_band_entitlements(i).meaning :=
2299 hr_general.decode_lookup
2300 (p_entitlement_bands_list_name
2301 ,l_band_entitlements(i).band);
2302 l_band_entitlements(i).entitlement := l_band_entitlement;
2303 END IF;
2304
2305 END IF; -- IF l_override_entitlement.override_start_date_txt IS NOT NULL
2306
2307 -- END IF; -- IF p_absence_pay_plan_class = 'OSP'
2308
2309 l_proc_step := 35;
2310 debug(l_proc_name, l_proc_step);
2311
2312 p_band_entitlements := l_band_entitlements;
2313
2314 IF g_debug THEN
2315 debug_exit(l_proc_name);
2316 END IF;
2317 RETURN l_override_entitlement_found;
2318
2319 EXCEPTION
2320 WHEN OTHERS THEN
2321 clear_cache;
2322 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
2323 debug_others(l_proc_name,l_proc_step);
2324 IF g_debug THEN
2325 debug('Leaving: '||l_proc_name,-999);
2326 END IF;
2327 fnd_message.raise_error;
2328 ELSE
2329 RAISE;
2330 END IF;
2331 END get_override_entitlements;
2332 --
2333 --
2334 --
2335 FUNCTION get_los_based_entitlements
2336 (p_assignment_id IN NUMBER
2337 ,p_business_group_id IN NUMBER
2338 ,p_effective_date IN DATE
2339 ,p_pl_id IN NUMBER
2340 ,p_absence_pay_plan_class IN VARCHAR2
2341 ,p_entitlement_table_id IN NUMBER
2342 ,p_benefits_length_of_service IN NUMBER
2343 ,p_band_entitlements OUT NOCOPY pqp_absval_pkg.t_entitlements
2344 ,p_error_msg OUT NOCOPY VARCHAR2
2345 ,p_omp_intend_to_return_to_work IN VARCHAR2 DEFAULT 'X'
2346 ,p_entitlement_bands_list_name IN VARCHAR2 DEFAULT
2347 'PQP_GAP_ENTITLEMENT_BANDS'
2348 ,p_is_ent_override IN OUT NOCOPY BOOLEAN
2349 )
2350 RETURN NUMBER
2351 IS
2352 l_user_column_id pay_user_columns.user_column_id%TYPE;
2353 l_band_ent pqp_absval_pkg.t_entitlements;
2354 l_band_entitlement NUMBER;
2355 l_retval NUMBER;
2356
2357 l_proc_step NUMBER(38,10):=0;
2358 l_proc_name VARCHAR2(61):=
2359 g_package_name||'get_LOS_based_entitlements';
2360
2361 i BINARY_INTEGER;
2362 l_column_name hr_lookups.meaning%TYPE;
2363 l_lookup_code hr_lookups.lookup_code%TYPE;
2364
2365 --l_fte csr_get_asg_fte_value%ROWTYPE;
2366 l_fte_value per_assignment_budget_values.value%TYPE;
2367
2368 -- for the moment private cursors
2369 -- as we do not want to encourage their use outside this function
2370
2371 CURSOR csr_omp_entitlement_UOM
2372 (p_entitlement_UDT_id IN NUMBER
2373 ) IS
2374 SELECT eei_information9 UOM -- "Absence Entitlement Days Type" segment
2375 FROM pay_element_type_extra_info
2376 WHERE information_type = 'PQP_GB_OMP_ABSENCE_PLAN_INFO' -- OMP col indexed
2377 AND eei_information11 = -- "Absence Entitlement Parameters" segment
2378 fnd_number.number_to_canonical(p_entitlement_UDT_id);
2379
2380
2381 CURSOR csr_osp_entitlement_UOM
2382 (p_entitlement_UDT_id IN NUMBER
2383 ) IS
2384 SELECT eei_information8 UOM -- "Absence Days" segment
2385 FROM pay_element_type_extra_info
2386 WHERE information_type = 'PQP_GB_OSP_ABSENCE_PLAN_INFO' -- OSP col indexed
2387 AND eei_information9 = -- "Absence Entitlement Sick Leave" segment
2388 fnd_number.number_to_canonical(p_entitlement_UDT_id);
2389
2390 l_entitlement_UOM pay_element_type_extra_info.eei_information8%TYPE;
2391 l_entitlement_override_is_set BOOLEAN:= FALSE;
2392
2393
2394 BEGIN
2395 --
2396 IF g_debug THEN
2397 debug_enter(l_proc_name);
2398 debug(l_proc_name,5);
2399 debug('p_assignment_id:'||p_assignment_id);
2400 debug('p_business_group_id:'||p_business_group_id);
2401 debug(p_effective_date);
2402 debug('p_pl_id:'||p_pl_id);
2403 debug('p_absence_pay_plan_class'||p_absence_pay_plan_class);
2404 debug('p_entitlement_table_id:'||p_entitlement_table_id);
2405 debug('p_benefits_length_of_service:'||p_benefits_length_of_service);
2406 END IF;
2407 --
2408 -- Determine if the person has any override entitlement against the
2409 -- assignment/person. If the person has any override entitlement
2410 -- defined against the person then use that and do NOT multiply the FTE
2411 -- to that value.
2412 -- The override entitlements could be supported for either OSP or OMP.
2413 -- At the moment it doesnot apply to OMP.
2414 --
2415
2416 -- IF p_absence_pay_plan_class = 'OSP'
2417 -- THEN
2418
2419 l_proc_step := 10;
2420 debug(l_proc_name, l_proc_step);
2421
2422 l_entitlement_override_is_set :=
2423 get_override_entitlements
2424 (p_assignment_id => p_assignment_id
2425 ,p_business_group_id => p_business_group_id
2426 ,p_pl_id => p_pl_id
2427 ,p_effective_date => p_effective_date
2428 ,p_band_entitlements => l_band_ent
2429 ,p_absence_pay_plan_class => p_absence_pay_plan_class -- Default OMP
2430 ,p_entitlement_bands_list_name => p_entitlement_bands_list_name
2431 );
2432
2433 -- END IF; -- IF p_absence_pay_plan_class = 'OSP'
2434
2435 IF NOT l_entitlement_override_is_set THEN
2436
2437 l_proc_step := 15;
2438 debug(l_proc_name, l_proc_step);
2439
2440 -- has no override set or is an OMP entitlement
2441
2442 -- Determine the UOM for this scheme using p_entitlement_table_id
2443 -- to determine the UOM
2444 -- we need to hit element extra information
2445 -- to find and OSP/OMP information type which has
2446 -- PQP_GB_OMP_ABSENCE_PLAN_INFO or PQP_GB_OSP_ABSENCE_PLAN_INFO
2447 -- which has a "Absence Entitlement Parameters" (OMP EEI_INFORMATION11)
2448 -- or "Absence Entitlement Sick Leave" (OSP EEI_INFORMATION9)
2449 -- that matches with the given table id
2450 -- and then determine its entitlement UOM (OSP "Absence Days"
2451 -- EEI_INFORMATION8) (OMP Absence Entitlement Days Type EEI_INFORMATION9)
2452 -- since this is an inefficient hit and we are loathe to add a UOM
2453 -- parameter the UOM will be cached for a given entitlement_table_id
2454
2455 debug('g_entitlement_UDT_id:'|| g_entitlement_UDT_id);
2456 debug('p_entitlement_table_id:'||to_char(p_entitlement_table_id));
2457 debug('g_entitlement_UOM:'||g_entitlement_UOM);
2458
2459 IF g_entitlement_UDT_id <> p_entitlement_table_id
2460 OR
2461 g_entitlement_UDT_id IS NULL
2462 OR
2463 g_entitlement_UOM IS NULL
2464 THEN
2465
2466 l_proc_step := 20;
2467 debug(l_proc_name, l_proc_step);
2468
2469
2470 IF p_absence_pay_plan_class = 'OSP'
2471 THEN
2472
2473 l_proc_step := 25;
2474 debug(l_proc_name, l_proc_step);
2475
2476 OPEN csr_osp_entitlement_UOM(p_entitlement_table_id);
2477 FETCH csr_osp_entitlement_UOM INTO l_entitlement_UOM;
2478 CLOSE csr_osp_entitlement_UOM;
2479
2480 ELSE -- IF p_absence_pay_plan_class = 'OSP' THEN
2481
2482 l_proc_step := 30;
2483 debug(l_proc_name, l_proc_step);
2484
2485 -- must be p_absence_pay_plan_class = 'OMP' THEN
2486 OPEN csr_omp_entitlement_UOM(p_entitlement_table_id);
2487 FETCH csr_omp_entitlement_UOM INTO l_entitlement_UOM;
2488 CLOSE csr_omp_entitlement_UOM;
2489
2490 END IF; -- IF p_absence_pay_plan_class = 'OSP' THEN
2491
2492 -- Cache the UDT id and UOM
2493 g_entitlement_UDT_id := p_entitlement_table_id;
2494 g_entitlement_UOM := l_entitlement_UOM;
2495
2496 ELSE --IF g_entitlement_UDT_id <> p_entitlement_table_id
2497 -- we need the UOM for the same UDT id as before
2498 -- use cached value
2499 l_proc_step := 35;
2500 debug(l_proc_name, l_proc_step);
2501 l_entitlement_UOM := g_entitlement_UOM;
2502
2503 END IF; --IF g_entitlement_UDT_id <> p_entitlement_table_id
2504
2505 IF g_debug THEN
2506 debug('l_entitlement_UOM:'||l_entitlement_UOM);
2507 END IF;
2508
2509 IF l_entitlement_UOM IN ( 'H', 'WH')
2510 THEN
2511
2512 l_proc_step := 40;
2513 IF g_debug THEN
2514 debug(l_proc_name, l_proc_step);
2515 END IF;
2516
2517 -- Determine the FTE
2518 l_fte_value :=
2519 pqp_fte_utilities.get_fte_value
2520 (p_assignment_id => p_assignment_id
2521 ,p_calculation_date => p_effective_date);
2522
2523 IF g_debug THEN
2524 debug('l_fte_value:'||l_fte_value);
2525 END IF;
2526
2527 END IF;
2528
2529 -- Set the FTE to 1 if no FTE is found or it was a days based scheme
2530 IF l_fte_value IS NULL THEN
2531 l_proc_step := 45;
2532 l_fte_value := 1;
2533 IF g_debug THEN
2534 debug('l_fte_value:'||l_fte_value);
2535 END IF;
2536 END IF;
2537
2538
2539 OPEN csr_get_lookup_info(p_entitlement_bands_list_name, 'BAND%');
2540 FETCH csr_get_lookup_info INTO l_column_name, l_lookup_code;
2541
2542 --IF csr_get_lookup_info%FOUND -- why not found ?
2543 --THEN
2544 i := 1;
2545
2546 debug('l_column_name:'||l_column_name);
2547 l_proc_step := 50;
2548 debug(l_proc_name, l_proc_step);
2549
2550 IF p_absence_pay_plan_class = 'OMP'
2551 THEN
2552 l_proc_step := 55;
2553 debug(l_proc_name, l_proc_step);
2554 l_column_name := l_column_name || p_omp_intend_to_return_to_work;
2555 END IF;
2556
2557 l_retval :=
2558 pqp_utilities.pqp_gb_get_table_value_id(
2559 p_business_group_id => p_business_group_id
2560 ,p_effective_date => p_effective_date
2561 ,p_table_id => p_entitlement_table_id
2562 ,p_column_name => l_column_name
2563 ,p_row_name => p_benefits_length_of_service
2564 ,p_value => l_band_entitlement
2565 ,p_error_msg => p_error_msg
2566 );
2567
2568 IF l_retval < 0 THEN
2569 l_proc_step := 60;
2570 debug(l_proc_name, l_proc_step);
2571 check_error_code(l_retval,p_error_msg);
2572 END IF;
2573
2574 --IF l_band_entitlement IS NULL THEN -- remove
2575 -- --
2576 -- -- If there is no value defined
2577 -- --
2578 -- CLOSE csr_get_lookup_info;
2579 -- p_error_msg := fnd_message.get_string('PQP', 'PQP_230603_DEF_BAND1');
2580 -- debug(p_error_msg);
2581 -- debug_exit(l_proc_name);
2582 -- RETURN -1;
2583 --
2584 --ELSE -- IF l_band_entitlement IS NULL THEN
2585
2586 l_band_ent(i).band := l_lookup_code;
2587 l_band_ent(i).meaning := l_column_name;
2588 l_band_ent(i).entitlement := NVL(l_band_entitlement,0) * l_fte_value;
2589 -- For Band1 we are NLVing the entitlement
2590 -- this ensures that when the code to get the entitlement parameters
2591 -- tries to get a percentage (and/or earning type value) it will
2592 -- error out if the percentage values for Band1 have not been
2593 -- defined.
2594 -- the purpose is two fold,
2595 -- one the process should error if the UDT setup isn't complete
2596 -- two the process should not error if band1 entitlement has not been
2597 -- entered. This allows us to setup LOS bands which have just
2598 -- band2 and 3 but not band1 and also makes the system have fewer
2599 -- error raising points.
2600 -- I suspect this will break some other code. but need to test
2601
2602
2603 --END IF; -- IF l_band_entitlement IS NULL THEN
2604
2605 l_proc_step := 70;
2606 debug(l_proc_name, l_proc_step);
2607
2608 LOOP
2609
2610 l_proc_step := 75;
2611 debug(l_proc_name, l_proc_step);
2612
2613 FETCH csr_get_lookup_info INTO l_column_name, l_lookup_code;
2614 EXIT WHEN csr_get_lookup_info%NOTFOUND;
2615 i := i + 1;
2616
2617 l_proc_step := 75;
2618 debug(l_proc_name, l_proc_step+i/100);
2619
2620 IF p_absence_pay_plan_class = 'OMP'
2621 THEN
2622 l_proc_step := 80;
2623 debug(l_proc_name, l_proc_step+i/100);
2624 l_column_name := l_column_name || p_omp_intend_to_return_to_work;
2625 END IF;
2626
2627 debug('l_column_name: '||l_column_name);
2628
2629 l_proc_step := 85;
2630 debug(l_proc_name, l_proc_step+i/100);
2631
2632 l_retval :=
2633 pqp_utilities.pqp_gb_get_table_value_id(
2634 p_business_group_id => p_business_group_id
2635 ,p_effective_date => p_effective_date
2636 ,p_table_id => p_entitlement_table_id
2637 ,p_column_name => l_column_name
2638 ,p_row_name => p_benefits_length_of_service
2639 ,p_value => l_band_entitlement
2640 ,p_error_msg => p_error_msg
2641 );
2642
2643 IF l_retval < 0
2644 THEN
2645 l_proc_step := 87;
2646 debug(l_proc_name, l_proc_step+i/100);
2647 check_error_code(l_retval,p_error_msg);
2648 END IF;
2649
2650 --IF l_band_entitlement IS NULL -- removed this check
2651 --THEN -- to allow easy setup wherein I may want band1 and 3 but not 2
2652 -- for a particular LOS range but in the same scheme a diff LOS range
2653 -- gets all three bands.
2654 -- CLOSE csr_get_lookup_info;
2655 -- p_band_entitlements := l_band_ent;
2656 -- p_error_msg := NULL;
2657 -- debug_exit(l_proc_name);
2658 -- RETURN 0;
2659
2660 --ELSE
2661
2662 IF l_band_entitlement IS NOT NULL
2663 THEN
2664 l_proc_step := 90;
2665 debug(l_proc_name, l_proc_step+i/100);
2666 -- by checking for NOT NULL
2667 -- we are ensuring we only store the details of only those
2668 -- bands which have some information setup even its 0
2669 -- may even check for 0...hmmm
2670 l_band_ent(i).band := l_lookup_code;
2671 l_band_ent(i).meaning := l_column_name;
2672 l_band_ent(i).entitlement := l_band_entitlement * l_fte_value;
2673 END IF;
2674
2675 --END IF; -- End if of retval -1 Check...
2676 l_proc_step := 95;
2677 debug(l_proc_name, l_proc_step+i/100);
2678
2679 END LOOP;
2680
2681 l_proc_step := 100;
2682 debug(l_proc_name, l_proc_step);
2683
2684 CLOSE csr_get_lookup_info;
2685
2686 END IF; --IF NOT l_entitlement_override_is_set THEN
2687
2688 l_proc_step := 110;
2689 debug(l_proc_name, l_proc_step);
2690
2691 p_is_ent_override := l_entitlement_override_is_set ;
2692 p_band_entitlements := l_band_ent;
2693 --
2694 --END IF; -- End if of row found check ...
2695 --
2696 debug_exit(l_proc_name);
2697 RETURN 0;
2698
2699 EXCEPTION
2700 WHEN OTHERS THEN
2701 clear_cache;
2702 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
2703 debug_others(l_proc_name,l_proc_step);
2704 IF g_debug THEN
2705 debug('Leaving: '||l_proc_name,-999);
2706 END IF;
2707 fnd_message.raise_error;
2708 ELSE
2709 RAISE;
2710 END IF;
2711 END get_los_based_entitlements;
2712 --
2713 --
2714 --
2715 FUNCTION pqp_get_band_ent_parameters(
2716 p_business_group_id IN NUMBER
2717 ,p_effective_date IN DATE
2718 ,p_absence_pay_plan_class IN VARCHAR2
2719 ,p_entitlement_table_id IN NUMBER
2720 ,p_level_of_entitlement IN VARCHAR2
2721 ,p_entitlement_parameters OUT NOCOPY r_entitlement_parameters
2722 ,p_error_msg OUT NOCOPY VARCHAR2
2723 )
2724 RETURN NUMBER
2725 IS
2726 l_user_column_id pay_user_columns.user_column_id%TYPE;
2727 l_band_ent_rows r_entitlement_parameters;
2728 l_band_percentage NUMBER;
2729 l_lookup_code hr_lookups.lookup_code%TYPE;
2730 l_row_val hr_lookups.meaning%TYPE;
2731 l_row_earn_type hr_lookups.meaning%TYPE;
2732 l_band_avg_rec_ind hr_lookups.meaning%TYPE;
2733 l_retval NUMBER;
2734 l_proc_step NUMBER(38,10):=0;
2735 l_proc_name VARCHAR2(61):=
2736 g_package_name||'pqp_get_band_ent_parameters';
2737 BEGIN
2738
2739 IF g_debug THEN
2740 debug_enter(l_proc_name);
2741 debug('p_business_group_id:'||p_business_group_id);
2742 debug(p_effective_date);
2743 debug('p_absence_pay_plan_class'||p_absence_pay_plan_class);
2744 debug('p_entitlement_table_id:'||p_entitlement_table_id);
2745 debug('p_level_of_entitlement'||p_level_of_entitlement);
2746 END IF;
2747
2748 -- Get Percentage
2749
2750 l_row_val := NULL;
2751 OPEN csr_get_lookup_info
2752 ('PQP_GAP_ENTITLEMENT_ROWS'
2753 ,'GB_GAP_PERCENTAGE_ROW');
2754 FETCH csr_get_lookup_info INTO l_row_val, l_lookup_code;
2755 CLOSE csr_get_lookup_info;
2756
2757 debug('p_level_of_entitlement:'||p_level_of_entitlement);
2758 l_retval :=
2759 pqp_utilities.pqp_gb_get_table_value_id(
2760 p_business_group_id => p_business_group_id
2761 ,p_effective_date => p_effective_date
2762 ,p_table_id => p_entitlement_table_id
2763 ,p_column_name => p_level_of_entitlement
2764 ,p_row_name => l_row_val
2765 ,p_value => l_band_percentage
2766 ,p_error_msg => p_error_msg
2767 );
2768
2769
2770 IF l_retval < 0
2771 THEN
2772 check_error_code(l_retval,p_error_msg);
2773 END IF;
2774
2775 IF l_band_percentage IS NULL
2776 THEN
2777 fnd_message.set_name('PQP', 'PQP_230604_DEF_BND_PER');
2778 fnd_message.set_token('BAND', p_level_of_entitlement);
2779 p_error_msg := fnd_message.get();
2780 debug_exit(l_proc_name);
2781 RETURN -1;
2782 ELSE
2783 l_band_ent_rows.meaning := p_level_of_entitlement;
2784 l_band_ent_rows.percentage := l_band_percentage;
2785 END IF; -- End if of retval = -1 Check ...
2786 --
2787
2788 IF p_absence_pay_plan_class = 'OMP'
2789 THEN
2790 -- Get Earnings Row
2791 l_row_earn_type := NULL;
2792 OPEN csr_get_lookup_info
2793 ('PQP_GAP_ENTITLEMENT_ROWS'
2794 ,'GB_OMP_EARNINGS_TYPE_ROW'
2795 );
2796 FETCH csr_get_lookup_info INTO l_row_earn_type, l_lookup_code;
2797 CLOSE csr_get_lookup_info;
2798 debug('p_level_of_entitlement:' || p_level_of_entitlement);
2799 debug(l_proc_name, 30);
2800 l_retval :=
2801 pqp_utilities.pqp_gb_get_table_value_id(
2802 p_business_group_id => p_business_group_id
2803 ,p_effective_date => p_effective_date
2804 ,p_table_id => p_entitlement_table_id
2805 ,p_column_name => p_level_of_entitlement
2806 ,p_row_name => l_row_earn_type
2807 ,p_value => l_band_avg_rec_ind
2808 ,p_error_msg => p_error_msg
2809 );
2810
2811 IF l_retval < 0 THEN
2812 check_error_code(l_retval,p_error_msg);
2813 END IF;
2814
2815 IF l_band_avg_rec_ind IS NULL
2816 THEN
2817 fnd_message.set_name('PQP', 'PQP_230605_DEF_AVG_REC');
2818 fnd_message.set_token('BAND', p_level_of_entitlement);
2819 p_error_msg := fnd_message.get();
2820 debug(p_error_msg);
2821 debug_exit(l_proc_name);
2822 RETURN -1;
2823 ELSE
2824 l_band_ent_rows.earnings_type :=
2825 hr_general.decode_lookup(
2826 p_lookup_type => 'PQP_GB_OMP_EARNINGS_TYPE'
2827 ,p_lookup_code => l_band_avg_rec_ind
2828 );
2829 END IF; -- IF l_band_avg_rec_ind IS NULL
2830
2831 END IF; -- IF p_absence_pay_plan_class = 'OMP'
2832
2833 p_entitlement_parameters := l_band_ent_rows;
2834 --
2835 debug_exit(l_proc_name);
2836 RETURN 0;
2837 --
2838
2839
2840 EXCEPTION
2841 WHEN OTHERS THEN
2842 clear_cache;
2843 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
2844 debug_others(l_proc_name,l_proc_step);
2845 IF g_debug THEN
2846 debug('Leaving: '||l_proc_name,-999);
2847 END IF;
2848 fnd_message.raise_error;
2849 ELSE
2850 RAISE;
2851 END IF;
2852 END pqp_get_band_ent_parameters;
2853
2854 --
2855
2856 --
2857 FUNCTION get_entitlement_parameters( --pqp_get_entitlement_parameters
2858 p_business_group_id IN NUMBER
2859 ,p_effective_date IN DATE
2860 ,p_assignment_id IN NUMBER
2861 ,p_pl_id IN NUMBER
2862 ,p_absence_pay_plan_class IN VARCHAR2
2863 ,p_entitlement_table_id IN NUMBER
2864 ,p_benefits_length_of_service IN NUMBER
2865 ,p_entitlement_parameters OUT NOCOPY t_entitlement_parameters
2866 ,p_error_msg OUT NOCOPY VARCHAR2
2867 ,p_omp_intend_to_return_to_work IN VARCHAR2
2868 ,p_entitlement_bands_list_name IN VARCHAR2
2869 )
2870 RETURN NUMBER
2871 IS
2872 l_user_column_id pay_user_columns.user_column_id%TYPE;
2873 l_band_ent pqp_absval_pkg.t_entitlements;
2874 l_band_ent_rows r_entitlement_parameters;
2875 l_ent_parameters t_entitlement_parameters;
2876 l_band_entitlement NUMBER;
2877 l_retval NUMBER;
2878 l_proc_step NUMBER(38,10):=0;
2879 l_proc_name VARCHAR2(61):=
2880 g_package_name||'get_entitlement_parameters';
2881 i NUMBER;
2882 l_column_name hr_lookups.meaning%TYPE;
2883 l_lookup_code hr_lookups.lookup_code%TYPE;
2884
2885 l_is_ent_override BOOLEAN := FALSE ;
2886 BEGIN
2887
2888 IF g_debug THEN
2889 debug_enter(l_proc_name);
2890 debug('p_business_group_id:'||p_business_group_id);
2891 debug('p_effective_date:'||fnd_date.date_to_canonical(p_effective_date));
2892 debug('p_pl_id:'||p_pl_id);
2893 debug('p_absence_pay_plan_class:'|| p_absence_pay_plan_class);
2894 debug('p_entitlement_table_id:'||p_entitlement_table_id);
2895 debug('p_benefits_length_of_service:'||p_benefits_length_of_service);
2896 debug('p_omp_intend_to_return_to_work:'||p_omp_intend_to_return_to_work);
2897 debug('p_entitlement_bands_list_name:'||p_entitlement_bands_list_name);
2898 END IF;
2899
2900 IF p_absence_pay_plan_class = 'OSP' THEN
2901 get_entitlements
2902 (p_assignment_id => p_assignment_id
2903 ,p_business_group_id => p_business_group_id
2904 ,p_effective_date => p_effective_date
2905 ,p_pl_id => p_pl_id
2906 ,p_entitlement_table_id => p_entitlement_table_id
2907 ,p_benefits_length_of_service => p_benefits_length_of_service
2908 ,p_band_entitlements => l_band_ent
2909 ) ;
2910 l_retval := 0 ;
2911 ELSE
2912
2913 -- Get the entitlement information for each bands
2914 l_retval := -- pqp_
2915 get_los_based_entitlements(
2916 p_assignment_id => p_assignment_id
2917 ,p_business_group_id => p_business_group_id
2918 ,p_effective_date => p_effective_date
2919 ,p_pl_id => p_pl_id
2920 ,p_absence_pay_plan_class => p_absence_pay_plan_class
2921 ,p_entitlement_table_id => p_entitlement_table_id
2922 ,p_benefits_length_of_service => p_benefits_length_of_service
2923 ,p_entitlement_bands_list_name => p_entitlement_bands_list_name
2924 ,p_band_entitlements => l_band_ent
2925 ,p_error_msg => p_error_msg
2926 ,p_omp_intend_to_return_to_work => p_omp_intend_to_return_to_work
2927 ,p_is_ent_override => l_is_ent_override
2928 );
2929
2930 END IF ;
2931
2932
2933
2934 IF l_retval < 0
2935 THEN
2936 debug(p_error_msg);
2937 debug_exit(l_proc_name);
2938 RETURN l_retval;
2939 ELSE
2940 i := l_band_ent.FIRST;
2941
2942 WHILE i IS NOT NULL
2943 LOOP
2944 -- Get the entitlement parameter for each bands
2945
2946 --IF l_band_ent(i).entitlement IS NOT NULL
2947 --THEN
2948
2949 IF p_absence_pay_plan_class = 'OMP' and l_is_ent_override THEN
2950 l_band_ent(i).meaning := l_band_ent(i).meaning ||
2951 p_omp_intend_to_return_to_work ;
2952 END IF ;
2953
2954 l_retval :=
2955 pqp_get_band_ent_parameters(
2956 p_business_group_id => p_business_group_id
2957 ,p_effective_date => p_effective_date
2958 ,p_absence_pay_plan_class => p_absence_pay_plan_class
2959 ,p_entitlement_table_id => p_entitlement_table_id
2960 ,p_level_of_entitlement => l_band_ent(i).meaning
2961 ,p_entitlement_parameters => l_band_ent_rows
2962 ,p_error_msg => p_error_msg
2963 );
2964
2965 IF l_retval < 0
2966 THEN
2967 debug(p_error_msg);
2968 debug_exit(l_proc_name);
2969 RETURN -1;
2970 END IF; -- End if of retval -1 check ...
2971
2972 --END IF;
2973
2974 l_ent_parameters(i).band := l_band_ent(i).band;
2975 l_ent_parameters(i).meaning := l_band_ent(i).meaning;
2976 l_ent_parameters(i).entitlement := l_band_ent(i).entitlement;
2977 l_ent_parameters(i).percentage := l_band_ent_rows.percentage;
2978
2979 IF p_absence_pay_plan_class = 'OMP'
2980 THEN
2981 l_ent_parameters(i).earnings_type := l_band_ent_rows.earnings_type;
2982 END IF; -- End if of absence type = OMP check ....
2983
2984 i := l_band_ent.NEXT(i);
2985
2986 END LOOP;
2987
2988 END IF; -- End if of retval -1 check
2989 --
2990
2991 p_entitlement_parameters := l_ent_parameters;
2992 debug_exit(l_proc_name);
2993 RETURN 0;
2994
2995 EXCEPTION
2996 WHEN OTHERS THEN
2997 clear_cache;
2998 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
2999 debug_others(l_proc_name,l_proc_step);
3000 IF g_debug THEN
3001 debug('Leaving: '||l_proc_name,-999);
3002 END IF;
3003 fnd_message.raise_error;
3004 ELSE
3005 RAISE;
3006 END IF;
3007 END get_entitlement_parameters;
3008
3009 --
3010
3011 -- pqp_get_band_ent_value Returns the values of entitlements and its
3012 -- percentages of Band1 - Band4. Fatal error is raised if not a single
3013 -- BAND entitlement is entered or Band entitlement is captured
3014 -- without percentage. In case of fatal errors -1 is returned. If BAND1
3015 -- is not defined then fatal error is raised. If BAND2 is not defined
3016 -- then the remaining Bands are set to -1
3017
3018 FUNCTION pqp_get_band_ent_value
3019 (p_business_group_id IN NUMBER
3020 ,p_effective_date IN DATE
3021 ,p_assignment_id IN NUMBER -- Context #3
3022 ,p_element_type_id IN NUMBER -- Context #4
3023 ,p_entitlement_tab_id IN NUMBER
3024 ,p_benefits_length_of_service IN NUMBER
3025 ,p_band1_entitlement OUT NOCOPY NUMBER
3026 ,p_band1_percentage OUT NOCOPY NUMBER
3027 ,p_band2_entitlement OUT NOCOPY NUMBER
3028 ,p_band2_percentage OUT NOCOPY NUMBER
3029 ,p_band3_entitlement OUT NOCOPY NUMBER
3030 ,p_band3_percentage OUT NOCOPY NUMBER
3031 ,p_band4_entitlement OUT NOCOPY NUMBER
3032 ,p_band4_percentage OUT NOCOPY NUMBER
3033 ,p_error_msg OUT NOCOPY VARCHAR2
3034 ,p_entitlement_bands_list_name IN VARCHAR2 DEFAULT
3035 'PQP_GAP_ENTITLEMENT_BANDS'
3036 ,p_override_effective_date IN DATE DEFAULT NULL
3037 ) RETURN NUMBER
3038 IS
3039 l_user_column_id pay_user_columns.user_column_id%TYPE;
3040 l_retval NUMBER;
3041 l_row_val NUMBER := -1;
3042 l_proc_step NUMBER(38,10):=0;
3043 l_proc_name VARCHAR2(61):=
3044 g_package_name||'pqp_get_band_ent_value';
3045 i BINARY_INTEGER;
3046 l_band_ent t_entitlement_parameters;
3047 l_entitlement_parameters t_entitlement_parameters;
3048
3049 l_truncated_yes_no VARCHAR2(30);
3050 l_pl_id_txt pay_element_type_extra_info.eei_information1%TYPE;
3051 l_pl_id ben_pl_f.pl_id%TYPE;
3052
3053 l_effective_date DATE;
3054
3055 -- Added for CS
3056 l_scheme_type pay_element_type_extra_info.eei_information1%TYPE;
3057 l_default_work_pattern
3058 pay_element_type_extra_info.eei_information1%TYPE;
3059 l_entitlement_uom
3060 pay_element_type_extra_info.eei_information1%TYPE;
3061 l_absence_schedule_wp
3062 pay_element_type_extra_info.eei_information1%TYPE;
3063 l_track_part_timers
3064 pay_element_type_extra_info.eei_information1%TYPE;
3065 l_current_factor NUMBER ;
3066 l_ft_factor NUMBER ;
3067
3068 l_working_days_in_week
3069 pqp_gap_daily_absences.working_days_per_week%TYPE := 7 ;
3070 l_standard_work_days_in_week
3071 pqp_gap_daily_absences.working_days_per_week%TYPE ;
3072 l_entitlements_divisor NUMBER := 7 ;
3073
3074 l_working_days_per_week pqp_gap_daily_absences.working_days_per_week%TYPE;
3075 l_fte pqp_gap_daily_absences.fte%TYPE ;
3076 l_FT_absence_wp pqp_assignment_attributes_f.work_pattern%TYPE ;
3077 l_FT_working_wp pqp_assignment_attributes_f.work_pattern%TYPE ;
3078 l_assignment_wp pqp_assignment_attributes_f.work_pattern%TYPE ;
3079 l_is_full_timer BOOLEAN ;
3080 l_is_assignment_wp BOOLEAN;
3081
3082
3083 BEGIN
3084 --
3085 IF g_debug THEN
3086 debug_enter(l_proc_name);
3087 debug('p_business_group_id:'||p_business_group_id);
3088 debug('p_effective_date:'||fnd_date.date_to_canonical(p_effective_date));
3089 debug('p_assignment_id:'||p_assignment_id);
3090 debug('p_element_type_id:'||p_element_type_id);
3091 debug('p_entitlement_tab_id:'||p_entitlement_tab_id);
3092 debug('p_benefits_length_of_service:'||p_benefits_length_of_service);
3093 END IF;
3094 p_band1_entitlement := -1;
3095 p_band1_percentage := 0;
3096 p_band2_entitlement := -1;
3097 p_band2_percentage := 0;
3098 p_band3_entitlement := -1;
3099 p_band3_percentage := 0;
3100 p_band4_entitlement := -1;
3101 p_band4_percentage := 0;
3102
3103 l_effective_date := NVL(p_override_effective_date, p_effective_date);
3104
3105
3106 -- determine plan id for this given element type id
3107
3108 l_retval :=
3109 pqp_utilities.pqp_get_extra_element_info(
3110 p_element_type_id => p_element_type_id
3111 ,p_information_type => 'PQP_GB_OSP_ABSENCE_PLAN_INFO'
3112 ,p_segment_name => 'Plan Name'
3113 ,p_value => l_pl_id_txt
3114 ,p_truncated_yes_no => l_truncated_yes_no
3115 ,p_error_msg => p_error_msg
3116 );
3117
3118 IF l_retval < 0 THEN
3119 check_error_code(l_retval,p_error_msg);
3120 END IF;
3121
3122 l_pl_id := fnd_number.canonical_to_number(l_pl_id_txt);
3123
3124 --Set the global rounding factor cache if the values are not already set
3125 IF g_ft_entitl_rounding_type is null OR g_round_cache_plan_id <> l_pl_id THEN
3126 PQP_GB_OSP_FUNCTIONS.set_osp_omp_rounding_factors
3127 (p_pl_id => l_pl_id
3128 ,p_pt_entitl_rounding_type => g_pt_entitl_rounding_type
3129 ,p_pt_rounding_precision => g_pt_rounding_precision
3130 ,p_ft_entitl_rounding_type => g_ft_entitl_rounding_type
3131 ,p_ft_rounding_precision => g_ft_rounding_precision
3132 );
3133 g_round_cache_plan_id := l_pl_id;
3134 END IF;
3135
3136 l_retval :=
3137 get_entitlement_parameters(
3138 p_business_group_id => p_business_group_id
3139 ,p_effective_date => l_effective_date
3140 ,p_assignment_id => p_assignment_id
3141 ,p_pl_id => l_pl_id
3142 ,p_absence_pay_plan_class => 'OSP'
3143 ,p_entitlement_table_id => p_entitlement_tab_id
3144 ,p_benefits_length_of_service => p_benefits_length_of_service
3145 ,p_entitlement_bands_list_name => p_entitlement_bands_list_name
3146 ,p_entitlement_parameters => l_entitlement_parameters
3147 ,p_error_msg => p_error_msg
3148 );
3149
3150
3151 IF l_retval < 0
3152 THEN
3153 debug(p_error_msg);
3154 debug_exit(l_proc_name);
3155 RETURN -1;
3156 ELSE
3157
3158 -- Added for CS
3159
3160 l_retval :=
3161 pqp_utilities.pqp_get_extra_element_info(
3162 p_element_type_id => p_element_type_id
3163 ,p_information_type => 'PQP_GB_OSP_ABSENCE_PLAN_INFO'
3164 ,p_segment_name => 'Scheme Calendar Type'
3165 ,p_value => l_scheme_type
3166 ,p_truncated_yes_no => l_truncated_yes_no
3167 ,p_error_msg => p_error_msg
3168 );
3169
3170 IF l_retval < 0 THEN
3171 check_error_code(l_retval,p_error_msg);
3172 END IF;
3173
3174 -- In Civil Service Scheme for part timers and Fulltimers only one Entitlement
3175 -- UDT is created. But the entitlements can be derived based on the
3176 -- number of days the part timers work.
3177 -- For example :
3178 -- the standard entitlements for CS Full timer are BAND1-182 and BAND2-182
3179 -- For a part timer working 3 days in week entitlements will be
3180 -- BAND1 = FLOOR(182 * 3 / 7) = 78
3181 -- BAND2 = FLOOR(182 * 3 / 7) = 78
3182
3183
3184 l_retval :=
3185 pqp_utilities.pqp_get_extra_element_info(
3186 p_element_type_id => p_element_type_id
3187 ,p_information_type => 'PQP_GB_OSP_ABSENCE_PLAN_INFO'
3188 ,p_segment_name => 'Absence Default Work Pattern'
3189 ,p_value => l_default_work_pattern
3190 ,p_truncated_yes_no => l_truncated_yes_no
3191 ,p_error_msg => p_error_msg
3192 );
3193
3194 l_retval :=
3195 pqp_utilities.pqp_get_extra_element_info(
3196 p_element_type_id => p_element_type_id
3197 ,p_information_type => 'PQP_GB_OSP_ABSENCE_PLAN_INFO'
3198 ,p_segment_name => 'Enable Entitlement Proration'
3199 ,p_value => l_track_part_timers
3200 ,p_truncated_yes_no => l_truncated_yes_no
3201 ,p_error_msg => p_error_msg
3202 );
3203 l_retval :=
3204 pqp_utilities.pqp_get_extra_element_info(
3205 p_element_type_id => p_element_type_id
3206 ,p_information_type => 'PQP_GB_OSP_ABSENCE_PLAN_INFO'
3207 ,p_segment_name => 'Absence Schedule Work Pattern'
3208 ,p_value => l_absence_schedule_wp
3209 ,p_truncated_yes_no => l_truncated_yes_no
3210 ,p_error_msg => p_error_msg
3211 );
3212
3213 l_retval :=
3214 pqp_utilities.pqp_get_extra_element_info(
3215 p_element_type_id => p_element_type_id
3216 ,p_information_type => 'PQP_GB_OSP_ABSENCE_PLAN_INFO'
3217 ,p_segment_name => 'Absence Days'
3218 ,p_value => l_entitlement_uom
3219 ,p_truncated_yes_no => l_truncated_yes_no
3220 ,p_error_msg => p_error_msg
3221 );
3222
3223 pqp_absval_pkg.get_factors (
3224 p_business_group_id => p_business_group_id
3225 ,p_effective_date => l_effective_date
3226 ,p_assignment_id => p_assignment_id
3227 ,p_entitlement_uom => l_entitlement_uom
3228 ,p_default_wp => l_default_work_pattern
3229 ,p_absence_schedule_wp => l_absence_schedule_wp
3230 ,p_track_part_timers => NVL(l_track_part_timers,'N')
3231 ,p_current_factor => l_current_factor
3232 ,p_ft_factor => l_ft_factor
3233 ,p_working_days_per_week => l_working_days_per_week
3234 ,p_fte => l_fte
3235 ,p_FT_absence_wp => l_FT_absence_wp
3236 ,p_FT_working_wp => l_FT_working_wp
3237 ,p_assignment_wp => l_assignment_wp
3238 ,p_is_full_timer => l_is_full_timer
3239 ,p_is_assignment_wp => l_is_assignment_wp
3240 ) ;
3241
3242
3243 -- Change this logic as this will be supported by the above changes
3244
3245 IF l_scheme_type = 'DUALROLLING' THEN
3246
3247 -- l_retval :=
3248 -- pqp_utilities.pqp_get_extra_element_info(
3249 -- p_element_type_id => p_element_type_id
3250 -- ,p_information_type => 'PQP_GB_OSP_ABSENCE_PLAN_INFO'
3251 -- ,p_segment_name => 'Absence Default Work Pattern'
3252 -- ,p_value => l_default_work_pattern
3253 -- ,p_truncated_yes_no => l_truncated_yes_no
3254 -- ,p_error_msg => p_error_msg
3255 -- );
3256 -- this gets executed when called for CS
3257 -- get the number of working days per week.
3258 -- IF the person is a Full timer there may not be any assignment
3259 -- level work pattern. so pass a default work pattern
3260 -- the standard work pattern call is required as we have
3261 -- to compare to know if the person is Full timer or part timer
3262
3263 l_working_days_in_week :=
3264 pqp_schedule_calculation_pkg.get_working_days_in_week (
3265 p_assignment_id => p_assignment_id
3266 ,p_business_group_id => p_business_group_id
3267 ,p_effective_date => p_effective_date
3268 ,p_default_wp => l_FT_working_wp --l_default_work_pattern
3269 ) ;
3270
3271 -- Default Work Pattern is passed as Over Ride Work Pattern
3272 -- because we want the days in standard work pattern but not
3273 -- at assignment level.
3274 -- if we pass that as p_default_wp the function returns the
3275 -- number of days at assignment level work pattern if
3276 -- there is any
3277
3278 l_standard_work_days_in_week :=
3279 pqp_schedule_calculation_pkg.get_working_days_in_week (
3280 p_assignment_id => p_assignment_id
3281 ,p_business_group_id => p_business_group_id
3282 ,p_effective_date => p_effective_date
3283 ,p_override_wp => l_FT_working_wp --l_default_work_pattern
3284 ) ;
3285 IF NVL(l_working_days_in_week,l_standard_work_days_in_week) >=
3286 l_standard_work_days_in_week THEN
3287 l_working_days_in_week := 7 ;
3288 END IF;
3289
3290 l_current_factor := l_working_days_in_week ;
3291 l_ft_factor := 7 ;
3292 END IF ;
3293
3294 i := l_entitlement_parameters.FIRST;
3295
3296 WHILE i IS NOT NULL
3297 LOOP
3298 IF l_entitlement_parameters(i).band = 'BAND1'
3299 THEN
3300 -- p_band1_entitlement := FLOOR(l_entitlement_parameters(i).entitlement
3301 -- * l_working_days_in_week
3302 -- /l_entitlements_divisor) ;
3303
3304 -- p_band1_entitlement := FLOOR(l_entitlement_parameters(i).entitlement
3305 -- * l_current_factor
3306 -- /l_ft_factor) ;
3307
3308 p_band1_entitlement := l_entitlement_parameters(i).entitlement
3309 * l_current_factor
3310 /l_ft_factor ;
3311 p_band1_percentage := l_entitlement_parameters(i).percentage;
3312
3313
3314 -- Rounding off entitlements depending on wether a full timers or part timers
3315 /* IF l_is_full_timer THEN
3316 p_band1_entitlement := pqp_utilities.round_value_up_down
3317 (p_value_to_round => p_band1_entitlement
3318 ,p_base_value => g_ft_rounding_precision
3319 ,p_rounding_type => g_ft_entitl_rounding_type
3320 ) ;
3321 ELSE
3322 p_band1_entitlement := pqp_utilities.round_value_up_down
3323 ( p_value_to_round => p_band1_entitlement
3324 ,p_base_value => g_pt_rounding_precision
3325 ,p_rounding_type => g_pt_entitl_rounding_type
3326 ) ;
3327 END IF ;
3328 */
3329 ELSIF l_entitlement_parameters(i).band = 'BAND2'
3330 THEN
3331 -- p_band2_entitlement := FLOOR(l_entitlement_parameters(i).entitlement
3332 -- * l_working_days_in_week
3333 -- /l_entitlements_divisor) ;
3334 -- p_band2_entitlement := FLOOR(l_entitlement_parameters(i).entitlement
3335 -- * l_current_factor
3336 -- /l_ft_factor) ;
3337
3338 p_band2_entitlement := l_entitlement_parameters(i).entitlement
3339 * l_current_factor
3340 /l_ft_factor ;
3341
3342 p_band2_percentage := l_entitlement_parameters(i).percentage;
3343
3344
3345 -- Rounding off entitlements depending on wether a full timers or part timers
3346 /* IF l_is_full_timer THEN
3347 p_band2_entitlement := pqp_utilities.round_value_up_down
3348 ( p_value_to_round => p_band2_entitlement
3349 ,p_base_value => g_ft_rounding_precision
3350 ,p_rounding_type => g_ft_entitl_rounding_type
3351 ) ;
3352 ELSE
3353 p_band2_entitlement := pqp_utilities.round_value_up_down
3354 ( p_value_to_round => p_band2_entitlement
3355 ,p_base_value => g_pt_rounding_precision
3356 ,p_rounding_type => g_pt_entitl_rounding_type
3357 ) ;
3358 END IF ;
3359 */
3360
3361
3362 ELSIF l_entitlement_parameters(i).band = 'BAND3'
3363 THEN
3364 -- p_band3_entitlement := FLOOR(l_entitlement_parameters(i).entitlement
3365 -- * l_working_days_in_week
3366 -- /l_entitlements_divisor) ;
3367 -- p_band3_entitlement := FLOOR(l_entitlement_parameters(i).entitlement
3368 -- * l_current_factor
3369 -- /l_ft_factor) ;
3370
3371 p_band3_entitlement := l_entitlement_parameters(i).entitlement
3372 * l_current_factor
3373 /l_ft_factor ;
3374
3375 p_band3_percentage := l_entitlement_parameters(i).percentage;
3376
3377 -- Rounding off entitlements depending on wether a full timers or part timers
3378 /* IF l_is_full_timer THEN
3379 p_band3_entitlement := pqp_utilities.round_value_up_down
3380 ( p_value_to_round => p_band3_entitlement
3381 ,p_base_value => g_ft_rounding_precision
3382 ,p_rounding_type => g_ft_entitl_rounding_type
3383 ) ;
3384 ELSE
3385 p_band3_entitlement := pqp_utilities.round_value_up_down
3386 ( p_value_to_round => p_band3_entitlement
3387 ,p_base_value => g_pt_rounding_precision
3388 ,p_rounding_type => g_pt_entitl_rounding_type
3389 ) ;
3390 END IF ;
3391 */
3392 ELSIF l_entitlement_parameters(i).band = 'BAND4'
3393 THEN
3394 -- p_band4_entitlement := FLOOR(l_entitlement_parameters(i).entitlement
3395 -- * l_working_days_in_week
3396 -- /l_entitlements_divisor) ;
3397 -- p_band4_entitlement := FLOOR(l_entitlement_parameters(i).entitlement
3398 -- * l_current_factor
3399 -- /l_ft_factor ) ;
3400
3401 p_band4_entitlement := l_entitlement_parameters(i).entitlement
3402 * l_current_factor
3403 /l_ft_factor ;
3404
3405 p_band4_percentage := l_entitlement_parameters(i).percentage;
3406
3407 -- Rounding off entitlements depending on wether a full timers or part timers
3408 /* IF l_is_full_timer THEN
3409 p_band4_entitlement := pqp_utilities.round_value_up_down
3410 ( p_value_to_round => p_band4_entitlement
3411 ,p_base_value => g_ft_rounding_precision
3412 ,p_rounding_type => g_ft_entitl_rounding_type
3413 ) ;
3414 ELSE
3415 p_band4_entitlement := pqp_utilities.round_value_up_down
3416 ( p_value_to_round => p_band4_entitlement
3417 ,p_base_value => g_pt_rounding_precision
3418 ,p_rounding_type => g_pt_entitl_rounding_type
3419 ) ;
3420 END IF ;
3421 */
3422 EXIT;
3423 END IF; -- End if of band check ...
3424
3425 i := l_entitlement_parameters.NEXT(i);
3426 END LOOP;
3427 END IF; -- End if of retval -1 check
3428 --
3429
3430 debug_exit(l_proc_name);
3431 RETURN 0;
3432
3433 EXCEPTION
3434 WHEN OTHERS THEN
3435 clear_cache;
3436 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
3437 debug_others(l_proc_name,l_proc_step);
3438 IF g_debug THEN
3439 debug('Leaving: '||l_proc_name,-999);
3440 END IF;
3441 fnd_message.raise_error;
3442 ELSE
3443 RAISE;
3444 END IF;
3445 END pqp_get_band_ent_value;
3446
3447 --
3448
3449 -- pqp_get_maternity_id Returns the maternity id value for a given absence id
3450 FUNCTION pqp_get_maternity_id(
3451 p_absence_id IN NUMBER
3452 ,p_message OUT NOCOPY VARCHAR2
3453 )
3454 RETURN NUMBER
3455 IS
3456 l_proc_step NUMBER(38,10):=0;
3457 l_proc_name VARCHAR2(61):=
3458 g_package_name||'pqp_get_maternity_id';
3459 l_maternity_id ssp_maternities.maternity_id%TYPE;
3460 BEGIN
3461 IF g_debug THEN
3462 debug_enter(l_proc_name);
3463 debug('p_absence_id:'||p_absence_id);
3464 END IF;
3465 OPEN csr_maternity_id(p_absence_id => p_absence_id);
3466 FETCH csr_maternity_id INTO l_maternity_id;
3467
3468 --
3469 IF csr_maternity_id%NOTFOUND
3470 OR l_maternity_id IS NULL
3471 THEN
3472 p_message :=
3473 fnd_message.get_string('PQP', 'PQP_230599_INV_MATERNITY_ID');
3474 END IF;
3475
3476 --
3477 CLOSE csr_maternity_id;
3478 IF g_debug THEN
3479 debug('l_maternity_id:'||l_maternity_id);
3480 debug_exit(l_proc_name);
3481 END IF;
3482 RETURN l_maternity_id;
3483
3484 EXCEPTION
3485 WHEN OTHERS THEN
3486 clear_cache;
3487 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
3488 debug_others(l_proc_name,l_proc_step);
3489 IF g_debug THEN
3490 debug('Leaving: '||l_proc_name,-999);
3491 END IF;
3492 fnd_message.raise_error;
3493 ELSE
3494 RAISE;
3495 END IF;
3496 END pqp_get_maternity_id;
3497
3498 -- pqp_get_medical_id Returns the medical id value for a given absence id.
3499 FUNCTION pqp_get_medical_id(
3500 p_absence_id IN NUMBER
3501 ,p_message OUT NOCOPY VARCHAR2
3502 )
3503 RETURN NUMBER
3504 IS
3505 l_proc_step NUMBER(38,10):=0;
3506 l_proc_name VARCHAR2(61):=
3507 g_package_name||'pqp_get_medical_id';
3508 l_medical_id ssp_medicals.medical_id%TYPE;
3509 BEGIN
3510 IF g_debug THEN
3511 debug_enter(l_proc_name);
3512 debug('p_absence_id:'||p_absence_id);
3513 END IF;
3514 OPEN csr_medical_id(p_absence_id => p_absence_id);
3515 FETCH csr_medical_id INTO l_medical_id;
3516
3517 --
3518 IF csr_medical_id%NOTFOUND
3519 THEN
3520 p_message := fnd_message.get_string('PQP', 'PQP_230600_INV_MEDICAL_ID');
3521 END IF;
3522
3523 CLOSE csr_medical_id;
3524 IF g_debug THEN
3525 debug('l_medical_id:'||l_medical_id);
3526 debug_exit(l_proc_name);
3527 END IF;
3528 RETURN l_medical_id;
3529
3530 EXCEPTION
3531 WHEN OTHERS THEN
3532 clear_cache;
3533 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
3534 debug_others(l_proc_name,l_proc_step);
3535 IF g_debug THEN
3536 debug('Leaving: '||l_proc_name,-999);
3537 END IF;
3538 fnd_message.raise_error;
3539 ELSE
3540 RAISE;
3541 END IF;
3542 END pqp_get_medical_id;
3543
3544 -- pqp_gb_get_no_holidays Returns the number of holidays declared in UDT
3545 -- as holidays in the absence period which is start date and end date.
3546 FUNCTION pqp_gb_get_no_of_holidays(
3547 p_business_group_id IN NUMBER
3548 ,p_abs_start_date IN DATE
3549 ,p_abs_end_date IN DATE
3550 ,p_table_id IN NUMBER
3551 ,p_column_name IN VARCHAR2
3552 ,p_value IN VARCHAR2
3553 )
3554 RETURN NUMBER
3555 IS
3556 l_count NUMBER;
3557 l_proc_step NUMBER(38,10):=0;
3558 l_proc_name VARCHAR2(61):=
3559 g_package_name||'pqp_gb_get_no_holidays';
3560 l_abs_end_date DATE; -- Added to handle Open ended absences
3561 l_column_name pay_user_columns.user_column_name%TYPE;
3562 BEGIN
3563 IF g_debug THEN
3564 debug_enter(l_proc_name);
3565 debug('p_business_group_id:'||p_business_group_id);
3566 debug(p_abs_start_date);
3567 debug(p_abs_end_date);
3568 debug('p_table_id:'||p_table_id);
3569 debug('p_column_name:'||p_column_name);
3570 debug('p_value:'||p_value);
3571 END IF;
3572 --SELECT DECODE(
3573 -- p_abs_end_date
3574 -- ,hr_api.g_eot, p_abs_start_date
3575 -- ,p_abs_end_date
3576 -- )
3577 --INTO l_abs_end_date
3578 --FROM DUAL;
3579
3580 IF TRUNC(p_abs_end_date) = hr_api.g_eot THEN
3581 l_abs_end_date := p_abs_start_date;
3582 ELSE
3583 l_abs_end_date := p_abs_end_date;
3584 END IF;
3585
3586 IF p_column_name IS NULL
3587 THEN
3588 -- Get the Column from the Lookup
3589 l_column_name :=
3590 hr_general.decode_lookup(
3591 p_lookup_type => 'PQP_GB_OMP_CALENDAR_RULES'
3592 ,p_lookup_code => 'EXCLUDED'
3593 );
3594 ELSE
3595 l_column_name := p_column_name;
3596 END IF;
3597
3598 OPEN csr_get_hol_abs(
3599 p_business_group_id => p_business_group_id
3600 ,p_abs_start_date => p_abs_start_date
3601 ,p_abs_end_date => l_abs_end_date
3602 ,p_table_id => p_table_id
3603 ,p_column_name => l_column_name
3604 ,p_value => p_value
3605 );
3606 FETCH csr_get_hol_abs INTO l_count;
3607 CLOSE csr_get_hol_abs;
3608 debug_exit(l_proc_name);
3609 RETURN NVL(l_count, 0);
3610 EXCEPTION
3611 WHEN OTHERS THEN
3612 clear_cache;
3613 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
3614 debug_others(l_proc_name,l_proc_step);
3615 IF g_debug THEN
3616 debug('Leaving: '||l_proc_name,-999);
3617 END IF;
3618 fnd_message.raise_error;
3619 ELSE
3620 RAISE;
3621 END IF;
3622 END pqp_gb_get_no_of_holidays;
3623
3624 -- pqp_gb_get_calendar_days Returns the number of days in a given period
3625 FUNCTION pqp_gb_get_calendar_days(p_start_date IN DATE, p_end_date IN DATE)
3626 RETURN NUMBER
3627 IS
3628 l_count NUMBER;
3629 l_proc_step NUMBER(38,10):=0;
3630 l_proc_name VARCHAR2(61):=
3631 g_package_name||'pqp_gb_get_calendar_days';
3632
3633 CURSOR c_no_of_days(c_start_date IN DATE, c_end_date IN DATE)
3634 IS
3635 SELECT (c_end_date - c_start_date + 1) cnt
3636 FROM DUAL;
3637 BEGIN
3638 IF g_debug THEN
3639 debug_enter(l_proc_name);
3640 debug('p_start_date:'||fnd_date.date_to_canonical(p_start_date));
3641 debug('p_end_date:'||fnd_date.date_to_canonical(p_end_date));
3642 END IF;
3643
3644 OPEN c_no_of_days(c_start_date => p_start_date
3645 ,c_end_date => p_end_date);
3646 FETCH c_no_of_days INTO l_count;
3647 CLOSE c_no_of_days;
3648 IF g_debug THEN
3649 debug('l_count:'||l_count);
3650 debug_exit(l_proc_name);
3651 END IF;
3652 RETURN l_count;
3653 EXCEPTION
3654 WHEN OTHERS THEN
3655 clear_cache;
3656 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
3657 debug_others(l_proc_name,l_proc_step);
3658 IF g_debug THEN
3659 debug('Leaving: '||l_proc_name,-999);
3660 END IF;
3661 fnd_message.raise_error;
3662 ELSE
3663 RAISE;
3664 END IF;
3665 END pqp_gb_get_calendar_days;
3666
3667 -- pqp_gb_get_cal_abs_hol_days Returns the number of absences in a
3668 -- calendar period which is arrived at after deducting the
3669 -- number of holidays in the period from the number of calendar days.
3670 FUNCTION pqp_gb_get_cal_abs_hol_days(
3671 p_business_group_id IN NUMBER
3672 ,p_abs_start_date IN DATE
3673 ,p_abs_end_date IN DATE
3674 ,p_holidays OUT NOCOPY NUMBER
3675 ,p_table_id IN NUMBER
3676 ,p_column_name IN VARCHAR2
3677 ,p_value IN VARCHAR2
3678 )
3679 RETURN NUMBER
3680 IS
3681 l_count NUMBER;
3682 l_cal_days NUMBER;
3683 l_hol_days NUMBER;
3684 l_proc_step NUMBER(38,10):=0;
3685 l_proc_name VARCHAR2(61):=
3686 g_package_name||'pqp_gb_get_cal_abs_hol_days';
3687 BEGIN
3688 IF g_debug THEN
3689 debug_enter(l_proc_name);
3690 debug('p_business_group_id:'||p_business_group_id);
3691 debug('p_abs_start_date:'||fnd_date.date_to_canonical(p_abs_start_date));
3692 debug('p_abs_end_date:'||fnd_date.date_to_canonical(p_abs_end_date));
3693 debug('p_table_id:'||p_table_id);
3694 debug('p_column_name:'||p_column_name);
3695 debug('p_value:'||p_value);
3696 END IF;
3697
3698 -- Get the Number of Calendar Days.
3699 debug(l_proc_name, 10);
3700 l_cal_days :=
3701 pqp_gb_osp_functions.pqp_gb_get_calendar_days(p_start_date => p_abs_start_date
3702 ,p_end_date => p_abs_end_date);
3703 -- Get the Number of Holidays in the absence period.
3704 debug(l_proc_name, 20);
3705 l_hol_days :=
3706 pqp_gb_osp_functions.pqp_gb_get_no_of_holidays(
3707 p_business_group_id => p_business_group_id
3708 ,p_abs_start_date => p_abs_start_date
3709 ,p_abs_end_date => p_abs_end_date
3710 ,p_table_id => p_table_id
3711 ,p_column_name => p_column_name
3712 ,p_value => p_value
3713 );
3714 -- Deduct Holidays to get the no of absences.
3715 p_holidays := l_hol_days;
3716 l_count := l_cal_days - l_hol_days;
3717 IF g_debug THEN
3718 debug('l_count:'||l_count);
3719 debug_exit(l_proc_name);
3720 END IF;
3721 RETURN l_count;
3722
3723 EXCEPTION
3724 WHEN OTHERS THEN
3725 clear_cache;
3726 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
3727 debug_others(l_proc_name,l_proc_step);
3728 IF g_debug THEN
3729 debug('Leaving: '||l_proc_name,-999);
3730 END IF;
3731 fnd_message.raise_error;
3732 ELSE
3733 RAISE;
3734 END IF;
3735 END pqp_gb_get_cal_abs_hol_days;
3736
3737 -- pqp_gb_get_cal_abs_days Returns the number of calendar days if no UDT
3738 -- is passed. Returns the no of calendar days minus the holidays in
3739 -- the absence period declared in UDT if UDT is passed.
3740 FUNCTION pqp_gb_get_cal_abs_days(
3741 p_business_group_id IN NUMBER
3742 ,p_abs_start_date IN DATE
3743 ,p_abs_end_date IN DATE
3744 ,p_holidays OUT NOCOPY NUMBER
3745 ,p_table_id IN NUMBER
3746 ,p_column_name IN VARCHAR2
3747 ,p_value IN VARCHAR2
3748 )
3749 RETURN NUMBER
3750 IS
3751 l_count NUMBER;
3752 l_proc_step NUMBER(38,10):=0;
3753 l_proc_name VARCHAR2(61):=
3754 g_package_name||'pqp_gb_get_cal_abs_days';
3755 BEGIN
3756 IF g_debug THEN
3757 debug_enter(l_proc_name);
3758 debug('p_business_group_id:'||p_business_group_id);
3759 debug('p_abs_start_date:'||fnd_date.date_to_canonical(p_abs_start_date));
3760 debug('p_abs_end_date:'||fnd_date.date_to_canonical(p_abs_end_date));
3761 debug('p_table_id:'||p_table_id);
3762 debug('p_column_name:'||p_column_name);
3763 debug('p_value:'||p_value);
3764 END IF;
3765
3766 --
3767 IF p_table_id IS NULL
3768 THEN
3769 -- Get the number of days in the period .
3770 debug(l_proc_name, 10);
3771 l_count :=
3772 pqp_gb_osp_functions.pqp_gb_get_calendar_days(p_start_date => p_abs_start_date
3773 ,p_end_date => p_abs_end_date);
3774 ELSE
3775 -- when UDT is passed Get the Calendar Days minus no of holidays in the
3776 -- absence period declared in UDT.
3777 debug(l_proc_name, 20);
3778 l_count :=
3779 pqp_gb_osp_functions.pqp_gb_get_cal_abs_hol_days(
3780 p_business_group_id => p_business_group_id
3781 ,p_abs_start_date => p_abs_start_date
3782 ,p_abs_end_date => p_abs_end_date
3783 ,p_holidays => p_holidays
3784 ,p_table_id => p_table_id
3785 ,p_column_name => p_column_name
3786 ,p_value => p_value
3787 );
3788 END IF;
3789
3790 --
3791 IF g_debug THEN
3792 debug('l_count:'||l_count);
3793 debug_exit(l_proc_name);
3794 END IF;
3795 RETURN l_count;
3796
3797 EXCEPTION
3798 WHEN OTHERS THEN
3799 clear_cache;
3800 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
3801 debug_others(l_proc_name,l_proc_step);
3802 IF g_debug THEN
3803 debug('Leaving: '||l_proc_name,-999);
3804 END IF;
3805 fnd_message.raise_error;
3806 ELSE
3807 RAISE;
3808 END IF;
3809 END pqp_gb_get_cal_abs_days;
3810
3811 -- pqp_gb_get_no_of_work_holidays Returns the number of Holidays in the list of
3812 -- dates passed as input. Checks for each date is defined in UDT as a
3813 -- holiday and returns the count of holidays.
3814 FUNCTION pqp_gb_get_no_of_work_holidays(
3815 p_business_group_id IN NUMBER
3816 ,p_work_dates IN pqp_schedule_calculation_pkg.t_working_dates
3817 ,p_table_id IN NUMBER
3818 ,p_column_name IN VARCHAR2
3819 ,p_value IN VARCHAR2
3820 )
3821 RETURN NUMBER
3822 IS
3823 l_count NUMBER := 0;
3824 l_value pay_user_column_instances_f.VALUE%TYPE;
3825 l_proc_step NUMBER(38,10):=0;
3826 l_proc_name VARCHAR2(61):=
3827 g_package_name||'pqp_gb_get_no_of_work_holidays';
3828 l_column_name pay_user_columns.user_column_name%TYPE;
3829 BEGIN
3830 IF g_debug THEN
3831 debug_enter(l_proc_name);
3832 debug('p_business_group_id:'||p_business_group_id);
3833 debug('p_table_id:'||p_table_id);
3834 debug('p_column_name:'||p_column_name);
3835 debug('p_value:'||p_value);
3836 END IF;
3837
3838 IF p_column_name IS NULL
3839 THEN
3840 -- Get the Column from the Lookup
3841 l_column_name :=
3842 hr_general.decode_lookup(
3843 p_lookup_type => 'PQP_GB_OMP_CALENDAR_RULES'
3844 ,p_lookup_code => 'EXCLUDED'
3845 );
3846 ELSE
3847 l_column_name := p_column_name;
3848 END IF;
3849
3850 FOR i IN 1 .. p_work_dates.COUNT
3851 LOOP
3852 OPEN csr_get_work_hol(
3853 p_business_group_id => p_business_group_id
3854 ,p_abs_date => p_work_dates(i)
3855 ,p_table_id => p_table_id
3856 ,p_column_name => l_column_name
3857 ,p_value => p_value
3858 );
3859 FETCH csr_get_work_hol INTO l_value;
3860
3861 IF csr_get_work_hol%FOUND
3862 THEN
3863 l_count := l_count + 1;
3864 END IF;
3865
3866 CLOSE csr_get_work_hol;
3867 END LOOP;
3868
3869 IF g_debug THEN
3870 debug('l_count:'||l_count);
3871 debug_exit(l_proc_name);
3872 END IF;
3873 RETURN l_count;
3874 EXCEPTION
3875 WHEN OTHERS THEN
3876 clear_cache;
3877 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
3878 debug_others(l_proc_name,l_proc_step);
3879 IF g_debug THEN
3880 debug('Leaving: '||l_proc_name,-999);
3881 END IF;
3882 fnd_message.raise_error;
3883 ELSE
3884 RAISE;
3885 END IF;
3886 END pqp_gb_get_no_of_work_holidays;
3887
3888 -- pqp_gb_get_work_abs_days_udt Returns the number of absence Days in a
3889 -- given period.get_days_worked first calculates the number of working days
3890 -- in the period for the work pattern and Returns a list of working dates .
3891 -- These working dates are passed to pqp_gb_get_no_of_work_holidays and the
3892 -- number of holidays will be calculated. the difference between total
3893 -- working days and no of holidays gives the number of absences for the period
3894
3895 FUNCTION pqp_gb_get_work_abs_days_udt(
3896 p_assignment_id IN NUMBER
3897 ,p_business_group_id IN NUMBER
3898 ,p_start_date IN DATE
3899 ,p_end_date IN DATE
3900 ,p_default_wp IN VARCHAR2
3901 ,p_table_id IN NUMBER
3902 ,p_column_name IN VARCHAR2
3903 ,p_value IN VARCHAR2
3904 ,p_holidays OUT NOCOPY NUMBER
3905 ,p_error_code OUT NOCOPY NUMBER
3906 ,p_error_message OUT NOCOPY VARCHAR2
3907 )
3908 RETURN NUMBER
3909 IS
3910 l_count NUMBER := 0;
3911 l_work_days NUMBER;
3912 l_work_holidays NUMBER;
3913 l_proc_step NUMBER(38,10):=0;
3914 l_proc_name VARCHAR2(61):=
3915 g_package_name||'pqp_gb_get_work_abs_days_udt';
3916 l_working_dates pqp_schedule_calculation_pkg.t_working_dates;
3917 BEGIN
3918 IF g_debug THEN
3919 debug_enter(l_proc_name);
3920 debug('p_assignment_id:'||p_assignment_id);
3921 debug('p_business_group_id:'||p_business_group_id);
3922 debug('p_start_date:'||fnd_date.date_to_canonical(p_start_date));
3923 debug('p_end_date:'||fnd_date.date_to_canonical(p_end_date));
3924 debug('p_default_wp:'||p_default_wp);
3925 debug('p_table_id:'||p_table_id);
3926 debug('p_column_name:'||p_column_name);
3927 debug('p_value:'||p_value);
3928
3929 END IF;
3930 -- Call Work Patterns function to get Collection of Working Dates
3931 debug(l_proc_name, 10);
3932 l_work_days :=
3933 pqp_schedule_calculation_pkg.get_days_worked(
3934 p_assignment_id => p_assignment_id
3935 ,p_business_group_id => p_business_group_id
3936 ,p_date_start => p_start_date
3937 ,p_date_end => p_end_date
3938 ,p_default_wp => p_default_wp
3939 ,p_working_dates => l_working_dates
3940 ,p_error_code => p_error_code
3941 ,p_error_message => p_error_message
3942 );
3943 debug(l_proc_name, 20);
3944 l_work_holidays :=
3945 pqp_gb_osp_functions.pqp_gb_get_no_of_work_holidays(
3946 p_business_group_id => p_business_group_id
3947 ,p_work_dates => l_working_dates
3948 ,p_table_id => p_table_id
3949 ,p_column_name => p_column_name
3950 ,p_value => p_value
3951 );
3952 -- Number of Holidays in the period are Returned as OUT Parameter.
3953 p_holidays := l_work_holidays;
3954 l_count := l_work_days - l_work_holidays;
3955 IF g_debug THEN
3956 debug('l_count:'||l_count);
3957 debug_exit(l_proc_name);
3958 END IF;
3959 RETURN l_count;
3960
3961 EXCEPTION
3962 WHEN OTHERS THEN
3963 clear_cache;
3964 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
3965 debug_others(l_proc_name,l_proc_step);
3966 IF g_debug THEN
3967 debug('Leaving: '||l_proc_name,-999);
3968 END IF;
3969 fnd_message.raise_error;
3970 ELSE
3971 RAISE;
3972 END IF;
3973 END pqp_gb_get_work_abs_days_udt;
3974
3975 -- pqp_gb_get_work_abs_days Returns the number of Working Days absences
3976 -- in a given period.
3977 FUNCTION pqp_gb_get_work_abs_days(
3978 p_assignment_id IN NUMBER
3979 ,p_business_group_id IN NUMBER
3980 ,p_start_date IN DATE
3981 ,p_end_date IN DATE
3982 ,p_holidays OUT NOCOPY NUMBER
3983 ,p_error_code OUT NOCOPY NUMBER
3984 ,p_error_message OUT NOCOPY VARCHAR2
3985 ,p_default_wp IN VARCHAR2
3986 ,p_table_id IN NUMBER
3987 ,p_column_name IN VARCHAR2
3988 ,p_value IN VARCHAR2
3989 )
3990 RETURN NUMBER
3991 IS
3992 l_count NUMBER := 0;
3993 l_proc_step NUMBER(38,10):=0;
3994 l_proc_name VARCHAR2(61):=
3995 g_package_name||'pqp_gb_get_work_abs_days';
3996 BEGIN
3997 IF g_debug THEN
3998 debug_enter(l_proc_name);
3999 debug('p_assignment_id:'||p_assignment_id);
4000 debug('p_business_group_id:'||p_business_group_id);
4001 debug('p_start_date:'||fnd_date.date_to_canonical(p_start_date));
4002 debug('p_end_date:'||fnd_date.date_to_canonical(p_end_date));
4003 debug('p_default_wp:'||p_default_wp);
4004 debug('p_table_id:'||p_table_id);
4005 debug('p_column_name:'||p_column_name);
4006 debug('p_value:'||p_value);
4007 END IF;
4008 -- If Table Id is not passed then
4009 IF p_table_id IS NULL
4010 THEN
4011 debug(l_proc_name, 10);
4012 l_count :=
4013 pqp_schedule_calculation_pkg.get_days_worked(
4014 p_assignment_id => p_assignment_id
4015 ,p_business_group_id => p_business_group_id
4016 ,p_date_start => p_start_date
4017 ,p_date_end => p_end_date
4018 ,p_default_wp => p_default_wp
4019 ,p_error_code => p_error_code
4020 ,p_error_message => p_error_message
4021 );
4022 ELSE -- If UDT is Passed
4023 debug(l_proc_name, 20);
4024 l_count :=
4025 pqp_gb_osp_functions.pqp_gb_get_work_abs_days_udt(
4026 p_assignment_id => p_assignment_id
4027 ,p_business_group_id => p_business_group_id
4028 ,p_start_date => p_start_date
4029 ,p_end_date => p_end_date
4030 ,p_default_wp => p_default_wp
4031 ,p_table_id => p_table_id
4032 ,p_column_name => p_column_name
4033 ,p_value => p_value
4034 ,p_holidays => p_holidays
4035 ,p_error_code => p_error_code
4036 ,p_error_message => p_error_message
4037 );
4038 END IF;
4039
4040 IF g_debug THEN
4041 debug('l_count:'||l_count);
4042 debug_exit(l_proc_name);
4043 END IF;
4044 RETURN l_count;
4045
4046 EXCEPTION
4047 WHEN OTHERS THEN
4048 clear_cache;
4049 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
4050 debug_others(l_proc_name,l_proc_step);
4051 IF g_debug THEN
4052 debug('Leaving: '||l_proc_name,-999);
4053 END IF;
4054 fnd_message.raise_error;
4055 ELSE
4056 RAISE;
4057 END IF;
4058 END pqp_gb_get_work_abs_days;
4059 --
4060 -- pqp_get_omp_band_ent_value Returns the Entitlement Percentage and Recurring
4061 -- or Average Earnings Indicator for Band 1 - Band4. If Intends to Return to
4062 -- Work Flag is 'Y' then Band1Y is called otherwise Band1N for Band1
4063 -- Entitlement. A Fatal error is raised and -1 is returned if Band1 is not
4064 -- defined. For Other Bands if entitlement is defined without percentage or
4065 -- Earnings Type then a Fatal error is raised and -1 is Returned. If Other
4066 -- Band Entitlements are not defined then the value of entitlement is returned
4067 -- as -1 and Function Returns 0.
4068 --
4069 FUNCTION pqp_get_omp_band_ent_value
4070 (p_business_group_id IN NUMBER
4071 ,p_effective_date IN DATE
4072 ,p_assignment_id IN NUMBER -- Context #3
4073 ,p_element_type_id IN NUMBER -- Context #4
4074 ,p_entitlement_tab_id IN NUMBER
4075 ,p_benefits_length_of_service IN NUMBER
4076 ,p_return_to_work IN VARCHAR2
4077 ,p_band1_entitlement OUT NOCOPY NUMBER
4078 ,p_band1_percentage OUT NOCOPY NUMBER
4079 ,p_band1_avg_rec_ind OUT NOCOPY VARCHAR2
4080 ,p_band2_entitlement OUT NOCOPY NUMBER
4081 ,p_band2_percentage OUT NOCOPY NUMBER
4082 ,p_band2_avg_rec_ind OUT NOCOPY VARCHAR2
4083 ,p_band3_entitlement OUT NOCOPY NUMBER
4084 ,p_band3_percentage OUT NOCOPY NUMBER
4085 ,p_band3_avg_rec_ind OUT NOCOPY VARCHAR2
4086 ,p_band4_entitlement OUT NOCOPY NUMBER
4087 ,p_band4_percentage OUT NOCOPY NUMBER
4088 ,p_band4_avg_rec_ind OUT NOCOPY VARCHAR2
4089 ,p_error_msg OUT NOCOPY VARCHAR2
4090 ,p_entitlement_bands_list_name IN VARCHAR2 DEFAULT
4091 'PQP_GAP_ENTITLEMENT_BANDS'
4092 ,p_override_effective_date IN DATE DEFAULT NULL
4093 ) RETURN NUMBER
4094 IS
4095 l_user_column_id pay_user_columns.user_column_id%TYPE;
4096 l_retval NUMBER;
4097 l_row_val NUMBER := -1;
4098 l_proc_step NUMBER(38,10):=0;
4099 l_proc_name VARCHAR2(61):=
4100 g_package_name||'pqp_get_omp_band_ent_value';
4101 i BINARY_INTEGER;
4102 l_band_ent t_entitlement_parameters;
4103 l_entitlement_parameters t_entitlement_parameters;
4104 l_truncated_yes_no VARCHAR2(30);
4105 l_pl_id_txt pay_element_type_extra_info.eei_information1%TYPE;
4106 l_pl_id ben_pl_f.pl_id%TYPE;
4107 l_effective_date DATE;
4108
4109 BEGIN
4110 --
4111 IF g_debug THEN
4112 debug_enter(l_proc_name);
4113 debug('p_business_group_id:'||p_business_group_id);
4114 debug('p_effective_date:'||fnd_date.date_to_canonical(p_effective_date));
4115 debug('p_assignment_id:'||p_assignment_id);
4116 debug('p_element_type_id:'||p_element_type_id);
4117 debug('p_entitlement_tab_id:'||p_entitlement_tab_id);
4118 debug('p_benefits_length_of_service:'||p_benefits_length_of_service);
4119 debug('p_return_to_work:'||p_return_to_work);
4120 END IF;
4121 p_band1_entitlement := -1;
4122 p_band1_percentage := 0;
4123 p_band1_avg_rec_ind := ' ';
4124 p_band2_entitlement := -1;
4125 p_band2_percentage := 0;
4126 p_band2_avg_rec_ind := ' ';
4127 p_band3_entitlement := -1;
4128 p_band3_percentage := 0;
4129 p_band3_avg_rec_ind := ' ';
4130 p_band4_entitlement := -1;
4131 p_band4_percentage := 0;
4132 p_band4_avg_rec_ind := ' ';
4133 -- Get the entitlement information for all bands
4134
4135 l_effective_date := NVL(p_override_effective_date, p_effective_date);
4136
4137 l_retval :=
4138 pqp_utilities.pqp_get_extra_element_info(
4139 p_element_type_id => p_element_type_id
4140 ,p_information_type => 'PQP_GB_OMP_ABSENCE_PLAN_INFO'
4141 ,p_segment_name => 'Plan Name'
4142 ,p_value => l_pl_id_txt
4143 ,p_truncated_yes_no => l_truncated_yes_no
4144 ,p_error_msg => p_error_msg
4145 );
4146
4147 IF l_retval < 0 THEN
4148 check_error_code(l_retval,p_error_msg);
4149 END IF;
4150
4151 l_pl_id := fnd_number.canonical_to_number(l_pl_id_txt);
4152
4153 l_retval :=
4154 get_entitlement_parameters(
4155 p_business_group_id => p_business_group_id
4156 ,p_effective_date => l_effective_date
4157 ,p_assignment_id => p_assignment_id
4158 ,p_pl_id => l_pl_id
4159 ,p_absence_pay_plan_class => 'OMP'
4160 ,p_entitlement_table_id => p_entitlement_tab_id
4161 ,p_benefits_length_of_service => p_benefits_length_of_service
4162 ,p_entitlement_bands_list_name => p_entitlement_bands_list_name
4163 ,p_entitlement_parameters => l_entitlement_parameters
4164 ,p_error_msg => p_error_msg
4165 ,p_omp_intend_to_return_to_work => p_return_to_work
4166 );
4167
4168 IF l_retval = -1
4169 THEN
4170 debug(p_error_msg);
4171 debug_exit(l_proc_name);
4172 RETURN -1;
4173 ELSE
4174 i := l_entitlement_parameters.FIRST;
4175
4176 WHILE i IS NOT NULL
4177 LOOP
4178 IF l_entitlement_parameters(i).band = 'BAND1'
4179 THEN
4180 p_band1_entitlement := l_entitlement_parameters(i).entitlement;
4181 p_band1_percentage := l_entitlement_parameters(i).percentage;
4182 p_band1_avg_rec_ind := l_entitlement_parameters(i).earnings_type;
4183 ELSIF l_entitlement_parameters(i).band = 'BAND2'
4184 THEN
4185 p_band2_entitlement := l_entitlement_parameters(i).entitlement;
4186 p_band2_percentage := l_entitlement_parameters(i).percentage;
4187 p_band2_avg_rec_ind := l_entitlement_parameters(i).earnings_type;
4188 ELSIF l_entitlement_parameters(i).band = 'BAND3'
4189 THEN
4190 p_band3_entitlement := l_entitlement_parameters(i).entitlement;
4191 p_band3_percentage := l_entitlement_parameters(i).percentage;
4192 p_band3_avg_rec_ind := l_entitlement_parameters(i).earnings_type;
4193 ELSIF l_entitlement_parameters(i).band = 'BAND4'
4194 THEN
4195 p_band4_entitlement := l_entitlement_parameters(i).entitlement;
4196 p_band4_percentage := l_entitlement_parameters(i).percentage;
4197 p_band4_avg_rec_ind := l_entitlement_parameters(i).earnings_type;
4198 EXIT;
4199 END IF; -- End if of band check ...
4200
4201 i := l_entitlement_parameters.NEXT(i);
4202 END LOOP;
4203 END IF; -- End if of retval -1 check
4204 --
4205
4206 debug_exit(l_proc_name);
4207 RETURN 0;
4208
4209 EXCEPTION
4210 WHEN OTHERS THEN
4211 clear_cache;
4212 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
4213 debug_others(l_proc_name,l_proc_step);
4214 IF g_debug THEN
4215 debug('Leaving: '||l_proc_name,-999);
4216 END IF;
4217 fnd_message.raise_error;
4218 ELSE
4219 RAISE;
4220 END IF;
4221 END pqp_get_omp_band_ent_value;
4222 --
4223 --
4224 --
4225 -- PROCEDURE get_day_dets(
4226 -- p_wp_dets IN pqp_schedule_calculation_pkg.c_wp_dets%ROWTYPE
4227 -- ,p_calc_stdt IN DATE
4228 -- ,p_calc_edt IN DATE
4229 -- ,p_day_no OUT NOCOPY NUMBER
4230 -- ,p_days_in_wp OUT NOCOPY NUMBER
4231 -- )
4232 -- IS
4233 -- -- Local Declarations
4234 --
4235 ---- cursor c_get_days is
4236 ---- select count(pur.row_low_range_or_name)
4237 ---- from pay_user_rows_f pur
4238 ---- where pur.user_row_id in(
4239 ---- select distinct uci.user_row_id
4240 ---- from pay_user_tables put,
4241 ---- pay_user_columns puc,
4242 ---- pay_user_column_instances_f uci
4243 ---- where put.user_table_id = puc.user_table_id
4244 ---- and uci.user_column_id = puc.user_column_id
4245 ---- and put.user_table_name = g_udt_name
4246 ---- and puc.user_column_name = p_wp_dets.work_pattern
4247 ---- and puc.business_group_id = p_wp_dets.business_group_id
4248 ---- and (p_calc_stdt between uci.effective_start_date
4249 ---- and uci.effective_end_date
4250 ---- or p_calc_edt between uci.effective_start_date
4251 ---- and uci.effective_end_date));
4252 ---- changes by rrazdan
4253 ---- the above and below queries are non-performant
4254 ---- however it is not possible in this to safely change these
4255 ---- with te required performance changes without impacting
4256 ---- testing hence only minimal changes are being done
4257 ---- in order to make this cursor deal with seeded work patterns
4258 ----
4259 -- CURSOR c_get_days
4260 -- IS
4261 -- SELECT COUNT(pur.row_low_range_or_name)
4262 -- FROM pay_user_rows_f pur
4263 -- WHERE pur.user_row_id IN(
4264 -- SELECT DISTINCT uci.user_row_id
4265 -- FROM pay_user_tables put
4266 -- ,pay_user_columns puc
4267 -- ,pay_user_column_instances_f uci
4268 -- ,per_business_groups_perf pbg
4269 -- WHERE put.user_table_name = g_udt_name
4270 -- AND pbg.business_group_id =
4271 -- p_wp_dets.business_group_id
4272 -- AND put.legislation_code = pbg.legislation_code
4273 -- AND puc.user_table_id = put.user_table_id
4274 -- AND puc.user_column_name = p_wp_dets.work_pattern
4275 -- AND (
4276 -- puc.business_group_id =
4277 -- p_wp_dets.business_group_id
4278 -- OR (
4279 -- puc.business_group_id IS NULL
4280 -- AND puc.legislation_code =
4281 -- pbg.legislation_code
4282 -- )
4283 -- --OR global
4284 -- -- CANNOT BE as the table itself is legislatively seeded.
4285 -- )
4286 -- AND uci.user_column_id = puc.user_column_id
4287 -- AND (
4288 -- uci.business_group_id =
4289 -- p_wp_dets.business_group_id
4290 -- OR (
4291 -- uci.business_group_id IS NULL
4292 -- AND uci.legislation_code =
4293 -- pbg.legislation_code
4294 -- )
4295 -- --OR global
4296 -- -- CANNOT BE as the work pattern itself is either
4297 -- -- legislative or business group specific
4298 -- )
4299 -- AND (
4300 -- p_calc_stdt BETWEEN uci.effective_start_date
4301 -- AND uci.effective_end_date
4302 -- OR p_calc_edt BETWEEN uci.effective_start_date
4303 -- AND uci.effective_end_date
4304 -- ));
4305 --
4306 -- l_days_in_wp NUMBER;
4307 -- l_day_no NUMBER;
4308 -- l_diff_days NUMBER;
4309 -- l_diff_calcstdt_dtonday1 NUMBER;
4310 -- l_diff_temp NUMBER;
4311 -- l_dt_on_day1 DATE;
4312 -- l_proc_step NUMBER(38,10):=0;
4313 -- l_proc_name VARCHAR2(61):=
4314 -- g_package_name||'get_day_dets';
4315 -- BEGIN
4316 -- debug_enter(l_proc_name);
4317 ---- Get the number of days in the Work Pattern
4318 -- OPEN c_get_days;
4319 -- FETCH c_get_days INTO l_days_in_wp;
4320 -- CLOSE c_get_days;
4321 -- -- Find number of days to be added to effective date
4322 -- -- to get next date on 'Day 01'
4323 -- l_diff_days :=
4324 -- l_days_in_wp - TO_NUMBER(SUBSTR(p_wp_dets.start_day, 5, 2))
4325 -- + 1;
4326 -- -- Find the next date that would be 'Day 01' w.r.t. the p_wp_dets record
4327 -- l_dt_on_day1 := p_wp_dets.effective_start_date + l_diff_days;
4328 -- -- Find difference between calculation start_date and date on 'Day 01'
4329 -- l_diff_temp := p_calc_stdt - l_dt_on_day1;
4330 -- -- If difference is negative, multiply by -1 to make it positive
4331 -- l_diff_calcstdt_dtonday1 := l_diff_temp * SIGN(l_diff_temp);
4332 --
4333 -- -- Calculate Day Number on Calculation Start Date
4334 -- IF l_diff_temp < 0
4335 -- THEN
4336 -- l_day_no := l_days_in_wp - l_diff_calcstdt_dtonday1 + 1;
4337 -- ELSE
4338 -- l_day_no := MOD(l_diff_calcstdt_dtonday1, l_days_in_wp) + 1;
4339 -- END IF;
4340 --
4341 -- -- Assign values to be returned
4342 -- p_day_no := l_day_no;
4343 -- p_days_in_wp := l_days_in_wp;
4344 -- debug_exit(l_proc_name);
4345 --
4346 -- EXCEPTION
4347 -- WHEN OTHERS THEN
4348 -- clear_cache;
4349 -- IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
4350 -- debug_others(l_proc_name,l_proc_step);
4351 -- IF g_debug THEN
4352 -- debug('Leaving: '||l_proc_name,-999);
4353 -- END IF;
4354 -- fnd_message.raise_error;
4355 -- ELSE
4356 -- RAISE;
4357 -- END IF;
4358 -- END get_day_dets;
4359
4360 PROCEDURE get_next_working_date_wp(
4361 p_business_group_id IN NUMBER
4362 ,p_wp_dets IN pqp_schedule_calculation_pkg.c_wp_dets%ROWTYPE
4363 ,p_curr_date IN OUT NOCOPY DATE
4364 ,p_balance_days IN OUT NOCOPY NUMBER
4365 ,p_table_id IN NUMBER
4366 ,p_column_name IN VARCHAR2
4367 ,p_value IN VARCHAR2
4368 )
4369 IS
4370 l_calc_stdt DATE;
4371 l_calc_endt DATE;
4372 l_day_no NUMBER;
4373 l_days_in_wp NUMBER;
4374 l_curr_day_no NUMBER;
4375 l_day VARCHAR2(30);
4376 l_hours NUMBER := 0;
4377 l_holidays NUMBER := 0;
4378 l_continue VARCHAR2(1) := 'Y';
4379 l_proc_step NUMBER(38,10):=0;
4380 l_proc_name VARCHAR2(61):=
4381 g_package_name||'get_next_working_date_wp';
4382 l_retval NUMBER;
4383 l_error_msg fnd_new_messages.message_text%TYPE;
4384 -- nocopy changes
4385 l_curr_date_nc DATE;
4386 l_balance_days_nc NUMBER;
4387 BEGIN -- get_next_working_date_wp
4388 IF g_debug THEN
4389 debug_enter(l_proc_name);
4390 debug('p_business_group_id:'||p_business_group_id);
4391 debug('p_curr_date:'||fnd_date.date_to_canonical(p_curr_date));
4392 debug('p_balance_days:'||p_balance_days);
4393 debug('p_table_id:'||p_table_id);
4394 debug('p_column_name:'||p_column_name);
4395 debug('p_value:'||p_value);
4396 END IF;
4397 -- nocopy changes
4398 l_curr_date_nc := p_curr_date;
4399 l_balance_days_nc := p_balance_days;
4400
4401 -- Determine Calculation Start Date for this Work Pattern
4402 IF p_curr_date > p_wp_dets.effective_start_date
4403 THEN
4404 l_calc_stdt := p_curr_date;
4405 ELSE
4406 l_calc_stdt := p_wp_dets.effective_start_date;
4407 END IF;
4408
4409 -- Set Calculation End Date for this Work Pattern
4410 l_calc_endt := p_wp_dets.effective_end_date;
4411 --Get day number on calculation start date and number of days in Work Pattern
4412 pqp_schedule_calculation_pkg.get_day_dets
4413 (p_wp_dets => p_wp_dets
4414 ,p_calc_stdt => l_calc_stdt
4415 ,p_calc_edt => l_calc_endt
4416 ,p_day_no => l_day_no -- OUT
4417 ,p_days_in_wp => l_days_in_wp --OUT
4418 );
4419
4420 l_curr_day_no := l_day_no;
4421 debug('l_curr_day_no :' || to_char(l_curr_day_no));
4422 debug('p_curr_date :' || to_char(p_curr_date));
4423 debug('Work Pattern :' || p_wp_dets.work_pattern);
4424
4425 -- Loop throug the dates starting from p_curr_date
4426 -- PS : we don't know till when to loop, so p_balance_days
4427 -- will be used as a balance counter
4428 LOOP -- Through dates starting with p_curr_date
4429 l_day := 'Day ' || LPAD(l_curr_day_no, 2, 0);
4430 debug('p_curr_date:'||fnd_date.date_to_canonical(p_curr_date));
4431
4432 BEGIN
4433 l_retval :=
4434 pqp_utilities.pqp_gb_get_table_value(
4435 p_business_group_id => p_wp_dets.business_group_id
4436 ,p_effective_date => p_curr_date
4437 ,p_table_name => g_udt_name
4438 ,p_column_name => p_wp_dets.work_pattern
4439 ,p_row_name => l_day
4440 ,p_value => l_hours
4441 ,p_error_msg => l_error_msg
4442 );
4443
4444 IF l_retval = -1
4445 THEN
4446 /*
4447 * If any Error then Do not add to total
4448 * or count the day in the loop.
4449 */
4450 debug('l_error_msg:'||l_error_msg);
4451 l_hours := 0;
4452 END IF;
4453 END;
4454
4455 debug('Hours on ' || l_day || ' = ' || l_hours, 70);
4456
4457 -- Decrement working days balance if l_curr_day_no
4458 -- is a working day
4459 IF l_hours > 0
4460 THEN
4461 -- Check for Holidays only if the Calendar UDT Id has been passed
4462 IF p_table_id IS NOT NULL
4463 THEN
4464 -- Check for Holidays
4465 l_holidays :=
4466 pqp_gb_get_no_of_holidays(
4467 p_business_group_id => p_business_group_id
4468 ,p_abs_start_date => p_curr_date
4469 ,p_abs_end_date => p_curr_date
4470 ,p_table_id => p_table_id
4471 ,p_column_name => p_column_name
4472 ,p_value => p_value
4473 );
4474
4475 IF l_holidays = 0
4476 THEN
4477 p_balance_days := p_balance_days - 1;
4478 ELSE
4479 debug(l_proc_name, 80);
4480 debug('HOLIDAY');
4481 END IF;
4482 --
4483 ELSE -- DO NOT Check for Holidays
4484 p_balance_days := p_balance_days - 1;
4485 END IF; -- p_table_id IS NOT NULL then
4486 --
4487 END IF; -- l_hours > 0 then
4488
4489 -- If we have counted down all the working days then exit
4490
4491 IF p_balance_days = 0
4492 THEN
4493 l_continue := 'N';
4494 EXIT;
4495 END IF;
4496
4497 -- Calculate next day no
4498 IF l_curr_day_no = l_days_in_wp
4499 THEN
4500 l_curr_day_no := 1;
4501 ELSE
4502 l_curr_day_no := l_curr_day_no + 1;
4503 END IF;
4504
4505 -- Increment to the next date
4506 p_curr_date := p_curr_date + 1;
4507
4508 -- The WP has changed, exit, but continue process using the next
4509 -- effective work pattern row
4510 IF p_curr_date > p_wp_dets.effective_end_date
4511 THEN
4512 l_continue := 'Y';
4513 EXIT;
4514 END IF;
4515 END LOOP; -- Through dates starting with p_curr_date
4516
4517 debug_exit(l_proc_name);
4518 RETURN;
4519
4520 EXCEPTION
4521 WHEN OTHERS THEN
4522 clear_cache;
4523 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
4524 debug_others(l_proc_name,l_proc_step);
4525 IF g_debug THEN
4526 debug('Leaving: '||l_proc_name,-999);
4527 END IF;
4528 fnd_message.raise_error;
4529 ELSE
4530 RAISE;
4531 END IF;
4532 END get_next_working_date_wp;
4533
4534 FUNCTION get_next_working_date(
4535 p_assignment_id IN NUMBER
4536 ,p_business_group_id IN NUMBER
4537 ,p_date_start IN DATE
4538 ,p_days IN NUMBER
4539 ,p_error_code OUT NOCOPY NUMBER
4540 ,p_error_message OUT NOCOPY VARCHAR2
4541 ,p_default_wp IN VARCHAR2
4542 ,p_table_id IN NUMBER
4543 ,p_column_name IN VARCHAR2
4544 ,p_value IN VARCHAR2
4545 )
4546 RETURN DATE
4547 IS
4548 l_balance_days NUMBER;
4549 l_curr_date DATE;
4550 l_calc_stdt DATE;
4551 l_calc_endt DATE;
4552 l_day_no NUMBER;
4553 l_days_in_wp NUMBER;
4554 l_curr_day_no NUMBER;
4555 l_day VARCHAR2(30);
4556 l_hours NUMBER := 0;
4557 l_continue VARCHAR2(1) := 'Y';
4558 l_asg_wp_found BOOLEAN := FALSE;
4559 l_error_code NUMBER := 0;
4560 l_err_msg_name fnd_new_messages.message_name%TYPE;
4561 l_proc_step NUMBER(38,10):=0;
4562 l_proc_name VARCHAR2(61):=
4563 g_package_name||'get_next_working_date';
4564 r_wp_dets pqp_schedule_calculation_pkg.c_wp_dets%ROWTYPE;
4565 r_def_wp_dets pqp_schedule_calculation_pkg.c_wp_dets%ROWTYPE;
4566 BEGIN /*get_next_working_date*/
4567 IF g_debug THEN
4568 debug_enter(l_proc_name);
4569 debug('p_assignment_id:'||p_assignment_id);
4570 debug('p_business_group_id:'||p_business_group_id);
4571 debug('p_date_start:'||fnd_date.date_to_canonical(p_date_start));
4572 debug('p_days:'||p_days);
4573 debug('p_default_wp:'||p_default_wp);
4574 debug('p_table_id:'||p_table_id);
4575 debug('p_column_name:'||p_column_name);
4576 debug('p_value:'||p_value);
4577 debug('g_udt_name:'||g_udt_name);
4578 END IF;
4579
4580 -- Add 1 to working days and assign to balance days
4581 -- We need to this as we want to return the date
4582 -- prior to the NEXT working day after p_days working days
4583 -- have been added to start date
4584 l_balance_days := FLOOR(p_days) + 1;
4585 l_curr_date := p_date_start;
4586
4587 FOR r_wp_dets IN pqp_schedule_calculation_pkg.c_wp_dets_up(p_assignment_id, p_date_start)
4588 LOOP /* Get Work Pattern Details */
4589 -- Only if this aat record contains a work pattern
4590 IF r_wp_dets.work_pattern IS NOT NULL
4591 THEN
4592 debug(l_proc_name, 30);
4593 l_asg_wp_found := TRUE;
4594
4595 IF l_curr_date BETWEEN r_wp_dets.effective_start_date
4596 AND r_wp_dets.effective_end_date
4597 THEN
4598 get_next_working_date_wp(
4599 p_business_group_id => p_business_group_id
4600 ,p_wp_dets => r_wp_dets
4601 ,p_curr_date => l_curr_date -- IN OUT
4602 ,p_balance_days => l_balance_days -- IN OUT
4603 ,p_table_id => p_table_id
4604 ,p_column_name => p_column_name
4605 ,p_value => p_value
4606 );
4607 --
4608 ELSIF p_default_wp IS NOT NULL
4609 THEN
4610 -- Use the default work pattern for the period where there is no
4611 -- work pattern on assignment and then use the asg work pattern
4612
4613 debug(l_proc_name, 40);
4614 -- Step 1) Add days for the default work pattern
4615 r_def_wp_dets := NULL;
4616 r_def_wp_dets.effective_start_date := l_curr_date;
4617 -- set effective end date as the day before the Asg WP becomes effective
4618 r_def_wp_dets.effective_end_date :=
4619 (
4620 r_wp_dets.effective_start_date - 1
4621 );
4622 r_def_wp_dets.business_group_id := p_business_group_id;
4623 r_def_wp_dets.work_pattern := p_default_wp;
4624 r_def_wp_dets.start_day :=
4625 'Day '
4626 || LPAD(
4627 TO_CHAR(
4628 8
4629 - (
4630 NEXT_DAY(l_curr_date, g_default_start_day)
4631 - l_curr_date
4632 )
4633 )
4634 ,2
4635 ,'0'
4636 );
4637 debug('Start Day :' || r_def_wp_dets.start_day);
4638 get_next_working_date_wp(
4639 p_business_group_id => p_business_group_id
4640 ,p_wp_dets => r_def_wp_dets
4641 ,p_curr_date => l_curr_date -- IN OUT
4642 ,p_balance_days => l_balance_days -- IN OUT
4643 ,p_table_id => p_table_id
4644 ,p_column_name => p_column_name
4645 ,p_value => p_value
4646 );
4647
4648 -- Step 2) Add days for the assignment work pattern
4649 -- But, only if there are more days to be added
4650 IF l_balance_days > 0
4651 THEN
4652 get_next_working_date_wp(
4653 p_business_group_id => p_business_group_id
4654 ,p_wp_dets => r_wp_dets
4655 ,p_curr_date => l_curr_date -- IN OUT
4656 ,p_balance_days => l_balance_days -- IN OUT
4657 ,p_table_id => p_table_id
4658 ,p_column_name => p_column_name
4659 ,p_value => p_value
4660 );
4661 END IF;
4662 --
4663 ELSE -- No default work pattern found, raise error and exit the loop.
4664 l_error_code := -1;
4665 l_err_msg_name := 'PQP_230589_NO_WORK_PATTERN';
4666 EXIT;
4667 END IF; -- l_calc_stdt between r_wp_dets.effective_start_date
4668 --
4669 END IF; -- if r_wp_dets.work_pattern is not null then
4670 -- Exit the loop if there are no more days to add
4671
4672 IF l_balance_days = 0
4673 THEN
4674 EXIT;
4675 END IF;
4676 --
4677 END LOOP; /* Get Work Pattern Details */
4678
4679 IF l_error_code = 0 -- No errors have occured
4680 AND ( -- No WP found on AAT
4681 NOT l_asg_wp_found
4682 OR -- not enough WP history on AAT so more days still to be added
4683 l_balance_days > 0
4684 )
4685 THEN
4686 IF p_default_wp IS NOT NULL
4687 THEN
4688 debug(l_proc_name, 60);
4689 debug('Asg WP NOT Found, default WP available');
4690 r_def_wp_dets := NULL;
4691 r_def_wp_dets.effective_start_date := l_curr_date;
4692 r_def_wp_dets.effective_end_date := hr_api.g_eot; -- End of Time
4693 r_def_wp_dets.business_group_id := p_business_group_id;
4694 r_def_wp_dets.work_pattern := p_default_wp;
4695 r_def_wp_dets.start_day :=
4696 'Day '
4697 || LPAD(
4698 TO_CHAR(8
4699 -(NEXT_DAY(l_curr_date, g_default_start_day) - l_curr_date))
4700 ,2
4701 ,'0'
4702 );
4703 debug('Start Day :' || r_def_wp_dets.start_day, 70);
4704 get_next_working_date_wp(
4705 p_business_group_id => p_business_group_id
4706 ,p_wp_dets => r_def_wp_dets
4707 ,p_curr_date => l_curr_date -- IN OUT
4708 ,p_balance_days => l_balance_days -- IN OUT
4709 ,p_table_id => p_table_id
4710 ,p_column_name => p_column_name
4711 ,p_value => p_value
4712 );
4713 ELSE
4714 l_error_code := -1;
4715 l_err_msg_name := 'PQP_230589_NO_WORK_PATTERN';
4716 END IF;
4717 --
4718 END IF; -- if NOT l_asg_wp_found the
4719
4720 -- If no errors hv occured and
4721 -- balance has not been zeroed yet, then raise an error.
4722
4723 IF l_error_code = 0 AND l_balance_days > 0
4724 THEN
4725 l_error_code := -2;
4726 l_err_msg_name := 'PQP_230590_WP_HIST_INCOMPLETE';
4727 END IF; -- l_error_code = 0 then
4728
4729 p_error_code := l_error_code;
4730
4731 --
4732 IF l_err_msg_name IS NOT NULL
4733 THEN
4734 p_error_message := fnd_message.get_string('PQP', l_err_msg_name);
4735 END IF;
4736 IF g_debug THEN
4737 debug('l_curr_date'|| to_char(l_curr_date));
4738 debug_exit(l_proc_name);
4739 END IF;
4740 RETURN l_curr_date;
4741
4742 EXCEPTION
4743 WHEN OTHERS THEN
4744 clear_cache;
4745 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
4746 debug_others(l_proc_name,l_proc_step);
4747 IF g_debug THEN
4748 debug('Leaving: '||l_proc_name,-999);
4749 END IF;
4750 fnd_message.raise_error;
4751 ELSE
4752 RAISE;
4753 END IF;
4754 END get_next_working_date;
4755
4756 -- pqp_get_omp_pl_extra_info Returns the value of the segment
4757 -- in Plan EIT. The Information Type is PQP_GB_OMP_ABSENCE_PLAN_INFO
4758 FUNCTION pqp_get_omp_pl_extra_info(
4759 p_pl_id IN NUMBER
4760 ,p_segment_name IN VARCHAR2
4761 ,p_value OUT NOCOPY VARCHAR2
4762 ,p_truncated_yes_no OUT NOCOPY VARCHAR2
4763 ,p_error_msg OUT NOCOPY VARCHAR2
4764 )
4765 RETURN NUMBER
4766 IS
4767 l_retval NUMBER;
4768 l_proc_step NUMBER(38,10):=0;
4769 l_proc_name VARCHAR2(61):=
4770 g_package_name||'pqp_get_omp_pl_extra_info';
4771 BEGIN
4772 IF g_debug THEN
4773 debug_enter(l_proc_name);
4774 debug('p_pl_id:'||p_pl_id);
4775 debug('p_segment_name:'||p_segment_name);
4776 END IF;
4777
4778 l_retval :=
4779 pqp_gb_osp_functions.pqp_get_plan_extra_info(
4780 p_pl_id => p_pl_id
4781 ,p_information_type => 'PQP_GB_OMP_ABSENCE_PLAN_INFO'
4782 ,p_segment_name => p_segment_name
4783 ,p_value => p_value
4784 ,p_truncated_yes_no => p_truncated_yes_no
4785 ,p_error_msg => p_error_msg
4786 );
4787 IF g_debug THEN
4788 debug('l_retval'|| to_char(l_retval));
4789 debug_exit(l_proc_name);
4790 END IF;
4791 RETURN l_retval;
4792
4793 EXCEPTION
4794 WHEN OTHERS THEN
4795 clear_cache;
4796 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
4797 debug_others(l_proc_name,l_proc_step);
4798 IF g_debug THEN
4799 debug('Leaving: '||l_proc_name,-999);
4800 END IF;
4801 fnd_message.raise_error;
4802 ELSE
4803 RAISE;
4804 END IF;
4805
4806 END pqp_get_omp_pl_extra_info;
4807
4808 -- pqp_get_omp_pl_extra_info Returns the value of the segment
4809 -- in Plan EIT. Plan Name is the Input.The Information Type is
4810 -- PQP_GB_OMP_ABSENCE_PLAN_INFO
4811 FUNCTION pqp_get_omp_oth_pl_extra_info(
4812 p_business_group_id IN NUMBER
4813 ,p_effective_date IN DATE
4814 ,p_pl_name IN VARCHAR2
4815 ,p_segment_name IN VARCHAR2
4816 ,p_value OUT NOCOPY VARCHAR2
4817 ,p_truncated_yes_no OUT NOCOPY VARCHAR2
4818 ,p_error_msg OUT NOCOPY VARCHAR2
4819 )
4820 RETURN NUMBER
4821 IS
4822 l_retval NUMBER;
4823 l_proc_step NUMBER(38,10):=0;
4824 l_proc_name VARCHAR2(61):=
4825 g_package_name||'pqp_get_omp_oth_pl_extra_info';
4826 BEGIN
4827 IF g_debug THEN
4828 debug_enter(l_proc_name);
4829 debug('p_business_group_id:'||p_business_group_id);
4830 debug('p_effective_date:'||p_effective_date);
4831 debug('p_pl_name:'||p_pl_name);
4832 debug('p_segment_name:'||p_segment_name);
4833 END IF;
4834 l_retval :=
4835 pqp_gb_osp_functions.pqp_get_other_plan_extra_info(
4836 p_business_group_id => p_business_group_id
4837 ,p_effective_date => p_effective_date
4838 ,p_pl_name => p_pl_name
4839 ,p_information_type => 'PQP_GB_OMP_ABSENCE_PLAN_INFO'
4840 ,p_segment_name => p_segment_name
4841 ,p_value => p_value
4842 ,p_truncated_yes_no => p_truncated_yes_no
4843 ,p_error_msg => p_error_msg
4844 );
4845 IF g_debug THEN
4846 debug('l_retval:'||l_retval);
4847 debug_exit(l_proc_name);
4848 END IF;
4849 RETURN l_retval;
4850
4851 EXCEPTION
4852 WHEN OTHERS THEN
4853 clear_cache;
4854 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
4855 debug_others(l_proc_name,l_proc_step);
4856 IF g_debug THEN
4857 debug('Leaving: '||l_proc_name,-999);
4858 END IF;
4859 fnd_message.raise_error;
4860 ELSE
4861 RAISE;
4862 END IF;
4863 END pqp_get_omp_oth_pl_extra_info;
4864 --
4865 --
4866 --
4867 -- ben_matrnty_details Returns the value of the column in table
4868 -- ssp_maternities. Input is title of the column in the absence form.
4869 -- The mapping of form title to the DB column is done in Lookup and the
4870 -- same is fetched by calling get_lookup_code function.
4871 -- assignment_id and effective Date are contexts.
4872 --
4873 --
4874 --
4875 FUNCTION ben_matrnty_details(
4876 p_assignment_id IN NUMBER
4877 ,p_effective_date IN DATE
4878 ,p_title IN VARCHAR2
4879 ,p_error_code OUT NOCOPY NUMBER
4880 ,p_message OUT NOCOPY VARCHAR2
4881 )
4882 RETURN VARCHAR2
4883 IS
4884 l_proc_step NUMBER(38,10):=0;
4885 l_proc_name VARCHAR2(61):=
4886 g_package_name||'ben_matrnty_details';
4887 l_absence_id per_absence_attendances.absence_attendance_id%TYPE;
4888 l_val VARCHAR2(2000);
4889 BEGIN
4890 IF g_debug THEN
4891 debug_enter(l_proc_name);
4892 debug('p_assignment_id:'||p_assignment_id);
4893 debug('p_effective_date:'||fnd_date.date_to_canonical(p_effective_date));
4894 debug('p_title:'||p_title);
4895 END IF;
4896 l_absence_id :=
4897 pqp_gb_osp_functions.ben_get_absence_id(
4898 p_assignment_id => p_assignment_id
4899 ,p_effective_date => p_effective_date
4900 );
4901 debug(l_proc_name, 20);
4902 l_val :=
4903 pqp_gb_osp_functions.get_matrnty_details(
4904 p_absence_attendance_id => l_absence_id
4905 ,p_title => p_title
4906 ,p_error_code => p_error_code
4907 ,p_message => p_message
4908 );
4909
4910 IF p_message IS NOT NULL
4911 THEN
4912 p_error_code := -1;
4913 debug(l_proc_name, 30);
4914 ELSE
4915 p_error_code := 0;
4916 debug(l_proc_name, 40);
4917 END IF;
4918
4919 IF g_debug THEN
4920 debug('l_val' || l_val);
4921 debug_exit(l_proc_name);
4922 END IF;
4923 RETURN l_val;
4924
4925
4926 EXCEPTION
4927 WHEN OTHERS THEN
4928 clear_cache;
4929 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
4930 debug_others(l_proc_name,l_proc_step);
4931 IF g_debug THEN
4932 debug('Leaving: '||l_proc_name,-999);
4933 END IF;
4934 fnd_message.raise_error;
4935 ELSE
4936 RAISE;
4937 END IF;
4938 END ben_matrnty_details;
4939
4940 -- ben_medical_details Returns the value of the column in table
4941 -- ssp_medicals. Inputs are absence_attendance_id and the title
4942 -- of the column in the absence form.The mapping of form title to the DB
4943 -- column is done in Lookup and the same is fetched by calling
4944 -- get_lookup_code function.
4945 FUNCTION ben_medical_details(
4946 p_assignment_id IN NUMBER
4947 ,p_effective_date IN DATE
4948 ,p_title IN VARCHAR2
4949 ,p_error_code OUT NOCOPY NUMBER
4950 ,p_message OUT NOCOPY VARCHAR2
4951 )
4952 RETURN VARCHAR2
4953 IS
4954 l_proc_step NUMBER(38,10):=0;
4955 l_proc_name VARCHAR2(61):=
4956 g_package_name||'ben_medical_details';
4957 l_absence_id per_absence_attendances.absence_attendance_id%TYPE;
4958 l_val VARCHAR2(2000);
4959 BEGIN
4960 IF g_debug THEN
4961 debug_enter(l_proc_name);
4962 debug('p_assignment_id:'||p_assignment_id);
4963 debug('p_effective_date:'||fnd_date.date_to_canonical(p_effective_date));
4964 debug('p_title:'||p_title);
4965
4966 END IF;
4967 l_absence_id :=
4968 pqp_gb_osp_functions.ben_get_absence_id(
4969 p_assignment_id => p_assignment_id
4970 ,p_effective_date => p_effective_date
4971 );
4972 debug(l_proc_name, 20);
4973 l_val :=
4974 pqp_gb_osp_functions.get_medical_details(
4975 p_absence_attendance_id => l_absence_id
4976 ,p_title => p_title
4977 ,p_error_code => p_error_code
4978 ,p_message => p_message
4979 );
4980
4981 IF p_message IS NOT NULL
4982 THEN
4983 p_error_code := -1;
4984 debug(l_proc_name, 30);
4985 ELSE
4986 p_error_code := 0;
4987 debug(l_proc_name, 40);
4988 END IF;
4989
4990 IF g_debug THEN
4991 debug('l_val:'||l_val);
4992 debug_exit(l_proc_name);
4993 END IF;
4994 RETURN l_val;
4995
4996 EXCEPTION
4997 WHEN OTHERS THEN
4998 clear_cache;
4999 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
5000 debug_others(l_proc_name,l_proc_step);
5001 IF g_debug THEN
5002 debug('Leaving: '||l_proc_name,-999);
5003 END IF;
5004 fnd_message.raise_error;
5005 ELSE
5006 RAISE;
5007 END IF;
5008 END ben_medical_details;
5009
5010 -- Function get_abs_plan_ent_days_info Returns the number of days
5011 -- the type of Entitlement is eligible. for example to find out in a absence
5012 -- period, for a attached Plan how many days are BAND1 Entitled days. This
5013 -- function returns that number.BAND1 is a input parameter.
5014 FUNCTION get_abs_plan_ent_days_info(
5015 p_absence_attendance_id IN NUMBER
5016 ,p_pl_id IN NUMBER
5017 ,p_error_code OUT NOCOPY NUMBER
5018 ,p_error_message OUT NOCOPY VARCHAR2
5019 ,p_search_start_date IN DATE
5020 ,p_search_end_date IN DATE
5021 ,p_level_of_entitlement IN VARCHAR2
5022 )
5023 RETURN NUMBER
5024 IS
5025 l_proc_step NUMBER(38,10):=0;
5026 l_proc_name VARCHAR2(61):=
5027 g_package_name||'get_abs_plan_ent_days_info';
5028 l_no_of_days NUMBER;
5029 l_csr_entitled_days_rec csr_entitled_days%ROWTYPE ;-----Added For Hours
5030
5031 BEGIN
5032 IF g_debug THEN
5033 debug_enter(l_proc_name);
5034 debug('p_absence_attendance_id:'||p_absence_attendance_id);
5035 debug('p_pl_id:'||p_pl_id);
5036 debug('p_search_start_date:'||fnd_date.date_to_canonical(p_search_start_date));
5037 debug('p_search_end_date:'||fnd_date.date_to_canonical(p_search_end_date));
5038 debug('p_level_of_entitlement' || p_level_of_entitlement);
5039 END IF;
5040 p_error_code := 0;
5041 debug('p_level_of_entitlement:'||p_level_of_entitlement);
5042 debug('p_search_start_date:'||p_search_start_date);
5043 debug('p_search_end_date:'||p_search_end_date);
5044
5045 -- Check the Start Date is earlier than or equal to End Date.
5046 IF NVL(p_search_start_date, SYSDATE) >
5047 NVL(p_search_end_date, hr_api.g_eot)
5048 THEN
5049 p_error_code := -1;
5050 fnd_message.set_name('PQP', 'PQP_230617_END_GE_START');
5051 --fnd_message.set_token('START'
5052 -- ,fnd_date.date_to_canonical(p_search_start_date));
5053 --fnd_message.set_token('END'
5054 -- ,fnd_date.date_to_canonical(p_search_end_date));
5055 p_error_message := fnd_message.get();
5056 RETURN NULL;
5057 END IF;
5058
5059 -- Open the Cursor to get total number of Entitled days for the qualifier.
5060 OPEN csr_entitled_days(
5061 p_absence_attendance_id => p_absence_attendance_id
5062 ,p_pl_id => p_pl_id
5063 ,p_search_start_date => p_search_start_date
5064 ,p_search_end_date => p_search_end_date
5065 ,p_level_of_entitlement => p_level_of_entitlement
5066 );
5067 FETCH csr_entitled_days INTO l_csr_entitled_days_rec ;
5068 -----Added For Hours --l_no_of_days;
5069 CLOSE csr_entitled_days;
5070
5071 l_no_of_days := l_csr_entitled_days_rec.days ;
5072 -----Added when the cursor is shared between days and hours
5073
5074 debug('l_no_of_days:'||l_no_of_days);
5075
5076 IF g_debug THEN
5077 debug('l_no_of_days:'||l_no_of_days);
5078 debug_exit(l_proc_name);
5079 END IF;
5080 RETURN l_no_of_days;
5081
5082 EXCEPTION
5083 WHEN OTHERS THEN
5084 clear_cache;
5085 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
5086 debug_others(l_proc_name,l_proc_step);
5087 IF g_debug THEN
5088 debug('Leaving: '||l_proc_name,-999);
5089 END IF;
5090 fnd_message.raise_error;
5091 ELSE
5092 RAISE;
5093 END IF;
5094 END get_abs_plan_ent_days_info;
5095
5096 -- Function get_abs_plan_paid_days_info Returns the number of days
5097 -- the type of Paid days is eligible. for example to find out in a absence
5098 -- period, for a attached Plan how many days are BAND1 Paid days. This
5099 -- function returns that number.BAND1 is a input parameter.
5100 FUNCTION get_abs_plan_paid_days_info(
5101 p_absence_attendance_id IN NUMBER
5102 ,p_pl_id IN NUMBER
5103 ,p_error_code OUT NOCOPY NUMBER
5104 ,p_error_message OUT NOCOPY VARCHAR2
5105 ,p_search_start_date IN DATE
5106 ,p_search_end_date IN DATE
5107 ,p_level_of_pay IN VARCHAR2
5108 )
5109 RETURN NUMBER
5110 IS
5111 l_proc_step NUMBER(38,10):=0;
5112 l_proc_name VARCHAR2(61):=
5113 g_package_name||'get_abs_plan_paid_days_info';
5114 l_no_of_days NUMBER;
5115 l_csr_paid_days_rec csr_paid_days%ROWTYPE ; -----Added For Hours
5116 BEGIN
5117 IF g_debug THEN
5118 debug_enter(l_proc_name);
5119 debug('p_absence_attendance_id:'||p_absence_attendance_id);
5120 debug('p_pl_id:'||p_pl_id);
5121 debug('p_search_start_date:'||fnd_date.date_to_canonical(p_search_start_date));
5122 debug('p_search_end_date:'||fnd_date.date_to_canonical(p_search_end_date));
5123 debug('p_level_of_pay'|| p_level_of_pay);
5124 END IF;
5125 p_error_code := 0;
5126
5127 -- Check the Start Date is earlier than or equal to End Date.
5128 IF NVL(p_search_start_date, SYSDATE) >
5129 NVL(p_search_end_date, hr_api.g_eot)
5130 THEN
5131 p_error_code := -1;
5132 fnd_message.set_name('PQP', 'PQP_230617_END_GE_START');
5133 --fnd_message.set_token('START'
5134 -- ,fnd_date.date_to_canonical(p_search_start_date));
5135 --fnd_message.set_token('END'
5136 -- ,fnd_date.date_to_canonical(p_search_end_date));
5137 p_error_message := fnd_message.get();
5138 RETURN NULL;
5139 END IF;
5140
5141 -- Open the Cursor to get total number of Paid days for the qualifier type.
5142 OPEN csr_paid_days(
5143 p_absence_attendance_id => p_absence_attendance_id
5144 ,p_pl_id => p_pl_id
5145 ,p_search_start_date => p_search_start_date
5146 ,p_search_end_date => p_search_end_date
5147 ,p_level_of_pay => p_level_of_pay
5148 );
5149 FETCH csr_paid_days INTO l_csr_paid_days_rec ;
5150 CLOSE csr_paid_days;
5151
5152 l_no_of_days := l_csr_paid_days_rec.days ; -----Added For Hours
5153
5154 IF g_debug THEN
5155 debug('l_no_of_days:'||l_no_of_days);
5156 debug_exit(l_proc_name);
5157 END IF;
5158 RETURN l_no_of_days;
5159
5160 EXCEPTION
5161 WHEN OTHERS THEN
5162 clear_cache;
5163 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
5164 debug_others(l_proc_name,l_proc_step);
5165 IF g_debug THEN
5166 debug('Leaving: '||l_proc_name,-999);
5167 END IF;
5168 fnd_message.raise_error;
5169 ELSE
5170 RAISE;
5171 END IF;
5172 END get_abs_plan_paid_days_info;
5173
5174 -- Function get_abs_plan_wp_info Returns the number of days
5175 -- the type of Work Pattern is eligible. for example to find out in a absence
5176 -- period, for a attached Plan how many days WORKON Pattern is eligible. This
5177 -- function returns that number.WORKON is a input parameter.
5178 FUNCTION get_abs_plan_wp_info(
5179 p_absence_attendance_id IN NUMBER
5180 ,p_pl_id IN NUMBER
5181 ,p_error_code OUT NOCOPY NUMBER
5182 ,p_error_message OUT NOCOPY VARCHAR2
5183 ,p_search_start_date IN DATE
5184 ,p_search_end_date IN DATE
5185 ,p_work_pattern_day_type IN VARCHAR2
5186 )
5187 RETURN NUMBER
5188 IS
5189 l_proc_step NUMBER(38,10):=0;
5190 l_proc_name VARCHAR2(61):=
5191 g_package_name||'get_abs_plan_wp_info';
5192 l_no_of_days NUMBER;
5193 BEGIN
5194 IF g_debug THEN
5195 debug_enter(l_proc_name);
5196 debug('p_absence_attendance_id:'||p_absence_attendance_id);
5197 debug('p_pl_id:'||p_pl_id);
5198 debug('p_search_start_date:'||fnd_date.date_to_canonical(p_search_start_date));
5199 debug('p_search_end_date:'||fnd_date.date_to_canonical(p_search_end_date));
5200 debug('p_work_pattern_day_type'||p_work_pattern_day_type);
5201 END IF;
5202 p_error_code := 0;
5203
5204 -- Check the Start Date is earlier than or equal to End Date.
5205 IF NVL(p_search_start_date, SYSDATE) >
5206 NVL(p_search_end_date, hr_api.g_eot)
5207 THEN
5208 p_error_code := -1;
5209 fnd_message.set_name('PQP', 'PQP_230617_END_GE_START');
5210 --fnd_message.set_token('START'
5211 -- ,fnd_date.date_to_canonical(p_search_start_date));
5212 --fnd_message.set_token('END'
5213 -- ,fnd_date.date_to_canonical(p_search_end_date));
5214 p_error_message := fnd_message.get();
5215 RETURN NULL;
5216 END IF;
5217
5218 -- Open the Cursor to get total number of Paid days for the qualifier type.
5219 OPEN csr_wp_days(
5220 p_absence_attendance_id => p_absence_attendance_id
5221 ,p_pl_id => p_pl_id
5222 ,p_search_start_date => p_search_start_date
5223 ,p_search_end_date => p_search_end_date
5224 ,p_work_pattern_day_type => p_work_pattern_day_type
5225 );
5226 FETCH csr_wp_days INTO l_no_of_days;
5227 CLOSE csr_wp_days;
5228 IF g_debug THEN
5229 debug('l_no_of_days:'||l_no_of_days);
5230 debug_exit(l_proc_name);
5231 END IF;
5232 RETURN l_no_of_days;
5233
5234 EXCEPTION
5235 WHEN OTHERS THEN
5236 clear_cache;
5237 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
5238 debug_others(l_proc_name,l_proc_step);
5239 IF g_debug THEN
5240 debug('Leaving: '||l_proc_name,-999);
5241 END IF;
5242 fnd_message.raise_error;
5243 ELSE
5244 RAISE;
5245 END IF;
5246 END get_abs_plan_wp_info;
5247
5248 -- The Function Returns the Entitlement Days and Paid Days for the Bands
5249 -- from BAND1 to BAND4 and NOBAND.
5250 FUNCTION get_osp_band_paid_entitlements(
5251 p_absence_attendance_id IN NUMBER
5252 ,p_pl_id IN NUMBER
5253 ,p_band1_entitled OUT NOCOPY NUMBER
5254 ,p_band1_paid OUT NOCOPY NUMBER
5255 ,p_band2_entitled OUT NOCOPY NUMBER
5256 ,p_band2_paid OUT NOCOPY NUMBER
5257 ,p_band3_entitled OUT NOCOPY NUMBER
5258 ,p_band3_paid OUT NOCOPY NUMBER
5259 ,p_band4_entitled OUT NOCOPY NUMBER
5260 ,p_band4_paid OUT NOCOPY NUMBER
5261 ,p_noband_entitled OUT NOCOPY NUMBER
5262 ,p_noband_paid OUT NOCOPY NUMBER
5263 ,p_error_code OUT NOCOPY NUMBER
5264 ,p_error_message OUT NOCOPY VARCHAR2
5265 ,p_search_start_date IN DATE
5266 ,p_search_end_date IN DATE
5267 )
5268 RETURN NUMBER
5269 IS
5270 l_proc_step NUMBER(38,10):=0;
5271 l_proc_name VARCHAR2(61):=
5272 g_package_name||'get_osp_band_entitlements';
5273 -- l_udt_column_name pay_user_columns.user_column_name%TYPE ;
5274 l_error_code NUMBER;
5275 BEGIN
5276
5277 IF g_debug THEN
5278 debug_enter(l_proc_name);
5279 debug('p_absence_attendance_id:'||p_absence_attendance_id);
5280 debug('p_pl_id:'||p_pl_id);
5281 debug('p_search_start_date:'||fnd_date.date_to_canonical(p_search_start_date));
5282 debug('p_search_end_date:'||fnd_date.date_to_canonical(p_search_end_date));
5283 END IF;
5284 -- Do the Search Start Date <= Search End Date Validation Here.
5285
5286 p_error_code := 0;
5287 -- With the above column name get entitlement days for BAND1.
5288 p_band1_entitled :=
5289 pqp_gb_osp_functions.get_abs_plan_ent_days_info(
5290 p_absence_attendance_id => p_absence_attendance_id
5291 ,p_pl_id => p_pl_id
5292 ,p_error_code => l_error_code
5293 ,p_error_message => p_error_message
5294 ,p_search_start_date => p_search_start_date
5295 ,p_search_end_date => p_search_end_date
5296 ,p_level_of_entitlement => 'BAND1'
5297 );
5298 -- With the above column name get Paid days for BAND1.
5299 p_band1_paid :=
5300 pqp_gb_osp_functions.get_abs_plan_paid_days_info(
5301 p_absence_attendance_id => p_absence_attendance_id
5302 ,p_pl_id => p_pl_id
5303 ,p_error_code => l_error_code
5304 ,p_error_message => p_error_message
5305 ,p_search_start_date => p_search_start_date
5306 ,p_search_end_date => p_search_end_date
5307 ,p_level_of_pay => 'BAND1'
5308 );
5309 -- Ended Calls for BAND1.
5310 -- With the above column name get entitlement days for BAND2.
5311 p_band2_entitled :=
5312 pqp_gb_osp_functions.get_abs_plan_ent_days_info(
5313 p_absence_attendance_id => p_absence_attendance_id
5314 ,p_pl_id => p_pl_id
5315 ,p_error_code => l_error_code
5316 ,p_error_message => p_error_message
5317 ,p_search_start_date => p_search_start_date
5318 ,p_search_end_date => p_search_end_date
5319 ,p_level_of_entitlement => 'BAND2'
5320 );
5321 -- With the above column name get Paid days for BAND2.
5322 p_band2_paid :=
5323 pqp_gb_osp_functions.get_abs_plan_paid_days_info(
5324 p_absence_attendance_id => p_absence_attendance_id
5325 ,p_pl_id => p_pl_id
5326 ,p_error_code => l_error_code
5327 ,p_error_message => p_error_message
5328 ,p_search_start_date => p_search_start_date
5329 ,p_search_end_date => p_search_end_date
5330 ,p_level_of_pay => 'BAND2'
5331 );
5332 -- Ended Calls for BAND2.
5333 -- With the above column name get entitlement days for BAND3.
5334 p_band3_entitled :=
5335 pqp_gb_osp_functions.get_abs_plan_ent_days_info(
5336 p_absence_attendance_id => p_absence_attendance_id
5337 ,p_pl_id => p_pl_id
5338 ,p_error_code => l_error_code
5339 ,p_error_message => p_error_message
5340 ,p_search_start_date => p_search_start_date
5341 ,p_search_end_date => p_search_end_date
5342 ,p_level_of_entitlement => 'BAND3'
5343 );
5344 -- With the above column name get Paid days for BAND2.
5345 p_band3_paid :=
5346 pqp_gb_osp_functions.get_abs_plan_paid_days_info(
5347 p_absence_attendance_id => p_absence_attendance_id
5348 ,p_pl_id => p_pl_id
5349 ,p_error_code => l_error_code
5350 ,p_error_message => p_error_message
5351 ,p_search_start_date => p_search_start_date
5352 ,p_search_end_date => p_search_end_date
5353 ,p_level_of_pay => 'BAND3'
5354 );
5355 -- Ended Calls for BAND3.
5356 -- With the above column name get entitlement days for BAND4.
5357 p_band4_entitled :=
5358 pqp_gb_osp_functions.get_abs_plan_ent_days_info(
5359 p_absence_attendance_id => p_absence_attendance_id
5360 ,p_pl_id => p_pl_id
5361 ,p_error_code => l_error_code
5362 ,p_error_message => p_error_message
5363 ,p_search_start_date => p_search_start_date
5364 ,p_search_end_date => p_search_end_date
5365 ,p_level_of_entitlement => 'BAND4'
5366 );
5367 -- With the above column name get Paid days for BAND2.
5368 p_band4_paid :=
5369 pqp_gb_osp_functions.get_abs_plan_paid_days_info(
5370 p_absence_attendance_id => p_absence_attendance_id
5371 ,p_pl_id => p_pl_id
5372 ,p_error_code => l_error_code
5373 ,p_error_message => p_error_message
5374 ,p_search_start_date => p_search_start_date
5375 ,p_search_end_date => p_search_end_date
5376 ,p_level_of_pay => 'BAND4'
5377 );
5378 -- Ended Calls for BAND4.
5379 -- With the above column name get entitlement days for NOBAND.
5380 p_noband_entitled :=
5381 pqp_gb_osp_functions.get_abs_plan_ent_days_info(
5382 p_absence_attendance_id => p_absence_attendance_id
5383 ,p_pl_id => p_pl_id
5384 ,p_error_code => l_error_code
5385 ,p_error_message => p_error_message
5386 ,p_search_start_date => p_search_start_date
5387 ,p_search_end_date => p_search_end_date
5388 ,p_level_of_entitlement => 'NOBAND'
5389 );
5390
5391 --We need to add up the rows with WAITINGDAY to p_noband_entitled for the
5392 --payroll calculation as WAITINGDAY is treated as NOBAND entitlement in payroll.
5393 p_noband_entitled := NVL(p_noband_entitled,0) +
5394 pqp_gb_osp_functions.get_abs_plan_ent_days_info(
5395 p_absence_attendance_id => p_absence_attendance_id
5396 ,p_pl_id => p_pl_id
5397 ,p_error_code => l_error_code
5398 ,p_error_message => p_error_message
5399 ,p_search_start_date => p_search_start_date
5400 ,p_search_end_date => p_search_end_date
5401 ,p_level_of_entitlement => 'WAITINGDAY'
5402 );
5403
5404
5405 -- With the above column name get Paid days for BAND2.
5406 p_noband_paid :=
5407 pqp_gb_osp_functions.get_abs_plan_paid_days_info(
5408 p_absence_attendance_id => p_absence_attendance_id
5409 ,p_pl_id => p_pl_id
5410 ,p_error_code => l_error_code
5411 ,p_error_message => p_error_message
5412 ,p_search_start_date => p_search_start_date
5413 ,p_search_end_date => p_search_end_date
5414 ,p_level_of_pay => 'NOBAND'
5415 );
5416 -- Ended Calls for NOBAND.
5417 debug_exit(l_proc_name);
5418 RETURN 0;
5419
5420
5421 EXCEPTION
5422 WHEN OTHERS THEN
5423 clear_cache;
5424 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
5425 debug_others(l_proc_name,l_proc_step);
5426 IF g_debug THEN
5427 debug('Leaving: '||l_proc_name,-999);
5428 END IF;
5429 fnd_message.raise_error;
5430 ELSE
5431 RAISE;
5432 END IF;
5433 END get_osp_band_paid_entitlements;
5434
5435 -- This function returns the column, row and the type declared as in the calendar.
5436 -- For example a date is defined as "Bank Holiday". Then if the date is passed as
5437 -- input this functions returns the column, row and value i.e.'Bank Holiday'.
5438 -- p_cal_value is the Value which effects the search in combination with p_filter parameter.
5439 -- p_filter parameter can have 4 possible values (AllMatch, ExactMatch, Except, AllExcept).
5440 --
5441 FUNCTION chk_calendar_occurance(
5442 p_date IN DATE
5443 ,p_calendar_table_id IN NUMBER
5444 ,p_calendar_rules_list IN VARCHAR2
5445 ,p_cal_rul_name OUT NOCOPY VARCHAR2
5446 ,p_cal_day_name OUT NOCOPY VARCHAR2
5447 ,p_cal_rule_value OUT NOCOPY VARCHAR2
5448 ,p_error_code OUT NOCOPY NUMBER
5449 ,p_error_message OUT NOCOPY VARCHAR2
5450 ,p_cal_value IN VARCHAR2
5451 ,p_filter IN VARCHAR2
5452 )
5453 RETURN NUMBER
5454 IS
5455 l_proc_step NUMBER(38,10):=0;
5456 l_proc_name VARCHAR2(61):=
5457 g_package_name||'chk_calendar_occurance';
5458 l_retval NUMBER := 0;
5459 BEGIN
5460 debug_enter(l_proc_name);
5461 p_error_code := 0;
5462 debug('p_date:' || fnd_date.date_to_canonical(p_date));
5463 debug(
5464 'p_calendar_table_id:'
5465 || fnd_number.number_to_canonical(p_calendar_table_id)
5466 );
5467 debug('p_calendar_rules_list:' || p_calendar_rules_list);
5468 debug('p_cal_value:' || p_cal_value);
5469 debug('p_filter:' || p_filter);
5470 OPEN csr_cal_occur(
5471 p_date => p_date
5472 ,p_table_id => p_calendar_table_id
5473 ,p_calendar_rules_list => p_calendar_rules_list
5474 ,p_filter_value => p_cal_value
5475 ,p_filter => p_filter
5476 );
5477 FETCH csr_cal_occur INTO p_cal_day_name, p_cal_rul_name, p_cal_rule_value;
5478
5479 IF csr_cal_occur%NOTFOUND
5480 THEN
5481 l_retval := -1;
5482 END IF;
5483
5484 CLOSE csr_cal_occur;
5485 debug('l_retval:' || fnd_number.number_to_canonical(l_retval));
5486 IF g_debug THEN
5487 debug('l_retval:'||l_retval);
5488 debug_exit(l_proc_name);
5489 END IF;
5490 RETURN l_retval;
5491
5492
5493 EXCEPTION
5494 WHEN OTHERS THEN
5495 clear_cache;
5496 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
5497 debug_others(l_proc_name,l_proc_step);
5498 IF g_debug THEN
5499 debug('Leaving: '||l_proc_name,-999);
5500 END IF;
5501 fnd_message.raise_error;
5502 ELSE
5503 RAISE;
5504 END IF;
5505 END chk_calendar_occurance;
5506
5507
5508 FUNCTION get_band_entitlement_balance(
5509 p_business_group_id IN NUMBER
5510 ,p_effective_date IN DATE
5511 ,p_assignment_id IN NUMBER
5512 ,p_pl_typ_id IN NUMBER
5513 ,p_scheme_calendar_type IN VARCHAR2
5514 ,p_scheme_calendar_duration IN VARCHAR2
5515 ,p_scheme_calendar_uom IN VARCHAR2
5516 ,p_scheme_start_date IN VARCHAR2
5517 ,p_scheme_overlap_rule IN VARCHAR2
5518 ,p_level_of_entitlement IN VARCHAR2
5519 ,p_error_code OUT NOCOPY NUMBER
5520 ,p_error_message OUT NOCOPY VARCHAR2
5521 ,p_days_hours IN VARCHAR2 DEFAULT 'DAYS'
5522 -- Added p_days_hours paramter for Hours solution
5523 -- It contains default DAYS. This paramter decides
5524 -- which value to return
5525 --Added for CS
5526 ,p_default_work_pattern IN VARCHAR2
5527 -- LG/PT
5528 ,p_plan_types_to_extend_period IN VARCHAR2 -- LG/PT
5529 ,p_entitlement_uom IN VARCHAR2 -- LG/PT
5530 ,p_absence_schedule_wp IN VARCHAR2 -- LG/PT
5531 ,p_track_part_timers IN VARCHAR2 -- LG/PT
5532 ,p_absence_start_date IN DATE DEFAULT NULL
5533 )
5534 RETURN NUMBER
5535 IS
5536 l_proc_step NUMBER(38,10):=0;
5537 l_proc_name VARCHAR2(61):=
5538 g_package_name||'get_band_entitlement_balance';
5539 l_entitlements pqp_absval_pkg.t_entitlements;
5540 -- dummy used only to ensure that all mandatory params
5541 -- to get_absences_taken_to_date are fulfilled
5542 -- note passing an empty entitlements table to
5543 -- get_absences_taken_to_date has no impact
5544 -- if you do pass it then the function ensures that
5545 -- any bands not used are set to 0.
5546
5547 l_absences_taken_to_date pqp_absval_pkg.t_entitlements;
5548 i BINARY_INTEGER;
5549 l_retval NUMBER(11, 5) := 0;
5550 -- Added for CS
5551 l_dualrolling_4_year BOOLEAN := FALSE ;
5552 l_working_days_in_week
5553 pqp_gap_daily_absences.working_days_per_week%TYPE ;
5554 l_standard_work_days_in_week
5555 pqp_gap_daily_absences.working_days_per_week%TYPE ;
5556
5557
5558 l_current_factor NUMBER ;
5559 l_ft_factor NUMBER ;
5560 l_working_days_per_week NUMBER ;
5561 l_fte NUMBER ;
5562 l_FT_absence_wp VARCHAR2(100);
5563 l_FT_working_wp VARCHAR2(100);
5564 l_assignment_wp VARCHAR2(100);
5565 l_is_full_timer BOOLEAN ;
5566 l_abs_precision VARCHAR2(10);
5567 l_absence_start_date DATE;
5568 l_is_assignmen_wp BOOLEAN;
5569
5570 BEGIN
5571
5572
5573 g_debug := hr_utility.debug_enabled;
5574
5575 IF p_absence_start_date IS NULL
5576 THEN
5577 l_absence_start_date := p_effective_date;
5578 ELSE
5579 l_absence_start_date := p_absence_start_date;
5580 END IF;
5581 IF g_debug THEN
5582 debug_enter(l_proc_name);
5583 debug('p_business_group_id:'||p_business_group_id);
5584 debug('p_effective_date:'||fnd_date.date_to_canonical(p_effective_date));
5585 debug('p_absence_start_date:'||fnd_date.date_to_canonical(l_absence_start_date));
5586 debug('p_assignment_id:'||p_assignment_id);
5587 debug('p_pl_typ_id:'||p_pl_typ_id);
5588 debug('p_scheme_calendar_type'||p_scheme_calendar_type);
5589 debug('p_scheme_calendar_duration'||p_scheme_calendar_duration);
5590 debug('p_scheme_calendar_uom'||p_scheme_calendar_uom);
5591 debug('p_scheme_start_date'||p_scheme_start_date);
5592 debug('p_scheme_overlap_rule'||p_scheme_overlap_rule);
5593 debug('p_level_of_entitlement'||p_level_of_entitlement);
5594 debug('p_days_hours'||p_days_hours);
5595 END IF;
5596 p_error_code := 0;
5597 l_proc_step := 10;
5598 -- check whether this is the first call for this assignment,
5599 -- plan and effective date
5600
5601 IF g_debug THEN
5602 debug('g_assignment_id');
5603 debug(g_assignment_id);
5604 debug('p_assignment_id');
5605 debug(p_assignment_id);
5606 debug('g_balance_date');
5607 debug(g_balance_date);
5608 debug('p_effective_date');
5609 debug(p_effective_date);
5610 debug('g_pl_typ_id');
5611 debug(g_pl_typ_id);
5612 END IF;
5613
5614 l_proc_step := 20;
5615
5616 l_abs_precision :=
5617 PQP_UTILITIES.pqp_get_config_value(
5618 p_business_group_id => p_business_group_id
5619 ,p_legislation_code => 'GB'
5620 ,p_column_name => 'PCV_INFORMATION7'
5621 ,p_information_category => 'PQP_GB_OSP_OMP_CONFIG'
5622 );
5623
5624 -- assign the rounding precision to global variable.
5625 -- if null then asssign rounding precision to be 5
5626 -- so by default absemces taken would be rounded to 5 places.
5627 g_abs_rounding_precision :=
5628 FND_NUMBER.canonical_to_number(NVL(l_abs_precision,5));
5629
5630 IF g_debug THEN
5631 debug('g_abs_rounding_precision');
5632 debug(g_abs_rounding_precision);
5633 END IF;
5634
5635
5636 IF g_assignment_id <> p_assignment_id
5637 OR g_pl_typ_id <> p_pl_typ_id
5638 OR g_balance_date <> p_effective_date
5639 -- Adding the remaining cache criterias as there is probability of
5640 -- scheme attributes changing for the same assignment, pl_typ and
5641 -- effective_date . Eg: in Civil Service, assignment_id, pl_typ_id,
5642 -- balance_date remains the same but scheme duration changes.
5643 OR g_scheme_calendar_type <> p_scheme_calendar_type
5644 OR g_scheme_calendar_duration <> p_scheme_calendar_duration
5645 OR g_scheme_calendar_uom <> p_scheme_calendar_uom
5646 OR g_scheme_start_date_txt <> p_scheme_start_date
5647 THEN
5648 -- Added for CS
5649
5650 l_proc_step := 25;
5651 IF g_debug THEN
5652 debug(l_proc_name,l_proc_step);
5653 END IF;
5654
5655 IF p_days_hours = 'WEEKS' THEN -- CSDAYS is changed to WEEKS
5656 l_dualrolling_4_year := TRUE ;
5657 END IF ;
5658
5659
5660 -- Idealy get_absences_taken_to_dates should return absences
5661 -- taken to date in terms of current work pattern.
5662 -- If the l_entitlement being passed is empty, then the
5663 -- absences taken to date returned, is the total absences taken to date
5664 -- irrespective of the work patterns enrolled during the period of
5665 -- absence.To get the absences in terms of the current work pattern
5666 -- we need to multiply it with the l_working_days_per_week factor
5667 -- returned by the get_factors call.
5668
5669 pqp_absval_pkg.get_absences_taken_to_date(
5670 p_assignment_id => p_assignment_id
5671 ,p_business_group_id => p_business_group_id
5672 ,p_effective_date => p_effective_date
5673 ,p_pl_typ_id => p_pl_typ_id
5674 ,p_scheme_period_overlap_rule => p_scheme_overlap_rule
5675 ,p_scheme_period_type => p_scheme_calendar_type
5676 ,p_scheme_period_duration => p_scheme_calendar_duration
5677 ,p_scheme_period_uom => p_scheme_calendar_uom
5678 ,p_scheme_period_start => p_scheme_start_date
5679 ,p_entitlements => l_entitlements
5680 ,p_absences_taken_to_date => l_absences_taken_to_date
5681 ,p_dualrolling_4_year => l_dualrolling_4_year
5682 ,p_plan_types_to_extend_period => p_plan_types_to_extend_period
5683 ,p_entitlement_uom => p_entitlement_uom
5684 ,p_default_wp => p_default_work_pattern
5685 ,p_absence_schedule_wp => p_absence_schedule_wp
5686 ,p_track_part_timers => p_track_part_timers
5687 ,p_absence_start_date => l_absence_start_date
5688 );
5689
5690 l_proc_step := 30;
5691 IF g_debug THEN
5692 debug(l_proc_name,l_proc_step);
5693 END IF;
5694
5695 g_assignment_id := p_assignment_id;
5696 g_pl_typ_id := p_pl_typ_id;
5697 g_balance_date := p_effective_date;
5698 g_scheme_calendar_type := p_scheme_calendar_type ;
5699 g_scheme_calendar_duration := p_scheme_calendar_duration ;
5700 g_scheme_calendar_uom := p_scheme_calendar_uom ;
5701 g_scheme_start_date_txt := p_scheme_start_date;
5702 g_absences_taken_to_date := l_absences_taken_to_date;
5703
5704 l_proc_step := 35;
5705 IF g_debug THEN
5706 debug(l_proc_name,l_proc_step);
5707 END IF;
5708
5709 END IF;
5710
5711
5712 l_proc_step := 40;
5713 IF g_debug THEN
5714 debug(l_proc_name,l_proc_step);
5715 END IF;
5716
5717 i := g_absences_taken_to_date.FIRST;
5718
5719 WHILE i IS NOT NULL
5720 LOOP
5721
5722 l_proc_step := 45+i/10000;
5723 IF g_debug THEN
5724 debug(l_proc_name,45+i/10000);
5725 END IF;
5726
5727
5728 IF g_absences_taken_to_date(i).band = p_level_of_entitlement
5729 THEN
5730
5731 l_proc_step := 47+i/10000;
5732 IF g_debug THEN
5733 debug(l_proc_name, 47+i/10000);
5734 END IF;
5735 -- l_retval := g_absences_taken_to_date(i).entitlement;
5736 -- i := NULL;
5737
5738 --Added to get the current work-pattern and fte
5739 pqp_absval_pkg.get_factors (
5740 p_business_group_id => p_business_group_id
5741 ,p_effective_date => p_effective_date
5742 ,p_assignment_id => p_assignment_id
5743 ,p_entitlement_uom => p_entitlement_uom
5744 ,p_default_wp => p_default_work_pattern
5745 ,p_absence_schedule_wp => p_absence_schedule_wp
5746 ,p_track_part_timers => p_track_part_timers
5747 ,p_current_factor => l_current_factor
5748 ,p_ft_factor => l_ft_factor
5749 ,p_working_days_per_week => l_working_days_per_week
5750 ,p_fte => l_fte
5751 ,p_FT_absence_wp => l_FT_absence_wp
5752 ,p_FT_working_wp => l_FT_working_wp
5753 ,p_assignment_wp => l_assignment_wp
5754 ,p_is_full_timer => l_is_full_timer
5755 ,p_is_assignment_wp => l_is_assignmen_wp
5756 ) ;
5757
5758 -- Added the below IF for Hours solution
5759
5760 IF p_days_hours = 'DAYS' THEN -- Enters this block for LG
5761
5762 l_proc_step := 50+i/10000;
5763 IF g_debug THEN
5764 debug(l_proc_name, 50+i/10000);
5765 END IF;
5766
5767 -- Added for converting the absences taken to date
5768 -- to absences taken in terms of current work pattern.
5769
5770 IF NVL(p_track_part_timers,'N') = 'Y' THEN
5771 l_retval := g_absences_taken_to_date(i).duration_per_week *
5772 l_working_days_per_week ;
5773 ELSE
5774 l_retval := g_absences_taken_to_date(i).duration ;
5775 END IF;
5776
5777 l_retval :=pqp_utilities.round_value_up_down
5778 ( p_value_to_round => l_retval
5779 ,p_base_value => g_abs_rounding_precision
5780 ,p_rounding_type => g_abs_rounding_type
5781 ) ;
5782
5783
5784 ELSIF p_days_hours = 'HOURS' THEN
5785
5786 l_proc_step := 52+i/10000;
5787 IF g_debug THEN
5788 debug(l_proc_name, 52+i/10000);
5789 END IF;
5790
5791 IF NVL(p_track_part_timers,'N') = 'Y' THEN
5792 l_retval := g_absences_taken_to_date(i).duration_in_hours*l_fte ;
5793 ELSE
5794 l_retval := g_absences_taken_to_date(i).duration_in_hours;
5795 END IF;
5796
5797 l_retval :=pqp_utilities.round_value_up_down
5798 ( p_value_to_round => l_retval
5799 ,p_base_value => g_abs_rounding_precision
5800 ,p_rounding_type => g_abs_rounding_type
5801 ) ;
5802
5803
5804 -- Added for CS
5805 ELSIF p_days_hours = 'WEEKS' THEN -- CSDAYS is changed to WEEKS
5806
5807 l_proc_step := 55+i/10000;
5808 IF g_debug THEN
5809 debug(l_proc_name, 55+i/10000);
5810 END IF;
5811
5812 -- this gets executed when called for CS
5813 -- get the number of working days per week.
5814 -- IF the person is a Full timer there may not be any assignment
5815 -- level work pattern. so pass a default work pattern
5816 -- the standard work pattern call is required as we have
5817 -- to compare to know if the person is Full timer or part timer
5818
5819 l_working_days_in_week :=
5820 pqp_schedule_calculation_pkg.get_working_days_in_week
5821 (
5822 p_assignment_id => p_assignment_id
5823 ,p_business_group_id => p_business_group_id
5824 ,p_effective_date => p_effective_date
5825 ,p_default_wp => p_default_work_pattern
5826 ) ;
5827 -- Default Work Pattern is passed as Over Ride Work Pattern
5828 -- because we want the days in standard work pattern but not
5829 -- at assignment level.
5830 -- if we pass that as p_default_wp the function returns the
5831 -- number of days at assignment level work pattern if
5832 -- there is any
5833
5834 l_proc_step := 57+i/10000;
5835 IF g_debug THEN
5836 debug(l_proc_name, 57+i/10000);
5837 END IF;
5838
5839 l_standard_work_days_in_week :=
5840 pqp_schedule_calculation_pkg.get_working_days_in_week
5841 (
5842 p_assignment_id => p_assignment_id
5843 ,p_business_group_id => p_business_group_id
5844 ,p_effective_date => p_effective_date
5845 ,p_override_wp => p_default_work_pattern
5846 ) ;
5847
5848 l_proc_step := 59+i/10000;
5849 IF g_debug THEN
5850 debug(l_proc_name, 59+i/10000);
5851 END IF;
5852
5853
5854 IF NVL(l_working_days_in_week,l_standard_work_days_in_week) >=
5855 l_standard_work_days_in_week THEN
5856 l_working_days_in_week := 7 ;
5857 END IF;
5858
5859 l_proc_step := 60+i/10000;
5860 IF g_debug THEN
5861 debug(l_proc_name, 60+i/10000);
5862 END IF;
5863
5864 -- Multiply with working_days_per_week
5865 l_retval := g_absences_taken_to_date(i).duration_per_week *
5866 l_working_days_in_week ;
5867 -- l_retval := ROUND(l_retval,2) ;
5868 -- PT Changes cchappid
5869 -- For Full timers round to lower 0.5
5870 -- For Part-timers round it to upper 0.5
5871 -- 4.4 for FT = 4. or 4.6 = 4.5
5872 -- 4.4 for a PT = 4.5 or 4.6 = 5
5873 -- NVL is just to ensure that it wont fail if there is no
5874 -- DEFAULT work Pattern at Scheme level
5875
5876 l_retval :=pqp_utilities.round_value_up_down
5877 ( p_value_to_round => l_retval
5878 ,p_base_value => g_abs_rounding_precision
5879 ,p_rounding_type => g_abs_rounding_type
5880 ) ;
5881
5882
5883 END IF;
5884
5885 i := NULL ;
5886
5887 ELSE
5888 l_proc_step := 70+i/10000;
5889 IF g_debug THEN
5890 debug(l_proc_name, 70+i/10000);
5891 END IF;
5892 i := g_absences_taken_to_date.NEXT(i);
5893 END IF;
5894 END LOOP;
5895
5896 l_proc_step := 75;
5897 IF g_debug THEN
5898 debug('l_retval:'||l_retval);
5899 END IF;
5900
5901 IF g_debug THEN
5902 debug('l_retval:'||l_retval);
5903 debug_exit(l_proc_name);
5904 END IF;
5905 RETURN l_retval;
5906
5907 EXCEPTION
5908 WHEN OTHERS THEN
5909 clear_cache;
5910 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
5911 debug_others(l_proc_name,l_proc_step);
5912 IF g_debug THEN
5913 debug('Leaving: '||l_proc_name,-999);
5914 END IF;
5915 fnd_message.raise_error;
5916 ELSE
5917 RAISE;
5918 END IF;
5919 END get_band_entitlement_balance;
5920
5921 -- This Function gets the scheme Details based on element_type_id available as context
5922 FUNCTION get_band_ent_bal_by_ele_typ_id(
5923 p_business_group_id IN NUMBER
5924 ,p_assignment_id IN NUMBER
5925 ,p_element_type_id IN NUMBER
5926 ,p_effective_date IN DATE
5927 ,p_level_of_entitlement IN VARCHAR2
5928 ,p_error_code OUT NOCOPY NUMBER
5929 ,p_error_message OUT NOCOPY VARCHAR2
5930 ,p_days_hours IN VARCHAR2 DEFAULT 'DAYS'
5931 ,p_absence_start_date IN DATE DEFAULT NULL
5932 )
5933 RETURN NUMBER
5934 IS
5935 l_proc_step NUMBER(38,10):=0;
5936 l_proc_name VARCHAR2(61):=
5937 g_package_name||'get_band_ent_bal_by_ele_typ_id';
5938 l_retval NUMBER;
5939 -- Added for CS
5940
5941 l_scheme_duration pay_element_type_extra_info.eei_information20%TYPE ;
5942 l_scheme_uom pay_element_type_extra_info.eei_information21%TYPE ;
5943 l_days_hours VARCHAR2(30) := p_days_hours ;
5944 --
5945 CURSOR csr_osp_scheme_det(
5946 p_element_type_id IN NUMBER
5947 ,p_effective_date IN DATE
5948 )
5949 IS
5950 SELECT pln.pl_typ_id
5951 ,eei.eei_information3 cal_type
5952 ,eei.eei_information4 cal_duration
5953 ,eei.eei_information5 cal_uom
5954 ,eei.eei_information6 start_date
5955 ,eei.eei_information26 overlap_rul
5956 -- Added for CS
5957 ,eei.eei_information20 dualrolling_dur
5958 ,eei.eei_information21 dualrolling_uom
5959 ,eei.eei_information17 default_work_pattern
5960 -- Added for LG/PT
5961 ,eei.eei_information22 track_part_timers
5962 ,eei.eei_information8 entitlement_uom
5963 ,eei.eei_information23 absence_schedule_wp
5964 ,eei.eei_information24 plan_types_to_extend_period
5965 FROM pay_element_type_extra_info eei
5966 ,ben_pl_f pln
5967 WHERE eei.element_type_id = p_element_type_id
5968 --AND eei.information_type = 'PQP_GB_OSP_ABSENCE_PLAN_INFO' -- is indexed
5969 AND UPPER(eei.eei_information19) = 'ABSENCE INFO'
5970 AND pln.pl_id = fnd_number.canonical_to_number(eei.eei_information1)
5971 AND p_effective_date BETWEEN pln.effective_start_date
5972 AND pln.effective_end_date;
5973
5974 l_scheme_det csr_osp_scheme_det%ROWTYPE;
5975 l_absence_start_date DATE;
5976 BEGIN
5977
5978 IF p_absence_start_date IS NULL
5979 THEN
5980 l_absence_start_date := p_effective_date;
5981 ELSE
5982 l_absence_start_date := p_absence_start_date;
5983 END IF;
5984
5985 IF g_debug THEN
5986 debug_enter(l_proc_name);
5987 debug('p_business_group_id:'||p_business_group_id);
5988 debug('p_assignment_id:'||p_assignment_id);
5989 debug('p_element_type_id:'||p_element_type_id);
5990 debug('p_effective_date:'||fnd_date.date_to_canonical(p_effective_date));
5991 debug('p_absence_start_date:'||fnd_date.date_to_canonical(l_absence_start_date));
5992 debug('p_level_of_entitlement'||p_level_of_entitlement);
5993 debug('p_days_hours'||p_days_hours);
5994
5995 END IF;
5996 OPEN csr_osp_scheme_det(
5997 p_element_type_id => p_element_type_id
5998 ,p_effective_date => p_effective_date
5999 );
6000 FETCH csr_osp_scheme_det INTO l_scheme_det;
6001 CLOSE csr_osp_scheme_det;
6002
6003 -- Added for CS
6004 l_scheme_duration := l_scheme_det.cal_duration ;
6005 l_scheme_uom := l_scheme_det.cal_uom ;
6006
6007 -- This control enters into this IF only
6008 -- when this is called from 4-Years Function
6009 -- changing the scheme duration and uom to refer to 4-years
6010 -- segments.
6011 IF l_scheme_det.cal_type = 'DUALROLLING' AND p_days_hours='WEEKS' THEN
6012 l_scheme_duration := l_scheme_det.dualrolling_dur ;
6013 l_scheme_uom := l_scheme_det.dualrolling_uom ;
6014 END IF;
6015
6016 -- setting the p_days_hours to WEEKS
6017 -- for 4-year call p_days_hours is already WEEKS
6018 -- But the below IF is requried for 1-Year call
6019 -- the reason being in the function we are returning the
6020 -- BANd Days based on work pattern when p_days_hours = 'WEEKS'
6021 -- this is requried whether it is 4-year or 1-year.
6022
6023 IF l_scheme_det.cal_type = 'DUALROLLING' THEN
6024 l_days_hours := 'WEEKS' ;
6025 END IF ;
6026 --
6027 -- Call get_band_entitlement_balance to get the entitlements.
6028 l_retval :=
6029 pqp_gb_osp_functions.get_band_entitlement_balance(
6030 p_business_group_id => p_business_group_id
6031 ,p_effective_date => p_effective_date
6032 ,p_assignment_id => p_assignment_id
6033 ,p_pl_typ_id => l_scheme_det.pl_typ_id
6034 ,p_scheme_calendar_type => l_scheme_det.cal_type
6035 ,p_scheme_calendar_duration => l_scheme_duration
6036 ,p_scheme_calendar_uom => l_scheme_uom
6037 ,p_scheme_start_date => l_scheme_det.start_date
6038 ,p_scheme_overlap_rule => l_scheme_det.overlap_rul
6039 ,p_level_of_entitlement => p_level_of_entitlement
6040 ,p_error_code => p_error_code
6041 ,p_error_message => p_error_message
6042 ,p_days_hours => l_days_hours
6043 ,p_default_work_pattern => l_scheme_det.default_work_pattern
6044 ,p_plan_types_to_extend_period => l_scheme_det.plan_types_to_extend_period
6045 ,p_entitlement_uom => l_scheme_det.entitlement_uom
6046 ,p_absence_schedule_wp => l_scheme_det.absence_schedule_wp
6047 ,p_track_part_timers => l_scheme_det.track_part_timers
6048 ,p_absence_start_date => l_absence_start_date
6049 );
6050
6051 IF g_debug THEN
6052 debug('l_retval:'||l_retval);
6053 debug_exit(l_proc_name);
6054 END IF;
6055 RETURN l_retval;
6056
6057 EXCEPTION
6058 WHEN OTHERS THEN
6059 clear_cache;
6060 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
6061 debug_others(l_proc_name,l_proc_step);
6062 IF g_debug THEN
6063 debug('Leaving: '||l_proc_name,-999);
6064 END IF;
6065 fnd_message.raise_error;
6066 ELSE
6067 RAISE;
6068 END IF;
6069 END get_band_ent_bal_by_ele_typ_id;
6070
6071 -- This Function gets the scheme Details based on element_type_id available as context
6072 -- and gets the entitlement balance for all bands at one go
6073 FUNCTION get_all_band_ent_balance(
6074 p_business_group_id IN NUMBER
6075 ,p_assignment_id IN NUMBER
6076 ,p_element_type_id IN NUMBER
6077 ,p_effective_date IN DATE
6078 ,p_band1_ent_bal OUT NOCOPY NUMBER
6079 ,p_band2_ent_bal OUT NOCOPY NUMBER
6080 ,p_band3_ent_bal OUT NOCOPY NUMBER
6081 ,p_band4_ent_bal OUT NOCOPY NUMBER
6082 ,p_noband_ent_bal OUT NOCOPY NUMBER
6083 ,p_error_code OUT NOCOPY NUMBER
6084 ,p_error_message OUT NOCOPY VARCHAR2
6085 ,p_absence_start_date IN DATE DEFAULT NULL
6086 )
6087 RETURN NUMBER
6088 IS
6089 l_proc_step NUMBER(38,10):=0;
6090 l_proc_name VARCHAR2(61):=
6091 g_package_name||'get_all_band_ent_balance';
6092 l_retval NUMBER;
6093 l_absence_start_date DATE;
6094 BEGIN
6095
6096
6097 IF p_absence_start_date IS NULL
6098 THEN
6099 l_absence_start_date := p_effective_date;
6100 ELSE
6101 l_absence_start_date := p_absence_start_date;
6102 END IF;
6103
6104 IF g_debug THEN
6105 debug_enter(l_proc_name);
6106 debug('p_business_group_id:'||p_business_group_id);
6107 debug('p_assignment_id:'||p_assignment_id);
6108 debug('p_element_type_id:'||p_element_type_id);
6109 debug('p_effective_date'||fnd_date.date_to_canonical(p_effective_date));
6110 debug('p_absence_start_date'||fnd_date.date_to_canonical(l_absence_start_date));
6111 END IF;
6112 p_band1_ent_bal :=
6113 get_band_ent_bal_by_ele_typ_id(
6114 p_business_group_id => p_business_group_id
6115 ,p_effective_date => p_effective_date
6116 ,p_assignment_id => p_assignment_id
6117 ,p_element_type_id => p_element_type_id
6118 ,p_level_of_entitlement => 'BAND1'
6119 ,p_error_code => p_error_code
6120 ,p_error_message => p_error_message
6121 ,p_absence_start_date => l_absence_start_date
6122 );
6123
6124 IF p_error_code = -1
6125 THEN
6126 RETURN -1;
6127 END IF; -- End if of check for error code ...
6128
6129 p_band2_ent_bal :=
6130 get_band_ent_bal_by_ele_typ_id(
6131 p_business_group_id => p_business_group_id
6132 ,p_effective_date => p_effective_date
6133 ,p_assignment_id => p_assignment_id
6134 ,p_element_type_id => p_element_type_id
6135 ,p_level_of_entitlement => 'BAND2'
6136 ,p_error_code => p_error_code
6137 ,p_error_message => p_error_message
6138 ,p_absence_start_date => l_absence_start_date
6139 );
6140
6141 IF p_error_code = -1
6142 THEN
6143 RETURN -1;
6144 END IF; -- End if of check for error code ...
6145
6146 p_band3_ent_bal :=
6147 get_band_ent_bal_by_ele_typ_id(
6148 p_business_group_id => p_business_group_id
6149 ,p_effective_date => p_effective_date
6150 ,p_assignment_id => p_assignment_id
6151 ,p_element_type_id => p_element_type_id
6152 ,p_level_of_entitlement => 'BAND3'
6153 ,p_error_code => p_error_code
6154 ,p_error_message => p_error_message
6155 ,p_absence_start_date => l_absence_start_date
6156 );
6157
6158 IF p_error_code = -1
6159 THEN
6160 RETURN -1;
6161 END IF; -- End if of check for error code ...
6162
6163 p_band4_ent_bal :=
6164 get_band_ent_bal_by_ele_typ_id(
6165 p_business_group_id => p_business_group_id
6166 ,p_effective_date => p_effective_date
6167 ,p_assignment_id => p_assignment_id
6168 ,p_element_type_id => p_element_type_id
6169 ,p_level_of_entitlement => 'BAND4'
6170 ,p_error_code => p_error_code
6171 ,p_error_message => p_error_message
6172 ,p_absence_start_date => l_absence_start_date
6173 );
6174
6175 IF p_error_code = -1
6176 THEN
6177 RETURN -1;
6178 END IF; -- End if of check for error code ...
6179
6180 p_noband_ent_bal :=
6181 get_band_ent_bal_by_ele_typ_id(
6182 p_business_group_id => p_business_group_id
6183 ,p_effective_date => p_effective_date
6184 ,p_assignment_id => p_assignment_id
6185 ,p_element_type_id => p_element_type_id
6186 ,p_level_of_entitlement => 'NOBAND'
6187 ,p_error_code => p_error_code
6188 ,p_error_message => p_error_message
6189 ,p_absence_start_date => l_absence_start_date
6190 );
6191
6192 IF p_error_code = -1
6193 THEN
6194 RETURN -1;
6195 END IF; -- End if of check for error code ...
6196
6197 debug_exit(l_proc_name);
6198 RETURN 0;
6199
6200 EXCEPTION
6201 WHEN OTHERS THEN
6202 clear_cache;
6203 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
6204 debug_others(l_proc_name,l_proc_step);
6205 IF g_debug THEN
6206 debug('Leaving: '||l_proc_name,-999);
6207 END IF;
6208 fnd_message.raise_error;
6209 ELSE
6210 RAISE;
6211 END IF;
6212 END get_all_band_ent_balance;
6213
6214 --
6215
6216 FUNCTION get_band_ent_bal_by_pl_id( -- needs to be extended for omp
6217 p_business_group_id IN NUMBER
6218 ,p_assignment_id IN NUMBER
6219 ,p_pl_id IN NUMBER
6220 ,p_effective_date IN DATE
6221 ,p_level_of_entitlement IN VARCHAR2
6222 ,p_error_code OUT NOCOPY NUMBER
6223 ,p_error_message OUT NOCOPY VARCHAR2
6224 )
6225 RETURN NUMBER
6226 IS
6227 l_proc_step NUMBER(38,10):=0;
6228 l_proc_name VARCHAR2(61):=
6229 g_package_name||'get_band_ent_bal_by_pl_id';
6230 l_retval NUMBER;
6231 l_ele_typ_id NUMBER;
6232
6233 CURSOR csr_get_element_type_id(p_pl_id IN NUMBER)
6234 IS
6235 SELECT eei.element_type_id
6236 FROM pay_element_type_extra_info eei
6237 WHERE eei.information_type = 'PQP_GB_OSP_ABSENCE_PLAN_INFO'
6238 -- needs to be extended for omp
6239 AND eei.eei_information1 = fnd_number.number_to_canonical(p_pl_id)
6240 AND UPPER(eei.eei_information19) = 'ABSENCE INFO';
6241 BEGIN
6242 IF g_debug THEN
6243 debug_enter(l_proc_name);
6244 debug('p_business_group_id:'||p_business_group_id);
6245 debug('p_assignment_id:'||p_assignment_id);
6246 debug('p_pl_id:'||p_pl_id);
6247 debug('p_effective_date:'||fnd_date.date_to_canonical(p_effective_date));
6248 debug('p_level_of_entitlement'||p_level_of_entitlement);
6249
6250 END IF;
6251 OPEN csr_get_element_type_id(p_pl_id => p_pl_id);
6252 FETCH csr_get_element_type_id INTO l_ele_typ_id;
6253 CLOSE csr_get_element_type_id;
6254 l_retval :=
6255 get_band_ent_bal_by_ele_typ_id(
6256 p_business_group_id => p_business_group_id
6257 ,p_effective_date => p_effective_date
6258 ,p_assignment_id => p_assignment_id
6259 ,p_element_type_id => l_ele_typ_id
6260 ,p_level_of_entitlement => p_level_of_entitlement
6261 ,p_error_code => p_error_code
6262 ,p_error_message => p_error_message
6263 );
6264 IF g_debug THEN
6265 debug('l_retval:'||l_retval);
6266 debug_exit(l_proc_name);
6267 END IF;
6268 RETURN l_retval;
6269
6270 EXCEPTION
6271 WHEN OTHERS THEN
6272 clear_cache;
6273 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
6274 debug_others(l_proc_name,l_proc_step);
6275 IF g_debug THEN
6276 debug('Leaving: '||l_proc_name,-999);
6277 END IF;
6278 fnd_message.raise_error;
6279 ELSE
6280 RAISE;
6281 END IF;
6282 END get_band_ent_bal_by_pl_id;
6283
6284 --Function added by sshetty
6285 --This function returns value for the level of pay passed.
6286
6287 FUNCTION get_paid_days_duration(
6288 p_assignment_id IN NUMBER
6289 ,p_business_group_id IN NUMBER
6290 ,p_effective_date IN DATE
6291 ,p_pl_id IN NUMBER
6292 ,p_level_of_pay IN VARCHAR2
6293 ,p_search_start_date IN DATE
6294 ,p_search_end_date IN DATE
6295 ,p_error_code OUT NOCOPY NUMBER
6296 ,p_message OUT NOCOPY VARCHAR2
6297 )
6298 RETURN NUMBER
6299 IS
6300 l_error_message VARCHAR2(100);
6301 l_error_code NUMBER;
6302 l_balance pqp_gap_daily_absences.DURATION%TYPE;
6303 l_proc_step NUMBER(38,10):=0;
6304 l_proc_name VARCHAR2(61):=
6305 g_package_name||'get_paid_days_duration';
6306 BEGIN
6307 IF g_debug THEN
6308 debug_enter(l_proc_name);
6309 debug('p_assignment_id:'||p_assignment_id);
6310 debug('p_business_group_id:'||p_business_group_id);
6311 debug('p_effective_date'||p_effective_date);
6312 debug('p_pl_id:'||p_pl_id);
6313 debug('p_level_of_pay'||p_level_of_pay);
6314 debug('p_search_start_date:'||fnd_date.date_to_canonical(p_search_start_date));
6315 debug('p_search_end_date:'||fnd_date.date_to_canonical(p_search_end_date));
6316 END IF;
6317 OPEN csr_get_level_pay(
6318 p_assignment_id
6319 ,p_business_group_id
6320 ,p_search_start_date
6321 ,p_search_end_date
6322 ,p_level_of_pay
6323 );
6324 FETCH csr_get_level_pay INTO l_balance;
6325 CLOSE csr_get_level_pay;
6326 IF g_debug THEN
6327 debug_exit(l_proc_name);
6328 END IF;
6329 RETURN(l_balance);
6330
6331 EXCEPTION
6332 WHEN OTHERS THEN
6333 clear_cache;
6334 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
6335 debug_others(l_proc_name,l_proc_step);
6336 IF g_debug THEN
6337 debug('Leaving: '||l_proc_name,-999);
6338 END IF;
6339 fnd_message.raise_error;
6340 ELSE
6341 RAISE;
6342 END IF;
6343 END get_paid_days_duration;
6344
6345 -- Function get_entitled_days_duration Returns the No of Entitlements used up
6346 -- in the given date range.
6347 FUNCTION get_entitled_days_duration(
6348 p_assignment_id IN NUMBER
6349 ,p_business_group_id IN NUMBER
6350 ,p_effective_date IN DATE
6351 ,p_pl_id IN NUMBER
6352 ,p_level_of_entitlement IN VARCHAR2
6353 ,p_search_start_date IN DATE
6354 ,p_search_end_date IN DATE
6355 ,p_error_code OUT NOCOPY NUMBER
6356 ,p_message OUT NOCOPY VARCHAR2
6357 )
6358 RETURN NUMBER
6359 IS
6360 l_error_message VARCHAR2(100);
6361 l_error_code NUMBER;
6362 l_balance pqp_gap_daily_absences.DURATION%TYPE;
6363 l_proc_step NUMBER(38,10):=0;
6364 l_proc_name VARCHAR2(61):=
6365 g_package_name||'get_entitled_days_duration';
6366 BEGIN
6367 IF g_debug THEN
6368 debug_enter(l_proc_name);
6369 debug('p_assignment_id:'||p_assignment_id);
6370 debug('p_business_group_id:'||p_business_group_id);
6371 debug('p_effective_date:'||fnd_date.date_to_canonical(p_effective_date));
6372 debug('p_pl_id:'||p_pl_id);
6373 debug('p_level_of_entitlement'||p_level_of_entitlement);
6374 debug('p_search_start_date:'||fnd_date.date_to_canonical(p_search_start_date));
6375 debug('p_search_end_date:'||fnd_date.date_to_canonical(p_search_end_date));
6376 END IF;
6377 OPEN csr_get_level_ent(
6378 p_assignment_id
6379 ,p_business_group_id
6380 ,p_search_start_date
6381 ,p_search_end_date
6382 ,p_level_of_entitlement
6383 );
6384 FETCH csr_get_level_ent INTO l_balance;
6385 CLOSE csr_get_level_ent;
6386 IF g_debug THEN
6387 debug('l_balance:'||l_balance);
6388 debug_exit(l_proc_name);
6389 END IF;
6390 RETURN(l_balance);
6391
6392 EXCEPTION
6393 WHEN OTHERS THEN
6394 clear_cache;
6395 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
6396 debug_others(l_proc_name,l_proc_step);
6397 IF g_debug THEN
6398 debug('Leaving: '||l_proc_name,-999);
6399 END IF;
6400 fnd_message.raise_error;
6401 ELSE
6402 RAISE;
6403 END IF;
6404 END get_entitled_days_duration;
6405
6406 -- Function get_wp_days_duration Returns the No of Work Pattern Days
6407 -- in the given date range.
6408 FUNCTION get_wp_days_duration(
6409 p_assignment_id IN NUMBER
6410 ,p_business_group_id IN NUMBER
6411 ,p_effective_date IN DATE
6412 ,p_pl_id IN NUMBER
6413 ,p_wp_day_type IN VARCHAR2
6414 ,p_search_start_date IN DATE
6415 ,p_search_end_date IN DATE
6416 ,p_error_code OUT NOCOPY NUMBER
6417 ,p_message OUT NOCOPY VARCHAR2
6418 )
6419 RETURN NUMBER
6420 IS
6421 l_error_message VARCHAR2(100);
6422 l_error_code NUMBER;
6423 l_balance pqp_gap_daily_absences.DURATION%TYPE;
6424 l_proc_step NUMBER(38,10):=0;
6425 l_proc_name VARCHAR2(61):=
6426 g_package_name||'get_wp_days_duration';
6427 BEGIN
6428 debug_enter(l_proc_name);
6429 debug(l_proc_name, 20);
6430 OPEN csr_get_wp_type_days(
6431 p_assignment_id
6432 ,p_business_group_id
6433 ,p_search_start_date
6434 ,p_search_end_date
6435 ,p_wp_day_type
6436 );
6437 FETCH csr_get_wp_type_days INTO l_balance;
6438 CLOSE csr_get_wp_type_days;
6439 debug_exit(l_proc_name);
6440 RETURN(l_balance);
6441 EXCEPTION
6442 WHEN OTHERS THEN
6443 clear_cache;
6444 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
6445 debug_others(l_proc_name,l_proc_step);
6446 IF g_debug THEN
6447 debug('Leaving: '||l_proc_name,-999);
6448 END IF;
6449 fnd_message.raise_error;
6450 ELSE
6451 RAISE;
6452 END IF;
6453 END get_wp_days_duration;
6454
6455 -- Converts the Absence Start Date into julian day and returns the last 4 digits
6456 -- as Sub Priority.This may be changed in futire to (julian_date * 100) + offset
6457 FUNCTION get_subpriority(
6458 p_business_group_id IN NUMBER
6459 ,p_assignment_id IN NUMBER
6460 ,p_payroll_action_id IN NUMBER
6461 ,p_effective_date IN DATE
6462 ,p_pl_id IN NUMBER
6463 ,p_ler_id IN NUMBER
6464 ,p_absence_start_date IN DATE
6465 )
6466 RETURN NUMBER
6467 IS
6468 l_proc_step NUMBER(38,10):=0;
6469 l_proc_name VARCHAR2(61):=
6470 g_package_name||'get_subproirity';
6471 l_subpriority NUMBER;
6472 BEGIN
6473 /*
6474 l_proc_step := 1;
6475 hr_utility.set_location(l_proc_name,44333);
6476 l_proc_step := 2;
6477 hr_utility.set_location(' Absence Start Date: ' || to_char(p_absence_start_date),44333);
6478 l_proc_step := 3;
6479 hr_utility.set_location('p_business_group_id:'||p_business_group_id,44333);
6480 l_proc_step := 4;
6481 hr_utility.set_location('p_assignment_id:'||p_assignment_id,44333);
6482 l_proc_step := 5;
6483 hr_utility.set_location('p_payroll_action_id:'||p_payroll_action_id,44333);
6484 l_proc_step := 6;
6485 hr_utility.set_location('p_pl_id:'||p_pl_id,44333);
6486 l_proc_step := 7;
6487 hr_utility.set_location('p_ler_id:'||p_ler_id,44333);
6488 l_proc_step := 8;
6489
6490 -- In future the sub priority Calculation may be changed to consider element priorities
6491 -- like Primary element or Secondary element. For this element Type Id can be derived from
6492 -- the logic of the existing DBI ( BEN_ABR_ELEMENT_TYPE_ID ). The calculation could change
6493 -- to something like (julian_date * 100) + 2digit offset. For all the elements in a absence
6494 -- (julian_date * 100) is same.So offset value can be derived based on the element.
6495 -- The Contexts are provided for futire use in calculating the offset.
6496
6497 */
6498 l_proc_step := 1;
6499 l_subpriority := TO_NUMBER(SUBSTR(TO_CHAR(p_absence_start_date, 'J'), -4));
6500 l_proc_step := 2;
6501 /*
6502 l_proc_step := 9;
6503 debug('l_subpriority ' || l_subpriority, 121 );
6504 l_proc_step := 10;
6505 debug_exit(l_proc_name, 121 );
6506 l_proc_step := 11;
6507 */
6508 RETURN l_subpriority;
6509
6510 EXCEPTION
6511 WHEN OTHERS THEN
6512 clear_cache;
6513 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
6514 debug_others(l_proc_name,l_proc_step);
6515 IF g_debug THEN
6516 debug('Leaving: '||l_proc_name,-999);
6517 END IF;
6518 fnd_message.raise_error;
6519 ELSE
6520 RAISE;
6521 END IF;
6522 END get_subpriority;
6523
6524 -- This Function Returns the End Date after adding the Number od Days
6525 -- to the Start Date ( both are in parameters ). If Holiday UDT ID is
6526 -- passed then the holidays are excluded otherwise simple addition of
6527 -- days will be used to arrive at End Date.
6528 --
6529 FUNCTION get_next_cal_date(
6530 p_business_group_id IN NUMBER
6531 ,p_date_start IN DATE
6532 ,p_days IN NUMBER
6533 ,p_error_code OUT NOCOPY NUMBER
6534 ,p_error_message OUT NOCOPY VARCHAR2
6535 ,p_table_id IN NUMBER
6536 ,p_column_name IN VARCHAR2
6537 ,p_value IN VARCHAR2
6538 )
6539 RETURN DATE
6540 IS
6541 l_proc_step NUMBER(38,10):=0;
6542 l_proc_name VARCHAR2(61):=
6543 g_package_name||'get_next_cal_day';
6544 l_days NUMBER;
6545 l_holidays NUMBER;
6546 l_curr_date DATE;
6547 BEGIN
6548 debug_enter(l_proc_name);
6549 debug(' p_date_start ' || to_char(p_date_start));
6550 debug('p_business_group_id:'||p_business_group_id);
6551 debug('p_days:'||p_days);
6552 debug('p_table_id:'||p_table_id);
6553 debug('p_column_name'||p_days);
6554 debug('p_value'||p_table_id);
6555
6556 l_days := p_days;
6557
6558 IF p_table_id IS NULL
6559 THEN
6560 debug(l_proc_name, 10);
6561 l_curr_date := p_date_start + l_days;
6562 ELSE
6563 debug(' Table ID Passed : ' || p_table_id);
6564 l_curr_date := p_date_start;
6565
6566 LOOP
6567 EXIT WHEN l_days <= 0;
6568 -- Check for Holidays
6569 l_holidays :=
6570 pqp_gb_get_no_of_holidays(
6571 p_business_group_id => p_business_group_id
6572 ,p_abs_start_date => l_curr_date
6573 ,p_abs_end_date => l_curr_date
6574 ,p_table_id => p_table_id
6575 ,p_column_name => p_column_name
6576 ,p_value => p_value
6577 );
6578
6579 IF l_holidays = 0
6580 THEN
6581 l_days := l_days - 1;
6582 ELSE
6583 debug(l_proc_name, 80);
6584 END IF;
6585
6586 l_curr_date := l_curr_date + 1;
6587 END LOOP;
6588 END IF;
6589 debug('l_holidays:'||l_holidays);
6590 debug_exit(l_proc_name);
6591 RETURN(l_curr_date);
6592 EXCEPTION
6593 WHEN OTHERS THEN
6594 clear_cache;
6595 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
6596 debug_others(l_proc_name,l_proc_step);
6597 IF g_debug THEN
6598 debug('Leaving: '||l_proc_name,-999);
6599 END IF;
6600 fnd_message.raise_error;
6601 ELSE
6602 RAISE;
6603 END IF;
6604 END get_next_cal_date;
6605
6606 --======================================================================
6607 -- FUNCTION EXISTS_IN_GAP_LOOKUP
6608 --======================================================================
6609 FUNCTION exists_in_gap_lookup(
6610 p_business_group_id IN NUMBER
6611 ,p_lookup_code IN VARCHAR2
6612 ,p_effective_date IN DATE
6613 ,p_lookup_type IN VARCHAR2
6614 )
6615 RETURN BOOLEAN
6616 IS
6617 --
6618 l_security_group_id NUMBER;
6619 l_exists VARCHAR2(1);
6620 l_return BOOLEAN := FALSE;
6621 l_proc_step NUMBER(38,10):=0;
6622 l_proc_name VARCHAR2(61):=
6623 g_package_name||'exists_in_gap_lookup';
6624
6625 --
6626
6627 -- Cursor to get security group for a
6628 -- given business_group_id
6629
6630 CURSOR csr_get_security_group
6631 IS
6632 SELECT fnd_number.canonical_to_number(security_group_id)
6633 security_group_id
6634 FROM per_business_groups
6635 WHERE business_group_id = p_business_group_id;
6636
6637 -- Cursor to check lookup code exists in
6638 -- user security group
6639
6640 CURSOR csr_exists_in_gap_lookup(
6641 c_security_group_id NUMBER
6642 ,c_view_application_id NUMBER
6643 )
6644 IS
6645 SELECT 'X'
6646 FROM fnd_lookup_values_vl
6647 WHERE lookup_type = p_lookup_type
6648 AND lookup_code = p_lookup_code
6649 AND security_group_id = c_security_group_id
6650 AND view_application_id = c_view_application_id
6651 AND enabled_flag = 'Y'
6652 AND p_effective_date BETWEEN NVL(start_date_active, p_effective_date)
6653 AND NVL(end_date_active, p_effective_date);
6654 --
6655 BEGIN
6656 --
6657 debug_enter(l_proc_name);
6658 --
6659 debug('p_business_group_id:'||p_business_group_id);
6660 debug('p_lookup_code '||p_lookup_code);
6661 debug('p_effective_date'|| fnd_date.date_to_canonical(p_effective_date));
6662 debug('p_lookup_type '||p_lookup_type);
6663 -- Get Security Group Information
6664 OPEN csr_get_security_group;
6665 FETCH csr_get_security_group INTO l_security_group_id;
6666 CLOSE csr_get_security_group;
6667
6668 IF l_security_group_id IS NULL
6669 THEN
6670 hr_utility.set_message(800, 'HR_289296_SEC_PROF_SETUP_ERR');
6671 hr_utility.raise_error;
6672 END IF;
6673
6674 -- Check whether the lookup code exists
6675 -- for the user security group id
6676 debug('Lookup Type exists for user security group id check');
6677 OPEN csr_exists_in_gap_lookup(l_security_group_id, 3);
6678 FETCH csr_exists_in_gap_lookup INTO l_exists;
6679
6680 IF csr_exists_in_gap_lookup%NOTFOUND
6681 THEN
6682 -- Check whether the lookup code exists
6683 -- for global security group id
6684 debug('Call hr_api.not_exists_in_hr_lookups');
6685
6686 IF hr_api.not_exists_in_hr_lookups(p_effective_date, p_lookup_type
6687 ,p_lookup_code)
6688 THEN
6689 l_return := FALSE;
6690 ELSE
6691 l_return := TRUE;
6692 END IF; -- End if of lookup code in hr_lookups check...
6693 ELSE -- exists in fnd_lookups
6694 l_return := TRUE;
6695 END IF; -- End if of lookup code in fnd_lookups check...
6696
6697 CLOSE csr_exists_in_gap_lookup;
6698 --
6699 debug_exit(l_proc_name);
6700 RETURN l_return;
6701 --
6702 EXCEPTION
6703 WHEN OTHERS THEN
6704 clear_cache;
6705 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
6706 debug_others(l_proc_name,l_proc_step);
6707 IF g_debug THEN
6708 debug('Leaving: '||l_proc_name,-999);
6709 END IF;
6710 fnd_message.raise_error;
6711 ELSE
6712 RAISE;
6713 END IF;
6714 END exists_in_gap_lookup;
6715
6716 --
6717
6718
6719
6720 ---------------------------------------------------
6721 ---- Added for Daily Absences in OMP from here ----
6722 ---------------------------------------------------
6723
6724 -- This is a Formula Fucntion called in OMP Pay Processing Fast Formula
6725 -- This Formula get all the Bands consumed as of effective date
6726 -- ( usually this will be period start date or absence start date )
6727 FUNCTION get_omp_all_band_ent_balance(
6728 p_business_group_id IN NUMBER
6729 ,p_assignment_id IN NUMBER
6730 ,p_element_type_id IN NUMBER
6731 ,p_effective_date IN DATE
6732 ,p_band1_ent_bal OUT NOCOPY NUMBER
6733 ,p_band2_ent_bal OUT NOCOPY NUMBER
6734 ,p_band3_ent_bal OUT NOCOPY NUMBER
6735 ,p_band4_ent_bal OUT NOCOPY NUMBER
6736 ,p_noband_ent_bal OUT NOCOPY NUMBER
6737 ,p_error_code OUT NOCOPY NUMBER
6738 ,p_error_message OUT NOCOPY VARCHAR2
6739 )
6740 RETURN NUMBER
6741 IS
6742 l_proc_step NUMBER(38,10):=0;
6743 l_proc_name VARCHAR2(61):=
6744 g_package_name||'get_omp_all_band_ent_balance';
6745 l_retval NUMBER;
6746 BEGIN
6747 debug_enter(l_proc_name);
6748 debug('p_business_group_id:'||p_business_group_id);
6749 debug('p_assignment_id:'||p_assignment_id);
6750 debug('p_element_type_id:'||p_element_type_id);
6751 p_band1_ent_bal :=
6752 pqp_gb_osp_functions.get_omp_band_ent_bal_ele_typ(
6753 p_business_group_id => p_business_group_id
6754 ,p_effective_date => p_effective_date
6755 ,p_assignment_id => p_assignment_id
6756 ,p_element_type_id => p_element_type_id
6757 ,p_level_of_entitlement => 'BAND1'
6758 ,p_error_code => p_error_code
6759 ,p_error_message => p_error_message
6760 );
6761
6762 IF p_error_code = -1
6763 THEN
6764 RETURN -1;
6765 END IF; -- End if of check for error code ...
6766
6767 p_band2_ent_bal :=
6768 pqp_gb_osp_functions.get_omp_band_ent_bal_ele_typ(
6769 p_business_group_id => p_business_group_id
6770 ,p_effective_date => p_effective_date
6771 ,p_assignment_id => p_assignment_id
6772 ,p_element_type_id => p_element_type_id
6773 ,p_level_of_entitlement => 'BAND2'
6774 ,p_error_code => p_error_code
6775 ,p_error_message => p_error_message
6776 );
6777
6778 IF p_error_code = -1
6779 THEN
6780 RETURN -1;
6781 END IF; -- End if of check for error code ...
6782
6783 p_band3_ent_bal :=
6784 pqp_gb_osp_functions.get_omp_band_ent_bal_ele_typ(
6785 p_business_group_id => p_business_group_id
6786 ,p_effective_date => p_effective_date
6787 ,p_assignment_id => p_assignment_id
6788 ,p_element_type_id => p_element_type_id
6789 ,p_level_of_entitlement => 'BAND3'
6790 ,p_error_code => p_error_code
6791 ,p_error_message => p_error_message
6792 );
6793
6794 IF p_error_code = -1
6795 THEN
6796 RETURN -1;
6797 END IF; -- End if of check for error code ...
6798
6799 p_band4_ent_bal :=
6800 pqp_gb_osp_functions.get_omp_band_ent_bal_ele_typ(
6801 p_business_group_id => p_business_group_id
6802 ,p_effective_date => p_effective_date
6803 ,p_assignment_id => p_assignment_id
6804 ,p_element_type_id => p_element_type_id
6805 ,p_level_of_entitlement => 'BAND4'
6806 ,p_error_code => p_error_code
6807 ,p_error_message => p_error_message
6808 );
6809
6810 IF p_error_code = -1
6811 THEN
6812 RETURN -1;
6813 END IF; -- End if of check for error code ...
6814
6815 p_noband_ent_bal :=
6816 pqp_gb_osp_functions.get_omp_band_ent_bal_ele_typ(
6817 p_business_group_id => p_business_group_id
6818 ,p_effective_date => p_effective_date
6819 ,p_assignment_id => p_assignment_id
6820 ,p_element_type_id => p_element_type_id
6821 ,p_level_of_entitlement => 'NOBAND'
6822 ,p_error_code => p_error_code
6823 ,p_error_message => p_error_message
6824 );
6825
6826 IF p_error_code = -1
6827 THEN
6828 RETURN -1;
6829 END IF; -- End if of check for error code ...
6830
6831 debug_exit(l_proc_name);
6832 RETURN 0;
6833
6834 EXCEPTION
6835 WHEN OTHERS THEN
6836 clear_cache;
6837 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
6838 debug_others(l_proc_name,l_proc_step);
6839 IF g_debug THEN
6840 debug('Leaving: '||l_proc_name,-999);
6841 END IF;
6842 fnd_message.raise_error;
6843 ELSE
6844 RAISE;
6845 END IF;
6846 END get_omp_all_band_ent_balance;
6847
6848 -- This function is called from function get_omp_all_band_ent_balance. This
6849 -- gets the Plan Type Id from the Element Type Id and Passes in onto
6850 -- get_omp_band_ent_bal_pl_typ to get the Band Entitlements usedup.
6851 FUNCTION get_omp_band_ent_bal_ele_typ(
6852 p_business_group_id IN NUMBER
6853 ,p_assignment_id IN NUMBER
6854 ,p_element_type_id IN NUMBER
6855 ,p_effective_date IN DATE
6856 ,p_level_of_entitlement IN VARCHAR2
6857 ,p_error_code OUT NOCOPY NUMBER
6858 ,p_error_message OUT NOCOPY VARCHAR2
6859 ,p_days_hours IN VARCHAR2
6860 )
6861 RETURN NUMBER
6862 IS
6863 l_proc_step NUMBER(38,10):=0;
6864 l_proc_name VARCHAR2(61):=
6865 g_package_name||'get_omp_band_ent_bal';
6866 l_retval NUMBER;
6867
6868 CURSOR csr_osp_scheme_det
6869 (p_element_type_id IN NUMBER
6870 ,p_effective_date IN DATE
6871 ) IS
6872 SELECT pln.pl_typ_id
6873 FROM pay_element_type_extra_info eei
6874 ,ben_pl_f pln
6875 WHERE UPPER(eei.eei_information19) = 'ABSENCE INFO'
6876 AND eei.element_type_id = p_element_type_id
6877 --AND eei.information_type = 'PQP_GB_OMP_ABSENCE_PLAN_INFO'
6878 AND pln.pl_id =
6879 fnd_number.canonical_to_number(eei.eei_information1)
6880 AND p_effective_date BETWEEN pln.effective_start_date
6881 AND pln.effective_end_date;
6882
6883 l_scheme_det csr_osp_scheme_det%ROWTYPE;
6884 BEGIN
6885 debug_enter(l_proc_name);
6886 debug('p_business_group_id:'||p_business_group_id);
6887 debug('p_assignment_id:'||p_assignment_id);
6888 debug('p_element_type_id:'||p_element_type_id);
6889 OPEN csr_osp_scheme_det(
6890 p_element_type_id => p_element_type_id
6891 ,p_effective_date => p_effective_date
6892 );
6893 FETCH csr_osp_scheme_det INTO l_scheme_det;
6894 CLOSE csr_osp_scheme_det;
6895 -- Call get_band_entitlement_balance to get the entitlements.
6896 l_retval :=
6897 pqp_gb_osp_functions.get_omp_band_ent_bal_pl_typ(
6898 p_business_group_id => p_business_group_id
6899 ,p_effective_date => p_effective_date
6900 ,p_assignment_id => p_assignment_id
6901 ,p_pl_typ_id => l_scheme_det.pl_typ_id
6902 ,p_level_of_entitlement => p_level_of_entitlement
6903 ,p_error_code => p_error_code
6904 ,p_error_message => p_error_message
6905 ,p_days_hours => p_days_hours
6906 );
6907 debug_exit(l_proc_name);
6908 RETURN l_retval;
6909 EXCEPTION
6910 WHEN OTHERS THEN
6911 clear_cache;
6912 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
6913 debug_others(l_proc_name,l_proc_step);
6914 IF g_debug THEN
6915 debug('Leaving: '||l_proc_name,-999);
6916 END IF;
6917 fnd_message.raise_error;
6918 ELSE
6919 RAISE;
6920 END IF;
6921 END get_omp_band_ent_bal_ele_typ;
6922
6923 -- Function calls pqp_gb_omp_daily_absences.get_entitlement_balance
6924 -- and caches the Band entitlements and Returns the requested Band details
6925 FUNCTION get_omp_band_ent_bal_pl_typ(
6926 p_business_group_id IN NUMBER
6927 ,p_effective_date IN DATE
6928 ,p_assignment_id IN NUMBER
6929 ,p_pl_typ_id IN NUMBER
6930 ,p_level_of_entitlement IN VARCHAR2
6931 ,p_error_code OUT NOCOPY NUMBER
6932 ,p_error_message OUT NOCOPY VARCHAR2
6933 ,p_days_hours IN VARCHAR2
6934 )
6935 RETURN NUMBER
6936 IS
6937 l_proc_step NUMBER(38,10):=0;
6938 l_proc_name VARCHAR2(61):=
6939 g_package_name||'get_omp_band_ent_bal_pl_typ';
6940
6941 l_omp_absences_taken_to_date pqp_absval_pkg.t_entitlements;
6942 l_retval NUMBER;
6943 i BINARY_INTEGER;
6944 BEGIN
6945 debug_enter(l_proc_name);
6946 debug('p_business_group_id:'||p_business_group_id);
6947 debug('p_assignment_id:'||p_assignment_id);
6948 debug('p_pl_typ_id:'||p_pl_typ_id);
6949 debug('p_level_of_entitlement'||p_level_of_entitlement);
6950 debug('p_days_hours'||p_days_hours);
6951 p_error_code := 0;
6952
6953 -- First Check whether the call is first time
6954 -- by looking at the Global Variables.
6955 IF g_omp_assignment_id <> p_assignment_id
6956 OR g_omp_pl_typ_id <> p_pl_typ_id
6957 OR g_omp_balance_date <> p_effective_date
6958 THEN
6959 debug('p_assignment_id:' || p_assignment_id);
6960 -- Call the get_total_entitlements_balance Procedure
6961 -- and get the values in pl/sql table and set global values.
6962 pqp_gb_omp_daily_absences.get_entitlement_balance(
6963 p_assignment_id => p_assignment_id
6964 ,p_business_group_id => p_business_group_id
6965 ,p_effective_date => p_effective_date
6966 ,p_pl_typ_id => p_pl_typ_id
6967 ,p_absences_taken_to_date => l_omp_absences_taken_to_date
6968 ,p_error_code => p_error_code
6969 ,p_message => p_error_message
6970 );
6971 g_omp_assignment_id := p_assignment_id;
6972 g_omp_pl_typ_id := p_pl_typ_id;
6973 g_omp_balance_date := p_effective_date;
6974 g_omp_absences_taken_to_date := l_omp_absences_taken_to_date;
6975 END IF;
6976
6977 debug(l_proc_name, 30);
6978
6979
6980 i := g_omp_absences_taken_to_date.FIRST;
6981
6982 WHILE i IS NOT NULL
6983 LOOP
6984 IF g_omp_absences_taken_to_date(i).band = p_level_of_entitlement
6985 THEN
6986 IF p_days_hours = 'DAYS' THEN
6987 l_retval := g_omp_absences_taken_to_date(i).entitlement ;
6988 ELSIF p_days_hours = 'HOURS' THEN
6989 l_retval := g_omp_absences_taken_to_date(i).duration_in_hours ;
6990 END IF;
6991 i := NULL ;
6992 ELSE
6993 i := g_omp_absences_taken_to_date.NEXT(i);
6994 END IF;
6995 END LOOP;
6996 debug('l_retval:'||l_retval);
6997 debug_exit(l_proc_name);
6998 RETURN NVL(l_retval, 0);
6999
7000 EXCEPTION
7001 WHEN OTHERS THEN
7002 clear_cache;
7003 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
7004 debug_others(l_proc_name,l_proc_step);
7005 IF g_debug THEN
7006 debug('Leaving: '||l_proc_name,-999);
7007 END IF;
7008 fnd_message.raise_error;
7009 ELSE
7010 RAISE;
7011 END IF;
7012 END get_omp_band_ent_bal_pl_typ;
7013 ---------------------------------------------------
7014 ---- Added for Daily Absences in OMP End here ----
7015 ---------------------------------------------------
7016
7017
7018 ---------------------------------------------------------------------------
7019 ------ Added Required Functions for Hours Solution ----------------
7020 ---------------------------------------------------------------------------
7021 FUNCTION get_abs_plan_ent_hours_info
7022 ( p_absence_attendance_id IN NUMBER,
7023 p_pl_id IN NUMBER,
7024 p_error_code OUT NOCOPY NUMBER,
7025 p_error_message OUT NOCOPY VARCHAR2,
7026 p_search_start_date IN DATE DEFAULT NULL,
7027 p_search_end_date IN DATE DEFAULT NULL,
7028 p_level_of_entitlement IN VARCHAR2 DEFAULT NULL )
7029 RETURN NUMBER IS
7030 l_csr_entitled_days_rec csr_entitled_days%ROWTYPE ;
7031 l_proc_step NUMBER(38,10):=0;
7032 l_proc_name VARCHAR2(61):=
7033 g_package_name||'get_abs_plan_ent_hours_info';
7034 l_no_of_hours NUMBER ;
7035 BEGIN
7036 debug_enter(l_proc_name) ;
7037 IF g_debug then
7038 debug('p_absence_attendance_id:'||p_absence_attendance_id);
7039 debug('p_pl_id:'||p_pl_id);
7040 debug(p_search_start_date);
7041 debug(p_search_end_date);
7042 debug('p_level_of_entitlement'||p_level_of_entitlement);
7043 END IF;
7044 p_error_code := 0 ;
7045 -- Check the Start Date is earlier than or equal to End Date.
7046 IF NVL(p_search_start_date,SYSDATE) > NVL(p_search_end_date,hr_api.g_eot) THEN
7047 p_error_code := -1 ;
7048 fnd_message.set_name('PQP','PQP_230617_END_GE_START');
7049 --fnd_message.set_token('START',fnd_date.date_to_canonical(p_search_start_date));
7050 --fnd_message.set_token('END',fnd_date.date_to_canonical(p_search_end_date));
7051 p_error_message := fnd_message.get();
7052 RETURN NULL;
7053 END IF;
7054
7055 -- Open the Cursor to get total number of Entitled days for the qualifier.
7056 OPEN csr_entitled_days( p_absence_attendance_id => p_absence_attendance_id,
7057 p_pl_id => p_pl_id,
7058 p_search_start_date => p_search_start_date,
7059 p_search_end_date => p_search_end_date,
7060 p_level_of_entitlement => p_level_of_entitlement ) ;
7061 FETCH csr_entitled_days INTO l_csr_entitled_days_rec ;
7062 CLOSE csr_entitled_days;
7063
7064 l_no_of_hours := l_csr_entitled_days_rec.hours ;
7065 IF g_debug THEN
7066 debug('l_no_of_hours:'||l_no_of_hours);
7067 END IF;
7068 debug_exit(l_proc_name) ;
7069
7070 RETURN l_no_of_hours ;
7071
7072 EXCEPTION
7073 WHEN OTHERS THEN
7074 clear_cache;
7075 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
7076 debug_others(l_proc_name,l_proc_step);
7077 IF g_debug THEN
7078 debug('Leaving: '||l_proc_name,-999);
7079 END IF;
7080 fnd_message.raise_error;
7081 ELSE
7082 RAISE;
7083 END IF;
7084
7085 END get_abs_plan_ent_hours_info ;
7086
7087 FUNCTION get_abs_plan_paid_hours_info
7088 ( p_absence_attendance_id IN NUMBER,
7089 p_pl_id IN NUMBER,
7090 p_error_code OUT NOCOPY NUMBER,
7091 p_error_message OUT NOCOPY VARCHAR2,
7092 p_search_start_date IN DATE DEFAULT NULL,
7093 p_search_end_date IN DATE DEFAULT NULL,
7094 p_level_of_pay IN VARCHAR2 DEFAULT NULL )
7095 RETURN NUMBER IS
7096 l_proc_step NUMBER(38,10):=0;
7097 l_proc_name VARCHAR2(61):=
7098 g_package_name||'get_abs_plan_paid_hours_info';
7099 l_no_of_days NUMBER ;
7100 l_csr_paid_days_rec csr_paid_days%ROWTYPE ; -----Added For Hours
7101 BEGIN
7102 debug_enter(l_proc_name) ;
7103 IF g_debug then
7104 debug('p_absence_attendance_id:'||p_absence_attendance_id);
7105 debug('p_pl_id:'||p_pl_id);
7106 debug(p_search_start_date);
7107 debug(p_search_end_date);
7108 debug('p_level_of_pay'||p_level_of_pay);
7109 END IF;
7110 p_error_code := 0 ;
7111 -- Check the Start Date is earlier than or equal to End Date.
7112 IF NVL(p_search_start_date,SYSDATE) > NVL(p_search_end_date,hr_api.g_eot) THEN
7113 p_error_code := -1 ;
7114 fnd_message.set_name('PQP','PQP_230617_END_GE_START');
7115 --fnd_message.set_token('START',fnd_date.date_to_canonical(p_search_start_date));
7116 --fnd_message.set_token('END',fnd_date.date_to_canonical(p_search_end_date));
7117 p_error_message := fnd_message.get();
7118 RETURN NULL;
7119 END IF;
7120
7121 -- Open the Cursor to get total number of Paid days for the qualifier type.
7122 OPEN csr_paid_days( p_absence_attendance_id => p_absence_attendance_id,
7123 p_pl_id => p_pl_id,
7124 p_search_start_date => p_search_start_date,
7125 p_search_end_date => p_search_end_date,
7126 p_level_of_pay => p_level_of_pay ) ;
7127 FETCH csr_paid_days INTO l_csr_paid_days_rec ; -----Added For Hours
7128 CLOSE csr_paid_days;
7129
7130 l_no_of_days := l_csr_paid_days_rec.hours ; -----Added For Hours
7131 IF g_debug THEN
7132 debug('l_no_of_days:'||l_no_of_days);
7133 END IF;
7134 debug_exit(l_proc_name) ;
7135
7136 RETURN l_no_of_days ;
7137
7138
7139 EXCEPTION
7140 WHEN OTHERS THEN
7141 clear_cache;
7142 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
7143 debug_others(l_proc_name,l_proc_step);
7144 IF g_debug THEN
7145 debug('Leaving: '||l_proc_name,-999);
7146 END IF;
7147 fnd_message.raise_error;
7148 ELSE
7149 RAISE;
7150 END IF;
7151
7152 END get_abs_plan_paid_hours_info ;
7153
7154
7155
7156 --Added For Hours
7157
7158 FUNCTION get_osp_hours_band_paid_ent
7159 (p_absence_attendance_id IN NUMBER,
7160 p_pl_id IN NUMBER,
7161 p_band1_entitled OUT NOCOPY NUMBER,
7162 p_band2_entitled OUT NOCOPY NUMBER,
7163 p_band3_entitled OUT NOCOPY NUMBER,
7164 p_band4_entitled OUT NOCOPY NUMBER,
7165 p_noband_entitled OUT NOCOPY NUMBER,
7166 p_error_code OUT NOCOPY NUMBER,
7167 p_error_message OUT NOCOPY VARCHAR2,
7168 p_search_start_date IN DATE DEFAULT NULL,
7169 p_search_end_Date IN DATE DEFAULT NULL
7170 ) RETURN NUMBER
7171 IS
7172 l_proc_step NUMBER(38,10):=0;
7173 l_proc_name VARCHAR2(61):=
7174 g_package_name||'get_osp_hours_band_paid_ent';
7175
7176 l_error_code NUMBER;
7177 BEGIN
7178 debug_enter(l_proc_name) ;
7179 IF g_debug then
7180 debug('p_absence_attendance_id:'||p_absence_attendance_id);
7181 debug('p_pl_id:'||p_pl_id);
7182 debug(p_search_start_date);
7183 debug(p_search_end_date);
7184
7185 END IF;
7186 -- Do the Search Start Date <= Search End Date Validation Here.
7187
7188 p_error_code := 0 ;
7189 -- With the above column name get entitlement days for BAND1.
7190 p_band1_entitled := pqp_gb_osp_functions.get_abs_plan_ent_hours_info
7191 ( p_absence_attendance_id => p_absence_attendance_id,
7192 p_pl_id => p_pl_id,
7193 p_error_code => l_error_code,
7194 p_error_message => p_error_message,
7195 p_search_start_date => p_search_start_date,
7196 p_search_end_date => p_search_end_date,
7197 p_level_of_entitlement => 'BAND1') ;
7198
7199 -- Ended Calls for BAND1.
7200 -- With the above column name get entitlement days for BAND2.
7201 p_band2_entitled := pqp_gb_osp_functions.get_abs_plan_ent_hours_info
7202 ( p_absence_attendance_id => p_absence_attendance_id,
7203 p_pl_id => p_pl_id,
7204 p_error_code => l_error_code,
7205 p_error_message => p_error_message,
7206 p_search_start_date => p_search_start_date,
7207 p_search_end_date => p_search_end_date,
7208 p_level_of_entitlement => 'BAND2') ;
7209
7210 -- Ended Calls for BAND2.
7211 -- With the above column name get entitlement days for BAND3.
7212 p_band3_entitled := pqp_gb_osp_functions.get_abs_plan_ent_hours_info
7213 ( p_absence_attendance_id => p_absence_attendance_id,
7214 p_pl_id => p_pl_id,
7215 p_error_code => l_error_code,
7216 p_error_message => p_error_message,
7217 p_search_start_date => p_search_start_date,
7218 p_search_end_date => p_search_end_date,
7219 p_level_of_entitlement => 'BAND3') ;
7220
7221 -- Ended Calls for BAND3.
7222 -- With the above column name get entitlement days for BAND4.
7223 p_band4_entitled := pqp_gb_osp_functions.get_abs_plan_ent_hours_info
7224 ( p_absence_attendance_id => p_absence_attendance_id,
7225 p_pl_id => p_pl_id,
7226 p_error_code => l_error_code,
7227 p_error_message => p_error_message,
7228 p_search_start_date => p_search_start_date,
7229 p_search_end_date => p_search_end_date,
7230 p_level_of_entitlement => 'BAND4') ;
7231
7232 -- Ended Calls for BAND4.
7233 -- With the above column name get entitlement days for NOBAND.
7234 p_noband_entitled := pqp_gb_osp_functions.get_abs_plan_ent_hours_info
7235 ( p_absence_attendance_id => p_absence_attendance_id,
7236 p_pl_id => p_pl_id,
7237 p_error_code => l_error_code,
7238 p_error_message => p_error_message,
7239 p_search_start_date => p_search_start_date,
7240 p_search_end_date => p_search_end_date,
7241 p_level_of_entitlement => 'NOBAND') ;
7242
7243 --We need to add up the rows with WAITINGDAY to p_noband_entitled for the
7244 --payroll calculation as WAITINGDAY is treated as NOBAND entitlement in payroll.
7245
7246 p_noband_entitled := NVL(p_noband_entitled,0) +
7247 pqp_gb_osp_functions.get_abs_plan_ent_days_info(
7248 p_absence_attendance_id => p_absence_attendance_id
7249 ,p_pl_id => p_pl_id
7250 ,p_error_code => l_error_code
7251 ,p_error_message => p_error_message
7252 ,p_search_start_date => p_search_start_date
7253 ,p_search_end_date => p_search_end_date
7254 ,p_level_of_entitlement => 'WAITINGDAY'
7255 );
7256
7257 -- Ended Calls for NOBAND.
7258
7259 RETURN 0 ;
7260
7261 EXCEPTION
7262 WHEN OTHERS THEN
7263 clear_cache;
7264 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
7265 debug_others(l_proc_name,l_proc_step);
7266 IF g_debug THEN
7267 debug('Leaving: '||l_proc_name,-999);
7268 END IF;
7269 fnd_message.raise_error;
7270 ELSE
7271 RAISE;
7272 END IF;
7273 END get_osp_hours_band_paid_ent ;
7274
7275
7276
7277
7278
7279
7280 -- This Function gets the scheme Details based on element_type_id available as context
7281 -- and gets the entitlement balance for all bands at one go
7282 FUNCTION get_all_band_hours_ent_balance( p_business_group_id IN NUMBER
7283 ,p_assignment_id IN NUMBER
7284 ,p_element_type_id IN NUMBER
7285 ,p_effective_date IN DATE
7286 ,p_band1_ent_bal OUT NOCOPY NUMBER
7287 ,p_band2_ent_bal OUT NOCOPY NUMBER
7288 ,p_band3_ent_bal OUT NOCOPY NUMBER
7289 ,p_band4_ent_bal OUT NOCOPY NUMBER
7290 ,p_noband_ent_bal OUT NOCOPY NUMBER
7291 ,p_error_code OUT NOCOPY NUMBER
7292 ,p_error_message OUT NOCOPY VARCHAR2 )
7293 RETURN NUMBER IS
7294 l_proc_step NUMBER(38,10):=0;
7295 l_proc_name VARCHAR2(61):=
7296 g_package_name||'get_all_band_hours_ent_balance';
7297 l_retval number ;
7298
7299 BEGIN
7300
7301 debug_enter(l_proc_name);
7302 IF g_debug then
7303 debug('p_business_group_id:'||p_business_group_id);
7304 debug('p_assignment_id:'||p_assignment_id);
7305 debug('p_element_type_id:'||p_element_type_id);
7306 debug(p_effective_date);
7307 END IF;
7308 p_band1_ent_bal := get_band_ent_bal_by_ele_typ_id
7309 ( p_business_group_id => p_business_group_id
7310 ,p_effective_date => p_effective_date
7311 ,p_assignment_id => p_assignment_id
7312 ,p_element_type_id => p_element_type_id
7313 ,p_level_of_entitlement => 'BAND1'
7314 ,p_error_code => p_error_code
7315 ,p_error_message => p_error_message
7316 ,p_days_hours => 'HOURS'
7317 );
7318
7319 IF p_error_code < 0 THEN
7320 RETURN p_error_code;
7321 END IF; -- End if of check for error code ...
7322
7323 p_band2_ent_bal := get_band_ent_bal_by_ele_typ_id
7324 ( p_business_group_id => p_business_group_id
7325 ,p_effective_date => p_effective_date
7326 ,p_assignment_id => p_assignment_id
7327 ,p_element_type_id => p_element_type_id
7328 ,p_level_of_entitlement => 'BAND2'
7329 ,p_error_code => p_error_code
7330 ,p_error_message => p_error_message
7331 ,p_days_hours => 'HOURS'
7332 );
7333
7334 IF p_error_code = -1 THEN
7335 RETURN -1;
7336 END IF; -- End if of check for error code ...
7337
7338 p_band3_ent_bal := get_band_ent_bal_by_ele_typ_id
7339 ( p_business_group_id => p_business_group_id
7340 ,p_effective_date => p_effective_date
7341 ,p_assignment_id => p_assignment_id
7342 ,p_element_type_id => p_element_type_id
7343 ,p_level_of_entitlement => 'BAND3'
7344 ,p_error_code => p_error_code
7345 ,p_error_message => p_error_message
7346 ,p_days_hours => 'HOURS'
7347 );
7348
7349 IF p_error_code = -1 THEN
7350 RETURN -1;
7351 END IF; -- End if of check for error code ...
7352
7353 p_band4_ent_bal := get_band_ent_bal_by_ele_typ_id
7354 ( p_business_group_id => p_business_group_id
7355 ,p_effective_date => p_effective_date
7356 ,p_assignment_id => p_assignment_id
7357 ,p_element_type_id => p_element_type_id
7358 ,p_level_of_entitlement => 'BAND4'
7359 ,p_error_code => p_error_code
7360 ,p_error_message => p_error_message
7361 ,p_days_hours => 'HOURS'
7362 );
7363
7364 IF p_error_code = -1 THEN
7365 RETURN -1;
7366 END IF; -- End if of check for error code ...
7367
7368 p_noband_ent_bal := get_band_ent_bal_by_ele_typ_id
7369 ( p_business_group_id => p_business_group_id
7370 ,p_effective_date => p_effective_date
7371 ,p_assignment_id => p_assignment_id
7372 ,p_element_type_id => p_element_type_id
7373 ,p_level_of_entitlement => 'NOBAND'
7374 ,p_error_code => p_error_code
7375 ,p_error_message => p_error_message
7376 ,p_days_hours => 'HOURS'
7377 );
7378
7379 IF p_error_code = -1 THEN
7380 RETURN -1;
7381 END IF; -- End if of check for error code ...
7382
7383
7384 debug_exit(l_proc_name);
7385 RETURN 0;
7386
7387 EXCEPTION
7388 WHEN OTHERS THEN
7389 clear_cache;
7390 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
7391 debug_others(l_proc_name,l_proc_step);
7392 IF g_debug THEN
7393 debug('Leaving: '||l_proc_name,-999);
7394 END IF;
7395 fnd_message.raise_error;
7396 ELSE
7397 RAISE;
7398 END IF;
7399
7400 END get_all_band_hours_ent_balance ;
7401
7402
7403
7404 -- This is a Formula Fucntion called in OMP Pay Processing Fast Formula
7405 -- This Formula get all the Bands consumed as of effective date
7406 -- ( usually this will be period start date or absence start date )
7407 FUNCTION get_omp_all_band_hours_ent_bal(
7408 p_business_group_id IN NUMBER
7409 ,p_assignment_id IN NUMBER
7410 ,p_element_type_id IN NUMBER
7411 ,p_effective_date IN DATE
7412 ,p_band1_ent_bal OUT NOCOPY NUMBER
7413 ,p_band2_ent_bal OUT NOCOPY NUMBER
7414 ,p_band3_ent_bal OUT NOCOPY NUMBER
7415 ,p_band4_ent_bal OUT NOCOPY NUMBER
7416 ,p_noband_ent_bal OUT NOCOPY NUMBER
7417 ,p_error_code OUT NOCOPY NUMBER
7418 ,p_error_message OUT NOCOPY VARCHAR2 )
7419 RETURN NUMBER IS
7420 l_proc_step NUMBER(38,10):=0;
7421 l_proc_name VARCHAR2(61):=
7422 g_package_name||'get_omp_all_band_hours_ent_bal';
7423 l_retval number ;
7424
7425 BEGIN
7426
7427 debug_enter(l_proc_name);
7428
7429 p_band1_ent_bal := pqp_gb_osp_functions.get_omp_band_ent_bal_ele_typ
7430 ( p_business_group_id => p_business_group_id
7431 ,p_effective_date => p_effective_date
7432 ,p_assignment_id => p_assignment_id
7433 ,p_element_type_id => p_element_type_id
7434 ,p_level_of_entitlement => 'BAND1'
7435 ,p_error_code => p_error_code
7436 ,p_error_message => p_error_message
7437 ,p_days_hours => 'HOURS'
7438 );
7439
7440 IF p_error_code = -1 THEN
7441 RETURN -1;
7442 END IF; -- End if of check for error code ...
7443
7444 p_band2_ent_bal := pqp_gb_osp_functions.get_omp_band_ent_bal_ele_typ
7445 ( p_business_group_id => p_business_group_id
7446 ,p_effective_date => p_effective_date
7447 ,p_assignment_id => p_assignment_id
7448 ,p_element_type_id => p_element_type_id
7449 ,p_level_of_entitlement => 'BAND2'
7450 ,p_error_code => p_error_code
7451 ,p_error_message => p_error_message
7452 ,p_days_hours => 'HOURS'
7453 );
7454
7455 IF p_error_code = -1 THEN
7456 RETURN -1;
7457 END IF; -- End if of check for error code ...
7458
7459 p_band3_ent_bal := pqp_gb_osp_functions.get_omp_band_ent_bal_ele_typ
7460 ( p_business_group_id => p_business_group_id
7461 ,p_effective_date => p_effective_date
7462 ,p_assignment_id => p_assignment_id
7463 ,p_element_type_id => p_element_type_id
7464 ,p_level_of_entitlement => 'BAND3'
7465 ,p_error_code => p_error_code
7466 ,p_error_message => p_error_message
7467 ,p_days_hours => 'HOURS'
7468 );
7469
7470 IF p_error_code = -1 THEN
7471 RETURN -1;
7472 END IF; -- End if of check for error code ...
7473
7474 p_band4_ent_bal := pqp_gb_osp_functions.get_omp_band_ent_bal_ele_typ
7475 ( p_business_group_id => p_business_group_id
7476 ,p_effective_date => p_effective_date
7477 ,p_assignment_id => p_assignment_id
7478 ,p_element_type_id => p_element_type_id
7479 ,p_level_of_entitlement => 'BAND4'
7480 ,p_error_code => p_error_code
7481 ,p_error_message => p_error_message
7482 ,p_days_hours => 'HOURS'
7483 );
7484
7485 IF p_error_code = -1 THEN
7486 RETURN -1;
7487 END IF; -- End if of check for error code ...
7488
7489 p_noband_ent_bal := pqp_gb_osp_functions.get_omp_band_ent_bal_ele_typ
7490 ( p_business_group_id => p_business_group_id
7491 ,p_effective_date => p_effective_date
7492 ,p_assignment_id => p_assignment_id
7493 ,p_element_type_id => p_element_type_id
7494 ,p_level_of_entitlement => 'NOBAND'
7495 ,p_error_code => p_error_code
7496 ,p_error_message => p_error_message
7497 ,p_days_hours => 'HOURS'
7498 );
7499
7500 IF p_error_code = -1 THEN
7501 RETURN -1;
7502 END IF; -- End if of check for error code ...
7503
7504 debug_exit(l_proc_name);
7505 RETURN 0;
7506
7507 EXCEPTION
7508 WHEN OTHERS THEN
7509 clear_cache;
7510 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
7511 debug_others(l_proc_name,l_proc_step);
7512 IF g_debug THEN
7513 debug('Leaving: '||l_proc_name,-999);
7514 END IF;
7515 fnd_message.raise_error;
7516 ELSE
7517 RAISE;
7518 END IF;
7519 END get_omp_all_band_hours_ent_bal ;
7520 --
7521 --
7522 --
7523 FUNCTION get_boundary_dates
7524 (p_absence_attendance_id IN NUMBER
7525 ,p_pl_id IN NUMBER
7526 ,p_first_of_last IN VARCHAR2
7527 ,p_level_of_entitlement IN VARCHAR2 DEFAULT NULL
7528 ,p_level_of_pay IN VARCHAR2 DEFAULT NULL
7529 ) RETURN DATE
7530 IS
7531
7532 g_debug BOOLEAN;
7533
7534 l_proc_step NUMBER(38,10):=0;
7535 l_proc_name VARCHAR2(61):=
7536 g_package_name||'get_boundary_dates';
7537
7538 CURSOR csr_gap_absence_plan
7539 (p_absence_attendance_id IN NUMBER
7540 ,p_pl_id IN NUMBER
7541 ) IS
7542 SELECT gap.gap_absence_plan_id id
7543 ,gap.last_gap_daily_absence_date
7544 FROM pqp_gap_absence_plans gap
7545 WHERE gap.absence_attendance_id = p_absence_attendance_id
7546 AND gap.pl_id = p_pl_id;
7547
7548 l_gap_absence_plan csr_gap_absence_plan%ROWTYPE;
7549
7550 CURSOR csr_first_day
7551 (p_gap_absence_plan_id IN NUMBER
7552 ,p_level_of_entitlement IN VARCHAR2 DEFAULT NULL
7553 ,p_level_of_pay IN VARCHAR2 DEFAULT NULL
7554 ) IS
7555 SELECT MIN(gda.absence_date) abs_date
7556 FROM pqp_gap_daily_absences gda
7557 WHERE gda.gap_absence_plan_id = p_gap_absence_plan_id
7558 AND ( ( p_level_of_entitlement IS NOT NULL
7559 AND
7560 gda.level_of_entitlement = p_level_of_entitlement
7561 )
7562 OR
7563 ( p_level_of_pay IS NOT NULL
7564 AND
7565 gda.level_of_pay = p_level_of_pay
7566 )
7567 OR
7568 ( p_level_of_entitlement IS NULL
7569 AND
7570 p_level_of_pay IS NULL
7571 )
7572 );
7573
7574
7575 CURSOR csr_last_day
7576 (p_gap_absence_plan_id IN NUMBER
7577 ,p_level_of_entitlement IN VARCHAR2 DEFAULT NULL
7578 ,p_level_of_pay IN VARCHAR2 DEFAULT NULL
7579 ) IS
7580 SELECT MAX(gda.absence_date) abs_date
7581 FROM pqp_gap_daily_absences gda
7582 WHERE gda.gap_absence_plan_id = p_gap_absence_plan_id
7583 AND ( ( p_level_of_entitlement IS NOT NULL
7584 AND
7585 gda.level_of_entitlement = p_level_of_entitlement
7586 )
7587 OR
7588 ( p_level_of_pay IS NOT NULL
7589 AND
7590 gda.level_of_pay = p_level_of_pay
7591 )
7592 );
7593
7594
7595 l_boundary_date DATE;
7596
7597 BEGIN
7598 g_debug := hr_utility.debug_enabled;
7599
7600 IF g_debug then
7601 debug('p_absence_attendance_id:'||p_absence_attendance_id);
7602 debug('p_pl_id:'||p_pl_id);
7603 debug('p_first_of_last'|| p_first_of_last);
7604 debug('p_level_of_entitlement' ||p_level_of_entitlement);
7605 debug('p_level_of_pay' ||p_level_of_pay);
7606 END IF;
7607 IF g_debug THEN
7608 debug_enter(l_proc_name);
7609 END IF;
7610
7611 OPEN csr_gap_absence_plan
7612 (p_absence_attendance_id
7613 ,p_pl_id
7614 );
7615 FETCH csr_gap_absence_plan INTO l_gap_absence_plan;
7616
7617 l_proc_step := 10;
7618 IF g_debug THEN
7619 debug(l_proc_name,l_proc_step);
7620 END IF;
7621
7622 IF csr_gap_absence_plan%FOUND
7623 THEN
7624
7625 l_proc_step := 15;
7626 IF g_debug THEN
7627 debug(l_proc_name,l_proc_step);
7628 debug(p_first_of_last);
7629 END IF;
7630
7631 IF p_first_of_last = 'LAST'
7632 THEN
7633
7634 IF p_level_of_entitlement IS NOT NULL
7635 OR
7636 p_level_of_pay IS NOT NULL
7637 THEN
7638
7639 OPEN csr_last_day
7640 (p_gap_absence_plan_id => l_gap_absence_plan.id
7641 ,p_level_of_entitlement => p_level_of_entitlement
7642 ,p_level_of_pay => p_level_of_pay
7643 );
7644 FETCH csr_last_day INTO l_boundary_date;
7645 CLOSE csr_last_day;
7646
7647 ELSE
7648
7649 l_boundary_date := l_gap_absence_plan.last_gap_daily_absence_date;
7650
7651 END IF; -- IF p_level_of_entitlement IS NOT NULL
7652
7653
7654 ELSE -- p_first_of_last = 'FIRST'
7655
7656 OPEN csr_first_day
7657 (p_gap_absence_plan_id => l_gap_absence_plan.id
7658 ,p_level_of_entitlement => p_level_of_entitlement
7659 ,p_level_of_pay => p_level_of_pay
7660 );
7661 FETCH csr_first_day INTO l_boundary_date;
7662 CLOSE csr_first_day;
7663
7664 END IF;
7665
7666
7667 END IF;
7668 CLOSE csr_gap_absence_plan;
7669
7670 l_proc_step := 20;
7671 IF g_debug THEN
7672 debug(l_proc_name,l_proc_step);
7673 END IF;
7674
7675 IF l_boundary_date IS NULL
7676 THEN
7677 -- Don't return NULL as fast formulas don't like them
7678 l_proc_step := 25;
7679 IF g_debug THEN
7680 debug(l_proc_name,l_proc_step);
7681 END IF;
7682
7683 l_boundary_date := hr_api.g_eot;
7684
7685 END IF;
7686
7687 IF g_debug THEN
7688 debug_exit(l_proc_name);
7689 END IF;
7690 RETURN l_boundary_date;
7691
7692
7693 EXCEPTION
7694 WHEN OTHERS THEN
7695 clear_cache;
7696 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
7697 debug_others(l_proc_name,l_proc_step);
7698 IF g_debug THEN
7699 debug('Leaving: '||l_proc_name,-999);
7700 END IF;
7701 fnd_message.raise_error;
7702 ELSE
7703 RAISE;
7704 END IF;
7705 END get_boundary_dates;
7706 --
7707 --
7708 --
7709 FUNCTION get_first_paid_day
7710 (p_absence_attendance_id IN NUMBER
7711 ,p_pl_id IN NUMBER
7712 ,p_level_of_pay IN VARCHAR2 DEFAULT NULL
7713 ) RETURN DATE
7714 IS
7715
7716 g_debug BOOLEAN;
7717
7718 l_proc_step NUMBER(38,10):=0;
7719 l_proc_name VARCHAR2(61):=
7720 g_package_name||'get_first_paid_day';
7721
7722 l_boundary_date DATE;
7723
7724 BEGIN
7725 g_debug := hr_utility.debug_enabled;
7726
7727 IF g_debug THEN
7728 debug_enter(l_proc_name);
7729 debug('p_absence_attendance_id:'||p_absence_attendance_id);
7730 debug('p_pl_id:'||p_pl_id);
7731 debug('p_level_of_pay' || p_level_of_pay);
7732 END IF;
7733
7734
7735 l_boundary_date :=
7736 get_boundary_dates
7737 (p_absence_attendance_id => p_absence_attendance_id
7738 ,p_pl_id => p_pl_id
7739 ,p_first_of_last => 'FIRST'
7740 ,p_level_of_pay => p_level_of_pay
7741 );
7742
7743 IF g_debug THEN
7744 debug_exit(l_proc_name);
7745 END IF;
7746 RETURN l_boundary_date;
7747
7748
7749 EXCEPTION
7750 WHEN OTHERS THEN
7751 clear_cache;
7752 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
7753 debug_others(l_proc_name,l_proc_step);
7754 IF g_debug THEN
7755 debug('Leaving: '||l_proc_name,-999);
7756 END IF;
7757 fnd_message.raise_error;
7758 ELSE
7759 RAISE;
7760 END IF;
7761 END get_first_paid_day;
7762 --
7763 --
7764 --
7765 FUNCTION get_last_paid_day
7766 (p_absence_attendance_id IN NUMBER
7767 ,p_pl_id IN NUMBER
7768 ,p_level_of_pay IN VARCHAR2 DEFAULT NULL
7769 ) RETURN DATE
7770 IS
7771
7772 g_debug BOOLEAN;
7773
7774 l_proc_step NUMBER(38,10):=0;
7775 l_proc_name VARCHAR2(61):=
7776 g_package_name||'get_last_paid_day';
7777
7778 l_boundary_date DATE;
7779
7780 BEGIN
7781 g_debug := hr_utility.debug_enabled;
7782 IF g_debug THEN
7783 debug_enter(l_proc_name);
7784 debug('p_absence_attendance_id:'||p_absence_attendance_id);
7785 debug('p_pl_id:'||p_pl_id);
7786 debug('p_level_of_pay' || p_level_of_pay);
7787 END IF;
7788
7789 IF g_debug THEN
7790 debug_enter(l_proc_name);
7791 END IF;
7792
7793 l_boundary_date :=
7794 get_boundary_dates
7795 (p_absence_attendance_id => p_absence_attendance_id
7796 ,p_pl_id => p_pl_id
7797 ,p_first_of_last => 'LAST'
7798 ,p_level_of_pay => p_level_of_pay
7799 );
7800
7801 IF g_debug THEN
7802 debug_exit(l_proc_name);
7803 END IF;
7804 RETURN l_boundary_date;
7805
7806
7807 EXCEPTION
7808 WHEN OTHERS THEN
7809 clear_cache;
7810 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
7811 debug_others(l_proc_name,l_proc_step);
7812 IF g_debug THEN
7813 debug('Leaving: '||l_proc_name,-999);
7814 END IF;
7815 fnd_message.raise_error;
7816 ELSE
7817 RAISE;
7818 END IF;
7819 END get_last_paid_day;
7820 --
7821 --
7822 --
7823 FUNCTION get_first_entitled_day
7824 (p_absence_attendance_id IN NUMBER
7825 ,p_pl_id IN NUMBER
7826 ,p_level_of_entitlement IN VARCHAR2 DEFAULT NULL
7827 ) RETURN DATE
7828 IS
7829
7830 g_debug BOOLEAN;
7831
7832 l_proc_step NUMBER(38,10):=0;
7833 l_proc_name VARCHAR2(61):=
7834 g_package_name||'get_first_entitled_day';
7835
7836 l_boundary_date DATE;
7837
7838 BEGIN
7839 g_debug := hr_utility.debug_enabled;
7840 IF g_debug THEN
7841 debug_enter(l_proc_name);
7842 debug('p_absence_attendance_id:'||p_absence_attendance_id);
7843 debug('p_pl_id:'||p_pl_id);
7844 debug('p_level_of_entitlement' || p_level_of_entitlement);
7845 END IF;
7846
7847 IF g_debug THEN
7848 debug_enter(l_proc_name);
7849 END IF;
7850
7851
7852 l_boundary_date :=
7853 get_boundary_dates
7854 (p_absence_attendance_id => p_absence_attendance_id
7855 ,p_pl_id => p_pl_id
7856 ,p_first_of_last => 'FIRST'
7857 ,p_level_of_entitlement => p_level_of_entitlement
7858 );
7859
7860 IF g_debug THEN
7861 debug_exit(l_proc_name);
7862 END IF;
7863 RETURN l_boundary_date;
7864
7865
7866 EXCEPTION
7867 WHEN OTHERS THEN
7868 clear_cache;
7869 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
7870 debug_others(l_proc_name,l_proc_step);
7871 IF g_debug THEN
7872 debug('Leaving: '||l_proc_name,-999);
7873 END IF;
7874 fnd_message.raise_error;
7875 ELSE
7876 RAISE;
7877 END IF;
7878 END get_first_entitled_day;
7879 --
7880 --
7881 --
7882 FUNCTION get_last_entitled_day
7883 (p_absence_attendance_id IN NUMBER
7884 ,p_pl_id IN NUMBER
7885 ,p_level_of_entitlement IN VARCHAR2 DEFAULT NULL
7886 ) RETURN DATE
7887 IS
7888
7889 g_debug BOOLEAN;
7890
7891 l_proc_step NUMBER(38,10):=0;
7892 l_proc_name VARCHAR2(61):=
7893 g_package_name||'get_last_entitled_day';
7894
7895 l_boundary_date DATE;
7896
7897 BEGIN
7898 g_debug := hr_utility.debug_enabled;
7899 IF g_debug THEN
7900 debug_enter(l_proc_name);
7901 debug('p_absence_attendance_id:'||p_absence_attendance_id);
7902 debug('p_pl_id:'||p_pl_id);
7903 debug('p_level_of_entitlement' || p_level_of_entitlement);
7904 END IF;
7905
7906 IF g_debug THEN
7907 debug_enter(l_proc_name);
7908 END IF;
7909
7910
7911 l_boundary_date :=
7912 get_boundary_dates
7913 (p_absence_attendance_id => p_absence_attendance_id
7914 ,p_pl_id => p_pl_id
7915 ,p_first_of_last => 'LAST'
7916 ,p_level_of_entitlement => p_level_of_entitlement
7917 );
7918
7919 IF g_debug THEN
7920 debug_exit(l_proc_name);
7921 END IF;
7922 RETURN l_boundary_date;
7923
7924
7925 EXCEPTION
7926 WHEN OTHERS THEN
7927 clear_cache;
7928 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
7929 debug_others(l_proc_name,l_proc_step);
7930 IF g_debug THEN
7931 debug('Leaving: '||l_proc_name,-999);
7932 END IF;
7933 fnd_message.raise_error;
7934 ELSE
7935 RAISE;
7936 END IF;
7937 END get_last_entitled_day;
7938 --
7939 --
7940 --
7941 PROCEDURE chk_override_entitlements -- AI and AU USER HOOK PROC pqpeihcd.sql
7942 (p_person_extra_info_id IN NUMBER
7943 ,p_person_id IN NUMBER
7944 ,p_information_type IN VARCHAR2
7945 ,p_pei_information_category IN VARCHAR2
7946 ,p_pei_information1 IN VARCHAR2 -- override_start_date
7947 ,p_pei_information2 IN VARCHAR2 -- override_end_date
7948 ,p_pei_information3 IN VARCHAR2 -- plan id
7949 ,p_pei_information11 IN VARCHAR2 -- band1
7950 ,p_pei_information12 IN VARCHAR2 -- band2
7951 ,p_pei_information13 IN VARCHAR2 -- band3
7952 ,p_pei_information14 IN VARCHAR2 -- band4
7953 )
7954 IS
7955
7956 CURSOR csr_other_override_rows
7957 (p_person_id IN NUMBER
7958 ,p_information_type IN VARCHAR2
7959 ,p_person_extra_info_id IN NUMBER
7960 ,p_pei_information3 IN VARCHAR2 -- plan id
7961 ) IS
7962 SELECT pei_information1 override_start_date_txt
7963 ,pei_information2 override_end_date_txt
7964 ,pei_information3 pl_id_txt
7965 FROM per_people_extra_info pei
7966 WHERE pei.person_id = p_person_id
7967 AND pei.information_type = p_information_type
7968 AND pei.pei_information3 = p_pei_information3 -- fetch rows of same plan
7969 AND pei.person_extra_info_id <> p_person_extra_info_id;
7970
7971 --CURSOR csr_plan_type
7972 -- (p_pl_id IN NUMBER
7973 -- ) IS
7974 --SELECT pl_typ_id
7975 --FROM ben_pl_f
7976 --WHERE pl_id = p_pl_id
7977 -- AND ROWNUM < 2; -- any effective one
7978 -- cannot reason out date track changes in plan types
7979
7980 --l_other_override_rows csr_other_override_rows%ROWTYPE:
7981 l_override_start_date DATE;
7982 l_override_end_date DATE;
7983 --l_override_pl_id ben_pl_f.pl_id%TYPE;
7984 --l_override_pl_typ_id ben_pl_f.pl_typ_id%TYPE;
7985
7986 l_other_override_start_date DATE;
7987 l_other_override_end_date DATE;
7988 --l_other_override_pl_id ben_pl_f.pl_id%TYPE;
7989 --l_other_override_pl_typ_id ben_pl_f.pl_typ_id%TYPE;
7990
7991 l_loop_counter BINARY_INTEGER:= 0;
7992
7993 l_proc_step NUMBER(38,10);
7994 l_proc_name VARCHAR2(61):=
7995 g_package_name||'chk_override_entitlements';
7996
7997 BEGIN
7998 --
7999 -- Added for GSI Bug 5472781
8000 --
8001 IF hr_utility.chk_product_install('Oracle Human Resources', 'GB') THEN
8002 --
8003 g_debug := hr_utility.debug_enabled;
8004
8005 IF g_debug THEN
8006 debug_enter(l_proc_name);
8007 debug('p_person_extra_info_id:'||p_person_extra_info_id);
8008 debug('p_person_id:'||p_person_id);
8009 END IF;
8010
8011 -- things to validate
8012 -- the following validations are only required for GAP information type
8013 -- 1. start date and end date are valid, ie end date >= start date
8014 -- explicit format validation not required as this info is comingt thru UI
8015 -- 2. the date range does not overlap with any other existing row
8016
8017
8018 IF p_information_type = 'PQP_GB_GAP_ENTITLEMENT_INFO'
8019 THEN
8020
8021 l_proc_step := 10;
8022 IF g_debug THEN
8023 debug(l_proc_name, l_proc_step);
8024 END IF;
8025 -- if there are format errors it will bomb out in the next
8026 -- two statements
8027 l_override_start_date :=
8028 fnd_date.canonical_to_date(p_pei_information1);
8029
8030 l_override_end_date :=
8031 fnd_date.canonical_to_date(p_pei_information2);
8032
8033 --l_override_pl_id :=
8034 -- fnd_number.canonical_to_number(p_pei_information3);
8035
8036 IF g_debug THEN
8037 debug('p_pei_information1:'||p_pei_information1);
8038 debug('p_pei_information2:'||p_pei_information2);
8039 debug('p_pei_information3:'||p_pei_information3);
8040 END IF;
8041
8042 IF l_override_end_date < l_override_start_date
8043 THEN
8044 l_proc_step := 15;
8045 IF g_debug THEN
8046 debug(l_proc_name, l_proc_step);
8047 END IF;
8048 fnd_message.set_name('PQP','PQP_230617_END_GE_START');
8049 --fnd_message.set_token('START',p_pei_information1);
8050 --fnd_message.set_token('END',p_pei_information2);
8051 fnd_message.raise_error;
8052 END IF;
8053
8054 l_proc_step := 20;
8055 IF g_debug THEN
8056 debug(l_proc_name, l_proc_step);
8057 END IF;
8058
8059 FOR r_other_override_row IN
8060 csr_other_override_rows -- fetch
8061 (p_person_id => p_person_id -- person extra info rows
8062 ,p_information_type => p_information_type -- of osp override type
8063 ,p_person_extra_info_id => p_person_extra_info_id -- other rows <> match
8064 ,p_pei_information3 => p_pei_information3 -- of the same plan
8065 )
8066 LOOP
8067 l_loop_counter:= l_loop_counter + 1;
8068
8069 l_proc_step := 20;
8070 IF g_debug THEN
8071 debug(l_proc_name, l_proc_step+(l_loop_counter/100000));
8072 END IF;
8073
8074 l_other_override_start_date :=
8075 fnd_date.canonical_to_date(r_other_override_row.override_start_date_txt);
8076
8077 l_other_override_end_date :=
8078 fnd_date.canonical_to_date(r_other_override_row.override_end_date_txt);
8079
8080 --l_other_override_pl_id :=
8081 -- fnd_number.canonical_to_number(r_other_override_row.pl_id_txt);
8082
8083 IF ( l_override_start_date -- |---------|
8084 BETWEEN l_other_override_start_date -- |-------------|
8085 AND l_other_override_end_date -- |---------|
8086 ) -- |---|
8087 OR
8088 ( l_override_end_date -- |---------|
8089 BETWEEN l_other_override_start_date -- |-------------|
8090 AND l_other_override_end_date -- |-------|
8091 ) -- |---|
8092 OR
8093 ( l_other_override_start_date -- |---------|
8094 BETWEEN l_override_start_date -- |-----------------|
8095 AND l_override_end_date -- |-------------|
8096 ) -- |---------|
8097 OR
8098 ( l_other_override_end_date -- |---------|
8099 BETWEEN l_override_start_date -- |-----------------|
8100 AND l_override_end_date -- |-------------|
8101 ) -- |---------|
8102 THEN
8103 -- the row currently being inserted or updated overlaps with an existing row
8104 -- and belongs to the same plan , raise erro
8105 -- same plan type check -- NOT IMPLEMENTED
8106
8107 l_proc_step := 25;
8108 IF g_debug THEN
8109 debug(l_proc_name, l_proc_step+(l_loop_counter/100000));
8110 END IF;
8111
8112 -- check if they are of the same plan type -- NOT IMPLEMENTED
8113 -- unless the plans are of the same plan type
8114 -- its ok to have an overlap because the absence types of one
8115 -- do not contribute to the balance of the other
8116 -- if they are the same then
8117 --OPEN csr_plan_type(l_override_pl_id);
8118 --FETCH csr_plan_type INTO l_override_pl_typ_id;
8119 --CLOSE csr_plan_type;
8120
8121 --OPEN csr_plan_type(l_other_override_pl_id);
8122 --FETCH csr_plan_type INTO l_other_override_pl_typ_id;
8123 --CLOSE csr_plan_type;
8124
8125 --IF l_other_override_pl_id = l_override_pl_id
8126 --THEN
8127 fnd_message.set_name('PQP','PQP_230010_PLAN_OVRRIDE_OVRLAP');
8128
8129 --fnd_message.set_token('CURRSTART',p_pei_information1);
8130 --fnd_message.set_token('CURREND',p_pei_information2);
8131 --fnd_message.set_token('OTHERSTART',r_other_override_row.override_start_date_txt);
8132 --fnd_message.set_token('OTHEREND',r_other_override_row.override_end_date_txt);
8133
8134 -- Changed Tokens to refer to Date in Date Format rather
8135 -- Canonical Format for Bug : 3110889
8136 fnd_message.set_token('CURRSTART',l_override_start_date);
8137 fnd_message.set_token('CURREND',l_override_end_date);
8138 fnd_message.set_token('OTHERSTART',l_other_override_start_date);
8139 fnd_message.set_token('OTHEREND',l_other_override_end_date);
8140 fnd_message.raise_error;
8141 --END IF;
8142
8143 END IF;
8144
8145 END LOOP;
8146
8147 l_proc_step := 30;
8148 IF g_debug THEN
8149 debug(l_proc_name, l_proc_step);
8150 END IF;
8151
8152 END IF;
8153
8154 IF g_debug THEN
8155 debug_exit(l_proc_name);
8156 END IF;
8157 END IF;
8158 END chk_override_entitlements;
8159 --
8160 --
8161 --
8162 FUNCTION get_num_of_ssp_qualifying_days
8163 (p_business_group_id IN NUMBER
8164 ,p_person_id IN NUMBER
8165 ,p_schedule_start_date IN DATE
8166 ,p_schedule_end_date IN DATE
8167 ) RETURN NUMBER
8168 IS
8169
8170
8171 l_calendar_usages csr_calendar_usages%ROWTYPE;
8172 l_hr_scheduler_v_count BINARY_INTEGER;
8173
8174 l_num_of_ssp_qualifying_days NUMBER:= 0;
8175
8176 l_proc_step NUMBER(38,10);
8177 l_proc_name VARCHAR2(61):=
8178 g_package_name||'get_num_of_ssp_qualifying_days';
8179
8180
8181 BEGIN
8182
8183 IF g_debug THEN
8184 debug_enter(l_proc_name);
8185 debug('p_business_group_id:'||p_business_group_id);
8186 debug('p_person_id:'||p_person_id);
8187 debug('p_schedule_start_date'|| p_schedule_start_date);
8188 debug('p_schedule_end_date'|| p_schedule_end_date);
8189 END IF;
8190
8191 OPEN csr_calendar_usages
8192 ('PERSON' --2 -- Person Type Usage
8193 ,p_person_id
8194 ,p_schedule_start_date);
8195 FETCH csr_calendar_usages INTO l_calendar_usages;
8196 IF csr_calendar_usages%NOTFOUND THEN -- person level usage does not exist
8197 l_proc_step := 10;
8198 IF g_debug THEN
8199 debug(l_proc_name,l_proc_step);
8200 END IF;
8201 CLOSE csr_calendar_usages;
8202 OPEN csr_calendar_usages
8203 ('ORGANIZATION' --1 -- Business Group Type Usage
8204 ,p_business_group_id
8205 ,p_schedule_start_date);
8206 FETCH csr_calendar_usages INTO l_calendar_usages;
8207 END IF;
8208 CLOSE csr_calendar_usages;
8209
8210 --
8211 -- if you want to hr_scheduler_v and need to know the number
8212 -- of days between date1 and date2 , invoke the denormalise
8213 -- procedure for date1 and date2+1, then count sum(end_date-start_date)
8214 -- where availablity is QUALIFYING
8215 --
8216
8217
8218 hr_calendar_pkg.denormalise_calendar
8219 (p_purpose_usage_id => l_calendar_usages.purpose_usage_id
8220 ,p_primary_key_value => l_calendar_usages.primary_key_value
8221 ,p_period_from => p_schedule_start_date
8222 ,p_period_to => p_schedule_end_date + 1
8223 );
8224
8225 l_proc_step := 20;
8226 IF g_debug THEN
8227 debug(l_proc_name,l_proc_step);
8228 END IF;
8229
8230 -- This view is non performant as it has cartesian join on fnd_common_lookups
8231 -- SELECT NVL(SUM(TRUNC(sch.end_date) - TRUNC(sch.start_date)),0)
8232 -- INTO l_num_of_ssp_qualifying_days
8233 -- FROM hr_scheduler_v sch
8234 -- WHERE availability = 'QUALIFYING';
8235 --
8236 -- expanding the hr_scheduler_v view
8237 -- SELECT hr_calendar_pkg.start_date(ROWNUM)
8238 -- ,TO_CHAR(hr_calendar_pkg.start_date(ROWNUM), 'HH24:MI')
8239 -- ,hr_calendar_pkg.end_date(ROWNUM)
8240 -- ,TO_CHAR(hr_calendar_pkg.end_date(ROWNUM), 'HH24:MI')
8241 -- ,SUBSTR(hr_calendar_pkg.availability_value(ROWNUM), 1, 80)
8242 -- ,hr_calendar_pkg.schedule_level_value(ROWNUM)
8243 -- FROM fnd_common_lookups, /* -- NB THE CARTESIAN JOIN IS DELIBERATE!!!!! */
8244 -- fnd_common_lookups
8245 -- WHERE ROWNUM <= hr_calendar_pkg.schedule_rowcount
8246 --APPS@hrukps:SQL>desc hr_scheduler_v
8247 --Name Null? Type
8248 --------------------------------- -------- ----
8249 --START_DATE DATE
8250 --START_TIME VARCHAR2(5)
8251 --END_DATE DATE
8252 --END_TIME VARCHAR2(5)
8253 --AVAILABILITY VARCHAR2(80)
8254 --SCHEDULE_LEVEL NUMBER
8255 --
8256 -- replace above logic with a plsql for loop
8257 -- for 1 to hr_calendar_pkg.schedule_rowcount
8258 -- the view had a cartesian join hence performance problems
8259 l_hr_scheduler_v_count := hr_calendar_pkg.schedule_rowcount;
8260 FOR i IN 1..l_hr_scheduler_v_count
8261 LOOP
8262 IF hr_calendar_pkg.availability_value(i) = 'QUALIFYING' THEN
8263 l_num_of_ssp_qualifying_days :=
8264 l_num_of_ssp_qualifying_days +
8265 NVL(TRUNC(hr_calendar_pkg.end_date(i)) - TRUNC(hr_calendar_pkg.start_date(i)),0);
8266 END IF;
8267 END LOOP;
8268 -- no date range needed, never use this view without doing the
8269 -- denormalize first for the require date range
8270
8271 IF g_debug THEN
8272 debug('l_num_of_ssp_qualifying_days:'||to_char(l_num_of_ssp_qualifying_days));
8273 debug_exit(l_proc_name);
8274 END IF;
8275
8276 RETURN l_num_of_ssp_qualifying_days;
8277
8278 EXCEPTION
8279 WHEN OTHERS THEN
8280 clear_cache;
8281 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
8282 debug_others(l_proc_name,l_proc_step);
8283 IF g_debug THEN
8284 debug('Leaving: '||l_proc_name,-999);
8285 END IF;
8286 fnd_message.raise_error;
8287 ELSE
8288 RAISE;
8289 END IF;
8290 END get_num_of_ssp_qualifying_days;
8291 --
8292 --
8293 --
8294 FUNCTION get_number_of_overlap_ssp_days
8295 (p_business_group_id IN NUMBER
8296 ,p_person_id IN NUMBER
8297 ,p_piw_id IN NUMBER
8298 ,p_withheld_days IN NUMBER
8299 ,p_overlap_range_start_date IN DATE
8300 ,p_overlap_range_end_date IN DATE
8301 ) RETURN NUMBER
8302 IS
8303
8304 -- pickup only those stoppages which are
8305 -- |stoppages|
8306 -- wf wt
8307 -- |----range----| -- completely included in the range
8308 -- rs re
8309 -- |-range-| -- or partially overlap with the range
8310 -- rs re
8311 -- |-range-| -- or partially overlap with the range
8312 -- rs re
8313 --
8314 --
8315 -- OR in other words
8316 --
8317 -- do not pickup those stoppages which are
8318 -- |stoppages|
8319 -- wf wt
8320 -- |--range--| -- are exactly equal ie no overlap days as they are all withheld
8321 -- rs re
8322 -- |range| -- or the range is completely included in the stoppage range
8323 -- |range|
8324 -- |range|
8325 -- rsre
8326 -- |rg|-- or do not overlap at all with range
8327 -- |rg|
8328 -- rsre
8329
8330 CURSOR csr_ssp_stoppages
8331 (p_piw_id IN NUMBER
8332 ) IS
8333 SELECT withhold_from
8334 ,NVL(withhold_to,withhold_from) withhold_to
8335 FROM ssp_stoppages
8336 WHERE absence_attendance_id = p_piw_id --index confirmed -- need not cache
8337 AND override_stoppage = 'N';
8338
8339
8340 l_number_of_overlap_ssp_days NUMBER:= 0;
8341 l_num_of_qualifying_stop_days NUMBER:= 0;
8342 l_num_of_range_qualifying_days NUMBER:= 0;
8343 l_all_range_days_are_withheld BOOLEAN:= FALSE;
8344
8345 l_proc_step NUMBER(38,10);
8346 l_proc_name VARCHAR2(61):=
8347 g_package_name||'get_number_of_overlap_ssp_days';
8348
8349
8350 BEGIN
8351
8352 IF g_debug THEN
8353 debug_enter(l_proc_name);
8354 END IF;
8355
8356 /*
8357 To get the number of qualfying days between any two dates we need to
8358 1. know the qual pattern to use
8359 2. know the start "day" of the qual pattern
8360 3. know any exceptions marked for that period
8361 4. know any stoppages marked for that period
8362 */
8363
8364 /*
8365 the dates we recieve in this function are the overlap range period
8366 for that week.
8367
8368 we are in this function because there was a partial overlap
8369
8370 */
8371
8372
8373 --IF p_withheld_days > 0 -- there are some stoppages in the week
8374 --THEN
8375 -- there are some stoppages in this week
8376 -- 1. do they overlap with requesed period
8377 -- if so determine the number of qual days in the stoppage period
8378 --
8379 --
8380 -- waiting days bug:
8381 -- when the only stoppages in the system are waiting days then
8382 -- withheld_days is 0 hence we need to check for stoppages for
8383 -- every element entry
8384 -- the reason we cannot do a simple count is because
8385 -- a single waiting day stoppage may be applied for several days
8386 -- the only way to count a stoppage is to take the diff between
8387 -- the end date and the start date (if there is an overlap)
8388 -- and then count the number of qualifying days between them
8389 --
8390 -- this check will need to be done for every partially overlapping
8391 -- partially overlapping entries are likely to occur only once or
8392 -- twice within the "expected" range that get...ssp will be invoked
8393 -- for. hence no particular significance of caching
8394 --
8395 -- the index on ssp_stoppages.absence_attendance_id has now been
8396 -- confirmed.
8397 --
8398 l_proc_step := 10;
8399 IF g_debug THEN
8400 debug(l_proc_name,l_proc_step);
8401 END IF;
8402
8403 FOR r_ssp_stoppage IN csr_ssp_stoppages(p_piw_id)
8404 LOOP
8405 -- the only rows that will be selected
8406 -- will be the ones which have a partial overlap
8407 -- or where the stoppage is completely included
8408 -- in the range (but not equal ones)
8409 -- so we don't need the following IF NOT check
8410
8411 l_proc_step := 15;
8412 IF g_debug THEN
8413 debug(l_proc_name,l_proc_step);
8414 END IF;
8415
8416 IF NOT
8417 (
8418 ( p_overlap_range_start_date >= r_ssp_stoppage.withhold_from -- |withhold|
8419 AND -- |--rnge--|
8420 p_overlap_range_end_date <= r_ssp_stoppage.withhold_to -- |rnge|
8421 )
8422 OR
8423 ( p_overlap_range_start_date > r_ssp_stoppage.withhold_to -- |withhold|
8424 OR -- |range|
8425 p_overlap_range_end_date < r_ssp_stoppage.withhold_from -- |range|
8426 )
8427 )
8428 THEN
8429
8430 l_proc_step := 20;
8431 IF g_debug THEN
8432 debug(l_proc_name,l_proc_step);
8433 END IF;
8434 -- its a partial overlap between the stoppage
8435 -- and the period for which we are trying to find ssp qual days
8436
8437 -- determines the number of qual days in this period as this will
8438 -- be deducted from the total number of qual days for the given range
8439
8440 IF g_debug THEN
8441 debug('stoppages_overlap_start_date:'||
8442 GREATEST(r_ssp_stoppage.withhold_from,p_overlap_range_start_date));
8443 debug('stoppages_overlap_end_date:'||
8444 LEAST(r_ssp_stoppage.withhold_to,p_overlap_range_end_date));
8445 debug('l_num_of_qualifying_stop_days:'||l_num_of_qualifying_stop_days);
8446 END IF;
8447
8448 l_num_of_qualifying_stop_days := l_num_of_qualifying_stop_days +
8449 get_num_of_ssp_qualifying_days
8450 (p_business_group_id
8451 ,p_person_id
8452 ,GREATEST(r_ssp_stoppage.withhold_from,p_overlap_range_start_date)
8453 ,LEAST(r_ssp_stoppage.withhold_to,p_overlap_range_end_date)
8454 );
8455
8456 l_proc_step := 25;
8457 IF g_debug THEN
8458 debug(l_proc_name,l_proc_step);
8459 debug('l_num_of_qualifying_stop_days:'||l_num_of_qualifying_stop_days);
8460 END IF;
8461
8462 ELSE
8463 -- two possiblities
8464 -- the stoppage does not overlap with the given period
8465 -- or the stoppage completely covers the period
8466 -- if the latter then save on performance by not checking
8467 -- for number_of_ssp_qual_days as all have been Stoppaged !
8468 l_proc_step := 30;
8469 IF g_debug THEN
8470 debug(l_proc_name,l_proc_step);
8471 END IF;
8472
8473 IF ( p_overlap_range_start_date >= r_ssp_stoppage.withhold_from -- |withhold|
8474 AND -- |--rnge--|
8475 p_overlap_range_end_date <= r_ssp_stoppage.withhold_to -- |rnge|
8476 )
8477 THEN
8478
8479 l_proc_step := 35;
8480 IF g_debug THEN
8481 debug(l_proc_name,l_proc_step);
8482 END IF;
8483 -- withhold completely covers the range overlap
8484 -- in which case set a flag so that num of ssp days can be returned
8485 -- as 0 without any further processing
8486
8487 l_all_range_days_are_withheld := TRUE;
8488 EXIT; -- this for loop all days are withheld by this stoppage no need
8489 -- to examine other stoppages
8490
8491 --ELSE
8492 -- there is no overlap, continue with the next stoppage if any
8493
8494 END IF; -- IF ( p_overlap_range_start_date >= r_ssp_stoppage.withhold_from
8495
8496 END IF; -- IF NOT
8497
8498 END LOOP; -- FOR r_ssp_stoppage IN csr_ssp_stoppages(p_piw_id)
8499
8500 IF csr_ssp_stoppages%ISOPEN THEN
8501 l_proc_step := 37;
8502 IF g_debug THEN
8503 debug(l_proc_name,l_proc_step);
8504 END IF;
8505 CLOSE csr_ssp_stoppages;
8506 END IF;
8507
8508
8509 --END IF; -- IF p_withheld_days > 0
8510
8511 l_proc_step := 40;
8512 IF g_debug THEN
8513 debug(l_proc_name,l_proc_step);
8514 END IF;
8515
8516 IF NOT l_all_range_days_are_withheld -- by default false
8517 THEN
8518
8519 l_proc_step := 45;
8520 IF g_debug THEN
8521 debug(l_proc_name,l_proc_step);
8522 debug('l_num_of_qualifying_stop_days:'||l_num_of_qualifying_stop_days);
8523 END IF;
8524
8525 l_num_of_range_qualifying_days :=
8526 get_num_of_ssp_qualifying_days
8527 (p_business_group_id
8528 ,p_person_id
8529 ,p_overlap_range_start_date
8530 ,p_overlap_range_end_date
8531 );
8532
8533 IF g_debug THEN
8534 debug('l_num_of_range_qualifying_days:'||l_num_of_range_qualifying_days);
8535 END IF;
8536
8537 l_number_of_overlap_ssp_days :=
8538 l_num_of_range_qualifying_days - l_num_of_qualifying_stop_days;
8539
8540 -- ELSE
8541 -- l_number_of_overlap_ssp_days := 0;
8542
8543 l_proc_step := 50;
8544 IF g_debug THEN
8545 debug(l_proc_name,l_proc_step);
8546 END IF;
8547
8548 END IF; -- IF NOT l_all_range_days_are_withheld
8549
8550
8551 IF g_debug THEN
8552 debug('l_number_of_overlap_ssp_days:'||l_number_of_overlap_ssp_days);
8553 debug_exit(l_proc_name);
8554 END IF;
8555
8556 RETURN l_number_of_overlap_ssp_days;
8557
8558 EXCEPTION
8559 WHEN OTHERS THEN
8560 clear_cache;
8561 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
8562 debug_others(l_proc_name,l_proc_step);
8563 IF g_debug THEN
8564 debug('Leaving: '||l_proc_name,-999);
8565 END IF;
8566 fnd_message.raise_error;
8567 ELSE
8568 RAISE;
8569 END IF;
8570 END get_number_of_overlap_ssp_days;
8571 --
8572 --
8573 --
8574 FUNCTION get_ssp_entry_overlap_amount
8575 (p_business_group_id IN NUMBER
8576 ,p_person_id IN NUMBER
8577 ,p_piw_id IN NUMBER
8578 ,p_ssp_week_entry IN csr_ssp_entries%ROWTYPE
8579 ,p_range_start_date IN DATE
8580 ,p_range_end_date IN DATE
8581 ) RETURN NUMBER
8582 IS
8583
8584 l_overlap_amount NUMBER:= 0;
8585 l_ssp_daily_rate NUMBER:= 0;
8586 l_number_of_overlap_ssp_days NUMBER:= 0;
8587
8588 l_proc_step NUMBER(38,10);
8589 l_proc_name VARCHAR2(61):=
8590 g_package_name||'get_ssp_entry_overlap_amount';
8591
8592 BEGIN
8593 /*
8594 6. For every determine, determine the extent of overlap with the relevant period range
8595 7. For entries which are completely overlapped add the "amount"
8596 8. For entries which overlap partially, pro-rate based on the relevant qualifying pattern.
8597 9. SSP Daily Rate = Amount / SSP Days Due
8598 10. Amount to include = SSP Daily Rate * Number of Qual days in overlap period
8599 11. Number of qual days in overlap period = Loop thru the days in the element entry
8600 */
8601
8602 IF g_debug THEN
8603 debug_enter(l_proc_name);
8604 END IF;
8605
8606
8607 IF NOT
8608 ( -- if not a complete overlap
8609 ( p_ssp_week_entry.date_from >= p_range_start_date -- |range|
8610 AND -- |sspwk|
8611 p_ssp_week_entry.date_to <= p_range_end_date -- |swk|
8612 ) -- df dt
8613 OR -- or not a complete overlap
8614 ( p_ssp_week_entry.date_from > p_range_end_date -- |range| df
8615 OR -- rs re |sspwk|
8616 p_ssp_week_entry.date_to < p_range_start_date -- |sspwk|
8617 ) -- dt
8618 )
8619 THEN
8620 -- its a partial overlap
8621
8622 l_proc_step := 15;
8623 IF g_debug THEN
8624 debug(l_proc_name,l_proc_step);
8625 END IF;
8626
8627 l_ssp_daily_rate :=
8628 p_ssp_week_entry.amount /
8629 ABS(p_ssp_week_entry.ssp_days_due - p_ssp_week_entry.withheld_days);
8630
8631
8632
8633 --
8634 -- 37.32 :=
8635 -- 62.20 /
8636 -- ( 5 - 2 ) -- 5 qual days, 3 days of stoppages of which 2 are qual
8637 --
8638
8639 /*
8640 what do we need to do here ..
8641 roll thru the overlap period on a daily basis
8642 determine the number of qualifying days
8643 and set the overlap amount to number_of_qual_days * l_ssp_daily_rate
8644 */
8645
8646 IF g_debug THEN
8647 debug('partial_overlap_start_date:'||GREATEST(p_range_start_date,p_ssp_week_entry.date_from));
8648 debug('partial_overlap_end_date:'||LEAST(p_range_end_date,p_ssp_week_entry.date_to));
8649 END IF;
8650
8651 l_number_of_overlap_ssp_days :=
8652 get_number_of_overlap_ssp_days
8653 (p_business_group_id
8654 ,p_person_id
8655 ,p_piw_id
8656 ,p_ssp_week_entry.withheld_days
8657 ,GREATEST(p_range_start_date,p_ssp_week_entry.date_from)
8658 ,LEAST(p_range_end_date,p_ssp_week_entry.date_to)
8659 );
8660
8661 l_proc_step := 20;
8662 IF g_debug THEN
8663 debug(l_proc_name,l_proc_step);
8664 END IF;
8665
8666 l_overlap_amount := l_number_of_overlap_ssp_days * l_ssp_daily_rate;
8667
8668 ELSE
8669 -- either no overap or the week is completely included in the range
8670 l_proc_step := 25;
8671 IF g_debug THEN
8672 debug(l_proc_name,l_proc_step);
8673 END IF;
8674
8675 IF p_ssp_week_entry.date_from >= p_range_start_date -- |range|
8676 AND -- |sspwk|
8677 p_ssp_week_entry.date_to <= p_range_end_date -- |swk|
8678 THEN
8679 -- its a complete overlap
8680 l_proc_step := 30;
8681 IF g_debug THEN
8682 debug(l_proc_name,l_proc_step);
8683 END IF;
8684
8685 l_overlap_amount := p_ssp_week_entry.amount;
8686
8687 --ELSE -- |range|
8688 -- there is no overlap --|sspwk|
8689 -- |sspwk|
8690 -- this can occur since for linked absences the entries of the parent
8691 -- will also be picked up which will have no overlap with range period.
8692
8693 -- l_overlap_amount := 0;
8694
8695 END IF; -- IF p_ssp_week_entry.date_from >= p_range_start_date
8696
8697 END IF; -- IF ( p_ssp_week_entry.date_from < p_range_start_date
8698
8699 IF g_debug THEN
8700 debug('l_overlap_amount:'||l_overlap_amount);
8701 debug_exit(l_proc_name,l_proc_step);
8702 END IF;
8703
8704 RETURN l_overlap_amount;
8705
8706 EXCEPTION
8707 WHEN OTHERS THEN
8708 clear_cache;
8709 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
8710 debug_others(l_proc_name,l_proc_step);
8711 IF g_debug THEN
8712 debug('Leaving: '||l_proc_name,-999);
8713 END IF;
8714 fnd_message.raise_error;
8715 ELSE
8716 RAISE;
8717 END IF;
8718 END get_ssp_entry_overlap_amount;
8719 --
8720 --
8721 --
8722 PROCEDURE get_range_and_absence_ssp
8723 (p_business_group_id IN NUMBER
8724 ,p_assignment_id IN NUMBER
8725 ,p_absence_attendance_id IN NUMBER
8726 ,p_range_start_date IN DATE
8727 ,p_range_end_date IN DATE
8728 ,p_range_amount OUT NOCOPY NUMBER
8729 ,p_absence_amount OUT NOCOPY NUMBER
8730 )
8731 IS
8732
8733 c_ssp_element_name CONSTANT
8734 pay_element_types_f.element_name%TYPE:='Statutory Sick Pay';
8735 l_ssp_element_type_id g_ssp_element_type_id%TYPE;
8736 l_ssp_input_values g_ssp_input_values%TYPE;
8737 l_ssp_element_links g_ssp_element_links%TYPE;
8738
8739 c_ssp_retro_element_name CONSTANT
8740 pay_element_types_f.element_name%TYPE:='SSP Corrections';
8741 l_ssp_retro_element_type_id g_ssp_retro_element_type_id%TYPE;
8742 l_ssp_retro_input_values g_ssp_retro_input_values%TYPE;
8743 l_ssp_retro_element_links g_ssp_retro_element_links%TYPE;
8744
8745 l_max_ssp_period NUMBER;
8746 l_primary_assignment_id per_all_assignments_f.assignment_id%TYPE;
8747 l_absence csr_absence_details%ROWTYPE;
8748 l_piw_id per_absence_attendances.absence_attendance_id%TYPE;
8749 i BINARY_INTEGER:= 0;
8750 j BINARY_INTEGER:= 0;
8751 l_screen_entry_value pay_element_entry_values.screen_entry_value%TYPE;
8752 l_range_start_date DATE;
8753 l_range_end_date DATE;
8754
8755 l_range_amount NUMBER;
8756 l_absence_amount NUMBER;
8757 l_ssp_entry_amount NUMBER;
8758 l_proc_step NUMBER(38,10);
8759 l_proc_name VARCHAR2(61):=
8760 g_package_name||'get_range_and_absence_ssp';
8761
8762 BEGIN
8763
8764 IF g_debug THEN
8765 debug_enter(l_proc_name);
8766 debug('p_absence_attendance_id:'||p_absence_attendance_id);
8767 debug('p_business_group_id:'||p_business_group_id);
8768 debug('p_assignment_id:'||p_assignment_id);
8769 debug('p_range_start_date:'||p_range_start_date);
8770 debug('p_range_end_date:'||p_range_end_date);
8771 END IF;
8772
8773 /*
8774 1. Determine Primary assignment -- can we assume the context is ?
8775 2. Determine the absence details and the piw id
8776 -- the piw id is the absence_attendance_id for unliked absences
8777 -- or it is the linked_absence_id for the linked absences
8778 3. Determine the constants for Statutory Sick Pay and SSP Corrections element types
8779 and cache for this business group(caching context)...tho it is very unlikely that
8780 the same session would be used by two diff business groups.
8781 4. Loop for every link in the bg(use context or derive from per_absences??)
8782 for the two element types derived in step 3
8783 5. Loop thru SSP element entries(p_assignmen_id, p_link_id, p_piw_id)
8784 6. For every determine, determine the extent of overlap with the relevant period range
8785 7. For entries which are completely overlapped add the "amount"
8786 8. For entries which overlap partially, pro-rate based on the relevant qualifying pattern.
8787 9. SSP Daily Rate = Amount / SSP Days Due
8788 10. Amount to include = SSP Daily Rate * Number of Qual days in overlap period
8789 11. Number of qual days in overlap period = Loop thru the days in the element entry
8790 */
8791
8792
8793 -- 1. Determine Primary Assignment For now assume p_assignment_id is the one
8794 -- 2. Determine the absence details and piw_id
8795
8796
8797 OPEN csr_absence_details(p_absence_attendance_id);
8798 FETCH csr_absence_details INTO l_absence;
8799 IF g_debug THEN
8800 debug('l_absence.business_group_id:'||l_absence.business_group_id);
8801 debug('p_business_group_id:'||p_business_group_id);
8802 END IF;
8803
8804 IF csr_absence_details%FOUND
8805 AND
8806 l_absence.business_group_id = p_business_group_id
8807 THEN
8808
8809 l_proc_step := 10;
8810 IF g_debug THEN
8811 debug(l_proc_name, l_proc_step);
8812 END IF;
8813
8814 OPEN csr_absence_primary_assignment(p_absence_attendance_id);
8815 FETCH csr_absence_primary_assignment INTO l_primary_assignment_id;
8816 CLOSE csr_absence_primary_assignment;
8817
8818 IF g_debug THEN
8819 debug('l_primary_assignment_id:'||l_primary_assignment_id);
8820 debug('p_assignment_id:'||p_assignment_id);
8821 END IF;
8822
8823 -- IF l_primary_assignment_id = p_assignment_id
8824 -- THEN
8825 -- commenting the Primary Assignment check as this can be called
8826 -- from any assignment in case of multiple assignments
8827 -- check TAR:4178767.995
8828
8829 l_proc_step := 12;
8830 IF g_debug THEN
8831 debug(l_proc_name, l_proc_step);
8832 END IF;
8833
8834 IF l_absence.date_start IS NULL
8835 THEN
8836 -- there was a time when for SSP one could only enter the sickness
8837 -- start and end dates, with the date_start and end being optional
8838 l_absence.date_start :=
8839 l_absence.sickness_start_date;
8840 END IF;
8841
8842 IF l_absence.date_end IS NULL
8843 THEN
8844 -- there was a time when for SSP one could only enter the sickness
8845 -- start and end dates, with the date_start and end being optional
8846 -- in addition end dates can be open, default to EOT
8847 l_absence.date_end :=
8848 NVL(l_absence.sickness_end_date,hr_api.g_eot);
8849 END IF;
8850
8851
8852 IF l_absence.business_group_id <> g_ssp_business_group_id
8853 OR
8854 g_ssp_business_group_id IS NULL
8855 OR
8856 g_ssp_element_type_id IS NULL
8857 OR
8858 g_ssp_retro_element_type_id IS NULL
8859 THEN
8860
8861 l_proc_step := 15;
8862 IF g_debug THEN
8863 debug(l_proc_name, l_proc_step);
8864 END IF;
8865
8866 -- cache the bg for which this information is relevant
8867 g_ssp_business_group_id := l_absence.business_group_id;
8868
8869 OPEN csr_seeded_element_type(c_ssp_element_name);
8870 FETCH csr_seeded_element_type INTO g_ssp_element_type_id;
8871 CLOSE csr_seeded_element_type;
8872
8873 l_proc_step := 20;
8874 IF g_debug THEN
8875 debug(l_proc_name, l_proc_step);
8876 END IF;
8877
8878 -- avoid using cache variables directly as parameters
8879 l_ssp_element_type_id := g_ssp_element_type_id;
8880
8881 IF g_debug THEN
8882 debug('l_ssp_element_type_id:'||l_ssp_element_type_id);
8883 END IF;
8884
8885
8886
8887
8888 FOR r_input_value IN
8889 csr_inputvalue_ids
8890 (l_ssp_element_type_id
8891 ,l_absence.date_start
8892 )
8893 LOOP
8894
8895 g_ssp_input_values(r_input_value.display_sequence):=
8896 r_input_value;
8897
8898 IF g_debug THEN
8899 debug('r_input_value.display_sequence:'||r_input_value.display_sequence);
8900 debug('r_input_value.id:'||r_input_value.id);
8901 END IF;
8902
8903 END LOOP;
8904
8905 l_proc_step := 25;
8906 IF g_debug THEN
8907 debug(l_proc_name, l_proc_step);
8908 END IF;
8909
8910
8911 -- loop and fetch the element links also for this bg#
8912 -- we don't fetch element links based on effective date
8913 -- as we want all possible links
8914 i := 0;
8915 FOR r_element_link IN
8916 csr_element_links
8917 (l_ssp_element_type_id
8918 ,l_absence.business_group_id
8919 )
8920 LOOP
8921 i := i + 1;
8922 g_ssp_element_links(i) := r_element_link;
8923
8924 IF g_debug THEN
8925 debug('g_ssp_element_links(i).id:'||g_ssp_element_links(i).id);
8926 END IF;
8927
8928 END LOOP;
8929
8930 l_proc_step := 30;
8931 IF g_debug THEN
8932 debug(l_proc_name, l_proc_step);
8933 END IF;
8934
8935 OPEN csr_seeded_element_type(c_ssp_retro_element_name);
8936 FETCH csr_seeded_element_type INTO g_ssp_retro_element_type_id;
8937 CLOSE csr_seeded_element_type;
8938
8939 l_proc_step := 35;
8940 IF g_debug THEN
8941 debug(l_proc_name, l_proc_step);
8942 END IF;
8943
8944 -- avoid using cache variables directly as parameters
8945 l_ssp_retro_element_type_id := g_ssp_retro_element_type_id;
8946
8947 IF g_debug THEN
8948 debug('l_ssp_retro_element_type_id:'||l_ssp_retro_element_type_id);
8949 END IF;
8950
8951 FOR r_input_value IN
8952 csr_inputvalue_ids
8953 (l_ssp_retro_element_type_id
8954 ,l_absence.date_start
8955 )
8956 LOOP
8957
8958 g_ssp_retro_input_values(r_input_value.display_sequence):=
8959 r_input_value;
8960
8961 IF g_debug THEN
8962 debug('retro r_input_value.display_sequence:'||r_input_value.display_sequence);
8963 debug('retro r_input_value.id:'||r_input_value.id);
8964 END IF;
8965
8966 END LOOP;
8967
8968 l_proc_step := 40;
8969 IF g_debug THEN
8970 debug(l_proc_name, l_proc_step);
8971 END IF;
8972
8973 -- loop and fetch the element links also for this bg
8974 i := 0;
8975 FOR r_element_link IN
8976 csr_element_links
8977 (l_ssp_retro_element_type_id
8978 ,l_absence.business_group_id
8979 )
8980 LOOP
8981 i := i + 1;
8982 g_ssp_retro_element_links(i) := r_element_link;
8983
8984 IF g_debug THEN
8985 debug('g_ssp_retro_element_links(i).id:'||g_ssp_retro_element_links(i).id);
8986 END IF;
8987
8988 END LOOP;
8989
8990 l_proc_step := 45;
8991 IF g_debug THEN
8992 debug(l_proc_name, l_proc_step);
8993 END IF;
8994
8995 END IF; -- IF l_absence.business_group_id <> g_ssp_business_group_id
8996
8997 l_ssp_element_type_id := g_ssp_element_type_id;
8998 l_ssp_input_values := g_ssp_input_values;
8999 l_ssp_element_links:= g_ssp_element_links;
9000 l_ssp_retro_element_type_id := g_ssp_retro_element_type_id;
9001 l_ssp_retro_input_values := g_ssp_retro_input_values;
9002 l_ssp_retro_element_links := g_ssp_retro_element_links;
9003
9004 l_piw_id := NVL(l_absence.linked_absence_id,p_absence_attendance_id);
9005
9006 -- IF l_absence.date_end IS NULL -- open ended
9007 -- THEN
9008
9009 -- the reason we donot cache this is because
9010 -- this a date effective attribute of SSP
9011 -- we always need to fetch the value as of this absence
9012
9013 -- OPEN csr_max_ssp_period
9014 -- (l_ssp_element_type_id
9015 -- ,l_absence.date_start
9016 -- );
9017 -- FETCH csr_max_ssp_period INTO l_max_ssp_period;
9018 -- CLOSE csr_max_ssp_period;
9019 --
9020 -- l_absence.date_end := l_absence.date_start+l_max_ssp_period;
9021 -- l_absence.sickness_end_date := l_absence.date_start+l_max_ssp_period;
9022
9023 -- l_absence.date_end := NVL(l_absence.sickness_end_date,hr_api.g_eot);
9024 --
9025 -- END IF;
9026
9027
9028 l_range_end_date := LEAST(p_range_end_date,l_absence.date_end);
9029
9030 l_range_start_date := GREATEST(p_range_start_date,l_absence.date_start);
9031
9032 IF g_debug THEN
9033 debug('l_range_start_date:'||l_range_start_date);
9034 debug('l_range_end_date:'||l_range_end_date);
9035 END IF;
9036
9037 l_range_amount := 0;
9038 l_absence_amount := 0;
9039
9040 l_proc_step := 50;
9041 IF g_debug THEN
9042 debug(l_proc_name, l_proc_step);
9043 END IF;
9044
9045 -- Process any related Statutory Sick Pay element entries
9046 i:= l_ssp_element_links.FIRST;
9047 WHILE i IS NOT NULL
9048 LOOP
9049
9050 l_proc_step := 50+i/1000;
9051 IF g_debug THEN
9052 debug(l_proc_name, 50+i/1000);
9053 END IF;
9054
9055 FOR r_ssp_entry IN
9056 csr_ssp_entries
9057 (p_primary_assignment_id => l_primary_assignment_id
9058 ,p_element_link_id => l_ssp_element_links(i).id
9059 ,p_piw_id => l_piw_id
9060 -- ,p_amount_iv_id => l_ssp_input_values(1).id
9061 -- ,p_ssp_days_due_iv_id => l_ssp_input_values(2).id
9062 -- ,p_date_from_iv_id => l_ssp_input_values(3).id
9063 -- ,p_date_to_iv_id => l_ssp_input_values(4).id
9064 -- ,p_rate_iv_id => l_ssp_input_values(5).id
9065 -- ,p_withheld_days_iv_id => l_ssp_input_values(6).id
9066 -- ,p_ssp_weeks_iv_id => l_ssp_input_values(7).id
9067 -- ,p_qualifying_days_iv_id => l_ssp_input_values(8).id
9068 )
9069 LOOP
9070
9071 l_proc_step := 55+i/1000;
9072 IF g_debug THEN
9073 debug(l_proc_name, 55+i/1000);
9074 debug('r_ssp_entry.element_entry_id:'||r_ssp_entry.element_entry_id);
9075 debug('r_ssp_entry.effective_start_date:'||r_ssp_entry.effective_start_date);
9076 debug('r_ssp_entry.effective_end_date:'||r_ssp_entry.effective_end_date);
9077 END IF;
9078
9079 j := l_ssp_input_values.FIRST;
9080 WHILE j IS NOT NULL
9081 LOOP
9082
9083 OPEN get_element_entry_value
9084 (p_element_entry_id => r_ssp_entry.element_entry_id
9085 ,p_effective_date => r_ssp_entry.effective_start_date
9086 ,p_input_value_id => l_ssp_input_values(j).id
9087 );
9088 FETCH get_element_entry_value INTO l_screen_entry_value;
9089 CLOSE get_element_entry_value;
9090 IF j = 1 THEN -- its amount
9091 r_ssp_entry.amount :=
9092 fnd_number.canonical_to_number(l_screen_entry_value);
9093 END IF;
9094 IF j = 2 THEN -- its ssp_days_due
9095 r_ssp_entry.ssp_days_due :=
9096 fnd_number.canonical_to_number(l_screen_entry_value);
9097 END IF;
9098 IF j = 3 THEN -- its date_from
9099 r_ssp_entry.date_from:=
9100 fnd_date.canonical_to_date(l_screen_entry_value);
9101 END IF;
9102 IF j = 4 THEN -- its date_to
9103 r_ssp_entry.date_to:=
9104 fnd_date.canonical_to_date(l_screen_entry_value);
9105 END IF;
9106 IF j = 5 THEN -- its rate
9107 r_ssp_entry.rate:=
9108 fnd_number.canonical_to_number(l_screen_entry_value);
9109 END IF;
9110 IF j = 6 THEN -- its withheld_days
9111 r_ssp_entry.withheld_days:=
9112 fnd_number.canonical_to_number(l_screen_entry_value);
9113 END IF;
9114 --IF j = 7 THEN -- its ssp_weeks
9115 -- r_ssp_entry.ssp_weeks:=
9116 -- fnd_number.canonical_to_number(l_screen_entry_value);
9117 --END IF;
9118 IF j = 8 THEN -- its qualifying_days
9119 r_ssp_entry.qualifying_days:=
9120 fnd_number.canonical_to_number(l_screen_entry_value);
9121 END IF;
9122 j := l_ssp_input_values.NEXT(j);
9123 END LOOP;
9124
9125 l_proc_step := 57+i/1000;
9126 IF g_debug THEN
9127 debug(l_proc_name, 57+i/1000);
9128 debug('r_ssp_entry.date_from:'||r_ssp_entry.date_from);
9129 debug('r_ssp_entry.date_to:'||r_ssp_entry.date_to);
9130 debug('r_ssp_entry.amount:'||r_ssp_entry.amount);
9131 debug('r_ssp_entry.rate:'||r_ssp_entry.rate);
9132 debug('r_ssp_entry.ssp_days_due:'||r_ssp_entry.ssp_days_due);
9133 debug('r_ssp_entry.withheld_days:'||r_ssp_entry.withheld_days);
9134 debug('r_ssp_entry.qualifying_days:'||r_ssp_entry.qualifying_days);
9135 debug('p_piw_id:'||l_piw_id);
9136 END IF;
9137
9138 l_ssp_entry_amount :=
9139 get_ssp_entry_overlap_amount
9140 (l_absence.business_group_id
9141 ,l_absence.person_id
9142 ,l_piw_id
9143 ,r_ssp_entry
9144 ,l_range_start_date
9145 ,l_range_end_date);
9146 l_range_amount := l_ssp_entry_amount + l_range_amount;
9147
9148
9149 IF r_ssp_entry.date_from >= l_absence.date_start
9150 AND
9151 r_ssp_entry.date_to <= l_absence.date_end
9152 THEN
9153 l_absence_amount := l_absence_amount + r_ssp_entry.amount;
9154 END IF;
9155
9156 IF g_debug THEN
9157 debug('SubTotal:l_range_amount:'||l_range_amount);
9158 debug('SubTotal:l_absence_amount:'||l_absence_amount);
9159 END IF;
9160
9161 END LOOP;
9162
9163 i:= l_ssp_element_links.NEXT(i);
9164 END LOOP;
9165
9166
9167 l_proc_step := 60;
9168 IF g_debug THEN
9169 debug(l_proc_name, 60);
9170 END IF;
9171 -- Process any related SSP Corrections element entries
9172 i:= l_ssp_retro_element_links.FIRST;
9173 WHILE i IS NOT NULL
9174 LOOP
9175
9176 l_proc_step := 65+i/1000;
9177 IF g_debug THEN
9178 debug(l_proc_name, 65+i/1000);
9179 END IF;
9180
9181 FOR r_ssp_entry IN
9182 csr_ssp_entries
9183 (p_primary_assignment_id => l_primary_assignment_id
9184 ,p_element_link_id => l_ssp_retro_element_links(i).id
9185 ,p_piw_id => l_piw_id
9186 -- ,p_amount_iv_id => l_ssp_retro_input_values(1).id
9187 -- ,p_ssp_days_due_iv_id => l_ssp_retro_input_values(2).id
9188 -- ,p_date_from_iv_id => l_ssp_retro_input_values(3).id
9189 -- ,p_date_to_iv_id => l_ssp_retro_input_values(4).id
9190 -- ,p_rate_iv_id => l_ssp_retro_input_values(5).id
9191 -- ,p_withheld_days_iv_id => l_ssp_retro_input_values(6).id
9192 -- ,p_ssp_weeks_iv_id => l_ssp_retro_input_values(7).id
9193 -- ,p_qualifying_days_iv_id => l_ssp_retro_input_values(8).id
9194 )
9195 LOOP
9196
9197 l_proc_step := 70+i/1000;
9198 IF g_debug THEN
9199 debug(l_proc_name, 70+i/1000);
9200 debug('r_ssp_entry.element_entry_id:'||r_ssp_entry.element_entry_id);
9201 debug('r_ssp_entry.effective_start_date:'||r_ssp_entry.effective_start_date);
9202 debug('r_ssp_entry.effective_end_date:'||r_ssp_entry.effective_end_date);
9203 END IF;
9204
9205 j := l_ssp_retro_input_values.FIRST;
9206 WHILE j IS NOT NULL
9207 LOOP
9208
9209 OPEN get_element_entry_value
9210 (p_element_entry_id => r_ssp_entry.element_entry_id
9211 ,p_effective_date => r_ssp_entry.effective_start_date
9212 ,p_input_value_id => l_ssp_retro_input_values(j).id
9213 );
9214 FETCH get_element_entry_value INTO l_screen_entry_value;
9215 CLOSE get_element_entry_value;
9216 IF j = 1 THEN -- its amount
9217 r_ssp_entry.amount :=
9218 fnd_number.canonical_to_number(l_screen_entry_value);
9219 END IF;
9220 IF j = 2 THEN -- its ssp_days_due
9221 r_ssp_entry.ssp_days_due :=
9222 fnd_number.canonical_to_number(l_screen_entry_value);
9223 END IF;
9224 IF j = 3 THEN -- its date_from
9225 r_ssp_entry.date_from:=
9226 fnd_date.canonical_to_date(l_screen_entry_value);
9227 END IF;
9228 IF j = 4 THEN -- its date_to
9229 r_ssp_entry.date_to:=
9230 fnd_date.canonical_to_date(l_screen_entry_value);
9231 END IF;
9232 IF j = 5 THEN -- its rate
9233 r_ssp_entry.rate:=
9234 fnd_number.canonical_to_number(l_screen_entry_value);
9235 END IF;
9236 IF j = 6 THEN -- its withheld_days
9237 r_ssp_entry.withheld_days:=
9238 fnd_number.canonical_to_number(l_screen_entry_value);
9239 END IF;
9240 --IF j = 7 THEN -- its ssp_weeks
9241 -- r_ssp_entry.ssp_weeks:=
9242 -- fnd_number.canonical_to_number(l_screen_entry_value);
9243 --END IF;
9244 IF j = 8 THEN -- its qualifying_days
9245 r_ssp_entry.qualifying_days:=
9246 fnd_number.canonical_to_number(l_screen_entry_value);
9247 END IF;
9248 j := l_ssp_retro_input_values.NEXT(j);
9249 END LOOP;
9250
9251 l_proc_step := 75+i/1000;
9252 IF g_debug THEN
9253 debug(l_proc_name, 75+i/1000);
9254 debug('r_ssp_entry.date_from:'||r_ssp_entry.date_from);
9255 debug('r_ssp_entry.date_to:'||r_ssp_entry.date_to);
9256 debug('r_ssp_entry.amount:'||r_ssp_entry.amount);
9257 debug('r_ssp_entry.rate:'||r_ssp_entry.rate);
9258 debug('r_ssp_entry.ssp_days_due:'||r_ssp_entry.ssp_days_due);
9259 debug('r_ssp_entry.withheld_days:'||r_ssp_entry.withheld_days);
9260 debug('r_ssp_entry.qualifying_days:'||r_ssp_entry.qualifying_days);
9261 debug('p_piw_id:'||l_piw_id);
9262 END IF;
9263
9264 l_ssp_entry_amount :=
9265 get_ssp_entry_overlap_amount
9266 (l_absence.business_group_id
9267 ,l_absence.person_id
9268 ,l_piw_id
9269 ,r_ssp_entry
9270 ,l_range_start_date
9271 ,l_range_end_date);
9272
9273 l_range_amount := l_ssp_entry_amount + l_range_amount;
9274
9275 -- the reason we need this range overlap check
9276 -- for absence totals is because not all element
9277 -- entries by this fetch will relate to the given
9278 -- absence id. there may be element entries of
9279 -- linked parent absence
9280
9281 IF r_ssp_entry.date_from >= l_absence.date_start
9282 AND
9283 r_ssp_entry.date_to <= l_absence.date_end
9284 THEN
9285 l_absence_amount := l_absence_amount + r_ssp_entry.amount;
9286 END IF;
9287
9288 IF g_debug THEN
9289 debug('SubTotal:l_range_amount:'||l_range_amount);
9290 debug('SubTotal:l_absence_amount:'||l_absence_amount);
9291 END IF;
9292
9293 END LOOP;
9294
9295 i:= l_ssp_retro_element_links.NEXT(i);
9296 END LOOP;-- WHILE i IS NOT NULL -- ssp_retro
9297
9298 -- END IF; -- IF l_primary_assignment_id = p_assignment_id
9299
9300 l_proc_step := 80;
9301 IF g_debug THEN
9302 debug(l_proc_name, l_proc_step);
9303 END IF;
9304
9305 END IF; -- IF csr_absence_details%FOUND
9306 CLOSE csr_absence_details;
9307
9308 p_range_amount := ROUND(l_range_amount,2);
9309 p_absence_amount := ROUND(l_absence_amount,2);
9310
9311 l_proc_step := 90;
9312 IF g_debug THEN
9313 debug(l_proc_name, l_proc_step);
9314 debug('l_range_amount:'||l_range_amount);
9315 debug('l_absence_amount:'||l_absence_amount);
9316 debug('p_range_amount:'||p_range_amount);
9317 debug('p_absence_amount:'||p_absence_amount);
9318 debug_exit(l_proc_name);
9319 END IF;
9320
9321 EXCEPTION
9322 WHEN OTHERS THEN
9323 clear_cache;
9324 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
9325 debug_others(l_proc_name,l_proc_step);
9326 IF g_debug THEN
9327 debug('Leaving: '||l_proc_name,-999);
9328 END IF;
9329 fnd_message.raise_error;
9330 ELSE
9331 RAISE;
9332 END IF;
9333 END get_range_and_absence_ssp;
9334 --
9335 --
9336 --
9337 FUNCTION get_absence_ssp
9338 (p_business_group_id IN NUMBER
9339 ,p_assignment_id IN NUMBER
9340 ,p_absence_attendance_id IN NUMBER
9341 ,p_range_start_date IN DATE
9342 ,p_range_end_date IN DATE
9343 ) RETURN NUMBER
9344 IS
9345
9346 l_range_amount NUMBER:=0;
9347 l_absence_amount NUMBER:=0;
9348
9349 l_proc_step NUMBER(38,10);
9350 l_proc_name VARCHAR2(61):=
9351 g_package_name||'get_absence_ssp';
9352
9353 BEGIN
9354
9355 g_debug := hr_utility.debug_enabled;
9356
9357 IF g_debug THEN
9358 debug_enter(l_proc_name);
9359 debug('p_absence_attendance_id:'||p_absence_attendance_id);
9360 debug('p_business_group_id:'||p_business_group_id);
9361 debug('p_assignment_id:'||p_assignment_id);
9362 debug('p_range_start_date:'||p_range_start_date);
9363 debug('p_range_end_date:'||p_range_end_date);
9364 END IF;
9365
9366 get_range_and_absence_ssp
9367 (p_business_group_id => p_business_group_id
9368 ,p_assignment_id => p_assignment_id
9369 ,p_absence_attendance_id => p_absence_attendance_id
9370 ,p_range_start_date => p_range_start_date
9371 ,p_range_end_date => p_range_end_date
9372 ,p_range_amount => l_range_amount -- OUT
9373 ,p_absence_amount => l_absence_amount -- OUT
9374 );
9375
9376 l_proc_step := 90;
9377 IF g_debug THEN
9378 debug(l_proc_name, l_proc_step);
9379 debug('l_range_amount:'||to_char(l_range_amount));
9380 debug('l_absence_amount:'||to_char(l_absence_amount));
9381 debug_exit(l_proc_name);
9382 END IF;
9383
9384 RETURN l_range_amount;
9385
9386 EXCEPTION
9387 WHEN OTHERS THEN
9388 clear_cache;
9389 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
9390 debug_others(l_proc_name,l_proc_step);
9391 IF g_debug THEN
9392 debug('Leaving: '||l_proc_name,-999);
9393 END IF;
9394 fnd_message.raise_error;
9395 ELSE
9396 RAISE;
9397 END IF;
9398 END get_absence_ssp;
9399 --
9400 --
9401 --
9402 FUNCTION get_smp_entry_overlap_amount
9403 (p_smp_week_entry IN csr_smp_entries%ROWTYPE
9404 ,p_range_start_date IN DATE
9405 ,p_range_end_date IN DATE
9406 ) RETURN NUMBER
9407 IS
9408
9409 l_smp_entry_overlap_amount NUMBER:=0;
9410 l_number_of_overlap_smp_days NUMBER:=0;
9411 l_smp_daily_rate NUMBER:=0;
9412 l_smp_week_start_date DATE;
9413 l_smp_week_end_date DATE;
9414
9415 l_proc_step NUMBER(38,10);
9416 l_proc_name VARCHAR2(61):=
9417 g_package_name||'get_smp_entry_overlap_amount';
9418 BEGIN
9419
9420 IF g_debug THEN
9421 debug_enter(l_proc_name);
9422 END IF;
9423
9424 l_smp_week_start_date := p_smp_week_entry.week_commencing;
9425 l_smp_week_end_date := p_smp_week_entry.week_commencing + 6;
9426
9427 IF g_debug THEN
9428 debug('l_smp_week_start_date:'||l_smp_week_start_date);
9429 debug('l_smp_week_end_date:'||l_smp_week_end_date);
9430 END IF;
9431
9432 IF NOT
9433 (
9434 ( l_smp_week_start_date >= p_range_start_date
9435 AND
9436 l_smp_week_end_date <= p_range_end_date
9437 )
9438 OR
9439 ( l_smp_week_start_date > p_range_end_date
9440 OR
9441 l_smp_week_end_date < p_range_start_date
9442 )
9443 )
9444 THEN
9445 -- its a partial overlap
9446 l_proc_step := 10;
9447 IF g_debug THEN
9448 debug(l_proc_name,l_proc_step);
9449 END IF;
9450
9451 -- at the moment pro-ration on the basis of OMP Pattern
9452 -- isn't yet supported hence use basic pro-ration by 7 days
9453 -- ie we find the number of calendar days in the overlap period
9454 -- we find the daily rate as the SMP amount / 7
9455 -- set the overlap amount = overlap_cal_days * daily_rate
9456
9457 l_number_of_overlap_smp_days := -- number of calendar days between
9458 LEAST(l_smp_week_end_date,p_range_end_date) - -- and
9459 GREATEST(l_smp_week_start_date,p_range_start_date) + 1;
9460
9461 l_smp_daily_rate := p_smp_week_entry.amount / 7;
9462
9463 l_smp_entry_overlap_amount :=
9464 l_smp_daily_rate * l_number_of_overlap_smp_days;
9465
9466 l_proc_step := 15;
9467 IF g_debug THEN
9468 debug(l_proc_name,l_proc_step);
9469 debug('l_smp_daily_rate:'||l_smp_daily_rate);
9470 debug('l_number_of_overlap_smp_days:'||l_number_of_overlap_smp_days);
9471 END IF;
9472
9473 ELSE
9474 -- its either a complete overlap or there is no overlap at all
9475 l_proc_step := 50;
9476 IF g_debug THEN
9477 debug(l_proc_name,l_proc_step);
9478 END IF;
9479
9480
9481 IF l_smp_week_start_date >= p_range_start_date
9482 AND
9483 l_smp_week_end_date <= p_range_end_date
9484 THEN
9485
9486 l_proc_step := 55;
9487 IF g_debug THEN
9488 debug(l_proc_name,l_proc_step);
9489 END IF;
9490 -- the week falls completly within the range add the full amount
9491 l_smp_entry_overlap_amount := p_smp_week_entry.amount;
9492
9493 --ELSE
9494 ---- there is no overlap return 0 as overlap amount
9495 --l_smp_entry_overlap_amount := 0; -- is default
9496 END IF;
9497
9498 END IF; -- IF NOT
9499
9500 IF g_debug THEN
9501 debug('l_smp_entry_overlap_amount:'||to_char(l_smp_entry_overlap_amount));
9502
9503 debug_exit(l_proc_name);
9504 END IF;
9505
9506 RETURN l_smp_entry_overlap_amount;
9507
9508 EXCEPTION
9509 WHEN OTHERS THEN
9510 clear_cache;
9511 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
9512 debug_others(l_proc_name,l_proc_step);
9513 IF g_debug THEN
9514 debug('Leaving: '||l_proc_name,-999);
9515 END IF;
9516 fnd_message.raise_error;
9517 ELSE
9518 RAISE;
9519 END IF;
9520 END get_smp_entry_overlap_amount;
9521 --
9522 --
9523 --
9524 PROCEDURE get_range_and_absence_smp
9525 (p_business_group_id IN NUMBER
9526 ,p_assignment_id IN NUMBER
9527 ,p_absence_attendance_id IN NUMBER
9528 ,p_range_start_date IN DATE
9529 ,p_range_end_date IN DATE
9530 ,p_absence_category IN VARCHAR2
9531 ,p_range_amount OUT NOCOPY NUMBER
9532 ,p_absence_amount OUT NOCOPY NUMBER
9533 )
9534 IS
9535
9536 l_range_amount NUMBER:=0;
9537 l_absence_amount NUMBER:=0;
9538
9539 l_absence csr_absence_details%ROWTYPE;
9540 l_primary_assignment_id per_all_assignments_f.assignment_id%TYPE;
9541
9542 c_smp_element_name CONSTANT
9543 pay_element_types_f.element_name%TYPE:='Statutory Maternity Pay';
9544 c_sap_element_name CONSTANT
9545 pay_element_types_f.element_name%TYPE:='Statutory Adoption Pay';
9546 c_spa_element_name CONSTANT
9547 pay_element_types_f.element_name%TYPE:='Statutory Paternity Pay Adoption';
9548 c_spb_element_name CONSTANT
9549 pay_element_types_f.element_name%TYPE:='Statutory Paternity Pay Birth';
9550
9551 l_statutory_element_name pay_element_types_f.element_name%TYPE ;
9552 l_smp_element_type_id g_smp_element_type_id%TYPE;
9553 l_smp_input_values g_smp_input_values%TYPE;
9554 l_smp_element_links g_smp_element_links%TYPE;
9555
9556 c_smp_retro_element_name CONSTANT
9557 pay_element_types_f.element_name%TYPE:='SMP Corrections';
9558 c_sap_retro_element_name CONSTANT
9559 pay_element_types_f.element_name%TYPE:='SAP Corrections';
9560 c_spa_retro_element_name CONSTANT
9561 pay_element_types_f.element_name%TYPE:='SPP Adoption Corrections';
9562 c_spb_retro_element_name CONSTANT
9563 pay_element_types_f.element_name%TYPE:='SPP Birth Corrections';
9564
9565 l_statutory_retro_element_name pay_element_types_f.element_name%TYPE ;
9566 l_smp_retro_element_type_id g_smp_retro_element_type_id%TYPE;
9567 l_smp_retro_input_values g_smp_retro_input_values%TYPE;
9568 l_smp_retro_element_links g_smp_retro_element_links%TYPE;
9569
9570 l_max_smp_period NUMBER;
9571 l_range_start_date DATE;
9572 l_range_end_date DATE;
9573 l_smp_entry_amount NUMBER:=0;
9574 i BINARY_INTEGER:=0;
9575 j BINARY_INTEGER:= 0;
9576 l_screen_entry_value pay_element_entry_values.screen_entry_value%TYPE;
9577 l_proc_step NUMBER(38,10);
9578 l_proc_name VARCHAR2(61):=
9579 g_package_name||'get_range_and_absence_smp';
9580
9581 l_absence_category hr_lookups.lookup_code%TYPE ;
9582
9583 BEGIN
9584
9585 IF g_debug THEN
9586 debug_enter(l_proc_name);
9587 debug('p_business_group_id:'||p_business_group_id);
9588 debug('p_assignment_id:'||p_assignment_id);
9589 debug('p_absence_attendance_id:'||p_absence_attendance_id);
9590 debug('p_range_start_date:'||p_range_start_date);
9591 debug('p_range_end_date:'||p_range_end_date);
9592 debug('p_absence_category:'||p_absence_category);
9593 END IF;
9594
9595 OPEN csr_absence_details(p_absence_attendance_id);
9596 FETCH csr_absence_details INTO l_absence;
9597 IF g_debug THEN
9598 debug('l_absence.business_group_id:'||l_absence.business_group_id);
9599 debug('p_business_group_id:'||p_business_group_id);
9600 END IF;
9601
9602 IF csr_absence_details%FOUND
9603 AND
9604 l_absence.business_group_id = p_business_group_id
9605 THEN
9606
9607 l_proc_step := 10;
9608 IF g_debug THEN
9609 debug(l_proc_name, l_proc_step);
9610 END IF;
9611
9612 OPEN csr_absence_primary_assignment(p_absence_attendance_id);
9613 FETCH csr_absence_primary_assignment INTO l_primary_assignment_id;
9614 CLOSE csr_absence_primary_assignment;
9615
9616 IF g_debug THEN
9617 debug('l_primary_assignment_id:'||l_primary_assignment_id);
9618 debug('p_assignment_id:'||p_assignment_id);
9619 END IF;
9620
9621 -- IF l_primary_assignment_id = p_assignment_id
9622 -- THEN
9623 -- commenting the Primary Assignment check as this can be called
9624 -- from any assignment in case of multiple assignments
9625 -- check TAR:4178767.995
9626
9627 l_proc_step := 20;
9628 IF g_debug THEN
9629 debug(l_proc_name, l_proc_step);
9630 END IF;
9631
9632 IF l_absence.date_start IS NULL
9633 THEN
9634 l_absence.date_start := l_absence.date_projected_start;
9635 END IF;
9636
9637 IF l_absence.date_end IS NULL
9638 THEN
9639 l_absence.date_end :=
9640 NVL(l_absence.date_projected_end,hr_api.g_eot);
9641 END IF;
9642
9643
9644 IF l_absence.business_group_id <> g_smp_business_group_id
9645 OR
9646 p_absence_category <> g_absence_category
9647 OR
9648 g_smp_business_group_id IS NULL
9649 OR
9650 g_smp_element_type_id IS NULL
9651 OR
9652 g_smp_retro_element_type_id IS NULL
9653 THEN
9654
9655 IF g_debug THEN
9656 debug('l_absence_category:'||l_absence_category);
9657 END IF;
9658
9659 IF p_absence_category = 'M' THEN
9660 l_proc_step := 21;
9661 IF g_debug THEN
9662 debug(l_proc_name, l_proc_step);
9663 END IF;
9664 l_statutory_element_name := c_smp_element_name ;
9665 l_statutory_retro_element_name := c_smp_retro_element_name ;
9666
9667 ELSIF p_absence_category = 'GB_ADO' THEN
9668 l_proc_step := 22;
9669 IF g_debug THEN
9670 debug(l_proc_name, l_proc_step);
9671 END IF;
9672 l_statutory_element_name := c_sap_element_name;
9673 l_statutory_retro_element_name := c_sap_retro_element_name;
9674
9675 ELSIF p_absence_category = 'GB_PAT_ADO' THEN
9676 l_proc_step := 23;
9677 IF g_debug THEN
9678 debug(l_proc_name, l_proc_step);
9679 END IF;
9680 l_statutory_element_name := c_spa_element_name ;
9681 l_statutory_retro_element_name := c_spa_retro_element_name ;
9682
9683 ELSIF p_absence_category = 'GB_PAT_BIRTH' THEN
9684 l_proc_step := 24;
9685 IF g_debug THEN
9686 debug(l_proc_name, l_proc_step);
9687 END IF;
9688 l_statutory_element_name := c_spb_element_name ;
9689 l_statutory_retro_element_name := c_spb_retro_element_name ;
9690 END IF ;
9691
9692 --assigning the global variable for absence_category
9693 g_absence_category := p_absence_category;
9694
9695 l_proc_step := 30;
9696 IF g_debug THEN
9697 debug(l_proc_name, l_proc_step);
9698 END IF;
9699
9700 -- cache the bg for which this information is relevant
9701 g_smp_business_group_id := l_absence.business_group_id;
9702
9703 OPEN csr_seeded_element_type(l_statutory_element_name);
9704 FETCH csr_seeded_element_type INTO g_smp_element_type_id;
9705 CLOSE csr_seeded_element_type;
9706
9707 l_proc_step := 40;
9708 IF g_debug THEN
9709 debug(l_proc_name, l_proc_step);
9710 END IF;
9711
9712 -- avoid using cache variables directly as parameters
9713 l_smp_element_type_id := g_smp_element_type_id;
9714
9715 IF g_debug THEN
9716 debug('l_smp_element_type_id:'||l_smp_element_type_id);
9717 END IF;
9718
9719 FOR r_input_value IN
9720 csr_inputvalue_ids
9721 (l_smp_element_type_id
9722 ,l_absence.date_start
9723 )
9724 LOOP
9725
9726 g_smp_input_values(r_input_value.display_sequence):=
9727 r_input_value;
9728
9729 IF g_debug THEN
9730 debug('r_input_value.display_sequence:'||r_input_value.display_sequence);
9731 debug('r_input_value.id:'||r_input_value.id);
9732 END IF;
9733
9734 END LOOP;
9735
9736 l_proc_step := 45;
9737 IF g_debug THEN
9738 debug(l_proc_name, l_proc_step);
9739 END IF;
9740
9741 -- loop and fetch the element links also for this bg#
9742 -- we don't fetch element links based on effective date
9743 -- as we want all possible links
9744 i := 0;
9745 FOR r_element_link IN
9746 csr_element_links
9747 (l_smp_element_type_id
9748 ,l_absence.business_group_id
9749 )
9750 LOOP
9751 i := i + 1;
9752 g_smp_element_links(i) := r_element_link;
9753
9754 IF g_debug THEN
9755 debug('g_smp_element_links(i).id:'||g_smp_element_links(i).id);
9756 END IF;
9757
9758 END LOOP;
9759
9760 l_proc_step := 50;
9761 IF g_debug THEN
9762 debug(l_proc_name, l_proc_step);
9763 END IF;
9764
9765 OPEN csr_seeded_element_type(l_statutory_retro_element_name);
9766 FETCH csr_seeded_element_type INTO g_smp_retro_element_type_id;
9767 CLOSE csr_seeded_element_type;
9768
9769 l_proc_step := 55;
9770 IF g_debug THEN
9771 debug(l_proc_name, l_proc_step);
9772 END IF;
9773
9774 -- avoid using cache variables directly as parameters
9775 l_smp_retro_element_type_id := g_smp_retro_element_type_id;
9776
9777 IF g_debug THEN
9778 debug('l_smp_retro_element_type_id:'||l_smp_retro_element_type_id);
9779 END IF;
9780
9781 FOR r_input_value IN
9782 csr_inputvalue_ids
9783 (l_smp_retro_element_type_id
9784 ,l_absence.date_start
9785 )
9786 LOOP
9787
9788 g_smp_retro_input_values(r_input_value.display_sequence):=
9789 r_input_value;
9790
9791 IF g_debug THEN
9792 debug('retro r_input_value.display_sequence:'||r_input_value.display_sequence);
9793 debug('retro r_input_value.id:'||r_input_value.id);
9794 END IF;
9795
9796 END LOOP;
9797
9798 l_proc_step := 60;
9799 IF g_debug THEN
9800 debug(l_proc_name, l_proc_step);
9801 END IF;
9802
9803 -- loop and fetch the element links also for this bg
9804 i := 0;
9805 FOR r_element_link IN
9806 csr_element_links
9807 (l_smp_retro_element_type_id
9808 ,l_absence.business_group_id
9809 )
9810 LOOP
9811 i := i + 1;
9812 g_smp_retro_element_links(i) := r_element_link;
9813
9814 IF g_debug THEN
9815 debug('g_smp_retro_element_links(i).id:'||g_smp_retro_element_links(i).id);
9816 END IF;
9817
9818 END LOOP;
9819
9820 l_proc_step := 65;
9821 IF g_debug THEN
9822 debug(l_proc_name, l_proc_step);
9823 END IF;
9824
9825 END IF; -- IF l_absence.business_group_id <> g_smp_business_group_id
9826
9827 l_smp_element_type_id := g_smp_element_type_id;
9828 l_smp_input_values := g_smp_input_values;
9829 l_smp_element_links:= g_smp_element_links;
9830 l_smp_retro_element_type_id := g_smp_retro_element_type_id;
9831 l_smp_retro_input_values := g_smp_retro_input_values;
9832 l_smp_retro_element_links := g_smp_retro_element_links;
9833
9834
9835 -- IF l_absence.date_end IS NULL -- open ended
9836 -- THEN
9837 --
9838 -- the reason we donot cache this is because
9839 -- this a date effective attribute of SMP
9840 -- we always need to fetch the value as of this absence
9841 --
9842 -- OPEN csr_max_smp_period
9843 -- (l_smp_element_type_id
9844 -- ,l_absence.date_start
9845 -- );
9846 -- FETCH csr_max_smp_period INTO l_max_smp_period;
9847 -- CLOSE csr_max_smp_period;
9848 --
9849 -- l_absence.date_end := l_absence.date_start+l_max_smp_period;
9850 --
9851 -- END IF;
9852
9853 l_range_end_date := LEAST(p_range_end_date,l_absence.date_end);
9854 l_range_start_date := GREATEST(p_range_start_date,l_absence.date_start);
9855
9856 IF g_debug THEN
9857 debug('l_range_start_date:'||l_range_start_date);
9858 debug('l_range_end_date:'||l_range_end_date);
9859 END IF;
9860
9861 l_range_amount := 0;
9862 l_absence_amount := 0;
9863
9864 -- Process any related Statutory Maternity Pay element entries
9865
9866 i:= l_smp_element_links.FIRST;
9867 WHILE i IS NOT NULL
9868 LOOP
9869
9870 l_proc_step := 70+i/1000;
9871 IF g_debug THEN
9872 debug(l_proc_name, 70+i/1000);
9873 debug('l_absence.maternity_id:'||l_absence.maternity_id);
9874 END IF;
9875
9876 FOR r_smp_entry IN
9877 csr_smp_entries
9878 (p_maternity_id => l_absence.maternity_id
9879 -- Pass Primary Assignment Id as the SMP element entries
9880 -- will be created for primary assignment
9881 ,p_primary_assignment_id => l_primary_assignment_id
9882 --p_assignment_id
9883 ,p_element_link_id => l_smp_element_links(i).id
9884 -- ,p_amount_iv_id => l_smp_input_values(1).id
9885 -- ,p_week_commencing_iv_id => l_smp_input_values(2).id
9886 -- ,p_rate_iv_id => l_smp_input_values(3).id
9887 -- ,p_recoverable_amount_iv_id => l_smp_input_values(4).id
9888 )
9889 LOOP
9890
9891 l_proc_step := 75+i/1000;
9892 IF g_debug THEN
9893 debug(l_proc_name, 75+i/1000);
9894 debug('r_smp_entry.element_entry_id:'||r_smp_entry.element_entry_id);
9895 debug('r_smp_entry.effective_start_date:'||r_smp_entry.effective_start_date);
9896 debug('r_smp_entry.effective_end_date:'||r_smp_entry.effective_end_date);
9897 --debug('r_smp_entry.week_commencing:'||r_smp_entry.week_commencing);
9898 --debug('r_smp_entry.amount:'||r_smp_entry.amount);
9899 --debug('r_smp_entry.rate:'||r_smp_entry.rate);
9900 --debug('r_smp_entry.recoverable_amount:'||r_smp_entry.recoverable_amount);
9901 END IF;
9902
9903
9904 j := l_smp_input_values.FIRST;
9905 WHILE j IS NOT NULL
9906 LOOP
9907
9908 OPEN get_element_entry_value
9909 (p_element_entry_id => r_smp_entry.element_entry_id
9910 ,p_effective_date => r_smp_entry.effective_start_date
9911 ,p_input_value_id => l_smp_input_values(j).id
9912 );
9913 FETCH get_element_entry_value INTO l_screen_entry_value;
9914 CLOSE get_element_entry_value;
9915 IF j = 1 THEN -- its amount
9916 r_smp_entry.amount :=
9917 fnd_number.canonical_to_number(l_screen_entry_value);
9918 END IF;
9919 IF j = 2 THEN -- its week_commencing
9920 r_smp_entry.week_commencing :=
9921 fnd_date.canonical_to_date(l_screen_entry_value);
9922 END IF;
9923 --IF j = 3 THEN -- its rate (text)
9924 -- r_smp_entry.rate :=
9925 -- l_screen_entry_value;
9926 --END IF;
9927 --IF j = 4 THEN -- its recoverable_amount
9928 -- r_smp_entry.l_smp_retro_input_valuesrecoverable_amount:=
9929 -- fnd_number.canonical_to_number(l_screen_entry_value);
9930 --END IF;
9931
9932 j := l_smp_input_values.NEXT(j);
9933 END LOOP;
9934
9935 l_proc_step := 77+i/1000;
9936 IF g_debug THEN
9937 debug(l_proc_name, 77+i/1000);
9938 debug('r_smp_entry.week_commencing:'||r_smp_entry.week_commencing);
9939 debug('r_smp_entry.amount:'||r_smp_entry.amount);
9940 --debug('r_smp_entry.rate:'||r_smp_entry.rate);
9941 --debug('r_smp_entry.recoverable_amount:'||r_smp_entry.recoverable_amount);
9942 END IF;
9943
9944
9945 l_smp_entry_amount :=
9946 get_smp_entry_overlap_amount
9947 (r_smp_entry
9948 ,l_range_start_date
9949 ,l_range_end_date);
9950
9951 l_range_amount := l_smp_entry_amount + l_range_amount;
9952
9953 l_absence_amount := r_smp_entry.amount + l_absence_amount;
9954
9955 IF g_debug THEN
9956 debug('SubTotal:l_range_amount:'||l_range_amount);
9957 debug('SubTotal:l_absence_amount:'||l_absence_amount);
9958 END IF;
9959
9960 END LOOP;
9961
9962 i:= l_smp_element_links.NEXT(i);
9963 END LOOP;
9964
9965
9966 -- Process any related SMP Corrections element entries
9967 i:= l_smp_retro_element_links.FIRST;
9968 WHILE i IS NOT NULL
9969 LOOP
9970
9971 l_proc_step := 80+i/1000;
9972 IF g_debug THEN
9973 debug(l_proc_name, 80+i/1000);
9974 debug('l_absence.maternity_id:'||l_absence.maternity_id);
9975 END IF;
9976
9977 FOR r_smp_entry IN
9978 csr_smp_entries
9979 (p_maternity_id => l_absence.maternity_id
9980 ,p_primary_assignment_id => p_assignment_id
9981 ,p_element_link_id => l_smp_retro_element_links(i).id
9982 -- ,p_amount_iv_id => l_smp_retro_input_values(1).id
9983 -- ,p_week_commencing_iv_id => l_smp_retro_input_values(2).id
9984 -- ,p_rate_iv_id => l_smp_retro_input_values(3).id
9985 -- ,p_recoverable_amount_iv_id => l_smp_retro_input_values(4).id
9986 )
9987 LOOP
9988
9989 l_proc_step := 85+i/1000;
9990 IF g_debug THEN
9991 debug(l_proc_name, 85+i/1000);
9992 debug('r_smp_entry.element_entry_id:'||r_smp_entry.element_entry_id);
9993 debug('r_smp_entry.effective_start_date:'||r_smp_entry.effective_start_date);
9994 debug('r_smp_entry.effective_end_date:'||r_smp_entry.effective_end_date);
9995 --debug('r_smp_entry.week_commencing:'||r_smp_entry.week_commencing);
9996 --debug('r_smp_entry.amount:'||r_smp_entry.amount);
9997 --debug('r_smp_entry.rate:'||r_smp_entry.rate);
9998 --debug('r_smp_entry.recoverable_amount:'||r_smp_entry.recoverable_amount);
9999 END IF;
10000
10001
10002 j := l_smp_retro_input_values.FIRST;
10003 WHILE j IS NOT NULL
10004 LOOP
10005
10006 OPEN get_element_entry_value
10007 (p_element_entry_id => r_smp_entry.element_entry_id
10008 ,p_effective_date => r_smp_entry.effective_start_date
10009 ,p_input_value_id => l_smp_retro_input_values(j).id
10010 );
10011 FETCH get_element_entry_value INTO l_screen_entry_value;
10012 CLOSE get_element_entry_value;
10013 IF j = 1 THEN -- its amount
10014 r_smp_entry.amount :=
10015 fnd_number.canonical_to_number(l_screen_entry_value);
10016 END IF;
10017 IF j = 2 THEN -- its week_commencing
10018 r_smp_entry.week_commencing :=
10019 fnd_date.canonical_to_date(l_screen_entry_value);
10020 END IF;
10021 --IF j = 3 THEN -- its rate (text)
10022 -- r_smp_entry.rate :=
10023 -- l_screen_entry_value;
10024 --END IF;
10025 --IF j = 4 THEN -- its recoverable_amount
10026 -- r_smp_entry.l_smp_retro_input_valuesrecoverable_amount:=
10027 -- fnd_number.canonical_to_number(l_screen_entry_value);
10028 --END IF;
10029
10030 j := l_smp_retro_input_values.NEXT(j);
10031 END LOOP;
10032
10033 l_proc_step := 87+i/1000;
10034 IF g_debug THEN
10035 debug(l_proc_name, 87+i/1000);
10036 debug('r_smp_entry.week_commencing:'||r_smp_entry.week_commencing);
10037 debug('r_smp_entry.amount:'||r_smp_entry.amount);
10038 --debug('r_smp_entry.rate:'||r_smp_entry.rate);
10039 --debug('r_smp_entry.recoverable_amount:'||r_smp_entry.recoverable_amount);
10040 END IF;
10041
10042
10043 l_smp_entry_amount :=
10044 get_smp_entry_overlap_amount
10045 (r_smp_entry
10046 ,l_range_start_date
10047 ,l_range_end_date);
10048
10049 l_range_amount := l_smp_entry_amount + l_range_amount;
10050
10051 l_absence_amount := r_smp_entry.amount + l_absence_amount;
10052
10053 IF g_debug THEN
10054 debug('SubTotal:l_range_amount:'||l_range_amount);
10055 debug('SubTotal:l_absence_amount:'||l_absence_amount);
10056 END IF;
10057
10058 END LOOP;
10059
10060 i:= l_smp_retro_element_links.NEXT(i);
10061 END LOOP;
10062
10063 l_proc_step := 90;
10064 IF g_debug THEN
10065 debug(l_proc_name,l_proc_step);
10066 END IF;
10067
10068 -- END IF; -- IF l_primary_assignment_id = p_assignment_id
10069
10070 END IF; --IF csr_absence_details%FOUND and abs.bg = p_bg
10071 CLOSE csr_absence_details;
10072
10073
10074 p_range_amount := ROUND(l_range_amount,2);
10075 p_absence_amount := ROUND(l_absence_amount,2);
10076
10077 l_proc_step := 100;
10078 IF g_debug THEN
10079 debug(l_proc_name,l_proc_step);
10080 debug('l_range_amount:'||l_range_amount);
10081 debug('l_absence_amount:'||l_absence_amount);
10082 debug('p_range_amount:'||p_range_amount);
10083 debug('p_absence_amount:'||p_absence_amount);
10084 debug_exit(l_proc_name);
10085 END IF;
10086
10087 EXCEPTION
10088 WHEN OTHERS THEN
10089 clear_cache;
10090 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
10091 debug_others(l_proc_name,l_proc_step);
10092 IF g_debug THEN
10093 debug('Leaving: '||l_proc_name,-999);
10094 END IF;
10095 fnd_message.raise_error;
10096 ELSE
10097 RAISE;
10098 END IF;
10099 END get_range_and_absence_smp;
10100 --
10101 --
10102 --
10103 FUNCTION get_absence_smp
10104 (p_business_group_id IN NUMBER
10105 ,p_assignment_id IN NUMBER
10106 ,p_absence_attendance_id IN NUMBER
10107 ,p_range_start_date IN DATE
10108 ,p_range_end_date IN DATE
10109 ) RETURN NUMBER
10110 IS
10111
10112 l_range_amount NUMBER:=0;
10113 l_absence_amount NUMBER:=0;
10114
10115 l_proc_step NUMBER(38,10);
10116 l_proc_name VARCHAR2(61):=
10117 g_package_name||'get_absence_smp';
10118
10119 BEGIN
10120
10121 g_debug := hr_utility.debug_enabled;
10122
10123 IF g_debug THEN
10124 debug_enter(l_proc_name);
10125 debug('p_absence_attendance_id:'||p_absence_attendance_id);
10126 debug('p_business_group_id:'||p_business_group_id);
10127 debug('p_assignment_id:'||p_assignment_id);
10128 debug('p_range_start_date:'||p_range_start_date);
10129 debug('p_range_end_date:'||p_range_end_date);
10130 END IF;
10131
10132 get_range_and_absence_smp
10133 (p_business_group_id => p_business_group_id
10134 ,p_assignment_id => p_assignment_id
10135 ,p_absence_attendance_id => p_absence_attendance_id
10136 ,p_range_start_date => p_range_start_date
10137 ,p_range_end_date => p_range_end_date
10138 ,p_absence_category => 'M' -- Maternity
10139 ,p_range_amount => l_range_amount -- OUT
10140 ,p_absence_amount => l_absence_amount -- OUT
10141 );
10142
10143 l_proc_step := 90;
10144 IF g_debug THEN
10145 debug(l_proc_name, l_proc_step);
10146 debug('l_range_amount:'||l_range_amount);
10147 debug('l_absence_amount:'||l_absence_amount);
10148 debug_exit(l_proc_name);
10149 END IF;
10150
10151 RETURN l_range_amount;
10152
10153 EXCEPTION
10154 WHEN OTHERS THEN
10155 clear_cache;
10156 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
10157 debug_others(l_proc_name,l_proc_step);
10158 IF g_debug THEN
10159 debug('Leaving: '||l_proc_name,-999);
10160 END IF;
10161 fnd_message.raise_error;
10162 ELSE
10163 RAISE;
10164 END IF;
10165 END get_absence_smp;
10166 --
10167 --
10168 --
10169 FUNCTION get_period_ssp
10170 (p_business_group_id IN NUMBER -- Context
10171 ,p_assignment_id IN NUMBER -- Context
10172 ,p_range_start_date IN DATE
10173 ,p_range_end_date IN DATE
10174 ) RETURN NUMBER
10175 IS
10176 BEGIN
10177 NULL;
10178 END get_period_ssp;
10179 --
10180 --
10181 --
10182 FUNCTION pqp_gb_get_absence_ssp
10183 (p_business_group_id IN NUMBER
10184 ,p_assignment_id IN NUMBER
10185 ,p_absence_id IN NUMBER
10186 ,p_start_date IN DATE
10187 ,p_end_date IN DATE
10188 ,p_range_total OUT NOCOPY NUMBER
10189 ,p_absence_total OUT NOCOPY NUMBER
10190 ,p_error_code OUT NOCOPY NUMBER
10191 ,p_error_msg OUT NOCOPY VARCHAR2
10192 ) RETURN NUMBER
10193 IS
10194 l_proc_step NUMBER(38,10);
10195 l_proc_name VARCHAR2(61):=
10196 g_package_name||'pqp_gb_get_absence_ssp';
10197
10198 l_range_total NUMBER;
10199 l_absence_total NUMBER;
10200 l_absence csr_absence_details%ROWTYPE;
10201 --l_absence_assignment_details csr_absence_primary_assignment%ROWTYPE;
10202
10203 l_error_code fnd_new_messages.message_number%TYPE:= 0;
10204 l_error_msg fnd_new_messages.message_text%TYPE;
10205
10206 BEGIN
10207
10208 g_debug := hr_utility.debug_enabled;
10209 IF g_debug THEN
10210 debug_enter(l_proc_name);
10211 END IF;
10212
10213 p_error_code := 0;
10214 p_error_msg := NULL;
10215
10216 OPEN csr_absence_details(p_absence_id);
10217 FETCH csr_absence_details INTO l_absence;
10218 IF csr_absence_details%FOUND
10219 THEN
10220 CLOSE csr_absence_details;
10221
10222 l_proc_step := 10;
10223 IF g_debug THEN
10224 debug(l_proc_name,l_proc_step);
10225 END IF;
10226
10227 get_range_and_absence_ssp
10228 (p_assignment_id => p_assignment_id
10229 ,p_business_group_id => p_business_group_id
10230 ,p_absence_attendance_id => p_absence_id
10231 ,p_range_start_date => p_start_date
10232 ,p_range_end_date => p_end_date
10233 ,p_range_amount => p_range_total
10234 ,p_absence_amount => p_absence_total
10235 );
10236
10237 l_proc_step := 20;
10238 IF g_debug THEN
10239 debug(l_proc_name,l_proc_step);
10240 END IF;
10241
10242 -- p_absence_total :=
10243 -- get_absence_ssp
10244 -- (p_assignment_id => p_assignment_id
10245 -- ,p_business_group_id => p_business_group_id
10246 -- ,p_absence_attendance_id => p_absence_id
10247 -- ,p_range_start_date => NVL(l_absence.date_start
10248 -- ,l_absence.sickness_start_date)
10249 -- ,p_range_end_date => NVL(l_absence.date_end
10250 -- ,NVL(l_absence.sickness_end_date
10251 -- ,hr_api.g_eot))
10252 -- );
10253
10254
10255 END IF; -- IF csr_absence_details%FOUND
10256 IF csr_absence_details%ISOPEN THEN
10257 CLOSE csr_absence_details;
10258 END IF;
10259
10260 l_proc_step := 40;
10261 IF g_debug THEN
10262 debug(l_proc_name,l_proc_step);
10263 debug('p_range_total:'||p_range_total);
10264 debug('p_absence_total:'||p_absence_total);
10265 debug('p_error_code:'||p_error_code);
10266 debug('p_error_msg:'||p_error_msg);
10267 debug('l_error_code:'||l_error_code);
10268 debug_exit(l_proc_name);
10269 END IF;
10270
10271 RETURN l_error_code;
10272
10273 EXCEPTION
10274 WHEN OTHERS THEN
10275 p_error_msg := SQLERRM;
10276 p_error_code := SQLCODE;
10277 l_error_code := -1;
10278 clear_cache;
10279 --IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
10280 debug_others(l_proc_name,l_proc_step);
10281 IF g_debug THEN
10282 debug('Leaving: '||l_proc_name,-999);
10283 END IF;
10284 --fnd_message.raise_error;
10285
10286 RETURN l_error_code;
10287 --ELSE
10288 -- RAISE;
10289 --END IF;
10290 END pqp_gb_get_absence_ssp;
10291 --
10292 --
10293 --
10294 FUNCTION pqp_gb_get_absence_smp
10295 (p_business_group_id IN NUMBER
10296 ,p_assignment_id IN NUMBER
10297 ,p_absence_id IN NUMBER
10298 ,p_start_date IN DATE
10299 ,p_end_date IN DATE
10300 ,p_range_total OUT NOCOPY NUMBER
10301 ,p_absence_total OUT NOCOPY NUMBER
10302 ,p_error_code OUT NOCOPY NUMBER
10303 ,p_error_msg OUT NOCOPY VARCHAR2
10304 ) RETURN NUMBER
10305 IS
10306
10307 l_absence csr_absence_details%ROWTYPE;
10308 l_error_code fnd_new_messages.message_number%TYPE:= 0;
10309 --l_error_msg fnd_new_messages.message_text%TYPE;
10310
10311
10312 l_proc_step NUMBER(38,10);
10313 l_proc_name VARCHAR2(61):=
10314 g_package_name||'pqp_gb_get_absence_smp';
10315
10316 BEGIN
10317
10318 IF g_debug THEN
10319 debug_enter(l_proc_name);
10320 debug('p_business_group_id:'||p_business_group_id);
10321 debug('p_assignment_id:'||p_assignment_id);
10322 debug('p_absence_id:'||p_absence_id);
10323 debug('p_start_date:'||p_start_date);
10324 debug('p_end_date:'||p_end_date);
10325 END IF;
10326
10327 p_error_code := 0;
10328 p_error_msg := NULL;
10329
10330 OPEN csr_absence_details(p_absence_id);
10331 FETCH csr_absence_details INTO l_absence;
10332 IF csr_absence_details%FOUND
10333 THEN
10334 CLOSE csr_absence_details;
10335
10336 l_proc_step := 10;
10337 IF g_debug THEN
10338 debug(l_proc_name,l_proc_step);
10339 END IF;
10340
10341 -- p_range_total :=
10342 get_range_and_absence_smp
10343 (p_assignment_id => p_assignment_id
10344 ,p_business_group_id => p_business_group_id
10345 ,p_absence_attendance_id => p_absence_id
10346 ,p_range_start_date => p_start_date
10347 ,p_range_end_date => p_end_date
10348 ,p_absence_category => 'M' -- Maternity
10349 ,p_range_amount => p_range_total
10350 ,p_absence_amount => p_absence_total
10351 );
10352
10353 l_proc_step := 20;
10354 IF g_debug THEN
10355 debug(l_proc_name,l_proc_step);
10356 END IF;
10357
10358 -- p_absence_total :=
10359 -- get_absence_smp
10360 -- (p_assignment_id => p_assignment_id
10361 -- ,p_business_group_id => p_business_group_id
10362 -- ,p_absence_attendance_id => p_absence_id
10363 -- ,p_range_start_date => NVL(l_absence.date_start
10364 -- ,l_absence.date_projected_start)
10365 -- ,p_range_end_date => NVL(l_absence.date_end
10366 -- ,NVL(l_absence.date_projected_end
10367 -- ,hr_api.g_eot))
10368 -- );
10369
10370
10371 END IF; -- IF csr_absence_details%FOUND
10372
10373 IF csr_absence_details%ISOPEN THEN
10374 CLOSE csr_absence_details;
10375 END IF;
10376
10377 l_proc_step := 40;
10378 IF g_debug THEN
10379 debug(l_proc_name,l_proc_step);
10380 debug('p_range_total:'||p_range_total);
10381 debug('p_absence_total:'||p_absence_total);
10382 debug('p_error_code:'||p_error_code);
10383 debug('p_error_msg:'||p_error_msg);
10384 debug_exit(l_proc_name);
10385 END IF;
10386
10387 RETURN l_error_code;
10388
10389 EXCEPTION
10390 WHEN OTHERS THEN
10391 p_error_msg := SQLERRM;
10392 p_error_code := SQLCODE;
10393 l_error_code := -1;
10394 clear_cache;
10395 --IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
10396 debug_others(l_proc_name,l_proc_step);
10397 IF g_debug THEN
10398 debug('Leaving: '||l_proc_name,-999);
10399 END IF;
10400 --fnd_message.raise_error;
10401
10402 RETURN l_error_code;
10403 --ELSE
10404 -- RAISE;
10405 --END IF;
10406 END pqp_gb_get_absence_smp;
10407 --
10408 --
10409 --
10410
10411 -- This function is returns the number of days paid for a employee at a
10412 -- certain pay level. pay level is a input parameter.this returns only
10413 -- for absence types of Sickness and Maternity.
10414
10415
10416 FUNCTION get_absence_paid_days_tp
10417 ( p_assignment_id IN NUMBER
10418 ,p_start_date IN DATE
10419 ,p_end_date IN DATE
10420 ,p_level_of_pay IN VARCHAR2
10421 ) RETURN NUMBER
10422 IS
10423
10424 CURSOR csr_paid_days_for_this_plan
10425 (p_assigment_id IN NUMBER
10426 ,p_plan_id IN NUMBER
10427 ,p_level_of_payment IN VARCHAR2
10428 ,p_range_start_date IN DATE
10429 ,p_range_end_date IN DATE
10430 ) IS
10431 SELECT NVL(SUM(gda.duration),0) days
10432 FROM pqp_gap_absence_plans gap
10433 ,pqp_gap_daily_absences gda
10434 WHERE gap.assignment_id = p_assignment_id
10435 AND gap.pl_id = p_plan_id
10436 AND gda.gap_absence_plan_id = gap.gap_absence_plan_id
10437 -- commented out due to perf changes
10438 -- AND EXISTS ( SELECT 1
10439 -- FROM pay_element_type_extra_info eei
10440 -- WHERE eei.eei_information30 IN ( 'Sickness','Maternity')
10441 -- AND eei.eei_information1 = gap.pl_id
10442 -- )
10443 AND gda.level_of_pay = p_level_of_payment
10444 AND gda.absence_date
10445 BETWEEN p_range_start_date
10446 AND p_range_end_date
10447
10448 ;
10449
10450 CURSOR csr_all_osp_omp_plans IS
10451 SELECT DISTINCT eei.eei_information1
10452 FROM pay_element_type_extra_info eei
10453 WHERE eei.information_type IN -- is indexed
10454 ('PQP_GB_OMP_ABSENCE_PLAN_INFO'
10455 ,'PQP_GB_OSP_ABSENCE_PLAN_INFO'
10456 )
10457 AND UPPER(eei_information30) IN
10458 ('SICKNESS'
10459 ,'MATERNITY'
10460 );
10461
10462
10463 CURSOR csr_nopay_days_for_this_plan
10464 (p_assigment_id IN NUMBER
10465 ,p_plan_id IN NUMBER
10466 ,p_level_of_payment IN VARCHAR2
10467 ,p_range_start_date IN DATE
10468 ,p_range_end_date IN DATE
10469 ) IS
10470 SELECT MAX(ABSENCE_DATE) NB_END_DT, MIN(ABSENCE_DATE) NB_START_DT
10471 FROM pqp_gap_absence_plans gap
10472 ,pqp_gap_daily_absences gda
10473 WHERE gap.assignment_id = p_assignment_id
10474 AND gap.pl_id = p_plan_id
10475 AND gda.gap_absence_plan_id = gap.gap_absence_plan_id
10476 AND gda.level_of_pay = p_level_of_payment
10477 AND gda.absence_date
10478 BETWEEN p_range_start_date
10479 AND p_range_end_date
10480 group by gda.gap_absence_plan_id;
10481
10482
10483 rec_nopay_days_for_this_plan csr_nopay_days_for_this_plan%ROWTYPE;
10484 i BINARY_INTEGER:= 0;
10485 l_this_plan_id ben_pl_f.pl_id%TYPE;
10486
10487 l_total_paid_days_of_all_plans NUMBER:= 0;
10488 l_paid_days_for_this_plan NUMBER:= 0;
10489
10490 l_proc_step NUMBER(20,10);
10491 l_proc_name VARCHAR2(61):=
10492 g_package_name||'get_absence_paid_days_tp';
10493
10494 BEGIN
10495
10496 IF g_debug THEN
10497 debug_enter(l_proc_name);
10498 debug('p_assignment_id:'||p_assignment_id);
10499 debug('p_start_date:'||p_start_date);
10500 debug('p_end_date:'||p_end_date);
10501 debug('p_level_of_pay:'||p_level_of_pay);
10502 END IF;
10503
10504 FOR l_an_osp_omp_plan IN csr_all_osp_omp_plans
10505 LOOP
10506
10507 i := i + 1;
10508 l_proc_step := 10+i/10000;
10509 IF g_debug THEN
10510 debug(l_proc_name,10+i/10000);
10511 debug('l_an_osp_omp_plan.eei_information1:'||l_an_osp_omp_plan.eei_information1);
10512 END IF;
10513
10514 l_this_plan_id := TO_NUMBER(l_an_osp_omp_plan.eei_information1);
10515
10516 IF p_level_of_pay = 'NOBAND'
10517 THEN
10518 OPEN csr_nopay_days_for_this_plan
10519 (p_assigment_id => p_assignment_id
10520 ,p_plan_id => l_this_plan_id
10521 ,p_level_of_payment => p_level_of_pay
10522 ,p_range_start_date => p_start_date
10523 ,p_range_end_date => p_end_date
10524 );
10525 LOOP
10526 FETCH csr_nopay_days_for_this_plan INTO rec_nopay_days_for_this_plan;
10527 IF csr_nopay_days_for_this_plan%NOTFOUND THEN
10528 EXIT ;
10529 END IF;
10530 l_paid_days_for_this_plan := get_ssp_smp_paid_days (rec_nopay_days_for_this_plan.NB_START_DT,
10531 rec_nopay_days_for_this_plan.NB_END_DT,
10532 p_assignment_id);
10533 l_proc_step := 20+i/10000;
10534 IF g_debug THEN
10535 debug(l_proc_name,20+i/10000);
10536 debug('l_paid_days_for_this_plan:'||l_paid_days_for_this_plan);
10537 END IF;
10538
10539 l_total_paid_days_of_all_plans :=
10540 l_total_paid_days_of_all_plans
10541 + l_paid_days_for_this_plan;
10542
10543 END LOOP ;
10544 CLOSE csr_nopay_days_for_this_plan;
10545
10546 ELSE
10547 OPEN csr_paid_days_for_this_plan
10548 (p_assigment_id => p_assignment_id
10549 ,p_plan_id => l_this_plan_id
10550 ,p_level_of_payment => p_level_of_pay
10551 ,p_range_start_date => p_start_date
10552 ,p_range_end_date => p_end_date
10553 );
10554
10555 FETCH csr_paid_days_for_this_plan INTO l_paid_days_for_this_plan;
10556 IF csr_paid_days_for_this_plan%FOUND
10557 THEN
10558
10559 l_proc_step := 25+i/10000;
10560 IF g_debug THEN
10561 debug(l_proc_name,25+i/10000);
10562 debug('l_paid_days_for_this_plan:'||l_paid_days_for_this_plan);
10563 END IF;
10564
10565 l_total_paid_days_of_all_plans :=
10566 l_total_paid_days_of_all_plans
10567 + l_paid_days_for_this_plan;
10568
10569 END IF; -- IF csr_paid_days_for_this_plan%FOUND
10570 CLOSE csr_paid_days_for_this_plan;
10571
10572 END IF;
10573
10574
10575
10576 l_proc_step := 30+i/10000;
10577 IF g_debug THEN
10578 debug(l_proc_name,30+i/10000);
10579 debug('l_total_paid_days_of_all_plans:'||l_total_paid_days_of_all_plans);
10580 END IF;
10581
10582 END LOOP; -- FOR l_an_osp_omp_plan IN csr_all_osp_omp_plans
10583
10584 IF g_debug THEN
10585 debug('l_total_paid_days_of_all_plans:'||l_total_paid_days_of_all_plans);
10586 debug_exit(l_proc_name);
10587 END IF;
10588
10589 RETURN l_total_paid_days_of_all_plans;
10590
10591 EXCEPTION
10592 WHEN OTHERS THEN
10593 clear_cache;
10594 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
10595 debug_others(l_proc_name,l_proc_step);
10596 IF g_debug THEN
10597 debug('Leaving: '||l_proc_name,-999);
10598 END IF;
10599 fnd_message.raise_error;
10600 ELSE
10601 RAISE;
10602 END IF;
10603 END get_absence_paid_days_tp ;
10604
10605
10606 ---- For CS Added
10607
10608 -- This Function gets the scheme Details based on element_type_id available as context
10609 -- and gets the entitlement balance for all bands at one go
10610 FUNCTION get_all_band_cs_4_yr_ent_bal(
10611 p_business_group_id IN NUMBER
10612 ,p_assignment_id IN NUMBER
10613 ,p_element_type_id IN NUMBER
10614 ,p_effective_date IN DATE
10615 ,p_band1_ent_bal OUT NOCOPY NUMBER
10616 ,p_band2_ent_bal OUT NOCOPY NUMBER
10617 ,p_band3_ent_bal OUT NOCOPY NUMBER
10618 ,p_band4_ent_bal OUT NOCOPY NUMBER
10619 ,p_noband_ent_bal OUT NOCOPY NUMBER
10620 ,p_error_message OUT NOCOPY VARCHAR2 )
10621 RETURN NUMBER IS
10622 l_error_code fnd_new_messages.message_number%TYPE:= 0;
10623 l_proc_step NUMBER(38,10):=0;
10624 l_proc_name VARCHAR2(61):=
10625 g_package_name||'get_all_band_cs_4_yr_ent_bal';
10626 l_retval number ;
10627
10628 BEGIN
10629
10630 IF g_debug THEN
10631 debug_enter(l_proc_name);
10632 debug('p_business_group_id:'||p_business_group_id);
10633 debug('p_assignment_id:'||p_assignment_id);
10634 debug('p_element_type_id:'||p_element_type_id);
10635 debug('p_effective_date:'||p_effective_date);
10636 END IF ;
10637 l_proc_step := 10 ;
10638 p_band1_ent_bal := get_band_ent_bal_by_ele_typ_id
10639 ( p_business_group_id => p_business_group_id
10640 ,p_effective_date => p_effective_date
10641 ,p_assignment_id => p_assignment_id
10642 ,p_element_type_id => p_element_type_id
10643 ,p_level_of_entitlement => 'BAND1'
10644 ,p_error_code => l_error_code
10645 ,p_error_message => p_error_message
10646 ,p_days_hours => 'WEEKS'
10647 );
10648
10649 IF l_error_code < 0 THEN
10650 RETURN -1;
10651 END IF; -- End if of check for error code ...
10652 IF g_debug THEN
10653 debug('BAND1:'||p_band1_ent_bal);
10654 END IF ;
10655 l_proc_step := 20 ;
10656 p_band2_ent_bal := get_band_ent_bal_by_ele_typ_id
10657 ( p_business_group_id => p_business_group_id
10658 ,p_effective_date => p_effective_date
10659 ,p_assignment_id => p_assignment_id
10660 ,p_element_type_id => p_element_type_id
10661 ,p_level_of_entitlement => 'BAND2'
10662 ,p_error_code => l_error_code
10663 ,p_error_message => p_error_message
10664 ,p_days_hours => 'WEEKS'
10665 );
10666
10667 IF l_error_code = -1 THEN
10668 RETURN -1;
10669 END IF; -- End if of check for error code ...
10670 IF g_debug THEN
10671 debug('BAND2:'||p_band2_ent_bal);
10672 END IF ;
10673 l_proc_step := 30 ;
10674 p_band3_ent_bal := get_band_ent_bal_by_ele_typ_id
10675 ( p_business_group_id => p_business_group_id
10676 ,p_effective_date => p_effective_date
10677 ,p_assignment_id => p_assignment_id
10678 ,p_element_type_id => p_element_type_id
10679 ,p_level_of_entitlement => 'BAND3'
10680 ,p_error_code => l_error_code
10681 ,p_error_message => p_error_message
10682 ,p_days_hours => 'WEEKS'
10683 );
10684
10685 IF l_error_code = -1 THEN
10686 RETURN -1;
10687 END IF; -- End if of check for error code ...
10688 IF g_debug THEN
10689 debug('BAND3:'||p_band3_ent_bal);
10690 END IF;
10691 l_proc_step := 40 ;
10692 p_band4_ent_bal := get_band_ent_bal_by_ele_typ_id
10693 ( p_business_group_id => p_business_group_id
10694 ,p_effective_date => p_effective_date
10695 ,p_assignment_id => p_assignment_id
10696 ,p_element_type_id => p_element_type_id
10697 ,p_level_of_entitlement => 'BAND4'
10698 ,p_error_code => l_error_code
10699 ,p_error_message => p_error_message
10700 ,p_days_hours => 'WEEKS'
10701 );
10702
10703 IF l_error_code = -1 THEN
10704 RETURN -1;
10705 END IF; -- End if of check for error code ...
10706 IF g_debug THEN
10707 debug('BAND4:'||p_band4_ent_bal);
10708 END IF;
10709 l_proc_step := 50 ;
10710 p_noband_ent_bal := get_band_ent_bal_by_ele_typ_id
10711 ( p_business_group_id => p_business_group_id
10712 ,p_effective_date => p_effective_date
10713 ,p_assignment_id => p_assignment_id
10714 ,p_element_type_id => p_element_type_id
10715 ,p_level_of_entitlement => 'NOBAND'
10716 ,p_error_code => l_error_code
10717 ,p_error_message => p_error_message
10718 ,p_days_hours => 'WEEKS'
10719 );
10720
10721 IF l_error_code = -1 THEN
10722 RETURN -1;
10723 END IF; -- End if of check for error code ...
10724 IF g_debug THEN
10725 debug('NOBAND:'||p_noband_ent_bal);
10726 END IF;
10727 l_proc_step := 60 ;
10728 debug_exit(l_proc_name);
10729 RETURN 0;
10730
10731 EXCEPTION
10732 WHEN OTHERS THEN
10733 clear_cache;
10734 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
10735 debug_others(l_proc_name,l_proc_step);
10736 IF g_debug THEN
10737 debug('Leaving: '||l_proc_name,-999);
10738 END IF;
10739 fnd_message.raise_error;
10740 ELSE
10741 RAISE;
10742 END IF;
10743
10744 END get_all_band_cs_4_yr_ent_bal ;
10745
10746
10747
10748 -- This Procedure returns a pl/sql table with the defined entitlements
10749 -- in the UDT for the length of service.
10750
10751 PROCEDURE get_entitlements
10752 (p_assignment_id IN NUMBER
10753 ,p_business_group_id IN NUMBER
10754 ,p_effective_date IN DATE
10755 ,p_pl_id IN NUMBER
10756 ,p_entitlement_table_id IN NUMBER
10757 ,p_benefits_length_of_service IN NUMBER
10758 ,p_band_entitlements OUT NOCOPY pqp_absval_pkg.t_entitlements
10759 ,p_entitlement_bands_list_name IN VARCHAR2 DEFAULT
10760 'PQP_GAP_ENTITLEMENT_BANDS'
10761 )
10762 IS
10763 l_user_column_id pay_user_columns.user_column_id%TYPE;
10764 l_band_ent pqp_absval_pkg.t_entitlements;
10765 l_band_entitlement NUMBER;
10766 l_retval NUMBER;
10767
10768 l_proc_step NUMBER(38,10):=0;
10769 l_proc_name VARCHAR2(61):=
10770 g_package_name||'get_entitlements';
10771
10772 i BINARY_INTEGER := 1 ;
10773 l_entitlement_override_is_set BOOLEAN:= FALSE;
10774 l_error_message fnd_new_messages.message_text%TYPE ;
10775
10776
10777
10778 BEGIN
10779 --
10780 IF g_debug THEN
10781 debug_enter(l_proc_name);
10782 debug('p_assignment_id:'||p_assignment_id);
10783 debug('p_business_group_id:'||p_business_group_id);
10784 debug('p_effective_date:'||p_effective_date);
10785 debug('p_pl_id:'||p_pl_id);
10786 debug('p_entitlement_table_id:'||p_entitlement_table_id);
10787 debug('p_benefits_length_of_service:'||p_benefits_length_of_service);
10788 debug('p_entitlement_bands_list_name:'||p_entitlement_bands_list_name);
10789
10790 END IF ;
10791 --
10792
10793 l_entitlement_override_is_set :=
10794 get_override_entitlements
10795 (p_assignment_id => p_assignment_id
10796 ,p_business_group_id => p_business_group_id
10797 ,p_pl_id => p_pl_id
10798 ,p_effective_date => p_effective_date
10799 ,p_band_entitlements => l_band_ent
10800 ,p_absence_pay_plan_class => 'OSP'
10801 ,p_entitlement_bands_list_name => p_entitlement_bands_list_name
10802 );
10803
10804
10805 l_proc_step := 15;
10806 IF g_debug THEN
10807 debug(l_proc_name, l_proc_step);
10808 END IF;
10809
10810 IF NOT l_entitlement_override_is_set THEN
10811
10812 FOR l_get_lookup_info IN csr_get_lookup_info(
10813 p_entitlement_bands_list_name
10814 , 'BAND%') LOOP
10815 l_proc_step := 50;
10816 IF g_debug THEN
10817 debug(l_proc_name, l_proc_step);
10818 debug('l_column_name:'||l_get_lookup_info.meaning);
10819 END IF ;
10820
10821 l_retval :=
10822 pqp_utilities.pqp_gb_get_table_value_id(
10823 p_business_group_id => p_business_group_id
10824 ,p_effective_date => p_effective_date
10825 ,p_table_id => p_entitlement_table_id
10826 ,p_column_name => l_get_lookup_info.meaning
10827 ,p_row_name => p_benefits_length_of_service
10828 ,p_value => l_band_entitlement
10829 ,p_error_msg => l_error_message
10830 ) ;
10831
10832 IF l_retval < 0 THEN
10833
10834 l_proc_step := 60;
10835 IF g_debug THEN
10836 debug(l_proc_name, l_proc_step);
10837 END IF ;
10838
10839 check_error_code(l_retval,l_error_message);
10840 END IF;
10841
10842 IF g_debug THEN
10843 debug('Entitlements:'||l_band_entitlement);
10844 END IF ;
10845
10846 IF l_band_entitlement IS NOT NULL THEN
10847
10848 l_proc_step := 90;
10849 debug(l_proc_name, l_proc_step+i/100);
10850 -- by checking for NOT NULL
10851 -- we are ensuring we only store the details of only those
10852 -- bands which have some information setup even its 0
10853 -- may even check for 0...
10854 l_band_ent(i).band := l_get_lookup_info.lookup_code;
10855 l_band_ent(i).meaning := l_get_lookup_info.meaning ;
10856 l_band_ent(i).entitlement := l_band_entitlement ;
10857
10858 END IF;
10859
10860 l_proc_step := 70;
10861 IF g_debug THEN
10862 debug(l_proc_name, l_proc_step);
10863 END IF ;
10864
10865 i := i + 1 ;
10866
10867 END LOOP ;
10868
10869 END IF; -- IF NOT l_entitlement_override_is_set
10870
10871 l_proc_step := 110;
10872 debug(l_proc_name, l_proc_step);
10873
10874 p_band_entitlements := l_band_ent;
10875
10876 --
10877 debug_exit(l_proc_name);
10878
10879 EXCEPTION
10880 WHEN OTHERS THEN
10881 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
10882 debug_others(l_proc_name,l_proc_step);
10883 IF g_debug THEN
10884 debug('Leaving: '||l_proc_name,-999);
10885 END IF;
10886 fnd_message.raise_error;
10887 ELSE
10888 RAISE;
10889 END IF;
10890 END get_entitlements;
10891 --
10892 -- akarmaka made changes
10893
10894 FUNCTION get_minimum_pay_info
10895 (p_assignment_id IN NUMBER
10896 ,p_business_group_id IN NUMBER
10897 ,p_absence_id IN NUMBER
10898 ,p_minpay_start_date OUT NOCOPY DATE
10899 ,p_minpay_end_date OUT NOCOPY DATE
10900
10901 ) RETURN NUMBER
10902 IS
10903
10904 CURSOR csr_get_minpay_info
10905 IS
10906 SELECT atd.abs_information4 start_date_txt -- minimum pay start day
10907 ,atd.abs_information5 end_date_txt -- minimum pay end day
10908 ,atd.abs_information6 min_pay -- minimum pay value
10909 FROM per_absence_attendances atd, per_all_assignments_f asg
10910 WHERE atd.abs_information_category = 'GB_PQP_OSP_OMP_PART_DAYS'
10911 AND atd.absence_attendance_id = p_absence_id
10912 AND atd.person_id = asg.person_id
10913 AND asg.assignment_id = p_assignment_id
10914 AND atd.business_group_id = p_business_group_id;
10915
10916
10917 l_minimum_pay_info csr_get_minpay_info%ROWTYPE;
10918
10919 l_minpay_rate NUMBER ;
10920
10921 l_proc_step NUMBER(38,10);
10922 l_proc_name VARCHAR2(61):=
10923 g_package_name||'get_minimum_pay_info';
10924
10925 BEGIN
10926
10927 debug_enter(l_proc_name);
10928 debug('p_assignment_id:'||to_char(p_assignment_id));
10929 debug('p_business_group_id'||to_char(p_business_group_id));
10930 debug('p_absence_id'||to_char(p_absence_id));
10931
10932 l_proc_step := 10;
10933 debug(l_proc_name, l_proc_step);
10934
10935 OPEN csr_get_minpay_info;
10936 FETCH csr_get_minpay_info INTO l_minimum_pay_info;
10937
10938 IF csr_get_minpay_info%FOUND THEN
10939
10940 p_minpay_start_date :=
10941 fnd_date.canonical_to_date(l_minimum_pay_info.start_date_txt);
10942 p_minpay_end_date :=
10943 fnd_date.canonical_to_date(l_minimum_pay_info.end_date_txt);
10944 l_minpay_rate := l_minimum_pay_info.min_pay ;
10945 END IF;
10946 CLOSE csr_get_minpay_info;
10947
10948 IF g_debug THEN
10949 debug('p_minpay_start_date: '||to_char(p_minpay_start_date));
10950 debug('p_minpay_end_date: '||to_char(p_minpay_end_date));
10951 debug('l_minpay_rate :'||to_char(l_minpay_rate));
10952 END IF;
10953 IF g_debug THEN
10954 l_proc_step := 20;
10955 debug(l_proc_name, l_proc_step);
10956 END IF;
10957 debug_exit(l_proc_name);
10958
10959 RETURN NVL(l_minpay_rate,0) ;
10960 EXCEPTION
10961 WHEN OTHERS THEN
10962 clear_cache;
10963 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
10964 debug_others(l_proc_name,l_proc_step);
10965 IF g_debug THEN
10966 debug('Leaving: '||l_proc_name,-999);
10967 END IF;
10968 fnd_message.raise_error;
10969 ELSE
10970 RAISE;
10971 END IF;
10972 END get_minimum_pay_info ;
10973 ----------------------------
10974 FUNCTION get_osp_minimum_pay_rate
10975 (p_assignment_id IN NUMBER
10976 ,p_business_group_id IN NUMBER
10977 ,p_pl_id IN NUMBER
10978 ,p_effective_date IN DATE
10979 ) RETURN NUMBER IS
10980
10981 l_min_pay_rate NUMBER;
10982
10983 l_proc_step NUMBER(38,10);
10984 l_proc_name VARCHAR2(61):=
10985 g_package_name||'get_osp_minimum_pay_rate';
10986 l_min_pay_defined BOOLEAN ;
10987
10988 BEGIN
10989
10990 debug_enter(l_proc_name);
10991 debug(p_assignment_id);
10992 debug(p_business_group_id);
10993 debug(p_pl_id);
10994 debug(p_effective_date);
10995
10996
10997 l_proc_step := 10;
10998 debug(l_proc_name, l_proc_step);
10999 -- commenting out the call as the called func
11000 -- definition is changed and is a standalone one
11001 -- which is called from the formula .
11002 --we supporting this piece of code for previous
11003 -- version of OSP payroll formula shipped to customers
11004
11005 /*
11006 l_min_pay_defined := get_minimum_pay_info
11007 (p_assignment_id => p_assignment_id
11008 ,p_business_group_id => p_business_group_id
11009 ,p_pl_id => p_pl_id
11010 ,p_effective_date => p_effective_date
11011 ,p_rate_per_day => l_min_pay_rate
11012 ) ;
11013 */
11014 l_proc_step := 20;
11015 debug(l_proc_name, l_proc_step);
11016
11017 debug_exit(l_proc_name);
11018
11019 RETURN NVL(l_min_pay_rate,0) ;
11020
11021 EXCEPTION
11022 WHEN OTHERS THEN
11023 clear_cache;
11024 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
11025 debug_others(l_proc_name,l_proc_step);
11026 IF g_debug THEN
11027 debug('Leaving: '||l_proc_name,-999);
11028 END IF;
11029 fnd_message.raise_error;
11030 ELSE
11031 RAISE;
11032 END IF;
11033 END get_osp_minimum_pay_rate ;
11034 ---------------------------------
11035 PROCEDURE set_osp_omp_rounding_factors
11036 (p_pl_id IN NUMBER
11037 ,p_pt_entitl_rounding_type OUT NOCOPY VARCHAR2
11038 ,p_pt_rounding_precision OUT NOCOPY NUMBER
11039 ,p_ft_entitl_rounding_type OUT NOCOPY VARCHAR2
11040 ,p_ft_rounding_precision OUT NOCOPY NUMBER
11041 )
11042 IS
11043 l_proc_name VARCHAR2(61):=
11044 g_package_name||
11045 'set_osp_omp_rounding_factors';
11046 l_proc_step NUMBER(20,10) ;
11047 l_pt_val varchar2(15);
11048 l_ft_val varchar2(15);
11049 l_enb_prorat varchar2(5);
11050 l_trunc varchar2(10);
11051 l_err varchar2(100);
11052 l_ret_num NUMBER;
11053
11054 BEGIN
11055 --This function sets the rounding configuration values at plan level.
11056 --1)Gets coded value for the rounding off from Extra Info EIT for
11057 -- Part-Timers and FullTimers.
11058 --2)Passes the coded value to the decode procedure to get the
11059 -- rounding type and precision.
11060 --3)Passes on the values to the out parameters.
11061 --4)Added for precaution...get the entitlement proration
11062 -- if it is Y and No rounding values is provided then
11063 -- by default round it to max precision..5 decimal places
11064 g_debug := hr_utility.debug_enabled;
11065 IF g_debug THEN
11066 debug_enter(l_proc_name);
11067 debug('p_pl_id:'||p_pl_id);
11068 END IF;
11069
11070
11071 --Get Part-Timer rounding config value from EIT in coded form.
11072 l_ret_num:=
11073 pqp_gb_osp_functions.pqp_get_plan_extra_info(
11074 p_pl_id => p_pl_id
11075 ,p_information_type => 'PQP_GB_OSP_ABSENCE_PLAN_INFO'
11076 ,p_segment_name => 'Part Timer Rounding Values'
11077 ,p_value => l_pt_val
11078 ,p_truncated_yes_no => l_trunc
11079 ,p_error_msg => l_err
11080 );
11081
11082
11083 IF l_ret_num <> 0 THEN
11084 pqp_utilities.check_error_code(l_ret_num, l_err);
11085 END IF;
11086
11087 l_proc_step := 20;
11088
11089 IF g_debug THEN
11090 debug(l_proc_name,l_proc_step);
11091 debug('l_pt_val:'||l_pt_val);
11092 debug('l_trunc:'||l_trunc);
11093 END IF;
11094
11095 --Get Full-Timer rounding config value from EIT in coded form.
11096 l_ret_num:=
11097 pqp_gb_osp_functions.pqp_get_plan_extra_info(
11098 p_pl_id => p_pl_id
11099 ,p_information_type => 'PQP_GB_OSP_ABSENCE_PLAN_INFO'
11100 ,p_segment_name => 'Full Timer Rounding Values'
11101 ,p_value => l_ft_val
11102 ,p_truncated_yes_no => l_trunc
11103 ,p_error_msg => l_err
11104 );
11105
11106 IF l_ret_num <> 0 THEN
11107 pqp_utilities.check_error_code(l_ret_num, l_err);
11108 END IF;
11109
11110 l_proc_step := 30;
11111
11112 IF g_debug THEN
11113 debug(l_proc_name,l_proc_step);
11114 debug('l_ft_val:'||l_ft_val);
11115 debug('l_trunc:'||l_trunc);
11116 END IF;
11117
11118
11119
11120 --Get Enable Proration value from EIT
11121 l_ret_num:=
11122 pqp_gb_osp_functions.pqp_get_plan_extra_info(
11123 p_pl_id => p_pl_id
11124 ,p_information_type => 'PQP_GB_OSP_ABSENCE_PLAN_INFO'
11125 ,p_segment_name => 'Enable Entitlement Proration'
11126 ,p_value => l_enb_prorat
11127 ,p_truncated_yes_no => l_trunc
11128 ,p_error_msg => l_err
11129 );
11130
11131
11132 IF l_ret_num <> 0 THEN
11133 pqp_utilities.check_error_code(l_ret_num, l_err);
11134 END IF;
11135
11136 l_proc_step := 35;
11137
11138 IF g_debug THEN
11139 debug(l_proc_name,l_proc_step);
11140 debug('l_enb_prorat:'||l_enb_prorat);
11141 debug('l_trunc:'||l_trunc);
11142 END IF;
11143
11144
11145 --Pass the coded value to the decode procedure for part-timers and
11146 --get the return values in to the out parameters.
11147 pqp_gb_osp_functions.decode_round_config(
11148 p_code => l_pt_val
11149 ,p_rounding_type => p_pt_entitl_rounding_type
11150 ,p_rounding_precision => p_pt_rounding_precision
11151 ,p_enb_prorat => l_enb_prorat
11152 );
11153
11154 l_proc_step := 40;
11155
11156 IF g_debug THEN
11157 debug(l_proc_name,l_proc_step);
11158 END IF;
11159
11160 --Pass the coded value to the decode procedure for full-timers and
11161 --get the return values in to the out parameters.
11162 pqp_gb_osp_functions.decode_round_config(
11163 p_code => l_ft_val
11164 ,p_rounding_type => p_ft_entitl_rounding_type
11165 ,p_rounding_precision => p_ft_rounding_precision
11166 ,p_enb_prorat => l_enb_prorat
11167 );
11168
11169 l_proc_step :=50;
11170
11171 IF g_debug THEN
11172 debug(l_proc_name,l_proc_step);
11173 debug('p_pt_entitl_rounding_type:'||p_pt_entitl_rounding_type);
11174 debug('p_pt_rounding_precision:'||p_pt_rounding_precision);
11175 debug('p_ft_entitl_rounding_type:'||p_ft_entitl_rounding_type);
11176 debug('p_ft_rounding_precision:'||p_ft_rounding_precision);
11177 END IF;
11178
11179 EXCEPTION
11180 WHEN OTHERS THEN
11181 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
11182 pqp_utilities.debug_others
11183 (l_proc_name
11184 ,l_proc_step
11185 );
11186 IF g_debug THEN
11187 debug('Leaving: '||l_proc_name,-999);
11188 END IF;
11189 fnd_message.raise_error;
11190 ELSE
11191 RAISE;
11192 END IF;
11193 END set_osp_omp_rounding_factors;
11194
11195 ---------------------------------
11196
11197
11198
11199 -- This function returns a TRUE/FALSE, TRUE indicating that the
11200 -- absence reported belongs to the person. it checks if the
11201 -- absence_id passed and the context assignment_id both belongs
11202 -- to the same person.
11203
11204 FUNCTION chk_absence_belongs_to_person
11205 ( p_assignment_id IN NUMBER
11206 ,p_business_group_id IN NUMBER
11207 ,p_absence_attendance_id IN NUMBER
11208 ) RETURN BOOLEAN
11209 IS
11210
11211 l_proc_step NUMBER(38,10);
11212 l_proc_name VARCHAR2(61):=
11213 g_package_name||'chk_absence_belongs_to_person';
11214
11215
11216
11217 CURSOR csr_absence_person IS
11218 SELECT abs.person_id
11219 FROM per_absence_attendances abs
11220 WHERE abs.absence_attendance_id = p_absence_attendance_id
11221 AND abs.business_group_id = p_business_group_id ;
11222
11223 CURSOR csr_assignment_person IS
11224 SELECT asg.person_id
11225 FROM per_all_assignments_f asg
11226 WHERE asg.assignment_id = p_assignment_id
11227 AND rownum < 2 ;
11228
11229 l_abs_person_id per_absence_attendances.person_id%TYPE ;
11230 l_asg_person_id per_all_assignments_f.person_id%TYPE ;
11231
11232 BEGIN
11233
11234 IF g_debug THEN
11235 debug_enter(l_proc_name);
11236 debug('p_business_group_id:'||p_business_group_id);
11237 debug('p_assignment_id:'||p_assignment_id);
11238 debug('p_absence_attendance_id:'||p_absence_attendance_id);
11239 END IF;
11240
11241 OPEN csr_absence_person ;
11242 FETCH csr_absence_person INTO l_abs_person_id ;
11243 CLOSE csr_absence_person ;
11244
11245 IF l_abs_person_id IS NOT NULL THEN
11246 l_proc_step := 15 ;
11247 IF g_debug THEN
11248 debug(l_proc_name,l_proc_step);
11249 END IF ;
11250 OPEN csr_assignment_person ;
11251 FETCH csr_assignment_person INTO l_asg_person_id ;
11252 CLOSE csr_assignment_person ;
11253 ELSE
11254 l_proc_step := 20 ;
11255 IF g_debug THEN
11256 debug(l_proc_name,l_proc_step);
11257 END IF ;
11258 RETURN FALSE ;
11259 END IF ;
11260
11261 IF l_abs_person_id = l_asg_person_id THEN
11262 l_proc_step := 25 ;
11263 IF g_debug THEN
11264 debug(l_proc_name,l_proc_step);
11265 END IF ;
11266 RETURN TRUE ;
11267 ELSE
11268 l_proc_step := 30 ;
11269 IF g_debug THEN
11270 debug(l_proc_name,l_proc_step);
11271 END IF ;
11272 RETURN FALSE ;
11273 END IF ;
11274
11275 IF g_debug THEN
11276 debug_exit(l_proc_name);
11277 END IF;
11278
11279 EXCEPTION
11280 WHEN OTHERS THEN
11281 clear_cache;
11282 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
11283 debug_others(l_proc_name,l_proc_step);
11284 IF g_debug THEN
11285 debug('Leaving: '||l_proc_name,-999);
11286 END IF;
11287 fnd_message.raise_error;
11288 ELSE
11289 RAISE;
11290 END IF;
11291 END chk_absence_belongs_to_person ;
11292
11293
11294 -- This function is called through a Formula Fucntion to
11295 -- calculate the Statutory Pay. Based on the absence this
11296 -- function will calculate SSP/SMP/Paternity/Adoption etc.
11297 -- the core logic to calculate values still remains with the
11298 -- lower level functions get_absence_ssp, get_absence_smp
11299 -- for 'S'ickness category get_absence_ssp is called and for
11300 -- other categories we pass absence_category to get_absence_smp
11301 -- and set the element names there based on category. Remaining
11302 -- logic is same for all Paternity, Adoption categories
11303 -- and Maternity.
11304
11305 FUNCTION get_absence_statutory_pay
11306 (p_business_group_id IN NUMBER
11307 ,p_assignment_id IN NUMBER
11308 ,p_absence_attendance_id IN NUMBER
11309 ,p_start_date IN DATE
11310 ,p_end_date IN DATE
11311 ) RETURN NUMBER
11312 IS
11313 l_proc_step NUMBER(38,10);
11314 l_proc_name VARCHAR2(61):=
11315 g_package_name||'get_absence_statutory_pay';
11316
11317 l_statutory_amount NUMBER ;
11318 l_absence_amount NUMBER ;
11319
11320 CURSOR csr_absence_details IS
11321 select abs.person_id, type.absence_category
11322 from per_absence_attendances abs
11323 ,per_absence_attendance_types type
11324 where abs.absence_attendance_type_id = type.absence_attendance_type_id
11325 and abs.absence_attendance_id = p_absence_attendance_id
11326 and abs.business_group_id = p_business_group_id ;
11327
11328 l_absence_details csr_absence_details%ROWTYPE ;
11329 l_absence_belongs_to_person BOOLEAN ;
11330
11331 BEGIN
11332 IF g_debug THEN
11333 debug_enter(l_proc_name);
11334 debug('p_business_group_id:'||p_business_group_id);
11335 debug('p_assignment_id:'||p_assignment_id);
11336 debug('p_absence_attendance_id:'||p_absence_attendance_id);
11337 debug('p_start_date:'||p_start_date);
11338 debug('p_end_date:'||p_end_date);
11339 END IF;
11340
11341 -- Check if the absence_id passed belongs to the assignment_id passed through context.
11342 -- if its not the same Return 0.
11343 -- Fetch the person_id, absence_type from the absence.
11344 -- fetch the person_id, business_group_id of the p_assignment_id
11345 -- compare the person_id and business_group_id
11346 -- does_absence_belongs_to_person
11347
11348
11349 l_absence_belongs_to_person :=
11350 chk_absence_belongs_to_person
11351 (
11352 p_assignment_id => p_assignment_id
11353 ,p_business_group_id => p_business_group_id
11354 ,p_absence_attendance_id => p_absence_attendance_id
11355 ) ;
11356
11357 IF l_absence_belongs_to_person THEN
11358
11359 OPEN csr_absence_details ;
11360 FETCH csr_absence_details INTO l_absence_details ;
11361 CLOSE csr_absence_details ;
11362
11363 IF g_debug THEN
11364 debug('Absence Category:'||l_absence_details.absence_category);
11365 END IF ;
11366
11367 IF l_absence_details.absence_category = 'S' THEN
11368 l_proc_step := 10 ;
11369 IF g_debug THEN
11370 debug(l_proc_name,l_proc_step);
11371 END IF ;
11372 -- call SSP
11373 get_range_and_absence_ssp
11374 (p_business_group_id => p_business_group_id
11375 ,p_assignment_id => p_assignment_id
11376 ,p_absence_attendance_id => p_absence_attendance_id
11377 ,p_range_start_date => p_start_date
11378 ,p_range_end_date => p_end_date
11379 ,p_range_amount => l_statutory_amount
11380 ,p_absence_amount => l_absence_amount
11381 ) ;
11382
11383 ELSIF l_absence_details.absence_category IN
11384 ('M','GB_ADO','GB_PAT_ADO','GB_PAT_BIRTH') THEN
11385 l_proc_step := 20 ;
11386 IF g_debug THEN
11387 debug(l_proc_name,l_proc_step);
11388 END IF ;
11389
11390 get_range_and_absence_smp
11391 (p_business_group_id => p_business_group_id
11392 ,p_assignment_id => p_assignment_id
11393 ,p_absence_attendance_id => p_absence_attendance_id
11394 ,p_range_start_date => p_start_date
11395 ,p_range_end_date => p_end_date
11396 ,p_absence_category => l_absence_details.absence_category
11397 ,p_range_amount => l_statutory_amount
11398 ,p_absence_amount => l_absence_amount
11399 ) ;
11400
11401 END IF ;
11402
11403
11404 IF g_debug THEN
11405 debug('l_absence_amount:'||l_absence_amount);
11406 debug('l_statutory_amount'||l_statutory_amount);
11407 debug_exit(l_proc_name);
11408 END IF;
11409
11410 END IF ; -- IF l_absence_belongs_to_person THEN
11411
11412 RETURN NVL(l_statutory_amount,0) ;
11413
11414 EXCEPTION
11415 WHEN OTHERS THEN
11416 clear_cache;
11417 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
11418 debug_others(l_proc_name,l_proc_step);
11419 IF g_debug THEN
11420 debug('Leaving: '||l_proc_name,-999);
11421 END IF;
11422 fnd_message.raise_error;
11423 ELSE
11424 RAISE;
11425 END IF;
11426 END get_absence_statutory_pay ;
11427
11428 --------------
11429 PROCEDURE decode_round_config
11430 (p_code IN VARCHAR2
11431 ,p_rounding_type OUT NOCOPY VARCHAR2
11432 ,p_rounding_precision OUT NOCOPY NUMBER
11433 ,p_enb_prorat IN VARCHAR2 DEFAULT 'Y'
11434 )
11435 IS
11436 l_proc_name VARCHAR2(61):=
11437 g_package_name||
11438 'decode_round_config';
11439 l_round_to VARCHAR(10);
11440 l_round_val_1 VARCHAR2(1);
11441 l_round_val_2 VARCHAR2(10);
11442 l_proc_step NUMBER;
11443
11444 BEGIN
11445
11446 g_debug := hr_utility.debug_enabled;
11447 l_proc_step := 10;
11448 IF g_debug THEN
11449 debug_enter(l_proc_name);
11450 debug(l_proc_name,l_proc_step);
11451 debug('p_code:'||p_code);
11452 debug('p_enb_prorat:'||p_enb_prorat);
11453 END IF;
11454
11455 IF (p_code IS NULL) OR p_code='NOROUND' THEN
11456 --Check if proration is enabled but no value for
11457 --Rounding config is provided.Defualt prcision to
11458 --5 decimal places...Issue majorly only in QA env.
11459 --as in the previous patch provided to the QA no value
11460 --for rounding exist but the customer deliverable patch
11461 --would always have a value for rounding config if proration
11462 --is enabled.
11463 IF(p_enb_prorat='Y') THEN
11464 l_proc_step := 15;
11465 IF g_debug THEN
11466 debug(l_proc_name,l_proc_step);
11467 END IF;
11468 p_rounding_type:='ROUNDTO';
11469 p_rounding_precision:=5;
11470
11471 ELSE
11472 l_proc_step := 20;
11473 IF g_debug THEN
11474 debug(l_proc_name,l_proc_step);
11475 END IF;
11476 p_rounding_type:='NOROUND';
11477 p_rounding_precision:=0;
11478 END IF;
11479 ELSE
11480 l_proc_step := 25;
11481 IF g_debug THEN
11482 debug(l_proc_name,l_proc_step);
11483 END IF;
11484
11485 l_round_to:=substr(p_code,2,1);
11486 l_round_val_1:=substr(p_code,3,1);
11487 l_round_val_2:=l_round_val_1 || '.' || substr(p_code,4);
11488 p_rounding_precision:=fnd_number.canonical_to_number(l_round_val_2);
11489
11490 IF l_round_to='N' THEN
11491 p_rounding_type:='NEAREST';
11492 ELSIF l_round_to='U' THEN
11493 p_rounding_type:='UP';
11494 ELSIF l_round_to ='P' THEN
11495 p_rounding_type:='ROUNDTO';
11496 ELSE
11497 p_rounding_type:='DOWN';
11498 END IF;
11499 END IF;
11500
11501 l_proc_step := 30;
11502 IF g_debug THEN
11503 debug(l_proc_name,l_proc_step);
11504 debug('p_rounding_type:'||p_rounding_type);
11505 debug('p_rounding_precision:'||p_rounding_precision);
11506 END IF;
11507
11508
11509 EXCEPTION
11510 WHEN OTHERS THEN
11511 clear_cache;
11512 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
11513 debug_others(l_proc_name,l_proc_step);
11514 IF g_debug THEN
11515 debug('Leaving: '||l_proc_name,-999);
11516 END IF;
11517 fnd_message.raise_error;
11518 ELSE
11519 RAISE;
11520 END IF;
11521
11522 END decode_round_config;
11523
11524 -----------------
11525
11526 FUNCTION get_all_band_ent_used_and_rem(
11527 p_business_group_id IN NUMBER
11528 ,p_assignment_id IN NUMBER
11529 ,p_element_type_id IN NUMBER
11530 ,p_date_earned IN DATE
11531 ,p_effective_date IN DATE
11532 ,p_entitlement_tab_id IN NUMBER
11533 ,p_benefits_length_of_service IN NUMBER
11534 ,p_band1_abs_used IN NUMBER
11535 ,p_band2_abs_used IN NUMBER
11536 ,p_band3_abs_used IN NUMBER
11537 ,p_band4_abs_used IN NUMBER
11538 ,p_override_effective_date IN DATE DEFAULT NULL
11539 ,p_scheme_cal_type IN VARCHAR2 DEFAULT 'FIXED'
11540 ,p_band1_ent_used OUT NOCOPY NUMBER
11541 ,p_band2_ent_used OUT NOCOPY NUMBER
11542 ,p_band3_ent_used OUT NOCOPY NUMBER
11543 ,p_band4_ent_used OUT NOCOPY NUMBER
11544 ,p_noband_ent_used OUT NOCOPY NUMBER
11545 ,p_band1_4year_ent_used OUT NOCOPY NUMBER
11546 ,p_band2_4year_ent_used OUT NOCOPY NUMBER
11547 ,p_band3_4year_ent_used OUT NOCOPY NUMBER
11548 ,p_band4_4year_ent_used OUT NOCOPY NUMBER
11549 ,p_noband_4year_ent_used OUT NOCOPY NUMBER
11550 ,p_band1_remaining OUT NOCOPY NUMBER
11551 ,p_band2_remaining OUT NOCOPY NUMBER
11552 ,p_band3_remaining OUT NOCOPY NUMBER
11553 ,p_band4_remaining OUT NOCOPY NUMBER
11554 ,p_band1_percentage OUT NOCOPY NUMBER
11555 ,p_band2_percentage OUT NOCOPY NUMBER
11556 ,p_band3_percentage OUT NOCOPY NUMBER
11557 ,p_band4_percentage OUT NOCOPY NUMBER
11558 ,p_error_msg OUT NOCOPY VARCHAR2
11559 )RETURN NUMBER
11560 IS
11561 l_proc_step NUMBER(38,10):=0;
11562 l_proc_name VARCHAR2(61):=
11563 g_package_name||'get_all_band_entit_remaining';
11564 l_retval NUMBER;
11565 l_error_code NUMBER;
11566 l_band1_entitlement NUMBER;
11567 l_band1_percentage NUMBER;
11568 l_band2_entitlement NUMBER;
11569 l_band2_percentage NUMBER;
11570 l_band3_entitlement NUMBER;
11571 l_band3_percentage NUMBER;
11572 l_band4_entitlement NUMBER;
11573 l_band4_percentage NUMBER;
11574 l_abs_precision NUMBER;
11575 l_error_msg VARCHAR2(250);
11576
11577
11578
11579 BEGIN
11580
11581 --hr_utility.trace_on(null,'rvishwan');
11582 IF g_debug THEN
11583 debug_enter(l_proc_name);
11584 debug(l_proc_name,10);
11585 debug('p_business_group_id:'||p_business_group_id);
11586 debug('p_assignment_id:'||p_assignment_id);
11587 debug('p_element_type_id:'||p_element_type_id);
11588 debug('p_effective_date' || p_effective_date);
11589 debug('p_entitlement_tab_id:'||p_entitlement_tab_id);
11590 debug('p_benefits_length_of_service:'||p_benefits_length_of_service);
11591 debug('p_band1_abs_used:'||p_band1_abs_used);
11592 debug('p_band2_abs_used:'||p_band2_abs_used);
11593 debug('p_band3_abs_used:'||p_band3_abs_used);
11594 debug('p_band4_abs_used:'||p_band4_abs_used);
11595 debug('p_override_effective_date' || p_override_effective_date);
11596 debug('p_scheme_cal_type'|| p_scheme_cal_type);
11597 END IF;
11598
11599
11600 l_abs_precision :=
11601 PQP_UTILITIES.pqp_get_config_value(
11602 p_business_group_id => p_business_group_id
11603 ,p_legislation_code => 'GB'
11604 ,p_column_name => 'PCV_INFORMATION7'
11605 ,p_information_category => 'PQP_GB_OSP_OMP_CONFIG'
11606 );
11607
11608 -- assign the rounding precision to global variable.
11609 -- if null then asssign rounding precision to be 5
11610 -- so by default absemces taken would be rounded to 5 places.
11611 g_abs_rounding_precision :=
11612 FND_NUMBER.canonical_to_number(NVL(l_abs_precision,5));
11613
11614 IF g_debug THEN
11615 debug('g_abs_rounding_precision');
11616 debug(g_abs_rounding_precision);
11617 END IF;
11618
11619 IF g_debug THEN
11620 debug(l_proc_name,20);
11621 END IF;
11622
11623
11624 IF p_scheme_cal_type = 'DUALROLLING'
11625 THEN
11626
11627 IF g_debug THEN
11628 debug(l_proc_name,25);
11629 END IF;
11630
11631 l_retval := get_all_band_cs_4_yr_ent_bal
11632 (p_business_group_id => p_business_group_id
11633 ,p_assignment_id => p_assignment_id
11634 ,p_element_type_id => p_element_type_id
11635 ,p_effective_date => p_effective_date
11636 ,p_band1_ent_bal => p_band1_4year_ent_used
11637 ,p_band2_ent_bal => p_band2_4year_ent_used
11638 ,p_band3_ent_bal => p_band3_4year_ent_used
11639 ,p_band4_ent_bal => p_band4_4year_ent_used
11640 ,p_noband_ent_bal => p_noband_4year_ent_used
11641 ,p_error_message => p_error_msg
11642 );
11643
11644 END IF;
11645
11646 IF g_debug THEN
11647 debug(l_proc_name,30);
11648 END IF;
11649
11650 l_retval := get_all_band_ent_balance
11651 (p_business_group_id => p_business_group_id
11652 ,p_assignment_id => p_assignment_id
11653 ,p_element_type_id => p_element_type_id
11654 ,p_effective_date => p_effective_date
11655 ,p_band1_ent_bal => p_band1_ent_used
11656 ,p_band2_ent_bal => p_band2_ent_used
11657 ,p_band3_ent_bal => p_band3_ent_used
11658 ,p_band4_ent_bal => p_band4_ent_used
11659 ,p_noband_ent_bal => p_noband_ent_used
11660 ,p_error_code => l_error_code
11661 ,p_error_message => p_error_msg
11662 ,p_absence_start_date => p_override_effective_date
11663 );
11664
11665
11666 IF l_retval = -1 THEN
11667 RETURN -1;
11668 END IF; -- End if of check for error code
11669
11670 IF g_debug THEN
11671 debug(l_proc_name,40);
11672 END IF;
11673
11674 l_retval := pqp_get_band_ent_value
11675 (p_business_group_id => p_business_group_id
11676 ,p_effective_date => p_date_earned
11677 ,p_assignment_id => p_assignment_id
11678 ,p_element_type_id => p_element_type_id
11679 ,p_entitlement_tab_id => p_entitlement_tab_id
11680 ,p_benefits_length_of_service => p_benefits_length_of_service
11681 ,p_band1_entitlement => l_band1_entitlement
11682 ,p_band1_percentage => p_band1_percentage
11683 ,p_band2_entitlement => l_band2_entitlement
11684 ,p_band2_percentage => p_band2_percentage
11685 ,p_band3_entitlement => l_band3_entitlement
11686 ,p_band3_percentage => p_band3_percentage
11687 ,p_band4_entitlement => l_band4_entitlement
11688 ,p_band4_percentage => p_band4_percentage
11689 ,p_error_msg => p_error_msg
11690 ,p_override_effective_date => p_override_effective_date
11691 );
11692
11693
11694 IF l_retval = -1 THEN
11695 RETURN -1;
11696 END IF; -- End if of check for error code
11697
11698 IF g_debug THEN
11699 debug(l_proc_name,50);
11700 END IF;
11701
11702 p_band1_remaining := l_band1_entitlement - p_band1_ent_used;
11703 p_band2_remaining := l_band2_entitlement - p_band2_ent_used;
11704 p_band3_remaining := l_band3_entitlement - p_band3_ent_used;
11705 p_band4_remaining := l_band4_entitlement - p_band4_ent_used;
11706
11707 IF p_scheme_cal_type <> 'DUALROLLING' THEN
11708
11709 IF g_debug THEN
11710 debug(l_proc_name,55);
11711 END IF;
11712
11713 p_band1_remaining := p_band1_remaining - p_band1_abs_used ;
11714 p_band2_remaining := p_band2_remaining - p_band2_abs_used ;
11715 p_band3_remaining := p_band3_remaining - p_band3_abs_used ;
11716 p_band4_remaining := p_band4_remaining - p_band4_abs_used ;
11717 p_band1_ent_used := p_band1_ent_used + p_band1_abs_used ;
11718 p_band2_ent_used := p_band2_ent_used + p_band2_abs_used ;
11719 p_band3_ent_used := p_band3_ent_used + p_band3_abs_used ;
11720 p_band4_ent_used := p_band4_ent_used + p_band4_abs_used ;
11721
11722
11723 END IF;
11724
11725
11726 --Round Absence remaining figures
11727
11728 p_band1_remaining := pqp_utilities.round_value_up_down
11729 (p_value_to_round => p_band1_remaining
11730 ,p_base_value => g_abs_rounding_precision
11731 ,p_rounding_type => g_abs_rounding_type
11732 ) ;
11733
11734 p_band2_remaining := pqp_utilities.round_value_up_down
11735 (p_value_to_round => p_band2_remaining
11736 ,p_base_value => g_abs_rounding_precision
11737 ,p_rounding_type => g_abs_rounding_type
11738 ) ;
11739
11740
11741 p_band3_remaining := pqp_utilities.round_value_up_down
11742 (p_value_to_round => p_band3_remaining
11743 ,p_base_value => g_abs_rounding_precision
11744 ,p_rounding_type => g_abs_rounding_type
11745 ) ;
11746
11747 p_band4_remaining := pqp_utilities.round_value_up_down
11748 (p_value_to_round => p_band4_remaining
11749 ,p_base_value => g_abs_rounding_precision
11750 ,p_rounding_type => g_abs_rounding_type
11751 ) ;
11752
11753 IF g_debug THEN
11754 debug(l_proc_name,60);
11755 END IF;
11756
11757 --Round Absence Used One year figures
11758
11759 p_band1_ent_used := pqp_utilities.round_value_up_down
11760 (p_value_to_round => p_band1_ent_used
11761 ,p_base_value => g_abs_rounding_precision
11762 ,p_rounding_type => g_abs_rounding_type
11763 ) ;
11764
11765 p_band2_ent_used := pqp_utilities.round_value_up_down
11766 (p_value_to_round => p_band2_ent_used
11767 ,p_base_value => g_abs_rounding_precision
11768 ,p_rounding_type => g_abs_rounding_type
11769 ) ;
11770
11771
11772 p_band3_ent_used := pqp_utilities.round_value_up_down
11773 (p_value_to_round => p_band3_ent_used
11774 ,p_base_value => g_abs_rounding_precision
11775 ,p_rounding_type => g_abs_rounding_type
11776 ) ;
11777
11778 p_band4_ent_used := pqp_utilities.round_value_up_down
11779 (p_value_to_round => p_band4_ent_used
11780 ,p_base_value => g_abs_rounding_precision
11781 ,p_rounding_type => g_abs_rounding_type
11782 ) ;
11783
11784 p_noband_ent_used := pqp_utilities.round_value_up_down
11785 (p_value_to_round => p_noband_ent_used
11786 ,p_base_value => g_abs_rounding_precision
11787 ,p_rounding_type => g_abs_rounding_type
11788 ) ;
11789
11790
11791 --Round Absence Used Four years figures
11792 IF p_scheme_cal_type = 'DUALROLLING'
11793 THEN
11794
11795 IF g_debug THEN
11796 debug(l_proc_name,65);
11797 END IF;
11798
11799 p_band1_4year_ent_used := pqp_utilities.round_value_up_down
11800 (p_value_to_round => p_band1_4year_ent_used
11801 ,p_base_value => g_abs_rounding_precision
11802 ,p_rounding_type => g_abs_rounding_type
11803 ) ;
11804
11805 p_band2_4year_ent_used := pqp_utilities.round_value_up_down
11806 (p_value_to_round => p_band2_4year_ent_used
11807 ,p_base_value => g_abs_rounding_precision
11808 ,p_rounding_type => g_abs_rounding_type
11809 ) ;
11810
11811
11812 p_band3_4year_ent_used := pqp_utilities.round_value_up_down
11813 (p_value_to_round => p_band3_4year_ent_used
11814 ,p_base_value => g_abs_rounding_precision
11815 ,p_rounding_type => g_abs_rounding_type
11816 ) ;
11817
11818 p_band4_4year_ent_used := pqp_utilities.round_value_up_down
11819 (p_value_to_round => p_band4_4year_ent_used
11820 ,p_base_value => g_abs_rounding_precision
11821 ,p_rounding_type => g_abs_rounding_type
11822 ) ;
11823 p_noband_4year_ent_used := pqp_utilities.round_value_up_down
11824 (p_value_to_round => p_noband_4year_ent_used
11825 ,p_base_value => g_abs_rounding_precision
11826 ,p_rounding_type => g_abs_rounding_type
11827 ) ;
11828
11829 END IF;
11830
11831 IF g_debug THEN
11832 debug('p_band1_ent_used:'||p_band1_ent_used);
11833 debug('p_band2_ent_used:'||p_band2_ent_used);
11834 debug('p_band3_ent_used:'||p_band3_ent_used);
11835 debug('p_band4_ent_used:'||p_band4_ent_used);
11836 debug('p_noband_ent_used:'||p_noband_ent_used);
11837 debug('p_band1_4year_ent_used:'||p_band1_4year_ent_used);
11838 debug('p_band2_4year_ent_used:'||p_band2_4year_ent_used);
11839 debug('p_band3_4year_ent_used:'||p_band3_4year_ent_used);
11840 debug('p_band4_4year_ent_used:'||p_band4_4year_ent_used);
11841 debug('p_noband_4year_ent_used:'||p_noband_4year_ent_used);
11842 debug('p_band1_remaining:'||p_band1_remaining);
11843 debug('p_band2_remaining:'||p_band2_remaining);
11844 debug('p_band3_remaining:'||p_band3_remaining);
11845 debug('p_band4_remaining:'||p_band4_remaining);
11846 debug_exit(l_proc_name);
11847 END IF;
11848
11849 RETURN 0;
11850
11851 EXCEPTION
11852 WHEN OTHERS THEN
11853 clear_cache;
11854 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
11855 debug_others(l_proc_name,l_proc_step);
11856 IF g_debug THEN
11857 debug('Leaving: '||l_proc_name,-999);
11858 END IF;
11859 fnd_message.raise_error;
11860 ELSE
11861 RAISE;
11862 END IF;
11863 END get_all_band_ent_used_and_rem;
11864
11865 ------------------
11866
11867 ---------------
11868 PROCEDURE abs_pension_date_chk( p_date_start IN DATE
11869 ,p_date_end IN DATE
11870 ,p_absence_attendance_id IN NUMBER
11871 ,p_abs_information4 IN VARCHAR2
11872 ,p_abs_information5 IN VARCHAR2
11873 ,p_abs_information6 IN VARCHAR2
11874 -- bug 5975119
11875 ,p_abs_information_category IN VARCHAR2 default null
11876 )
11877 IS
11878
11879 l_proc_step NUMBER(38,10):=0;
11880 l_proc_name VARCHAR2(61):=
11881 g_package_name||'abs_pension_date_check';
11882
11883 l_is_check_true VARCHAR2(2):='Y';
11884 l_is_rate_true VARCHAR2(2):='Y';
11885 l_pension_st_dt DATE DEFAULT NULL;
11886 l_pension_end_dt DATE DEFAULT NULL ;
11887 l_pension_rt NUMBER DEFAULT NULL;
11888 l_abs_id NUMBER;
11889 l_date_end DATE;
11890
11891
11892 BEGIN
11893
11894
11895 g_debug := hr_utility.debug_enabled;
11896
11897 IF g_debug THEN
11898 debug_enter(l_proc_name);
11899 debug(l_proc_name,10);
11900 debug('p_date_start'||p_date_start);
11901 debug('p_date_end'||p_date_end);
11902 debug('p_abs_information4'||p_abs_information4);
11903 debug('p_abs_information5'||p_abs_information5);
11904 debug('p_abs_information6'||p_abs_information6);
11905 debug('p_absence_attendance_id',p_absence_attendance_id);
11906 debug('p_abs_information_category ' || p_abs_information_category);
11907 debug('l_is_check_true'||l_is_check_true);
11908 debug('l_is_rate_true'||l_is_rate_true);
11909
11910 END IF;
11911
11912 -- bug 5975119
11913 IF p_abs_information_category = 'GB_PQP_OSP_OMP_PART_DAYS' THEN
11914 -- absence end date can be null incase of open end date absence
11915 -- so defaulting it to '31-dec-4712'
11916
11917 l_date_end := NVL(p_date_end,to_date('4712/12/31','YYYY/MM/DD')) ;
11918
11919
11920 IF g_debug THEN
11921 debug('l_date_end'||l_date_end);
11922 debug(l_proc_name,15);
11923 END IF;
11924
11925 IF (p_abs_information4 <> hr_api.g_varchar2)
11926 THEN
11927 l_pension_st_dt := fnd_date.canonical_to_date(p_abs_information4);
11928 END IF;
11929
11930 IF g_debug THEN
11931 debug(l_proc_name,25);
11932 END IF;
11933
11934
11935 IF (p_abs_information5 <> hr_api.g_varchar2)
11936 THEN
11937 l_pension_end_dt := fnd_date.canonical_to_date(p_abs_information5);
11938 END IF;
11939
11940 IF g_debug THEN
11941 debug(l_proc_name,35);
11942 END IF;
11943
11944
11945 IF (p_abs_information6 <> hr_api.g_varchar2)
11946 THEN
11947 l_pension_rt := fnd_number.canonical_to_number(p_abs_information6);
11948 END IF;
11949
11950 IF g_debug THEN
11951 debug(l_proc_name,40);
11952 END IF;
11953
11954
11955 IF g_debug THEN
11956 debug('l_pension_st_dt'||l_pension_st_dt);
11957 debug('l_pension_end_dt'||l_pension_end_dt);
11958 debug('l_pension_rt',l_pension_rt);
11959 END IF;
11960
11961
11962
11963 IF (l_pension_end_dt IS NOT NULL OR l_pension_st_dt IS NOT NULL) AND
11964 (l_pension_end_dt IS NULL OR l_pension_st_dt IS NULL)
11965 THEN
11966 hr_utility.set_message(8303,'PQP_230462_ABS_PENSION_DATE');
11967 hr_utility.raise_error;
11968 END IF;
11969
11970 IF g_debug THEN
11971 debug(l_proc_name,45);
11972 END IF;
11973
11974
11975 IF l_pension_end_dt IS NOT NULL THEN
11976
11977 IF g_debug THEN
11978 debug(l_proc_name,50);
11979 END IF;
11980
11981 IF (l_pension_end_dt NOT BETWEEN p_date_start AND l_date_end)
11982 THEN
11983 hr_utility.set_message(8303,'PQP_230462_ABS_PENSION_DATE');
11984 hr_utility.raise_error;
11985
11986 IF g_debug THEN
11987 debug(l_proc_name,60);
11988 debug('l_is_check_true'||l_is_check_true);
11989 END IF;
11990 END IF;
11991 END IF;
11992
11993
11994 IF g_debug THEN
11995 debug(l_proc_name,65);
11996 END IF;
11997
11998 IF l_pension_st_dt IS NOT NULL
11999 AND(l_pension_st_dt NOT BETWEEN p_date_start AND l_date_end)
12000 THEN
12001 hr_utility.set_message(8303,'PQP_230462_ABS_PENSION_DATE');
12002 hr_utility.raise_error;
12003 IF g_debug THEN
12004 debug(l_proc_name,70);
12005 debug('l_is_check_true'||l_is_check_true);
12006 END IF;
12007 END IF;
12008
12009 IF g_debug THEN
12010 debug(l_proc_name,75);
12011 END IF;
12012
12013 IF l_pension_st_dt IS NOT NULL AND l_pension_end_dt IS NOT NULL THEN
12014 IF l_pension_st_dt > l_pension_end_dt THEN
12015 hr_utility.set_message(8303,'PQP_230463_ABS_PENSION_RATE');
12016 hr_utility.raise_error;
12017 END IF;
12018 END IF;
12019
12020 IF g_debug THEN
12021 debug(l_proc_name,80);
12022 END IF;
12023
12024 IF ( (l_pension_rt IS NOT NULL AND l_pension_rt < 0)
12025 OR
12026 ( l_pension_rt IS NULL AND(( l_pension_st_dt IS NOT NULL OR l_pension_end_dt is NOT NULL ) ) )
12027 )
12028
12029 THEN
12030 hr_utility.set_message(8303,'PQP_230463_ABS_PENSION_RATE');
12031 hr_utility.raise_error;
12032 END IF;
12033
12034 IF g_debug THEN
12035 debug(l_proc_name,85);
12036 END IF;
12037
12038 END IF; -- checking abs_information_category
12039 IF g_debug THEN
12040 debug_exit(l_proc_name);
12041 END IF;
12042
12043 EXCEPTION
12044 WHEN OTHERS THEN
12045
12046 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
12047 IF g_debug THEN
12048 debug('Leaving: '||l_proc_name,-999);
12049 END IF;
12050 hr_utility.raise_error;
12051 ELSE
12052 RAISE;
12053 END IF;
12054
12055
12056 END abs_pension_date_chk;
12057
12058 /*
12059 Overloaded function with the old leg hook call signature to avoid invalid
12060 user hook package while installation.The procedure has been nulled out
12061 and exist only for defention purpose.
12062 */
12063
12064 PROCEDURE abs_pension_date_check( p_date_start IN DATE
12065 ,p_date_end IN DATE
12066 ,p_abs_information4 IN VARCHAR2
12067 ,p_abs_information5 IN VARCHAR2
12068 ,p_abs_information6 IN VARCHAR2
12069 )
12070
12071 IS
12072
12073 l_proc_name VARCHAR2(61):=
12074 g_package_name||'abs_pension_date_check--2';
12075
12076
12077 BEGIN
12078 --
12079 -- Added for GSI Bug 5472781
12080 --
12081 IF hr_utility.chk_product_install('Oracle Human Resources', 'GB') THEN
12082 --
12083 IF g_debug THEN
12084 debug_enter(l_proc_name);
12085 END IF;
12086 --
12087 END IF;
12088
12089 EXCEPTION
12090 WHEN OTHERS THEN
12091
12092
12093 IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
12094 IF g_debug THEN
12095 debug('Leaving: '||l_proc_name,-999);
12096 END IF;
12097 hr_utility.raise_error;
12098 ELSE
12099 RAISE;
12100 END IF;
12101
12102
12103 END abs_pension_date_check;
12104
12105
12106 FUNCTION get_ssp_smp_paid_days (
12107 p_range_start_date IN DATE,
12108 p_range_end_date IN DATE,
12109 p_assignment_id IN NUMBER) RETURN NUMBER
12110 IS
12111
12112 c_date date:= p_range_start_date;
12113 i NUMBER ;
12114 SSP_No_Paid_Days NUMBER :=0;
12115 l_person_id number;
12116 l_proc_name VARCHAR2(61):=
12117 g_package_name||'get_ssp_smp_paid_days';
12118
12119
12120 Cursor cur_no_paid_days(p_date date) IS
12121 select 1 from SSP_SMP_ENTRIES_V a1 , per_absence_attendances b1
12122 where a1.person_id = b1.person_id and a1.person_id = l_person_id
12123 and c_date between date_from and least(nvl(date_end, date_to), date_to)
12124 union
12125 (select 1 from SSP_SSP_ENTRIES_V where person_id = l_person_id
12126 and c_date between date_from and date_to
12127 MINUS
12128 SELECT 1 FROM ssp_stoppages_v x, per_absence_attendances y
12129 WHERE X.absence_attendance_id = y.absence_attendance_id AND y.person_id = l_person_id
12130 AND c_date BETWEEN withhold_from AND withhold_to
12131 -- added for Bug 7304886
12132 -- The Work-Off days falling in between Waiting days should NOT be
12133 -- counted under paid days, even the date fall in SPP Paid Week.
12134 MINUS
12135 select 1 from
12136 (SELECT min(withhold_from) min_withhold_from
12137 , max(withhold_to) max_withhold_to
12138 , X.absence_attendance_id
12139 FROM ssp_stoppages_v x, per_absence_attendances y
12140 WHERE X.absence_attendance_id = y.absence_attendance_id
12141 AND y.person_id = l_person_id
12142 AND x.reason = 'Waiting day'
12143 GROUP BY X.absence_attendance_id
12144 )
12145 where c_date between min_withhold_from and max_withhold_to
12146 )
12147 -- addition for Bug 7304886 ends
12148 union
12149 select 1 from SSP_SAP_ENTRIES_V a2 , per_absence_attendances b2
12150 where a2.person_id = b2.person_id and a2.person_id = l_person_id
12151 and c_date between date_from and least(nvl(date_end, date_to), date_to )
12152 union
12153 select 1 from SSP_SPPA_ENTRIES_V a3 , per_absence_attendances b3
12154 where a3.person_id = b3.person_id and a3.person_id = l_person_id
12155 and c_date between date_from and least(nvl(date_end, date_to), date_to );
12156
12157 CURSOR cur_person_id is
12158 SELECT person_id FROM per_all_assignments_f WHERE assignment_id = p_assignment_id;
12159
12160 BEGIN
12161 IF g_debug THEN
12162 debug_enter(l_proc_name);
12163 debug('p_assignment_id: '||p_assignment_id);
12164 debug('NOBAND Start Date: '|| p_range_start_date);
12165 debug('NOBAND End Date: '|| p_range_end_date);
12166 END IF;
12167
12168 OPEN cur_person_id;
12169 FETCH cur_person_id INTO l_person_id;
12170 CLOSE cur_person_id;
12171
12172
12173 LOOP
12174 OPEN cur_no_paid_days(c_date);
12175 FETCH cur_no_paid_days into i;
12176 IF cur_no_paid_days%notfound then
12177 SSP_No_Paid_Days := SSP_No_Paid_Days +1;
12178 END IF;
12179 CLOSE cur_no_paid_days;
12180 c_date := c_date+1;
12181
12182 if c_date > p_range_end_date then
12183 EXIT;
12184 END IF;
12185 END LOOP;
12186 IF g_debug THEN
12187 debug('Statutary No paid days : '|| SSP_No_Paid_Days);
12188 END IF;
12189
12190 RETURN SSP_No_Paid_Days;
12191 EXCEPTION
12192 WHEN OTHERS THEN
12193 clear_cache;
12194 /* IF SQLCODE <> hr_utility.HR_ERROR_NUMBER THEN
12195 debug_others(l_proc_name,l_proc_step);*/
12196 IF g_debug THEN
12197 debug('Leaving: '||l_proc_name,-999);
12198 END IF;
12199 /* fnd_message.raise_error;
12200 ELSE*/
12201 RAISE;
12202 -- END IF;
12203 END get_ssp_smp_paid_days;
12204
12205
12206 END pqp_gb_osp_functions;