1 PACKAGE BODY pqp_gb_t1_pension_extracts AS
2 -- /* $Header: pqpgbtp1.pkb 120.22.12010000.9 2008/10/16 11:56:33 dchindar ship $ */
3 --
4 --
5 -- Exceptions
6 hr_application_error exception;
7 pragma exception_init (hr_application_error, -20001);
8
9
10 --
11 -- Overloaded Debug procedures
12 --
13 PROCEDURE debug
14 (p_trace_message IN VARCHAR2
15 ,p_trace_location IN NUMBER
16 )
17 IS
18 l_padding VARCHAR2(12);
19 l_MAX_MESSAGE_LENGTH NUMBER:= 72;
20 BEGIN
21
22 IF p_trace_location IS NOT NULL THEN
23
24 l_padding := SUBSTR
25 (RPAD(' ',LEAST(g_nested_level,5)*2,' ')
26 ,1,l_MAX_MESSAGE_LENGTH
27 - LEAST(LENGTH(p_trace_message)
28 ,l_MAX_MESSAGE_LENGTH)
29 );
30
31 hr_utility.set_location
32 (l_padding||
33 SUBSTR(p_trace_message
34 ,GREATEST(-LENGTH(p_trace_message),-l_MAX_MESSAGE_LENGTH))
35 ,p_trace_location);
36
37 ELSE
38
39 hr_utility.trace(SUBSTR(p_trace_message,1,250));
40
41 END IF;
42
43 END debug;
44 --
45 --
46 --
47 PROCEDURE debug
48 (p_trace_number IN NUMBER )
49 IS
50 BEGIN
51 debug(fnd_number.number_to_canonical(p_trace_number));
52 END debug;
53 --
54 --
55 --
56 PROCEDURE debug
57 (p_trace_date IN DATE )
58 IS
59 BEGIN
60 debug(fnd_date.date_to_canonical(p_trace_date));
61 END debug;
62 --
63 --
64 --
65 PROCEDURE debug_enter
66 (p_proc_name IN VARCHAR2
67 ,p_trace_on IN VARCHAR2
68 )
69 IS
70
71 l_extract_attributes pqp_gb_tp_pension_extracts.csr_pqp_extract_attributes%ROWTYPE;
72 l_business_group_id per_all_assignments_f.business_group_id%TYPE;
73
74 BEGIN
75
76 IF g_nested_level = 0 THEN -- swtich tracing on/off at the top level only
77
78 -- Set the trace flag, but only the first time around
79 IF g_trace IS NULL THEN
80
81 OPEN pqp_gb_tp_pension_extracts.csr_pqp_extract_attributes;
82 FETCH pqp_gb_tp_pension_extracts.csr_pqp_extract_attributes INTO l_extract_attributes;
83 CLOSE pqp_gb_tp_pension_extracts.csr_pqp_extract_attributes;
84
85 l_business_group_id := fnd_global.per_business_group_id;
86
87 BEGIN
88 g_trace := hruserdt.get_table_value
89 (p_bus_group_id => l_business_group_id
90 ,p_table_name => l_extract_attributes.user_table_name
91 ,p_col_name => 'Attribute Location Qualifier 1'
92 ,p_row_value => 'Debug'
93 ,p_effective_date => NULL -- don't hv the date
94 );
95 EXCEPTION
96 WHEN OTHERS THEN
97 g_trace := 'N';
98 END;
99
100 g_trace := nvl(g_trace,'N');
101
102 debug('UDT Trace Flag : '||g_trace);
103
104 END IF; -- g_trace IS NULL THEN
105
106 IF NVL(p_trace_on,'N') = 'Y'
107 OR
108 g_trace = 'Y' THEN
109
110 hr_utility.trace_on(NULL,'REQID'); -- Pipe name REQIDnnnnnn
111
112 END IF; -- NVL(p_trace_on,'N') = 'Y'
113 --
114 END IF; -- if nested level = 0
115
116 g_nested_level := g_nested_level + 1;
117 debug('Entered: '||NVL(p_proc_name,g_proc_name),g_nested_level*100);
118
119 END debug_enter;
120 --
121 -- debug_exit
122 -- The exception handler of top level functions must call debug_ext
123 -- with p_trace_off = 'Y'
124 --
125 PROCEDURE debug_exit
126 (p_proc_name IN VARCHAR2
127 ,p_trace_off IN VARCHAR2
128 )
129 IS
130 BEGIN
131
132 debug('Leaving: '||NVL(p_proc_name,g_proc_name),-g_nested_level*100);
133 g_nested_level := g_nested_level - 1;
134
135 -- debug enter sets trace ON when g_trace = 'Y' and nested level = 0
136 -- so we must turn it off for the same condition
137 -- Also turn off tracing when the override flag of p_trace_off has been passed as Y
138 IF (g_nested_level = 0
139 AND
140 g_trace = 'Y'
141 )
142 OR
143 NVL(p_trace_off,'N') = 'Y' THEN
144
145 hr_utility.trace_off;
146
147 END IF; -- (g_nested_level = 0
148
149 END debug_exit;
150
151
152 -- 8iComp Changes: IMORTANT NOTE
153
154 -- Removing the definition for Table Of Table datastructure
155 -- as Oracle 8i does not support this.
156 -- Later as Oracle 9i becomes the minimum pre requisite for Apps
157 -- we can move back to this logic
158 -- till then we will use a common table for keeping Leaver-restarter dates
159 -- for all the assignmets together.
160 -- The new solution is not as performant as the older one.
161
162 -- The Following function sets the leaver-restarter rows for as assignment
163 -- in the global collection g_per_asg_leaver_dates
164 FUNCTION set_g_per_asg_leaver_dates
165 ( p_leaver_dates_type IN t_leaver_dates_type
166 ) RETURN NUMBER
167 IS
168
169 l_return NUMBER;
170 l_nxt_count NUMBER;
171 l_itr NUMBER;
172 --
173 l_proc_name VARCHAR2(61):=
174 g_proc_name||'set_g_per_asg_leaver_dates';
175
176 BEGIN
177 debug_enter(l_proc_name) ;
178
179 l_nxt_count := g_per_asg_leaver_dates.COUNT;
180
181 debug('g_per_asg_leaver_dates.COUNT: '||g_per_asg_leaver_dates.COUNT, 10);
182 debug('p_leaver_dates_type.COUNT: '||p_leaver_dates_type.COUNT);
183
184 IF p_leaver_dates_type.COUNT > 0 THEN
185
186 debug(l_proc_name, 20);
187 FOR l_itr IN p_leaver_dates_type.FIRST..p_leaver_dates_type.LAST
188 LOOP
189 debug('l_itr: '|| l_itr, 30) ;
190 debug('p_leaver_dates_type(l_itr).start_date: '|| p_leaver_dates_type(l_itr).start_date) ;
191 debug('p_leaver_dates_type(l_itr).leaver_date: '|| p_leaver_dates_type(l_itr).leaver_date) ;
192 debug('p_leaver_dates_type(l_itr).restarter_date: '|| p_leaver_dates_type(l_itr).restarter_date) ;
193 debug('p_leaver_dates_type(l_itr).assignment_id: '|| p_leaver_dates_type(l_itr).assignment_id) ;
194
195 l_nxt_count := l_nxt_count + 1 ;
196 g_per_asg_leaver_dates(l_nxt_count).start_date := p_leaver_dates_type(l_itr).start_date ;
197 g_per_asg_leaver_dates(l_nxt_count).leaver_date := p_leaver_dates_type(l_itr).leaver_date ;
198 g_per_asg_leaver_dates(l_nxt_count).restarter_date:= p_leaver_dates_type(l_itr).restarter_date ;
199 g_per_asg_leaver_dates(l_nxt_count).assignment_id := p_leaver_dates_type(l_itr).assignment_id ;
200 debug('l_nxt_count: '|| l_nxt_count, 40) ;
201
202 END LOOP ;
203 debug(l_proc_name, 50);
204
205 END IF ;
206
207 debug_exit(l_proc_name);
208
209 return l_itr ;
210
211 EXCEPTION
212 WHEN OTHERS THEN
213 debug_exit(' Others in '||l_proc_name);
214 RAISE;
215 END set_g_per_asg_leaver_dates;
216
217 -- 8iComp Changes: IMORTANT NOTE
218
219 -- Removing the definition for Table Of Table datastructure
220 -- as Oracle 8i does not support this.
221 -- Later as Oracle 9i becomes the minimum pre requisite for Apps
222 -- we can move back to this logic
223 -- till then we will use a common table for keeping Leaver-restarter dates
224 -- for all the assignmets together.
225 -- The new solution is not as performant as the older one.
226
227 -- The Following function get the leaver-restarter rows for an assignment
228 -- in the global collection g_per_asg_leaver_dates
229
230 FUNCTION get_g_per_asg_leaver_dates
231 ( p_assignment_id IN NUMBER
232 ,p_leaver_dates_type OUT NOCOPY t_leaver_dates_type
233 ) RETURN NUMBER
234 IS
235 l_leaver_dates_type t_leaver_dates_type;
236 l_counter NUMBER := 0;
237 l_found VARCHAR2(1) := 'N' ;
238
239 l_itr NUMBER;
240 --
241 l_proc_name VARCHAR2(61):=
242 g_proc_name||'get_g_per_asg_leaver_dates';
243
244 BEGIN
245
246 debug_enter(l_proc_name);
247 debug ('p_assignment_idT: '||p_assignment_id,10);
248 debug ('g_per_asg_leaver_dates.COUNT: '|| g_per_asg_leaver_dates.COUNT);
249
250 IF g_per_asg_leaver_dates.COUNT > 0 THEN
251 debug(l_proc_name,20);
252
253 FOR l_itr IN g_per_asg_leaver_dates.FIRST..g_per_asg_leaver_dates.LAST
254 LOOP
255 EXIT WHEN ( l_found = 'Y'
256 AND g_per_asg_leaver_dates(l_itr).assignment_id <> p_assignment_id ) ;
257
258 debug('assignment_id: '||g_per_asg_leaver_dates(l_itr).assignment_id, 30) ;
259
260 IF (g_per_asg_leaver_dates(l_itr).assignment_id = p_assignment_id) THEN
261
262 debug(l_proc_name, 40) ;
263 l_counter := l_counter + 1 ;
264 l_found := 'Y';
265 l_leaver_dates_type(l_counter).start_date := g_per_asg_leaver_dates(l_itr).start_date ;
266 l_leaver_dates_type(l_counter).leaver_date := g_per_asg_leaver_dates(l_itr).leaver_date ;
267 l_leaver_dates_type(l_counter).restarter_date:= g_per_asg_leaver_dates(l_itr).restarter_date ;
268 l_leaver_dates_type(l_counter).assignment_id := g_per_asg_leaver_dates(l_itr).assignment_id ;
269 debug('l_counter: '||l_counter, 50 );
270 debug('l_found: '||l_found );
271
272 END IF ;
273 debug(l_proc_name, 60);
274
275 END LOOP ;
276 debug(l_proc_name, 70);
277
278 END IF ;
279 debug(l_proc_name, 80) ;
280 p_leaver_dates_type := l_leaver_dates_type;
281 debug_exit(l_proc_name);
282
283 return l_counter;
284 EXCEPTION
285 WHEN OTHERS THEN
286 debug_exit(' Others in '||l_proc_name);
287 RAISE;
288 END get_g_per_asg_leaver_dates;
289
290 -- 8iComp Changes: IMORTANT NOTE
291 -- Changing he following function to use the 8iComp code.
292 -- Now it does not reference g_asg_leaver_events_table global
293 -- but references g_per_asg_leaver_dates global
294 -- and calls get_g_per_asg_leaver_dates to get the
295 -- collection for Leaver-Restarter dates for an assignment
296
297 -- MULT-LR --
298 FUNCTION chk_effective_asg(p_assignment_id IN NUMBER
299 ,p_effective_date IN DATE
300 ) RETURN VARCHAR2 IS
301
302 l_proc_name VARCHAR2(60) := g_proc_name || 'chk_effective_asg';
303 l_effective VARCHAR2(1) := NULL ;
304 l_current NUMBER ;
305 l_start_date DATE ;
306 l_leaver_date DATE ;
307 l_restarter_date DATE ;
308
309 l_returned_count NUMBER;
310
311 l_asg_events t_leaver_dates_type ;
312
313 BEGIN
314
315 debug_enter (l_proc_name) ;
316
317 debug('p_assignment_id : ' || to_char(p_assignment_id),10) ;
318 debug('g_primary_assignment_id : ' || to_char(g_primary_assignment_id)) ;
319 debug('p_effective_date : ' || to_char(p_effective_date)) ;
320
321
322 -- PERF_ENHANC_3A : Performance Enhancements
323 -- check if record corresponding to p_assignment_id is present in the
324 -- collection g_asg_recalc_details.
325 -- If yes, check for matching start_date of the record and the LOS
326 -- if they match, return the value from the record, else compute the
327 -- effectiveness of the assignment
328 -- This step is to avoid unnecessary checking of assignment status for
329 -- a given LOS
330
331 IF (g_asg_recalc_details.EXISTS(p_assignment_id)
332 AND
333 g_asg_recalc_details(p_assignment_id).eff_start_date = p_effective_date
334 ) THEN
335
336 l_effective := g_asg_recalc_details(p_assignment_id).effective_status;
337
338 ELSE -- check effectiveness of assignment
339
340
341 -- check if there is any Full time asg for the period
342 IF g_override_ft_asg_id IS NULL THEN
343 debug(l_proc_name, 12);
344 --debug('g_asg_leaver_events_table.COUNT: '||g_asg_leaver_events_table.COUNT);
345 debug('g_per_asg_leaver_dates.COUNT: '||g_per_asg_leaver_dates.COUNT);
346
347 -- check if leaver-restarter dates have been captured
348 --IF g_asg_leaver_events_table.COUNT > 0 THEN
349
350 -- 8iComp
351 IF g_per_asg_leaver_dates.COUNT > 0 THEN
352 debug(l_proc_name, 15);
353
354 -- Check if the assignment is present in global collection
355 -- Primary may be available even if not to be reported.
356 -- So check the report flag for primary assignment
357 IF ( g_ext_asg_details.EXISTS(p_assignment_id)
358 AND
359 ( -- Primary Assignment
360 ( p_assignment_id = g_primary_assignment_id
361 AND
362 g_ext_asg_details(p_assignment_id).report_asg = 'Y'
363 )
364 -- Secondary Assignment
365 OR p_assignment_id <> g_primary_assignment_id
366 )
367 ) THEN
368 debug(l_proc_name, 20) ;
369
370 -- 8iComp
371 --l_asg_events := g_asg_leaver_events_table(p_assignment_id);
372 l_returned_count := get_g_per_asg_leaver_dates
373 ( p_assignment_id => p_assignment_id
374 ,p_leaver_dates_type => l_asg_events
375 ) ;
376 debug('l_returned_count : '|| l_returned_count) ;
377 debug(l_proc_name, 25) ;
378
379 debug('l_asg_events.count: '||to_char(l_asg_events.count), 30) ;
380 IF l_asg_events.count = 0 THEN
381 debug(l_proc_name, 40) ;
382
383 -- check the effective assignment
384 -- There is no leaver event for the assignment
385 -- else it would have had an entry in the table.
386 IF ( p_effective_date
387 BETWEEN g_ext_asg_details(p_assignment_id).start_date
388 AND g_effective_run_date
389 ) THEN
390 debug(l_proc_name, 50);
391 l_effective := 'Y';
392 ELSE
393 l_effective := 'N' ;
394 END IF ; --p_effective_date BETWEEN start and run_date
395 ELSE
396 l_current := l_asg_events.FIRST ;
397 debug('l_current: '||to_char(l_current), 55) ;
398
399 -- Iterate through the collection
400 -- and break out of loop, if the condition is satisfied
401
402 WHILE (l_current <= l_asg_events.LAST
403 AND l_effective IS NULL )
404 LOOP
405 debug (l_proc_name, 60+l_current/100000) ;
406
407 l_start_date := l_asg_events(l_current).start_date ;
408 l_leaver_date := l_asg_events(l_current).leaver_date ;
409 l_restarter_date := l_asg_events(l_current).restarter_date ;
410
411 debug ('l_start_date : '||to_char(l_start_date), 70+l_current/100000) ;
412 debug ('l_leaver_date : '||to_char(l_leaver_date) ) ;
413 debug ('l_restarter_date : '||to_char(l_restarter_date)) ;
414
415 -- Date is before the Assignment start date
416 IF p_effective_date < l_start_date THEN
417 debug (l_proc_name, 80 + l_current/100000) ;
418 l_effective := 'N' ;
419 ELSIF p_effective_date BETWEEN
420 l_start_date AND l_leaver_date THEN
421 -- date is between a pair of start and end date.
422 -- therefor it is effective.
423 debug (l_proc_name, 120 + l_current/100000) ;
424 l_effective := 'Y' ;
425 ELSIF p_effective_date > l_leaver_date
426 AND l_restarter_date IS NULL THEN
427 -- Date is greater than leaver date and there is
428 -- no restarter event thereafter
429 -- therefor asg is not affective anymore.
430 -- not a restarter, so not effective on the date.
431 debug (l_proc_name, 130 + l_current/100000) ;
432 l_effective := 'N' ;
433 ELSIF l_restarter_date IS NOT NULL
434 AND p_effective_date BETWEEN
435 (l_leaver_date + 1) AND (l_restarter_date - 1) THEN
436 --date is between leaver and restarter dates.
437 debug (l_proc_name, 165 + l_current/100000) ;
438 l_effective := 'N' ;
439 ELSIF p_effective_date >= l_restarter_date
440 AND l_asg_events.NEXT(l_current) IS NOT NULL THEN
441 -- Date is greater than restarter date and there is
442 -- another set of start-leaver date therefor
443 -- can not decide for the effectiveness at this point.
444 -- Loop thru for the next set of dates.
445 debug (l_proc_name, 170 + l_current/100000) ;
446 l_current := l_asg_events.NEXT(l_current) ;
447 debug('l_current: '||to_char(l_current), 180 + l_current/100000 ) ;
448 ELSE -- p_effective_date > l_restarter_date
449 -- AND l_asg_events.NEXT(l_current) IS NULL
450
451 -- There are no more leaver events for the current restarter event,
452 -- and the restarter event exists so the asg is effective through
453 -- out the year after the restarter date
454 debug (l_proc_name, 190 + l_current/100000) ;
455 l_effective := 'Y' ;
456 END IF; --l_restarter_date IS NOT NULL
457
458 debug (l_proc_name, 220 + l_current/100000) ;
459
460 END LOOP;
461 END IF; --l_current IS NULL or l_current = ''
462
463 debug ('l_effective : ' ||l_effective, 230) ;
464 debug ('l_start_date : ' ||to_char(l_start_date)) ;
465 debug ('l_leaver_date : '||to_char(l_leaver_date) ) ;
466 debug ('l_restarter_date : '||to_char(l_restarter_date)) ;
467
468 ELSE -- g_ext_asg_details.EXISTS(p_assignment_id)
469 debug (l_proc_name,240) ;
470 l_effective := 'N' ;
471 END IF ;
472 ELSE -- g_per_asg_leaver_dates.COUNT > 0 THEN
473 --debug ('g_asg_leaver_events_table.COUNT is ZERO', 250) ;
474
475 IF (g_ext_asg_details.EXISTS(p_assignment_id)
476 AND
477 ( -- Primary Assignment
478 ( g_primary_assignment_id IS NOT NULL
479 AND
480 p_assignment_id = g_primary_assignment_id
481 AND
482 g_ext_asg_details(p_assignment_id).report_asg = 'Y'
483 )
484 -- Secondary Assignment
485 OR
486 (
487 g_primary_assignment_id IS NOT NULL
488 AND
489 p_assignment_id <> g_primary_assignment_id
490 )
491 )
492 AND
493 (p_effective_date
494 BETWEEN nvl(g_ext_asg_details(p_assignment_id).start_date, p_effective_date )
495 AND
496 nvl(g_ext_asg_details(p_assignment_id).leaver_date, g_effective_run_date)
497 OR
498 (g_ext_asg_details(p_assignment_id).restarter_date IS NOT NULL
499 AND
500 p_effective_date >= g_ext_asg_details(p_assignment_id).restarter_date
501 )
502 )
503 ) THEN
504
505 l_effective := 'Y';
506 debug(l_proc_name, 260);
507
508 ELSE --g_ext_asg_details.EXISTS(p_assignment_id)
509
510 debug(l_proc_name, 290);
511 l_effective := 'N';
512
513 END IF;
514 END IF ; -- g_per_asg_leaver_dates.COUNT > 0 THEN
515 ELSIF g_override_ft_asg_id = p_assignment_id THEN
516
517 l_effective := 'Y';
518 debug(l_proc_name, 310);
519
520 ELSE --g_override_ft_asg_id IS NULL
521
522 debug(l_proc_name, 320);
523 l_effective := 'N';
524
525 END IF; --g_override_ft_asg_id IS NULL
526
527 debug('l_effective: ' || l_effective,330);
528
529 -- PERF_ENHANC_3A : performance enhancement
530 -- insert a new row in the collection of records for this assignment_id
531 g_asg_recalc_details(p_assignment_id).assignment_id := p_assignment_id;
532 g_asg_recalc_details(p_assignment_id).eff_start_date := p_effective_date;
533 g_asg_recalc_details(p_assignment_id).eff_end_date := NULL;
534 g_asg_recalc_details(p_assignment_id).effective_status := l_effective;
535 g_asg_recalc_details(p_assignment_id).part_time_sal_paid := NULL;
536 g_asg_recalc_details(p_assignment_id).full_time_sal_rate := NULL;
537
538 END IF;
539
540
541 debug_exit(l_proc_name ) ;
542 RETURN l_effective ;
543
544 EXCEPTION
545 WHEN OTHERS THEN
546 debug_exit(' Others in '||l_proc_name);
547 RAISE;
548 END chk_effective_asg ;
549
550 --
551
552 -- 8iComp Changes: IMORTANT NOTE
553 -- Changing he following function to use the 8iComp code.
554 -- Now it does not reference g_asg_leaver_events_table global
555 -- but references g_per_asg_leaver_dates global
556 -- and calls get_g_per_asg_leaver_dates to get the
557 -- collection for Leaver-Restarter dates for an assignment.
558
559 PROCEDURE print_events_table IS
560
561 l_proc_name VARCHAR2(60) := g_proc_name || 'print_events_table';
562 l_effective VARCHAR2(1) := 'N' ;
563 l_current NUMBER ;
564 l_start_date DATE ;
565 l_leaver_date DATE ;
566 l_restarter_date DATE ;
567 l_asg_events t_leaver_dates_type ;
568 l_asg_events_current NUMBER ;
569
570 BEGIN
571
572 debug_enter (l_proc_name) ;
573 debug('g_per_asg_leaver_dates.COUNT: '|| g_per_asg_leaver_dates.COUNT,10);
574
575 IF g_per_asg_leaver_dates.COUNT > 0 THEN
576 debug ('asg_id start_date leaver_date restarter_date ',20) ;
577
578 FOR l_itr IN g_per_asg_leaver_dates.FIRST..g_per_asg_leaver_dates.LAST
579 LOOP
580
581 debug(g_per_asg_leaver_dates(l_itr).assignment_id || ' '||g_per_asg_leaver_dates(l_itr).start_date||' '||
582 g_per_asg_leaver_dates(l_itr).leaver_date ||' '||g_per_asg_leaver_dates(l_itr).restarter_date,30 ) ;
583
584 END LOOP ; -- outer
585
586 debug ('outside loop ' ,210) ;
587 ELSE
588 debug ('No records to print .....' ) ;
589 END IF ;
590 debug_exit(l_proc_name ) ;
591
592 EXCEPTION
593 WHEN OTHERS THEN
594 debug_exit(' Others in '||l_proc_name);
595 RAISE;
596 END print_events_table ;
597
598 -- 8iComp Changes: IMORTANT NOTE
599 -- Changing he following function to use the 8iComp code.
600 -- Now it does not reference g_asg_leaver_events_table global
601 -- but references g_per_asg_leaver_dates global
602 -- and calls get_g_per_asg_leaver_dates to get the
603 -- collection for Leaver-Restarter dates for an assignment
604
605 -- MULT-LR --
606 FUNCTION get_eff_end_date ( p_assignment_id IN NUMBER
607 ,p_effective_start_date IN DATE
608 ,p_effective_end_date IN DATE
609 ) RETURN DATE IS
610
611 l_proc_name VARCHAR2(60) := g_proc_name || 'get_eff_end_date';
612 l_effective VARCHAR2(1) := 'N' ;
613 l_current NUMBER ;
614 l_start_date DATE ;
615 l_leaver_date DATE ;
616 l_restarter_date DATE ;
617 l_asg_events t_leaver_dates_type ;
618 l_counter NUMBER ;
619
620 l_return_date DATE := NULL;
621 l_returned_count NUMBER;
622 BEGIN
623
624 debug_enter (l_proc_name) ;
625
626 debug('p_assignment_id : ' || to_char(p_assignment_id),10) ;
627 debug('g_primary_assignment_id : ' || to_char(g_primary_assignment_id)) ;
628 debug('p_effective_start_date : ' || to_char(p_effective_start_date)) ;
629 debug('p_effective_end_date : ' || to_char(p_effective_end_date)) ;
630
631 --debug('g_asg_leaver_events_table.COUNT : '|| g_asg_leaver_events_table.COUNT) ;
632 debug('g_per_asg_leaver_dates.COUNT : '|| g_per_asg_leaver_dates.COUNT) ;
633
634 -- 8iComp changes
635 --IF g_asg_leaver_events_table.COUNT > 0 THEN
636 IF g_per_asg_leaver_dates.COUNT > 0 THEN
637
638 -- Present in global collection ..
639 -- Primary may be available even
640 -- if not to be reported.
641 IF ( g_ext_asg_details.EXISTS(p_assignment_id)
642 AND
643 ( -- Primary Assignment
644 ( p_assignment_id = g_primary_assignment_id
645 AND
646 g_ext_asg_details(p_assignment_id).report_asg = 'Y'
647 )
648 -- Secondary Assignment
649 OR p_assignment_id <> g_primary_assignment_id
650 )
651 ) THEN
652
653 -- 8iComp
654 -- l_asg_events := g_asg_leaver_events_table(p_assignment_id);
655 l_returned_count := get_g_per_asg_leaver_dates
656 ( p_assignment_id => p_assignment_id
657 ,p_leaver_dates_type => l_asg_events
658 ) ;
659 debug('l_returned_count : '|| l_returned_count) ;
660 debug('l_asg_events.count: '||to_char(l_asg_events.count), 20) ;
661
662 IF l_asg_events.count = 0 THEN
663 debug(l_proc_name, 25) ;
664 -- There is no leaver event for the assignment.
665 -- otherwise, there shud be atleast one row in the table.
666 l_return_date := p_effective_end_date ;
667
668 ELSE --l_asg_events.count = 0
669 debug(l_proc_name, 30) ;
670 l_current := l_asg_events.FIRST ;
671 debug('l_current: '||to_char(l_current), 40) ;
672
673 WHILE (l_current <= l_asg_events.LAST
674 AND l_return_date IS NULL )
675 LOOP
676 debug (l_proc_name, 60+l_current/100000) ;
677 l_start_date := l_asg_events(l_current).start_date ;
678 l_leaver_date := l_asg_events(l_current).leaver_date ;
679 l_restarter_date := l_asg_events(l_current).restarter_date ;
680
681 debug ('l_start_date : '||to_char(l_start_date), 70+l_current/100000) ;
682 debug ('l_leaver_date : '||to_char(l_leaver_date) ) ;
683 debug ('l_restarter_date : '||to_char(l_restarter_date)) ;
684
685
686 IF p_effective_end_date < l_start_date THEN
687 debug (l_proc_name, 80 + l_current/100000) ;
688 debug('THIS CONDITION SHOULD NOT ARISE.......') ;
689 l_return_date := p_effective_end_date ;
690
691 ELSIF p_effective_end_date BETWEEN
692 l_start_date AND l_leaver_date THEN
693 -- Period end date is between a pair of start and end date
694 debug (l_proc_name, 120 + l_current/100000) ;
695 l_return_date := p_effective_end_date ;
696
697 ELSIF p_effective_end_date > l_leaver_date
698 AND l_restarter_date IS NULL THEN
699 -- period end date is after asg leaver date
700 -- and there is no restarter event
701 -- therefor the asg leaver date is the end date.
702 debug (l_proc_name, 140 + l_current/100000) ;
703 l_return_date := l_leaver_date ;
704
705 ELSIF l_restarter_date IS NOT NULL
706 AND p_effective_end_date BETWEEN
707 (l_leaver_date + 1) AND (l_restarter_date - 1) THEN
708 -- period end date is between leaver and restarter date.
709 debug (l_proc_name, 170 + l_current/100000) ;
710 l_return_date := l_leaver_date ;
711
712 ELSIF l_restarter_date IS NOT NULL
713 AND p_effective_end_date >= l_restarter_date
714 AND l_asg_events.NEXT(l_current) IS NOT NULL THEN
715 debug (l_proc_name, 170 + l_current/100000) ;
716 l_current := l_asg_events.NEXT(l_current) ;
717 debug('l_current: '||to_char(l_current), 180 + l_current/100000 ) ;
718 ELSE -- l_restarter_date IS NOT NULL
719 -- AND p_effective_end_date >= l_restarter_date
720 -- AND l_asg_events.NEXT(l_current) IS NOT NULL THEN
721 debug (l_proc_name, 190 + l_current/100000) ;
722 l_return_date := p_effective_end_date ;
723 END IF ;
724
725 debug (l_proc_name, 220 + l_current/100000) ;
726
727 END LOOP;
728 END IF; --l_asg_events.count = 0
729
730 debug ('l_return_date : ' ||to_char(l_return_date), 230) ;
731 debug ('l_start_date : ' ||to_char(l_start_date)) ;
732 debug ('l_leaver_date : '||to_char(l_leaver_date) ) ;
733 debug ('l_restarter_date : '||to_char(l_restarter_date)) ;
734
735 ELSE -- g_ext_asg_details.EXISTS(p_assignment_id)
736 debug (l_proc_name,240) ;
737 debug('THIS CONDITION SHOULD NOT ARISE ....') ;
738 l_return_date := p_effective_end_date ;
739 END IF ;
740 ELSE -- g_per_asg_leaver_dates.COUNT > 0 THEN
741 debug ('g_per_asg_leaver_dates.COUNT is ZERO',250) ;
742
743 IF ( g_ext_asg_details(p_assignment_id).restarter_date IS NOT NULL
744 AND (p_effective_end_date >= g_ext_asg_details(p_assignment_id).restarter_date )
745 ) THEN
746 debug (l_proc_name,260) ;
747 l_return_date := p_effective_end_date ;
748
749 ELSE
750 debug (l_proc_name,270) ;
751 l_return_date := LEAST(p_effective_end_date
752 ,nvl(g_ext_asg_details(p_assignment_id).leaver_date
753 ,p_effective_end_date
754 )
755 );
756 END IF ;
757 END IF ; -- g_per_asg_leaver_dates.COUNT > 0 THEN
758 debug('l_return_date : ' ||to_char(l_return_date) ) ;
759 debug_exit(l_proc_name ) ;
760 RETURN l_return_date ;
761
762 EXCEPTION
763 WHEN OTHERS THEN
764 debug_exit(' Others in '||l_proc_name);
765 RAISE;
766 END get_eff_end_date ;
767
768
769 -- 8iComp Changes: IMORTANT NOTE
770 -- Changing he following function to use the 8iComp code.
771 -- Now it does not reference g_asg_leaver_events_table global
772 -- but references g_per_asg_leaver_dates global
773 -- and calls get_g_per_asg_leaver_dates to get the
774 -- collection for Leaver-Restarter dates for an assignment
775 --
776 -- PER_LVR : New functionto check for the person level lever events.
777 --
778 FUNCTION chk_person_leaver
779 (p_assignment_id IN NUMBER -- context
780 ,p_person_id IN NUMBER
781 ) RETURN VARCHAR2
782 IS
783
784 -- Variable Declaration
785 l_curr_asg_id per_all_assignments_f.assignment_id%TYPE;
786 l_prev_asg_id per_all_assignments_f.assignment_id%TYPE;
787 l_sec_asg_id per_all_assignments_f.assignment_id%TYPE;
788
789 l_itr NUMBER(3);
790 l_next_itr NUMBER(3);
791 l_skip_itr NUMBER(3) := NULL;
792 l_next_of_next_itr NUMBER(3);
793 l_prev_asg_count NUMBER(3);
794 l_inclusion_flag VARCHAR2(1) := 'N';
795 l_reported VARCHAR2(1) := 'N';
796
797 l_person_leaver_date DATE ;
798 l_person_id NUMBER;
799 -- QAB1: Added to temporarily store g_asg_count Value
800 l_asg_count NUMBER;
801
802 -- Rowtype Variable Declaration
803 l_all_sec_asgs t_sec_asgs_type;
804
805 -- 8iComp
806 l_insert_rec NUMBER;
807 l_leaver_assignments t_leaver_asgs_type;
808 l_leaver_yn boolean;
809 i NUMBER;
810
811
812
813 --l_sec_asg_details csr_sec_assignments%ROWTYPE := NULL;
814
815 l_proc_name VARCHAR2(61):=
816 g_proc_name||'chk_person_leaver';
817
818 BEGIN -- chk_person_leaver
819
820 debug_enter(l_proc_name);
821 debug('p_assignment_id: '||to_char(p_assignment_id), 10) ;
822 debug('p_person_id: '||to_char(p_person_id)) ;
823
824 -- QAB1: Store the value of g_asg_count as
825 -- it may get change during the leaver check
826 -- we need to restore this value
827 -- before returning from the function.
828 l_asg_count := g_asg_count ;
829
830 -- Step 0) Reset the global variable, it may contain events for the previous person processed
831 -- If events will be stored in this global by the basic criteria, then the following
832 -- line will need to be commented out
833 -- Also, set the global variable for primary assignment id
834
835 debug('Count in g_asg_events :'||to_char(g_asg_events.COUNT), 20);
836
837 g_primary_leaver_dates.DELETE;
838 g_primary_assignment_id := p_assignment_id;
839
840 -- Bugfix 3803760:FTSUPPLY : Resetting override ft asg id
841 -- This is needed coz if for the frist line one of
842 -- the secondary was FT, then chk_report_assignment
843 -- will return N for the primary asg below and
844 -- we will not pick up any new line and leaver restarter
845 -- events for the primary asg
846 g_override_ft_asg_id := NULL;
847 g_tab_sec_asgs.DELETE;
848
849 IF chk_report_assignment
850 (p_assignment_id => p_assignment_id
851 ,p_secondary_assignment_id => l_sec_asg_id
852 ) = 'Y' THEN
853
854
855 -- Store all the leaver and restarter dates for the primary asg
856 store_leaver_restarter_dates
857 (p_assignment_id => p_assignment_id
858 );
859
860 -- MULT-LR changes
861 -- g_asg_leaver_events_table(p_assignment_id) := g_primary_leaver_dates ;
862
863 --8iComp
864 debug('inserting in new collection...', 22);
865 l_insert_rec := set_g_per_asg_leaver_dates
866 ( p_leaver_dates_type => g_primary_leaver_dates) ;
867
868 debug('l_insert_rec: '|| l_insert_rec, 24) ;
869
870
871 ELSE
872
873 -- Bugfix 3880543:REHIRE
874 -- Setting the sec asg id as the primary asg
875 -- We will treat the sec asg as promary so all
876 -- leaver restarter events for this secondary
877 -- will b treated as primary leaver restarter events
878 g_primary_assignment_id := l_sec_asg_id;
879
880 END IF; -- IF chk_report_assignment
881
882 -- Step 1b) Get secondary assignments
883 l_all_sec_asgs := get_all_secondary_asgs
884 (p_primary_assignment_id => p_assignment_id
885 ,p_effective_date => g_ext_asg_details(p_assignment_id).teacher_start_date
886 );
887
888 -- Have we found any secondary assignments?
889 IF l_all_sec_asgs.COUNT > 0 THEN
890
891 l_curr_asg_id := l_all_sec_asgs.FIRST;
892
893 WHILE l_curr_asg_id IS NOT NULL
894 LOOP
895
896 debug('Processing Secondary Asg :'||to_char(l_curr_asg_id),30);
897
898 -- Delete the global for lever restarter dates for secondary asg.
899 g_sec_leaver_dates.DELETE;
900
901 -- Store all the leaver and restarter dates for the secondary asg
902 store_leaver_restarter_dates
903 (p_assignment_id => l_curr_asg_id
904 );
905
906 -- MULT-LR changes
907 IF l_curr_asg_id = g_primary_assignment_id THEN
908 --g_asg_leaver_events_table(l_curr_asg_id) := g_primary_leaver_dates ;
909
910 --8iComp
911 debug('inserting in new collection...', 32);
912 l_insert_rec := set_g_per_asg_leaver_dates
913 ( p_leaver_dates_type => g_primary_leaver_dates) ;
914 debug('l_insert_rec: '|| l_insert_rec, 34) ;
915
916 ELSE
917 --g_asg_leaver_events_table(l_curr_asg_id) := g_sec_leaver_dates ;
918 --8iComp
919 debug('inserting in new collection...', 36);
920 l_insert_rec := set_g_per_asg_leaver_dates
921 ( p_leaver_dates_type => g_sec_leaver_dates) ;
922 debug('l_insert_rec: '|| l_insert_rec, 38) ;
923
924 END IF;
925
926 -- Assign the current asg id to prev asg id
927 -- and reset curr asg id, ready for the next one
928 l_prev_asg_id := l_curr_asg_id;
929 l_curr_asg_id := NULL;
930
931 -- Get next secondary assignment
932 l_curr_asg_id := l_all_sec_asgs.NEXT(l_prev_asg_id);
933
934 END LOOP; -- l_curr_asg_id IS NOT NULL
935 --
936 END IF; -- l_all_sec_asgs.COUNT > 0 THEN
937
938 -- MULT-LR --
939 -- print all the events stored so far.
940 -- Print the Events table only if Debug is switched on.
941 IF NVL(g_trace,'N') = 'Y' THEN
942 print_events_table ();
943 END IF;
944
945 -- rest the g_primary_assignment_id
946 g_primary_assignment_id := p_assignment_id;
947
948 debug('g_asg_events.COUNT: '||to_char(g_asg_events.COUNT),40) ;
949
950 -- This function is basically used by TP1P report, since we are using this function for TP1 report
951 -- till now code for both report is common, following portion will used only by TP1 report
952 IF g_extract_type = 'TP1' THEN
953 IF g_per_asg_leaver_dates.COUNT > 0 THEN --chk this table has any leaver events for the person
954 FOR l_itr IN g_per_asg_leaver_dates.FIRST..g_per_asg_leaver_dates.LAST
955 loop
956 debug('Checking asg from g_per_asg_leaver_dates : '||g_per_asg_leaver_dates(l_itr).assignment_id,41) ;
957 if l_leaver_assignments.EXISTS(g_per_asg_leaver_dates(l_itr).assignment_id) then
958 debug('asg already exist in l_leaver_assignments',42) ;
959 NULL;
960 else
961 debug('Storing in l_leaver_assignments ', 43) ;
962 l_leaver_assignments(g_per_asg_leaver_dates(l_itr).assignment_id) := g_per_asg_leaver_dates(l_itr).assignment_id; -- sore leaver asg ids
963 end if;
964 end loop;
965 end if;
966
967 debug('l_leaver_assignments.count: '||l_leaver_assignments.count,44) ;
968 debug('Teacher assignment Count :'||g_teach_asg_count,45) ;
969
970 if g_teach_asg_count = l_leaver_assignments.count THEN -- if all asgs of person have some leaver events
971 i := l_leaver_assignments.first; -- need to chk all asgs for restarter event
972 WHILE i IS NOT NULL
973 loop
974 debug('Checking Asg from l_leaver_assignments : '||l_leaver_assignments(i),46) ;
975 l_leaver_yn := FALSE;
976 FOR i_itr_1 IN g_per_asg_leaver_dates.FIRST..g_per_asg_leaver_dates.LAST
977 LOOP
978 IF l_leaver_assignments(i) = g_per_asg_leaver_dates(i_itr_1).assignment_id AND
979 g_per_asg_leaver_dates(i_itr_1).restarter_date IS NULL THEN --for each asgs check coresponding restarter event
980 l_leaver_yn := TRUE;
981 debug(l_leaver_assignments(i)||' Asg is leaver' , 47) ;
982 END if;
983 END LOOP ; --
984
985 IF NOT l_leaver_yn THEN -- if any asg is not leaver person must be reported , and no need to chk further
986 l_inclusion_flag:= 'Y';
987 debug(l_leaver_assignments(i)||' Asg is not leaver for this pension Year, person should be reported' , 48);
988 debug('l_inclusion_flag : '||l_inclusion_flag, 49);
989 RETURN l_inclusion_flag ;
990 END if;
991 i:= l_leaver_assignments.NEXT(i);
992 END loop;
993
994 debug(' All Asgs are leaver for this person' , 49);
995 l_inclusion_flag:= 'N'; -- all asg has leaver events and no corresponding restarter event
996 Else
997 l_inclusion_flag:= 'Y'; -- not all asg of person has leaver event
998 debug(' Not all asgs of this person are leavers ' , 50);
999 debug('l_inclusion_flag : '||l_inclusion_flag, 50);
1000 END IF; --g_ext_asg_details.COUNT = l_leaver_assignments.count
1001
1002 RETURN l_inclusion_flag ; -- following part of code is for TP1P report hence returning
1003 END IF;
1004
1005 -- Step 1d) Sort events by Ascending Date if we have found more than 1 events
1006 IF g_asg_events.COUNT > 1 THEN
1007 sort_stored_events;
1008 END IF;
1009
1010 IF g_asg_events.COUNT > 0 THEN
1011
1012 -- If the first event is a primary leaver event, then we need
1013 -- a W on withdrawal conf and
1014 -- the end date should be set as the event date
1015 IF (g_asg_count
1016 +
1017 nvl(g_asg_events(g_asg_events.FIRST).asg_count_change, 0)
1018 ) <= 0 THEN
1019
1020 l_person_leaver_date := g_asg_events(g_asg_events.FIRST).event_date ;
1021
1022 debug('l_person_leaver_date: '||to_char(l_person_leaver_date),50) ;
1023
1024 -- changed function with the date parameter.
1025 l_reported := chk_has_teacher_been_reported
1026 ( p_person_id => p_person_id
1027 ,p_leaver_date => l_person_leaver_date
1028 );
1029
1030 debug('l_reported: '||l_reported,60) ;
1031
1032 IF l_reported = 'N' THEN
1033 l_inclusion_flag := 'Y' ;
1034 END IF;
1035 END IF;
1036
1037 debug('l_inclusion_flag: '||l_inclusion_flag, 70) ;
1038 debug('g_latest_start_date: '||to_char(g_latest_start_date)) ;
1039
1040 IF l_inclusion_flag = 'N' THEN
1041
1042 -- Process each event in the global collection
1043 FOR l_itr IN g_asg_events.FIRST..g_asg_events.LAST
1044 LOOP -- through the sorted stored events
1045
1046 debug('g_asg_events(l_itr).event_date: '||to_char(g_asg_events(l_itr).event_date),80) ;
1047 -- check if the event date is before the g_latest_start_date
1048 -- coz after this date there are no more person leaver events.
1049 IF (g_asg_events(l_itr).event_date < g_latest_start_date)
1050 THEN
1051 l_prev_asg_count := g_asg_count;
1052
1053 -- Check if this event needs to be skipped
1054 IF (l_skip_itr IS NULL
1055 OR
1056 l_itr <> l_skip_itr
1057 ) THEN
1058
1059 g_asg_count := g_asg_count
1060 +
1061 nvl(g_asg_events(l_itr).asg_count_change
1062 , 0);
1063 END IF;
1064
1065 -- Eliminate duplicate changes as we will be re-calculating all
1066 -- data elements that are non-static
1067 -- Also eliminate the event if its a primary leaver event as
1068 -- we process these when deciding on withdrawal conf
1069 -- Now we also skip events if they are set in l_skip_itr
1070 IF (l_itr = g_asg_events.FIRST -- The event is the first one
1071 OR -- the date is not the same as previous event date
1072 g_asg_events(l_itr).event_date <>
1073 g_asg_events(g_asg_events.PRIOR(l_itr)).event_date
1074 )
1075 AND
1076 (g_asg_count > 0
1077 )
1078 AND
1079 -- Check if this event needs to be skipped
1080 (l_skip_itr IS NULL
1081 OR
1082 l_itr <> l_skip_itr
1083 ) THEN
1084
1085 l_next_itr := g_asg_events.NEXT(l_itr);
1086
1087 -- Bugfix 3880543:REHIRE :
1088 -- We need to pre-Evaluate the next event
1089 -- We might want to skip the next event if the
1090 -- next event date is equal to current event date+1
1091 -- as it could result in a line with start date
1092 -- greater than end date. We only want to skip
1093 -- if the next event will not result in a primary
1094 -- leaver event, meaning it will not coz g_asg_count
1095 -- to become zero.
1096 IF l_next_itr IS NOT NULL
1097 AND
1098 ( (g_asg_count
1099 +
1100 nvl(g_asg_events(l_next_itr).asg_count_change, 0)
1101 ) > 0
1102 ) THEN
1103
1104 -- The start date greater than end data problem
1105 -- can only occur in the following situation
1106 -- If the current event is a (new line) leaver event AND
1107 -- Next event is NOT a leaver event AND
1108 -- Next event date is EQUAL to current event date + 1
1109 IF (INSTR(nvl(g_asg_events(l_itr).event_type,'XX')
1110 ,'LEAVER'
1111 ) > 0
1112 )
1113 AND
1114 (INSTR(nvl(g_asg_events(l_next_itr).event_type,'XX')
1115 ,'LEAVER'
1116 ) <= 0
1117 )
1118 AND
1119 ( g_asg_events(l_itr).event_date + 1
1120 =
1121 g_asg_events(l_next_itr).event_date
1122 ) THEN
1123 -- We want to skip the next event, Set skip itr
1124 l_skip_itr := l_next_itr;
1125
1126 l_prev_asg_count := g_asg_count;
1127
1128 g_asg_count := g_asg_count
1129 +
1130 nvl(g_asg_events(l_skip_itr).asg_count_change
1131 , 0);
1132
1133 -- Get next-of-next and treat it as the next event
1134 l_next_of_next_itr := g_asg_events.NEXT(l_next_itr);
1135 l_next_itr := l_next_of_next_itr;
1136
1137 ELSE
1138 l_skip_itr := NULL;
1139 END IF;
1140
1141 ELSE -- Pre-Evaluating
1142
1143 l_skip_itr := NULL;
1144
1145 END IF; -- Pre-Evaluating
1146
1147 -- Now doing the real processing
1148 IF l_next_itr IS NOT NULL THEN
1149
1150 -- Also check if the next event is a Primary Leaver event
1151 IF -- If the next event will cause g_asg_count to become zero
1152 ( (g_asg_count
1153 +
1154 nvl(g_asg_events(l_next_itr).asg_count_change, 0)
1155 ) <= 0
1156 ) THEN
1157
1158 l_person_leaver_date := g_asg_events(l_next_itr).event_date ;
1159
1160 debug('l_person_leaver_date: '||to_char(l_person_leaver_date),90) ;
1161 -- changed function with the date parameter.
1162 l_reported := chk_has_teacher_been_reported
1163 ( p_person_id => p_person_id
1164 ,p_leaver_date => l_person_leaver_date
1165 );
1166 debug('l_reported: '||l_reported,110) ;
1167
1168 IF l_reported = 'N' THEN
1169 l_inclusion_flag := 'Y' ;
1170 EXIT;
1171 END IF;
1172
1173 END IF;
1174
1175 END IF; -- l_next_itr IS NOT NULL THEN
1176
1177 END IF; -- if this date <> last date to eliminate duplicates and primary leaver
1178
1179 ELSE
1180 -- There were no person level leaver events found
1181 -- that have not been reported earlier.
1182 -- so set the return value and Exit.
1183 l_inclusion_flag := 'N' ;
1184 EXIT ;
1185 END IF ; -- g_asg_events(l_itr).event_date < g_latest_start_date
1186 --
1187 END LOOP; -- through the sorted stored events
1188 END IF ; -- l_inclusion_flag = 'N' ;
1189 --
1190 END IF; -- g_asg_events.COUNT > 0 THEN
1191
1192 -- QAB1: Restore the value of g_asg_count.
1193 g_asg_count := l_asg_count ;
1194
1195 debug('l_inclusion_flag: '||l_inclusion_flag, 120);
1196 debug_exit(l_proc_name);
1197
1198 RETURN l_inclusion_flag ;
1199
1200 EXCEPTION
1201 WHEN OTHERS THEN
1202
1203 -- Reset the global variable containing events for this person
1204 g_asg_events.DELETE;
1205 -- QAB1: reset the global.
1206 g_asg_count := l_asg_count;
1207
1208 debug('SQLCODE :'||to_char(SQLCODE), 40);
1209 debug('SQLERRM :'||SQLERRM, 50);
1210
1211 debug_exit(' Others in '||l_proc_name
1212 ,'Y' -- turn trace off
1213 );
1214 RAISE;
1215 END; -- chk_person_leaver
1216
1217 --
1218 --
1219 Procedure Get_Udt_Data ( p_udt_name in varchar2
1220 ,p_effective_date in date ) Is
1221
1222 Cursor Get_table_id ( c_udt_name in varchar2 ) Is
1223 select tbls.user_table_id
1224 from pay_user_tables tbls
1225 where tbls.user_table_name = c_udt_name
1226 and ((business_group_id is null and legislation_code is null)
1227 or (legislation_code is not null
1228 and legislation_code = 'GB')
1229 or (business_group_id is not null
1230 and business_group_id = g_business_group_id)
1231 );
1232
1233 Cursor Get_Col_Name ( c_user_table_id in number ) Is
1234 Select user_column_id, user_column_name
1235 from pay_user_columns
1236 where user_table_id = c_user_table_id
1237 and ((business_group_id is null and legislation_code is null)
1238 or (legislation_code is not null
1239 and legislation_code = 'GB')
1240 or (business_group_id is not null
1241 and business_group_id = g_business_group_id)
1242 )
1243 order by user_column_id;
1244
1245 Cursor Get_Row_Name ( c_user_table_id in number
1246 ,c_effective_date in date ) Is
1247 Select user_row_id, row_low_range_or_name
1248 from pay_user_rows_f
1249 where user_table_id = c_user_table_id
1250 and trunc(c_effective_date) between effective_start_date
1251 and effective_end_date
1252 and ((business_group_id is null and legislation_code is null)
1253 or (legislation_code is not null
1254 and legislation_code = 'GB')
1255 or (business_group_id is not null
1256 and business_group_id = g_business_group_id)
1257 )
1258 order by display_sequence;
1259
1260 Cursor Get_Matrix_Value ( c_user_column_id in number
1261 ,c_user_row_id in number ) Is
1262 Select value, effective_start_date, effective_end_date
1263 from pay_user_column_instances_f
1264 where user_column_id = c_user_column_id
1265 and user_row_id = c_user_row_id
1266 and ((business_group_id is null and legislation_code is null)
1267 or (legislation_code is not null
1268 and legislation_code = 'GB')
1269 or (business_group_id is not null
1270 and business_group_id = g_business_group_id)
1271 );
1272
1273 -- Comment this out as this is not needed as a local collection
1274 -- This has been declared in the pkg header as global collection
1275 -- g_udt_rec t_udt_array;
1276 l_user_column_name pay_user_columns.user_column_name%TYPE;
1277 l_user_row_name pay_user_rows_f.row_low_range_or_name%TYPE;
1278 l_matrix_value pay_user_column_instances_f.value%TYPE;
1279 l_user_table_id pay_user_tables.user_table_id%TYPE;
1280 l_user_column_id pay_user_columns.user_column_id%TYPE;
1281 l_user_row_id pay_user_rows_f.user_row_id%TYPE;
1282 l_idx number;
1283 l_proc_name varchar2(60) := g_proc_name || 'get_udt_data';
1284
1285 Begin
1286 debug_enter(l_proc_name);
1287
1288 Open Get_table_id ( c_udt_name => p_udt_name);
1289 Fetch Get_table_id Into l_user_table_id;
1290 Close Get_table_id;
1291 l_idx := 1;
1292 For i in Get_Col_Name (c_user_table_id => l_user_table_id) Loop
1293 debug(l_proc_name, 20);
1294 l_user_column_id := i.user_column_id;
1295 l_user_column_name := i.user_column_name;
1296 For j in Get_Row_Name (c_user_table_id => l_user_table_id
1297 ,c_effective_date => p_effective_date) Loop
1298 debug(l_proc_name, 30);
1299 l_user_row_id := j.user_row_id;
1300 l_user_row_name := j.row_low_range_or_name;
1301 For k in Get_Matrix_Value ( c_user_column_id => l_user_column_id
1302 ,c_user_row_id => l_user_row_id ) Loop
1303 g_udt_rec(l_idx).column_name := l_user_column_name;
1304 g_udt_rec(l_idx).row_name := l_user_row_name;
1305 g_udt_rec(l_idx).matrix_value := k.value;
1306 g_udt_rec(l_idx).start_date := Trunc(k.effective_start_date);
1307 g_udt_rec(l_idx).end_date := Trunc(k.effective_end_date);
1308 l_idx := l_idx + 1; l_matrix_value := Null;
1309 debug(l_proc_name, 40);
1310 End Loop;
1311 l_user_row_name:=Null;
1312 End Loop;
1313 End Loop;
1314
1315 debug_exit (l_proc_name);
1316
1317 End Get_Udt_Data;
1318 --
1319 Procedure Get_Elements_Frm_UDT
1320 (p_assignment_id IN NUMBER -- 4336613 : LARP_SPAP_3A : new param
1321 ) Is
1322
1323 l_counter number;
1324 l_proc_name varchar2(70):= g_proc_name||'Get_Elements_Frm_UDT';
1325
1326 -- 4336613 : LARP_SPAP_3A
1327 l_error number;
1328
1329 Begin
1330
1331 debug_enter(l_proc_name);
1332
1333 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1334 -- ~ First element details from UDT for London Allowance ~
1335 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1336 l_counter :=0;
1337
1338 -- 4336613 : LARP_SPAP_3A : add this check for all the LARP elements
1339 -- Only if present in UDT, put values to global (record) variable
1340 IF ( Get_Udt_Value (p_column_name => 'Attribute Location Qualifier 1'
1341 ,p_row_name => 'LARP Inner Allowance'
1342 ) IS NOT NULL
1343 )
1344 THEN
1345
1346 l_counter := l_counter + 1;
1347 g_udt_element_LondAll(l_counter).element_name := Get_Udt_Value
1348 (p_column_name => 'Attribute Location Qualifier 1'
1349 ,p_row_name => 'LARP Inner Allowance'
1350 );
1351
1352 g_udt_element_LondAll(l_counter).allowance_code := Get_Udt_Value
1353 (p_column_name => 'Allowance Code'
1354 ,p_row_name => 'LARP Inner Allowance'
1355 );
1356
1357 g_udt_element_LondAll(l_counter).input_value_name := Get_Udt_Value
1358 (p_column_name => 'Attribute Location Qualifier 2'
1359 ,p_row_name => 'LARP Inner Allowance'
1360 );
1361
1362 debug('LondonAll Ele Count :'||to_char(g_udt_element_LondAll.COUNT), 20);
1363 END IF;
1364
1365
1366 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1367 -- ~ Second element details from UDT for London Allowance ~
1368 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1369
1370 -- 4336613 : LARP_SPAP_3A : add this check for all the LARP elements
1371 -- Only if present in UDT, put values to global (record) variable
1372 IF ( Get_Udt_Value (p_column_name => 'Attribute Location Qualifier 1'
1373 ,p_row_name => 'LARP Outer Allowance'
1374 ) IS NOT NULL
1375 )
1376 THEN
1377
1378 l_counter := l_counter + 1;
1379 g_udt_element_LondAll(l_counter).allowance_code := Get_Udt_Value
1380 (p_column_name => 'Allowance Code'
1381 ,p_row_name => 'LARP Outer Allowance'
1382 );
1383 g_udt_element_LondAll(l_counter).element_name := Get_Udt_Value
1384 (p_column_name => 'Attribute Location Qualifier 1'
1385 ,p_row_name => 'LARP Outer Allowance'
1386 );
1387 g_udt_element_LondAll(l_counter).input_value_name := Get_Udt_Value
1388 (p_column_name => 'Attribute Location Qualifier 2'
1389 ,p_row_name => 'LARP Outer Allowance'
1390 );
1391 debug('LondonAll Ele Count :'||to_char(g_udt_element_LondAll.COUNT), 30);
1392 END IF;
1393
1394 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1395 -- ~ Third element details from UDT for London Allowance ~
1396 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1397
1398 -- 4336613 : LARP_SPAP_3A : add this check for all the LARP elements
1399 -- Only if present in UDT, put values to global (record) variable
1400 IF ( Get_Udt_Value (p_column_name => 'Attribute Location Qualifier 1'
1401 ,p_row_name => 'LARP Fringe Allowance'
1402 ) IS NOT NULL
1403 )
1404 THEN
1405
1406 l_counter := l_counter + 1;
1407 g_udt_element_LondAll(l_counter).allowance_code := Get_Udt_Value
1408 (p_column_name => 'Allowance Code'
1409 ,p_row_name => 'LARP Fringe Allowance'
1410 );
1411 g_udt_element_LondAll(l_counter).element_name := Get_Udt_Value
1412 (p_column_name => 'Attribute Location Qualifier 1'
1413 ,p_row_name => 'LARP Fringe Allowance'
1414 );
1415 g_udt_element_LondAll(l_counter).input_value_name := Get_Udt_Value
1416 (p_column_name => 'Attribute Location Qualifier 2'
1417 ,p_row_name => 'LARP Fringe Allowance'
1418 );
1419 debug('LondonAll Ele Count :'||to_char(g_udt_element_LondAll.COUNT), 40);
1420 END IF;
1421
1422 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1423 -- ~ Fourth element details from UDT for London Allowance ~
1424 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1425
1426 -- 4336613 : LARP_SPAP_3A : add this check for all the LARP elements
1427 -- Only if present in UDT, put values to global (record) variable
1428 IF ( Get_Udt_Value (p_column_name => 'Attribute Location Qualifier 1'
1429 ,p_row_name => 'LARP Inner Plus Inner Supplement'
1430 ) IS NOT NULL
1431 )
1432 THEN
1433
1434 l_counter := l_counter + 1;
1435 g_udt_element_LondAll(l_counter).allowance_code := Get_Udt_Value
1436 (p_column_name => 'Allowance Code'
1437 ,p_row_name => 'LARP Inner Plus Inner Supplement'
1438 );
1439 g_udt_element_LondAll(l_counter).element_name := Get_Udt_Value
1440 (p_column_name => 'Attribute Location Qualifier 1'
1441 ,p_row_name => 'LARP Inner Plus Inner Supplement'
1442 );
1443 g_udt_element_LondAll(l_counter).input_value_name := Get_Udt_Value
1444 (p_column_name => 'Attribute Location Qualifier 2'
1445 ,p_row_name => 'LARP Inner Plus Inner Supplement'
1446 );
1447 debug('LondonAll Ele Count :'||to_char(g_udt_element_LondAll.COUNT), 50);
1448 END IF;
1449
1450 -- 4336613 : LARP_SPAP_3A : raise an error if no LARP entried found in the UDT
1451 IF g_udt_element_LondAll.COUNT = 0 THEN
1452 debug(' --------- No LARP entries found in UDT ---------', 55);
1453
1454 -- 4336613 : LARP_SPAP_3A : new error message for LARP
1455 l_error := pqp_gb_tp_extract_functions.raise_extract_warning
1456 (p_assignment_id => p_assignment_id
1457 ,p_error_text => 'BEN_94227_T1_LARP_ELE_NOTEXIST'
1458 ,p_error_number => 94227
1459 );
1460 END IF;
1461
1462
1463 --debug('Entering the Special Allowance element from UDT');
1464 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1465 -- ~ First element details from UDT for Special Allowance ~
1466 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1467 l_counter :=0;
1468
1469 -- 4336613 : LARP_SPAP_3A : add this check for all the SPAP elements
1470 -- Only if present in UDT, put values to global (record) variable
1471 IF ( Get_Udt_Value (p_column_name => 'Attribute Location Qualifier 1'
1472 ,p_row_name => 'SPAP Lower Rate'
1473 ) IS NOT NULL
1474 )
1475 THEN
1476
1477 l_counter := l_counter + 1;
1478 g_udt_element_SpcAll(l_counter).allowance_code := Get_Udt_Value
1479 (p_column_name => 'Allowance Code'
1480 ,p_row_name => 'SPAP Lower Rate'
1481 );
1482 g_udt_element_SpcAll(l_counter).element_name := Get_Udt_Value
1483 (p_column_name => 'Attribute Location Qualifier 1'
1484 ,p_row_name => 'SPAP Lower Rate'
1485 );
1486 g_udt_element_SpcAll(l_counter).input_value_name := Get_Udt_Value
1487 (p_column_name => 'Attribute Location Qualifier 2'
1488 ,p_row_name => 'SPAP Lower Rate'
1489 );
1490 debug('SpcAll Ele Count :'||to_char(g_udt_element_SpcAll.COUNT), 60);
1491 END IF;
1492
1493 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1494 -- ~ Second element details from UDT for Special Allowance ~
1495 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1496
1497 -- 4336613 : LARP_SPAP_3A : add this check for all the SPAP elements
1498 -- Only if present in UDT, put values to global (record) variable
1499 IF ( Get_Udt_Value (p_column_name => 'Attribute Location Qualifier 1'
1500 ,p_row_name => 'SPAP Higher Rate'
1501 ) IS NOT NULL
1502 )
1503 THEN
1504
1505 l_counter := l_counter + 1;
1506 g_udt_element_SpcAll(l_counter).allowance_code := Get_Udt_Value
1507 (p_column_name => 'Allowance Code'
1508 ,p_row_name => 'SPAP Higher Rate'
1509 );
1510 g_udt_element_SpcAll(l_counter).element_name := Get_Udt_Value
1511 (p_column_name => 'Attribute Location Qualifier 1'
1512 ,p_row_name => 'SPAP Higher Rate'
1513 );
1514 g_udt_element_SpcAll(l_counter).input_value_name := Get_Udt_Value
1515 (p_column_name => 'Attribute Location Qualifier 2'
1516 ,p_row_name => 'SPAP Higher Rate'
1517 );
1518 debug('SpcAll Ele Count :'||to_char(g_udt_element_SpcAll.COUNT), 70);
1519 END IF;
1520
1521 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1522 -- ~ Third element details from UDT for Special Allowance ~
1523 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1524
1525 -- 4336613 : LARP_SPAP_3A : add this check for all the SPAP elements
1526 -- Only if present in UDT, put values to global (record) variable
1527 IF ( Get_Udt_Value (p_column_name => 'Attribute Location Qualifier 1'
1528 ,p_row_name => 'SPAP Special Needs Lower Rate'
1529 ) IS NOT NULL
1530 )
1531 THEN
1532
1533 l_counter := l_counter + 1;
1534 g_udt_element_SpcAll(l_counter).allowance_code := Get_Udt_Value
1535 (p_column_name => 'Allowance Code'
1536 ,p_row_name => 'SPAP Special Needs Lower Rate'
1537 );
1538 g_udt_element_SpcAll(l_counter).element_name := Get_Udt_Value
1539 (p_column_name => 'Attribute Location Qualifier 1'
1540 ,p_row_name => 'SPAP Special Needs Lower Rate'
1541 );
1542 g_udt_element_SpcAll(l_counter).input_value_name := Get_Udt_Value
1543 (p_column_name => 'Attribute Location Qualifier 2'
1544 ,p_row_name => 'SPAP Special Needs Lower Rate'
1545 );
1546 debug('SpcAll Ele Count :'||to_char(g_udt_element_SpcAll.COUNT), 80);
1547 END IF;
1548
1549 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1550 -- ~ Fourth element details from UDT for Special Allowance ~
1551 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1552
1553 -- 4336613 : LARP_SPAP_3A : add this check for all the SPAP elements
1554 -- Only if present in UDT, put values to global (record) variable
1555 IF ( Get_Udt_Value (p_column_name => 'Attribute Location Qualifier 1'
1556 ,p_row_name => 'SPAP Special Needs Higher Rate'
1557 ) IS NOT NULL
1558 )
1559 THEN
1560
1561 l_counter := l_counter + 1;
1562 g_udt_element_SpcAll(l_counter).allowance_code := Get_Udt_Value
1563 (p_column_name => 'Allowance Code'
1564 ,p_row_name => 'SPAP Special Needs Higher Rate'
1565 );
1566 g_udt_element_SpcAll(l_counter).element_name := Get_Udt_Value
1567 (p_column_name => 'Attribute Location Qualifier 1'
1568 ,p_row_name => 'SPAP Special Needs Higher Rate'
1569 );
1570 g_udt_element_SpcAll(l_counter).input_value_name := Get_Udt_Value
1571 (p_column_name => 'Attribute Location Qualifier 2'
1572 ,p_row_name => 'SPAP Special Needs Higher Rate'
1573 );
1574 debug('SpcAll Ele Count :'||to_char(g_udt_element_SpcAll.COUNT), 90);
1575 END IF;
1576
1577 -- 4336613 : LARP_SPAP_3A : raise an error if no SPAP entried found in the UDT
1578 IF g_udt_element_SpcAll.COUNT = 0 THEN
1579 debug(' --------- No SPAP entries found in UDT ---------', 95);
1580
1581 -- 4336613 : LARP_SPAP_3A : new error message for SPAP
1582 l_error := pqp_gb_tp_extract_functions.raise_extract_warning
1583 (p_assignment_id => p_assignment_id
1584 ,p_error_text => 'BEN_94228_T1_SPAP_ELE_NOTEXIST'
1585 ,p_error_number => 94228
1586 );
1587 END IF;
1588
1589
1590 debug_exit(l_proc_name);
1591
1592 EXCEPTION
1593 WHEN OTHERS THEN
1594 debug_exit(' Others in '||l_proc_name);
1595 RAISE;
1596 End Get_Elements_Frm_UDT;
1597
1598 --
1599 -- ----------------------------------------------------------------------------
1600 -- |--------------------------< get_pay_bal_id >------------------------------|
1601 -- ----------------------------------------------------------------------------
1602 function get_pay_bal_id
1603 (p_balance_name in varchar2
1604 ,p_business_group_id in number
1605 ,p_legislation_code OUT NOCOPY VARCHAR2) -- 4336613 : new param added
1606 return number is
1607 --
1608 l_proc_name varchar2(60) := g_proc_name || 'get_pay_bal_id';
1609 l_bal_type_id csr_get_pay_bal_id%rowtype;
1610 --
1611 begin
1612
1613 --
1614 -- hr_utility.set_location('Entering: '||l_proc_name, 5);
1615 --
1616 debug_enter(l_proc_name);
1617
1618 open csr_get_pay_bal_id
1619 (c_balance_name => p_balance_name
1620 ,c_business_group_id => p_business_group_id);
1621 fetch csr_get_pay_bal_id into l_bal_type_id;
1622 IF csr_get_pay_bal_id%NOTFOUND THEN
1623 debug('Not found', 20);
1624 END IF;
1625
1626 close csr_get_pay_bal_id;
1627
1628 debug_exit(l_proc_name);
1629
1630 --
1631 -- hr_utility.set_location('Leaving: '||l_proc_name, 15);
1632 --
1633 p_legislation_code := l_bal_type_id.legislation_code;
1634
1635 return l_bal_type_id.balance_type_id;
1636
1637 EXCEPTION
1638 WHEN OTHERS THEN
1639 debug_exit(' Others in '||l_proc_name);
1640 RAISE;
1641 end get_pay_bal_id;
1642 --
1643 -- ----------------------------------------------------------------------------
1644 -- |-------------------------< get_pay_ele_ids_from_bal >---------------------|
1645 -- ----------------------------------------------------------------------------
1646 procedure get_pay_ele_ids_from_bal
1647 (p_assignment_id in number
1648 ,p_balance_type_id in number
1649 ,p_effective_date in date
1650 ,p_error_text in varchar2
1651 ,p_error_number in number
1652 ,p_business_group_id in number
1653 ,p_tab_ele_ids out nocopy t_ele_ids_from_bal
1654 ,p_token in varchar2 default null
1655 ) is
1656 --
1657 l_proc_name varchar2(60) := g_proc_name || 'get_pay_ele_ids_from_bal';
1658 l_ele_ids csr_get_pay_ele_ids_from_bal%rowtype;
1659 l_error number ;
1660 l_ele_type_id number ;
1661
1662 --
1663 begin
1664
1665 --
1666 -- hr_utility.set_location('Entering: '||l_proc_name, 5);
1667 --
1668
1669 debug_enter(l_proc_name);
1670
1671 debug('p_assignment_id: '||to_char(p_assignment_id),10) ;
1672 debug('p_balance_type_id: '||to_char(p_balance_type_id)) ;
1673 debug('p_effective_date: '||to_char(p_effective_date)) ;
1674 debug('p_error_text: '||p_error_text) ;
1675 debug('p_error_number: '||to_char(p_error_number)) ;
1676 debug('p_token: '||p_token) ;
1677
1678
1679 open csr_get_pay_ele_ids_from_bal
1680 (c_balance_type_id => p_balance_type_id
1681 ,c_effective_date => p_effective_date
1682 ,c_business_group_id => p_business_group_id
1683 );
1684 loop
1685
1686 fetch csr_get_pay_ele_ids_from_bal into l_ele_ids;
1687 exit when csr_get_pay_ele_ids_from_bal%notfound;
1688 --
1689 p_tab_ele_ids(l_ele_ids.element_type_id).element_type_id := l_ele_ids.element_type_id;
1690 p_tab_ele_ids(l_ele_ids.element_type_id).input_value_id := l_ele_ids.input_value_id;
1691 --
1692 debug(l_proc_name, 20);
1693 end loop;
1694
1695 if csr_get_pay_ele_ids_from_bal%rowcount = 0
1696 and p_error_text IS NOT NULL -- don't raise an error, as in OSLA case.
1697 then
1698
1699 debug(l_proc_name, 30);
1700 l_error := pqp_gb_tp_extract_functions.raise_extract_error
1701 (p_business_group_id => g_business_group_id
1702 ,p_assignment_id => p_assignment_id
1703 ,p_error_text => p_error_text
1704 ,p_error_number => p_error_number
1705 ,p_token1 => p_token
1706 );
1707
1708 end if;
1709 close csr_get_pay_ele_ids_from_bal;
1710
1711
1712 -- debug the element type ids fetched for a balance
1713 debug('p_balance_type_id: '||to_char(p_balance_type_id),40) ;
1714 l_ele_type_id := p_tab_ele_ids.FIRST;
1715 WHILE l_ele_type_id IS NOT NULL
1716 LOOP
1717 debug('element_type_id : '||to_char(l_ele_type_id), 50);
1718 l_ele_type_id := p_tab_ele_ids.NEXT(l_ele_type_id);
1719 END LOOP;
1720 -----
1721
1722 debug_exit(l_proc_name);
1723
1724 --Added by tmehra for nocopy changes Feb'03
1725
1726 EXCEPTION
1727 WHEN OTHERS THEN
1728 debug_exit(l_proc_name);
1729 p_tab_ele_ids.delete;
1730 raise;
1731
1732 end get_pay_ele_ids_from_bal;
1733
1734 --
1735 Function Get_Udt_Value( p_table_name in varchar2
1736 ,p_column_name in varchar2
1737 ,p_row_name in varchar2
1738 ,p_effective_date in date
1739 ,p_business_group_id in number) Return varchar2 Is
1740
1741 /*
1742 Cursor Get_Matrix_Value ( c_user_table_name in varchar
1743 ,c_user_column_name in varchar
1744 ,c_user_row_name in varchar
1745 ,c_effective_date in date) Is
1746 select put.user_table_name
1747 ,puc.user_column_name
1748 ,pur.row_low_range_or_name
1749 ,pci.value
1750 from pay_user_tables put
1751 ,pay_user_columns puc
1752 ,pay_user_rows_f pur
1753 ,pay_user_column_instances_f pci
1754 where put.user_table_name = c_user_table_name
1755 and puc.user_table_id = put.user_table_id
1756 and puc.user_column_name = c_user_column_name
1757 and pur.row_low_range_or_name = c_user_row_name
1758 and pur.user_table_id = put.user_table_id
1759 and pci.user_column_id = puc.user_column_id
1760 and pci.user_row_id = pur.user_row_id
1761 and Trunc(c_effective_date) between pur.effective_start_date
1762 and pur.effective_end_date
1763 and Trunc(c_effective_date) between pci.effective_start_date
1764 and pci.effective_end_date
1765 and ((pci.business_group_id is null and pci.legislation_code is null)
1766 or (pci.legislation_code is not null
1767 and pci.legislation_code = 'GB')
1768 or (pci.business_group_id is not null
1769 and pci.business_group_id = NVL(p_business_group_id, g_business_group_id))
1770 )
1771 order by put.user_table_name, puc.user_column_name, pur.display_sequence;
1772 */
1773
1774 l_return_value pay_user_column_instances_f.value%TYPE;
1775 l_udt_row Get_Matrix_Value%ROWTYPE;
1776 l_notfound_UDTCache Boolean;
1777 l_effective_date date;
1778 l_table_name pay_user_tables.user_table_name%TYPE;
1779 l_proc_name varchar2(70) := g_proc_name || 'get_udt_value';
1780
1781 Begin
1782 debug_enter (l_proc_name);
1783 -- If the effective date or the UDT table name are
1784 -- null then take the ones defined in the package header.
1785 l_effective_date := NVL(p_effective_date,g_effective_date);
1786 l_table_name := NVL(p_table_name,g_extract_udt_name);
1787 l_notfound_UDTCache := True;
1788 IF NVL(p_business_group_id, g_business_group_id) = g_business_group_id THEN
1789 -- Check if the value can be found in the cached
1790 -- PL/SQL record table for the given effective date
1791 For i In 1..g_udt_rec.count Loop
1792 debug(l_proc_name, 20);
1793 If g_udt_rec(i).column_name = p_column_name And
1794 g_udt_rec(i).row_name = p_row_name And
1795 (l_effective_date Between g_udt_rec(i).start_date
1796 and g_udt_rec(i).end_date) Then
1797 l_return_value := g_udt_rec(i).matrix_value;
1798 l_notfound_UDTCache := False;
1799 debug(l_proc_name, 30);
1800 Exit;
1801 End If;
1802 End Loop;
1803 END IF; -- End if of p_business_group = g_business_group check ...
1804 --
1805 debug(l_proc_name, 40);
1806 -- If the value could not found in the cached PL/SQL
1807 -- table then get the value from the UDT database tables
1808 If l_notfound_UDTCache Then
1809 debug(l_proc_name, 50);
1810 Open Get_Matrix_Value( c_user_table_name => l_table_name
1811 ,c_user_column_name => p_column_name
1812 ,c_user_row_name => p_row_name
1813 ,c_effective_date => l_effective_date
1814 ,c_business_group_id => p_business_group_id);
1815 Fetch Get_Matrix_Value Into l_udt_row;
1816 If Get_Matrix_Value%NOTFOUND Then
1817 debug(l_proc_name, 60);
1818 l_return_value := Null;
1819 Close Get_Matrix_Value;
1820 Else
1821 Close Get_Matrix_Value;
1822 l_return_value := l_udt_row.value;
1823 End If;
1824 End If;
1825 debug('Return Value :'||l_return_value, 70);
1826 debug_exit (l_proc_name);
1827 Return l_return_value;
1828 EXCEPTION
1829 WHEN OTHERS THEN
1830 debug_exit(' Others in '||l_proc_name);
1831 RAISE;
1832 End Get_Udt_Value;
1833
1834
1835 -- 4336613 : OSLA_3A : new function for defined_balance_id, moved from calc_part_time_sal
1836 -- into a separate generic function based on balance_type_id
1837 --
1838 -- ----------------------------------------------------------------------------
1839 -- |--------------------------< get_defined_balance_id >-----------------------|
1840 -- ----------------------------------------------------------------------------
1841
1842 PROCEDURE get_defined_balance_id(p_assignment_id IN NUMBER
1843 ,p_bal_type_id IN NUMBER
1844 ,p_business_group_id IN NUMBER
1845 ,p_tab_bal_name IN VARCHAR2
1846 ,p_seed_flag IN VARCHAR2)
1847
1848 IS
1849 --
1850 l_proc_name VARCHAR2(60) := g_proc_name || 'get_defined_balance_id';
1851 l_error NUMBER;
1852 l_error_text VARCHAR2(60);
1853 l_error_number NUMBER;
1854 --
1855 BEGIN
1856 --
1857 debug_enter (l_proc_name);
1858
1859 debug('p_assignment_id: '|| to_char(p_assignment_id), 10) ;
1860 debug('p_bal_type_id: '|| to_char(p_bal_type_id)) ;
1861 debug('p_business_group_id: '|| to_char(p_business_group_id)) ;
1862
1863 IF NOT g_def_bal_id.EXISTS(p_bal_type_id) THEN -- value is not set yet.
1864 -- get the defined balance id for the designaetd Balance type
1865 -- for Retro payments calculation
1866 debug('Setting the defined balance id ',40);
1867 OPEN csr_get_defined_balance_id
1868 ( p_balance_type_id => p_bal_type_id
1869 ,p_dimension_name => '_ASG_RETROELE_RUN'
1870 ,p_business_group_id => p_business_group_id
1871 );
1872 FETCH csr_get_defined_balance_id INTO g_def_bal_id(p_bal_type_id);
1873
1874 IF csr_get_defined_balance_id%NOTFOUND THEN
1875 debug('Balance Dimension not defined',50);
1876 debug('THIS CONDITION SHOULD NEVER ARISE - RAISE ERROR',60);
1877
1878 IF p_seed_flag = 'Y' THEN -- raise error for a seeded balance
1879 l_error_text := 'BEN_94208_EXT_TP1_DEF_BAL_ERR';
1880 l_error_number := 94208;
1881 ELSE -- raise error for user defined balance
1882 l_error_text := 'BEN_94246_EXT_TP1_DEF_BAL_ERR';
1883 l_error_number := 94246;
1884 END IF;
1885
1886 l_error := pqp_gb_tp_extract_functions.raise_extract_error
1887 (p_business_group_id => g_business_group_id
1888 ,p_assignment_id => p_assignment_id
1889 ,p_error_text => l_error_text
1890 ,p_error_number => l_error_number
1891 ,p_token1 => p_tab_bal_name
1892 );
1893
1894 ELSE
1895 debug('g_def_bal_id(p_bal_type_id): '||to_char(g_def_bal_id(p_bal_type_id)),70);
1896 END IF ;
1897
1898 CLOSE csr_get_defined_balance_id ;
1899 END IF ;
1900
1901 debug('AFTER: g_def_bal_id (p_bal_type_id):'|| to_char(g_def_bal_id(p_bal_type_id)),80) ;
1902
1903
1904 debug_exit (l_proc_name);
1905 EXCEPTION
1906 WHEN OTHERS THEN
1907 debug_exit(' Others in '||l_proc_name);
1908 RAISE;
1909
1910 END get_defined_balance_id;
1911
1912 --
1913 -- ----------------------------------------------------------------------------
1914 -- |--------------------------< fetch_eles_from_bals >-----------------------|
1915 -- ----------------------------------------------------------------------------
1916 procedure fetch_eles_from_bals (p_assignment_id in number
1917 ,p_effective_date in date
1918 ,p_business_group_id in number)
1919 is
1920 --
1921 l_proc_name varchar2(60) := g_proc_name || 'fetch_eles_from_bals';
1922
1923 l_tab_bal_name t_varchar;
1924 l_bal_type_id pay_balance_types.balance_type_id%type;
1925 l_legislation_code VARCHAR2(30); -- to hold legislation code of balance
1926 l_error NUMBER ;
1927 l_seed_flag VARCHAR2(1); -- flag to signify if balance is seeded/user defined
1928 --
1929 begin
1930 --
1931 -- hr_utility.set_location ('Entering: '||l_proc_name, 10);
1932 --
1933 debug_enter (l_proc_name);
1934
1935 -- Get Absence balance name from the UDT
1936
1937 l_tab_bal_name(1) := get_udt_value (p_column_name => 'Attribute Location Qualifier 1'
1938 ,p_row_name => 'Days Excluded Balance'
1939 ,p_business_group_id => p_business_group_id
1940 );
1941 -- Check whether a balance name is specified otherwise use
1942 -- the seeded generic balance for days excluded
1943
1944 if l_tab_bal_name(1) is null then
1945
1946 l_tab_bal_name(1) := 'Teachers Total Days Excluded';
1947
1948 end if; -- end if of balance name specified check ...
1949
1950 --
1951 debug(l_proc_name, 20);
1952 debug('Business Group: '||to_char(p_business_group_id));
1953 --
1954
1955 -- Get Superannuable Salary balance name from the UDT
1956
1957 l_tab_bal_name(2) := get_udt_value (p_column_name => 'Attribute Location Qualifier 1'
1958 ,p_row_name => 'Superannuable Salary Balance'
1959 ,p_business_group_id => p_business_group_id
1960 );
1961 -- Check whether a balance name is specified otherwise use
1962 -- the seeded generic balance for superannuable salary
1963
1964 if l_tab_bal_name(2) is null then
1965
1966 l_tab_bal_name(2) := 'Teachers Superannuable Salary';
1967
1968 end if; -- end if of balance name specified check ...
1969
1970
1971 --4336613 : OSLA_3A : new balance seeded for OSLA calculations
1972 -- Get Teachers OSLA Payments balance name from the UDT
1973
1974 l_tab_bal_name(3) := get_udt_value (p_column_name => 'Attribute Location Qualifier 1'
1975 ,p_row_name => 'Teachers OSLA Payments Balance'
1976 ,p_business_group_id => p_business_group_id
1977 );
1978 -- Check whether a balance name is specified otherwise use
1979 -- the seeded generic balance for superannuable salary
1980
1981 if l_tab_bal_name(3) is null then
1982
1983 l_tab_bal_name(3) := 'Teachers OSLA Payments';
1984
1985 end if; -- end if of balance name specified check ...
1986 -- end of OSLA section
1987
1988 l_tab_bal_name(4) := get_udt_value (p_column_name => 'Attribute Location Qualifier 1'
1989 ,p_row_name => 'Superannuable Claims Balance'
1990 ,p_business_group_id => p_business_group_id
1991 );
1992 -- Check whether a balance name is specified otherwise use
1993 -- the seeded generic balance for superannuable salary
1994
1995 if l_tab_bal_name(4) is null then
1996
1997 l_tab_bal_name(4) := 'Teachers Superannuable Claims';
1998
1999 end if; -- end if of balance name specified check ...
2000 -- end of OSLA section
2001
2002 -- Get Teachers OSLA Payments balance name from the UDT
2003
2004 l_tab_bal_name(5) := get_udt_value (p_column_name => 'Attribute Location Qualifier 1'
2005 ,p_row_name => 'Teachers OSLA Claims Balance'
2006 ,p_business_group_id => p_business_group_id
2007 );
2008 -- Check whether a balance name is specified otherwise use
2009 -- the seeded generic balance for superannuable salary
2010
2011 if l_tab_bal_name(5) is null then
2012
2013 l_tab_bal_name(5) := 'Teachers OSLA Claims';
2014
2015 end if; -- end if of balance name specified check ...
2016 -- end of OSLA section
2017
2018 FOR i IN 1..l_tab_bal_name.count LOOP
2019 --
2020 debug(l_proc_name, 30);
2021 debug('Balance Name: '||l_tab_bal_name(i));
2022 --
2023 -- Get balance type id for this balance name
2024 l_bal_type_id := get_pay_bal_id (p_balance_name => l_tab_bal_name(i)
2025 ,p_business_group_id => p_business_group_id
2026 ,p_legislation_code => l_legislation_code); --OUT
2027
2028 debug('Balance ID: '||to_char(l_bal_type_id),40);
2029
2030 -- store bal_type_id in global
2031 IF i = 1 THEN
2032 g_abs_bal_type_id(p_business_group_id) := l_bal_type_id;
2033 ELSIF i=2 THEN
2034 g_sal_bal_type_id(p_business_group_id) := l_bal_type_id;
2035 ELSIF i=3 THEN
2036 g_osla_bal_type_id(p_business_group_id) := l_bal_type_id; --4336613 : OSLA_3A: new global
2037 ELSIF i=4 THEN
2038 g_cl_bal_type_id(p_business_group_id) := l_bal_type_id;
2039 ELSE
2040 g_osla_cl_bal_type_id(p_business_group_id) := l_bal_type_id;
2041 END IF;
2042
2043
2044 -- 4336613 : OSLA_3A : moved from inside calc_part_time_sal to here
2045 -- call to function to store defined balance id for i=2 and 3,
2046 -- i.e. Teachers Superannuable Sal and OSLA Payments balance
2047 IF i=2 OR i=3 THEN
2048
2049 IF l_legislation_code IS NOT NULL THEN -- for case when user balance name is
2050 -- same as the seeded balance, leg_code will be GB for seeded balance
2051 -- and NULL for user balance
2052 l_seed_flag := 'Y'; -- not NULL,implies is a seeded balance name in UDT
2053 ELSE
2054 l_seed_flag := 'N'; -- user defined balance in the UDT
2055 END IF; -- end if of balance name specified check ...
2056
2057 -- store balance type id
2058 get_defined_balance_id(p_assignment_id => p_assignment_id
2059 ,p_bal_type_id => l_bal_type_id
2060 ,p_business_group_id => p_business_group_id
2061 ,p_tab_bal_name => l_tab_bal_name(i)
2062 ,p_seed_flag => l_seed_flag
2063 );
2064
2065 END IF;
2066
2067
2068 END LOOP;
2069
2070 --
2071 debug(l_proc_name, 60);
2072 --
2073 -- Get element type id's feeding absence balance
2074 --
2075 get_pay_ele_ids_from_bal (p_assignment_id => p_assignment_id
2076 ,p_balance_type_id => g_abs_bal_type_id(p_business_group_id)
2077 ,p_effective_date => p_effective_date
2078 ,p_error_text => 'BEN_93025_EXT_TP1_BAL_NOFEEDS'
2079 ,p_error_number => 93025
2080 ,p_business_group_id => p_business_group_id
2081 ,p_tab_ele_ids => g_tab_abs_ele_ids
2082 ,p_token => 'Days Excluded Balance'
2083 );
2084
2085 debug(l_proc_name, 70);
2086 --
2087 -- Get element type id's feeding salary balance
2088 --
2089 -- Bug 3015917 : Added this as we need to cache PET Ids for Sal Balance
2090 get_pay_ele_ids_from_bal (p_assignment_id => p_assignment_id
2091 ,p_balance_type_id => g_sal_bal_type_id(p_business_group_id)
2092 ,p_effective_date => p_effective_date
2093 ,p_error_text => 'BEN_93025_EXT_TP1_BAL_NOFEEDS'
2094 ,p_error_number => 93025
2095 ,p_business_group_id => p_business_group_id
2096 ,p_tab_ele_ids => g_tab_sal_ele_ids -- OUT
2097 ,p_token => 'Superannuable Salary Balance'
2098 );
2099
2100 -- Bug 6689648
2101 -- Superannuable Claims Balance is applicable only when Date Worked mode is Used
2102 if g_date_work_mode = 'Y' then
2103 get_pay_ele_ids_from_bal (p_assignment_id => p_assignment_id
2104 ,p_balance_type_id => g_cl_bal_type_id(p_business_group_id)
2105 ,p_effective_date => p_effective_date
2106 ,p_error_text => 'BEN_93025_EXT_TP1_BAL_NOFEEDS'
2107 ,p_error_number => 93025
2108 ,p_business_group_id => p_business_group_id
2109 ,p_tab_ele_ids => g_tab_cl_ele_ids -- OUT
2110 ,p_token => 'Superannuable Claims Balance'
2111 );
2112 end if ;
2113
2114 -- 4336613 : OSLA_3A : fetching values in g_tab_osla_ele_ids
2115 --
2116 -- Get element type id's feeding OSLA Payments balance
2117 --
2118 get_pay_ele_ids_from_bal (p_assignment_id => p_assignment_id
2119 ,p_balance_type_id => g_osla_bal_type_id(p_business_group_id)
2120 ,p_effective_date => p_effective_date
2121 ,p_error_text => NULL -- 'BEN_93025_EXT_TP1_BAL_NOFEEDS'
2122 ,p_error_number => NULL -- 93025
2123 ,p_business_group_id => p_business_group_id
2124 ,p_tab_ele_ids => g_tab_osla_ele_ids
2125 );
2126
2127 -- Bug 6689648
2128 -- Teachers OSLA Claims Balance is applicable only when Date Worked mode is Used
2129 if g_date_work_mode = 'Y' then
2130 get_pay_ele_ids_from_bal (p_assignment_id => p_assignment_id
2131 ,p_balance_type_id => g_osla_bal_type_id(p_business_group_id)
2132 ,p_effective_date => p_effective_date
2133 ,p_error_text => NULL -- 'BEN_93025_EXT_TP1_BAL_NOFEEDS'
2134 ,p_error_number => NULL -- 93025
2135 ,p_business_group_id => p_business_group_id
2136 ,p_tab_ele_ids => g_tab_osla_cl_ele_ids
2137 );
2138 end if ;
2139
2140 -- Raise a warning if no element is feeding the
2141 -- OSLA balance.
2142 IF g_tab_osla_ele_ids.COUNT = 0 THEN
2143 debug(l_proc_name,80 ) ;
2144 l_error := pqp_gb_tp_extract_functions.raise_extract_warning
2145 (p_assignment_id => p_assignment_id
2146 ,p_error_text => 'BEN_94240_T1_OSLA_ELE_NOTEXIST'
2147 ,p_error_number => 94240
2148 );
2149 debug('l_error: '|| to_char(l_error), 90 ) ;
2150 END IF;
2151
2152 -- Bug 6689648
2153 -- Teachers OSLA Claims Balance is applicable only when Date Worked mode is Used
2154 if g_date_work_mode = 'Y' then
2155 IF g_tab_osla_cl_ele_ids.COUNT = 0 THEN
2156 debug(l_proc_name,80 ) ;
2157 l_error := pqp_gb_tp_extract_functions.raise_extract_warning
2158 (p_assignment_id => p_assignment_id
2159 ,p_error_text => 'BEN_94240_T1_OSLA_ELE_NOTEXIST'
2160 ,p_error_number => 94240
2161 );
2162 debug('l_error: '|| to_char(l_error), 90 ) ;
2163 END IF;
2164 end if ;
2165
2166 debug_exit (l_proc_name);
2167 EXCEPTION
2168 WHEN OTHERS THEN
2169 debug_exit(' Others in '||l_proc_name);
2170 RAISE;
2171 end fetch_eles_from_bals;
2172 --
2173
2174 -- ----------------------------------------------------------------------------
2175 -- |--------------------------< fetch_eles_for_t1_bals >----------------------|
2176 -- ----------------------------------------------------------------------------
2177 procedure fetch_eles_for_t1_bals (p_assignment_id in number
2178 ,p_effective_date in date)
2179 is
2180 --
2181 l_proc_name varchar2(60) := g_proc_name || 'fetch_eles_for_t1_bals';
2182
2183 l_tab_bal_name t_varchar;
2184 l_bal_type_id pay_balance_types.balance_type_id%type;
2185 i number;
2186
2187 --
2188 begin
2189 --
2190 -- hr_utility.set_location ('Entering: '||l_proc_name, 10);
2191 --
2192 debug_enter (l_proc_name);
2193
2194 g_abs_bal_type_id.DELETE;
2195 g_sal_bal_type_id.DELETE;
2196 g_cl_bal_type_id.DELETE;
2197 g_tab_abs_ele_ids.DELETE;
2198 g_tab_sal_ele_ids.DELETE;
2199
2200 -- 4336613 : OSLA_3A : new globals for OSLA
2201 g_osla_bal_type_id.DELETE;
2202 g_osla_cl_bal_type_id.DELETE;
2203 g_tab_osla_ele_ids.DELETE;
2204
2205 -- Fetch the elements from balances for master business group first
2206
2207 debug(l_proc_name, 10);
2208
2209 fetch_eles_from_bals (p_assignment_id => p_assignment_id
2210 ,p_effective_date => p_effective_date
2211 ,p_business_group_id => g_business_group_id
2212 );
2213
2214 -- Check whether the collection g_LEA_business_groups has more than one count
2215 IF g_lea_business_groups.COUNT > 0 THEN
2216
2217 i := g_lea_business_groups.FIRST;
2218
2219 WHILE i IS NOT NULL
2220 LOOP
2221
2222 debug(l_proc_name, 20);
2223
2224 fetch_eles_from_bals (p_assignment_id => p_assignment_id
2225 ,p_effective_date => p_effective_date
2226 ,p_business_group_id => g_lea_business_groups(i).business_group_id
2227 );
2228 i := g_lea_business_groups.NEXT(i);
2229
2230 END LOOP;
2231
2232 END IF; -- End if of multiple business groups exists check ...
2233
2234 --
2235 -- hr_utility.set_location ('Leaving: '||l_proc_name, 30);
2236 --
2237 debug_exit (l_proc_name);
2238
2239 EXCEPTION
2240 WHEN OTHERS THEN
2241 debug_exit(' Others in '||l_proc_name);
2242 RAISE;
2243 end fetch_eles_for_t1_bals;
2244 --
2245 -- ----------------------------------------------------------------------------
2246 -- |--------------------------< get_rate_type_from_udt >----------------------|
2247 -- ----------------------------------------------------------------------------
2248 procedure get_rate_type_from_udt (p_assignment_id in number) is
2249 --
2250 l_proc_name varchar2(60) := g_proc_name || 'get_rate_type_from_udt';
2251
2252 cursor csr_rate_type_check (p_meaning varchar2) is
2253 select 'Y'
2254 from hr_lookups
2255 where meaning = p_meaning
2256 and lookup_type = 'PQP_RATE_TYPE'
2257 and enabled_flag = 'Y'
2258 and g_effective_date between
2259 nvl(start_date_active, g_effective_date)
2260 and nvl(end_date_active, g_effective_date);
2261
2262 l_tab_rate_type t_varchar;
2263 l_tab_rate_name t_varchar;
2264 l_exists varchar2(1);
2265 l_error number;
2266 --
2267 begin
2268 --
2269 -- hr_utility.set_location ('Entering: '||l_proc_name, 10);
2270 --
2271 debug_enter (l_proc_name);
2272
2273 l_tab_rate_type(1) := 'Other Allowances';
2274 l_tab_rate_type(2) := 'Salary';
2275 l_tab_rate_type(3) := 'Safeguarded Salary';
2276 l_tab_rate_type(4) := 'LARP and SPAP Allowances';
2277
2278 for i in 1..l_tab_rate_type.count loop
2279
2280 --
2281 debug (l_proc_name, 20);
2282 --
2283 l_tab_rate_name(i) := get_udt_value (p_column_name => 'Attribute Location Qualifier 1'
2284 ,p_row_name => l_tab_rate_type(i)
2285 );
2286
2287 -- Check whether a rate type has been specified
2288 -- Bug fix 2786740
2289 -- Raise error only for "Salary" rate type
2290
2291 if l_tab_rate_name(i) is null and l_tab_rate_type(i) = 'Salary' then
2292
2293 l_error := pqp_gb_tp_extract_functions.raise_extract_error
2294 (p_business_group_id => g_business_group_id
2295 ,p_assignment_id => p_assignment_id
2296 ,p_error_text => 'BEN_93023_EXT_TP1_NO_RATE_TYPE'
2297 ,p_error_number => 93023
2298 );
2299
2300 end if; -- end if of rate type specified check ...
2301
2302 -- Modified for bug fix 2350695
2303 -- Check whether this rate type exists in the lookup type 'PQP_RATE_TYPE'
2304
2305 IF l_tab_rate_name(i) IS NOT NULL THEN
2306
2307 debug (l_proc_name, 30);
2308 open csr_rate_type_check (l_tab_rate_name(i));
2309 fetch csr_rate_type_check into l_exists;
2310
2311 if csr_rate_type_check%notfound then
2312
2313 close csr_rate_type_check;
2314 l_error := pqp_gb_tp_extract_functions.raise_extract_error
2315 (p_business_group_id => g_business_group_id
2316 ,p_assignment_id => p_assignment_id
2317 ,p_error_text => 'BEN_93046_EXT_TP1_INV_RATE_TYP'
2318 ,p_error_number => 93046
2319 );
2320
2321 end if; -- end if of rate type exists in lookup check ...
2322 close csr_rate_type_check;
2323
2324 END IF; -- End if of rate name not null check ...
2325
2326 end loop;
2327
2328 g_oth_rate_type := l_tab_rate_name(1);
2329 g_sal_rate_type := l_tab_rate_name(2);
2330 g_sf_rate_type := l_tab_rate_name(3);
2331 g_lon_rate_type := l_tab_rate_name(4);
2332
2333 --
2334 -- hr_utility.set_location ('Leaving: '||l_proc_name, 30);
2335 --
2336 debug_exit (l_proc_name);
2337 EXCEPTION
2338 WHEN OTHERS THEN
2339 debug_exit(' Others in '||l_proc_name);
2340 RAISE;
2341 end get_rate_type_from_udt;
2342
2343 -- Commenting the following function
2344 -- as this is not required now.
2345 -- the replacement function is chk_effective_asg
2346 /*--
2347 -- chk_eff_primary_asg
2348 -- Procedure returns 'Y' if the primary is a valid TCHR assignment
2349 -- on p_effective_date.
2350 --
2351 FUNCTION chk_eff_primary_asg
2352 (p_assignment_id IN NUMBER
2353 ,p_effective_date IN DATE
2354 ) RETURN VARCHAR2
2355 IS
2356
2357 l_assignment_id per_all_assignments_f.assignment_id%TYPE;
2358 l_retval VARCHAR2(1) := 'Y';
2359 l_effective_date DATE;
2360
2361
2362
2363 l_proc_name varchar2(60) := g_proc_name || 'chk_eff_primary_asg';
2364
2365 BEGIN -- chk_eff_primary_asg
2366
2367 debug_enter(l_proc_name);
2368 debug('p_assignment_id :'||to_char(p_assignment_id), 10);
2369 debug('p_effective_date :'||to_char(p_effective_date), 20);
2370
2371
2372 -- Bugfix 3803760:FTSUPPLY : Added the overrid ft asg logic
2373 IF g_override_ft_asg_id IS NULL THEN
2374
2375 IF (g_ext_asg_details.EXISTS(p_assignment_id)
2376 AND
2377 g_ext_asg_details(p_assignment_id).report_asg = 'Y' -- is to be reported
2378 AND
2379 (p_effective_date
2380 BETWEEN nvl(g_ext_asg_details(p_assignment_id).start_date, p_effective_date )
2381 AND
2382 nvl(g_ext_asg_details(p_assignment_id).leaver_date, g_effective_run_date)
2383 OR
2384 (g_ext_asg_details(p_assignment_id).restarter_date IS NOT NULL
2385 AND
2386 p_effective_date >= g_ext_asg_details(p_assignment_id).restarter_date
2387 )
2388 )
2389 ) THEN
2390
2391 l_retval := 'Y';
2392 debug(l_proc_name, 30);
2393
2394 ELSE
2395
2396 debug(l_proc_name, 50);
2397 l_retval := 'N';
2398
2399 END IF;
2400
2401 ELSIF g_override_ft_asg_id = p_assignment_id THEN
2402
2403 l_retval := 'Y';
2404 debug(l_proc_name, 60);
2405
2406 ELSE
2407
2408 debug(l_proc_name, 70);
2409 l_retval := 'N';
2410
2411 END IF;
2412
2413 debug('l_retval ' ||l_retval) ;
2414 debug_exit(l_proc_name);
2415
2416 RETURN l_retval;
2417
2418 EXCEPTION
2419 WHEN OTHERS THEN
2420 debug_exit(' Others in '||l_proc_name);
2421 RAISE;
2422 END; -- chk_eff_primary_asg
2423 */
2424
2425 -- This procedure will find all BGs which have the same
2426 -- LEA number and have been enabled for cross BG reporting
2427 -- and store them in global collection
2428 PROCEDURE store_cross_bg_details
2429 IS
2430
2431 l_BG_dets csr_all_business_groups%ROWTYPE;
2432 l_master_bg_dets csr_multiproc_data%ROWTYPE;
2433
2434 l_proc_name varchar2(60) := g_proc_name || 'store_cross_bg_details';
2435
2436 BEGIN -- store_cross_bg_details
2437
2438 debug_enter(l_proc_name);
2439
2440 IF pqp_gb_tp_pension_extracts.g_parent_request_id <> -1 THEN
2441
2442 -- We are running the TPEP, get the master bg id
2443 OPEN csr_multiproc_data(p_record_type => 'M');
2444 FETCH csr_multiproc_data INTO l_master_bg_dets;
2445
2446 IF csr_multiproc_data%FOUND
2447 AND
2448 l_master_bg_dets.business_group_id IS NOT NULL THEN
2449 g_master_bg_id := l_master_bg_dets.business_group_id;
2450 ELSE
2451 -- We might need an ERROR here
2452 -- If we do raise an error, plaese also
2453 -- do a CLOSE cursor here
2454 debug('This situation should never arise', 10);
2455 END IF;
2456
2457 CLOSE csr_multiproc_data;
2458
2459 ELSE -- We are running the Extract Process
2460
2461 -- The Type 1 extract process has been submitted
2462 -- directly for an LEA report instead of using the new
2463 -- master process for TPA reports which sets the
2464 -- master BG in the multiproc data table.
2465 -- We can safely make this assumption and set the current
2466 -- BG as master BG.
2467 g_master_bg_id := g_business_group_id;
2468
2469 -- Should we still leave cross BG reporting enabled
2470 -- Answer is NO
2471 g_crossbg_enabled := 'N';
2472
2473 -- Also change the flag in Type 4 pkg
2474 pqp_gb_tp_pension_extracts.g_crossbg_enabled := 'N';
2475
2476 END IF;
2477
2478 debug('MasterBG :'||to_char(g_master_bg_id)||
2479 ' CurrentBG :'||to_char(g_business_group_id)
2480 , 20
2481 );
2482
2483 g_lea_business_groups.DELETE;
2484
2485 IF g_crossbg_enabled = 'Y' THEN
2486
2487 -- Loop thru all the LEA BGs enabled for Cross BG reporting
2488 FOR l_BG_dets IN csr_all_business_groups(g_lea_number)
2489 LOOP -- 1
2490
2491 g_lea_business_groups(l_BG_dets.business_group_id) := l_BG_dets;
2492
2493 debug(l_proc_name, 30);
2494
2495 -- Store all criteria establishments from this BG
2496 FOR l_estb_details IN pqp_gb_tp_pension_extracts.csr_estb_details
2497 (p_business_group_id => l_BG_dets.business_group_id
2498 ,p_lea_estb_yn => 'Y')
2499 LOOP -- 2
2500
2501 pqp_gb_tp_pension_extracts.g_criteria_estbs(l_estb_details.location_id):= l_estb_details;
2502
2503 debug('Establishment Details...', 40);
2504 debug(pqp_gb_tp_pension_extracts.g_criteria_estbs(l_estb_details.location_id).location_id);
2505 debug(pqp_gb_tp_pension_extracts.g_criteria_estbs(l_estb_details.location_id).lea_estb_yn);
2506 debug(pqp_gb_tp_pension_extracts.g_criteria_estbs(l_estb_details.location_id).estb_number);
2507 debug(pqp_gb_tp_pension_extracts.g_criteria_estbs(l_estb_details.location_id).estb_name);
2508 debug(pqp_gb_tp_pension_extracts.g_criteria_estbs(l_estb_details.location_id).estb_type);
2509 debug('...Establishment Details', 50);
2510
2511 END LOOP; -- 2
2512 --
2513 END LOOP; -- 1
2514
2515 END IF; -- g_crossbg_enabled = 'Y' THEN
2516
2517 debug_exit (l_proc_name);
2518
2519 EXCEPTION
2520 WHEN OTHERS THEN
2521 debug_exit(' Others in '||l_proc_name);
2522 RAISE;
2523 END; -- store_cross_bg_details
2524
2525 --
2526 -- reset_proc_status
2527 --
2528 PROCEDURE reset_proc_status IS
2529
2530 PRAGMA AUTONOMOUS_TRANSACTION;
2531
2532 l_req_dets csr_request_dets%ROWTYPE;
2533
2534 l_proc_name VARCHAR2(61):= 'reset_proc_status';
2535
2536 BEGIN
2537
2538 debug_enter(l_proc_name);
2539
2540 -- Reset the processing status to U in the multiproc data table
2541 -- if the Extract Process is running on its own
2542
2543 -- Bugfix 3671727:ENH2
2544 -- Commenting out the cursor call coz the parent
2545 -- request id is not being set in a global in
2546 -- Type 4 code coz its needed to get the master
2547 -- rec from pqp_ext_cross_person_records
2548 /* OPEN csr_request_dets;
2549 FETCH csr_request_dets INTO l_req_dets;
2550 CLOSE csr_request_dets;
2551 */
2552
2553 IF pqp_gb_tp_pension_extracts.g_parent_request_id = -1 THEN
2554
2555 debug(l_proc_name, 20);
2556 UPDATE pqp_ext_cross_person_records
2557 SET processing_status = 'U'
2558 ,request_id = fnd_global.conc_request_id
2559 ,last_updated_by = fnd_global.user_id
2560 ,last_update_date = SYSDATE
2561 ,last_update_login = fnd_global.login_id
2562 ,object_version_number = (object_version_number + 1)
2563 WHERE record_type = 'X'
2564 AND ext_dfn_id = ben_ext_thread.g_ext_dfn_id --ENH2
2565 AND lea_number = g_lea_number; --ENH1
2566
2567 END IF;
2568
2569 COMMIT;
2570
2571 debug_exit(l_proc_name);
2572 EXCEPTION
2573 WHEN OTHERS THEN
2574 debug_exit(' Others in '||l_proc_name);
2575 RAISE;
2576 END reset_proc_status;
2577
2578 --
2579 -- set_t1_extract_globals
2580 --
2581 PROCEDURE set_t1_extract_globals
2582 (p_business_group_id IN NUMBER
2583 ,p_effective_date IN DATE
2584 ,p_assignment_id IN NUMBER
2585 )
2586 IS
2587
2588 l_proc_name VARCHAR2(61):= 'set_t1_extract_globals';
2589
2590 -- 4336613 : PROSWITCH_3A :
2591 -- temporary variables to store value fetched from UDT
2592 l_calc_sal_new VARCHAR2(100);
2593 l_calendar_avg VARCHAR2(100);
2594 l_date_work_mode VARCHAR2(100); -- rahul supply
2595
2596 l_error NUMBER;
2597
2598
2599 BEGIN
2600 debug_enter(l_proc_name);
2601
2602 -- Set the globals in this package
2603 g_business_group_id := p_business_group_id;
2604 debug(p_effective_date);
2605 g_effective_date := p_effective_date;
2606
2607 -- Call the Type 4 function to set globals in Type 4 package
2608 pqp_gb_tp_pension_extracts.g_nested_level := g_nested_level;
2609 pqp_gb_tp_pension_extracts.set_extract_globals
2610 (p_business_group_id
2611 ,p_effective_date
2612 ,p_assignment_id
2613 );
2614 pqp_gb_tp_pension_extracts.g_nested_level := 0;
2615
2616 -- Set the globals in this package before exiting this function
2617 -- ********* Variables ***************
2618 g_extract_type := pqp_gb_tp_pension_extracts.g_extract_type;
2619 g_extract_udt_name := pqp_gb_tp_pension_extracts.g_extract_udt_name;
2620 g_criteria_location_code := pqp_gb_tp_pension_extracts.g_criteria_location_code;
2621 g_lea_number := pqp_gb_tp_pension_extracts.g_lea_number;
2622 g_crossbg_enabled := pqp_gb_tp_pension_extracts.g_crossbg_enabled;
2623 g_estb_number := pqp_gb_tp_pension_extracts.g_estb_number;
2624 g_originators_title := pqp_gb_tp_pension_extracts.g_originators_title;
2625 g_header_system_element := pqp_gb_tp_pension_extracts.g_header_system_element;
2626
2627 /************ Collections ***********
2628 Sh we duplicate or just use the one in Type 4??
2629 Current thought is reuse from Type 4
2630
2631 g_criteria_estbs
2632 */
2633 --ENH1:The store_cross_bg details is being called by set_extract_globals
2634 --from type4.
2635 /*
2636 -- Bugfix 3073562:GAP1:GAP2
2637 -- If its the LEA run
2638 -- AND current BG is enabled for cross BG reporting
2639 IF g_estb_number = '0000'
2640 AND
2641 g_crossbg_enabled = 'Y'
2642 THEN
2643 -- Store all BGs with same LEA Number and
2644 -- enabled for cross BG reporting
2645 store_cross_bg_details;
2646 ELSE -- Non-LEA Run
2647 g_master_bg_id := g_business_group_id;
2648 END IF;
2649 */
2650 g_tab_lon_aln_eles.DELETE;
2651 g_tab_spl_aln_eles.DELETE;
2652
2653 g_spl_all_grd_src := 'N';
2654 g_lon_all_grd_src := 'N';
2655
2656 -- Get UDT Data
2657 get_udt_data (p_udt_name => 'PQP_GB_TP_TYPE1_EXTRACT_DEFINITIONS'
2658 ,p_effective_date => p_effective_date
2659 );
2660
2661 -- Get Element information from UDT
2662 --get_elements_frm_udt (p_assignment_id => p_assignment_id);
2663
2664 -- Get Rate Type Name from UDT
2665 get_rate_type_from_udt (p_assignment_id => p_assignment_id);
2666
2667 -- changed for 5743209
2668 fetch_allow_eles_frm_udt (p_assignment_id => p_assignment_id
2669 ,p_effective_date => p_effective_date
2670 );
2671 --CALC_PT_SAL_OPTIONS : BUG: 4135481
2672 -- Two new rows are now seeded in the UDT for the role of switches
2673 -- 1. "Part Time Salary Paid - Enable Date Earned Mode"
2674 -- 2. "Part Time Salary Paid - Enable Calendar Day Proration"
2675 -- First switch is for enabling / disabling the new logic for calculating part
2676 -- time salary (based on date earned) or revert back to previous logic (date paid).
2677 -- The second switch is for enabling / disabling calendar averaging, in case NO
2678 -- matching proration events are found.
2679
2680 l_calc_sal_new := Get_Udt_Value (p_column_name => 'Attribute Location Qualifier 1'
2681 ,p_row_name => 'Part Time Salary Paid - Enable Date Earned Mode'
2682 );
2683
2684 debug('l_calc_sal_new: ' || l_calc_sal_new,10);
2685
2686 l_calendar_avg := Get_Udt_Value (p_column_name => 'Attribute Location Qualifier 1'
2687 ,p_row_name => 'Part Time Salary Paid - Enable Calendar Day Proration'
2688 );
2689
2690 debug('l_calendar_avg: ' || l_calendar_avg,20);
2691
2692
2693 --CALC_PT_SAL_OPTIONS :
2694 -- One new row is now seeded in the UDT for the role of switch
2695 -- 3. "Date Worked Payment Mode"
2696 -- The third switch is for enabling / disabling the new logic for calculating part time salary
2697 -- only for supply teachers (based on date worked) or revert back to previous logic (date earned or date paid).
2698 l_date_work_mode := Get_Udt_Value (p_column_name => 'Attribute Location Qualifier 1' -- rahul supply
2699 ,p_row_name => 'Date Worked Payment Mode'
2700 );
2701
2702 debug('l_date_work_mode: ' || l_date_work_mode,21); -- rahul supply
2703
2704
2705
2706 -- The following globals will be used to provide additional options for part
2707 -- time salary computation methods in calc_part_time_sal function
2708
2709 -- If Switch1 is not set and Switch2 is not set, then Switch1=Switch2 = 'Y'.
2710 -- If Switch1 is set and Switch2 is not set, then Switch2 = Switch1.
2711 -- If Switch1 is not set and Switch2 is set, then Switch1 = 'Y' and
2712 -- Switch2 is whatever it is set to.
2713
2714 -- switch 1
2715 l_calc_sal_new := nvl(l_calc_sal_new, 'Y'); -- use old/new method
2716
2717
2718 -- 4336613 : PROSWITCH_3A :
2719 -- raise an error if the value of g_calc_sal_new switch in UDT is not
2720 -- among 'Y', 'YES', 'N', or 'NO' (i.e. is an invalid value)
2721
2722 IF( UPPER(l_calc_sal_new) NOT IN ('Y', 'YES', 'N', 'NO')
2723 ) THEN
2724
2725 debug('--- Raise error : invalid switch values in UDT ---',25);
2726
2727 -- new error message for invalid values in UDT
2728 l_error := pqp_gb_tp_extract_functions.raise_extract_error
2729 (p_business_group_id => g_business_group_id
2730 ,p_assignment_id => p_assignment_id
2731 ,p_error_text => 'BEN_94231_TP1_INVALID_UDT_VAL'
2732 ,p_error_number => 94231
2733 ,p_token1 => 'Part Time Salary Paid - Enable Date Earned Mode'
2734 );
2735
2736 ELSIF((UPPER(l_calc_sal_new) = 'Y')
2737 OR
2738 (UPPER(l_calc_sal_new) = 'YES')
2739 )THEN
2740 l_calc_sal_new := 'Y';
2741 ELSE
2742 l_calc_sal_new := 'N';
2743
2744 END IF;
2745
2746 -- setting the validated value to global
2747 g_calc_sal_new := l_calc_sal_new;
2748
2749
2750
2751 -- setting globals after checking validity of values of g_calc_sal_new
2752 g_proration := g_calc_sal_new; -- set this to Y if new method is to be used
2753
2754 -- switch 2
2755 l_calendar_avg := nvl(l_calendar_avg, g_proration) ;
2756
2757
2758 -- 4336613 : PROSWITCH_3A :
2759 -- raise an error if the value of g_calendar_avg switch in UDT is not
2760 -- among 'Y', 'YES', 'N', or 'NO' (i.e. is an invalid value)
2761
2762 IF( UPPER(l_calendar_avg) NOT IN ('Y', 'YES', 'N', 'NO')
2763 ) THEN
2764
2765 debug('--- Raise error : invalid switch values in UDT ---',25);
2766
2767 -- new error message for invalid values in UDT
2768 l_error := pqp_gb_tp_extract_functions.raise_extract_error
2769 (p_business_group_id => g_business_group_id
2770 ,p_assignment_id => p_assignment_id
2771 ,p_error_text => 'BEN_94231_TP1_INVALID_UDT_VAL'
2772 ,p_error_number => 94231
2773 ,p_token1 => 'Part Time Salary Paid - Enable Calendar Day Proration'
2774 );
2775
2776 ELSIF((UPPER(l_calendar_avg) = 'Y')
2777 OR
2778 (UPPER(l_calendar_avg) = 'YES')
2779 )THEN
2780 l_calendar_avg := 'Y';
2781 ELSE
2782 l_calendar_avg := 'N';
2783
2784 END IF;
2785
2786 -- setting validated value to global
2787 g_calendar_avg := l_calendar_avg;
2788
2789 -- Switch 3
2790
2791 l_date_work_mode := nvl(l_date_work_mode,'N'); -- rahul supply
2792
2793 IF( UPPER(l_date_work_mode) NOT IN ('Y', 'YES', 'N', 'NO') -- rahul supply
2794 ) THEN
2795
2796 debug('--- Raise error : invalid switch values in UDT ---',25);
2797
2798 -- new error message for invalid values in UDT
2799 l_error := pqp_gb_tp_extract_functions.raise_extract_error
2800 (p_business_group_id => g_business_group_id
2801 ,p_assignment_id => p_assignment_id
2802 ,p_error_text => 'BEN_94231_TP1_INVALID_UDT_VAL'
2803 ,p_error_number => 94231
2804 ,p_token1 => 'Date Worked Payment Mode'
2805 );
2806
2807 ELSIF((UPPER(l_date_work_mode) = 'Y')
2808 OR
2809 (UPPER(l_date_work_mode) = 'YES')
2810 )THEN
2811 l_date_work_mode := 'Y';
2812 ELSE
2813 l_date_work_mode := 'N';
2814
2815 END IF;
2816
2817 -- Setting the validated value to global
2818 g_date_work_mode := l_date_work_mode; -- rahul supply
2819
2820 debug('g_calc_sal_new: ' || g_calc_sal_new,30);
2821 debug('g_proration: ' || g_proration,40);
2822 debug('g_calendar_avg: ' || g_calendar_avg,50);
2823 debug('g_date_work_mode: ' || g_date_work_mode,55);
2824
2825
2826
2827 -- Get the record id for the Type 1 Detail record
2828 OPEN csr_ext_rcd_id(p_hide_flag => 'N'
2829 ,p_rcd_type_cd => 'D'
2830 );
2831 FETCH csr_ext_rcd_id INTO g_ext_dtl_rcd_id;
2832 -- Do we need to raise an error if there are 2 diplayed detail records??
2833 -- If yes, then Fetch ... , check .. and raise error
2834 -- Alternatively, modify the cursor to return the required id by querying on name.
2835 CLOSE csr_ext_rcd_id;
2836
2837 --ENH1:The reset_proc_status details is being called by set_extract_globals
2838 --from type4.
2839 -- Reset the processing status in multiproc data table to U
2840 -- reset_proc_status;
2841
2842 debug_exit(l_proc_name);
2843 EXCEPTION
2844 WHEN OTHERS THEN
2845 debug_exit(' Others in '||l_proc_name);
2846 RAISE;
2847 END set_t1_extract_globals;
2848
2849 --
2850 -- set_periodic_run_dates
2851 --
2852 PROCEDURE set_periodic_run_dates
2853 IS
2854
2855 l_proc_name VARCHAR2(61):= 'set_periodic_run_dates';
2856
2857 BEGIN
2858
2859 debug_enter(l_proc_name);
2860
2861 -- Call the Type 4 function to set run dates in Type 4 package
2862 pqp_gb_tp_pension_extracts.g_nested_level := g_nested_level;
2863 pqp_gb_tp_pension_extracts.set_run_effective_dates;
2864 pqp_gb_tp_pension_extracts.g_nested_level := 0;
2865
2866 -- Set the globals in this package before exiting this function
2867 -- ********* Variables ****************
2868 g_last_effective_date := pqp_gb_tp_pension_extracts.g_last_effective_date;
2869 g_next_effective_date := pqp_gb_tp_pension_extracts.g_next_effective_date;
2870 g_effective_run_date := pqp_gb_tp_pension_extracts.g_effective_run_date;
2871
2872 -- For the sake of periodic report only
2873 -- pension year end date is being set as the run end date.
2874 g_pension_year_end_date := g_effective_run_date;
2875
2876 -- Changed by Raju T. on 08/05/2002 as a development bugfix
2877 -- Commented out as this is now being created differently for Type 1
2878 -- g_header_system_element := pqp_gb_tp_pension_extracts.g_header_system_element;
2879
2880 -- Set the start date of the pension year, i.e. 01-04-YYYY
2881 SELECT TO_DATE('01-04-'||
2882 DECODE
2883 (SIGN(TO_NUMBER(TO_CHAR(g_effective_run_date,'MM')) - 04)
2884 ,-1,TO_CHAR(ADD_MONTHS(g_effective_run_date,-12),'YYYY')
2885 ,TO_CHAR(g_effective_run_date,'YYYY'))
2886 ,'DD-MM-YYYY')
2887 INTO g_pension_year_start_date
2888 FROM DUAL;
2889
2890 -- Changed by Raju T. on 08/05/2002 as a development bugfix
2891 -- The last eff date and header sys element is now being created
2892 -- differently for Type 1 and being overwritten in the Type 4 Pkg
2893 -- Changes START here
2894 g_last_effective_date := GREATEST(g_last_effective_date
2895 ,g_pension_year_start_date
2896 );
2897
2898 IF g_last_effective_date <> pqp_gb_tp_pension_extracts.g_last_effective_date THEN
2899
2900 pqp_gb_tp_pension_extracts.g_last_effective_date := g_last_effective_date;
2901
2902 END IF;
2903
2904 g_header_system_element:=
2905 g_header_system_element||
2906 fnd_date.date_to_canonical(g_last_effective_date)||':'||
2907 fnd_date.date_to_canonical(g_effective_run_date) ||':'||
2908 fnd_date.date_to_canonical(g_next_effective_date)||':';
2909
2910 -- Assign the newly created system element to the type4 global
2911 pqp_gb_tp_pension_extracts.g_header_system_element := g_header_system_element;
2912
2913 debug('New Type 1 Header System Element :'||g_header_system_element);
2914 -- Changes END here
2915
2916 debug_exit(l_proc_name);
2917 EXCEPTION
2918 WHEN OTHERS THEN
2919 debug_exit(' Others in '||l_proc_name);
2920 RAISE;
2921 END set_periodic_run_dates;
2922
2923 --
2924 -- set_annual_run_dates
2925 --
2926 PROCEDURE set_annual_run_dates
2927 IS
2928
2929 l_year NUMBER;
2930 l_proc_name VARCHAR2(61):= 'set_annual_run_dates';
2931
2932 BEGIN
2933
2934 debug_enter(l_proc_name);
2935
2936 debug(TO_CHAR(g_effective_date,'DD-MON-YYYY'));
2937
2938 debug('g_effective_date: '||
2939 fnd_date.date_to_canonical(g_effective_date));
2940
2941 IF to_number(to_char(g_effective_date, 'MM'))
2942 BETWEEN 1 AND 3 THEN
2943
2944 -- Pension year should end YY - 1
2945 l_year := to_number(to_char(g_effective_date, 'YYYY')) - 1;
2946
2947 ELSE
2948
2949 -- Pension year should end YY
2950 l_year := to_number(to_char(g_effective_date, 'YYYY'));
2951
2952 END IF; -- End if of month check...
2953
2954 g_pension_year_start_date := to_date('01/04/'||to_char(l_year), 'DD/MM/YYYY');
2955 g_pension_year_end_date := to_date('31/03/'||to_char(l_year+1)||
2956 '23:59:59', 'DD/MM/YYYY HH24:MI:SS');
2957
2958
2959 g_header_system_element:=
2960 g_header_system_element||
2961 fnd_date.date_to_canonical(g_pension_year_start_date)||':'||
2962 fnd_date.date_to_canonical(g_pension_year_end_date)||':'||
2963 fnd_date.date_to_canonical(g_effective_date)||':';
2964
2965 -- Set the globals in this package
2966 g_last_effective_date := g_pension_year_start_date;
2967 g_next_effective_date := g_effective_date;
2968 g_effective_run_date := g_pension_year_end_date;
2969
2970 -- Now set the Type 4 globals
2971 pqp_gb_tp_pension_extracts.g_last_effective_date := g_last_effective_date;
2972 pqp_gb_tp_pension_extracts.g_next_effective_date := g_next_effective_date;
2973 pqp_gb_tp_pension_extracts.g_effective_run_date := g_effective_run_date;
2974 pqp_gb_tp_pension_extracts.g_header_system_element := g_header_system_element;
2975
2976 debug('Header System Element :'||g_header_system_element);
2977
2978 debug_exit(l_proc_name);
2979 EXCEPTION
2980 WHEN OTHERS THEN
2981 debug_exit(' Others in '||l_proc_name);
2982 RAISE;
2983 END set_annual_run_dates;
2984
2985 --
2986 -- set_pay_proc_events_to_process
2987 --
2988 PROCEDURE set_pay_proc_events_to_process
2989 (p_assignment_id IN NUMBER
2990 ,p_status IN VARCHAR2
2991 ,p_start_date IN DATE
2992 ,p_end_date IN DATE
2993 )
2994 IS
2995
2996 PRAGMA AUTONOMOUS_TRANSACTION;
2997
2998 l_proc_name VARCHAR2(61):= 'set_pay_proc_events_to_process';
2999
3000 BEGIN
3001 debug_enter(l_proc_name);
3002
3003
3004 debug('p_status: '||p_status);
3005 debug('p_start_date: '||fnd_date.date_to_canonical(p_start_date));
3006 debug('p_end_date: '||fnd_date.date_to_canonical(p_end_date));
3007 --
3008 -- Mark pay_process_events to process
3009 -- as determined by the date range. The maxmum allowed range
3010 -- is the pension year start date and a day before the current eff date
3011
3012 UPDATE pay_process_events
3013 SET retroactive_status = p_status
3014 ,status = p_status
3015 WHERE assignment_id = p_assignment_id
3016 AND change_type = 'REPORTS'
3017 AND effective_date -- allow all events effective as of and on pension year start date
3018 BETWEEN GREATEST(NVL(p_start_date,g_pension_year_start_date)
3019 ,g_pension_year_start_date)
3020 AND LEAST(NVL(p_end_date,g_effective_run_date)
3021 ,g_effective_run_date)
3022 ; -- allow all events upto end of day (eff_dt - 1)
3023
3024 COMMIT;
3025 --
3026 debug(fnd_number.number_to_canonical(SQL%ROWCOUNT)||' PPE row(s) updated.');
3027 --
3028 debug_exit(l_proc_name);
3029 --
3030 EXCEPTION
3031 WHEN OTHERS THEN
3032 debug_exit(' Others in '||l_proc_name);
3033 RAISE;
3034 END set_pay_proc_events_to_process;
3035
3036 --
3037 -- set_pay_proc_events_to_process
3038 -- Overloaded procedure, this one has an extra parameter p_element_entry_id
3039 --
3040 PROCEDURE set_pay_proc_events_to_process
3041 (p_assignment_id IN NUMBER
3042 ,p_element_entry_id IN NUMBER
3043 ,p_status IN VARCHAR2
3044 ,p_start_date IN DATE
3045 ,p_end_date IN DATE
3046 )
3047 IS
3048
3049 PRAGMA AUTONOMOUS_TRANSACTION;
3050
3051 l_proc_name VARCHAR2(61):= 'set_pay_proc_events_to_process';
3052
3053 BEGIN
3054 debug_enter(l_proc_name);
3055
3056
3057 debug('p_status: '||p_status);
3058 debug('p_start_date: '||fnd_date.date_to_canonical(p_start_date));
3059 debug('p_end_date: '||fnd_date.date_to_canonical(p_end_date));
3060
3061 --
3062 -- Mark pay_process_events to process
3063 -- as determined by the date range. The maxmum allowed range
3064 -- is the pension year start date and a day before the current eff date
3065
3066 -- First update for PAY_ELEMENT_ENTRIES_F
3067 UPDATE pay_process_events ppe
3068 SET ppe.retroactive_status = p_status
3069 ,ppe.status = p_status
3070 WHERE ppe.assignment_id = p_assignment_id
3071 AND ppe.change_type = 'REPORTS'
3072 AND ppe.effective_date -- allow all events effective as of and on pension year start date
3073 BETWEEN GREATEST(NVL(p_start_date,g_pension_year_start_date)
3074 ,g_pension_year_start_date)
3075 AND LEAST(NVL(p_end_date,g_effective_run_date)
3076 ,g_effective_run_date)
3077 AND ppe.surrogate_key = p_element_entry_id
3078 AND EXISTS (SELECT 1
3079 FROM pay_dated_tables pdt
3080 ,pay_event_updates peu
3081 WHERE pdt.table_name = 'PAY_ELEMENT_ENTRIES_F'
3082 AND peu.dated_table_id = pdt.dated_table_id
3083 AND peu.change_type = ppe.change_type
3084 AND peu.event_update_id = ppe.event_update_id
3085 )
3086 ;
3087
3088 debug(fnd_number.number_to_canonical(SQL%ROWCOUNT)||' PPE row(s) updated.');
3089
3090 -- Now update for PAY_ELEMENT_ENTRY_VALUES_F
3091 UPDATE pay_process_events ppe
3092 SET ppe.retroactive_status = p_status
3093 ,ppe.status = p_status
3094 WHERE ppe.assignment_id = p_assignment_id
3095 AND ppe.change_type = 'REPORTS'
3096 AND ppe.effective_date -- allow all events effective as of and on pension year start date
3097 BETWEEN GREATEST(NVL(p_start_date,g_pension_year_start_date)
3098 ,g_pension_year_start_date)
3099 AND LEAST(NVL(p_end_date,g_effective_run_date)
3100 ,g_effective_run_date)
3101 AND EXISTS (SELECT 1
3102 FROM pay_dated_tables pdt
3103 ,pay_event_updates peu
3104 WHERE pdt.table_name = 'PAY_ELEMENT_ENTRY_VALUES_F'
3105 AND peu.dated_table_id = pdt.dated_table_id
3106 AND peu.change_type = ppe.change_type
3107 AND peu.event_update_id = ppe.event_update_id
3108 )
3109 AND EXISTS (SELECT 1
3110 FROM pay_element_entry_values_f peev
3111 WHERE peev.element_entry_id = p_element_entry_id
3112 AND peev.element_entry_value_id = ppe.surrogate_key
3113 )
3114 ;
3115
3116
3117 COMMIT;
3118 --
3119 debug(fnd_number.number_to_canonical(SQL%ROWCOUNT)||' PPE row(s) updated.');
3120 --
3121 debug_exit(l_proc_name);
3122 --
3123 EXCEPTION
3124 WHEN OTHERS THEN
3125 debug_exit(' Others in '||l_proc_name);
3126 RAISE;
3127 END set_pay_proc_events_to_process;
3128
3129 --
3130 -- get_events
3131 --
3132 -- Generic function to return events found by the date track
3133 -- interpreter for the given event group and assignment id
3134 --
3135 -- Bug 3015917 : Added params p_start_date and p_end_date
3136 -- Bugfix 3073562:GAP1:GAP2 Added p_business_group_id parameter
3137 -- This param needs to be passed only when the get_events proc
3138 -- is called during the criteria chk process as the asg
3139 -- collection will not hv a row for this asg id at this point.
3140 -- For all other calls, the proc will find the bg id from
3141 -- the global asg collection.
3142 FUNCTION get_events(p_event_group IN VARCHAR2
3143 ,p_assignment_id IN NUMBER
3144 ,p_element_entry_id IN NUMBER -- DEFAULT NULL
3145 ,p_business_group_id IN NUMBER -- DEFAULT NULL
3146 ,p_start_date IN DATE
3147 ,p_end_date IN DATE
3148 ,t_proration_dates OUT NOCOPY pay_interpreter_pkg.t_proration_dates_table_type
3149 ,t_proration_changes OUT NOCOPY pay_interpreter_pkg.t_proration_type_table_type
3150 ) RETURN NUMBER
3151 IS
3152
3153 -- Variable Declaration
3154 l_no_of_events NUMBER;
3155
3156 -- Rowtype Variable Declaration
3157 l_event_group_details pqp_gb_tp_pension_extracts.csr_event_group_details%ROWTYPE;
3158 l_business_group_id per_all_assignments_f.business_group_id%TYPE;
3159 l_assignment_action_id number;
3160 l_proc_name VARCHAR2(61):=
3161 g_proc_name||'get_events';
3162
3163 -- Added to pass assignment action ID for event PQP_GB_TP_GRADE_RULES(5547471)
3164 CURSOR c_get_aact(p_assignment_id NUMBER) IS
3165 SELECT assignment_action_id
3166 FROM pay_assignment_actions
3167 WHERE assignment_id = p_assignment_id
3168 AND rownum = 1;
3169
3170 BEGIN
3171
3172 debug_enter(l_proc_name);
3173
3174 -- Bugfix 3073562:GAP1:GAP2
3175 IF p_business_group_id IS NULL THEN
3176
3177 -- If the asg is present in the global collections
3178 -- then get the bg id from there
3179 -- otherwise use g_business_groupd_id
3180 IF g_ext_asg_details.EXISTS(p_assignment_id) THEN
3181
3182 -- Doing NVL for no reason, just being over cautios...
3183 l_business_group_id :=
3184 NVL(g_ext_asg_details(p_assignment_id).business_group_id
3185 ,g_business_group_id
3186 );
3187 ELSE -- does not exist
3188 l_business_group_id := g_business_group_id;
3189 END IF;
3190
3191 ELSE -- Not null
3192 l_business_group_id := p_business_group_id;
3193 END IF; -- p_business_group_id IS NULL THEN
3194
3195 debug('Business_group_id :'||to_char(l_business_group_id), 10);
3196
3197 -- Now invoke the date track interpreter
3198 -- Bug 3015917 : Replaced old DTI call with this new DTI call
3199 IF p_event_group <> 'PQP_GB_TP_GRADE_RULES' THEN
3200 l_no_of_events := pqp_utilities.get_events
3201 (p_assignment_id => p_assignment_id
3202 ,p_element_entry_id => p_element_entry_id
3203 ,p_business_group_id => l_business_group_id
3204 ,p_process_mode => 'ENTRY_EFFECTIVE_DATE'
3205 ,p_event_group_name => p_event_group
3206 ,p_start_date => p_start_date
3207 ,p_end_date => p_end_date
3208 ,t_proration_dates => t_proration_dates -- OUT
3209 ,t_proration_change_type => t_proration_changes -- OUT
3210 );
3211 ELSE
3212 -- Added to pass assignment action ID for event PQP_GB_TP_GRADE_RULES(5547471)
3213 OPEN c_get_aact(p_assignment_id);
3214 FETCH c_get_aact INTO l_assignment_action_id;
3215 CLOSE c_get_aact;
3216 l_no_of_events := pqp_utilities.get_events
3217 (p_assignment_id => p_assignment_id,
3218 p_assignment_action_id => l_assignment_action_id
3219 ,p_element_entry_id => p_element_entry_id
3220 ,p_business_group_id => l_business_group_id
3221 ,p_process_mode => 'ENTRY_EFFECTIVE_DATE'
3222 ,p_event_group_name => p_event_group
3223 ,p_start_date => p_start_date
3224 ,p_end_date => p_end_date
3225 ,t_proration_dates => t_proration_dates -- OUT
3226 ,t_proration_change_type => t_proration_changes -- OUT
3227 );
3228 END IF;
3229 debug_exit(l_proc_name);
3230
3231 RETURN t_proration_dates.COUNT;
3232
3233 EXCEPTION
3234 WHEN OTHERS THEN
3235 debug_exit(' Others in '||l_proc_name);
3236 t_proration_dates.delete;
3237 t_proration_changes.delete;
3238
3239 RAISE;
3240 END; -- get_events
3241
3242 --
3243 -- Get the per system status from per_assignment_status_types
3244 --
3245 FUNCTION get_status_type
3246 (p_status_type_id IN NUMBER
3247 ) RETURN VARCHAR2
3248 IS
3249
3250 l_proc_name VARCHAR2(61):=
3251 g_proc_name||'get_status_type';
3252
3253 CURSOR csr_status_type IS
3254 SELECT per_system_status
3255 FROM per_assignment_status_types
3256 WHERE assignment_status_type_id = p_status_type_id;
3257
3258 l_per_system_status per_assignment_status_types.per_system_status%TYPE;
3259
3260 BEGIN -- get_status_type
3261
3262 debug_enter(l_proc_name);
3263
3264 OPEN csr_status_type;
3265 FETCH csr_status_type INTO l_per_system_status;
3266 CLOSE csr_status_type ;
3267
3268 debug('l_per_system_status :'||l_per_system_status, 10);
3269 debug_exit(l_proc_name);
3270
3271 RETURN l_per_system_status;
3272
3273 EXCEPTION
3274 WHEN OTHERS THEN
3275 debug_exit(' Others in '||l_proc_name);
3276 RAISE;
3277 END; -- get_status_type
3278
3279 --
3280 -- Check if the assignment satisfies the basic criteria
3281 --
3282 FUNCTION chk_has_tchr_elected_pension
3283 (p_business_group_id IN NUMBER -- context
3284 ,p_effective_date IN DATE -- context
3285 ,p_assignment_id IN NUMBER -- context
3286 ,p_asg_details OUT NOCOPY csr_asg_details_up%ROWTYPE
3287 ,p_asg_attributes OUT NOCOPY csr_pqp_asg_attributes_up%ROWTYPE
3288 ) RETURN VARCHAR2 -- Y or N
3289 IS
3290
3291 -- Variable Declaration
3292 l_pension_start_date DATE := NULL;
3293
3294 -- Rowtype Variable Declaration
3295 l_asg_details csr_asg_details_up%ROWTYPE;
3296 l_pqp_asg_attributes csr_pqp_asg_attributes_up%ROWTYPE;
3297
3298 -- Flag variable declaration
3299 l_inclusion_flag VARCHAR2(1) := 'Y'; -- Include all Teachers
3300 l_quit_asg_loop BOOLEAN := FALSE;
3301
3302 l_proc_name VARCHAR2(61):=
3303 g_proc_name||'chk_has_tchr_elected_pension';
3304
3305 BEGIN -- chk_has_tchr_elected_pension
3306
3307 debug_enter(l_proc_name);
3308
3309 OPEN csr_pqp_asg_attributes_up
3310 (p_assignment_id
3311 ,p_effective_date
3312 );
3313 LOOP -- Find the first effective assignment attributes in the run date range.
3314
3315 FETCH csr_pqp_asg_attributes_up INTO l_pqp_asg_attributes;
3316
3317 debug('Inside AAT LOOP ',20);
3318
3319 IF csr_pqp_asg_attributes_up%NOTFOUND THEN
3320 -- aat not found, hence this assignment does not qualify
3321
3322 l_inclusion_flag := 'N';
3323 debug('AAT Data not found',30);
3324
3325 ELSIF (l_pqp_asg_attributes.effective_start_date <= g_effective_run_date
3326 )
3327 AND
3328 (nvl(l_pqp_asg_attributes.tp_is_teacher,'NONT')
3329 IN ('TCHR','TTR6')
3330 ) THEN
3331 -- Only interested in teacher aat recs effective in the run date range.
3332
3333 -- Get assignment details
3334 OPEN csr_asg_details_up
3335 (p_assignment_id
3336 ,GREATEST(l_pqp_asg_attributes.effective_start_date
3337 ,p_effective_date)
3338 );
3339
3340 l_quit_asg_loop := FALSE;
3341
3342 LOOP -- Through assignment records to check if there is an assignment
3343 -- record with a valid criteria establishment
3344 -- But make sure that the check is only for the run date range.
3345
3346 debug('Inside ASG LOOP ',40);
3347
3348 FETCH csr_asg_details_up INTO l_asg_details;
3349
3350 IF csr_asg_details_up%NOTFOUND THEN
3351
3352 l_quit_asg_loop := TRUE;
3353 debug('ASG Data not found',50);
3354
3355 ELSE -- asg record FOUND
3356
3357 -- Bugfix 3073562:GAP1:GAP2
3358 -- Replacing the type4 func call with the type 1 function
3359 l_asg_details.ext_emp_cat_cd :=
3360 get_translate_asg_emp_cat_code
3361 (l_asg_details.asg_emp_cat_cd
3362 ,GREATEST(l_pqp_asg_attributes.effective_start_date
3363 ,p_effective_date)
3364 ,'Pension Extracts Employment Category Code'
3365 ,l_asg_details.business_group_id
3366 );
3367
3368 -- Bugfix 3873376:SUSP : Suspended assignments fix
3369 -- We need to ignore suspended asgs to fix a bug where
3370 -- assignments suspended in the previous pension year
3371 -- are being picked up and reported
3372 l_asg_details.status_type := get_status_type(l_asg_details.status_type_id);
3373
3374 -- If the establishment is NOT part of the criteria establishment(s)
3375 -- which we are reporting for, check the next record
3376 -- Also, if the start date is outside our date range, not look at this record.
3377 IF l_asg_details.start_date <= g_effective_run_date
3378 AND
3379 pqp_gb_tp_pension_extracts.g_criteria_estbs.EXISTS(l_asg_details.location_id)
3380 AND -- Bugfix 3873376:SUSP Ignore suspended assignments
3381 l_asg_details.status_type <> 'SUSP_ASSIGN'
3382 AND -- Bugfix 4336613 :IGNR_TERMASG_3A Ignore terminated assignments
3383 l_asg_details.status_type <> 'TERM_ASSIGN' THEN
3384
3385 IF nvl(l_pqp_asg_attributes.tp_elected_pension,'X') = 'Y' THEN
3386
3387 -- Do not exlude this assignment, get his pension start date.
3388 l_pension_start_date := GREATEST(l_pqp_asg_attributes.effective_start_date
3389 ,p_effective_date
3390 ,l_asg_details.start_date
3391 );
3392 debug('Teacher has Elected Pension',60);
3393 -- Teacher has elected pension,
3394 -- No need to check further assignments, set flag to quit the loop
3395 l_quit_asg_loop := TRUE;
3396
3397 ELSIF nvl(l_pqp_asg_attributes.tp_elected_pension,'X') = 'N' THEN
3398
3399 debug('Teacher has not Elected Pension',70);
3400 -- As this teacher has not elected pension, we need to
3401 -- do further checks before deciding on this assignment.
3402
3403 -- If this estb is part of the criteria establishment(s)
3404 -- Then Exclude this assignment only if
3405 -- 1) This assignment belongs to a Relief Teacher and Estb Type is Voluntary.
3406 -- 2) This is a part-time assignment
3407 -- 3) This is a full-time assignment and Estb Type is Voluntary.
3408 -- Include otherwise
3409
3410 IF NOT
3411 (-- To be excluded
3412 pqp_gb_tp_pension_extracts.g_criteria_estbs(l_asg_details.location_id).estb_number
3413 = '0966'
3414 OR
3415 (l_asg_details.ext_emp_cat_cd = 'P'
3416 -- Bugfix 3641851:ENH7 : Added this AND clause to INCLUDE
3417 -- part-time asgs at LEA establishment only
3418 AND
3419 pqp_gb_tp_pension_extracts.g_criteria_estbs(l_asg_details.location_id).estb_type
3420 <> 'LEA_ESTB'
3421 )
3422 OR
3423 (l_asg_details.ext_emp_cat_cd = 'F'
3424 AND
3425 pqp_gb_tp_pension_extracts.g_criteria_estbs(l_asg_details.location_id).estb_type
3426 = 'IND_ESTB'
3427 )
3428 ) THEN
3429
3430 -- Do not exluce this assignment, get his pension start date.
3431 l_pension_start_date := GREATEST(l_pqp_asg_attributes.effective_start_date
3432 ,p_effective_date
3433 ,l_asg_details.start_date
3434 );
3435
3436 debug('Teacher has not Elected Pension, but passes validation',80);
3437 -- Teacher has elected pension, but passes other validation
3438 -- No need to check further assignments, set flag to quit the loop
3439 l_quit_asg_loop := TRUE;
3440
3441 END IF; -- NOT...
3442 --
3443 ELSIF l_pqp_asg_attributes.tp_elected_pension IS NULL THEN
3444
3445 -- Check the next aat record, might be a valid one
3446 -- But first, exit the asg loop
3447 l_quit_asg_loop := TRUE;
3448 debug('Elected pension flag is NULL for this teacher',90);
3449
3450 END IF; -- nvl(l_pqp_asg_attributes.tp_elected_pension,'N') = 'N' THEN
3451 --
3452 END IF; -- l_asg_details.start_date <= g_effective_run_date
3453 --
3454 END IF; -- csr_asg_details_up%NOTFOUND THEN
3455 --
3456 IF l_quit_asg_loop THEN
3457
3458 debug('Quitting ASG Loop',100);
3459 EXIT;
3460
3461 END IF;
3462 --
3463 END LOOP; -- Through assignment records to check if there is an assignment
3464
3465 CLOSE csr_asg_details_up;
3466 debug('Pension Start Date :'||to_char(l_pension_start_date,'DD/MM/YYYY'),110);
3467
3468 --ELSE -- csr_pqp_asg_attributes%NOTFOUND THEN
3469 --
3470 -- -- Either the aat record is with a start date higher than the date range
3471 -- -- or not a teaching record.
3472 -- -- We are not interested in this record
3473 -- -- Look at further records
3474
3475 END IF; -- csr_pqp_asg_attributes%NOTFOUND THEN
3476
3477 -- We do not need to look at the next record if this aat record qualifies.
3478 IF (l_pension_start_date is not null
3479 AND
3480 l_inclusion_flag = 'Y'
3481 )
3482 OR
3483 l_inclusion_flag = 'N'
3484 THEN
3485
3486 -- Assign the pension start date to start date in asg record variable
3487 -- PS : If the original assignment start date is needed elsewhere, we might
3488 -- need to create a new column in the assignment or aat collection
3489 -- to hold the pension start date of the assignment.
3490 l_asg_details.start_date := l_pension_start_date;
3491 -- Bugfix 3641851:CBF1 : Assigning pension start date to teacher start date
3492 l_asg_details.teacher_start_date := l_pension_start_date;
3493
3494 debug('Quitting AAT LOOP',120);
3495 EXIT;
3496
3497 END IF; -- (l_pension_start_date is not null..
3498
3499 END LOOP; -- Find the first effective assignment attributes in the run date range.
3500
3501 CLOSE csr_pqp_asg_attributes_up;
3502
3503 -- At this point,
3504 -- IF l_pension_start_date is not null and l_inclusion_flag = 'Y' THEN
3505 -- 1) the rowtype variable l_pqp_asg_attributes contains a valid EFFECTIVE aat row
3506 -- 2) the rowtype variable l_asg_details contains a valid EFFECTIVE asg row
3507 -- 3) the variable l_pension_start_date contains the start date which should be on
3508 -- the report. This has already been assigned to start date in l_asg_details.
3509 --
3510 -- These can be be passed back to the calling point
3511 -- Assign the local record variable to the return variables
3512 p_asg_details := l_asg_details;
3513 p_asg_attributes := l_pqp_asg_attributes;
3514
3515 debug('Is this teacher being included by Basic Criteria ? '||l_inclusion_flag,130);
3516
3517 debug_exit(l_proc_name);
3518 RETURN l_inclusion_flag;
3519
3520 EXCEPTION
3521 WHEN OTHERS THEN
3522 debug_exit(' Others in '||l_proc_name);
3523 p_asg_details := NULL;
3524 p_asg_attributes := NULL;
3525 RAISE;
3526 END; -- chk_has_tchr_elected_pension
3527
3528 --
3529 -- Check if the teacher's is a leaver
3530 --
3531 FUNCTION chk_is_teacher_a_leaver
3532 (p_business_group_id IN NUMBER
3533 ,p_effective_start_date IN DATE
3534 ,p_effective_end_date IN DATE
3535 ,p_assignment_id IN NUMBER
3536 ,p_leaver_date OUT NOCOPY DATE
3537 ) RETURN VARCHAR2 -- Y or N
3538 IS
3539
3540 -- Variable Declaration
3541 l_leaver VARCHAR2(1) := 'N';
3542 l_leaver_date DATE;
3543 l_itr NUMBER;
3544 l_no_of_events NUMBER(5);
3545 l_inclusion_flag VARCHAR2(1) := 'Y';
3546 l_new_event_itr NUMBER(5);
3547
3548 -- Rowtype Variable Declaration
3549 l_event_group_details pqp_gb_tp_pension_extracts.csr_event_group_details%ROWTYPE;
3550 l_proration_dates pay_interpreter_pkg.t_proration_dates_table_type;
3551 l_proration_changes pay_interpreter_pkg.t_proration_type_table_type;
3552 l_asg_details csr_asg_details_up%ROWTYPE;
3553 l_prev_asg_details csr_asg_details_up%ROWTYPE;
3554 l_next_asg_details csr_asg_details_up%ROWTYPE;
3555 l_pqp_asg_attributes pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn%ROWTYPE;
3556 l_last_pqp_asg_attributes pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn%ROWTYPE;
3557
3558 l_temp_asg_details csr_asg_details_up%ROWTYPE;
3559 l_temp_aat_details csr_pqp_asg_attributes_up%ROWTYPE;
3560
3561 l_proc_name VARCHAR2(61):=
3562 g_proc_name||'chk_is_teacher_a_leaver';
3563
3564 BEGIN -- chk_is_teacher_a_leaver
3565
3566 debug_enter(l_proc_name);
3567 debug('p_effective_start_date: '||to_char(p_effective_start_date), 1) ;
3568 debug('p_effective_end_date: '||to_char(p_effective_end_date), 1) ;
3569
3570 -- Update the events in pay_process_events to 'P' for "in process".
3571 -- Bug 3015917 : Removed set_pay_process.. as we now use the new style DTI
3572
3573 -- Check for following leaver events here :
3574 -- Even if a leaver event is found, continue looking for more leaver evnts
3575 -- as we want the EARLIEST date of any of the leaver events
3576 -- 1) Assignment Status change
3577 -- 2) Location change resulting in change in Establishment from
3578 -- a) LEA estb to Non-LEA estb
3579 -- b) Non-LEA estb to LEA estb
3580 -- c) Non-LEA estb to Non-LEA estb
3581 -- 3) Change in Elected pension flag resulting in the flag changing from 'Y' to 'N'
3582 -- 4) Change in Teacher Status such that the status changes from
3583 -- 'TCHR'/'TTR6' to 'NONT' / 'NULL'.(PS : NULL sh not be possible)
3584
3585 -- 1) Assignment Status change
3586
3587 -- Now invoke the date track interpreter
3588 -- Bug 3015917 : Replaced old DTI call with new style DTI call
3589 l_no_of_events := get_events(p_event_group => 'PQP_GB_TP_ASG_STATUS'
3590 ,p_assignment_id => p_assignment_id
3591 ,p_business_group_id => p_business_group_id
3592 ,p_start_date => p_effective_start_date
3593 ,p_end_date => p_effective_end_date
3594 ,t_proration_dates => l_proration_dates -- OUT
3595 ,t_proration_changes => l_proration_changes -- OUT
3596 );
3597
3598 debug('Number of ASG_STATUS Events: '||
3599 fnd_number.number_to_canonical(l_no_of_events));
3600
3601 l_itr := l_proration_dates.FIRST;
3602
3603 WHILE l_itr <= l_proration_dates.LAST
3604 LOOP -- through the dates when some status change event happened
3605
3606 debug('Inside ASG Dates LOOP',20);
3607 --
3608 -- eliminate duplicate dates
3609 -- compare the last value to the current one
3610 -- always process the first date
3611 IF l_itr = l_proration_dates.FIRST
3612 OR
3613 ( l_proration_dates(l_itr) <>
3614 l_proration_dates(l_proration_dates.PRIOR(l_itr))
3615 ) THEN
3616
3617 debug('Event date :'||to_char(l_proration_dates(l_itr),'DD/MM/YYYY'), 25);
3618 debug('Update Type :'||l_proration_changes(l_itr), 26);
3619 debug('l_proration_dates(l_itr) - 1 :' ||to_char(l_proration_dates(l_itr) - 1),27);
3620
3621
3622 -- IMP : Changing to date - 1 as part of bugfix for end employment not begin picked up
3623 OPEN csr_asg_details_up
3624 (p_assignment_id
3625 ,l_proration_dates(l_itr) - 1
3626 );
3627 FETCH csr_asg_details_up INTO l_asg_details;
3628
3629 IF csr_asg_details_up%FOUND THEN
3630
3631 debug('Inside IF , found ASG record',30);
3632 -- Get the per_system_status for the assignment_status_type_id
3633 l_asg_details.status_type := get_status_type(l_asg_details.status_type_id);
3634
3635 -- Get the next assignment and compare status type
3636 FETCH csr_asg_details_up INTO l_next_asg_details;
3637 l_next_asg_details.status_type := get_status_type(l_next_asg_details.status_type_id);
3638
3639 debug('After second fetch',40);
3640 IF (csr_asg_details_up%FOUND
3641 AND
3642 l_asg_details.status_type <> l_next_asg_details.status_type
3643 AND
3644 l_next_asg_details.status_type IN ('TERM_ASSIGN','SUSP_ASSIGN','END')
3645 -- LVRDATE changes
3646 -- checking the assignment start date
3647 -- it should start on or before the period end date.
3648 AND
3649 l_next_asg_details.start_date <= p_effective_end_date
3650 )
3651 OR
3652 -- No future rows found
3653 (csr_asg_details_up%NOTFOUND
3654 AND
3655 -- But the current assignment has been suspended or is Active
3656 -- Added Active as a bugfix as END Employment does not change status
3657 -- when the termination happens on the last day of the payroll period
3658 l_asg_details.status_type IN ('SUSP_ASSIGN','ACTIVE_ASSIGN')
3659 -- Bugfix 3641851:CBF2 : Added this AND Clause
3660 -- We need to ensure that end date of asg record is <= end
3661 -- date of the period v r chking for. Ideally, DTI should
3662 -- not return a date if its outside our range, but a
3663 -- (potential) bug in DTI is causing such a situation and
3664 -- this check is a safety net, just in case.
3665 AND
3666 l_asg_details.effective_end_date <= p_effective_end_date
3667 )
3668 THEN
3669
3670 -- Assignment has been terminated/suspended/ended
3671 l_leaver := 'Y';
3672 l_leaver_date := l_asg_details.effective_end_date;
3673
3674 debug('Assignment is a leaver, Quitting LOOP ',50);
3675
3676 --TERM_LSP: BUG: 4135481
3677 -- Store the assignement status change event as a new line of service event
3678
3679 l_new_event_itr := g_asg_events.COUNT+1;
3680 debug('l_new_event_itr = '|| to_char(l_new_event_itr),55);
3681 debug('event_date: '|| to_char(l_proration_dates(l_itr)),56) ;
3682 debug('l_leaver_date: '|| to_char(l_leaver_date),57) ;
3683
3684 g_asg_events(l_new_event_itr).event_date := l_leaver_date;
3685 g_asg_events(l_new_event_itr).event_type := 'PQP_GB_TP_ASG_STATUS';
3686 g_asg_events(l_new_event_itr).assignment_id := p_assignment_id;
3687
3688
3689
3690
3691 CLOSE csr_asg_details_up;
3692 EXIT;
3693 --
3694 END IF; -- l_asg_details.status_type <> l_next_asg_details.status_type...
3695
3696 END IF; -- csr_asg_details_up%FOUND THEN
3697 --
3698 CLOSE csr_asg_details_up;
3699
3700 END IF; -- if this date <> last date, to eliminate duplicates
3701 --
3702 l_itr := l_proration_dates.NEXT(l_itr);
3703 --
3704 END LOOP; -- through the dates when some status change event happened
3705
3706 l_proration_dates.DELETE;
3707 l_proration_changes.DELETE;
3708
3709 l_asg_details := NULL;
3710 l_next_asg_details := NULL;
3711
3712 debug('After Assignment Status Events check - Deleted Proration Dates',60);
3713
3714 -- Check for the next set of events which qualify an assignment as leaver.
3715 -- 2) Location change resulting in change in Establishment
3716 -- a) LEA estb to Non-LEA estb
3717 -- b) Non-LEA estb to LEA estb
3718 -- c) Non-LEA estb to Non-LEA estb
3719 debug('Now Checking for location change',70);
3720
3721 -- Bug 3015917 : Replaced old DTI call with new style DTI call
3722 l_no_of_events := 0;
3723 l_no_of_events := get_events(p_event_group => 'PQP_GB_TP_ASG_LOCATION'
3724 ,p_assignment_id => p_assignment_id
3725 ,p_business_group_id => p_business_group_id
3726 ,p_start_date => p_effective_start_date
3727 ,p_end_date => p_effective_end_date
3728 ,t_proration_dates => l_proration_dates -- OUT
3729 ,t_proration_changes => l_proration_changes -- OUT
3730 );
3731
3732
3733 debug('Number of ASG_LOCATION Events: '||
3734 fnd_number.number_to_canonical(l_no_of_events));
3735
3736 l_itr := l_proration_dates.FIRST;
3737 WHILE l_itr <= l_proration_dates.LAST
3738 LOOP -- through location change proration dates
3739
3740 -- a location change event did take place, correction or update
3741 -- loop thru all the dates
3742 -- and query asg for location value
3743 -- check if location is a criteria location
3744 -- if so flag location changed and store teacher start date
3745 -- and exit else continue
3746
3747 debug('Inside LOC events loop, Location change event found',80);
3748
3749 --
3750 -- eliminate duplicate dates
3751 -- compare the last value to the current one
3752 -- always process the first date
3753 IF l_itr = l_proration_dates.FIRST
3754 OR
3755 ( l_proration_dates(l_itr) <>
3756 l_proration_dates(l_proration_dates.PRIOR(l_itr))
3757 )
3758 -- Bugfix 3470242:BUG3 : Need to make sure that we chk the next
3759 -- event just in case correction was returned b4 update
3760 OR
3761 (l_proration_changes(l_itr) <>
3762 l_proration_changes(l_proration_changes.PRIOR(l_itr))
3763 )
3764 THEN
3765
3766 debug('Event date :'||to_char(l_proration_dates(l_itr),'DD/MM/YYYY'), 85);
3767 debug('Update Type :'||l_proration_changes(l_itr), 86);
3768
3769 OPEN csr_asg_details_dn
3770 (p_assignment_id
3771 ,l_proration_dates(l_itr)
3772 );
3773 FETCH csr_asg_details_dn INTO l_asg_details;
3774
3775 debug('Inside IF, After first fetch',90);
3776
3777 IF (
3778 (csr_asg_details_dn%FOUND
3779 AND
3780 l_proration_changes(l_itr) = 'C' -- Correction
3781 AND -- asg start date > pension start date
3782 -- this is coz we don't want to pick an asg where
3783 -- the pension has started on that day.
3784 -- I.e. The correction sh have happened in the current pension year
3785 (l_asg_details.start_date >
3786 p_effective_start_date
3787 -- g_ext_asg_details(p_assignment_id).start_date
3788 AND -- the start dat eof the asg record is <= effective run date
3789 l_asg_details.start_date <= p_effective_end_date
3790 -- l_asg_details.start_date <= g_effective_run_date
3791 )
3792 )
3793
3794 OR
3795
3796 (csr_asg_details_dn%FOUND
3797 AND
3798 l_proration_changes(l_itr) = 'U' -- Update
3799 )
3800 ) THEN
3801
3802 -- Get the previous assignment record
3803 -- Currently not needed, will uncomment if needed
3804 --FETCH csr_asg_details_dn INTO l_prev_asg_details;
3805
3806 debug('Event worth considering',100);
3807
3808 -- Check if the locaiton change is a valid one to report as leaver
3809 -- The new establishment is not a criteria establishment
3810 IF NOT pqp_gb_tp_pension_extracts.g_criteria_estbs.EXISTS(l_asg_details.location_id) THEN
3811
3812 -- The assignment has had a location change such that it has become a leaver
3813 l_leaver := 'Y';
3814 l_leaver_date := LEAST((l_asg_details.start_date - 1)
3815 ,nvl(l_leaver_date
3816 ,(l_asg_details.start_date - 1)
3817 )
3818 );
3819
3820 debug('Leaver date :'||to_char(l_leaver_date,'DD/MM/YYYY'), 105);
3821 debug('Assignment is a leaver due to location change, Quitting loop',110);
3822
3823 CLOSE csr_asg_details_dn;
3824 EXIT;
3825
3826 ELSE -- Location change is not a leaver event
3827
3828 -- Bugfix 3073562:GAP10
3829 -- But as the location has changed form LEA Estb to
3830 -- another LEA Estb this is a new line of service event,
3831 -- store the event in the global collection.
3832
3833 -- Get the previous assignment record
3834 FETCH csr_asg_details_dn INTO l_prev_asg_details;
3835
3836 debug(l_proc_name, 120);
3837
3838 IF l_proration_changes(l_itr) = 'U' -- Event was an update
3839 AND
3840 -- Prev rec was found. Redundant chk, sh always b found
3841 csr_asg_details_dn%FOUND
3842 AND
3843 -- Bugfix 3641851:CBF4 : Added just to avoid exception
3844 l_prev_asg_details.location_id IS NOT NULL
3845 AND
3846 -- The current and new Establishment nos. are different
3847 -- This chk is to ensure that the current location
3848 -- was not corrected after doing a datetrack update
3849 (-- Bugfix 3641851:CBF4 : Added EXISTS just to avoid exception
3850 pqp_gb_tp_pension_extracts.g_criteria_estbs.EXISTS(l_prev_asg_details.location_id)
3851 AND
3852 pqp_gb_tp_pension_extracts.g_criteria_estbs(l_asg_details.location_id).estb_number
3853 <>
3854 pqp_gb_tp_pension_extracts.g_criteria_estbs(l_prev_asg_details.location_id).estb_number
3855 ) THEN
3856
3857 debug('Location change is a new line of service event, storing', 130);
3858
3859 l_new_event_itr := g_asg_events.COUNT+1;
3860
3861 -- Store the location change event as a new line of service event
3862 g_asg_events(l_new_event_itr).event_date := l_proration_dates(l_itr);
3863 g_asg_events(l_new_event_itr).event_type := 'PQP_GB_TP_ASG_LOCATION';
3864 g_asg_events(l_new_event_itr).assignment_id := p_assignment_id;
3865
3866 -- Bugfix 3470242:BUG1 : Now using new_location_id, estb_number can
3867 -- always be sought using the location id
3868 --g_asg_events(l_new_event_itr).new_estb_number :=
3869 -- pqp_gb_tp_pension_extracts.g_criteria_estbs(l_asg_details.location_id).estb_number;
3870 g_asg_events(l_new_event_itr).new_location_id := l_asg_details.location_id;
3871
3872 debug('New Location Id :'||to_char(l_asg_details.location_id), 135);
3873
3874 END IF; -- l_proration_changes(l_itr) = 'U'
3875 --
3876 END IF; -- Check if the locaiton change is a valid one to report as leaver
3877 --
3878 END IF; -- csr_asg_details_dn%FOUND THEN
3879 --
3880 CLOSE csr_asg_details_dn;
3881 --
3882 END IF; -- if this date <> last date to eliminate duplicates
3883 --
3884 l_itr := l_proration_dates.NEXT(l_itr);
3885
3886 l_asg_details := NULL;
3887 l_prev_asg_details := NULL;
3888 --
3889 END LOOP; -- through location change proration dates
3890
3891 l_proration_dates.DELETE;
3892 l_proration_changes.DELETE;
3893
3894 debug('After Location Change check - Deleted Proration Dates',140);
3895
3896 -- Check for the next set of events which qualify an assignment as leaver.
3897 -- 3) Change in Elected pension flag resulting in the flag changing from 'Y' to 'N'
3898
3899 -- Get the events
3900 l_no_of_events := 0;
3901 l_no_of_events := get_events(p_event_group => 'PQP_GB_TP_ELECTED_PENSION'
3902 ,p_assignment_id => p_assignment_id
3903 ,p_business_group_id => p_business_group_id
3904 ,p_start_date => p_effective_start_date
3905 ,p_end_date => p_effective_end_date
3906 ,t_proration_dates => l_proration_dates -- OUT
3907 ,t_proration_changes => l_proration_changes -- OUT
3908 );
3909
3910 debug('Number of '||'PQP_GB_TP_ELECTED_PENSION'||' Events: '||
3911 fnd_number.number_to_canonical(l_no_of_events), 150);
3912
3913 -- b) Loop through the events and check if any have changed.
3914 l_itr := l_proration_dates.FIRST;
3915 WHILE l_itr <= l_proration_dates.LAST
3916 LOOP -- through change proration dates
3917
3918 IF l_itr = l_proration_dates.FIRST
3919 OR
3920 ( l_proration_dates(l_itr) <>
3921 l_proration_dates(l_proration_dates.PRIOR(l_itr))
3922 ) THEN
3923
3924 debug('Inside IF for Elected pension changes check',160);
3925 debug('Event date :'||to_char(l_proration_dates(l_itr),'DD/MM/YYYY'), 165);
3926 debug('Update Type :'||l_proration_changes(l_itr), 166);
3927
3928 OPEN pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn
3929 (p_assignment_id
3930 ,l_proration_dates(l_itr)
3931 );
3932 FETCH pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn INTO l_pqp_asg_attributes;
3933 --
3934 IF pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn%FOUND
3935 AND
3936 NVL(l_pqp_asg_attributes.tp_elected_pension,'N') = 'N' THEN
3937
3938 -- Fetch the previous set of attributes
3939 FETCH pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn INTO l_last_pqp_asg_attributes;
3940 --
3941 IF pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn%FOUND
3942 AND
3943 nvl(l_last_pqp_asg_attributes.tp_elected_pension,'N') = 'Y' THEN
3944
3945 debug('B4 checking if asg passes chk_has_tchr_elected_pension',170);
3946
3947 -- Pension flag has changed to 'N', but check if this change to 'N'
3948 -- qualifies as leaver event. If the assignment satisfies the
3949 -- chk_has_teacher_elected_pension on this event date
3950 -- then the assignment is not a leaver, else, the assignment is a leaver
3951 l_inclusion_flag := chk_has_tchr_elected_pension
3952 (p_business_group_id => p_business_group_id
3953 ,p_effective_date => l_proration_dates(l_itr)
3954 ,p_assignment_id => p_assignment_id
3955 ,p_asg_details => l_temp_asg_details -- OUT
3956 ,p_asg_attributes => l_temp_aat_details -- OUT
3957 );
3958
3959 IF l_inclusion_flag = 'N'
3960 -- BUGFIX 2414035 : Added the following condition to fix this bug
3961 OR
3962 (l_inclusion_flag = 'Y' -- Has again become eligible in this pension year
3963 AND -- but on a future date
3964 l_temp_asg_details.start_date > l_proration_dates(l_itr)
3965 ) THEN
3966
3967 debug('This assignment HAS opted out nocopy of the pension scheme.',180);
3968
3969 l_leaver := 'Y';
3970 l_leaver_date := LEAST((l_pqp_asg_attributes.effective_start_date - 1)
3971 ,nvl(l_leaver_date
3972 ,(l_pqp_asg_attributes.effective_start_date - 1)
3973 )
3974 );
3975 debug('Leaver Date :'||to_char(l_leaver_date,'DD/MM/YYYY'), 185);
3976
3977 CLOSE pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn;
3978 EXIT; -- quit loop -- no need to search for other events
3979
3980 END IF; -- l_inclusion_flag = 'N' THEN
3981 --
3982 END IF; -- 2 pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn%FOUND
3983 --
3984 END IF; -- 1 pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn%FOUND
3985 --
3986 CLOSE pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn;
3987 --
3988 debug('Assignment attributes have had changes',190);
3989 --
3990 END IF; -- if this date <> last date to eliminate duplicates
3991 --
3992 l_itr := l_proration_dates.NEXT(l_itr);
3993 --
3994 END LOOP; -- through elected pension change proration dates
3995
3996 l_proration_dates.DELETE;
3997 l_proration_changes.DELETE;
3998
3999 l_pqp_asg_attributes := NULL;
4000 l_last_pqp_asg_attributes := NULL;
4001
4002 debug('After Elected Pension Flag change check - Deleted Proration Dates',200);
4003
4004 -- Check for the next set of events which qualify an assignment as leaver.
4005 -- 4) Change in Teacher Status such that the status changes from
4006 -- 'TCHR'/'TTR6' to 'NONT' / 'NULL'.(PS : NULL sh not be possible)
4007
4008 -- Get the events
4009 l_no_of_events := 0;
4010 l_no_of_events := get_events(p_event_group => 'PQP_GB_TP_IS_TEACHER'
4011 ,p_assignment_id => p_assignment_id
4012 ,p_business_group_id => p_business_group_id
4013 ,p_start_date => p_effective_start_date
4014 ,p_end_date => p_effective_end_date
4015 ,t_proration_dates => l_proration_dates -- OUT
4016 ,t_proration_changes => l_proration_changes -- OUT
4017 );
4018
4019 debug('Number of '||'PQP_GB_TP_IS_TEACHER'||' Events: '||
4020 fnd_number.number_to_canonical(l_no_of_events),210);
4021
4022 -- b) Loop through the events and check if any have changed.
4023 l_itr := l_proration_dates.FIRST;
4024 WHILE l_itr <= l_proration_dates.LAST
4025 LOOP -- through change proration dates
4026
4027 IF (l_itr = l_proration_dates.FIRST
4028 OR
4029 ( l_proration_dates(l_itr) <>
4030 l_proration_dates(l_proration_dates.PRIOR(l_itr))
4031 )
4032 )
4033 AND
4034 (l_proration_changes(l_itr) <> 'C' -- Not a Correction
4035 ) THEN
4036
4037 debug('Event date :'||to_char(l_proration_dates(l_itr),'DD/MM/YYYY'), 215);
4038 debug('Update Type :'||l_proration_changes(l_itr), 216);
4039
4040 OPEN pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn
4041 (p_assignment_id
4042 ,l_proration_dates(l_itr)
4043 );
4044 FETCH pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn INTO l_pqp_asg_attributes;
4045 --
4046 IF pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn%FOUND
4047 AND
4048 NVL(l_pqp_asg_attributes.tp_is_teacher,'NONT') = 'NONT' THEN
4049
4050 -- Fetch the previous set of attributes
4051 FETCH pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn INTO l_last_pqp_asg_attributes;
4052 --
4053 IF pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn%FOUND
4054 AND
4055 nvl(l_last_pqp_asg_attributes.tp_is_teacher,'NONT') IN ('TCHR','TTR6') THEN
4056
4057 debug('This assignment HAS become a Non-Teacher.',220);
4058
4059 l_leaver := 'Y';
4060 l_leaver_date := LEAST((l_pqp_asg_attributes.effective_start_date - 1)
4061 ,nvl(l_leaver_date
4062 ,(l_pqp_asg_attributes.effective_start_date - 1)
4063 )
4064 );
4065 debug('Leaver Date :'||to_char(l_leaver_date,'DD/MM/YYYY'), 225);
4066
4067 CLOSE pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn;
4068 EXIT; -- quit loop -- no need to search for other events
4069 --
4070 END IF; -- 2 pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn%FOUND
4071 --
4072 END IF; -- 1 pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn%FOUND
4073 --
4074 CLOSE pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn;
4075 --
4076 debug('Assignment attributes have had changes',230);
4077 --
4078 END IF; -- if this date <> last date to eliminate duplicates and ignore corrections
4079 --
4080 l_itr := l_proration_dates.NEXT(l_itr);
4081 --
4082 END LOOP; -- through elected pension change proration dates
4083
4084 debug('After Teacher Status change check',240);
4085
4086 -- Reset the events in pay_process_events to 'U' for "Unprocessed".
4087 -- Bug 3015917 : Removed set_pay_process.. as we now use the new style DTI
4088
4089 l_proration_dates.DELETE;
4090 l_proration_changes.DELETE;
4091
4092 debug('Leaver Flag :'||l_leaver,250);
4093 debug('Leaver Date :'||to_char(l_leaver_date,'dd/mm/yyyy'),260);
4094
4095 -- Assign the leaver date value to the return parameter
4096 p_leaver_date := l_leaver_date;
4097
4098 debug_exit(l_proc_name);
4099 RETURN l_leaver;
4100
4101 EXCEPTION
4102 WHEN OTHERS THEN
4103 debug_exit(' Others in '||l_proc_name);
4104 p_leaver_date := NULL;
4105 RAISE;
4106 END; -- chk_is_teacher_a_leaver
4107
4108 --
4109 -- Check if the leaver teacher is also a re-starter
4110 --
4111 FUNCTION chk_is_leaver_a_restarter
4112 (p_business_group_id IN NUMBER
4113 ,p_effective_start_date IN DATE
4114 ,p_effective_end_date IN DATE
4115 ,p_assignment_id IN NUMBER
4116 ,p_restarter_date OUT NOCOPY DATE
4117 ) RETURN VARCHAR2 -- Y or N
4118 IS
4119
4120 -- Variable Declaration
4121 l_restarter VARCHAR2(1) := 'N';
4122 l_restarter_date DATE;
4123 l_itr NUMBER;
4124 l_no_of_events NUMBER(5);
4125 l_inclusion_flag VARCHAR2(1) := 'N';
4126
4127 -- Rowtype Variable Declaration
4128 l_event_group_details pqp_gb_tp_pension_extracts.csr_event_group_details%ROWTYPE;
4129 l_proration_dates pay_interpreter_pkg.t_proration_dates_table_type;
4130 l_proration_changes pay_interpreter_pkg.t_proration_type_table_type;
4131 l_asg_details csr_asg_details_up%ROWTYPE;
4132 l_prev_asg_details csr_asg_details_up%ROWTYPE;
4133 l_pqp_asg_attributes pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn%ROWTYPE;
4134 l_last_pqp_asg_attributes pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn%ROWTYPE;
4135
4136 l_temp_asg_details csr_asg_details_up%ROWTYPE;
4137 l_temp_aat_details csr_pqp_asg_attributes_up%ROWTYPE;
4138
4139 -- BUG : 3873376
4140 --RSTRT: new variables added
4141 l_asg_details_restart csr_asg_details_up%ROWTYPE;
4142 l_pqp_asg_attributes_restart csr_pqp_asg_attributes_up%ROWTYPE;
4143
4144 l_proc_name VARCHAR2(61):=
4145 g_proc_name||'chk_is_leaver_a_restarter';
4146
4147 BEGIN -- chk_is_leaver_a_restarter
4148
4149 debug_enter(l_proc_name);
4150 debug('p_effective_start_date '||p_effective_start_date);
4151 debug('p_effective_end_date '||p_effective_end_date);
4152
4153 -- Update the events in pay_process_events to 'P' for "in process".
4154 -- Bug 3015917 : Removed set_pay_process.. as we now use the new style DTI
4155
4156 -- Check for following restarter events here :
4157 -- Even if a restarter event is found, continue looking for more restarter events
4158 -- as we want the EARLIEST date of any of the restarter events
4159 -- 1) Assignment Status change, back to ACTIVE from SUSPENDED ONLY
4160 -- 2) Location change resulting in change in Establishment from
4161 -- a) LEA estb to Non-LEA estb
4162 -- b) Non-LEA estb to LEA estb
4163 -- c) Non-LEA estb to Non-LEA estb
4164 -- 3) Change in Elected pension flag resulting in the flag changing from 'N' to 'Y'
4165 -- 4) Change in Teacher Status such that the status changes from
4166 -- 'NONT' / 'NULL' to 'TCHR'/'TTR6'
4167
4168
4169 -- 1) Assignment Status change, back to ACTIVE from SUSPENDED ONLY
4170 -- Get the events
4171 l_no_of_events := get_events(p_event_group => 'PQP_GB_TP_ASG_STATUS'
4172 ,p_assignment_id => p_assignment_id
4173 ,p_business_group_id => p_business_group_id
4174 ,p_start_date => p_effective_start_date
4175 ,p_end_date => p_effective_end_date
4176 ,t_proration_dates => l_proration_dates -- OUT
4177 ,t_proration_changes => l_proration_changes -- OUT
4178 );
4179
4180 debug('Number of ASG_STATUS Events: '||
4181 fnd_number.number_to_canonical(l_proration_dates.COUNT));
4182
4183 l_itr := l_proration_dates.FIRST;
4184
4185 WHILE l_itr <= l_proration_dates.LAST
4186 LOOP -- through the dates when some status change event happened
4187
4188 debug('Inside ASG Dates LOOP',20);
4189 --
4190 -- eliminate duplicate dates
4191 -- compare the last value to the current one
4192 -- always process the first date
4193 IF l_itr = l_proration_dates.FIRST
4194 OR
4195 ( l_proration_dates(l_itr) <>
4196 l_proration_dates(l_proration_dates.PRIOR(l_itr))
4197 ) THEN
4198
4199 OPEN csr_asg_details_dn
4200 (p_assignment_id
4201 ,l_proration_dates(l_itr)
4202 );
4203 FETCH csr_asg_details_dn INTO l_asg_details;
4204
4205 IF csr_asg_details_dn%FOUND THEN
4206
4207 debug('Inside IF , found ASG record',30);
4208 -- Get the per_system_status for the assignment_status_type_id
4209 l_asg_details.status_type := get_status_type(l_asg_details.status_type_id);
4210
4211 -- Get the previous assignment and compare status type
4212 FETCH csr_asg_details_dn INTO l_prev_asg_details;
4213 l_prev_asg_details.status_type := get_status_type(l_prev_asg_details.status_type_id);
4214
4215 debug('After second fetch',40);
4216 debug('l_asg_details.location_id '||l_asg_details.location_id,41);
4217
4218 IF (csr_asg_details_dn%FOUND
4219 AND
4220 l_prev_asg_details.status_type = 'SUSP_ASSIGN'
4221 AND
4222 l_asg_details.status_type = 'ACTIVE_ASSIGN'
4223 -- check if the location is a valid location
4224 AND
4225 pqp_gb_tp_pension_extracts.g_criteria_estbs.EXISTS(l_asg_details.location_id)
4226 ) THEN
4227
4228 debug('now checking chk_has_tchr_elected_pension',42);
4229 -- BUG : 3873376
4230 --:RSTRT --check if the asg is a valid tchr assignment on restart date.
4231 l_inclusion_flag := chk_has_tchr_elected_pension
4232 (p_business_group_id => p_business_group_id
4233 ,p_effective_date => l_asg_details.start_date
4234 ,p_assignment_id => p_assignment_id
4235 ,p_asg_details => l_asg_details_restart -- OUT
4236 ,p_asg_attributes => l_pqp_asg_attributes_restart -- OUT
4237 );
4238 debug('l_inclusion_flag :' ||l_inclusion_flag,43);
4239 debug('l_asg_details_restart.start_date :'||l_asg_details_restart.start_date);
4240
4241 IF l_inclusion_flag = 'Y'
4242 -- Valid tchr on the same date as of restart_date and not in future.
4243 -- future events will be taken care of in the other events check
4244 AND NOT(l_asg_details_restart.start_date > l_asg_details.start_date)
4245 THEN
4246 -- Assignment has been restarted
4247 l_restarter := 'Y';
4248 l_restarter_date := l_asg_details.start_date;
4249
4250 debug('Assignment is a restarter, Quitting LOOP ',50);
4251 CLOSE csr_asg_details_dn;
4252 EXIT;
4253 --
4254 END IF; --l_inclusion_flag = 'Y' THEN
4255
4256 END IF; -- FOUND and previous status = 'SUSP_ASSIGN' and current status = 'ACTIVE_ASSIGN'
4257 --
4258 END IF; -- csr_asg_details_dn%FOUND THEN
4259 --
4260 CLOSE csr_asg_details_dn;
4261
4262 END IF; -- if this date <> last date, to eliminate duplicates
4263 --
4264 l_itr := l_proration_dates.NEXT(l_itr);
4265 --
4266 END LOOP; -- through the dates when some status change event happened
4267
4268 l_proration_dates.DELETE;
4269 l_proration_changes.DELETE;
4270
4271 l_asg_details := NULL;
4272 l_prev_asg_details := NULL;
4273
4274 l_asg_details_restart := NULL;
4275 l_pqp_asg_attributes_restart := NULL ;
4276
4277 debug('After Assignment Status Events check - Deleted Proration Dates',60);
4278
4279 -- Check for the next set of events which qualify an assignment as restarter.
4280 -- 2) Location change resulting in change in Establishment
4281 -- a) LEA estb to Non-LEA estb
4282 -- b) Non-LEA estb to LEA estb
4283 -- c) Non-LEA estb to Non-LEA estb
4284 debug('Now Checking for location change',70);
4285
4286 -- Get the events
4287 l_no_of_events := get_events(p_event_group => 'PQP_GB_TP_ASG_LOCATION'
4288 ,p_assignment_id => p_assignment_id
4289 ,p_business_group_id => p_business_group_id
4290 ,p_start_date => p_effective_start_date
4291 ,p_end_date => p_effective_end_date
4292 ,t_proration_dates => l_proration_dates -- OUT
4293 ,t_proration_changes => l_proration_changes -- OUT
4294 );
4295
4296 debug('Number of ASG_LOCATION Events: '||
4297 fnd_number.number_to_canonical(l_proration_dates.COUNT));
4298
4299 l_itr := l_proration_dates.FIRST;
4300 WHILE l_itr <= l_proration_dates.LAST
4301 LOOP -- through location change proration dates
4302
4303 -- a location change event did take place, correction or update
4304 -- PS : Currently ignoring corrections, but if later there is a
4305 -- need to include corrections then
4306 -- ONLY include if asg start date is > p_effective_start_date
4307 -- coz if the asg start date is = p_effective_date then the
4308 -- asg will mostly not be reported as a leaver in the first place
4309 -- loop thru all the dates
4310 -- and query asg for location value
4311 -- check if location is a criteria location
4312 -- also confirm that the previous location was a non criteria location
4313 -- if so flag location changed and store teacher start date
4314 -- and exit else continue
4315
4316 debug('Inside LOC events loop, Location change event found',80);
4317
4318 --
4319 -- eliminate duplicate dates
4320 -- compare the last value to the current one
4321 -- always process the first date
4322 IF l_itr = l_proration_dates.FIRST
4323 OR
4324 ( l_proration_dates(l_itr) <>
4325 l_proration_dates(l_proration_dates.PRIOR(l_itr))
4326 )
4327 THEN
4328
4329 OPEN csr_asg_details_dn
4330 (p_assignment_id
4331 ,l_proration_dates(l_itr)
4332 );
4333 FETCH csr_asg_details_dn INTO l_asg_details;
4334
4335 debug('Inside IF, After first fetch',90);
4336
4337 IF (csr_asg_details_dn%FOUND
4338 AND
4339 l_proration_changes(l_itr) <> 'C' -- Not a Correction
4340 ) THEN
4341
4342 -- Get the previous assignment record
4343 FETCH csr_asg_details_dn INTO l_prev_asg_details;
4344
4345 debug('Event worth considering',100);
4346
4347 -- Check if the locaiton change is a valid one to report as restarter
4348 -- The new establishment must be a criteria establishment
4349 -- and the previous establishment must not be a criteria establishment
4350 IF (csr_asg_details_dn%FOUND
4351 AND -- the new asg location is a criteria location
4352 pqp_gb_tp_pension_extracts.g_criteria_estbs.EXISTS(l_asg_details.location_id)
4353 AND -- the previous was not a criteria location
4354 (NOT pqp_gb_tp_pension_extracts.g_criteria_estbs.EXISTS(l_prev_asg_details.location_id)
4355 )
4356 ) THEN
4357 debug('now checking chk_has_tchr_elected_pension',101);
4358 -- BUG : 3873376
4359 --:RSTRT --check if the asg is a valid tchr assignment on restart date.
4360 l_inclusion_flag := chk_has_tchr_elected_pension
4361 (p_business_group_id => p_business_group_id
4362 ,p_effective_date => l_asg_details.start_date
4363 ,p_assignment_id => p_assignment_id
4364 ,p_asg_details => l_asg_details_restart -- OUT
4365 ,p_asg_attributes => l_pqp_asg_attributes_restart -- OUT
4366 );
4367 debug('l_inclusion_flag :' ||l_inclusion_flag,102);
4368 debug('l_asg_details_restart.start_date :' ||l_asg_details_restart.start_date);
4369
4370 IF l_inclusion_flag = 'Y'
4371 -- Valid tchr on the same dateas the restart_Date, not in future.
4372 -- future events will be taken care of in the other events check
4373 AND NOT(l_asg_details_restart.start_date > l_asg_details.start_date)THEN
4374 -- The assignment has had a location change such that it has become a restarter
4375 l_restarter := 'Y';
4376 l_restarter_date := LEAST(l_asg_details.start_date
4377 ,nvl(l_restarter_date,l_asg_details.start_date)
4378 );
4379
4380 debug('Assignment is a restarter due to location change, Quitting loop',110);
4381
4382 CLOSE csr_asg_details_dn;
4383 EXIT;
4384 END IF ; --l_inclusion_flag = 'Y'
4385
4386 END IF; -- Check if the locaiton change is a valid one to report as restarter
4387 --
4388 END IF; -- csr_asg_details_dn%FOUND THEN
4389 --
4390 CLOSE csr_asg_details_dn;
4391 --
4392 END IF; -- if this date <> last date to eliminate duplicates
4393 --
4394 l_itr := l_proration_dates.NEXT(l_itr);
4395 --
4396 END LOOP; -- through location change proration dates
4397
4398 l_proration_dates.DELETE;
4399 l_proration_changes.DELETE;
4400
4401 l_asg_details_restart := NULL;
4402 l_pqp_asg_attributes_restart := NULL ;
4403
4404
4405 debug('After Location Change check - Deleted Proration Dates',120);
4406
4407 -- Check for the next set of events which qualify an assignment as restarter.
4408 -- 3) Change in Elected pension flag resulting in the flag changing from 'N' to 'Y'
4409
4410 -- Get the events
4411 l_no_of_events := 0;
4412 l_no_of_events := get_events(p_event_group => 'PQP_GB_TP_ELECTED_PENSION'
4413 ,p_assignment_id => p_assignment_id
4414 ,p_business_group_id => p_business_group_id
4415 ,p_start_date => p_effective_start_date
4416 ,p_end_date => p_effective_end_date
4417 ,t_proration_dates => l_proration_dates -- OUT
4418 ,t_proration_changes => l_proration_changes -- OUT
4419 );
4420
4421 debug('Number of '||'PQP_GB_TP_ELECTED_PENSION'||' Events: '||
4422 fnd_number.number_to_canonical(l_no_of_events));
4423
4424 -- b) Loop through the events and check if any have changed.
4425 l_itr := l_proration_dates.FIRST;
4426 WHILE l_itr <= l_proration_dates.LAST
4427 LOOP -- through change proration dates
4428
4429 IF l_itr = l_proration_dates.FIRST
4430 OR
4431 ( l_proration_dates(l_itr) <>
4432 l_proration_dates(l_proration_dates.PRIOR(l_itr))
4433 ) THEN
4434
4435 OPEN pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn
4436 (p_assignment_id
4437 ,l_proration_dates(l_itr)
4438 );
4439 FETCH pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn INTO l_pqp_asg_attributes;
4440 --
4441 IF pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn%FOUND
4442 AND
4443 NVL(l_pqp_asg_attributes.tp_elected_pension,'N') = 'Y' THEN
4444
4445 -- Fetch the previous set of attributes
4446 FETCH pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn INTO l_last_pqp_asg_attributes;
4447 --
4448 IF pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn%FOUND
4449 AND
4450 nvl(l_last_pqp_asg_attributes.tp_elected_pension,'N') = 'N' THEN
4451
4452 debug('now checking chk_has_tchr_elected_pension',121);
4453 -- BUG : 3873376
4454 --:RSTRT --check if the asg is a valid tchr assignment on restart date.
4455 l_inclusion_flag := chk_has_tchr_elected_pension
4456 (p_business_group_id => p_business_group_id
4457 ,p_effective_date => l_pqp_asg_attributes.effective_start_date
4458 ,p_assignment_id => p_assignment_id
4459 ,p_asg_details => l_asg_details_restart -- OUT
4460 ,p_asg_attributes => l_pqp_asg_attributes_restart -- OUT
4461 );
4462 debug('l_inclusion_flag :' ||l_inclusion_flag,122);
4463 debug('l_asg_details_restart.start_date :' ||l_asg_details_restart.start_date);
4464
4465 IF l_inclusion_flag = 'Y'
4466 -- Valid tchr on the same dateas the restart_Date, not in future.
4467 -- future events will be taken care of in the other events check
4468 AND NOT(l_asg_details_restart.start_date > l_pqp_asg_attributes.effective_start_date) THEN
4469 -- Pension flag has changed to 'Y' from 'N'/NULL
4470 debug('This assignment HAS opted back into the pension scheme.');
4471 l_restarter := 'Y';
4472 l_restarter_date := LEAST(l_pqp_asg_attributes.effective_start_date
4473 ,nvl(l_restarter_date,l_pqp_asg_attributes.effective_start_date)
4474 );
4475
4476 CLOSE pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn;
4477 EXIT; -- quit loop -- no need to search for other events
4478 END IF ; --l_inclusion_flag = 'Y' THEN
4479
4480 --
4481 END IF; -- 2 pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn%FOUND
4482 --
4483 END IF; -- 1 pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn%FOUND
4484 --
4485 CLOSE pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn;
4486 --
4487 debug('Assignment attributes have had changes',130);
4488 --
4489 END IF; -- if this date <> last date to eliminate duplicates
4490 --
4491 l_itr := l_proration_dates.NEXT(l_itr);
4492 --
4493 END LOOP; -- through elected pension change proration dates
4494
4495 l_proration_dates.DELETE;
4496 l_proration_changes.DELETE;
4497
4498 l_pqp_asg_attributes := NULL;
4499 l_last_pqp_asg_attributes := NULL;
4500
4501 l_asg_details_restart := NULL;
4502 l_pqp_asg_attributes_restart := NULL ;
4503
4504
4505 debug('After Elected Pension Flag change check - Deleted Proration Dates',140);
4506
4507 -- Check for the next set of events which qualify an assignment as restarter.
4508 -- 4) Change in Teacher Status such that the status changes from
4509 -- 'NONT' / 'NULL' to 'TCHR'/'TTR6'
4510
4511 -- Get the events
4512 l_no_of_events := 0;
4513 l_no_of_events := get_events(p_event_group => 'PQP_GB_TP_IS_TEACHER'
4514 ,p_assignment_id => p_assignment_id
4515 ,p_business_group_id => p_business_group_id
4516 ,p_start_date => p_effective_start_date
4517 ,p_end_date => p_effective_end_date
4518 ,t_proration_dates => l_proration_dates -- OUT
4519 ,t_proration_changes => l_proration_changes -- OUT
4520 );
4521
4522 debug('Number of '||'PQP_GB_TP_IS_TEACHER'||' Events: '||
4523 fnd_number.number_to_canonical(l_no_of_events));
4524
4525 -- b) Loop through the events and check if any have changed.
4526 l_itr := l_proration_dates.FIRST;
4527 WHILE l_itr <= l_proration_dates.LAST
4528 LOOP -- through change proration dates
4529
4530 IF (l_itr = l_proration_dates.FIRST
4531 OR
4532 ( l_proration_dates(l_itr) <>
4533 l_proration_dates(l_proration_dates.PRIOR(l_itr))
4534 )
4535 )
4536 AND
4537 (l_proration_changes(l_itr) <> 'C' -- Not a Correction
4538 ) THEN
4539
4540 OPEN pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn
4541 (p_assignment_id
4542 ,l_proration_dates(l_itr)
4543 );
4544 FETCH pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn INTO l_pqp_asg_attributes;
4545 --
4546 IF pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn%FOUND
4547 AND
4548 NVL(l_pqp_asg_attributes.tp_is_teacher,'NONT') IN ('TCHR','TTR6') THEN
4549
4550 -- Fetch the previous set of attributes
4551 FETCH pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn INTO l_last_pqp_asg_attributes;
4552 --
4553 IF pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn%FOUND
4554 AND
4555 nvl(l_last_pqp_asg_attributes.tp_is_teacher,'NONT') = 'NONT' THEN
4556
4557 debug('now checking chk_has_tchr_elected_pension',141);
4558 -- BUG : 3873376
4559 --:RSTRT --check if the asg is a valid tchr assignment on restart date.
4560 l_inclusion_flag := chk_has_tchr_elected_pension
4561 (p_business_group_id => p_business_group_id
4562 ,p_effective_date => l_pqp_asg_attributes.effective_start_date
4563 ,p_assignment_id => p_assignment_id
4564 ,p_asg_details => l_asg_details_restart -- OUT
4565 ,p_asg_attributes => l_pqp_asg_attributes_restart -- OUT
4566 );
4567 debug('l_inclusion_flag :' ||l_inclusion_flag,142);
4568 debug('l_asg_details_restart.start_date :' ||l_asg_details_restart.start_date);
4569
4570 IF l_inclusion_flag = 'Y'
4571 -- Valid tchr on the same dateas the restart_Date, not in future.
4572 -- future events will be taken care of in the other events check
4573 AND NOT(l_asg_details_restart.start_date > l_pqp_asg_attributes.effective_start_date) THEN
4574
4575 debug('The leaver HAS become a Teacher again.');
4576 l_restarter := 'Y';
4577 l_restarter_date := LEAST(l_pqp_asg_attributes.effective_start_date
4578 ,nvl(l_restarter_date,l_pqp_asg_attributes.effective_start_date)
4579 );
4580
4581 CLOSE pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn;
4582 EXIT; -- quit loop -- no need to search for other events
4583 END IF ; -- l_inclusion_flag = 'Y' THEN
4584 --
4585 END IF; -- 2 pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn%FOUND
4586 --
4587 END IF; -- 1 pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn%FOUND
4588 --
4589 CLOSE pqp_gb_tp_pension_extracts.csr_pqp_asg_attributes_dn;
4590 --
4591 debug('Assignment attributes have had changes',150);
4592 --
4593 END IF; -- if this date <> last date to eliminate duplicates and ignore corrections
4594 --
4595 l_itr := l_proration_dates.NEXT(l_itr);
4596 --
4597 END LOOP; -- through elected pension change proration dates
4598
4599 debug('After Teacher Status change check',160);
4600
4601 -- Reset the events in pay_process_events to 'U' for "Unprocessed".
4602 -- Bug 3015917 : Removed set_pay_process.. as we now use the new style DTI
4603
4604 l_proration_dates.DELETE;
4605 l_proration_changes.DELETE;
4606
4607 l_asg_details_restart := NULL;
4608 l_pqp_asg_attributes_restart := NULL ;
4609
4610
4611 debug('Restarter Flag :'||l_restarter,170);
4612 debug('Restarter Date :'||to_char(l_restarter_date,'dd/mm/yyyy'),180);
4613
4614 -- Assign the restarter date value to the return parameter
4615 p_restarter_date := l_restarter_date;
4616
4617 debug_exit(l_proc_name);
4618 RETURN l_restarter;
4619
4620 EXCEPTION
4621 WHEN OTHERS THEN
4622 debug_exit(' Others in '||l_proc_name);
4623 p_restarter_date := NULL;
4624 RAISE;
4625 END; -- chk_is_leaver_a_restarter
4626
4627 --
4628 -- Check if this teacher has already been reported in previous runs
4629 --
4630 FUNCTION chk_has_teacher_been_reported
4631 (p_person_id IN NUMBER
4632 -- ALRD_RPT change
4633 ,p_leaver_date IN DATE
4634 ) RETURN VARCHAR2
4635 IS
4636
4637 -- Variable declaration
4638 l_reported_flag VARCHAR2(1) := 'N';
4639
4640 -- Cursor declaration
4641 CURSOR csr_person_reported IS
4642 SELECT 'Y'
4643 FROM pqp_extract_attributes pqea
4644 ,ben_ext_rslt rslt
4645 ,ben_ext_rslt_dtl rdtl
4646 ,ben_ext_rcd drcd
4647 WHERE pqea.ext_dfn_type = g_extract_type
4648 AND rslt.ext_dfn_id = pqea.ext_dfn_id
4649 -- Bugfix 3073562:GAP1:GAP2, now using master bg id
4650 AND rslt.business_group_id = g_master_bg_id
4651 AND rslt.ext_stat_cd NOT IN
4652 ('F' -- Job Failure
4653 ,'R' -- Rejected By User
4654 ,'X' -- Executing
4655 )
4656 AND rdtl.ext_rslt_id = rslt.ext_rslt_id
4657 AND drcd.ext_rcd_id = rdtl.ext_rcd_id
4658 AND drcd.rcd_type_cd = 'D' -- detail records only
4659 -- changed the person_id check to NI Number check.
4660 --AND rdtl.person_id = p_person_id
4661 AND rdtl.val_04 IN
4662 ( SELECT national_identifier
4663 FROM per_all_people_f per2
4664 WHERE per2.person_id = p_person_id
4665 )
4666 -- match the header element
4667 AND EXISTS
4668 ( SELECT 'Y'
4669 FROM ben_ext_rslt_dtl rdtl1
4670 WHERE rdtl1.business_group_id = g_master_bg_id
4671 AND EXISTS
4672 ( SELECT 'Y'
4673 FROM ben_ext_rcd drcd1
4674 WHERE drcd1.rcd_type_cd = 'H'
4675 AND drcd1.ext_rcd_id = rdtl1.ext_rcd_id
4676 )
4677 AND rdtl.ext_rslt_id = rdtl1.ext_rslt_id
4678 AND SUBSTR(rdtl1.val_01
4679 ,1
4680 ,INSTR(rdtl1.val_01,':',1,3)--upto third occurence
4681 )
4682 =SUBSTR(g_header_system_element
4683 ,1
4684 ,INSTR(g_header_system_element,':',1,3)
4685 )
4686 )
4687 -- only in the current pension year and upto the end of last run
4688 AND rslt.eff_dt between g_pension_year_start_date and g_last_effective_date
4689 -- ALRD_RPT change
4690 -- checking for the matching date and withdrawl flag.
4691 AND to_date(rdtl.val_14,'DDMMRR') = p_leaver_date -- Leaver Date
4692 AND rdtl.val_15 = 'W' --Withdrawl Flag
4693 -- only need to look for one record
4694 AND ROWNUM < 2;
4695
4696 l_proc_name VARCHAR2(61):=
4697 g_proc_name||'chk_has_teacher_been_reported';
4698
4699 BEGIN -- chk_has_teacher_been_reported
4700
4701 debug_enter(l_proc_name);
4702 debug('p_person_id : '||to_char(p_person_id),10);
4703 debug('p_leaver_date: '||to_char(p_leaver_date));
4704
4705 -- ALRDRPT changes.
4706 -- check for the global variable
4707 -- if already set by the previous call to the function return that.
4708 -- else execute the logic to find the flag.
4709
4710 -- ALRD_RPT changes
4711
4712 -- PER_LVR: removed the check
4713 -- coz we need to check for each leaver date separatly.
4714
4715 --IF g_person_already_reported IS NULL THEN
4716
4717 debug(l_proc_name,10) ;
4718 OPEN csr_person_reported;
4719 FETCH csr_person_reported INTO l_reported_flag;
4720 CLOSE csr_person_reported;
4721
4722 -- PER_LVR: removed the check
4723 --g_person_already_reported := l_reported_flag ;
4724
4725 --ELSE
4726 --debug(l_proc_name,20) ;
4727 --l_reported_flag := g_person_already_reported ;
4728 --END IF;
4729
4730 debug('Teacher Already Reported:'||l_reported_flag);
4731 debug_exit(l_proc_name);
4732
4733 RETURN l_reported_flag;
4734
4735 EXCEPTION
4736 WHEN OTHERS THEN
4737 debug_exit(' Others in '||l_proc_name);
4738 RAISE;
4739 END; -- chk_has_teacher_been_reported
4740 --
4741 -- Bugfix 3073562:GAP9a
4742 -- Added this procedure for GAP9a
4743 --
4744 PROCEDURE warn_if_supply_tchr_is_ft
4745 (p_assignment_id IN NUMBER
4746 ,p_establishment_number IN VARCHAR2
4747 ,p_ext_emp_cat_code IN VARCHAR2
4748 ) IS
4749
4750 l_error number;
4751
4752 l_proc_name VARCHAR2(61):=
4753 g_proc_name||'warn_if_supply_tchr_is_ft';
4754
4755 BEGIN -- warn_if_supply_tchr_is_ft
4756
4757 debug_enter(l_proc_name);
4758
4759 IF p_establishment_number = '0966' -- Supply Establishment
4760 AND -- Full time
4761 p_ext_emp_cat_code = 'F' THEN
4762
4763 debug(l_proc_name, 20);
4764 l_error := pqp_gb_tp_extract_functions.raise_extract_warning
4765 (p_assignment_id => p_assignment_id
4766 ,p_error_text => 'BEN_93655_SUPPLY_TCHR_FULLTIME'
4767 ,p_error_number => 93655
4768 );
4769 END IF;
4770
4771 debug_exit(l_proc_name);
4772
4773 END; -- warn_if_supply_tchr_is_ft
4774
4775 --
4776 -- Function to get the Extract Employment category code
4777 --
4778 FUNCTION get_ext_emp_cat_cd
4779 (p_assignment_id IN NUMBER
4780 ,p_effective_date IN DATE
4781 ) RETURN VARCHAR2 -- F or P
4782 IS
4783
4784 l_asg_details csr_asg_details_up%ROWTYPE;
4785 l_ext_emp_cat_cd VARCHAR2(1);
4786
4787 l_proc_name VARCHAR2(61):=
4788 g_proc_name||'get_ext_emp_cat_cd';
4789
4790 BEGIN
4791
4792 debug_enter(l_proc_name);
4793 debug('p_assignment_id :'||to_char(p_assignment_id), 10);
4794 debug('p_effective_date :'||to_char(p_effective_date, 'DD/MM/YYYY'), 20);
4795
4796 OPEN csr_asg_details_up
4797 (p_assignment_id
4798 ,p_effective_date
4799 );
4800 FETCH csr_asg_details_up INTO l_asg_details;
4801 IF csr_asg_details_up%NOTFOUND THEN
4802 -- This situation should never happen, but
4803 -- if it does, we will assume part time
4804 debug('IMP : This situation should never happen', 30);
4805 l_ext_emp_cat_cd := 'P';
4806 ELSE -- asg record FOUND
4807 -- Bugfix 3073562:GAP1:GAP2
4808 l_ext_emp_cat_cd :=
4809 get_translate_asg_emp_cat_code
4810 (l_asg_details.asg_emp_cat_cd
4811 ,p_effective_date
4812 ,'Pension Extracts Employment Category Code'
4813 ,l_asg_details.business_group_id
4814 );
4815 END IF;
4816
4817 CLOSE csr_asg_details_up;
4818
4819 debug('Extract Emp Cat Code :'||l_ext_emp_cat_cd, 40);
4820 debug_exit(l_proc_name);
4821
4822 RETURN l_ext_emp_cat_cd;
4823 EXCEPTION
4824 WHEN OTHERS THEN
4825 CLOSE csr_asg_details_up;
4826 debug('SQLCODE :'||to_char(SQLCODE), 60);
4827 debug('SQLERRM :'||SQLERRM, 70);
4828 debug_exit(' Others in '||l_proc_name);
4829 RAISE;
4830 END get_ext_emp_cat_cd;
4831
4832 --
4833 -- Fetch and save Secondary assignments
4834 --
4835 PROCEDURE fetch_secondary_assignments
4836 (p_primary_assignment_id IN NUMBER
4837 ,p_person_id IN NUMBER
4838 ,p_effective_date IN DATE
4839 ,p_must_be_a_leaver IN BOOLEAN
4840 )
4841 IS
4842
4843 -- Variable Declaration
4844 l_inclusion_flag VARCHAR2(1) := 'Y';
4845 l_leaver VARCHAR2(1) := 'N';
4846 l_leaver_date DATE := NULL;
4847 l_restarter VARCHAR2(1) := 'N';
4848 l_restarter_date DATE := NULL;
4849 l_first_time BOOLEAN := TRUE;
4850 l_primary_asg_leaver_date DATE := NULL;
4851 l_new_event_itr NUMBER(5);
4852 -- LVRDATE change
4853 l_period_end_date DATE := NULL;
4854
4855 -- ALRDRPT change
4856 l_already_reported VARCHAR2(1) := 'N';
4857 --PROFILING changes
4858 l_start_time NUMBER;
4859 l_end_time NUMBER;
4860
4861 -- Rowtype Variable Declaration
4862 l_asg_details csr_asg_details_up%ROWTYPE;
4863 l_pqp_asg_attributes csr_pqp_asg_attributes_up%ROWTYPE;
4864 l_sec_asgs csr_sec_assignments%ROWTYPE;
4865 l_starter_event stored_events_type;
4866
4867 --
4868 l_proc_name VARCHAR2(61):=
4869 g_proc_name||'fetch_secondary_assignments';
4870
4871 BEGIN -- fetch_secondary_assignments
4872
4873 debug_enter(l_proc_name);
4874
4875 debug('g_cross_per_enabled :'||g_cross_per_enabled, 10);
4876 debug('g_crossbg_enabled :'||g_crossbg_enabled, 11);
4877 debug('p_person_id :'||to_char(p_person_id), 12);
4878
4879 -- Fetch secondary assignments and save them only if
4880 -- Teacher has elected pension.
4881 -- However, find the leaver date for all secondary asgs.
4882 FOR l_sec_asgs IN csr_sec_assignments(p_primary_assignment_id
4883 ,p_person_id
4884 ,p_effective_date
4885 )
4886 LOOP
4887
4888 debug('Inside Loop, secondary asg id :'||to_char(l_sec_asgs.assignment_id),20);
4889
4890 -- Check if the secondary assignment qualifies to be on the Periodic Returns
4891 -- Pass g_pension_year_start_date as the effective date as we are
4892 -- checking as of start date of pension year. Basically, we are
4893 -- reporting annual returns from start of pension year.
4894 l_inclusion_flag := chk_has_tchr_elected_pension
4895 (p_business_group_id => l_sec_asgs.business_group_id
4896 ,p_effective_date => g_pension_year_start_date
4897 ,p_assignment_id => l_sec_asgs.assignment_id
4898 ,p_asg_details => l_asg_details -- OUT
4899 ,p_asg_attributes => l_pqp_asg_attributes -- OUT
4900 );
4901
4902 IF l_inclusion_flag = 'Y' THEN
4903 -- 1)
4904
4905 -- Check for leaver events between pension year start date and effective run date
4906 -- Basically, we are reporting annual returns starting from the
4907 -- start of the pension year to the leaver date, and we want to check
4908 -- for people who have become leavers in the same date range.
4909 -- However as we donot want to report people who have already been reported,
4910 -- we will need to look at previous run results to exclude people who
4911 -- have already been reported.
4912 -- Dates :
4913 -- Start date should be pension year start date
4914 -- End Date should be the end date of the run date range.
4915 debug('Secondary asg passes chk_has_teacher_elected_pension, doing leaver chk',30);
4916
4917 -- LVRDATE changes
4918 -- Changed the date passed based on Annual/Periodic Criteria
4919
4920 debug ('g_extract_type: '|| g_extract_type) ;
4921
4922 IF g_extract_type = 'TP1' THEN
4923 l_period_end_date := g_effective_run_date;
4924 ELSIF g_extract_type = 'TP1P' THEN
4925 l_period_end_date := g_effective_run_date + 1;
4926 END IF ;
4927
4928 debug ('l_period_end_date: '|| l_period_end_date) ;
4929
4930 l_leaver := chk_is_teacher_a_leaver
4931 (p_business_group_id => l_sec_asgs.business_group_id
4932 ,p_effective_start_date => GREATEST(g_pension_year_start_date
4933 ,nvl(l_asg_details.start_date
4934 ,g_pension_year_start_date
4935 )
4936 )
4937 -- LVRDATE change: changed the date passed based on Annual/Periodic Criteria
4938 ,p_effective_end_date => l_period_end_date
4939 --,p_effective_end_date => g_effective_run_date
4940 ,p_assignment_id => l_sec_asgs.assignment_id
4941 ,p_leaver_date => l_leaver_date -- OUT
4942 );
4943
4944 IF l_leaver = 'Y' THEN
4945
4946 debug('Secondary asg is leaver storing leaver date',40);
4947
4948 -- Bugfix 3073562:GAP6
4949 -- Adding this for secondary teaching asg support.
4950 -- This check is needed as there might not be any
4951 -- primary assignment row in g_ext_asg_details if this
4952 -- is the first secondary asg being processed.
4953 IF g_ext_asg_details.EXISTS(p_primary_assignment_id)
4954 -- Bugfix 3641851:CBF3b : Only do this if primary is to be reported
4955 AND
4956 g_ext_asg_details(p_primary_assignment_id).report_asg = 'Y' THEN
4957 l_primary_asg_leaver_date := g_ext_asg_details(p_primary_assignment_id).leaver_date;
4958 ELSE
4959 l_primary_asg_leaver_date := NULL;
4960 END IF;
4961
4962 -- Store the leaver date
4963 -- Bugfix 3734942 : We don't need to overwrite the
4964 -- sec asg leaver date with primary leaver date.
4965 -- Infact we need the actual leaver date of the
4966 -- secondary assignment
4967 l_asg_details.leaver_date := l_leaver_date;
4968
4969 ELSE -- l_leaver = 'N'
4970
4971 debug('Secondary asg is NOT a leaver',50);
4972
4973 l_asg_details.leaver_date := NULL;
4974
4975 -- Return 'N' for Periodic Report if assignment is not terminated.
4976 -- Bug 5408932
4977 IF g_extract_type = 'TP1P' THEN
4978 l_asg_details.report_asg := 'N';
4979 l_inclusion_flag := 'N';
4980 END IF;
4981
4982 -- PER_LVR change.
4983 -- Store the minimum of latest start date, in case it is not a leaver asg.
4984 g_latest_start_date := LEAST (g_latest_start_date,l_asg_details.start_date) ;
4985
4986 END IF;
4987
4988 IF l_inclusion_flag = 'Y' THEN
4989 -- 2)
4990
4991 -- Assignment has passed all checks save the details in
4992 -- 1) Type 4 global collection g_ext_asg_details
4993 -- 2) Type 1 global collection g_ext_asg_details
4994 -- Has more stuff than the Type 4 counterpart
4995 -- 3) Type 1 global collection g_ext_aat_details
4996 --
4997
4998 -- Even secondary asgs which are leavers are stored in the global ASG and AAT
4999 -- collections as this will be necessary at the time of creating multiple lines
5000 -- of service even in annual with exclude leavers mode.
5001
5002 -- Check if the leaver is also a re-starter,
5003 -- i.e. there is break in service in this pension year
5004 -- But, do this only if the leaver date is present and
5005 -- less than the g_effective_run_date
5006 l_asg_details.restarter_date := NULL;
5007
5008 IF l_leaver = 'Y'
5009 AND
5010 l_leaver_date < g_effective_run_date THEN
5011
5012 debug('Chk if Secondary leaver is also a restarter',60);
5013
5014 l_restarter := chk_is_leaver_a_restarter
5015 (p_business_group_id => l_sec_asgs.business_group_id
5016 ,p_effective_start_date => (l_leaver_date + 1)
5017 -- Bugfix 3734942 Chk for restarter event to end of run period
5018 ,p_effective_end_date => g_effective_run_date
5019 ,p_assignment_id => l_sec_asgs.assignment_id
5020 ,p_restarter_date => l_restarter_date -- OUT
5021 );
5022
5023 IF l_restarter = 'Y' THEN
5024
5025 debug('Sec. leaver is also a restarter, restarter date :'||to_char(l_restarter_date,'DDMMYY'),70);
5026
5027 l_asg_details.restarter_date := l_restarter_date;
5028
5029 END IF; -- l_restarter = 'Y' THEN
5030
5031 END IF; -- l_leaver = 'Y' AND l_leaver_date < g_effective_run_date THEN
5032
5033 debug('Storing values to globals',80);
5034
5035 -- 1) Type 4 global collection g_ext_asg_details
5036 pqp_gb_tp_pension_extracts.g_ext_asg_details(l_sec_asgs.assignment_id).person_id := l_asg_details.person_id;
5037 pqp_gb_tp_pension_extracts.g_ext_asg_details(l_sec_asgs.assignment_id).assignment_id := l_asg_details.assignment_id;
5038 pqp_gb_tp_pension_extracts.g_ext_asg_details(l_sec_asgs.assignment_id).start_date := l_asg_details.start_date;
5039 pqp_gb_tp_pension_extracts.g_ext_asg_details(l_sec_asgs.assignment_id).effective_end_date := l_asg_details.effective_end_date;
5040 pqp_gb_tp_pension_extracts.g_ext_asg_details(l_sec_asgs.assignment_id).creation_date := l_asg_details.creation_date;
5041 pqp_gb_tp_pension_extracts.g_ext_asg_details(l_sec_asgs.assignment_id).location_id := l_asg_details.location_id;
5042 pqp_gb_tp_pension_extracts.g_ext_asg_details(l_sec_asgs.assignment_id).asg_emp_cat_cd := l_asg_details.asg_emp_cat_cd;
5043 pqp_gb_tp_pension_extracts.g_ext_asg_details(l_sec_asgs.assignment_id).ext_emp_cat_cd := l_asg_details.ext_emp_cat_cd;
5044
5045 pqp_gb_tp_pension_extracts.g_ext_asg_details(l_sec_asgs.assignment_id).estb_number :=
5046 pqp_gb_tp_pension_extracts.g_criteria_estbs(l_asg_details.location_id).estb_number;
5047
5048 pqp_gb_tp_pension_extracts.g_ext_asg_details(l_sec_asgs.assignment_id).tp_safeguarded_grade :=
5049 l_pqp_asg_attributes.tp_safeguarded_grade;
5050
5051 -- 2) Type 1 global collection g_ext_asg_details
5052 g_teach_asg_count := g_teach_asg_count +1;
5053 g_ext_asg_details(l_sec_asgs.assignment_id) := l_asg_details;
5054
5055 -- 3) Type 1 global collection g_ext_aat_details
5056 g_ext_asg_attributes(l_pqp_asg_attributes.assignment_id) := l_pqp_asg_attributes;
5057
5058 -- Bugfix 3073562:GAP9a
5059 -- Raise a warning if the assignment is at a
5060 -- supply location and full time
5061 warn_if_supply_tchr_is_ft
5062 (p_assignment_id => l_sec_asgs.assignment_id
5063 ,p_establishment_number =>
5064 pqp_gb_tp_pension_extracts.g_criteria_estbs(l_asg_details.location_id).estb_number
5065 ,p_ext_emp_cat_code => l_asg_details.ext_emp_cat_cd
5066 );
5067
5068 -- Bugfix 3073562:GAP9b
5069 -- Increment the supply asg count if this is a supply assignment
5070 IF pqp_gb_tp_pension_extracts.g_criteria_estbs(l_asg_details.location_id).estb_number = '0966' THEN
5071 g_supply_asg_count := g_supply_asg_count + 1;
5072 debug('Incrementing supply teacher count',90);
5073 END IF;
5074
5075 -- Bugfix 3641851:ENH6
5076 -- Increment the part time assignment count if the asg is part time
5077 -- Bugfix 3734942
5078 -- Moved the increment of part time asg count into the
5079 -- IF logic below coz we don't always want to increment
5080 -- We only increment if this assignment is the one
5081 -- to replace the teacher start date now.
5082 -- Otherwise, we just store the event and increment
5083 -- only when the event is being processed, i.e. only
5084 -- increment part time asg count when the event actually
5085 -- happens, not from the start of the period itself
5086 --IF l_asg_details.ext_emp_cat_cd = 'P' THEN
5087 -- g_part_time_asg_count := g_part_time_asg_count + 1;
5088 -- debug('Incrementing part time assignment count',100);
5089 --END IF;
5090
5091 -- Setting NULL before deciding if an event is needed
5092 -- for this sec asg. NULLing as there mite be an event
5093 -- stored from prvious asg
5094 l_starter_event := NULL;
5095
5096 -- Bugfix 3073562:GAP6
5097 IF l_first_time
5098 AND -- the primary asg is not being included
5099 (NOT g_ext_asg_details.EXISTS(p_primary_assignment_id))
5100 THEN
5101
5102 debug('First Time and Primary not being included',110);
5103 pqp_gb_tp_pension_extracts.g_ext_asg_details(p_primary_assignment_id) :=
5104 pqp_gb_tp_pension_extracts.g_ext_asg_details(l_sec_asgs.assignment_id);
5105
5106 g_ext_asg_details(p_primary_assignment_id) := g_ext_asg_details(l_sec_asgs.assignment_id);
5107 g_ext_asg_details(p_primary_assignment_id).report_asg := 'N';
5108
5109 -- Bugfix 3470242:GAP4 : We need to store the person id of the primary asg
5110 -- as we have to update the results data for this person id
5111 -- while creating new LOS.
5112 pqp_gb_tp_pension_extracts.g_ext_asg_details(p_primary_assignment_id).person_id := p_person_id;
5113 g_ext_asg_details(p_primary_assignment_id).person_id := p_person_id;
5114
5115 g_ext_asg_details(p_primary_assignment_id).secondary_assignment_id :=
5116 l_sec_asgs.assignment_id;
5117
5118 g_ext_asg_attributes(p_primary_assignment_id) :=
5119 g_ext_asg_attributes(l_pqp_asg_attributes.assignment_id);
5120
5121 IF l_asg_details.ext_emp_cat_cd = 'P' THEN
5122 g_part_time_asg_count := g_part_time_asg_count + 1;
5123 debug('Incrementing part time assignment count',120);
5124 END IF;
5125
5126 -- Bugfix 3803760:TERMASG
5127 g_asg_count := g_asg_count + 1;
5128
5129 l_first_time := FALSE;
5130
5131 ELSIF
5132 ( -- the primary asg is present in g_ext_asg_details
5133 g_ext_asg_details.EXISTS(p_primary_assignment_id)
5134 AND
5135 -- but not to be reported coz we r only reporting on a sec asg
5136 g_ext_asg_details(p_primary_assignment_id).report_asg = 'N'
5137 ) THEN
5138
5139 debug('Not First Time and Primary not being included',130);
5140 -- Then we need to set the sec asgs start and leaver
5141 -- dates into the primary asgs record
5142
5143 -- Bugfix 3734942 : We need to store the events for secondary
5144 -- and primary assignments starting in the middle of the
5145 -- period or starting after the least teacher start date
5146 -- for this person as these are new LOS events
5147
5148 IF (g_ext_asg_details(l_sec_asgs.assignment_id).start_date
5149 >
5150 g_ext_asg_details(p_primary_assignment_id).teacher_start_date
5151 ) THEN
5152
5153 debug('Event for this secondary asg to be recorded', 140);
5154 l_starter_event.event_type := 'SECONDARY_STARTER';
5155 l_starter_event.event_date
5156 := g_ext_asg_details(l_sec_asgs.assignment_id).start_date;
5157 l_starter_event.assignment_id := l_sec_asgs.assignment_id;
5158 IF l_asg_details.ext_emp_cat_cd = 'P' THEN
5159 l_starter_event.pt_asg_count_change := 1;
5160 END IF;
5161
5162 -- Bugfix 3803760:TERMASG
5163 l_starter_event.asg_count_change := 1;
5164
5165 ELSIF (g_ext_asg_details(l_sec_asgs.assignment_id).start_date
5166 < -- Sec asg start date LESS than teacher start date
5167 g_ext_asg_details(p_primary_assignment_id).teacher_start_date
5168 ) THEN
5169
5170 debug('Event for the other stored secondary asg to be recorded', 150);
5171 l_starter_event.event_type := 'SECONDARY_STARTER';
5172 l_starter_event.event_date
5173 := g_ext_asg_details(p_primary_assignment_id).teacher_start_date;
5174 l_starter_event.assignment_id :=
5175 g_ext_asg_details(p_primary_assignment_id).secondary_assignment_id;
5176 -- If the other sec asg is PT the count needs to be incremented
5177 IF g_ext_asg_details(l_starter_event.assignment_id).ext_emp_cat_cd = 'P' THEN
5178 -- Decrement the pt asg count coz we r moving this
5179 -- asgs start date into an event to be processed later
5180 g_part_time_asg_count := g_part_time_asg_count - 1;
5181 l_starter_event.pt_asg_count_change := 1;
5182 END IF;
5183
5184 -- Bugfix 3803760:TERMASG
5185 g_asg_count := g_asg_count - 1;
5186 l_starter_event.asg_count_change := 1;
5187
5188 -- Bugfix 3678324 : Now only assigning secondary assingment id
5189 -- and start date to teacher start date if it is actually
5190 -- less then the already stored teacher start date
5191 -- Previously we were incorrectly storing the sec asgs
5192 -- start date in start date of primary instead of teacher_start_date
5193 -- We were also not assigning the sec asg id into primary row
5194 g_ext_asg_details(p_primary_assignment_id).teacher_start_date
5195 := g_ext_asg_details(l_sec_asgs.assignment_id).start_date;
5196 g_ext_asg_details(p_primary_assignment_id).secondary_assignment_id
5197 := l_sec_asgs.assignment_id;
5198
5199 -- Since this assignment is being stored as teacher start
5200 -- increment the pt asg count if its PT
5201 IF l_asg_details.ext_emp_cat_cd = 'P' THEN
5202 g_part_time_asg_count := g_part_time_asg_count + 1;
5203 debug('Incrementing part time assignment count',160);
5204 END IF;
5205
5206 -- Bugfix 3803760:TERMASG
5207 g_asg_count := g_asg_count + 1;
5208
5209 debug('Teacher start date :'||
5210 to_char(g_ext_asg_details(p_primary_assignment_id).teacher_start_date, 'DD/MM/YYYY')
5211 ,170);
5212 ELSE -- dates are equal
5213 debug('Dates are equal, no event needed', 180);
5214 -- But since this assignment is also on the same
5215 -- date as teacher start, we should increment the
5216 -- pt asg count if this asg is PT. BUT we do have
5217 -- a problem now. If in the next iteration
5218 -- another asg has start date LESS than teacher
5219 -- start date, then the current sec asg will get
5220 -- pushed out and an event will be stored for it.
5221 -- We then hv no way of knowing that the pt asg count
5222 -- sh be decremented more than one times coz
5223 -- two asgs had started on the same date
5224 -- But we will still increment the Pt asg count
5225 -- coz otherwise we will not get 0953 for any
5226 -- asg that has had multi PT asgs for long
5227 -- Drawbak is it will show 0953 even when
5228 -- one of the two asgs that started together
5229 -- leaver resulting in single Pt asgs, but this
5230 -- case will be very rare comparitively
5231 IF l_asg_details.ext_emp_cat_cd = 'P' THEN
5232 g_part_time_asg_count := g_part_time_asg_count + 1;
5233 debug('Incrementing part time assignment count',175);
5234 END IF;
5235
5236 -- Bugfix 3803760:TERMASG
5237 g_asg_count := g_asg_count + 1;
5238
5239 END IF;
5240
5241 -- Not sure bout leaver date logic yet, change later.
5242 --g_ext_asg_details(p_primary_assignment_id).leaver_date :=
5243 -- LEAST(g_ext_asg_details(p_primary_assignment_id).leaver_date
5244 -- ,g_ext_asg_details(l_sec_asgs.assignment_id).leaver_date
5245 -- );
5246
5247 -- Bugfix 3641851:CBF1 : Added ELSE part
5248 ELSE -- Primary assignment is present and is to be reported
5249
5250 debug('Setting teacher start date for Primary asg',190);
5251 -- Bugfix 3641851:CBF1 : Assigning least start date of primary
5252 -- teacher start date (which sh be least of primary start date
5253 -- and previous secondary asg start date, if any) and current
5254 -- sec asg start date to teacher start date of primary asg
5255
5256 -- Bugfix 3734942 : We need to store the events for secondary
5257 -- and primary assignments starting in the middle of the
5258 -- period or starting after the least teacher start date
5259 -- for this person as these are new LOS events
5260
5261 -- Bugfix 3678324 : Now only assigning secondary assingment id
5262 -- and start date to teacher start date if it is actually
5263 -- less then the already stored teacher start date
5264 IF g_ext_asg_details(l_sec_asgs.assignment_id).start_date
5265 < -- Sec asg start date LESS than teacher start date
5266 g_ext_asg_details(p_primary_assignment_id).teacher_start_date THEN
5267
5268 debug('Sec asg start date :'||
5269 to_char(g_ext_asg_details(l_sec_asgs.assignment_id).start_date
5270 ,'DD/MM/YYYY')
5271 ,191);
5272 debug('Primary Tchr Start Date :'||
5273 to_char(g_ext_asg_details(p_primary_assignment_id).teacher_start_date
5274 ,'DD/MM/YYYY HH24:MI')
5275 ,191);
5276 debug('Primary Start Date :'||
5277 to_char(g_ext_asg_details(p_primary_assignment_id).start_date
5278 ,'DD/MM/YYYY HH24:MI')
5279 ,191);
5280 debug('Sec asg id on primary row :'||
5281 to_char(g_ext_asg_details(p_primary_assignment_id).secondary_assignment_id)
5282 ,191);
5283 -- IF teacher start date and start date on primary row are
5284 -- same, and secondary asg id is NULL then the primary is
5285 -- being reported, push it into an event for future processing
5286 -- ELSE it will be another secondary asg being report, push
5287 -- that sec asg into an event as primary wud hv already been
5288 -- pushed into an event in a previous iteration
5289 -- Bugfix 3823873 : Changed secondary_assignment_id IS NULL to
5290 -- is equal to primary asg id
5291 -- This should b the case if this is the first time
5292 -- v r trying to assign a id to secondary_assignment_id
5293 IF ((g_ext_asg_details(p_primary_assignment_id).teacher_start_date
5294 =
5295 g_ext_asg_details(p_primary_assignment_id).start_date
5296 )
5297 AND
5298 (g_ext_asg_details(p_primary_assignment_id).secondary_assignment_id
5299 =
5300 p_primary_assignment_id
5301 )
5302 )
5303 THEN
5304
5305 debug('Storing PRIMARY_STARTER event',192);
5306 -- Event for the primary asg to be recorded
5307 l_starter_event.event_type := 'PRIMARY_STARTER';
5308 l_starter_event.event_date
5309 := g_ext_asg_details(p_primary_assignment_id).start_date;
5310 l_starter_event.assignment_id := p_primary_assignment_id;
5311 IF g_ext_asg_details(p_primary_assignment_id).ext_emp_cat_cd = 'P' THEN
5312 g_part_time_asg_count := g_part_time_asg_count - 1;
5313 l_starter_event.pt_asg_count_change := 1;
5314 END IF;
5315
5316 -- Bugfix 3803760:TERMASG
5317 g_asg_count := g_asg_count - 1;
5318 l_starter_event.asg_count_change := 1;
5319
5320 ELSE
5321
5322 debug('Storing SECONDARY_STARTER event',193);
5323 -- Event for the other stored secondary asg to be recorded
5324 l_starter_event.event_type := 'SECONDARY_STARTER';
5325 l_starter_event.event_date
5326 := g_ext_asg_details(p_primary_assignment_id).teacher_start_date;
5327 l_starter_event.assignment_id :=
5328 g_ext_asg_details(p_primary_assignment_id).secondary_assignment_id;
5329 -- If the other sec asg is PT the count needs to be incremented
5330 IF g_ext_asg_details(l_starter_event.assignment_id).ext_emp_cat_cd = 'P' THEN
5331 -- Decrement the pt asg count coz we r moving this
5332 -- asgs start date into an event to be processed later
5333 g_part_time_asg_count := g_part_time_asg_count - 1;
5334 l_starter_event.pt_asg_count_change := 1;
5335 END IF;
5336
5337 -- Bugfix 3803760:TERMASG
5338 g_asg_count := g_asg_count - 1;
5339 l_starter_event.asg_count_change := 1;
5340
5341 debug('Stored sec asg id :'||to_char(l_starter_event.assignment_id),194);
5342
5343
5344 END IF;
5345
5346 g_ext_asg_details(p_primary_assignment_id).teacher_start_date
5347 := g_ext_asg_details(l_sec_asgs.assignment_id).start_date;
5348 g_ext_asg_details(p_primary_assignment_id).secondary_assignment_id
5349 := l_sec_asgs.assignment_id;
5350
5351 -- Since this assignment is being stored as teacher start
5352 -- increment the pt asg count if its PT
5353 IF l_asg_details.ext_emp_cat_cd = 'P' THEN
5354 g_part_time_asg_count := g_part_time_asg_count + 1;
5355 debug('Incrementing part time assignment count',200);
5356 END IF;
5357
5358 -- Bugfix 3803760:TERMASG
5359 g_asg_count := g_asg_count + 1;
5360
5361 debug('Teacher start date :'||
5362 to_char(g_ext_asg_details(p_primary_assignment_id).teacher_start_date, 'DD/MM/YYYY')
5363 ,210);
5364
5365 ELSIF g_ext_asg_details(l_sec_asgs.assignment_id).start_date
5366 > -- Sec asg start date GREATER than teacher start date
5367 g_ext_asg_details(p_primary_assignment_id).teacher_start_date THEN
5368
5369 debug('Event for this secondary asg to be recorded', 220);
5370 l_starter_event.event_type := 'SECONDARY_STARTER';
5371 l_starter_event.event_date
5372 := g_ext_asg_details(l_sec_asgs.assignment_id).start_date;
5373 l_starter_event.assignment_id := l_sec_asgs.assignment_id;
5374 IF l_asg_details.ext_emp_cat_cd = 'P' THEN
5375 l_starter_event.pt_asg_count_change := 1;
5376 END IF;
5377
5378 -- Bugfix 3803760:TERMASG
5379 l_starter_event.asg_count_change := 1;
5380
5381 ELSE -- dates are equal
5382 debug('Dates are equal, no event needed', 230);
5383 -- But since this assignment is also on the same
5384 -- date as teacher start, we should increment the
5385 -- pt asg count if this asg is PT. BUT we do have
5386 -- a problem now. If in the next iteration
5387 -- another asg has start date LESS than teacher
5388 -- start date, then the current sec asg will get
5389 -- pushed out and an event will be stored for it.
5390 -- We then hv no way of knowing that the pt asg count
5391 -- sh be decremented more than one times coz
5392 -- two asgs had started on the same date
5393 -- But we will still increment the Pt asg count
5394 -- coz otherwise we will not get 0953 for any
5395 -- asg that has had multi PT asgs for long
5396 -- Drawbak is it will show 0953 even when
5397 -- one of the two asgs that started together
5398 -- leaver resulting in single Pt asgs, but this
5399 -- case will be very rare comparitively
5400 IF l_asg_details.ext_emp_cat_cd = 'P' THEN
5401 g_part_time_asg_count := g_part_time_asg_count + 1;
5402 debug('Incrementing part time assignment count',175);
5403 END IF;
5404
5405 -- Bugfix 3803760:TERMASG
5406 g_asg_count := g_asg_count + 1;
5407
5408 END IF;
5409
5410 END IF; -- IF l_first_time
5411
5412 debug('Teacher start date :'||
5413 to_char(g_ext_asg_details(p_primary_assignment_id).teacher_start_date, 'DD/MM/YYYY')
5414 ,240);
5415
5416 -- Store the starter event as a new line of service event
5417 IF l_starter_event.event_date IS NOT NULL THEN
5418 debug('Storing the starter event', 250);
5419 l_new_event_itr := g_asg_events.COUNT+1;
5420 g_asg_events(l_new_event_itr) := l_starter_event;
5421 END IF;
5422
5423 END IF; -- 2) l_inclusion_flag = 'Y' THEN
5424 --
5425 END IF; -- 1) l_inclusion_flag = 'Y' THEN
5426
5427 -- Reset local variables to default values
5428 -- before processing next secondary assingnment
5429 l_inclusion_flag := 'Y';
5430 l_leaver := 'N';
5431 l_leaver_date := NULL;
5432
5433 END LOOP; -- l_sec_asg_details IN csr_sec_asg_details
5434
5435 debug_exit(l_proc_name);
5436 --
5437 RETURN;
5438 --
5439 EXCEPTION
5440 WHEN OTHERS THEN
5441 debug_exit(' Others in '||l_proc_name);
5442 RAISE;
5443 END; -- fetch_secondary_assignments
5444
5445 --
5446 -- Return secondary assignments that are effective and in the future
5447 --
5448 FUNCTION get_all_secondary_asgs
5449 (p_primary_assignment_id IN NUMBER
5450 ,p_effective_date IN DATE
5451 ) RETURN t_sec_asgs_type
5452 IS
5453
5454 -- Rowtype Variable Declaration
5455 l_sec_asgs csr_sec_assignments%ROWTYPE;
5456 l_all_sec_asgs t_sec_asgs_type;
5457 --
5458 l_proc_name VARCHAR2(61):=
5459 g_proc_name||'get_all_secondary_asgs';
5460
5461 BEGIN -- get_all_secondary_asgs
5462
5463 debug_enter(l_proc_name);
5464
5465 -- Fetch secondary assignments and save them only if
5466 -- Teacher has elected pension.
5467 -- However, find the leaver date for all secondary asgs.
5468 FOR l_sec_asgs IN csr_sec_assignments(p_primary_assignment_id
5469 ,g_ext_asg_details(p_primary_assignment_id).person_id
5470 ,p_effective_date
5471 )
5472 LOOP
5473
5474 -- If the secondary assignment is part of the global ASG collection
5475 IF g_ext_asg_details.EXISTS(l_sec_asgs.assignment_id) THEN
5476
5477 -- Add this to the table of valid secondary asgs
5478 l_all_sec_asgs(l_sec_asgs.assignment_id) := l_sec_asgs;
5479
5480 END IF; -- g_ext_asg_details.EXISTS(l_sec_asgs.assignment_id) THEN
5481 --
5482 END LOOP; -- l_sec_asg_details IN csr_sec_asg_details
5483
5484 debug_exit(l_proc_name);
5485 --
5486 RETURN l_all_sec_asgs;
5487 --
5488 EXCEPTION
5489 WHEN OTHERS THEN
5490 debug_exit(' Others in '||l_proc_name);
5491 RAISE;
5492 END; -- get_all_secondary_asgs
5493
5494 --
5495 -- Return secondary assignments that are effective only
5496 --
5497 FUNCTION get_eff_secondary_asgs
5498 (p_primary_assignment_id IN NUMBER
5499 ,p_effective_date IN DATE
5500 ) RETURN t_sec_asgs_type
5501 IS
5502
5503 -- Rowtype Variable Declaration
5504 l_sec_asgs csr_eff_sec_assignments%ROWTYPE;
5505 l_eff_sec_asgs t_sec_asgs_type;
5506 --
5507 l_proc_name VARCHAR2(61):=
5508 g_proc_name||'get_eff_secondary_asgs';
5509
5510 BEGIN -- get_eff_secondary_asgs
5511
5512 debug_enter(l_proc_name);
5513 debug('p_primary_assignment_id ' || p_primary_assignment_id, 10) ;
5514 debug('p_effective_date ' || p_effective_date, 20) ;
5515 debug('g_effective_run_date ' || g_effective_run_date, 30) ;
5516
5517
5518 -- Fetch secondary assignments and save them only if
5519 -- Teacher has elected pension.
5520 -- However, find the leaver date for all secondary asgs.
5521 FOR l_sec_asgs IN csr_eff_sec_assignments(p_primary_assignment_id
5522 ,g_ext_asg_details(p_primary_assignment_id).person_id
5523 ,p_effective_date
5524 )
5525 LOOP
5526 debug('l_sec_asgs.assignment_id ' || l_sec_asgs.assignment_id, 50) ;
5527 -- If the secondary assignment is part of the global ASG collection
5528 IF g_ext_asg_details.EXISTS(l_sec_asgs.assignment_id) THEN
5529
5530 debug(l_proc_name,60);
5531 debug('teacher_start_date ' || g_ext_asg_details(l_sec_asgs.assignment_id).teacher_start_date) ;
5532 debug('leaver_date ' || g_ext_asg_details(l_sec_asgs.assignment_id).leaver_date) ;
5533 debug('restarter_date ' || g_ext_asg_details(l_sec_asgs.assignment_id).restarter_date) ;
5534
5535 -- MULT-LR --
5536 -- Use the new Function to check the effectivness of an assignment
5537 -- it takes care of multiple Leaver-Restarter events
5538 -- where as the old logic used to take into account
5539 -- only the first restarter event.
5540 IF ( chk_effective_asg ( p_assignment_id => l_sec_asgs.assignment_id
5541 ,p_effective_date => p_effective_date
5542 ) = 'Y' ) THEN
5543 debug(l_proc_name,70);
5544 -- Add this to the table of valid secondary asgs
5545 l_eff_sec_asgs(l_sec_asgs.assignment_id) := l_sec_asgs;
5546
5547 END IF ; --Valid Tchr in the period
5548
5549 END IF; -- g_ext_asg_details.EXISTS(l_sec_asgs.assignment_id) THEN
5550 --
5551 END LOOP; -- l_sec_asg_details IN csr_sec_asg_details
5552
5553 debug_exit(l_proc_name);
5554 --
5555 RETURN l_eff_sec_asgs;
5556 --
5557 EXCEPTION
5558 WHEN OTHERS THEN
5559 debug_exit(' Others in '||l_proc_name);
5560 RAISE;
5561 END; -- get_eff_secondary_asgs
5562
5563 --
5564 -- set_effective_assignments
5565 --
5566 -- Bugfix 3803760:FTSUPPLY
5567 -- New Function to check all assignments for effectiveness
5568 -- Purpose : Chcks all assignments for effectiveness and
5569 -- do the following considering the new rule where
5570 -- if any assignment is FT, only process that assignment
5571 -- and leave out the other assignments
5572 -- 1) If primary assignment is effecitve and FT, set it as
5573 -- g_override_ft_asg_id and do not get secondary assignments
5574 -- 2) If primary not FT, then call get_eff_secondary_asgs.
5575 -- 3) If any effective secondary is FT, set it as override and
5576 -- add to g_tab_sec_asgs
5577 -- 4) If no secondary is FT, store all effective secondary
5578 -- asgs in g_tab_sec_asgs
5579 --
5580 PROCEDURE set_effective_assignments
5581 (p_primary_assignment_id IN NUMBER
5582 ,p_effective_date IN DATE
5583 )
5584 IS
5585
5586 -- Rowtype Variable Declaration
5587 l_sec_asgs csr_eff_sec_assignments%ROWTYPE;
5588 l_sec_asg_id per_all_assignments_f.assignment_id%TYPE;
5589 l_tab_eff_sec_asgs t_sec_asgs_type;
5590 l_rep_primary_asg VARCHAR2(1);
5591 l_prev_asg_id per_all_assignments_f.assignment_id%TYPE;
5592
5593 l_asg_details csr_asg_details_up%ROWTYPE;
5594
5595 --
5596 l_proc_name VARCHAR2(61):=
5597 g_proc_name||'set_effective_assignments';
5598
5599 BEGIN
5600
5601 debug_enter(l_proc_name);
5602 debug('p_primary_assignment_id ' || p_primary_assignment_id, 10) ;
5603 debug('p_effective_date ' || p_effective_date, 20) ;
5604 debug('g_effective_run_date ' || g_effective_run_date, 30) ;
5605
5606 g_override_ft_asg_id := NULL;
5607 g_tab_sec_asgs.DELETE;
5608
5609 -- Bugfix 3880543:REHIRE : Done this as we need to nominate one
5610 -- sec asg for reporting if primary is not valid
5611
5612 -- MULT-LR --
5613 -- Use the new Function to check the effectivness of an assignment
5614 -- it takes care of multiple Leaver-Restarter events
5615 -- where as the old logic used to take into account
5616 -- only the first restarter event.
5617 l_rep_primary_asg := chk_effective_asg (
5618 p_assignment_id => p_primary_assignment_id
5619 ,p_effective_date => p_effective_date
5620 );
5621
5622 IF (l_rep_primary_asg = 'Y'
5623 )
5624 AND
5625 (get_ext_emp_cat_cd
5626 (p_assignment_id => p_primary_assignment_id
5627 ,p_effective_date => p_effective_date
5628 ) = 'F'
5629 ) THEN
5630
5631 g_override_ft_asg_id := p_primary_assignment_id;
5632 debug('Primary asg is FT, setting as override', 40);
5633
5634 ELSE -- check the secondary assignments
5635
5636 debug('Getting effective sec asgs', 50);
5637 l_tab_eff_sec_asgs := get_eff_secondary_asgs
5638 (p_primary_assignment_id => p_primary_assignment_id
5639 ,p_effective_date => p_effective_date
5640 );
5641
5642 -- Bugfix 3880543:REHIRE : We are now setting the first sec asg id
5643 -- as the secondary_assignment in row for the primary.
5644 -- And then the 2nd sec asg id in as secondary_assignment
5645 -- in the row for 1st sec asg and so on
5646 l_prev_asg_id := p_primary_assignment_id;
5647 l_sec_asg_id := l_tab_eff_sec_asgs.FIRST;
5648 WHILE l_sec_asg_id IS NOT NULL
5649 LOOP
5650
5651 debug('Processing sec asg id :'||to_char(l_sec_asg_id), 60);
5652 IF get_ext_emp_cat_cd
5653 (p_assignment_id => l_sec_asg_id
5654 ,p_effective_date => p_effective_date
5655 ) = 'F' -- Full time
5656 THEN
5657
5658 debug('This sec asg is FT, setting as override', 70);
5659
5660 g_tab_sec_asgs.DELETE;
5661 g_tab_sec_asgs(l_sec_asg_id) := l_tab_eff_sec_asgs(l_sec_asg_id);
5662 g_override_ft_asg_id := l_sec_asg_id;
5663
5664 -- Bugfix 3880543:REHIRE : Need to nomindate this sec for reporting
5665 -- coz its the FT asg
5666 g_ext_asg_details(p_primary_assignment_id).secondary_assignment_id
5667 := g_override_ft_asg_id;
5668 EXIT;
5669
5670 ELSE
5671
5672 debug('Adding this sec asg to global collection', 80);
5673 g_tab_sec_asgs(l_sec_asg_id) := l_tab_eff_sec_asgs(l_sec_asg_id);
5674
5675 -- Bugfix 3880543:REHIRE : Need to nominate one sec for reporting if
5676 -- primary OR the current secondary is not to be reported,
5677 -- The first secondary asg will b stored in secondary_assignment_id
5678 -- in the row for primary asg
5679 -- In the future if needed we can add logic to choose the
5680 -- secondary asg based on some criteria
5681 g_ext_asg_details(l_prev_asg_id).secondary_assignment_id := l_sec_asg_id;
5682
5683 END IF;
5684
5685 -- Set the current as previous
5686 l_prev_asg_id := l_sec_asg_id;
5687
5688 -- Get the next secondary assignment
5689 l_sec_asg_id := l_tab_eff_sec_asgs.NEXT(l_sec_asg_id);
5690
5691 END LOOP;
5692 debug('Total eff sec asgs :'||to_char(g_tab_sec_asgs.COUNT), 90);
5693
5694 END IF; -- (l_rep_primary_asg
5695
5696 debug('Override FT Assignment ID :'||to_char(nvl(g_override_ft_asg_id, -1)), 100);
5697
5698 -- If the override asg was found re-evaluate the asg details
5699 -- as of effective date and store in g_ext_asg_details
5700 IF g_override_ft_asg_id IS NOT NULL
5701 AND
5702 -- If effective date is > teacher start date
5703 -- this sh b for a new line, we should refresh
5704 -- some columns on g_ext_asg_details for the override
5705 -- asg as new values need to be used. For the first
5706 -- line, the values should be current
5707 p_effective_date > g_ext_asg_details(p_primary_assignment_id).teacher_start_date THEN
5708
5709 OPEN csr_asg_details_up
5710 (g_override_ft_asg_id
5711 ,p_effective_date
5712 );
5713 FETCH csr_asg_details_up INTO l_asg_details;
5714 IF csr_asg_details_up%NOTFOUND THEN
5715 -- This situation should never happen,
5716 debug('IMP : This situation should never happen', 100);
5717 NULL;
5718 ELSE -- asg record FOUND
5719
5720 IF l_asg_details.location_id IS NOT NULL
5721 AND
5722 pqp_gb_tp_pension_extracts.g_criteria_estbs.EXISTS(l_asg_details.location_id) THEN
5723
5724
5725 debug('Re-evaluating override asg details', 110);
5726 -- Setting the current ext_emp_cat_cd, location_id and estb_number
5727 g_ext_asg_details(g_override_ft_asg_id).ext_emp_cat_cd := 'F';
5728 debug('l_asg_details.location_id :'||to_char(l_asg_details.location_id), 111);
5729 g_ext_asg_details(g_override_ft_asg_id).location_id := l_asg_details.location_id;
5730 debug('g_ext_asg_details(g_override_ft_asg_id).estb_number :'||g_ext_asg_details(g_override_ft_asg_id).estb_number, 111);
5731 debug('Estb number in Global :'||pqp_gb_tp_pension_extracts.g_criteria_estbs(l_asg_details.location_id).estb_number, 112);
5732 g_ext_asg_details(g_override_ft_asg_id).estb_number :=
5733 pqp_gb_tp_pension_extracts.g_criteria_estbs(l_asg_details.location_id).estb_number;
5734
5735 ELSE
5736 debug('WARNING: This asg might hv multiple leaver events', 113);
5737 END IF;
5738
5739 END IF;
5740 debug('After IF Asg_Record_Found ' , 114);
5741
5742 CLOSE csr_asg_details_up;
5743
5744 END IF; -- g_override_ft_asg_id IS NOT NULL
5745
5746 debug_exit(l_proc_name);
5747 --
5748 RETURN;
5749 --
5750 EXCEPTION
5751 WHEN OTHERS THEN
5752 debug('SQLCODE :'||to_char(SQLCODE), 150);
5753 debug('SQLERRM :'||SQLERRM, 160);
5754 debug_exit(' Others in '||l_proc_name);
5755 RAISE;
5756 END; -- set_effective_assignments
5757
5758 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5759 -- ~ To get the corresponding Pension Extract Emp Category code ~
5760 -- ~ and Pension Extract Working Pattern Code ~
5761 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5762 Function Get_Translate_Asg_Emp_Cat_Code (p_asg_emp_cat_cd in varchar2
5763 ,p_effective_date in Date
5764 ,p_udt_column_name in varchar2
5765 ,p_business_group_id IN NUMBER
5766 ) Return Varchar2 Is
5767
5768 l_proc_name varchar2(70):= g_proc_name||'Get_Translate_Asg_Emp_Cat_Code';
5769 l_udt_value VARCHAR2(1):= '?';
5770
5771 Cursor csr_get_emp_cat_code (c_effective_date in date
5772 ,c_asg_emp_cat_cd in varchar2
5773 ,c_udt_column_name in varchar2
5774 ,c_business_group_id in number
5775 ,c_legislation_code in varchar2) Is
5776 Select extv.value,extv.business_group_id
5777 From pay_user_tables tbls
5778 ,pay_user_columns asgc
5779 ,pay_user_columns extc
5780 ,pay_user_rows_f urws
5781 ,pay_user_column_instances_f asgv
5782 ,pay_user_column_instances_f extv
5783 where tbls.user_table_name ='PQP_GB_TP_EMPLOYMENT_CATEGORY_TRANSALATION_TABLE'
5784 and asgc.user_table_id = tbls.user_table_id
5785 and extc.user_table_id = tbls.user_table_id
5786 and asgc.user_column_name = 'Assignment Employment Category Lookup Code'
5787 and extc.user_column_name = c_udt_column_name
5788 and urws.user_table_id = tbls.user_table_id
5789 and (urws.business_group_id = c_business_group_id
5790 OR
5791 (urws.business_group_id IS NULL
5792 AND urws.legislation_code = c_legislation_code)
5793 OR
5794 (urws.business_group_id IS NULL AND urws.legislation_code IS NULL)
5795 )
5796 and c_effective_date BETWEEN urws.effective_start_date
5797 AND urws.effective_end_date
5798 and asgv.user_column_id = asgc.user_column_id
5799 and c_effective_date BETWEEN asgv.effective_start_date
5800 AND asgv.effective_end_date
5801 and extv.user_column_id = extc.user_column_id
5802 and c_effective_date BETWEEN extv.effective_start_date
5803 AND extv.effective_end_date
5804 and asgv.user_row_id = urws.user_row_id
5805 and extv.user_row_id = asgv.user_row_id
5806 and asgv.value = c_asg_emp_cat_cd;
5807
5808 Begin
5809 debug_enter(l_proc_name);
5810 debug('c_effective_date : '|| to_char(NVL(p_effective_date,g_effective_date)),10);
5811 debug('p_asg_emp_cat_cd : '|| p_asg_emp_cat_cd);
5812 debug('p_udt_column_name : '|| p_udt_column_name);
5813
5814 -- Changed the procedure to return business group level values if values are defined both at Legislation
5815 -- and Business Group Level Bug 5498514
5816 FOR l_idx in csr_get_emp_cat_code (c_effective_date => NVL(p_effective_date,g_effective_date)
5817 ,c_asg_emp_cat_cd => p_asg_emp_cat_cd
5818 ,c_udt_column_name => p_udt_column_name
5819 ,c_business_group_id => p_business_group_id
5820 ,c_legislation_code => g_legislation_code
5821 ) LOOP
5822 -- Fetch csr_get_emp_cat_code Into l_udt_value;
5823
5824 -- Added by Babu and Raju as a fix for Invalid Emp Cat warning
5825 -- Date : 10/04/2002
5826 -- Assigns value if leg level data and no bg level data exists
5827 -- If bg level data exists always use the same
5828 IF (l_idx.business_group_id IS NULL AND l_udt_value = '?') OR
5829 (l_idx.business_group_id IS NOT NULL AND l_idx.value IS NOT NULL) THEN
5830 l_udt_value := l_idx.value;
5831 END IF;
5832 END LOOP;
5833
5834 IF l_udt_value = '?' THEN
5835 l_udt_value := NULL;
5836 END IF;
5837
5838 -- END LOOP;
5839 -- Close csr_get_emp_cat_code;
5840
5841 debug('Return Value :'||l_udt_value, 20);
5842 debug_exit(l_proc_name);
5843 RETURN l_udt_value;
5844
5845 Exception
5846 When No_Data_Found Then
5847 --debug('No Data Found in Translate UDT');
5848 --debug_exit;
5849 debug_exit(' No Data Found in '||l_proc_name);
5850 l_udt_value := NULL;
5851 Return l_udt_value;
5852 WHEN OTHERS THEN
5853 debug_exit(' Others in '||l_proc_name);
5854 RAISE;
5855 End Get_Translate_Asg_Emp_Cat_Code;
5856
5857 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5858 -- ~ Function returns the special class rules for teachers, based on emp category code ~
5859 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5860 Function Get_Special_ClassRule ( p_assignment_id in number
5861 ,p_effective_date in date
5862 ) Return varchar2 Is
5863
5864 Cursor csr_get_empcat ( c_assignment_id in number
5865 ,c_effective_date in date ) Is
5866 Select paa.employment_category
5867 from per_all_assignments_f paa
5868 where paa.assignment_id = c_assignment_id
5869 and c_effective_date between paa.effective_start_date
5870 and paa.effective_end_date;
5871 l_assig_emp_catcode per_all_assignments_f.employment_category%TYPE;
5872 l_pension_ext_empcode per_all_assignments_f.employment_category%TYPE;
5873 l_pension_ext_wrkpat per_all_assignments_f.employment_category%TYPE;
5874 l_return_value varchar2(7) :=' ';
5875 l_error_value number;
5876 l_proc_name varchar2(70):= g_proc_name||'Get_Special_ClassRule';
5877
5878 Begin
5879 debug_enter(l_proc_name);
5880 Open csr_get_empcat ( c_assignment_id => p_assignment_id
5881 ,c_effective_date => p_effective_date);
5882 Fetch csr_get_empcat Into l_assig_emp_catcode;
5883 If csr_get_empcat%NOTFOUND Then
5884 Close csr_get_empcat;
5885 l_return_value := 'UNKNOWN';
5886 Else
5887 Close csr_get_empcat;
5888
5889 debug('Get the Pension Ext EmpCat and WrkPat codes', 10);
5890
5891 -- Bugfix 3073562:GAP1:GAP2
5892 -- Only use cached copies if the assignment is frm
5893 -- the current BG, otherwise fetch from DB
5894 If g_ext_asg_details(p_assignment_id).business_group_id = g_business_group_id
5895 AND
5896 l_assig_emp_catcode = g_asg_emp_cat_cd
5897 And
5898 g_ext_emp_cat_cd Is Not Null Then
5899
5900 l_pension_ext_empcode := g_ext_emp_cat_cd;
5901 l_pension_ext_wrkpat := g_ext_emp_wrkp_cd;
5902
5903 Else
5904 l_pension_ext_empcode := Get_Translate_Asg_Emp_Cat_Code
5905 (p_asg_emp_cat_cd => l_assig_emp_catcode
5906 ,p_effective_date => p_effective_date
5907 ,p_udt_column_name => 'Pension Extracts Employment Category Code'
5908 ,p_business_group_id =>
5909 g_ext_asg_details(p_assignment_id).business_group_id
5910 );
5911 l_pension_ext_wrkpat := Get_Translate_Asg_Emp_Cat_Code
5912 (p_asg_emp_cat_cd => l_assig_emp_catcode
5913 ,p_effective_date => p_effective_date
5914 ,p_udt_column_name => 'Pension Extracts Working Pattern Code'
5915 ,p_business_group_id =>
5916 g_ext_asg_details(p_assignment_id).business_group_id
5917 );
5918
5919 l_pension_ext_empcode := nvl(l_pension_ext_empcode,'F');
5920 l_pension_ext_wrkpat := nvl(l_pension_ext_wrkpat,'R');
5921
5922 -- Bugfix 3073562:GAP1:GAP2
5923 -- Update the globals with new values only for current BG
5924 IF g_ext_asg_details(p_assignment_id).business_group_id = g_business_group_id THEN
5925 debug(l_proc_name, 20);
5926 g_asg_emp_cat_cd := l_assig_emp_catcode;
5927 g_ext_emp_cat_cd := l_pension_ext_empcode;
5928 g_ext_emp_wrkp_cd := l_pension_ext_wrkpat;
5929 END IF;
5930 End If;
5931 End If;
5932
5933 debug('Check the conditions', 30);
5934
5935 If l_pension_ext_empcode Is Not Null And
5936 l_pension_ext_empcode ='F' Then
5937 l_return_value := '0';
5938 Elsif l_pension_ext_empcode ='P' And
5939 l_pension_ext_wrkpat Is Not Null Then
5940
5941 If l_pension_ext_wrkpat ='R' Then
5942 l_return_value := '7';
5943 Elsif l_pension_ext_wrkpat ='T' Then
5944 l_return_value := '8';
5945 Else
5946 l_return_value := 'INVALID';
5947 End If;
5948 Else
5949 l_return_value := 'INVALID';
5950
5951 End If;
5952 debug('Return Value :'||l_return_value, 40);
5953 debug_exit(l_proc_name);
5954 Return l_return_value;
5955 EXCEPTION
5956 WHEN OTHERS THEN
5957 debug_exit(' Others in '||l_proc_name);
5958 RAISE;
5959 End Get_Special_ClassRule;
5960
5961 Function Get_Allowance_Code ( p_assignment_id in number
5962 ,p_effective_date in date
5963 ,p_allowance_type in varchar2 ) Return varchar2 Is
5964 --
5965 -- Cursor to get the element_type_id
5966 --
5967 Cursor csr_ele_type_id ( c_element_name in varchar2
5968 ,c_effective_date in date ) Is
5969 Select pet.element_type_id
5970 from pay_element_types_f pet
5971 where c_effective_date between pet.effective_start_date
5972 and pet.effective_end_date
5973 and pet.element_name = c_element_name;
5974 --
5975 -- Cursor to check if the element exits in element entries
5976 --
5977 Cursor csr_ele_entries ( c_assignment_id in number
5978 ,c_effective_date in date
5979 ,c_element_type_id in number ) Is
5980 Select pee.element_entry_id
5981 from pay_element_entries_f pee
5982 ,pay_element_links_f pel
5983 where pee.assignment_id = c_assignment_id
5984 and pel.element_link_id = pee.element_link_id
5985 and pel.element_type_id = c_element_type_id
5986 and c_effective_date between pee.effective_start_date
5987 and pee.effective_end_date
5988 and c_effective_date between pel.effective_start_date
5989 and pel.effective_end_date;
5990
5991 Type t_allowance_code Is Table of varchar2(1) Index By BINARY_INTEGER;
5992
5993 l_udt_allowance_code t_allowance_code;
5994 l_allowance_code varchar2(1);
5995 l_element_name pay_element_types_f.element_name%TYPE;
5996 l_input_value_name pay_input_values_f.name%TYPE;
5997 l_element_type_id pay_element_types_f.element_type_id%TYPE;
5998 l_element_entry_id pay_element_entries_f.element_entry_id%TYPE;
5999 l_count_ele_entries Number;
6000 l_return_value char(7) := ' ';
6001 l_error_value number;
6002 l_proc_name varchar2(60) := g_proc_name || 'Get_Allowance_Code';
6003
6004 -- 4336613 : LARP_SPAP_3A : new local variable to hold count of LARP/SPAP entries in UDT
6005 l_larp_spap_count NUMBER;
6006
6007
6008 Begin
6009 -- hr_utility.set_location('Entering: '||l_proc_name, 5);
6010 debug_enter(l_proc_name);
6011 debug('p_allowance_type :'||p_allowance_type, 10);
6012 l_count_ele_entries := 0;
6013 For i in 1..4 Loop
6014 l_udt_allowance_code(i) := Null;
6015 End Loop;
6016 --
6017 -- check if the assignment has one or more element entry as defined in the UDT
6018 --
6019
6020
6021 -- 4336613 : LARP_SPAP_3A : depending on LARP/SPAP entries being considered,
6022 -- assign number of entried to l_larp_spap_count to be used in for loop
6023 -- incase none are found, raise a warning (instead of an error as was being
6024 -- done earlier)
6025 IF p_allowance_type = 'LONDON_ALLOWANCE_RULE' THEN
6026 l_larp_spap_count := g_udt_element_LondAll.COUNT;
6027 ELSIF p_allowance_type = 'SPECIAL_ALLOWANCE_RULE' THEN
6028 l_larp_spap_count := g_udt_element_SpcAll.COUNT;
6029 ELSE
6030 l_error_value := pqp_gb_tp_extract_functions.raise_extract_error
6031 (p_business_group_id => g_business_group_id
6032 ,p_assignment_id => p_assignment_id
6033 ,p_error_text =>'BEN_93024_EXT_TP1_INVALID_ALOW'
6034 ,p_error_number => 93024 );
6035 END IF;
6036
6037
6038 For i_idx in 1..l_larp_spap_count Loop -- 4336613 : LARP_SPAP_3A : now from 1 to
6039 -- l_larp_spap instead of 1 to 4
6040 debug('Idx :'||to_char(i_idx), 20);
6041 If p_allowance_type = 'LONDON_ALLOWANCE_RULE' Then
6042 l_allowance_code := g_udt_element_LondAll(i_idx).allowance_code;
6043 l_element_name := g_udt_element_LondAll(i_idx).element_name;
6044 l_input_value_name := g_udt_element_LondAll(i_idx).input_value_name;
6045 Elsif p_allowance_type = 'SPECIAL_ALLOWANCE_RULE' Then
6046 l_allowance_code := g_udt_element_SpcAll(i_idx).allowance_code;
6047 l_element_name := g_udt_element_SpcAll(i_idx).element_name;
6048 l_input_value_name := g_udt_element_SpcAll(i_idx).input_value_name;
6049
6050 End if;
6051 debug('Checking if : '||l_element_name ||' is defined', 30);
6052 Open csr_ele_type_id ( c_element_name => l_element_name
6053 ,c_effective_date => p_effective_date);
6054 Fetch csr_ele_type_id Into l_element_type_id;
6055
6056 If csr_ele_type_id%NOTFOUND Then
6057 Close csr_ele_type_id;
6058 l_error_value := pqp_gb_tp_extract_functions.raise_extract_error
6059 (p_business_group_id => g_business_group_id
6060 ,p_assignment_id => p_assignment_id
6061 ,p_error_text => 'BEN_93026_EXT_TP1_ELE_NOTEXIST'
6062 ,p_error_number => 93026
6063 ,p_token1 => l_element_name
6064 );
6065
6066 Else
6067 Close csr_ele_type_id;
6068 debug('Checking for : '||l_element_name||' in element entries', 40);
6069 Open csr_ele_entries ( c_assignment_id => p_assignment_id
6070 ,c_effective_date => p_effective_date
6071 ,c_element_type_id => l_element_type_id);
6072 Fetch csr_ele_entries Into l_element_entry_id;
6073 If csr_ele_entries%FOUND Then
6074 -- Check to see if their are multiple entries for the element
6075 -- for the same pay period; if found raise error
6076 debug(l_proc_name, 50);
6077 l_count_ele_entries := l_count_ele_entries + 1;
6078 Fetch csr_ele_entries Into l_element_entry_id;
6079 If csr_ele_entries%FOUND Then
6080 debug('More than one entry found for element :'||l_element_name, 60);
6081 l_count_ele_entries := l_count_ele_entries + 1;
6082 Else
6083 debug('Idx :'||to_char(i_idx)||' l_allowance_code :'||l_allowance_code, 70);
6084 l_udt_allowance_code(i_idx):= l_allowance_code;
6085 End If;
6086 Else
6087 debug('Setting NULL', 80);
6088 l_udt_allowance_code(i_idx):= Null;
6089 End If;
6090 Close csr_ele_entries;
6091 End If;
6092 -- If the assignment has more than one element then exit and raise error
6093 Exit When l_count_ele_entries > 1;
6094
6095 End Loop;
6096 debug(l_proc_name, 90);
6097
6098 If l_count_ele_entries > 1 Then
6099 l_return_value := 'TOOMANY';
6100 Elsif l_count_ele_entries = 0 Then
6101 l_return_value := 'UNKNOWN';
6102 Else
6103 For i in 1..4 Loop
6104 debug(l_proc_name, 100);
6105 If l_udt_allowance_code(i) Is Not Null Then
6106 l_return_value := l_udt_allowance_code(i);
6107 Exit;
6108 End If;
6109 End Loop;
6110 End If;
6111 debug('Return value :'||l_return_value, 110);
6112 debug_exit(l_proc_name);
6113 -- hr_utility.set_location('Leaving: '||l_proc_name, 15);
6114
6115 Return l_return_value;
6116 EXCEPTION
6117 WHEN OTHERS THEN
6118 debug_exit(' Others in '||l_proc_name);
6119 RAISE;
6120 End Get_Allowance_Code;
6121
6122 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6123 -- ~ Function checks the Safeguarded Grade and Fast Track Indicator ~
6124 -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6125 Function Get_Grade_Fasttrack_Info (p_assignment_id In number
6126 ,p_effective_date In date) Return char Is
6127
6128 Cursor csr_get_aat_info (c_assignment_id In number
6129 ,c_effective_date In date ) Is
6130 select assignment_attribute_id
6131 ,assignment_id
6132 ,tp_is_teacher
6133 ,tp_safeguarded_grade
6134 ,tp_fast_track
6135 ,tp_elected_pension
6136 -- added the new column for the new safeguarded logic based on safeguarded rate type
6137 ,tp_safeguarded_rate_type
6138 from pqp_assignment_attributes_f
6139 where assignment_id = c_assignment_id
6140 and c_effective_date between effective_start_date
6141 and effective_end_date
6142 order by effective_start_date;
6143
6144 l_proc_name varchar2(60) := g_proc_name || 'Get_Grade_Fasttrack_Info';
6145 l_aat_info csr_get_aat_info%rowtype;
6146 l_return_value char(1):= ' ';
6147 Begin
6148 -- hr_utility.set_location('Entering: '||l_proc_name, 5);
6149 debug_enter(l_proc_name);
6150 Open csr_get_aat_info
6151 (c_assignment_id => p_assignment_id
6152 ,c_effective_date => p_effective_date
6153 );
6154 Fetch csr_get_aat_info into l_aat_info;
6155
6156 If csr_get_aat_info%FOUND Then
6157 debug(l_proc_name, 10);
6158 -- SFG:4135481 : modified the criteria for deciding safegarded check
6159 -- Instead of using safeguarded grade , now using safeguarded rate type field.
6160 If (l_aat_info.tp_safeguarded_rate_type Is Not Null ) Then
6161 l_return_value := 'S';
6162 Elsif l_aat_info.tp_fast_track ='Y' Then
6163 l_return_value := 'F';
6164 End If;
6165 End If;
6166
6167 Close csr_get_aat_info;
6168
6169 debug('Return value :'||l_return_value, 20);
6170 debug_exit(l_proc_name);
6171 -- hr_utility.set_location('Leaving: '||l_proc_name, 15);
6172
6173 Return l_return_value;
6174
6175 EXCEPTION
6176 WHEN OTHERS THEN
6177 debug_exit(' Others in '||l_proc_name);
6178 RAISE;
6179 End Get_Grade_Fasttrack_Info;
6180
6181 --
6182 -- ----------------------------------------------------------------------------
6183 -- |------------------------< process_element >-------------------------------|
6184 -- ----------------------------------------------------------------------------
6185 function process_element (p_assignment_id in number
6186 ,p_calculation_date in date
6187 ,p_rate_name in varchar2
6188 ,p_rate_type in varchar2
6189 ,p_from_time_dim in varchar2
6190 ,p_to_time_dim in varchar2
6191 ,p_fte in varchar2
6192 ,p_term_time_yes_no in varchar2
6193 )
6194 return number is
6195 --
6196 l_proc_name varchar2(60) := g_proc_name || 'process_element';
6197 l_ele_rate csr_ele_rate_id%rowtype;
6198 l_paa_rate csr_paa_rate_id%rowtype;
6199 l_paa_attribute_id pqp_assignment_attributes_f.assignment_attribute_id%type := null;
6200 l_value number := 0;
6201 --
6202 begin
6203 --
6204 -- hr_utility.set_location('Entering: '||l_proc_name, 10);
6205 --
6206 debug_enter (l_proc_name);
6207
6208 open csr_ele_rate_id (c_rate_name => p_rate_name
6209 ,c_rate_type => p_rate_type);
6210 fetch csr_ele_rate_id into l_ele_rate;
6211 close csr_ele_rate_id;
6212
6213 -- Check whether the rate id is the same in aat
6214 open csr_paa_rate_id (c_assignment_id => p_assignment_id
6215 ,c_effective_date => p_calculation_date
6216 );
6217 loop
6218
6219 debug(l_proc_name, 10);
6220 fetch csr_paa_rate_id into l_paa_rate;
6221 exit when csr_paa_rate_id%notfound;
6222
6223 if l_paa_rate.tp_safeguarded_rate_id = l_ele_rate.rate_id
6224 then
6225
6226 debug(l_proc_name, 15);
6227 l_paa_attribute_id := l_paa_rate.assignment_attribute_id;
6228 exit;
6229 end if; -- end if of rate id check...
6230
6231 end loop;
6232 close csr_paa_rate_id;
6233
6234 if l_paa_attribute_id is not null then
6235
6236 if p_rate_type = 'SP' then
6237
6238 --
6239 debug(l_proc_name, 20);
6240 --
6241 open csr_scale_rate(c_attribute_id => l_paa_attribute_id
6242 ,c_effective_date => p_calculation_date
6243 );
6244 fetch csr_scale_rate into l_value;
6245 close csr_scale_rate;
6246
6247 elsif p_rate_type = 'GR' then
6248
6249 --
6250 debug(l_proc_name, 30);
6251 --
6252 open csr_grade_rate (c_attribute_id => l_paa_attribute_id
6253 ,c_effective_date => p_calculation_date
6254 );
6255 fetch csr_grade_rate into l_value;
6256 close csr_grade_rate;
6257
6258 end if; -- end if of rate type check ...
6259
6260 if l_value is not null then
6261
6262 --
6263 debug(l_proc_name, 40);
6264 --
6265 l_value := pqp_rates_history_calc.convert_values
6266 (p_assignment_id => p_assignment_id
6267 ,p_date => p_calculation_date
6268 ,p_value => l_value
6269 ,p_to_time_dim => p_to_time_dim
6270 ,p_from_time_dim => p_from_time_dim
6271 ,p_fte => p_fte
6272 ,p_service_history => 'N'
6273 ,p_term_time_yes_no => p_term_time_yes_no
6274 );
6275
6276 end if; -- end if of value not null check...
6277
6278 end if; -- end if of attribute id not null check ...
6279
6280 debug('Return Value :'||to_char(l_value), 50);
6281 --
6282 -- hr_utility.set_location('Leaving: '||l_proc_name, 50);
6283 --
6284 debug_exit (l_proc_name);
6285
6286 return l_value;
6287
6288 EXCEPTION
6289 WHEN OTHERS THEN
6290 debug_exit(' Others in '||l_proc_name);
6291 RAISE;
6292 end process_element;
6293 --
6294 -- ----------------------------------------------------------------------------
6295 -- |------------------------< rates_history >---------------------------------|
6296 -- ----------------------------------------------------------------------------
6297 function rates_history (p_assignment_id in number
6298 ,p_calculation_date in date
6299 ,p_rate_type_name in varchar2
6300 ,p_fte in varchar2
6301 ,p_to_time_dim in varchar2
6302 ,p_safeguarded_yn in varchar2
6303 ,p_rate in out nocopy number
6304 )
6305 return number is
6306 --
6307
6308 -- Cursor to check if an element is linked to a assignment
6309
6310 CURSOR c_link_assign (
6311 p_assignment_id IN NUMBER
6312 ,p_element_type_id IN NUMBER
6313 ,p_date IN DATE )IS
6314 select 'Y'
6315 from pay_element_links_f pel
6316 ,pay_element_entries_f pee
6317 ,pay_element_types_f pet
6318 where pet.element_type_id = pel.element_type_id
6319 and pel.element_link_id = pee.element_link_id
6320 and pee.assignment_id = p_assignment_id
6321 and pet.element_type_id = p_element_type_id
6322 and p_date between pel.effective_start_date and
6323 pel.effective_end_date
6324 and p_date between pee.effective_start_date and
6325 pee.effective_end_date
6326 and p_date between pet.effective_start_date and
6327 pet.effective_end_date ;
6328
6329 l_proc_name varchar2(60) := g_proc_name || 'rates_history';
6330 l_element_set csr_element_set%rowtype;
6331 l_service_history pay_element_type_extra_info.eei_information5%type;
6332 l_fte pay_element_type_extra_info.eei_information4%type;
6333 l_pay_source_value pay_element_type_extra_info.eei_information2%type;
6334 l_qualifier pay_element_type_extra_info.eei_information3%type;
6335 l_from_time_dim pay_element_type_extra_info.eei_information1%type;
6336 l_element_rate number := 0;
6337 l_total_rate number := 0;
6338
6339 l_calculation_type pay_element_type_extra_info.eei_information1%type;
6340 l_calculation_value pay_element_type_extra_info.eei_information1%type;
6341 l_input_value pay_element_type_extra_info.eei_information1%type;
6342 l_linked_to_assignment pay_element_type_extra_info.eei_information1%type;
6343 l_term_time_yes_no pay_element_type_extra_info.eei_information1%type;
6344 l_chk_assign_link fnd_lookup_values.lookup_code%TYPE;
6345 l_sum_multiple_entries_yn fnd_lookup_values.lookup_code%TYPE;
6346 l_lookup_input_values_yn fnd_lookup_values.lookup_code%TYPE;
6347 l_column_name_source_type pay_element_type_extra_info.eei_information16%TYPE;
6348 l_column_name_source_name pay_element_type_extra_info.eei_information17%TYPE;
6349 l_row_name_source_type pay_element_type_extra_info.eei_information18%TYPE;
6350 l_row_name_source_name pay_element_type_extra_info.eei_information19%TYPE;
6351
6352
6353 -- Added a new varaibale to hold the element details .
6354 l_element_dtl pqp_gb_tp_pension_extracts.t_allowance_eles;
6355 l_element_type_id NUMBER;
6356 l_count NUMBER := 0;
6357 l_error NUMBER;
6358
6359 l_rate_nc number;
6360 --
6361 BEGIN
6362
6363 -- nocopy changes
6364 l_rate_nc := p_rate;
6365
6366 debug_enter(l_proc_name);
6367
6368 debug('p_assignment_id :'||to_char(p_assignment_id),10);
6369 debug('Calculation Date :'||to_char(p_calculation_date,'dd/mm/yyyy'));
6370 debug('p_rate_type_name :'||p_rate_type_name);
6371 debug('p_fte :'||p_fte);
6372 debug('p_to_time_dim :'||p_to_time_dim);
6373 debug('p_safeguarded_yn :'||p_safeguarded_yn);
6374
6375
6376 BEGIN
6377 -- Get Element Attribution for the given rate type
6378 IF p_rate_type_name IS NULL THEN
6379 -- Retention elements are defined so we need to create the element set
6380 -- using the l_tab_ret_aln_eles
6381 debug('g_tab_ret_aln_eles.COUNT: '||to_char(pqp_gb_tp_pension_extracts.g_tab_ret_aln_eles.COUNT),20);
6382
6383 l_element_dtl := pqp_gb_tp_pension_extracts.g_tab_ret_aln_eles;
6384
6385 ELSE
6386 -- Create the element set from the rate type passed.
6387 OPEN csr_element_set (c_name => p_rate_type_name
6388 ,c_eff_date => p_calculation_date
6389 ,c_business_group_id =>
6390 g_ext_asg_details(p_assignment_id).business_group_id
6391 );
6392 LOOP
6393 FETCH csr_element_set into l_element_set;
6394 EXIT WHEN csr_element_set%NOTFOUND;
6395
6396 debug('element_type_id: '||to_char(l_element_type_id), 30);
6397 debug('element_type_extra_info_id: '||to_char(l_element_set.element_type_extra_info_id));
6398
6399 l_element_dtl(l_element_set.element_type_id).element_type_id
6400 := l_element_set.element_type_id ;
6401 l_element_dtl(l_element_set.element_type_id).element_type_extra_info_id
6402 := l_element_set.element_type_extra_info_id ;
6403 END LOOP;
6404 CLOSE csr_element_set;
6405
6406 END IF ;
6407
6408 debug('l_element_dtl.COUNT: '||l_element_dtl.COUNT, 40) ;
6409 l_element_type_id := l_element_dtl.FIRST;
6410
6411 l_count := 1 ; -- Loop counter ;
6412
6413 WHILE l_element_type_id IS NOT NULL
6414 LOOP
6415 --
6416 debug('element_type_id: '|| l_element_type_id,50+l_count/100 );
6417 --
6418 pqp_rates_history_calc.get_element_attributes
6419 (--p_element_type_extra_info_id => l_element_set.element_type_extra_info_id
6420 p_element_type_extra_info_id => l_element_dtl(l_element_type_id).element_type_extra_info_id
6421 ,p_service_history => l_service_history -- out
6422 ,p_fte => l_fte -- out
6423 ,p_pay_source_value => l_pay_source_value -- out
6424 ,p_qualifier => l_qualifier -- out
6425 ,p_from_time_dim => l_from_time_dim -- out
6426 ,p_calculation_type => l_calculation_type -- out
6427 ,p_calculation_value => l_calculation_value -- out
6428 ,p_input_value => l_input_value -- out
6429 ,p_linked_to_assignment => l_linked_to_assignment -- out
6430 ,p_term_time_yes_no => l_term_time_yes_no -- out
6431 ,p_sum_multiple_entries_yn => l_sum_multiple_entries_yn --out
6432 ,p_lookup_input_values_yn => l_lookup_input_values_yn --out
6433 ,p_column_name_source_type => l_column_name_source_type -- out
6434 ,p_column_name_source_name => l_column_name_source_name -- out
6435 ,p_row_name_source_type => l_row_name_source_type -- out
6436 ,p_row_name_source_name => l_row_name_source_name -- out
6437 );
6438
6439 -- The value Linked to Assignment is Yes indicates that
6440 -- the element should be considered only if it is linked to
6441 -- assignment
6442
6443 IF l_linked_to_assignment = 'Y' THEN
6444
6445 -- Checking whether linked to Assignment
6446
6447 OPEN c_link_assign (
6448 p_assignment_id => p_assignment_id
6449 ,p_element_type_id => l_element_type_id -- l_element_set.element_type_id
6450 ,p_date => p_calculation_date ) ;
6451
6452 FETCH c_link_assign INTO l_chk_assign_link ;
6453 IF c_link_assign%NOTFOUND THEN
6454
6455 -- The element is not linked to assignment
6456 l_chk_assign_link := 'N' ;
6457 END IF ;
6458 CLOSE c_link_assign ;
6459
6460 debug('l_chk_assign_link' ||l_chk_assign_link, 30);
6461
6462 ELSE -- IF l_linked_to_assignment = 'N'
6463
6464 -- Element Need not be Linked to Assignment
6465 l_chk_assign_link := 'Y' ;
6466
6467 END IF ; -- IF l_link_to_assign = 'Y'
6468
6469 debug('l_chk_assign_link' || l_chk_assign_link, 40);
6470 --hr_utility.set_location('l_chk_assign_link' ||l_chk_assign_link, 40);
6471
6472 IF l_chk_assign_link = 'Y' THEN
6473
6474 --debug('Element Type Id :'||l_element_set.element_type_id);
6475 debug('Element Type Id :'||l_element_type_id);
6476 debug('Qualifier :'||l_qualifier);
6477 debug('Pay Source Value :'||l_pay_source_value);
6478
6479 IF l_pay_source_value in ('SP', 'GR') THEN
6480
6481 debug('Pay Source is SP or GR');
6482
6483 -- Check whether process should calculate rate based on safeguarded scale
6484 IF p_safeguarded_yn = 'Y' THEN
6485
6486 --
6487 debug(l_proc_name, 30);
6488 --
6489 l_element_rate :=
6490 process_element -- only processes SP and GR so doesn't need entry value related params
6491 (p_assignment_id => p_assignment_id
6492 ,p_calculation_date => p_calculation_date
6493 ,p_rate_name => l_qualifier
6494 ,p_rate_type => l_pay_source_value
6495 ,p_from_time_dim => l_from_time_dim
6496 ,p_to_time_dim => p_to_time_dim
6497 ,p_fte => p_fte
6498 ,p_term_time_yes_no => l_term_time_yes_no
6499 );
6500
6501 debug('Element Rate for SF :'||l_element_rate);
6502
6503 ELSE -- if not paid on safeguarded scale
6504
6505 --
6506 debug(l_proc_name, 40);
6507 --
6508 l_element_rate := pqp_rates_history_calc.process_element
6509 (p_assignment_id => p_assignment_id
6510 ,p_date => p_calculation_date
6511 --,p_element_type_id => l_element_set.element_type_id
6512 ,p_element_type_id => l_element_type_id
6513 ,p_to_time_dim => p_to_time_dim
6514 ,p_fte => p_fte
6515 ,p_service_history => 'N'
6516 ,p_pay_source_value => l_pay_source_value
6517 ,p_qualifier => l_qualifier
6518 ,p_from_time_dim => l_from_time_dim
6519 ,p_calculation_type => l_calculation_type
6520 ,p_calculation_value => l_calculation_value
6521 ,p_input_value => l_input_value
6522 ,p_term_time_yes_no => l_term_time_yes_no
6523 ,p_sum_multiple_entries_yn => l_sum_multiple_entries_yn
6524 ,p_lookup_input_values_yn => l_lookup_input_values_yn
6525 ,p_column_name_source_type => l_column_name_source_type
6526 ,p_column_name_source_name => l_column_name_source_name
6527 ,p_row_name_source_type => l_row_name_source_type
6528 ,p_row_name_source_name => l_row_name_source_name
6529 );
6530
6531 debug('Element Rate for non-SF :'||l_element_rate);
6532
6533 END IF; -- end if of safeguarded flag check...
6534
6535 ELSE -- if pay source is not SP or GR
6536
6537 --
6538 debug(l_proc_name, 50);
6539 debug('Pay Source NOT SP or GR');
6540 -- Additional parameters following rates history changes
6541 l_element_rate := pqp_rates_history_calc.process_element
6542 (p_assignment_id => p_assignment_id
6543 ,p_date => p_calculation_date
6544 --,p_element_type_id => l_element_set.element_type_id
6545 ,p_element_type_id => l_element_type_id
6546 ,p_to_time_dim => p_to_time_dim
6547 ,p_fte => p_fte
6548 ,p_service_history => 'N'
6549 ,p_pay_source_value => l_pay_source_value
6550 ,p_qualifier => l_qualifier
6551 ,p_from_time_dim => l_from_time_dim
6552 ,p_calculation_type => l_calculation_type
6553 ,p_calculation_value => l_calculation_value
6554 ,p_input_value => l_input_value
6555 ,p_term_time_yes_no => l_term_time_yes_no
6556 ,p_sum_multiple_entries_yn => l_sum_multiple_entries_yn
6557 ,p_lookup_input_values_yn => l_lookup_input_values_yn
6558 ,p_column_name_source_type => l_column_name_source_type
6559 ,p_column_name_source_name => l_column_name_source_name
6560 ,p_row_name_source_type => l_row_name_source_type
6561 ,p_row_name_source_name => l_row_name_source_name
6562 );
6563
6564 debug('Element Rate for non-SF :'||l_element_rate);
6565
6566 end if; -- end of of pay source check ...
6567
6568 l_total_rate := l_total_rate + nvl(l_element_rate,0);
6569
6570 END IF; -- End if of chk link to assignment check ...
6571
6572 l_element_type_id := l_element_dtl.NEXT(l_element_type_id);
6573
6574 END LOOP;
6575 --close csr_element_set;
6576
6577 p_rate := round(l_total_rate, 5);
6578
6579 debug('p_rate :'||to_char(p_rate), 60);
6580 --
6581 -- hr_utility.set_location('Leaving: '||l_proc_name, 60);
6582 --
6583 debug_exit(l_proc_name);
6584
6585 return 0;
6586
6587
6588 debug('con_err: SQLCODE' || to_char(SQLCODE), 97);
6589 debug('con_err: SQLERRM' || SQLERRM, 97);
6590
6591 --
6592 exception
6593 when hr_application_error then
6594 --
6595 debug('con_err: SQLCODE' || to_char(SQLCODE), 98);
6596 debug('con_err: SQLERRM' || SQLERRM, 98);
6597 --
6598 p_rate := 0;
6599
6600 if csr_element_set%ISOPEN then -- BUG 4431495 : checking if cursor is open
6601 close csr_element_set;
6602 end if;
6603
6604 debug('error message for contract missing :' || hr_utility.get_message, 98);
6605
6606 debug('hr_application_error RAISED in Type1 rates_history function', 70);
6607
6608 debug('Trying to raise a PQP error message', 98);
6609
6610 -- BUG 4431495 : raising a warning message, which is being caught as an exception
6611 -- from pqp_rates_history_calc in SQLERRM, and passed on as token in dummy BEN messg
6612 -- having text as only a TOKEN
6613
6614 l_error := pqp_gb_tp_extract_functions.raise_extract_warning
6615 (p_assignment_id => p_assignment_id
6616 ,p_error_text => 'BEN_94268_DUMMY_MESSAGE'
6617 ,p_error_number => 94268
6618 ,p_token1 => SQLERRM
6619 );
6620
6621 debug('Have raised a PQP error message, check on extract results ', 98);
6622
6623 debug_exit(l_proc_name);
6624 return -1;
6625
6626 WHEN OTHERS THEN
6627 --
6628 debug('con_err: SQLCODE' || to_char(SQLCODE), 99);
6629 debug('con_err: SQLERRM' || SQLERRM, 99);
6630 --
6631
6632 p_rate := l_rate_nc;
6633 debug_exit(' Others in '||l_proc_name);
6634 raise;
6635 --
6636 end;
6637
6638 end rates_history;
6639 --
6640 -- RET: BUG 4135481: New function added to return the Retention Allowance Rate
6641 -- Following the Legislative Updates to Management and Retention Allowance
6642 -- Effective from 01-APR-2004.
6643 -- ----------------------------------------------------------------------------
6644 -- |------------------------< get_tp1_retention_allow_rate >--------------------|
6645 -- ----------------------------------------------------------------------------
6646 function get_tp1_retention_allow_rate (p_assignment_id in number
6647 ,p_ret_allow out nocopy varchar2
6648 )
6649 return number is
6650 --
6651 l_proc_name varchar2(60) := g_proc_name || 'get_tp1_retention_allow_rate';
6652 l_return number;
6653 l_ret_allow number;
6654 --
6655 begin
6656
6657 debug_enter(l_proc_name);
6658
6659 l_return := calc_tp1_retention_allow_rate
6660 (p_assignment_id => p_assignment_id
6661 ,p_effective_start_date => greatest
6662 (g_pension_year_start_date
6663 ,g_ext_asg_details(p_assignment_id).teacher_start_date
6664 )
6665 ,p_effective_end_date => least
6666 (g_effective_run_date
6667 ,nvl(g_ext_asg_details(p_assignment_id).leaver_date,
6668 g_effective_run_date)
6669 )
6670 ,p_rate => l_ret_allow
6671 );
6672
6673 debug_exit(l_proc_name);
6674
6675 if l_return <> -1 then
6676
6677 p_ret_allow := trim(to_char(l_ret_allow,'09999'));
6678 return 0;
6679
6680 else
6681
6682 p_ret_allow := '00000';
6683 return -1;
6684
6685 end if; -- end if of l_return check ...
6686
6687 EXCEPTION
6688 WHEN OTHERS THEN
6689 debug_exit(' Others in '||l_proc_name
6690 ,'Y' -- turn trace off
6691 );
6692 p_ret_allow := NULL;
6693 RAISE;
6694 end get_tp1_retention_allow_rate;
6695
6696
6697 -- RET: BUG 4135481: New function added to return the Retention Allowance Rate
6698 -- Following the Legislative Updates to Management and Retention Allowance
6699 -- Effective from 01-APR-2004.
6700 -- ----------------------------------------------------------------------------
6701 -- |------------------------< calc_tp1_retention_allow_rate >---------------|
6702 -- ----------------------------------------------------------------------------
6703
6704 FUNCTION calc_tp1_retention_allow_rate
6705 (p_assignment_id in number
6706 ,p_effective_start_date in date
6707 ,p_effective_end_date in date
6708 ,p_rate in out nocopy number
6709 )
6710 RETURN NUMBER IS
6711
6712 --
6713 l_proc_name varchar2(60) := g_proc_name ||
6714 'calc_tp1_retention_allow_rate';
6715
6716
6717 l_tab_mult_asg t_sec_asgs_type;
6718 l_sec_effective_date date;
6719 l_primary_esd date;
6720 l_return number;
6721 l_error number;
6722 l_rate_nc number;
6723 i number;
6724 l_primary_eed date;
6725 l_sec_eed date;
6726
6727 l_total_rert_allowance_rate number := 0;
6728 l_retention_allowance_rate number;
6729 --
6730
6731
6732 BEGIN
6733 --
6734
6735 debug_enter(l_proc_name);
6736
6737 -- nocopy changes
6738 l_rate_nc := p_rate;
6739
6740 --
6741 debug('p_assignment_id :'||to_char(p_assignment_id), 10);
6742 debug('Start date :'||to_char(p_effective_start_date,'DD/MM/YY'));
6743 debug('End date :'||to_char(p_effective_end_date,'DD/MM/YY'));
6744 --
6745
6746 -- Check if the primary asg is valid TCHR assignment
6747 -- on the p_effective_start_date
6748 -- MULT-LR --
6749 -- Use the new Function to check the effectivness of an assignment
6750 -- it takes care of multiple Leaver-Restarter events
6751 -- where as the old logic used to take into account
6752 -- only the first restarter event.
6753
6754 IF ( chk_effective_asg (p_assignment_id => p_assignment_id
6755 ,p_effective_date => p_effective_start_date
6756 ) = 'Y'
6757 )
6758 THEN
6759 --
6760 debug(l_proc_name, 20);
6761 -- We need to calculate
6762 -- from start of primary asg as its possible that
6763 -- primary asg bcomes a teacher after secondary
6764 l_primary_esd := GREATEST(p_effective_start_date
6765 ,g_ext_asg_details(p_assignment_id).start_date
6766 );
6767
6768 debug('l_primary_esd :'||to_char(l_primary_esd,'DD/MM/YY'),30);
6769
6770 -- MULT-LR --
6771 -- Use the new Function to get the correct end date
6772 -- based on the multiple restarter events
6773 -- It takes care of multiple Leaver-Restarter events
6774 -- where as the old logic used to take into account
6775 -- only the first restarter event.
6776
6777 -- Performance changes
6778 -- no need to call tihs function as we are checking assignment status in chk_effective_asg
6779 /*
6780 l_primary_eed := get_eff_end_date
6781 (p_assignment_id => p_assignment_id
6782 ,p_effective_start_date => p_effective_start_date
6783 ,p_effective_end_date => p_effective_end_date
6784 ) ;
6785 */
6786
6787 l_primary_eed := p_effective_end_date;
6788
6789 debug('l_primary_eed :'||to_char(l_primary_eed,'DD/MM/YY'),40);
6790
6791 -- Call rates_history function for primary assignment
6792 -- No Rate type available, so PASS Null, this will work as an identifier
6793 -- for rates_history function to derive the Ratention Allowance Rate
6794 -- Which otherwise expects a Rate Type as input.
6795
6796 l_return := rates_history
6797 (p_assignment_id => p_assignment_id
6798 ,p_calculation_date => l_primary_esd
6799 ,p_rate_type_name => NULL
6800 ,p_fte => 'N'
6801 ,p_to_time_dim => 'A'
6802 ,p_safeguarded_yn => NULL
6803 ,p_rate => l_retention_allowance_rate
6804 );
6805 --
6806 if l_return <> -1 then
6807 debug('l_retention_allowance_rate :'||to_char(l_retention_allowance_rate), 50);
6808 l_total_rert_allowance_rate := l_total_rert_allowance_rate + l_retention_allowance_rate;
6809 debug('l_total_rert_allowance_rate :'||to_char(l_total_rert_allowance_rate), 60);
6810 else
6811 debug_exit(l_proc_name);
6812 p_rate := 0;
6813 return -1;
6814 end if;
6815 --
6816
6817 --
6818 ELSE -- primary not valid asg
6819 --
6820 debug(l_proc_name, 70);
6821 l_total_rert_allowance_rate := 0;
6822 l_return := 0;
6823 --
6824
6825 END IF; -- primary not valid asg
6826
6827 --
6828 IF l_return <> -1 THEN
6829
6830 -- Check for multiple assignments
6831 debug(l_proc_name, 80);
6832
6833 --
6834 -- Bugfix 3803760:FTSUPPLY : Now using g_tab_sec_asgs instead of
6835 -- calling get_eff_secondary_asgs
6836 l_tab_mult_asg := g_tab_sec_asgs;
6837
6838 debug('l_tab_mult_asg.count :'|| to_char(l_tab_mult_asg.count),90);
6839
6840 IF l_tab_mult_asg.count > 0 THEN
6841 --
6842 debug(l_proc_name, 110);
6843 --
6844
6845 i := l_tab_mult_asg.FIRST;
6846
6847 -- get the annual_salary_rate for secondary assignments
6848 -- and check for equality
6849 -- store the slaary rates and dates in global collection,
6850 -- as it may be required later.
6851
6852 WHILE i IS NOT NULL
6853 LOOP
6854 --
6855 debug (l_proc_name||'Assignment Id:'||to_char(nvl(l_tab_mult_asg(i).assignment_id,99999)),120);
6856 l_sec_effective_date := greatest
6857 (p_effective_start_date
6858 ,g_ext_asg_details(l_tab_mult_asg(i).assignment_id).start_date);
6859
6860 debug('l_sec_effective_date :'|| to_char(l_sec_effective_date,'DD/MM/YYYY'),130);
6861
6862
6863 -- MULT-LR --
6864 -- Use the new Function to get the correct end date
6865 -- based on the multiple restarter events
6866 -- It takes care of multiple Leaver-Restarter events
6867 -- where as the old logic used to take into account
6868 -- only the first restarter event.
6869
6870 -- Performance changes
6871 -- no need to call tihs function as we are checking assignment status in chk_effective_asg
6872 /*
6873 l_sec_eed := get_eff_end_date ( p_assignment_id => l_tab_mult_asg(i).assignment_id
6874 ,p_effective_start_date => p_effective_start_date
6875 ,p_effective_end_date => p_effective_end_date
6876 ) ;
6877 */
6878 l_sec_eed := p_effective_end_date;
6879
6880 debug('l_sec_eed :'||to_char(l_sec_eed,'DD/MM/YYYY'),140);
6881
6882 -- Call rates_history function for secondary assignments
6883 -- No Rate type available, so PASS Null, this will work as an identifier
6884 -- for rates_history function to derive the Ratention Allowance Rate
6885 -- Which otherwise expects a Rate Type as input.
6886
6887 l_return := rates_history
6888 (p_assignment_id => l_tab_mult_asg(i).assignment_id
6889 ,p_calculation_date => l_sec_effective_date
6890 ,p_rate_type_name => NULL
6891 ,p_fte => 'N'
6892 ,p_to_time_dim => 'A'
6893 ,p_safeguarded_yn => NULL
6894 ,p_rate => l_retention_allowance_rate
6895 );
6896
6897 --
6898 if l_return <> -1 then
6899 debug('l_retention_allowance_rate :'||to_char(l_retention_allowance_rate), 150);
6900 l_total_rert_allowance_rate := l_total_rert_allowance_rate + l_retention_allowance_rate;
6901 debug('l_total_rert_allowance_rate :'||to_char(l_total_rert_allowance_rate), 160);
6902 else
6903 debug_exit(l_proc_name);
6904 p_rate := 0;
6905 return -1;
6906 end if;
6907 --
6908
6909
6910 i := l_tab_mult_asg.NEXT(i);
6911
6912 END LOOP;
6913
6914 debug('After loop----', 170);
6915
6916 END IF; -- l_tab_mult_asg.count > 0
6917
6918 debug('Retention Allowance : '||to_char(l_total_rert_allowance_rate),175);
6919
6920 -- Check whether retention allowance rate has exceeded the 4 digit limit ...
6921 IF l_total_rert_allowance_rate > 99999 THEN
6922
6923 l_error := pqp_gb_tp_extract_functions.raise_extract_warning
6924 (p_assignment_id => p_assignment_id
6925 ,p_error_text => 'BEN_93041_EXT_TP1_ANN_VAL_EXC'
6926 ,p_error_number => 93041
6927 -- RET: token introduced in error message
6928 ,p_token1 => 'Recruitment Retention '|| TO_CHAR(l_total_rert_allowance_rate)
6929 ,p_token2 => TO_CHAR(99999) -- bug : 4336613
6930 );
6931
6932 p_rate := 99999;
6933
6934 ELSE -- end if of annual sal rate limit check ...
6935 debug('Total Retention Allowance Rate :'||to_char(l_total_rert_allowance_rate),180);
6936 p_rate := l_total_rert_allowance_rate;
6937
6938 END IF ; -- end if of annual sal rate limit check ...
6939
6940 debug('p_rate : '||to_char(p_rate),185);
6941
6942
6943 debug_exit (l_proc_name);
6944
6945 RETURN 0;
6946
6947 ELSE -- else of return <> -1 on prim asg check...
6948
6949 debug_exit (l_proc_name);
6950 p_rate := 0;
6951
6952 RETURN -1;
6953
6954 END IF ; -- end if of return <> -1 on prim asg check...
6955
6956 -- Added by tmehra for nocopy changes Feb'03
6957
6958 EXCEPTION
6959 WHEN OTHERS THEN
6960 debug_exit(' Others in '||l_proc_name);
6961 p_rate := l_rate_nc;
6962 raise;
6963
6964 END calc_tp1_retention_allow_rate;
6965
6966 --
6967 -- ----------------------------------------------------------------------------
6968 -- |------------------------< calc_annual_sal_rate >---------------------------|
6969 -- ----------------------------------------------------------------------------
6970 function calc_annual_sal_rate (p_assignment_id in number
6971 ,p_calculation_date in date
6972 ,p_safeguarded_yn in varchar2
6973 ,p_fte in varchar2
6974 ,p_to_time_dim in varchar2
6975 ,p_rate in out nocopy number
6976 ,p_effective_start_date in date
6977 ,p_effective_end_date in date
6978 )
6979 return number is
6980 --
6981 l_proc_name varchar2(60) := g_proc_name || 'calc_annual_sal_rate';
6982 l_annual_rate number := 0;
6983 l_lonsoc_allowance number;
6984 l_other_allowance number;
6985 l_basic_salary number;
6986 l_return number;
6987 l_rate_name per_grades.name%type;
6988
6989 l_rate_nc number;
6990
6991 -- 4336613 : OSLA_3A
6992 l_grossed_osla_payment number;
6993
6994 --
6995 begin
6996 --
6997 -- hr_utility.set_location('Entering: '||l_proc_name, 10);
6998 --
6999 debug_enter(l_proc_name);
7000
7001 -- nocopy changes
7002 l_rate_nc := p_rate;
7003
7004
7005 -- PERF_ENHANC_3A : Performance Enhancements
7006 -- check if record corresponding to p_assignment_id is present in the
7007 -- collection g_asg_recalc_details.
7008 -- If yes, check for matching start_date (a double check,although not necessary)
7009 -- If full_time_sal_rate has been calculated before, then the row
7010 -- will contain the value,return it.
7011 -- If full_time_sal_rate for this assignment has not been calculated before,
7012 -- compute it, store it in a row for this assignment_id and return it
7013 -- This step is to avoid recomputing the value for a given LOS. Originally,
7014 -- calculations were repeated for each data element
7015
7016 IF (g_asg_recalc_details.EXISTS(p_assignment_id)
7017 AND
7018 g_asg_recalc_details(p_assignment_id).eff_start_date = p_effective_start_date
7019 AND
7020 g_asg_recalc_details(p_assignment_id).full_time_sal_rate IS NOT NULL
7021 ) THEN
7022
7023 p_rate := g_asg_recalc_details(p_assignment_id).full_time_sal_rate;
7024 debug('full_time_sal_rate is already present !! '||p_rate, 5);
7025
7026 ELSE -- calc_part_time_paid has to be computed for this assignment_id for this LOS
7027
7028
7029 -- Bug fix 2786740
7030 -- London rate type, other allowance need not have a value
7031 -- always
7032
7033 IF g_lon_rate_type IS NOT NULL THEN
7034
7035 -- Find annual rate for London and special needs allowance
7036 l_return := rates_history
7037 (p_assignment_id => p_assignment_id
7038 ,p_calculation_date => p_calculation_date
7039 ,p_rate_type_name => g_lon_rate_type
7040 ,p_fte => p_fte
7041 ,p_to_time_dim => p_to_time_dim
7042 ,p_safeguarded_yn => p_safeguarded_yn
7043 ,p_rate => l_lonsoc_allowance
7044 );
7045
7046 if l_return <> -1 then
7047
7048 l_annual_rate := l_annual_rate + nvl(l_lonsoc_allowance, 0);
7049
7050 else
7051
7052 debug_exit(l_proc_name);
7053 p_rate := 0;
7054 return -1;
7055
7056 end if; -- end if of london allowance return value check...
7057
7058 END IF; -- End if of g_lon_rate_type is not null check ...
7059
7060 --
7061 debug(l_proc_name, 20);
7062 --
7063
7064 IF g_oth_rate_type IS NOT NULL THEN
7065
7066 -- Find rate for Other allowance
7067 l_return := rates_history
7068 (p_assignment_id => p_assignment_id
7069 ,p_calculation_date => p_calculation_date
7070 ,p_rate_type_name => g_oth_rate_type
7071 ,p_fte => p_fte
7072 ,p_to_time_dim => p_to_time_dim
7073 ,p_safeguarded_yn => p_safeguarded_yn
7074 ,p_rate => l_other_allowance
7075 );
7076
7077 if l_return <> -1 then
7078
7079 debug('l_other_allowance: '||l_other_allowance,25);
7080 l_annual_rate := l_annual_rate + nvl(l_other_allowance,0);
7081 debug('l_annual_rate: '||l_annual_rate,25);
7082 g_other_allowance(p_assignment_id) := nvl(l_other_allowance, 0);
7083
7084 else
7085
7086 debug_exit(l_proc_name);
7087 p_rate := 0;
7088 return -1;
7089
7090 end if; -- end if of other allowance return value check...
7091
7092 ELSE
7093 g_other_allowance(p_assignment_id) := 0; -- Bug 4454427 :resetting value to 0
7094
7095 END IF; -- End if of g_oth_rate_type is not null check ...
7096
7097 debug('g_other_allowance(p_assignment_id): '||g_other_allowance(p_assignment_id),26);
7098
7099
7100 -- 4336613 : OSLA_3A : OSLA grossed payment function call
7101 l_grossed_osla_payment := get_grossed_osla_payments
7102 (p_assignment_id => p_assignment_id
7103 ,p_effective_start_date => p_effective_start_date
7104 ,p_effective_end_date => p_effective_end_date
7105 ,p_business_group_id => g_business_group_id
7106 );
7107
7108 -- 4336613 : OSLA_3A : add OSLA payments to annual sal rate and other allowances
7109
7110 debug('l_grossed_osla_payment: '||l_grossed_osla_payment,27);
7111 l_annual_rate := l_annual_rate + l_grossed_osla_payment;
7112 debug('l_annual_rate: '||l_annual_rate,27);
7113
7114 -- if grossed OSLA payments exist (non-zero), then add to Other Allowance
7115 IF l_grossed_osla_payment <> 0 THEN
7116 -- this is to avoid adding to a NULL value
7117 -- in case other_allowance has a value, add to it. Else, assign to it.
7118 IF (g_oth_rate_type IS NOT NULL) THEN
7119 g_other_allowance(p_assignment_id) := g_other_allowance(p_assignment_id) + l_grossed_osla_payment;
7120 ELSE
7121 g_other_allowance(p_assignment_id) := l_grossed_osla_payment;
7122 END IF;
7123 END IF;
7124
7125 debug('g_other_allowance(p_assignment_id): '||g_other_allowance(p_assignment_id),28);
7126
7127
7128 --
7129 debug(l_proc_name, 30);
7130 --
7131 -- Find rate for Basic Salary
7132 select decode(p_safeguarded_yn
7133 ,'Y'
7134 ,g_sf_rate_type
7135 ,g_sal_rate_type)
7136 into l_rate_name
7137 from dual;
7138
7139 debug('l_rate_name :'||l_rate_name, 40);
7140
7141 l_return := rates_history
7142 (p_assignment_id => p_assignment_id
7143 ,p_calculation_date => p_calculation_date
7144 ,p_rate_type_name => l_rate_name
7145 ,p_fte => p_fte
7146 ,p_to_time_dim => p_to_time_dim
7147 ,p_safeguarded_yn => p_safeguarded_yn
7148 ,p_rate => l_basic_salary
7149 );
7150
7151 debug('Basic Salary :'||l_basic_salary, 50);
7152
7153 if l_return <> -1 then
7154
7155 l_annual_rate := l_annual_rate + nvl(l_basic_salary,0);
7156
7157 else
7158
7159 debug_exit(l_proc_name);
7160 p_rate := 0;
7161 return -1;
7162
7163 end if; -- end if of basic salary return value check...
7164
7165 debug('Total Annual Rate :'||l_annual_rate);
7166
7167 --
7168 -- hr_utility.set_location('Leaving: '||l_proc_name, 50);
7169 --
7170 debug_exit(l_proc_name);
7171
7172 --PERF_ENHANC_3A : performance enhancements
7173 -- computed full_time_sal_rate value being stored in the collection for future use
7174 g_asg_recalc_details(p_assignment_id).full_time_sal_rate := l_annual_rate;
7175 debug('full_time_sal_rate (1st time computation) :'|| l_annual_rate,55);
7176
7177 p_rate := l_annual_rate;
7178
7179
7180 END IF; -- IF (g_asg_recalc_details.EXISTS.... )
7181
7182 return 0;
7183
7184 -- Added by tmehra for nocopy changes Feb'03
7185
7186 EXCEPTION
7187 WHEN OTHERS THEN
7188 p_rate := l_rate_nc;
7189 debug_exit(' Others in '||l_proc_name);
7190 raise;
7191
7192 --
7193 end calc_annual_sal_rate;
7194 --
7195 -- ----------------------------------------------------------------------------
7196 -- |------------------------< get_safeguarded_info >--------------------------|
7197 -- ----------------------------------------------------------------------------
7198 function get_safeguarded_info (p_assignment_id in number
7199 ,p_effective_date in date
7200 )
7201 return varchar2 is
7202 --
7203 l_proc_name varchar2(60) := g_proc_name || 'get_safeguarded_info';
7204 l_paa_info csr_paa_rate_id%rowtype;
7205 l_safeguarded_yn varchar2(1) := 'N';
7206 --
7207 begin
7208 --
7209 -- hr_utility.set_location('Entering: '||l_proc_name, 10);
7210 --
7211 debug_enter(l_proc_name);
7212
7213 open csr_paa_rate_id (c_assignment_id => p_assignment_id
7214 ,c_effective_date => p_effective_date
7215 );
7216 fetch csr_paa_rate_id into l_paa_info;
7217 close csr_paa_rate_id;
7218
7219 if (( l_paa_info.tp_safeguarded_rate_type is not null)
7220 and (l_paa_info.tp_safeguarded_rate_type <> 'SN' )) then
7221
7222 l_safeguarded_yn := 'Y';
7223
7224 end if; -- end if of tp_safeguarded_grade is not null check...
7225
7226 --
7227 -- hr_utility.set_location('Leaving: '||l_proc_name, 20);
7228 --
7229 debug_exit(l_proc_name);
7230
7231 return l_safeguarded_yn;
7232
7233 EXCEPTION
7234 WHEN OTHERS THEN
7235 debug_exit(' Others in '||l_proc_name);
7236 RAISE;
7237 end get_safeguarded_info;
7238 --
7239 -- ----------------------------------------------------------------------------
7240 -- |------------------------< get_fte_for_asg >----------------------|
7241 -- ----------------------------------------------------------------------------
7242 -- Bug 3889646
7243 -- The function will fetch the FTE value
7244 -- from assignment budget values
7245 -- using fte_utilities.
7246 -- if not found then
7247 -- it calculates the fte from
7248 -- average salary calculations.
7249
7250 FUNCTION get_fte_for_asg(p_assignment_id IN NUMBER
7251 ,p_effective_start_date IN DATE
7252 ,p_effective_end_date IN DATE
7253 ,p_annual_sal_rate IN NUMBER
7254 ,p_business_group_id IN NUMBER
7255 )
7256 return NUMBER IS
7257
7258 l_proc_name varchar2(60) := g_proc_name || 'get_fte_for_asg';
7259 l_days_in_period NUMBER ;
7260 l_no_of_days_in_year NUMBER := 365;
7261 l_total_part_time_sal_paid NUMBER;
7262 l_avg_sal_for_period NUMBER;
7263 l_fte NUMBER := 0;
7264
7265 BEGIN
7266 debug_enter(l_proc_name);
7267
7268 debug('p_assignment_id '|| to_char(p_assignment_id) ,10 ) ;
7269 debug('p_effective_start_date '|| to_char(p_effective_start_date,'DD/MM/YYYY') ) ;
7270 debug('p_effective_end_date '|| to_char(p_effective_end_date,'DD/MM/YYYY') ) ;
7271 debug('p_annual_sal_rate '|| to_char(p_annual_sal_rate) ) ;
7272 debug('p_business_group_id '|| to_char(p_business_group_id) ) ;
7273
7274 -- Get FTE value for primary assignment
7275 l_fte := pqp_fte_utilities.get_fte_value
7276 (p_assignment_id => p_assignment_id
7277 ,p_calculation_date => p_effective_start_date
7278 );
7279 debug('l_fte '|| l_fte ,20 ) ;
7280 IF l_fte is null or l_fte = 0 THEN
7281
7282 debug(l_proc_name, 30) ;
7283
7284 l_days_in_period := (trunc(p_effective_end_date) - trunc(p_effective_start_date)) + 1;
7285
7286 debug('l_days_in_period '|| to_char(l_days_in_period) ,40 ) ;
7287 IF l_days_in_period > l_no_of_days_in_year THEN
7288 l_days_in_period := l_no_of_days_in_year ;
7289 END IF ;
7290 debug('l_days_in_period :'||to_char(l_days_in_period), 50);
7291
7292 l_total_part_time_sal_paid := calc_part_time_sal
7293 (p_assignment_id => p_assignment_id
7294 ,p_effective_start_date => p_effective_start_date
7295 ,p_effective_end_date => p_effective_end_date
7296 ,p_business_group_id => p_business_group_id
7297 );
7298 debug('l_total_part_time_sal_paid :'||to_char(l_total_part_time_sal_paid),60);
7299
7300 IF l_total_part_time_sal_paid = 0 THEN
7301 debug('Part Time salary paid is ZERO for the period ' , 70);
7302 debug(to_char(p_effective_start_date,'dd/mm/yyyy') || ' to ' || to_char(p_effective_end_date,'dd/mm/yyyy')) ;
7303 debug('need to RAISE a warning here') ;
7304 END IF;
7305
7306 l_avg_sal_for_period := (p_annual_sal_rate/l_no_of_days_in_year) * l_days_in_period ;
7307 debug('l_avg_sal_for_period :'||to_char(l_avg_sal_for_period), 80);
7308
7309 IF l_avg_sal_for_period <> 0 THEN
7310 debug(l_proc_name, 90);
7311 l_fte := (l_total_part_time_sal_paid/l_avg_sal_for_period);
7312 ELSE
7313 debug(l_proc_name, 110);
7314 l_fte := 0;
7315 END IF ;
7316 END IF ; --l_fte = 0 or NULL
7317
7318 debug('l_fte :'||to_char(l_fte));
7319
7320 debug_exit (l_proc_name);
7321 RETURN l_fte;
7322
7323 EXCEPTION
7324 WHEN OTHERS THEN
7325 debug_exit(' Others in '||l_proc_name);
7326 raise;
7327
7328 END get_fte_for_asg;
7329
7330 -- ----------------------------------------------------------------------------
7331 -- |------------------------< get_annual_sal_rate_date >----------------------|
7332 -- ----------------------------------------------------------------------------
7333 function get_annual_sal_rate_date (p_assignment_id in number
7334 ,p_effective_start_date in date
7335 ,p_effective_end_date in date
7336 ,p_rate in out nocopy number
7337 )
7338 return number is
7339 --
7340 l_proc_name varchar2(60) := g_proc_name || 'get_annual_sal_rate_date';
7341 l_safeguarded_yn varchar2(1);
7342 l_annual_sal_rate number;
7343 l_actual_ann_sal_rate number := 0;
7344 l_actual_other_allowance number := 0;
7345 l_fte number := 0;
7346 l_total_fte number := 0;
7347 l_total_oth_alo_fte number := 0;
7348 l_sec_annual_sal_rate number;
7349 l_total_annual_sal_rate number := 0;
7350 l_total_other_allowance number := 0;
7351 l_tab_mult_asg t_sec_asgs_type;
7352 l_sec_effective_date date;
7353 l_primary_esd date;
7354 l_return number;
7355 l_error number;
7356
7357 l_rate_nc number;
7358 i number;
7359 -- new Variable added for FTE calculation changes.
7360 l_total_part_time_sal_paid number := 0;
7361 l_no_of_days_in_year number := 365 ;
7362 l_days_in_period number := 0 ;
7363 l_avg_sal_for_period number := 0;
7364 l_primary_eed date;
7365 l_sec_eed date;
7366 --new variable added for FTE calc changes.
7367 l_prev_annual_sal_rate number := NULL;
7368 l_equal_sal_rate varchar2(1) := 'Y';
7369 --Flags for showing warning for a LoS
7370 l_warn_for_sal_rate varchar2(1) := 'N';
7371 l_warn_for_sal_paid varchar2(1) := 'N';
7372
7373 -- changed g_asg_sal_rate to a local variable as
7374 -- this is not being eferenced from outside this function.
7375 l_asg_sal_rate t_asg_salary_rate_type;
7376
7377 --
7378 BEGIN
7379 -- Bug 3889646
7380 -- This function is enhanced and
7381 -- the following logic is applied.
7382 -- This function gets the salary rates
7383 -- for all assignments valid in the period.
7384 -- if all the salary rates are equal, then
7385 -- this salary rate is returned
7386 -- as Full Time Salary Rate
7387 -- else we do the average salary rate calculation
7388
7389 -- Average salary rate calculation :
7390 -- first we check for the stored FTE
7391 -- at assignment budget values.
7392 -- if found then
7393 -- this value is used as
7394 -- the FTE for the assignment
7395 -- else FTE is calculated on the fly
7396 -- by calculating average salary rate
7397 -- and Part time salary paid.
7398 -- all the FTE calculation is done separatly
7399 -- in the get_fte_for_asg function
7400 -- then this FTE value is used as
7401 -- per the following formula
7402 -- for average salary rate calculation
7403
7404 -- Average Salary Rate Formula
7405 -- avg sal rate = (sal_rate1 * fte1 + sal_rate2 * fte2 +....)/(fte1 + fte2 + ....)
7406
7407 debug_enter(l_proc_name);
7408
7409 -- nocopy changes
7410 l_rate_nc := p_rate;
7411
7412 -- This global has been removed.
7413 -- clear the global values.
7414 -- g_asg_sal_rate.DELETE;
7415
7416 --
7417 debug('p_assignment_id :'||to_char(p_assignment_id), 10);
7418 debug('Start date :'||to_char(p_effective_start_date,'DD/MM/YY'));
7419 debug('End date :'||to_char(p_effective_end_date,'DD/MM/YY'));
7420
7421 -- Get the safeguarded information and the annual rate
7422 -- for primary assignment only if the assignment qualifies
7423 -- for inclusion in the report
7424 -- Bug Fix 3073562:GAP6
7425
7426 -- Check if the primary asg is valid TCHR assignment
7427 -- on the p_effective_start_date
7428 -- MULT-LR --
7429 -- Use the new Function to check the effectivness of an assignment
7430 -- it takes care of multiple Leaver-Restarter events
7431 -- where as the old logic used to take into account
7432 -- only the first restarter event.
7433 IF ( chk_effective_asg (
7434 p_assignment_id => p_assignment_id
7435 ,p_effective_date => p_effective_start_date
7436 ) = 'Y'
7437 )
7438 THEN
7439 debug(l_proc_name, 20);
7440 -- Bugfix 3641851:CBF1 : We need to calculate the sal rate
7441 -- from start of primary asg as its possible that
7442 -- primary asg bcomes a teacher after secondary
7443 l_primary_esd := GREATEST(p_effective_start_date
7444 ,g_ext_asg_details(p_assignment_id).start_date
7445 );
7446 debug('l_primary_esd :'||to_char(l_primary_esd,'DD/MM/YY'),30);
7447
7448
7449 -- MULT-LR --
7450 -- Use the new Function to get the correct end date
7451 -- based on the multiple restarter events
7452 -- It takes care of multiple Leaver-Restarter events
7453 -- where as the old logic used to take into account
7454 -- only the first restarter event.
7455
7456 -- Performance changes
7457 -- no need to call tihs function as we are checking assignment status in chk_effective_asg
7458 /*
7459 l_primary_eed := get_eff_end_date ( p_assignment_id => p_assignment_id
7460 ,p_effective_start_date => p_effective_start_date
7461 ,p_effective_end_date => p_effective_end_date
7462 ) ;
7463 */
7464
7465 l_primary_eed := p_effective_end_date;
7466
7467
7468 debug('l_primary_eed :'||to_char(l_primary_eed,'DD/MM/YY'),40);
7469 --
7470 -- Get safeguarded information
7471
7472 l_safeguarded_yn := get_safeguarded_info
7473 (p_assignment_id => p_assignment_id
7474 -- Bugfix 3641851:CBF1 : Changed to l_primary_esd
7475 ,p_effective_date => l_primary_esd
7476 );
7477
7478 --
7479 debug('Safeguarded :'||l_safeguarded_yn,50);
7480 --
7481 -- Get the annual sal rate for primary assignment
7482
7483 l_return := calc_annual_sal_rate
7484 (p_assignment_id => p_assignment_id
7485 -- Bugfix 3641851:CBF1 : Changed to l_primary_esd
7486 ,p_calculation_date => l_primary_esd
7487 ,p_safeguarded_yn => l_safeguarded_yn
7488 ,p_fte => 'N'
7489 ,p_to_time_dim => 'A'
7490 ,p_rate => l_annual_sal_rate
7491 ,p_effective_start_date => p_effective_start_date
7492 ,p_effective_end_date => p_effective_end_date
7493 );
7494 debug('l_annual_sal_rate '||to_char(l_annual_sal_rate), 60) ;
7495 debug('l_return '||to_char(l_return)) ;
7496
7497 IF l_return <> -1 THEN --No error
7498 IF l_annual_sal_rate <> 0 THEN
7499 -- store the values in the global
7500 -- may be required later for average salary calculation
7501 l_asg_sal_rate(p_assignment_id).salary_rate := l_annual_sal_rate ;
7502 l_asg_sal_rate(p_assignment_id).eff_start_date := l_primary_esd ;
7503 l_asg_sal_rate(p_assignment_id).eff_end_date := l_primary_eed ;
7504 --Store the val in another var for comparison later.
7505 l_prev_annual_sal_rate := l_annual_sal_rate ;
7506
7507 IF g_other_allowance.exists(p_assignment_id) THEN
7508 debug(l_proc_name, 70);
7509 l_total_other_allowance := g_other_allowance(p_assignment_id);
7510 END IF;
7511
7512 debug('l_total_other_allowance :'||to_char(l_total_other_allowance),80);
7513
7514 ELSE --l_annual_sal_rate <> 0
7515 debug(l_proc_name, 90);
7516 -- if Annual Salary rate is ZERO
7517 -- set the warning flag to 'Y'
7518 -- will warn at the end of the function
7519 l_warn_for_sal_rate := 'Y' ;
7520
7521 l_asg_sal_rate(p_assignment_id).salary_rate := 0 ;
7522 l_asg_sal_rate(p_assignment_id).eff_start_date := l_primary_esd ;
7523 l_asg_sal_rate(p_assignment_id).eff_end_date := l_primary_eed ;
7524
7525 END IF ; --l_annual_sal_rate <> 0
7526 END IF; --l_return <> -1
7527
7528
7529 ELSE -- primary not valid asg
7530 debug(l_proc_name, 110);
7531 l_annual_sal_rate := 0;
7532 l_return := 0;
7533 END IF; -- primary not valid asg
7534
7535 debug('Annual Sal Rate :'||to_char(l_annual_sal_rate), 120);
7536
7537 --
7538 IF l_return <> -1 THEN
7539 -- Check for multiple assignments
7540 debug(l_proc_name, 130);
7541 --
7542 -- Bugfix 3803760:FTSUPPLY : Now using g_tab_sec_asgs instead of
7543 -- calling get_eff_secondary_asgs
7544 l_tab_mult_asg := g_tab_sec_asgs;
7545
7546 debug('l_tab_mult_asg.count :'|| to_char(l_tab_mult_asg.count),140);
7547 IF l_tab_mult_asg.count > 0 THEN
7548 --
7549 debug(l_proc_name, 150);
7550 --
7551 i := l_tab_mult_asg.FIRST;
7552 -- get the annual_salary_rate for secondary assignments
7553 -- and check for equality
7554 -- store the slaary rates and dates in global collection,
7555 -- as it may be required later.
7556
7557 WHILE i IS NOT NULL
7558 LOOP
7559 --
7560 debug (l_proc_name||'Assignment Id:'||to_char(nvl(l_tab_mult_asg(i).assignment_id,99999)),160);
7561
7562 l_sec_effective_date := greatest
7563 (p_effective_start_date
7564 ,g_ext_asg_details(l_tab_mult_asg(i).assignment_id).start_date);
7565 debug('l_sec_effective_date :'|| to_char(l_sec_effective_date,'DD/MM/YYYY'),170);
7566
7567 -- MULT-LR --
7568 -- Use the new Function to get the correct end date
7569 -- based on the multiple restarter events
7570 -- It takes care of multiple Leaver-Restarter events
7571 -- where as the old logic used to take into account
7572 -- only the first restarter event.
7573
7574 -- Performance changes
7575 -- no need to call tihs function as we are checking assignment status in chk_effective_asg
7576 /*
7577
7578 l_sec_eed := get_eff_end_date ( p_assignment_id => l_tab_mult_asg(i).assignment_id
7579 ,p_effective_start_date => p_effective_start_date
7580 ,p_effective_end_date => p_effective_end_date
7581 ) ;
7582 */
7583
7584 l_sec_eed := p_effective_end_date;
7585
7586
7587 debug('l_sec_eed :'||to_char(l_sec_eed,'DD/MM/YYYY'),180);
7588
7589 l_safeguarded_yn := get_safeguarded_info
7590 (p_assignment_id => l_tab_mult_asg(i).assignment_id
7591 ,p_effective_date => l_sec_effective_date
7592 );
7593 debug('l_safeguarded_yn :'||l_safeguarded_yn,190);
7594
7595 -- Get annual sal rate for secondary assignments
7596 l_return := calc_annual_sal_rate
7597 (p_assignment_id => l_tab_mult_asg(i).assignment_id
7598 ,p_calculation_date => l_sec_effective_date
7599 ,p_safeguarded_yn => l_safeguarded_yn
7600 ,p_fte => 'N'
7601 ,p_to_time_dim => 'A'
7602 ,p_rate => l_sec_annual_sal_rate
7603 ,p_effective_start_date => p_effective_start_date
7604 ,p_effective_end_date => p_effective_end_date
7605 );
7606 debug('l_sec_annual_sal_rate :'||l_sec_annual_sal_rate, 195);
7607
7608 IF l_return <> -1 THEN
7609 IF l_sec_annual_sal_rate = 0 THEN
7610
7611 debug('RAISE A warning for ZERO sal rate ----',210);
7612 -- Set the flag for Warning Message
7613 l_warn_for_sal_rate := 'Y' ;
7614
7615 l_asg_sal_rate(l_tab_mult_asg(i).assignment_id).salary_rate := 0 ;
7616 l_asg_sal_rate(l_tab_mult_asg(i).assignment_id).eff_start_date := l_sec_effective_date ;
7617 l_asg_sal_rate(l_tab_mult_asg(i).assignment_id).eff_end_date := l_sec_eed ;
7618
7619 ELSE
7620
7621 debug(l_proc_name, 215);
7622 l_asg_sal_rate(l_tab_mult_asg(i).assignment_id).salary_rate := l_sec_annual_sal_rate;
7623 l_asg_sal_rate(l_tab_mult_asg(i).assignment_id).eff_start_date := l_sec_effective_date ;
7624 l_asg_sal_rate(l_tab_mult_asg(i).assignment_id).eff_end_date := l_sec_eed ;
7625
7626 IF g_other_allowance.exists(l_tab_mult_asg(i).assignment_id) THEN
7627 debug(l_proc_name, 220);
7628 l_total_other_allowance := l_total_other_allowance + nvl(g_other_allowance(l_tab_mult_asg(i).assignment_id), 0);
7629 END IF ;
7630
7631 debug('l_total_other_allowance :'||to_char(l_total_other_allowance),230);
7632
7633 --compare with the previous salary rate and set the flag to 'N'
7634 -- as soon as a different sal_rate is found.
7635 IF l_prev_annual_sal_rate is not NULL THEN
7636 debug(l_proc_name, 240);
7637
7638 IF l_sec_annual_sal_rate <> l_prev_annual_sal_rate THEN
7639 debug(l_proc_name, 250);
7640 l_equal_sal_rate := 'N' ;
7641 ELSE
7642 debug('sal_rate are equal for this iteration',260);
7643 END IF;
7644
7645 ELSE -- l_prev_annual_sal_rate is not Null
7646 --The first valid assignment
7647 debug(l_proc_name, 270);
7648 l_prev_annual_sal_rate := l_sec_annual_sal_rate ;
7649 END IF ; --l_prev_annual_sal_rate <> 0
7650
7651 END IF ; --l_sec_annual_sal_rate = 0
7652
7653 ELSE --l_return <> -1
7654 debug('error returned from calc_annual_sal_rate',280) ;
7655 debug('need to raise a warning from here....') ;
7656 p_rate := 0;
7657 debug_exit (l_proc_name);
7658 RETURN -1;
7659 END IF ; --l_return <> -1
7660
7661 i := l_tab_mult_asg.NEXT(i);
7662
7663 END LOOP;
7664 debug('After loop----', 290);
7665
7666 END IF; -- l_tab_mult_asg.count > 0
7667
7668 debug('l_equal_sal_rate '|| l_equal_sal_rate, 310);
7669
7670 -- check if the flag is still 'Y'
7671 -- return the salary rate .
7672 -- else go to the average calculation
7673 -- Added for 5460058
7674 g_equal_sal_rate := l_equal_sal_rate;
7675 IF l_equal_sal_rate = 'Y' THEN
7676 debug(l_proc_name, 320);
7677
7678 IF l_prev_annual_sal_rate is NOT NULL THEN
7679 l_actual_ann_sal_rate := l_prev_annual_sal_rate ;
7680 ELSE
7681 l_actual_ann_sal_rate := 0;
7682 END IF ;
7683
7684 l_actual_other_allowance := l_total_other_allowance ;
7685
7686 ELSE ----l_equal_sal_rate = 'Y'
7687 -- need to get the average salary calculation and calculate the FTE.
7688
7689 debug(l_proc_name, 330);
7690
7691 -- reset the two variables
7692 -- as average calcultions will be done here as well.
7693 l_actual_other_allowance := 0;
7694 l_total_other_allowance := 0;
7695
7696 -- MULT-LR --
7697 -- Use the new Function to check the effectivness of an assignment
7698 -- it takes care of multiple Leaver-Restarter events
7699 -- where as the old logic used to take into account
7700 -- only the first restarter event.
7701
7702 IF ( chk_effective_asg (
7703 p_assignment_id => p_assignment_id
7704 ,p_effective_date => p_effective_start_date
7705 ) = 'Y'
7706 )
7707 THEN
7708 debug(l_proc_name, 340);
7709 l_fte := get_fte_for_asg(
7710 p_assignment_id => p_assignment_id
7711 ,p_effective_start_date => l_asg_sal_rate(p_assignment_id).eff_start_date
7712 ,p_effective_end_date => l_asg_sal_rate(p_assignment_id).eff_end_date
7713 ,p_annual_sal_rate => l_asg_sal_rate(p_assignment_id).salary_rate
7714 ,p_business_group_id => g_ext_asg_details(p_assignment_id).business_group_id
7715 );
7716
7717 debug('l_fte ' ||to_char(l_fte), 350);
7718 IF l_fte = 0 THEN
7719 debug('set warning for FTE = 0', 355) ;
7720 l_warn_for_sal_paid :='Y' ;
7721 END IF;
7722 --storing FTE, just in case we need it in future.
7723 l_asg_sal_rate(p_assignment_id).fte := l_fte ;
7724
7725 l_total_annual_sal_rate := l_fte * l_asg_sal_rate(p_assignment_id).salary_rate;
7726 l_total_fte := l_fte;
7727 debug('l_total_annual_sal_rate :'||l_total_annual_sal_rate,360);
7728 debug('l_total_fte :'||l_total_fte);
7729
7730 IF g_other_allowance.exists(p_assignment_id) AND
7731 g_other_allowance(p_assignment_id) <> 0
7732 THEN
7733 debug(l_proc_name, 370);
7734 l_total_other_allowance := g_other_allowance(p_assignment_id) * l_fte;
7735 l_total_oth_alo_fte := l_fte;
7736 END IF; -- end if of other allowance check ...
7737 END IF ; --Check if Priamry is Valid
7738
7739 i := l_tab_mult_asg.FIRST;
7740 WHILE i IS NOT NULL
7741 LOOP
7742 --
7743 debug (l_proc_name||'Assignment Id:'||to_char(nvl(l_tab_mult_asg(i).assignment_id,99999)),380);
7744
7745 l_fte := get_fte_for_asg(
7746 p_assignment_id => l_tab_mult_asg(i).assignment_id
7747 ,p_effective_start_date => l_asg_sal_rate(l_tab_mult_asg(i).assignment_id).eff_start_date
7748 ,p_effective_end_date => l_asg_sal_rate(l_tab_mult_asg(i).assignment_id).eff_end_date
7749 ,p_annual_sal_rate => l_asg_sal_rate(l_tab_mult_asg(i).assignment_id).salary_rate
7750 ,p_business_group_id => g_ext_asg_details(l_tab_mult_asg(i).assignment_id).business_group_id
7751 );
7752
7753 debug('l_fte :'|| to_char(l_fte), 390);
7754
7755 IF l_fte = 0 THEN
7756 debug('set warning for FTE = 0', 395) ;
7757 l_warn_for_sal_paid :='Y' ;
7758 END IF;
7759 --storing FTE, just in case we need it in future.
7760 l_asg_sal_rate(l_tab_mult_asg(i).assignment_id).fte := l_fte ;
7761
7762 l_total_annual_sal_rate := l_total_annual_sal_rate +
7763 (l_asg_sal_rate(l_tab_mult_asg(i).assignment_id).salary_rate * l_fte);
7764 l_total_fte := l_total_fte + l_fte;
7765 debug('l_total_annual_sal_rate :'|| to_char(l_total_annual_sal_rate),410);
7766 debug('l_total_fte :'|| to_char(l_total_fte));
7767
7768 IF g_other_allowance.exists(l_tab_mult_asg(i).assignment_id) AND
7769 g_other_allowance(l_tab_mult_asg(i).assignment_id) <> 0
7770 THEN
7771 debug(l_proc_name, 420);
7772 l_total_other_allowance := l_total_other_allowance +
7773 (g_other_allowance(l_tab_mult_asg(i).assignment_id) * l_fte);
7774 l_total_oth_alo_fte := l_total_oth_alo_fte + l_fte;
7775 END IF; -- end if of other allowance exists check...
7776
7777 i := l_tab_mult_asg.NEXT(i);
7778
7779 END LOOP;
7780
7781 debug (l_proc_name ||'Total Secondary Asgs: '||TO_CHAR(l_tab_mult_asg.COUNT),430);
7782
7783 debug('l_total_fte ' ||to_char(l_total_fte), 440);
7784 debug('l_total_annual_sal_rate ' ||to_char(l_total_annual_sal_rate));
7785
7786 IF l_total_fte <> 0 THEN
7787 debug(l_proc_name, 450);
7788 l_actual_ann_sal_rate := l_total_annual_sal_rate/l_total_fte;
7789 debug('l_actual_ann_sal_rate ' ||to_char(l_actual_ann_sal_rate));
7790 ELSE
7791 debug(l_proc_name,460);
7792 l_actual_ann_sal_rate := 0 ;
7793 --p_rate := 0;
7794 END IF ;
7795
7796 IF l_total_oth_alo_fte <> 0 THEN
7797 debug(l_proc_name,470);
7798 l_actual_other_allowance := l_total_other_allowance/l_total_oth_alo_fte;
7799 ELSE
7800 debug(l_proc_name,480);
7801 l_actual_other_allowance := 0;
7802 END IF; -- end if of other allowance exists check ...
7803
7804 END IF ; --l_equal_sal_rate = 'Y'
7805
7806 g_other_allowance(p_assignment_id) := round(l_actual_other_allowance);
7807 l_actual_ann_sal_rate := round(l_actual_ann_sal_rate);
7808
7809 debug('g_other_allowance(p_assignment_id) ' ||to_char(g_other_allowance(p_assignment_id)),490);
7810 debug('l_actual_ann_sal_rate ' ||to_char(l_actual_ann_sal_rate));
7811
7812 -- 4336613 : SAL_VALIDAT_3A : Check whether annual sal rate has exceeded the 5 digit limit
7813 -- If yes, raise warning.
7814 IF l_actual_ann_sal_rate > 999999 THEN
7815
7816 l_error := pqp_gb_tp_extract_functions.raise_extract_warning
7817 (p_assignment_id => p_assignment_id
7818 ,p_error_text => 'BEN_93041_EXT_TP1_ANN_VAL_EXC'
7819 ,p_error_number => 93041
7820 -- token introduced in error message
7821 ,p_token1 => 'Annual Salary Rate ' || TO_CHAR(l_actual_ann_sal_rate) -- bug : 4336613
7822 ,p_token2 => TO_CHAR(999999) -- bug : 4336613
7823 );
7824
7825 p_rate := 999999; -- 4336613 : SAL_VALIDAT_3A : set to 99999 if > 99999
7826 ELSE -- end if of annual sal rate limit check ...
7827 debug('Actual Annual Salary Rate :'||to_char(l_actual_ann_sal_rate),510);
7828 p_rate := l_actual_ann_sal_rate;
7829 END IF ; -- end if of annual sal rate limit check ...
7830
7831 debug('p_rate : '||to_char(p_rate),515);
7832
7833 debug('l_warn_for_sal_rate: '||l_warn_for_sal_rate,520) ;
7834 -- Check for the Warning flag
7835 IF l_warn_for_sal_rate = 'Y' THEN
7836 l_error := pqp_gb_tp_extract_functions.raise_extract_warning
7837 (p_assignment_id => p_assignment_id
7838 ,p_error_text => 'BEN_94044_ZERO_SAL_RATE'
7839 ,p_error_number => 94044
7840 ,p_token1 => fnd_date.date_to_displaydate(p_effective_start_date)
7841 );
7842 END IF ;
7843
7844 debug('l_warn_for_sal_paid: '||l_warn_for_sal_paid,530) ;
7845 -- Check for the Warning flag
7846 IF l_warn_for_sal_paid = 'Y' THEN
7847 l_error := pqp_gb_tp_extract_functions.raise_extract_warning
7848 (p_assignment_id => p_assignment_id
7849 ,p_error_text => 'BEN_94045_ZERO_PT_SAL_PAID'
7850 ,p_error_number => 94045
7851 ,p_token1 => fnd_date.date_to_displaydate(p_effective_start_date)
7852 );
7853 END IF ;
7854
7855
7856 debug_exit (l_proc_name);
7857 RETURN 0;
7858
7859 ELSE -- else of return <> -1 on prim asg check...
7860
7861 debug_exit (l_proc_name);
7862 p_rate := 0;
7863 RETURN -1;
7864
7865 END IF ; -- end if of return <> -1 on prim asg check...
7866
7867 -- Added by tmehra for nocopy changes Feb'03
7868
7869 EXCEPTION
7870 WHEN OTHERS THEN
7871 debug_exit(' Others in '||l_proc_name);
7872 p_rate := l_rate_nc;
7873 raise;
7874
7875 END get_annual_sal_rate_date;
7876
7877
7878 -- BUG 4135481
7879 -- TERM_LSP: get_terminated_payments finds the
7880 -- Final process date of employee if he/she
7881 -- has been terminated with in the reporting period and
7882 -- sums up salary paid upto Final close Date.
7883 -- NB: If for a terminated employee there is no Final Close Date
7884 -- then it picks up the Last Standard Process Date if it exists, else
7885 -- (ie. LSP date is Null and Final Close Date is Null ) then it picks up the
7886 -- actual Termination Date. Since no upper bound for payroll date
7887 -- is found the payments are done till actual termination date
7888 -- which is calculated as per adjust_post_part_payments.
7889 Function get_terminated_payments (p_assignment_id IN NUMBER
7890 ,p_effective_start_date IN DATE
7891 ,p_effective_end_date IN DATE
7892 ,p_business_group_id IN NUMBER
7893 ,p_part_payment OUT NOCOPY NUMBER
7894 ,p_balance_type_id IN NUMBER -- 4336613 : OSLA_3A
7895 )
7896 RETURN VARCHAR2 IS
7897
7898 l_proc_name VARCHAR2(60) := g_proc_name || 'get_terminated_payments';
7899 l_terminated VARCHAR2(1);
7900 l_term_proc_date DATE ;
7901 l_effective_date DATE;
7902 l_total_term_payment NUMBER := 0;
7903 l_count NUMBER := 0;
7904 l_term_payment NUMBER := 0;
7905 l_effective_start_date DATE;
7906
7907 l_get_term_details csr_get_termination_details%ROWTYPE;
7908
7909 -- RETRO:BUG: 4135481
7910 l_asg_act_dtl csr_get_asg_act_id_retro%ROWTYPE;
7911 l_supp_claim NUMBER := 0;
7912
7913 BEGIN
7914
7915 debug_enter(l_proc_name);
7916 debug('p_assignment_id :' ||to_char(p_assignment_id ),10);
7917 debug('p_effective_start_date :' ||to_char(p_effective_start_date,'DD/MM/YYYY') );
7918 debug('p_effective_end_date :' ||to_char(p_effective_end_date,'DD/MM/YYYY'));
7919
7920 -- get the final close date (if exists)
7921 OPEN csr_get_termination_details
7922 (p_assignment_id => p_assignment_id
7923 ,p_effective_end_date => p_effective_end_date
7924 ,p_business_group_id => p_business_group_id
7925 );
7926
7927 FETCH csr_get_termination_details INTO l_get_term_details;
7928
7929
7930 IF csr_get_termination_details%FOUND THEN
7931 -- employee has been terminated with in the reporting period (line of service)
7932 debug('actual_termination_date: '||
7933 to_char(l_get_term_details.actual_termination_date,'DD-MM-YYYY'),20);
7934
7935 l_term_proc_date := NVL(l_get_term_details.final_process_date ,
7936 NVL(l_get_term_details.last_standard_process_date,
7937 l_get_term_details.actual_termination_date));
7938
7939 IF l_term_proc_date <> l_get_term_details.actual_termination_date THEN
7940 l_terminated := 'Y'; -- flag to check employee being terminated.
7941
7942 ELSE
7943 --actual_termination_date = either of Last Std Process date or Final Close date
7944 --i.e. actual_termination_date is on last day of the Pay period
7945 debug('actual_termination_date is on last day of the Pay period',23);
7946 l_terminated := 'N';
7947 --person's payments included in regular payroll
7948 END IF;
7949
7950
7951 debug('termination payment date: '||
7952 to_char( l_term_proc_date,'DD-MM-YYYY'),25);
7953
7954
7955
7956 ELSE --csr_get_lsp_date%FOUND THEN
7957 debug('No Termination Date found ', 30);
7958 l_terminated := 'N';
7959
7960 END IF;
7961 CLOSE csr_get_termination_details;
7962
7963
7964 IF l_terminated ='Y' THEN
7965
7966 -- If there is a case where person is terminated and
7967 -- there is no pay period after that current month then
7968 -- p_effective start_date is NULL after pre_payment is done.
7969 -- In that case if any days exist between terminated day and
7970 -- Last Standard process date then we want to calculate
7971 -- the terminated payment as well by setting the effective start date
7972 -- to p_effective_end_date.
7973
7974 -- IF p_effective_start_date is NULL THEN
7975 -- l_effective_start_date := p_effective_end_date;
7976 -- ELSE
7977 l_effective_start_date := p_effective_start_date;
7978 -- END IF;
7979
7980 debug('l_effective_start_date :'||to_char(l_effective_start_date, 'DD/MM/YYYY'),40) ;
7981
7982 -- RETRO:BUG: 4135481/4273915
7983 -- Check if the RETRO flag g_calc_sal_new is set to 'Y'
7984
7985 debug('g_calc_sal_new: ' ||g_calc_sal_new, 50);
7986
7987
7988 IF ( g_calc_sal_new = 'Y' ) THEN
7989
7990 debug('g_def_bal_id(p_balance_type_id): '||to_char(g_def_bal_id(p_balance_type_id)),60);
7991 -- get the assignment_action_id and
7992 -- use the new seeded route to fetch the payments including the
7993 -- retro payments.
7994
7995 l_count := 1;
7996 OPEN csr_get_asg_act_id_retro
7997 (p_assignment_id => p_assignment_id
7998 ,p_effective_start_date => l_effective_start_date
7999 ,p_effective_end_date => l_term_proc_date
8000 );
8001 LOOP
8002
8003 FETCH csr_get_asg_act_id_retro INTO l_asg_act_dtl;
8004 EXIT WHEN csr_get_asg_act_id_retro%NOTFOUND;
8005
8006 --
8007 debug('assignment_action_id: '||to_char(l_asg_act_dtl.assignment_action_id),70);
8008 debug('date_earned: '||to_char(l_asg_act_dtl.date_earned,'DD/MM/YYYY'));
8009 --
8010 l_term_payment := pay_balance_pkg.get_value
8011 ( p_defined_balance_id => g_def_bal_id(p_balance_type_id)
8012 ,p_assignment_action_id => l_asg_act_dtl.assignment_action_id
8013 ) ;
8014
8015 debug('l_term_payment :'||to_char(l_term_payment), 80+l_count/10000) ;
8016
8017 l_total_term_payment := l_total_term_payment + l_term_payment;
8018
8019 debug('l_total_term_payment :'||to_char(l_total_term_payment),90+l_count/10000) ;
8020
8021 l_count := l_count + 1 ;
8022 END LOOP;
8023 CLOSE csr_get_asg_act_id_retro;
8024
8025 debug('l_total_term_payment :'||to_char(l_total_term_payment),110) ;
8026 /*
8027 IF g_date_work_mode = 'Y' AND g_supp_teacher = 'Y' THEN
8028 OPEN csr_get_supp_ded(p_balance_type_id,p_assignment_id,l_effective_start_date,l_term_proc_date);
8029 FETCH csr_get_supp_ded INTO l_supp_claim;
8030 CLOSE csr_get_supp_ded;
8031 debug('l_supp_claim :'||to_char(l_supp_claim),208);
8032 l_total_term_payment := l_total_term_payment - l_supp_claim;
8033 debug('l_total_term_payment after supply claims deduction:'||to_char(l_total_term_payment),209) ;
8034 END IF;
8035 */
8036 debug('....retro payments calc over....') ;
8037
8038 ELSE -- ( g_calc_sal_new = 'N' ) THEN
8039
8040 -- get the payments using the usual balance route.
8041
8042 OPEN csr_get_end_date (c_assignment_id => p_assignment_id
8043 ,c_effective_start_date => l_effective_start_date
8044 ,c_effective_end_date => l_term_proc_date
8045 );
8046 LOOP
8047
8048 FETCH csr_get_end_date INTO l_effective_date;
8049 EXIT when csr_get_end_date%notfound;
8050
8051 debug('l_effective_date :'||to_char(l_effective_date, 'DD/MM/YYYY'),120) ;
8052
8053 l_term_payment := hr_gbbal.calc_asg_proc_ptd_date
8054 (p_assignment_id => p_assignment_id
8055 ,p_balance_type_id => p_balance_type_id
8056 ,p_effective_date => l_effective_date
8057 );
8058
8059
8060 debug('l_term_payment :'||to_char(l_term_payment), 130+l_count/10000) ;
8061
8062 l_total_term_payment := l_total_term_payment + l_term_payment;
8063
8064 debug('l_total_term_payment :'||to_char(l_total_term_payment),140+l_count/10000) ;
8065
8066 l_count := l_count + 1 ;
8067 END LOOP;
8068 debug('l_total_term_payment :'||to_char(l_total_term_payment),150) ;
8069 CLOSE csr_get_end_date;
8070 /*
8071 IF g_date_work_mode = 'Y' AND g_supp_teacher = 'Y' THEN
8072 OPEN csr_get_supp_ded(p_balance_type_id,p_assignment_id,l_effective_start_date,l_term_proc_date);
8073 FETCH csr_get_supp_ded INTO l_supp_claim;
8074 CLOSE csr_get_supp_ded;
8075 debug('l_supp_claim :'||to_char(l_supp_claim),208);
8076 l_total_term_payment := l_total_term_payment - l_supp_claim;
8077 debug('l_total_term_payment after supply claims deduction:'||to_char(l_total_term_payment),209) ;
8078
8079 END IF;
8080 */
8081 END IF; --( g_calc_sal_new = 'N' ) THEN
8082
8083
8084 END IF; --l_terminated ='Y' THEN
8085
8086 debug('l_total_term_payment :'||to_char(l_total_term_payment),160) ;
8087
8088 IF l_total_term_payment IS NULL THEN
8089 p_part_payment := 0;
8090 ELSE
8091 p_part_payment := l_total_term_payment;
8092 END IF;
8093
8094 debug('p_part_payment: '|| to_char(p_part_payment), 170);
8095 debug_exit(l_proc_name);
8096
8097 RETURN l_terminated;
8098
8099 EXCEPTION
8100 WHEN OTHERS THEN
8101 debug_exit(' Others in '||l_proc_name);
8102 p_part_payment := NULL;
8103 RAISE;
8104
8105 END get_terminated_payments;
8106
8107
8108 -- PTS: BUG 4135481
8109 -- This is a utility function that calculates the
8110 -- number of overlapping days in the two sets of dates.
8111 -- set1 (p_start_date1, p_end_date1)
8112 -- set2 (p_start_date2,p_end_date2)
8113 -- RETURNS 0 if no overlap period is found.
8114 FUNCTION get_overlap_days
8115 (p_start_date1 DATE
8116 ,p_end_date1 DATE
8117 ,p_start_date2 DATE
8118 ,p_end_date2 DATE
8119 ) RETURN NUMBER
8120
8121 IS
8122
8123 l_overlap_days NUMBER :=0 ;
8124 l_proc_name VARCHAR2(60) := 'get_overlap_days' ;
8125
8126 BEGIN
8127
8128 debug_enter(l_proc_name) ;
8129
8130 debug('p_start_date1: '||to_char(p_start_date1,'DD/MM/YYYY')) ;
8131 debug('p_end_date1: '||to_char(p_end_date1,'DD/MM/YYYY')) ;
8132 debug('p_start_date2: '||to_char(p_start_date2,'DD/MM/YYYY')) ;
8133 debug('p_end_date2: '||to_char(p_end_date2,'DD/MM/YYYY')) ;
8134
8135 IF ( (p_end_date1 < p_start_date2) OR (p_end_date2 < p_start_date1) ) THEN
8136 debug(l_proc_name, 10);
8137 l_overlap_days := 0;
8138 ELSIF ( (p_end_date1 = p_start_date2) OR (p_end_date2 = p_start_date1) ) THEN
8139 debug(l_proc_name, 20);
8140 l_overlap_days := 1 ;
8141 ELSIF ( (p_start_date1 <= p_start_date2) AND (p_end_date2 <= p_end_date1) ) THEN
8142 debug(l_proc_name, 30);
8143 l_overlap_days := p_end_date2 - p_start_date2 + 1 ;
8144 ELSIF ( (p_start_date2 <= p_start_date1) AND (p_end_date1 <= p_end_date2) ) THEN
8145 debug(l_proc_name, 40);
8146 l_overlap_days := p_end_date1 - p_start_date1 + 1;
8147 ELSIF ( (p_start_date2 <= p_start_date1) AND (p_end_date2 <= p_end_date1) ) THEN
8148 debug(l_proc_name, 50);
8149 l_overlap_days := p_end_date2 - p_start_date1 + 1;
8150 ELSE
8151 debug(l_proc_name, 60);
8152 l_overlap_days := p_end_date1 - p_start_date2 + 1;
8153 END IF;
8154
8155 debug('l_overlap_days: '|| l_overlap_days, 70);
8156 debug_exit(l_proc_name);
8157
8158 RETURN abs(l_overlap_days);
8159
8160 END get_overlap_days;
8161
8162
8163 -- PTS: BUG 4135481:
8164 ------<calc_payment_by_run_rslt>--------------
8165 -- function gets the sum of run result values for
8166 -- the assignment for the period
8167 -- p_start_date to p_end_date
8168 -- for the payments earned on p_date_earned (payroll run date)
8169 -- p_val returns the value of payments.
8170 -- Returns -1 in case of error
8171 FUNCTION calc_payment_by_run_rslt
8172 ( p_assignment_id IN NUMBER
8173 ,p_start_date IN DATE
8174 ,p_end_date IN DATE
8175 ,p_pay_period_start IN DATE
8176 ,p_date_earned IN DATE
8177 ,p_balance_type_id IN NUMBER
8178 ,p_val OUT NOCOPY NUMBER
8179 ,p_tab_bal_ele_ids IN t_ele_ids_from_bal -- 4336613 : OSLA_3A
8180 ) RETURN NUMBER
8181 IS
8182
8183 l_proc_name VARCHAR2(60) := g_proc_name || 'calc_payment_by_run_rslt';
8184
8185 l_element_type_id NUMBER;
8186 l_input_val_id NUMBER;
8187 l_total_val NUMBER:= 0;
8188
8189 l_asg_act_id NUMBER;
8190 l_count NUMBER; -- Loop counter
8191
8192 l_overlap_days NUMBER := 0;
8193 l_avg_payment NUMBER := 0;
8194 l_proration VARCHAR2(1) :='N' ;
8195 l_balance_val NUMBER := 0;
8196 l_balance_type_id NUMBER;
8197
8198 --l_rr csr_get_run_result_value%ROWTYPE;
8199 l_rr1 csr_get_run_results%ROWTYPE; -- 5403512
8200 l_element_info csr_get_eet_info%ROWTYPE;
8201 i NUMBER :=0;
8202 l_qualify VARCHAR2(1) := 'Y';
8203 --
8204 BEGIN
8205
8206 debug_enter(l_proc_name);
8207
8208 debug('p_start_date :' ||to_char(p_start_date, 'DD/MM/YYYY'),10) ;
8209 debug('p_end_date :' ||to_char(p_end_date, 'DD/MM/YYYY')) ;
8210 debug('p_pay_period_start :' ||to_char(p_pay_period_start, 'DD/MM/YYYY')) ;
8211 debug('p_date_earned :' ||to_char(p_date_earned, 'DD/MM/YYYY')) ;
8212 debug('p_assignment_id :' ||to_char(p_assignment_id)) ;
8213 debug('p_balance_type_id :' ||to_char(p_balance_type_id)) ;
8214 debug('p_tab_bal_ele_ids.COUNT :' ||to_char(p_tab_bal_ele_ids.COUNT)) ;
8215
8216 -- get the assignment_action_id
8217
8218 OPEN csr_get_asg_act_id
8219 ( p_assignment_id => p_assignment_id
8220 ,p_date_earned => p_date_earned
8221 );
8222 FETCH csr_get_asg_act_id INTO l_asg_act_id;
8223
8224 IF csr_get_asg_act_id%NOTFOUND THEN
8225 CLOSE csr_get_asg_act_id;
8226 debug('Assignment action id not found....',30);
8227 l_total_val := 0 ;
8228
8229 ELSE -- csr_get_asg_act_id%NOTFOUND THEN
8230 CLOSE csr_get_asg_act_id;
8231
8232 -- Run Results exist so get the element Ids
8233 debug('l_asg_act_id: '||to_char(l_asg_act_id),40 );
8234
8235 -- get_elements from element entries
8236 -- for the assignment
8237 l_count := 1 ; -- Loop counter
8238
8239 /* OPEN csr_get_eet_info -- 5403512
8240 ( c_assignment_id => p_assignment_id
8241 ,c_effective_start_date => p_start_date
8242 ,c_effective_end_date => p_end_date
8243 ) ; */
8244 -- LOOP
8245 -- FETCH csr_get_eet_info INTO l_element_info;
8246 -- EXIT WHEN csr_get_eet_info%NOTFOUND;
8247
8248 -- check if the element is feeding the
8249 -- 'Teachers Supperannuable Salary' Balance'
8250
8251 -- l_element_type_id := l_element_info.element_type_id;
8252
8253
8254 debug('element_type_id :' ||to_char(l_element_type_id),50+l_count/10000) ;
8255
8256 -- 4336613 : OSLA_3A : check for payment type (OSLA/NULL)
8257 -- IF OSLA, then use g_tab_osla_ele_ids, else use g_tab_sal_ele_ids
8258
8259 /* IF p_tab_bal_ele_ids.EXISTS(l_element_type_id) THEN
8260
8261 debug('input_value_id :' ||
8262 to_char(p_tab_bal_ele_ids(l_element_type_id).input_value_id),60+l_count/10000) ; */ -- 5403512
8263
8264 l_balance_type_id := p_balance_type_id;
8265 -- Get the run_results
8266 -- for this element type id
8267 /* FOR l_rr IN csr_get_run_result_value -- 5403512
8268 ( p_start_date => p_pay_period_start --p_start_date
8269 ,p_end_date => p_date_earned --p_end_date
8270 ,p_element_type_id => l_element_type_id
8271 ,p_input_value_id => p_tab_bal_ele_ids(l_element_type_id).input_value_id
8272 ,p_asg_act_id => l_asg_act_id
8273 ) */
8274 FOR l_rr1 IN csr_get_run_results -- 5403512
8275 ( p_start_date => p_pay_period_start --p_start_date
8276 ,p_end_date => p_date_earned --p_end_date
8277 ,p_asg_act_id => l_asg_act_id
8278 ,p_balance_type_id => l_balance_type_id
8279 )
8280 LOOP
8281 debug('l_total_val :' ||to_char(l_total_val), 70+l_count/10000) ;
8282 debug('l_rr.start_date :'||to_char(l_rr1.start_date,'DD/MM/YYYY'));
8283 debug('l_rr.end_date :'||to_char(l_rr1.end_date,'DD/MM/YYYY'));
8284 debug('l_rr.result_value :'||to_char(l_rr1.result));
8285 debug('l_rr.run_result_id :' ||to_char(l_rr1.run_result_id));
8286
8287 l_proration := 'Y' ;
8288 l_qualify := 'Y' ;
8289
8290 IF g_date_work_mode = 'Y' AND g_supp_teacher = 'Y' THEN
8291 OPEN csr_is_supp_claim(l_rr1.run_result_id,p_start_date,p_end_date);
8292 FETCH csr_is_supp_claim INTO l_qualify;
8293 CLOSE csr_is_supp_claim;
8294 debug('l_qualify :' ||l_qualify, 79) ;
8295 END IF;
8296 debug('l_qualify :' ||l_qualify, 80) ;
8297 IF l_qualify = 'Y' THEN
8298 debug(l_proc_name, 80);
8299
8300 IF (l_rr1.start_date >= p_start_date
8301 AND
8302 l_rr1.end_date <= p_end_date) THEN
8303
8304 debug(l_proc_name, 90) ;
8305 l_total_val := l_total_val + l_rr1.result * l_rr1.scale; -- 5403512
8306
8307 -- CALC_PT_SAL_OPTIONS: BUG : 4135481
8308 -- perform average calculations if specified
8309 ELSIF g_calendar_avg = 'Y' THEN --(l_rr.start_date >= p_start_date
8310
8311 debug(l_proc_name, 110) ;
8312 -- need average calculation
8313 -- get the number of days in the period that overlap with the payroll period
8314 l_overlap_days := get_overlap_days
8315 (p_start_date1 => p_start_date
8316 ,p_end_date1 => p_end_date
8317 ,p_start_date2 => l_rr1.start_date
8318 ,p_end_date2 => l_rr1.end_date
8319 );
8320
8321 debug('l_overlap_days: '||to_char(l_overlap_days), 120);
8322
8323 IF l_overlap_days <> 0 THEN
8324 l_avg_payment := (l_rr1.result*l_overlap_days)/(l_rr1.end_date - l_rr1.start_date + 1 );
8325 debug('l_avg_payment: '||to_char(l_avg_payment), 130);
8326 l_total_val := l_total_val + l_avg_payment * l_rr1.scale;
8327 debug('l_total_val: '||to_char(l_total_val), 140);
8328 END IF ;
8329
8330 ELSIF (l_rr1.end_date BETWEEN p_start_date
8331 AND p_end_date
8332 ) THEN -- g_calendar_avg = 'N', direct addition, no average calculation
8333 debug(l_proc_name, 150) ;
8334 l_total_val := l_total_val + l_rr1.result * l_rr1.scale;
8335 END IF; --(l_rr.start_date >= p_start_date
8336 END IF;
8337 debug('l_total_val :' ||to_char(l_total_val),160) ;
8338 END LOOP;
8339
8340 debug('l_proration: '||l_proration, 170);
8341 -- There is no proration on this asignment, need to get the
8342 -- payroll balance and average calculation is required.
8343 IF l_proration = 'N' THEN
8344 debug(l_proc_name, 180);
8345
8346 l_proration := 'Y'; -- 4336613 : ensuring that we pick the balance only once
8347
8348 --get the balance value as of date earned
8349 -- and get the average value for the number of days in the period.
8350
8351 l_balance_val := hr_gbbal.calc_asg_proc_ptd_date
8352 (p_assignment_id => p_assignment_id
8353 ,p_balance_type_id => p_balance_type_id
8354 ,p_effective_date => p_date_earned
8355 );
8356
8357 debug('l_balance_val: '||to_char(l_balance_val), 190);
8358 -- get the number of days in the period that overlap with the payroll period
8359 IF l_balance_val > 0 THEN
8360
8361 debug(l_proc_name, 210);
8362 l_overlap_days := get_overlap_days
8363 (p_start_date1 => p_start_date
8364 ,p_end_date1 => p_end_date
8365 ,p_start_date2 => p_pay_period_start
8366 ,p_end_date2 => p_date_earned
8367 );
8368 debug('l_overlap_days: '||to_char(l_overlap_days), 220);
8369 l_avg_payment := (l_balance_val*l_overlap_days)/(p_date_earned - p_pay_period_start + 1 );
8370
8371 END IF; --l_balance_val > 0 THEN
8372
8373 debug('l_avg_payment: '||to_char(l_avg_payment), 230);
8374 l_total_val := l_total_val + l_avg_payment;
8375
8376 END IF; --l_proration = 'N'
8377 debug('l_total_val :' ||to_char(l_total_val), 240+l_count/10000) ;
8378
8379 -- END IF; --p_tab_bal_ele_ids.EXISTS(l_element_type_id) THEN -- 5403512
8380
8381 debug(l_proc_name, 250);
8382
8383 -- END LOOP;
8384 -- CLOSE csr_get_eet_info; -- 5403512
8385
8386 debug('l_total_val :' ||to_char(l_total_val), 260) ;
8387 END IF; -- csr_get_asg_act_id%NOTFOUND THEN
8388
8389
8390 IF l_total_val IS NULL THEN
8391 l_total_val := 0;
8392 END IF;
8393
8394 p_val := l_total_val ;
8395
8396 debug_exit(l_proc_name);
8397 RETURN 0 ;
8398
8399 EXCEPTION
8400 WHEN OTHERS THEN
8401 debug_exit(' Others in '||l_proc_name);
8402 p_val := NULL;
8403 raise;
8404
8405 END calc_payment_by_run_rslt ;
8406
8407
8408 --
8409 --
8410 -- PTS: BUG 4135481:
8411 -----adjust_pre_part_payments------
8412 --
8413 -- The following function is used to get the prorated payments for the
8414 -- period at the begining of the Line of Service
8415 -- IN PARAMS:
8416 -- p_balance_type_id: Balance ID for the balance 'Teachers Supperannuable Salary'
8417 -- OUT PARAMS:
8418 -- p_effective_start_date : Start date for the non prorated payments
8419 -- p_effective_end_date : END date for the non prorated payments
8420 -- p_part_payment : Prorated payment for the period.
8421
8422 FUNCTION adjust_pre_part_payments(p_assignment_id IN NUMBER -- in
8423 ,p_balance_type_id IN NUMBER
8424 ,p_effective_start_date IN OUT NOCOPY DATE
8425 ,p_effective_end_date IN OUT NOCOPY DATE
8426 ,p_part_payment OUT NOCOPY NUMBER
8427 ,p_tab_bal_ele_ids IN t_ele_ids_from_bal
8428 ) RETURN NUMBER
8429 IS
8430
8431 --
8432 l_proc_name varchar2(60) := g_proc_name || 'adjust_pre_part_payments';
8433
8434 -- Required for nocopy
8435 l_nc_effective_start_date DATE ;
8436 l_nc_effective_end_date DATE ;
8437
8438 l_return_start_date DATE;
8439 l_return_end_date DATE;
8440 l_effective_start_date DATE;
8441 l_effective_end_date DATE;
8442 l_temp_end_date DATE;
8443 l_pre_payroll_date DATE;
8444 l_pre_part_payment NUMBER := 0 ;
8445 l_pre_payment_exist VARCHAR2(1) := NULL ;
8446 l_return NUMBER := 0;
8447 l_date_earned DATE;
8448
8449 -- RETRO:BUG: 4135481
8450 l_retro_entry VARCHAR2(1):= 'N' ;
8451 l_count NUMBER := 0;
8452 l_retro_dtl csr_get_date_earned_retro%ROWTYPE;
8453
8454
8455 BEGIN
8456 --
8457 debug_enter(l_proc_name);
8458
8459 debug('p_assignment_id :' ||to_char(p_assignment_id),10) ;
8460 debug('p_balance_type_id :' ||to_char(p_balance_type_id)) ;
8461 debug('p_effective_start_date :' ||to_char(p_effective_start_date, 'DD/MM/YYYY')) ;
8462 debug('p_effective_end_date :' ||to_char(p_effective_end_date, 'DD/MM/YYYY')) ;
8463
8464
8465 -- Nocopy changes
8466 l_nc_effective_start_date := p_effective_start_date;
8467 l_nc_effective_end_date := p_effective_end_date;
8468 --
8469
8470 -- initialize the two dates,
8471 -- we may return these dates back as it is ..
8472 l_return_start_date := p_effective_start_date;
8473 l_return_end_date := p_effective_end_date;
8474
8475 -- Get the recent payroll date
8476 -- and check if there are any prorated periods
8477 -- in the date range
8478 OPEN csr_get_previous_payroll_date
8479 ( p_assignment_id => p_assignment_id
8480 ,p_effective_start_date => p_effective_start_date
8481 );
8482 FETCH csr_get_previous_payroll_date INTO l_pre_payroll_date;
8483
8484 IF csr_get_previous_payroll_date%NOTFOUND THEN
8485 -- there is no payroll defined before this date so
8486 -- we can safely assume that this is the start of the period.
8487
8488 l_pre_payment_exist := 'Y' ;
8489
8490 l_effective_start_date := p_effective_start_date ;
8491 l_return_start_date := NULL; --p_effective_start_date ;
8492
8493 debug('l_effective_start_date :' ||to_char(l_effective_start_date, 'DD/MM/YYYY'),20) ;
8494
8495 ELSE --csr_get_previous_payroll_date%NOTFOUND THEN
8496 debug('l_pre_payroll_date :' ||to_char(l_pre_payroll_date, 'DD/MM/YYYY'),30) ;
8497
8498 -- if p_effective_start_date is not start of some payroll period
8499 IF p_effective_start_date > l_pre_payroll_date + 1 THEN
8500 debug(l_proc_name,40) ;
8501 -- Calculate the part payment for start date
8502 l_pre_payment_exist := 'Y' ;
8503 l_effective_start_date := p_effective_start_date;
8504 l_return_start_date := NULL ; -- nedd to set it later...
8505
8506 debug('l_effective_start_date :' ||to_char(l_effective_start_date, 'DD/MM/YYYY'),50) ;
8507 ELSE --p_effective_start_date > l_pre_payroll_date + 1 THEN
8508 debug(l_proc_name, 60);
8509 -- there are no pre_part_payments ..
8510 -- Period start date is the payroll period start date, so we will calculate by
8511 -- using the default logic to get the balance values.
8512 l_pre_payment_exist := 'N' ;
8513 l_return_start_date := p_effective_start_date ;
8514 l_return_end_date := p_effective_end_date ;
8515 END IF ; -- p_effective_start_date > l_pre_payroll_date + 1 THEN
8516
8517 END IF; --sr_get_previous_payroll_date%NOTFOUND THEN
8518
8519 CLOSE csr_get_previous_payroll_date;
8520
8521 debug('l_pre_payment_exist :' ||l_pre_payment_exist, 70) ;
8522 debug('l_effective_start_date :' ||to_char(l_effective_start_date, 'DD/MM/YYYY')) ;
8523 debug('l_return_start_date :' ||to_char(l_return_start_date, 'DD/MM/YYYY')) ;
8524
8525 -- Calculate prorated Period End Date
8526 IF l_pre_payment_exist = 'Y' THEN
8527
8528 debug(l_proc_name, 80);
8529 -- get the end date of the prorateed period....
8530 OPEN csr_get_pre_end_date (c_assignment_id => p_assignment_id
8531 ,c_effective_start_date => l_effective_start_date
8532 ,c_effective_end_date => p_effective_end_date
8533 );
8534 FETCH csr_get_pre_end_date INTO l_temp_end_date;
8535
8536 IF csr_get_pre_end_date%NOTFOUND THEN
8537 -- the period is less than one payroll period defined.
8538 -- hence no Pyroll defined in that period.
8539
8540 debug(l_proc_name, 90);
8541 CLOSE csr_get_pre_end_date;
8542
8543 l_effective_end_date := p_effective_end_date ;
8544 -- theer are no more payroll periods to get the values from.
8545 l_return_end_date := p_effective_end_date;
8546 l_return_start_date := l_effective_start_date;
8547
8548 debug('l_effective_end_date :' ||to_char(l_effective_end_date, 'DD/MM/YYYY'),110) ;
8549
8550 ELSE --csr_get_pre_end_date%NOT FOUND THE
8551
8552
8553 debug(l_proc_name, 120);
8554 CLOSE csr_get_pre_end_date;
8555
8556 debug('l_temp_end_date :' ||to_char(l_temp_end_date, 'DD/MM/YYYY'),130) ;
8557
8558 IF l_temp_end_date = p_effective_end_date THEN
8559 debug(l_proc_name, 135);
8560 -- There are some prorated payments
8561 l_effective_end_date := p_effective_end_date ;
8562 debug('l_effective_end_date :' ||to_char(l_effective_end_date, 'DD/MM/YYYY'),140) ;
8563
8564 -- No more payments left....
8565 l_return_end_date := NULL;
8566
8567 ELSIF l_temp_end_date < p_effective_end_date THEN
8568 -- There are some prorated payments and
8569 -- there are more payments also
8570 debug(l_proc_name, 150);
8571 l_effective_end_date := l_temp_end_date ;
8572 debug('l_effective_end_date :' ||to_char(l_effective_end_date, 'DD/MM/YYYY'),160) ;
8573
8574 -- More payments left....
8575 -- could be full apyment period or part post payments ...
8576 l_return_start_date := l_effective_end_date + 1;
8577 l_return_end_date := p_effective_end_date ;
8578
8579 END IF;
8580
8581 debug('l_effective_end_date :' ||to_char(l_effective_end_date, 'DD/MM/YYYY'),170) ;
8582
8583 END IF; -- --csr_get_pre_end_date%NOT FOUND THEN
8584
8585 debug('l_effective_start_date :' ||to_char(l_effective_start_date, 'DD/MM/YYYY'),180) ;
8586 debug('l_effective_end_date :' ||to_char(l_effective_end_date, 'DD/MM/YYYY')) ;
8587 debug('l_return_start_date :' ||to_char(l_return_start_date, 'DD/MM/YYYY')) ;
8588 debug('l_return_end_date :' ||to_char(l_return_end_date, 'DD/MM/YYYY')) ;
8589
8590 OPEN csr_get_next_payroll_date
8591 ( p_assignment_id => p_assignment_id
8592 ,p_effective_start_date => p_effective_start_date
8593 ) ;
8594 FETCH csr_get_next_payroll_date INTO l_date_earned;
8595
8596 IF csr_get_next_payroll_date%FOUND THEN
8597
8598 CLOSE csr_get_next_payroll_date;
8599
8600 debug('l_date_earned :' ||to_char(l_date_earned,'DD/MM/YYYY'),190) ;
8601
8602 l_return := calc_payment_by_run_rslt
8603 ( p_assignment_id => p_assignment_id
8604 ,p_start_date => l_effective_start_date --in
8605 ,p_end_date => l_effective_end_date --in
8606 ,p_pay_period_start => l_pre_payroll_date + 1
8607 ,p_date_earned => l_date_earned
8608 ,p_balance_type_id => p_balance_type_id
8609 ,p_val => l_pre_part_payment --out
8610 ,p_tab_bal_ele_ids => p_tab_bal_ele_ids -- in -- 4336613 : OSLA_3A
8611 ) ;
8612 debug('l_return :' ||to_char(l_return),210) ;
8613 debug('l_pre_part_payment :' ||to_char(l_pre_part_payment)) ;
8614
8615 ELSE
8616 CLOSE csr_get_next_payroll_date;
8617 debug(l_proc_name, 220);
8618 END IF;
8619
8620
8621 p_part_payment := l_pre_part_payment;
8622 p_effective_start_date := l_return_start_date ;
8623 p_effective_end_date := l_return_end_date ;
8624
8625 -- RETRO:BUG: 4135481
8626 -- check if there are any retro earnings existing
8627 -- for the period.
8628 -- If there are any raise a warning.
8629 -- Still exploring the possibility to fix this.
8630 -- so that we can show the actual payments made in the period
8631
8632 l_count := 1 ;
8633 FOR l_retro_dtl IN csr_get_date_earned_retro
8634 (p_assignment_id => p_assignment_id
8635 ,p_start_date => l_pre_payroll_date + 1
8636 ,p_end_date => l_date_earned
8637 )
8638 LOOP
8639 l_retro_entry := 'Y';
8640 debug('|-----------------------------------------------|', 230+l_count/10000);
8641 debug('element_entry_id : '||to_char(l_retro_dtl.element_entry_id));
8642 debug('element_type_id : '||to_char(l_retro_dtl.element_type_id));
8643 debug('creator_type : '||l_retro_dtl.creator_type);
8644 debug('effective_start_date: '||to_char(l_retro_dtl.effective_start_date,'DD/MM/YYYY'));
8645 debug('effective_end_date : '||to_char(l_retro_dtl.effective_end_date,'DD/MM/YYYY'));
8646 debug('source_start_date : '||to_char(l_retro_dtl.source_start_date,'DD/MM/YYYY'));
8647 debug('source_end_date : '||to_char(l_retro_dtl.source_end_date,'DD/MM/YYYY'));
8648 debug('date_earned : '||to_char(l_retro_dtl.date_earned,'DD/MM/YYYY'));
8649 debug('|-----------------------------------------------|', 240+l_count/10000);
8650 l_count := l_count + 1 ;
8651 END LOOP;
8652
8653 /* IF (l_retro_entry = 'Y') THEN -- changed to remove the warning.
8654 debug('RAISE A WARNING FOR RETRO ENTRIES.......', 250);
8655 -- Find the retro payments here and show them along
8656 -- with the warning message
8657 -- Still investigating the possibility to show the
8658 -- correct payments if both Proration and Retro are
8659 -- enabled and applied on the period.
8660
8661
8662 -- Set the global here to raise a warning from recalc_data_element
8663 -- can not raise a warning from this place,
8664 -- as we don't have the primary assignment id
8665 -- and this function can be called multiple times
8666 -- from Salary Rate/Days Excluded/parttime sal paid functions.
8667
8668 g_raise_retro_warning := 'Y' ;
8669 END IF; */
8670
8671
8672 ELSE --l_pre_payment_exist = 'Y' THEN
8673 debug(l_proc_name, 260);
8674
8675 p_effective_start_date := l_return_start_date ;
8676 p_effective_end_date := l_return_end_date ;
8677 p_part_payment := 0;
8678
8679 END IF ; --l_pre_payment_exist = 'Y' THEN
8680
8681 debug_exit(l_proc_name);
8682
8683 RETURN l_return ;
8684
8685 EXCEPTION
8686 WHEN OTHERS THEN
8687 debug_exit(' Others in '||l_proc_name);
8688 p_effective_start_date := l_nc_effective_start_date ;
8689 p_effective_end_date := l_nc_effective_end_date ;
8690 p_part_payment := 0;
8691 raise;
8692
8693 END adjust_pre_part_payments;
8694
8695
8696 -- PTS: BUG 4135481:
8697 -----adjust_post_part_payments------
8698 --
8699 -- The following function is used to get
8700 -- the prorated payments for the period at
8701 -- the end of the Line of Service . The function
8702 -- checks first if the assigment is terminated.If
8703 -- it is then it fetches the terminated pay amount
8704 -- else it goes and calculates prorated payments
8705 -- at the end of Lines of service.
8706
8707 FUNCTION adjust_post_part_payments(p_assignment_id IN NUMBER
8708 ,p_balance_type_id IN NUMBER
8709 ,p_effective_start_date IN DATE
8710 ,p_effective_end_date IN DATE
8711 ,p_part_payment OUT NOCOPY NUMBER
8712 ,p_tab_bal_ele_ids IN t_ele_ids_from_bal
8713 ) RETURN NUMBER
8714 IS
8715
8716 --
8717 l_proc_name VARCHAR2(60) := g_proc_name || 'adjust_post_part_payments';
8718 l_post_part_payment NUMBER := 0;
8719 l_return NUMBER := 0;
8720 l_date_earned DATE;
8721 --TERM_LSP:BUG :4135481 Check for terminated employees
8722 l_is_terminated VARCHAR2(1) := 'N';
8723
8724 -- RETRO:BUG: 4135481
8725 l_retro_entry VARCHAR2(1):= 'N' ;
8726 l_count NUMBER := 0;
8727 l_retro_dtl csr_get_date_earned_retro%ROWTYPE;
8728 --
8729 BEGIN
8730 --
8731 debug_enter(l_proc_name);
8732
8733 debug('p_assignment_id :' ||to_char(p_assignment_id),10) ;
8734 debug('p_balance_type_id :' ||to_char(p_balance_type_id)) ;
8735 debug('p_effective_start_date:' ||to_char(p_effective_start_date, 'DD/MM/YYYY')) ;
8736 debug('p_effective_end_date :' ||to_char(p_effective_end_date, 'DD/MM/YYYY')) ;
8737 debug('g_terminated_person :' || g_terminated_person) ;
8738
8739
8740 -- check if period length is not ZERO days.
8741 IF( (p_effective_start_date IS NULL) -- no period exists
8742 OR ( (p_effective_start_date IS NOT NULL)
8743 AND (p_effective_start_date > p_effective_end_date)
8744 )
8745 )THEN
8746 debug(l_proc_name,30) ;
8747 -- there are no post_part_payments
8748 -- so return 0
8749 l_post_part_payment := 0 ;
8750
8751 ELSE
8752 -- get the part_payments from run_results
8753 debug(l_proc_name,40) ;
8754
8755 OPEN csr_get_next_payroll_date
8756 ( p_assignment_id => p_assignment_id
8757 ,p_effective_start_date => p_effective_start_date
8758 ) ;
8759 FETCH csr_get_next_payroll_date INTO l_date_earned;
8760
8761 IF csr_get_next_payroll_date%FOUND THEN
8762
8763 CLOSE csr_get_next_payroll_date;
8764
8765 debug('l_date_earned :' ||to_char(l_date_earned,'DD/MM/YYYY'),50) ;
8766
8767 l_return := calc_payment_by_run_rslt
8768 ( p_assignment_id => p_assignment_id
8769 ,p_start_date => p_effective_start_date -- in
8770 ,p_end_date => p_effective_end_date -- in
8771 ,p_pay_period_start => p_effective_start_date -- for Avg calc ...
8772 ,p_date_earned => l_date_earned
8773 ,p_balance_type_id => p_balance_type_id
8774 ,p_val => l_post_part_payment --out
8775 ,p_tab_bal_ele_ids => p_tab_bal_ele_ids -- in -- 4336613 : OSLA_3A
8776 ) ;
8777 debug('l_return :' ||to_char(l_return),60) ;
8778 debug('l_post_part_payment :' ||to_char(l_post_part_payment)) ;
8779
8780
8781 -- RETRO:BUG: 4135481
8782 -- check if there are any retro earnings existing
8783 -- for the period
8784 -- If there are any raise a warning.
8785 -- exploring the possibility to fix this.
8786 -- so that we can show the actual payments made in the period
8787 --
8788 l_count := 1 ;
8789 FOR l_retro_dtl IN csr_get_date_earned_retro
8790 (p_assignment_id => p_assignment_id
8791 ,p_start_date => p_effective_start_date
8792 ,p_end_date => l_date_earned
8793 )
8794 LOOP
8795 l_retro_entry := 'Y';
8796 debug('|-----------------------------------------------|', 70+l_count/10000);
8797 debug('element_entry_id : '||to_char(l_retro_dtl.element_entry_id));
8798 debug('element_type_id : '||to_char(l_retro_dtl.element_type_id));
8799 debug('creator_type : '||l_retro_dtl.creator_type);
8800 debug('effective_start_date: '||to_char(l_retro_dtl.effective_start_date,'DD/MM/YYYY'));
8801 debug('effective_end_date : '||to_char(l_retro_dtl.effective_end_date,'DD/MM/YYYY'));
8802 debug('source_start_date : '||to_char(l_retro_dtl.source_start_date,'DD/MM/YYYY'));
8803 debug('source_end_date : '||to_char(l_retro_dtl.source_end_date,'DD/MM/YYYY'));
8804 debug('date_earned : '||to_char(l_retro_dtl.date_earned,'DD/MM/YYYY'));
8805 debug('|-----------------------------------------------|', 210+l_count/10000);
8806 l_count := l_count + 1 ;
8807 END LOOP;
8808
8809 /* IF (l_retro_entry = 'Y') THEN -- Changed to remove the warning.
8810 debug('......raise a warning for retro entries.......',80);
8811 -- Find the retro payments here and show them along
8812 -- with the warning message
8813 -- Still investigating the possibility to show the
8814 -- correct payments if both Proration and Retro are
8815 -- enabled and applied on the period.
8816
8817 -- Set the global here to raise a warning from recalc_data_element.
8818 -- Can not raise a warning from this place,
8819 -- as we don't have the primary assignment id
8820 -- and this function can be called multiple times
8821 -- from Salary Rate/Days Excluded/parttime sal paid functions.
8822
8823 g_raise_retro_warning := 'Y' ;
8824
8825 END IF; */
8826
8827
8828 ELSE
8829 CLOSE csr_get_next_payroll_date;
8830 debug(l_proc_name, 90);
8831 END IF;
8832
8833
8834 END IF ; --p_effective_start_date > p_effective_end_date THEN
8835
8836
8837 debug(l_proc_name,110) ;
8838
8839 p_part_payment := l_post_part_payment;
8840
8841 debug_exit(l_proc_name);
8842
8843 RETURN l_return ;
8844
8845 END adjust_post_part_payments;
8846
8847
8848
8849
8850
8851
8852 -- CALC_PT_SAL_OPTIONS: BUG : 4135481
8853 -- this function is the older implementation of calc_part_time_sal
8854 -- this is used when g_calc_sal_new is 'N'
8855 -- ----------------------------------------------------------------------------
8856 -- |------------------------< calc_part_time_sal_old >----------------------------|
8857 -- ----------------------------------------------------------------------------
8858 function calc_part_time_sal_old (p_assignment_id in number
8859 ,p_effective_start_date in date
8860 ,p_effective_end_date in date
8861 ,p_business_group_id in number
8862 ,p_next_payroll_start_date out nocopy date -- new parameter to track
8863 --last complete payroll run date
8864 ,p_sal_bal_type_id in number -- 4336613 : OSLA_3A
8865 )
8866 return number is
8867 --
8868 l_proc_name varchar2(60) := g_proc_name || 'calc_part_time_sal_old';
8869 l_effective_date date;
8870 l_total_part_time_sal number := 0;
8871 l_part_time_sal number := 0;
8872 l_supp_claim number := 0;
8873 --
8874 begin
8875 --
8876 -- hr_utility.set_location('Entering: '||l_proc_name, 10);
8877 --
8878 debug_enter(l_proc_name);
8879
8880 debug('p_assignment_id :' ||to_char(p_assignment_id),10) ;
8881 debug('p_effective_start_date :' ||to_char(p_effective_start_date, 'DD/MM/YYYY'),20) ;
8882 debug('p_effective_end_date :' ||to_char(p_effective_end_date, 'DD/MM/YYYY'),30) ;
8883 debug('p_sal_bal_type_id :' ||to_char(p_sal_bal_type_id),35) ;
8884
8885 open csr_get_end_date (c_assignment_id => p_assignment_id
8886 ,c_effective_start_date => p_effective_start_date
8887 ,c_effective_end_date => p_effective_end_date
8888 );
8889 loop
8890
8891 fetch csr_get_end_date into l_effective_date;
8892 exit when csr_get_end_date%notfound;
8893
8894 --
8895 debug(l_proc_name, 40);
8896 --
8897 debug('l_effective_date :'||to_char(l_effective_date, 'DD/MM/YYYY'),50) ;
8898
8899 l_part_time_sal := hr_gbbal.calc_asg_proc_ptd_date
8900 (p_assignment_id => p_assignment_id
8901 -- 4336613 : OSLA_3A : changed from g_sal_bal_type_id
8902 ,p_balance_type_id => p_sal_bal_type_id
8903 ,p_effective_date => l_effective_date
8904 );
8905 debug('l_part_time_sal :'||to_char(l_part_time_sal),60) ;
8906 l_total_part_time_sal := l_total_part_time_sal + l_part_time_sal;
8907
8908 end loop;
8909
8910 close csr_get_end_date;
8911
8912 /*
8913 IF g_date_work_mode = 'Y' AND g_supp_teacher = 'Y' THEN
8914 OPEN csr_get_supp_ded(p_sal_bal_type_id,p_assignment_id,p_effective_start_date,l_effective_date);
8915 FETCH csr_get_supp_ded INTO l_supp_claim;
8916 CLOSE csr_get_supp_ded;
8917 debug('l_supp_claim :'||to_char(l_supp_claim),51);
8918 l_total_part_time_sal := l_total_part_time_sal - l_supp_claim;
8919 debug('l_total_part_time_sal after supply claims deduction:'||to_char(l_total_part_time_sal),52) ;
8920 END IF;
8921 */
8922 --We now need to set date for terminated payments
8923 --If no complete payroll exist for that person
8924 -- eg person assignment starts on 1-apr-2000 and terminates b4 30-apr-2000
8925 -- in such a case, we set the last_payroll_date = effective_start_date of assignment
8926
8927 -- else we set the last_payroll_date = the next day of the last complete payroll end date
8928 -- eg person starts 01-apr2000 and terminates on say 15-jun-2000.
8929 -- Then we set last_payroll_date = 31-may-2000(last complete payrol run date) + 1 = 01-jun-2000
8930
8931 -- BUG : 4273915
8932 IF l_effective_date IS NOT NULL THEN
8933 debug(l_proc_name, 70);
8934 p_next_payroll_start_date := l_effective_date + 1;
8935 ELSE
8936 -- no complete payroll periods
8937 debug(l_proc_name, 80);
8938 p_next_payroll_start_date := p_effective_start_date;
8939 END IF;
8940
8941 debug('l_total_part_time_sal :'||to_char(l_total_part_time_sal),90);
8942 --
8943 -- hr_utility.set_location('Leaving: '||l_proc_name, 30);
8944 --
8945 debug_exit(l_proc_name);
8946
8947 return l_total_part_time_sal;
8948
8949 EXCEPTION
8950 WHEN OTHERS THEN
8951 debug_exit(' Others in '||l_proc_name);
8952 RAISE;
8953 END calc_part_time_sal_old;
8954
8955
8956
8957 -- ----------------------------------------------------------------------------
8958 -- |------------------------< calc_part_time_sal >----------------------------|
8959 -- ----------------------------------------------------------------------------
8960 function calc_part_time_sal (p_assignment_id in number
8961 ,p_effective_start_date in date
8962 ,p_effective_end_date in date
8963 ,p_business_group_id in number
8964 ,p_sal_bal_type_id IN NUMBER DEFAULT NULL --4336613 : OSLA_3A
8965 ,p_cl_bal_type_id IN NUMBER DEFAULT NULL
8966 ,p_tab_bal_ele_ids IN t_ele_ids_from_bal DEFAULT g_tab_sal_ele_ids
8967 )
8968 return number is
8969 --
8970 l_proc_name VARCHAR2(60) := g_proc_name || 'calc_part_time_sal';
8971 l_effective_date DATE;
8972 l_total_part_time_sal NUMBER := 0;
8973 l_part_time_sal NUMBER := 0;
8974 l_cl_sal NUMBER := 0;
8975 l_total_cl_sal NUMBER := 0;
8976 l_effective_start_date DATE ;
8977 l_effective_end_date DATE ;
8978 l_period_start_date DATE ; -- rahul supply
8979 l_period_end_date DATE ; -- rahul supply
8980 l_return NUMBER;
8981
8982 l_pre_part_payment NUMBER :=0;
8983 l_post_part_payment NUMBER :=0;
8984 l_count NUMBER; -- Loop counter
8985
8986 l_terminated_payment NUMBER :=0;
8987
8988 --TERM_LSP:BUG :4135481 Check for terminated employees
8989 l_is_terminated VARCHAR2(1) := 'N';
8990
8991 -- RETRO:BUG: 4135481
8992 l_asg_act_dtl csr_get_asg_act_id_retro%ROWTYPE;
8993 l_error NUMBER;
8994
8995 l_next_payroll_start_date DATE;
8996
8997 -- 4336613 : OSLA_3A
8998 l_sal_bal_type_id NUMBER :=0;
8999 l_cl_bal_type_id NUMBER :=0;
9000 i NUMBER :=0;
9001
9002 l_supp_claim NUMBER := 0;
9003 --
9004 begin
9005
9006 debug_enter(l_proc_name);
9007
9008 debug('p_assignment_id: '||to_char(p_assignment_id), 10);
9009 debug('p_effective_start_date: '||to_char(p_effective_start_date));
9010 debug('p_effective_end_date: '||to_char(p_effective_end_date));
9011 debug('p_business_group_id: '||to_char(p_business_group_id));
9012 debug('p_sal_bal_type_id: '||to_char(p_sal_bal_type_id));
9013
9014 -- PERF_ENHANC_3A : Performance Enhancements
9015 -- check if record corresponding to p_assignment_id is present in the
9016 -- collection g_asg_recalc_details.
9017 -- If yes, check for matching start_date (a double check,although not necessary)
9018 -- If part_time_sal_paid has been calculated before, then the row
9019 -- will contain the value,return it.
9020 -- If part_time_sal_paid for this assignment has not been calculated before,
9021 -- compute it, store it in a row for this assignment_id and return it
9022 -- This step is to avoid recomputing the value for a given LOS. Originally,
9023 -- calculations were repeated for each data element
9024
9025
9026 IF (p_sal_bal_type_id IS NULL -- 4336613 : OSLA_3A : if NULL implies we need to calculate
9027 -- PT sal paid, and not OSLA
9028 AND
9029 g_asg_recalc_details.EXISTS(p_assignment_id) -- check if row exists
9030 AND
9031 g_asg_recalc_details(p_assignment_id).eff_start_date = p_effective_start_date
9032 AND
9033 -- check below to find if PT sal paid has been calculated before
9034 g_asg_recalc_details(p_assignment_id).part_time_sal_paid IS NOT NULL
9035 ) THEN
9036
9037 debug(l_proc_name, 30);
9038 l_total_part_time_sal := g_asg_recalc_details(p_assignment_id).part_time_sal_paid;
9039 debug('l_total_part_time_sal is already present !! '||l_total_part_time_sal, 40);
9040
9041 ELSE -- calc_part_time_paid has to be computed for this assignment_id for this LOS
9042
9043 debug(l_proc_name, 50);
9044
9045 IF p_sal_bal_type_id IS NULL THEN -- calculate PT sal paid, and not OSLA
9046 debug(l_proc_name, 60);
9047 l_sal_bal_type_id := g_sal_bal_type_id(p_business_group_id);
9048 l_cl_bal_type_id := g_cl_bal_type_id(p_business_group_id);
9049 ELSE
9050 debug(l_proc_name, 70);
9051 l_sal_bal_type_id := p_sal_bal_type_id; -- pick up from the parameter
9052 l_cl_bal_type_id := p_cl_bal_type_id;
9053 END IF;
9054
9055 debug('l_sal_bal_type_id : '||l_sal_bal_type_id, 80);
9056
9057
9058 --CALC_PT_SAL_OPTIONS: BUG : 4135481
9059 -- check if calc_part_time_sal OR calc_part_time_sal_old is to be used
9060 /*
9061 IF g_calc_sal_new <> 'Y' AND
9062 (pqp_gb_tp_pension_extracts.g_ext_asg_details(p_assignment_id).estb_number <> '0966' OR
9063 g_date_work_mode <> 'Y') THEN -- switch is YES for old method
9064 */
9065 IF g_calc_sal_new <> 'Y' THEN
9066 debug(l_proc_name, 90);
9067
9068 l_total_part_time_sal := calc_part_time_sal_old
9069 (p_assignment_id => p_assignment_id
9070 ,p_effective_start_date => p_effective_start_date
9071 ,p_effective_end_date => p_effective_end_date
9072 ,p_business_group_id => g_business_group_id
9073 ,p_next_payroll_start_date => l_next_payroll_start_date --BUG : 4273915
9074 -- new parameter (last complete payroll run date)
9075 ,p_sal_bal_type_id => l_sal_bal_type_id -- 4336613 : OSLA_3A
9076 );
9077
9078 debug('l_total_part_time_sal :'||l_total_part_time_sal, 110);
9079 debug('l_next_payroll_start_date:'|| l_next_payroll_start_date);
9080
9081
9082 -- BUG : 4273915
9083 -- We now need to test for terminated person case
9084 -- If no complete payroll exist for that person
9085 -- eg person assignment starts on 1-apr-2000 and terminates b4 30-apr-2000
9086 -- in such a case, we set the last_payroll_date = effective_start_date of assignment
9087
9088 -- else we set the last_payroll_date = the next day of the last complete payroll end date
9089 -- eg person starts 01-apr2000 and terminates on say 15-jun-2000.
9090 -- Then we set last_payroll_date = 31-may-2000(last complete payrol run date) + 1 = 01-jun-2000
9091
9092
9093 --Check for terminated employees
9094 IF g_terminated_person = 'Y' THEN
9095
9096 debug(l_proc_name, 120);
9097
9098 l_is_terminated := get_terminated_payments
9099 ( p_assignment_id => p_assignment_id
9100 ,p_effective_start_date => l_next_payroll_start_date
9101 ,p_effective_end_date => p_effective_end_date
9102 ,p_business_group_id => g_ext_asg_details(p_assignment_id).business_group_id
9103 ,p_part_payment => l_terminated_payment
9104 ,p_balance_type_id => l_sal_bal_type_id -- 4336613 : OSLA_3A
9105 ) ;
9106
9107 l_total_part_time_sal := l_total_part_time_sal + l_terminated_payment;
9108 debug('l_is_terminated :'|| l_is_terminated ,130);
9109 debug('l_post_part_payment :'|| to_char(l_post_part_payment));
9110 debug('l_total_part_time_sal :'|| to_char(l_total_part_time_sal) );
9111
9112 END IF;
9113
9114
9115 ELSE -- g_calc_sal_new = 'Y', use the new implementation of calc_part_time_sal
9116
9117 debug('p_assignment_id :' ||to_char(p_assignment_id),140) ;
9118 debug('p_effective_start_date :' ||to_char(p_effective_start_date, 'DD/MM/YYYY')) ;
9119 debug('p_effective_end_date :' ||to_char(p_effective_end_date, 'DD/MM/YYYY')) ;
9120
9121 l_effective_end_date := p_effective_end_date ;
9122 l_effective_start_date := p_effective_start_date ;
9123
9124 -- PTS: BUG 4135481: get the total salary payments in THREE parts
9125 -- (1) Pre payments : any prorated payment in the begining of the period
9126 -- (2) Payments for Full Payroll Periods
9127 -- (3) Post Payment: any prorated payments at the end of the period.
9128
9129
9130 --If the person is not terminated then his salary is calculated as per
9131 --regular post_part_payment method.
9132 IF g_proration = 'Y'
9133 THEN
9134 debug('g_proration is set to Y',299);
9135 debug('g_ext_asg_details(p_assignment_id).location_id : ' || to_char(g_ext_asg_details(p_assignment_id).location_id),1212);
9136 debug('pqp_gb_tp_pension_extracts.g_ext_asg_details(p_assignment_id).estb_number :'|| pqp_gb_tp_pension_extracts.g_ext_asg_details(p_assignment_id).estb_number, 300) ;
9137 debug('g_date_work_mode is set to ' || g_date_work_mode,299);
9138 -- IF pqp_gb_tp_pension_extracts.g_ext_asg_details(p_assignment_id).estb_number <> '0966' OR g_date_work_mode <> 'Y' THEN
9139 debug(l_proc_name, 150);
9140 -- get the pre payments here. (if any)
9141 -- the function returns the modified dates for the Full Pyroll Periods
9142 -- these will be used to get the Full Payroll Period payments.
9143 l_return := adjust_pre_part_payments
9144 ( p_assignment_id => p_assignment_id -- in
9145 ,p_balance_type_id => l_sal_bal_type_id -- 4336613 : OSLA_3A : g_sal_bal_type_id(p_business_group_id)
9146 ,p_effective_start_date => l_effective_start_date --in/out
9147 ,p_effective_end_date => l_effective_end_date -- in/out
9148 ,p_part_payment => l_pre_part_payment -- out
9149 ,p_tab_bal_ele_ids => p_tab_bal_ele_ids -- in -- 4336613 : OSLA_3A
9150 );
9151
9152 debug('l_return :'||to_char(l_return),160) ;
9153 debug('l_pre_part_payment :'||to_char(l_pre_part_payment)) ;
9154 debug('l_effective_start_date :'||to_char(l_effective_start_date, 'DD/MM/YYYY')) ;
9155 debug('l_effective_end_date :'||to_char(l_effective_end_date, 'DD/MM/YYYY')) ;
9156 -- END IF;
9157 END IF;
9158 -- 4336613 : moved code to fetch defined balance id to global settings.
9159
9160 l_count := 1;
9161 -- IF pqp_gb_tp_pension_extracts.g_ext_asg_details(p_assignment_id).estb_number = '0966' and g_date_work_mode = 'Y' THEN
9162 --ELSE
9163 debug('Calling csr_get_asg_act_id_retro',302);
9164
9165 OPEN csr_get_asg_act_id_retro
9166 (p_assignment_id => p_assignment_id
9167 ,p_effective_start_date => l_effective_start_date
9168 ,p_effective_end_date => l_effective_end_date
9169 );
9170 LOOP
9171
9172 FETCH csr_get_asg_act_id_retro into l_asg_act_dtl;
9173 EXIT WHEN csr_get_asg_act_id_retro%NOTFOUND;
9174 debug('calling get value for date earned mode',303);
9175 debug('Defined balance id = '||to_char(g_def_bal_id(l_sal_bal_type_id)),304);
9176
9177 debug('assignment_action_id: '||to_char(l_asg_act_dtl.assignment_action_id), 170+l_count/10000);
9178 debug('date_earned: '||to_char(l_asg_act_dtl.date_earned,'DD/MM/YYYY'));
9179 l_part_time_sal := pay_balance_pkg.get_value
9180 ( p_defined_balance_id => g_def_bal_id(l_sal_bal_type_id)
9181 ,p_assignment_action_id => l_asg_act_dtl.assignment_action_id
9182 ) ;
9183
9184 debug('l_part_time_sal :'||to_char(l_part_time_sal), 180+l_count/10000) ;
9185
9186 l_count := l_count + 1 ;
9187 l_effective_date := l_asg_act_dtl.date_earned;
9188 l_total_part_time_sal := l_total_part_time_sal + l_part_time_sal;
9189 debug('l_total_part_time_sal :'||to_char(l_total_part_time_sal),190+l_count/10000) ;
9190
9191 END loop;
9192 CLOSE csr_get_asg_act_id_retro;
9193
9194 /*
9195 IF g_date_work_mode = 'Y' AND g_supp_teacher = 'Y' THEN
9196 OPEN csr_get_supp_ded(l_sal_bal_type_id,p_assignment_id,l_effective_start_date,l_effective_end_date);
9197 FETCH csr_get_supp_ded INTO l_supp_claim;
9198 CLOSE csr_get_supp_ded;
9199 debug('l_supp_claim :'||to_char(l_supp_claim),208);
9200 l_total_part_time_sal := l_total_part_time_sal - l_supp_claim;
9201 debug('l_total_part_time_sal after supply claims deduction:'||to_char(l_total_part_time_sal),209) ;
9202 END IF;
9203 */
9204
9205 -- END IF;
9206
9207
9208 debug('l_total_part_time_sal :'||to_char(l_total_part_time_sal),210) ;
9209 debug('.....retro payments calc over.....') ;
9210
9211 debug('l_effective_date :'||to_char(l_effective_date, 'DD/MM/YYYY'),220) ;
9212
9213
9214 -- PTS:BUG 4135481: get the post payments here. (if any)
9215 IF l_effective_date IS NOT NULL THEN
9216
9217 debug(l_proc_name, 230);
9218 -- there were few Full payroll periods
9219 -- so the start for the for post payment is the end of Full Payroll Periods.
9220 l_effective_date := l_effective_date + 1; -- next date of he last payroll date
9221
9222 ELSE -- l_effective_date IS NOT NULL THEN
9223 -- it implies that there are no complete Payroll Periods
9224 -- so get the Post payments (if any)
9225 -- for the remaining days in the period.
9226 debug(l_proc_name, 240);
9227 l_effective_date := l_effective_start_date;
9228
9229 END IF;
9230
9231 debug('l_effective_start_date :' ||to_char(l_effective_start_date, 'DD/MM/YYYY'),250) ;
9232 debug('p_effective_end_date :' ||to_char(p_effective_end_date, 'DD/MM/YYYY')) ;
9233
9234
9235 --CALC_PT_SAL_OPTIONS: BUG : 4135481
9236 --TERM_LSP:BUG :4135481 Check for terminated employees
9237 --if the global is set to Y then check if the person is terminated
9238 IF g_terminated_person = 'Y' THEN
9239
9240 debug(l_proc_name, 260);
9241
9242 l_is_terminated := get_terminated_payments
9243 ( p_assignment_id => p_assignment_id
9244 ,p_effective_start_date => l_effective_date
9245 ,p_effective_end_date => p_effective_end_date
9246 ,p_business_group_id => g_ext_asg_details(p_assignment_id).business_group_id
9247 ,p_part_payment => l_terminated_payment
9248 ,p_balance_type_id => l_sal_bal_type_id -- 4336613 : OSLA_3A : g_sal_bal_type_id(p_business_group_id)
9249 );
9250 debug('l_is_terminated :'|| l_is_terminated ,270);
9251 END IF;
9252
9253
9254 --If the person is not terminated then his salary is calculated as per
9255 --regular post_part_payment method.
9256 IF l_is_terminated = 'N' AND g_proration = 'Y'
9257 THEN
9258
9259 debug(l_proc_name, 280);
9260 l_return := adjust_post_part_payments
9261 ( p_assignment_id => p_assignment_id
9262 ,p_balance_type_id => l_sal_bal_type_id -- 4336613 : OSLA_3A : parameter based
9263 ,p_effective_start_date => l_effective_date
9264 ,p_effective_end_date => p_effective_end_date
9265 ,p_part_payment => l_post_part_payment -- out
9266 ,p_tab_bal_ele_ids => p_tab_bal_ele_ids -- in -- 4336613 : OSLA_3A
9267 );
9268 debug('l_return :' ||to_char(l_return),290) ;
9269 debug('l_post_part_payment :' ||to_char(l_post_part_payment)) ;
9270 END IF;
9271
9272
9273 debug('l_pre_part_payment :'||to_char(l_pre_part_payment),310);
9274 debug('l_total_part_time_sal :'||to_char(l_total_part_time_sal));
9275 debug('l_post_part_payment :'||to_char(l_post_part_payment));
9276
9277 -- PTS: BUG 4135481: add all the payments to get the final payments
9278 l_total_part_time_sal := l_pre_part_payment + l_total_part_time_sal
9279 + l_post_part_payment + l_terminated_payment;
9280
9281 END IF; -- end of check if calc_part_time_sal OR calc_part_time_sal_old is to be used
9282
9283 IF g_date_work_mode = 'Y' THEN
9284 debug('Calling csr_get_asg_act_id_dw',302);
9285 OPEN csr_get_asg_act_id_dw
9286 (p_assignment_id => p_assignment_id
9287 ,p_effective_start_date => p_effective_start_date
9288 ,p_effective_end_date => p_effective_end_date
9289 );
9290 FETCH csr_get_asg_act_id_dw into l_asg_act_dtl;
9291 CLOSE csr_get_asg_act_id_dw;
9292
9293 OPEN csr_get_dw_value(l_cl_bal_type_id,
9294 l_asg_act_dtl.assignment_action_id,
9295 p_effective_start_date,
9296 p_effective_end_date
9297 );
9298 FETCH csr_get_dw_value INTO l_cl_sal;
9299 CLOSE csr_get_dw_value;
9300
9301 l_total_cl_sal := l_cl_sal;
9302 l_effective_date := p_effective_end_date;
9303 l_total_part_time_sal := l_total_part_time_sal + l_total_cl_sal;
9304 END IF;
9305
9306 IF l_total_part_time_sal IS NULL THEN
9307 debug(l_proc_name, 320);
9308 l_total_part_time_sal := 0;
9309 END IF;
9310
9311 debug('l_total_part_time_sal :'||to_char(l_total_part_time_sal),330);
9312
9313
9314 IF p_sal_bal_type_id IS NULL THEN -- 4336613 : OSLA_3A : check if OSLA or PT sal paid
9315 -- IF null => PT sal paid is being computed
9316 debug(l_proc_name, 340);
9317 -- PERF_ENHANC_3A : performance enhancements
9318 -- computed part_time_sal_paid value being stored in the collection for future use
9319 g_asg_recalc_details(p_assignment_id).part_time_sal_paid := l_total_part_time_sal;
9320 debug('l_total_part_time_sal (1st time computation) :'||l_total_part_time_sal, 350);
9321
9322 END IF;
9323 debug(l_proc_name, 350);
9324 END IF; -- IF (g_asg_recalc_details.EXISTS.... )
9325
9326 debug(l_proc_name, 360);
9327 debug_exit(l_proc_name);
9328
9329 return l_total_part_time_sal;
9330
9331 EXCEPTION
9332 WHEN OTHERS THEN
9333 debug_exit(' Others in '||l_proc_name);
9334 RAISE;
9335 END calc_part_time_sal;--
9336
9337
9338 -- 4336613 : OSLA_3A : GET_GROSSED_OSLA_PAYMENTS
9339 -- calculates the OSLA payments for a LOS, and grosses it up for the year.
9340 --
9341 -- ----------------------------------------------------------------------------
9342 -- |------------------------< get_grossed_osla_payments >----------------------------|
9343 -- ----------------------------------------------------------------------------
9344 function get_grossed_osla_payments (p_assignment_id in number
9345 ,p_effective_start_date in date
9346 ,p_effective_end_date in date
9347 ,p_business_group_id in number
9348 )
9349 return number is
9350 --
9351 l_proc_name VARCHAR2(60) := g_proc_name || 'get_grossed_osla_payments';
9352 l_grossed_osla_payment NUMBER := 0;
9353 l_return NUMBER;
9354
9355 --
9356 begin
9357
9358 debug_enter(l_proc_name);
9359 debug('p_effective_start_date: '||to_char(p_effective_start_date), 10);
9360 debug('p_effective_end_date: '||to_char(p_effective_end_date));
9361
9362 debug('TOTAL number of OSLA elements: '|| to_char(g_tab_osla_ele_ids.COUNT), 20);
9363
9364 IF g_tab_osla_ele_ids.COUNT > 0 THEN
9365
9366 debug(l_proc_name, 30) ;
9367 -- a call to calc_part_time_sal
9368 -- the last 2 parameters have been introduced in part_time_sal to make it generic
9369 l_grossed_osla_payment := calc_part_time_sal
9370 (p_assignment_id => p_assignment_id
9371 ,p_effective_start_date => p_effective_start_date
9372 ,p_effective_end_date => p_effective_end_date
9373 ,p_business_group_id => g_business_group_id
9374 ,p_sal_bal_type_id => g_osla_bal_type_id(p_business_group_id)
9375 ,p_cl_bal_type_id => g_osla_cl_bal_type_id(p_business_group_id)
9376 ,p_tab_bal_ele_ids => g_tab_osla_ele_ids
9377 );
9378 debug('l_grossed_osla_payment: '||to_char(l_grossed_osla_payment), 40) ;
9379
9380 -- grossing up the payment to calculate the rate
9381 l_grossed_osla_payment := ((l_grossed_osla_payment * 365) / (trunc(p_effective_end_date) - trunc(p_effective_start_date) + 1));
9382
9383 ELSE
9384 debug(l_proc_name, 50) ;
9385 l_grossed_osla_payment := 0;
9386 END IF;
9387
9388 debug('l_grossed_osla_payment :'||to_char(l_grossed_osla_payment),60);
9389
9390 debug_exit(l_proc_name);
9391
9392 return l_grossed_osla_payment;
9393
9394 EXCEPTION
9395 WHEN OTHERS THEN
9396 debug_exit(' Others in '||l_proc_name);
9397 RAISE;
9398 END get_grossed_osla_payments;
9399
9400
9401 -- ----------------------------------------------------------------------------
9402 -- |------------------------< get_part_time_sal_date >------------------------|
9403 -- ----------------------------------------------------------------------------
9404 function get_part_time_sal_date (p_assignment_id in number
9405 ,p_effective_start_date in date
9406 ,p_effective_end_date in date
9407 )
9408 return number is
9409 --
9410 l_proc_name varchar2(60) := g_proc_name || 'get_part_time_sal_date';
9411 l_part_time_sal number := 0;
9412 l_tab_mult_asg t_sec_asgs_type;
9413 l_error number;
9414 l_sec_eff_start_date date;
9415 l_sec_eff_end_date date;
9416 i number;
9417 l_eff_sec_count NUMBER := 0 ;--Sec asg tchr on p_effective_start_date
9418 l_look_for_sec_asg varchar2(1) := 'Y';
9419 --
9420 begin
9421 --
9422 -- hr_utility.set_location('Entering: '||l_proc_name, 10);
9423 --
9424 debug_enter(l_proc_name);
9425 debug('p_assignment_id: '||p_assignment_id);
9426 debug('p_effective_start_date: '||p_effective_start_date);
9427 debug('p_effective_end_date: '||p_effective_end_date);
9428
9429 debug('g_part_time_asg_count: '||g_part_time_asg_count,10);
9430 -- Bugfix 3803760:FTSUPPLY
9431 -- If override ft asg is set, always return zero
9432 IF g_override_ft_asg_id IS NOT NULL THEN
9433 debug('Override is set, returning zero', 11);
9434 debug_exit(l_proc_name);
9435 RETURN 0;
9436 -- if there are multiple concurrent part time assignment (primary or secondary) and ft sal rates are not equal
9437 ELSIF g_part_time_asg_count > 1 AND g_equal_sal_rate = 'N' THEN
9438 debug('PT Asg count > zero, returning one', 12);
9439 debug_exit(l_proc_name);
9440 RETURN 1;
9441 END IF ;
9442
9443 -- Check for multiple teaching assignments
9444 -- Bugfix 3803760:FTSUPPLY : Now using g_tab_sec_asgs instead of
9445 -- calling get_eff_secondary_asgs
9446 l_tab_mult_asg := g_tab_sec_asgs;
9447
9448 debug('l_tab_mult_asg.count: '||l_tab_mult_asg.count,20);
9449 l_eff_sec_count := l_tab_mult_asg.count ;
9450
9451 -- there are concurrent assignments and ft sal rates are not equal
9452 IF l_eff_sec_count > 1 AND g_equal_sal_rate = 'N' THEN
9453
9454 debug_exit(l_proc_name);
9455 RETURN 1;
9456
9457 END IF;
9458
9459 -- Call this function only if primary assignment qualifies for
9460 -- report
9461 -- Bug Fix 3073562:GAP6
9462
9463 debug('assignemnt_id: '||p_assignment_id,50);
9464 debug('start_date: '||g_ext_asg_details(p_assignment_id).start_date);
9465 debug('teacher_start_date: '||g_ext_asg_details(p_assignment_id).teacher_start_date);
9466 debug('leaver_date: '||g_ext_asg_details(p_assignment_id).leaver_date);
9467 debug('restarter_date: '||g_ext_asg_details(p_assignment_id).restarter_date);
9468
9469 -- MULT-LR --
9470 -- Use the new Function to check the effectivness of an assignment
9471 -- it takes care of multiple Leaver-Restarter events
9472 -- where as the old logic used to take into account
9473 -- only the first restarter event.
9474 IF ( chk_effective_asg (
9475 p_assignment_id => p_assignment_id
9476 ,p_effective_date => p_effective_start_date
9477 ) = 'Y'
9478 )
9479 THEN
9480 debug(l_proc_name, 60);
9481
9482 --if only the primary is valid on the start date or the ft sal rate is same as other pt assignments.
9483 IF l_eff_sec_count = 0 OR g_equal_sal_rate = 'Y' THEN
9484 --
9485 debug(l_proc_name, 70);
9486 --
9487 l_part_time_sal := l_part_time_sal +
9488 calc_part_time_sal
9489 (p_assignment_id => p_assignment_id
9490 ,p_effective_start_date => p_effective_start_date
9491 ,p_effective_end_date => p_effective_end_date
9492 ,p_business_group_id => g_business_group_id
9493 );
9494
9495 -- l_part_time_sal := round(l_part_time_sal);
9496 debug('l_part_time_sal of asg '||p_assignment_id||' = '||l_part_time_sal,70);
9497 -- Look for Secondary assignments also if FT sal rate is equal
9498 IF g_equal_sal_rate = 'Y' THEN
9499 l_look_for_sec_asg := 'Y';
9500 ELSE
9501 l_look_for_sec_asg := 'N';
9502 END IF;
9503 debug('look for secondary assignments ' || l_look_for_sec_asg,70);
9504 ELSE -- secondary assignment exists
9505 debug(l_proc_name, 80);
9506 debug_exit (l_proc_name);
9507
9508 RETURN 1;
9509
9510 END IF; -- End if of secondary assignment check ...
9511
9512 -- ELSE -- primary assignment does not qualify
9513 END IF; -- End if of primary assignment qualifies check ...
9514
9515 -- Fetch the part time salary information if there is
9516 -- only one secondary assignment
9517 debug(l_proc_name, 90);
9518 -- IF l_eff_sec_count = 1 THEN
9519 IF l_look_for_sec_asg = 'Y' THEN
9520 --
9521 debug(l_proc_name, 110);
9522 --
9523 i := l_tab_mult_asg.FIRST ;
9524
9525 WHILE i IS NOT NULL
9526 LOOP
9527 l_sec_eff_start_date := greatest
9528 (p_effective_start_date
9529 ,g_ext_asg_details(l_tab_mult_asg(i).assignment_id).start_date
9530 );
9531
9532 -- MULT-LR --
9533 -- Use the new Function to get the correct end date
9534 -- based on the multiple restarter events
9535 -- It takes care of multiple Leaver-Restarter events
9536 -- where as the old logic used to take into account
9537 -- only the first restarter event.
9538
9539 -- Performance changes
9540 -- no need to call tihs function as we are checking assignment status in chk_effective_asg
9541 /*
9542 l_sec_eff_end_date := get_eff_end_date (
9543 p_assignment_id => l_tab_mult_asg(i).assignment_id
9544 ,p_effective_start_date => p_effective_start_date
9545 ,p_effective_end_date => p_effective_end_date
9546 ) ;
9547 */
9548
9549 l_sec_eff_end_date := p_effective_end_date;
9550
9551 debug('l_sec_eff_end_date: '|| to_char(l_sec_eff_end_date,'DD/MM/YYYY'),112) ;
9552
9553 l_part_time_sal := l_part_time_sal +
9554 calc_part_time_sal
9555 (p_assignment_id => l_tab_mult_asg(i).assignment_id
9556 ,p_effective_start_date => l_sec_eff_start_date
9557 ,p_effective_end_date => l_sec_eff_end_date
9558 ,p_business_group_id => g_ext_asg_details(l_tab_mult_asg(i).assignment_id).business_group_id
9559 );
9560 debug('l_part_time_sal of after processing asg '||l_tab_mult_asg(i).assignment_id||' = '||l_part_time_sal,80);
9561 -- l_part_time_sal := round(l_part_time_sal);
9562
9563 i := l_tab_mult_asg.NEXT(i);
9564 END LOOP;
9565
9566 ELSE -- no secondary assignments
9567
9568 -- l_part_time_sal := 0; --condition should not arise
9569 debug (l_proc_name ||' This Condition should not arise..',115 );
9570
9571 END IF; -- End if of secondary assignment exists check ...
9572 -- round the pt salary after adding all the asg contributions.
9573 l_part_time_sal := round(l_part_time_sal);
9574 --
9575 -- hr_utility.set_location('Leaving: '||l_proc_name, 30);
9576 --
9577 debug('l_part_time_sal :'||to_char(l_part_time_sal),120);
9578
9579 -- 4336613 : SAL_VALIDAT_3A : Check whether part time sal value has exceeeded 5 digit limit
9580 -- If yes, raise warning.
9581 if l_part_time_sal > 999999 then
9582
9583 l_error := pqp_gb_tp_extract_functions.raise_extract_warning
9584 (p_assignment_id => p_assignment_id
9585 ,p_error_text => 'BEN_93042_EXT_TP1_PT_SAL_EXC'
9586 ,p_error_number => 93042
9587 ,p_token1 => TO_CHAR(l_part_time_sal) -- bug : 4336613
9588 );
9589 l_part_time_sal := 999999; -- 4336613 : SAL_VALIDAT_3A : set to 99999 if > 99999
9590
9591 end if; -- end if of part time sal value maxim limit check ...
9592
9593 debug('l_part_time_sal :'||to_char(l_part_time_sal),125);
9594
9595 debug_exit(l_proc_name);
9596 return l_part_time_sal;
9597
9598 EXCEPTION
9599 WHEN OTHERS THEN
9600 debug_exit(' Others in '||l_proc_name);
9601 RAISE;
9602 end get_part_time_sal_date;
9603
9604 --
9605 -- ----------------------------------------------------------------------------
9606 -- |------------------------< calc_days_worked >------------------------------|
9607 -- ----------------------------------------------------------------------------
9608 function calc_days_worked (p_assignment_id in number
9609 ,p_effective_start_date in date
9610 ,p_effective_end_date in date
9611 ,p_annual_sal_rate in number
9612 )
9613 return number is
9614 --
9615 l_proc_name varchar2(60) := g_proc_name || 'calc_days_worked';
9616 l_part_time_sal number;
9617 l_days_worked number := 0;
9618 --
9619 begin
9620 --
9621 -- hr_utility.set_location ('Entering: '||l_proc_name, 10);
9622 --
9623 debug_enter(l_proc_name);
9624
9625 -- Call this function only if salary rate is non zero
9626
9627 if p_annual_sal_rate <> 0 then
9628
9629 -- Get part time salary paid for this period
9630
9631 l_part_time_sal := calc_part_time_sal
9632 (p_assignment_id => p_assignment_id
9633 ,p_effective_start_date => p_effective_start_date
9634 ,p_effective_end_date => p_effective_end_date
9635 ,p_business_group_id => g_ext_asg_details(p_assignment_id).business_group_id
9636 );
9637
9638 -- Calculate days worked
9639
9640 l_days_worked := (l_part_time_sal/p_annual_sal_rate) * 365;
9641
9642 else
9643
9644 l_days_worked := 0;
9645
9646 end if; -- end if of annual rate value check ...
9647
9648 --
9649 -- hr_utility.set_location ('Leaving: '||l_proc_name, 20);
9650 --
9651 debug('l_days_worked :'||to_char(l_days_worked));
9652 debug_exit(l_proc_name);
9653
9654 return l_days_worked;
9655
9656 --
9657 EXCEPTION
9658 WHEN OTHERS THEN
9659 debug_exit(' Others in '||l_proc_name);
9660 RAISE;
9661 end calc_days_worked;
9662 --
9663 -- ----------------------------------------------------------------------------
9664 -- |------------------------< get_eev_info >----------------------------------|
9665 -- ----------------------------------------------------------------------------
9666 procedure get_eev_info (p_element_entry_id in number
9667 ,p_input_value_id in number
9668 ,p_effective_start_date in date
9669 ,p_effective_end_date in date
9670 ,p_tab_eev_info out nocopy csr_get_eev_info_date%rowtype
9671 ) is
9672 --
9673 l_proc_name varchar2(60) := g_proc_name || 'get_eev_info';
9674 --
9675 begin
9676 --
9677 -- hr_utility.set_location ('Entering: '||l_proc_name, 10);
9678 --
9679 debug_enter(l_proc_name);
9680
9681 open csr_get_eev_info_date
9682 (c_element_entry_id => p_element_entry_id
9683 ,c_input_value_id => p_input_value_id
9684 ,c_effective_start_date => p_effective_start_date
9685 ,c_effective_end_date => p_effective_end_date
9686 );
9687 fetch csr_get_eev_info_date into p_tab_eev_info;
9688 close csr_get_eev_info_date;
9689
9690 --
9691 -- hr_utility.set_location ('Leaving :'||l_proc_name, 20);
9692 --
9693 debug_exit(l_proc_name);
9694
9695 -- Added by tmehra for nocopy changes Feb'03
9696
9697 EXCEPTION
9698 WHEN OTHERS THEN
9699 debug_exit(' Others in '||l_proc_name);
9700 p_tab_eev_info := NULL;
9701 raise;
9702
9703 end get_eev_info;
9704 --
9705 -- ----------------------------------------------------------------------------
9706 -- |------------------------< get_days_absent >-------------------------------|
9707 -- ----------------------------------------------------------------------------
9708 function get_days_absent (p_element_type_id in number
9709 ,p_element_entry_id in number
9710 ,p_effective_start_date in date
9711 ,p_effective_end_date in date
9712 )
9713 return number is
9714 --
9715 l_proc_name varchar2(60) := g_proc_name || 'get_days_absent';
9716 l_start_dt_iv_info csr_get_iv_info%rowtype;
9717 l_days_abs_iv_info csr_get_iv_info%rowtype;
9718 l_start_dt_vals csr_get_eev_info%rowtype;
9719 l_days_abs_vals csr_get_eev_info%rowtype;
9720 l_abs_start_day date;
9721 l_days number := 0;
9722 l_total_days number := 0;
9723 l_ref_date date;
9724 --
9725 begin
9726 --
9727 -- hr_utility.set_location ('Entering: '||l_proc_name, 10);
9728 --
9729 debug_enter(l_proc_name);
9730
9731 -- Get input value id for Start Date
9732 open csr_get_iv_info
9733 (c_element_type_id => p_element_type_id
9734 ,c_input_value_name => 'Start Date'
9735 );
9736 fetch csr_get_iv_info into l_start_dt_iv_info;
9737 close csr_get_iv_info;
9738
9739 -- Get input value id for Days Absent
9740 open csr_get_iv_info
9741 (c_element_type_id => p_element_type_id
9742 ,c_input_value_name => 'Days Absent'
9743 );
9744 fetch csr_get_iv_info into l_days_abs_iv_info;
9745 close csr_get_iv_info;
9746
9747 -- Get eev info for start date input value
9748 --
9749 debug (l_proc_name, 20);
9750 --
9751
9752 open csr_get_eev_info
9753 (c_element_entry_id => p_element_entry_id
9754 ,c_input_value_id => l_start_dt_iv_info.input_value_id
9755 ,c_effective_start_date => p_effective_start_date
9756 ,c_effective_end_date => p_effective_end_date
9757 );
9758 loop
9759 fetch csr_get_eev_info into l_start_dt_vals;
9760 exit when csr_get_eev_info%notfound;
9761
9762 l_abs_start_day := fnd_date.canonical_to_date(l_start_dt_vals.screen_entry_value);
9763 if trunc(p_effective_end_date) < trunc(l_abs_start_day)
9764 then
9765
9766 exit;
9767
9768 end if; -- end if of effective end date check ...
9769
9770 -- Get eev info for Days absent input value
9771 --
9772 debug (l_proc_name, 30);
9773 --
9774 get_eev_info (p_element_entry_id => p_element_entry_id
9775 ,p_input_value_id => l_days_abs_iv_info.input_value_id
9776 ,p_effective_start_date => l_start_dt_vals.effective_start_date
9777 ,p_effective_end_date => l_start_dt_vals.effective_end_date
9778 ,p_tab_eev_info => l_days_abs_vals
9779 );
9780
9781 -- BUGFIX 2340488
9782 -- Change line below, now doing a minus 1
9783 l_ref_date := (trunc(l_abs_start_day) +
9784 l_days_abs_vals.screen_entry_value) - 1;
9785
9786 if l_ref_date > trunc(p_effective_end_date) then
9787
9788 -- BUGFIX 2340488
9789 -- Changed line below, now doing a + 1
9790 l_days := (trunc(p_effective_end_date) -
9791 trunc(l_abs_start_day)) + 1;
9792
9793 else
9794
9795 -- Bug fix 2419860
9796 if l_ref_date >= trunc(p_effective_start_date) and
9797 trunc(p_effective_start_date) > trunc(l_abs_start_day)
9798 then
9799
9800 l_days := (l_ref_date - trunc(p_effective_start_date)) + 1;
9801
9802 elsif trunc(p_effective_start_date) <= trunc(l_abs_start_day) then
9803
9804 l_days := l_days_abs_vals.screen_entry_value;
9805
9806 end if; -- end of of ref_date > eff_start_date check...
9807
9808 end if; -- end if of ref date check ...
9809
9810 l_total_days := l_total_days + l_days;
9811
9812 end loop;
9813 close csr_get_eev_info;
9814
9815 debug('l_total_days :'||to_char(l_total_days), 40);
9816 --
9817 -- hr_utility.set_location ('Leaving: '||l_proc_name, 40);
9818 --
9819 debug_exit(l_proc_name);
9820
9821 return l_total_days;
9822
9823 EXCEPTION
9824 WHEN OTHERS THEN
9825 debug_exit(' Others in '||l_proc_name);
9826 RAISE;
9827 end get_days_absent;
9828 --
9829 -- ----------------------------------------------------------------------------
9830 -- |------------------------< get_eet_info >----------------------------------|
9831 -- ----------------------------------------------------------------------------
9832 function get_eet_info (p_assignment_id in number
9833 ,p_tab_ele_ids in t_ele_ids_from_bal
9834 ,p_effective_start_date in date
9835 ,p_effective_end_date in date
9836 )
9837 return number is
9838 --
9839 l_proc_name varchar2(60) := g_proc_name || 'get_eet_info';
9840 l_eet_details csr_get_eet_info%rowtype;
9841 l_days_absent number := 0;
9842 l_total_days number := 0;
9843 --
9844 begin
9845 --
9846 -- hr_utility.set_location ('Entering: '||l_proc_name, 10);
9847 --
9848 debug_enter(l_proc_name);
9849
9850 -- Check element entries exist in absence ele's
9851
9852 open csr_get_eet_info
9853 (c_assignment_id => p_assignment_id
9854 ,c_effective_start_date => p_effective_start_date
9855 ,c_effective_end_date => p_effective_end_date
9856 );
9857 loop
9858
9859 fetch csr_get_eet_info into l_eet_details;
9860 exit when csr_get_eet_info%notfound;
9861
9862 if p_tab_ele_ids.exists(l_eet_details.element_type_id) then
9863
9864 -- absence element exists
9865 -- get the no of days from the element
9866 --
9867 debug (l_proc_name, 20);
9868 --
9869 l_days_absent := get_days_absent
9870 (p_element_type_id => l_eet_details.element_type_id
9871 ,p_element_entry_id => l_eet_details.element_entry_id
9872 ,p_effective_start_date => p_effective_start_date
9873 ,p_effective_end_date => p_effective_end_date
9874 );
9875 l_total_days := l_total_days + l_days_absent;
9876
9877 end if; -- end if of element id exists check ...
9878
9879 end loop;
9880 close csr_get_eet_info;
9881
9882 debug('l_total_days :'||to_char(l_total_days), 30);
9883 --
9884 -- hr_utility.set_location ('Leaving: '||l_proc_name, 30);
9885 --
9886 debug_exit(l_proc_name);
9887
9888 return l_total_days;
9889
9890 EXCEPTION
9891 WHEN OTHERS THEN
9892 debug_exit(' Others in '||l_proc_name);
9893 RAISE;
9894 end get_eet_info;
9895 --
9896 -- ----------------------------------------------------------------------------
9897 -- |------------------------< get_ft_days_excluded >--------------------------|
9898 -- ----------------------------------------------------------------------------
9899 function get_ft_days_excluded (p_assignment_id in number
9900 ,p_effective_start_date in date
9901 ,p_effective_end_date in date
9902 )
9903 return number is
9904 --
9905 l_proc_name varchar2(60) := g_proc_name || 'get_ft_days_excluded';
9906 l_absence_bal_name pay_balance_types.balance_name%type;
9907 l_days_excluded number;
9908 l_part_time_sal number;
9909 l_eff_start_date date ;
9910 l_eff_end_date date ;
9911
9912 --
9913 begin
9914 --
9915 -- hr_utility.set_location('Entering: '||l_proc_name, 10);
9916 --
9917 debug_enter(l_proc_name);
9918
9919 -- GAP9: Modified function to incorporate changes for supply teachers
9920 -- 1. Check whether the assignment location is a supply teacher establishment
9921 -- 2. If it is get the part time salary paid for the assignment.
9922 -- 3. Return 365 only if the part time salary paid value is zero
9923 -- otherwise use the existing logic to determine days excluded value
9924
9925 l_days_excluded := NULL; -- Initialize first
9926 debug('g_supply_asg_count ' || to_char(g_supply_asg_count),10);
9927 IF g_supply_asg_count > 0 THEN
9928
9929 debug (l_proc_name, 20);
9930 debug ('Establishment Number: '||
9931 pqp_gb_tp_pension_extracts.g_ext_asg_details(p_assignment_id).estb_number,30
9932 );
9933
9934 -- Check whether the establishment number = 0966
9935 IF pqp_gb_tp_pension_extracts.g_ext_asg_details(p_assignment_id).estb_number = '0966'
9936 THEN
9937 debug (l_proc_name, 40);
9938
9939 -- Calculate the part time salary paid in the entire year
9940 -- If the salary paid is Zero, then the days_excluded will be = period length
9941
9942 l_eff_start_date := GREATEST(g_pension_year_start_date,p_effective_start_date
9943 ,g_ext_asg_details(p_assignment_id).teacher_start_date
9944 );
9945
9946 -- MULT-LR --
9947 -- Use the new Function to get the correct end date
9948 -- based on the multiple restarter events
9949 -- It takes care of multiple Leaver-Restarter events
9950 -- where as the old logic used to take into account
9951 -- only the first restarter event.
9952
9953 -- Performance changes
9954 -- no need to call tihs function as we are checking assignment status in chk_effective_asg
9955 /*
9956 l_eff_end_date := get_eff_end_date (
9957 p_assignment_id => p_assignment_id
9958 ,p_effective_start_date => p_effective_start_date
9959 ,p_effective_end_date => p_effective_end_date
9960 ) ;
9961 */
9962
9963 l_eff_end_date := p_effective_end_date;
9964
9965 -- Get part time salary paid value for this assignment
9966 debug ('l_eff_start_date '||fnd_date.date_to_canonical(l_eff_start_date),50);
9967 debug ('l_eff_end_date '||fnd_date.date_to_canonical(l_eff_end_date));
9968
9969 l_part_time_sal := calc_part_time_sal
9970 (p_assignment_id => p_assignment_id
9971 ,p_effective_start_date => l_eff_start_date
9972 ,p_effective_end_date => l_eff_end_date
9973 ,p_business_group_id => g_ext_asg_details(p_assignment_id).business_group_id
9974 );
9975
9976 debug ('Part Time Sal Paid: '||TO_CHAR(l_part_time_sal),60);
9977
9978 IF l_part_time_sal = 0 THEN
9979 debug (l_proc_name, 70);
9980 --l_days_excluded := 365;
9981 l_days_excluded := trunc(p_effective_end_date) - trunc(p_effective_start_date) + 1;
9982 END IF; -- End if of part time salary paid is zero check ...
9983
9984 END IF; -- End if of establishment number is supply teacher one check ...
9985
9986 END IF; -- End if of supply asg count > 0 check ...
9987
9988 debug ('l_days_excluded: '|| to_char(l_days_excluded),80);
9989 -- If days excluded is set above do not process further...
9990
9991 IF l_days_excluded IS NULL THEN
9992
9993 debug (l_proc_name, 90);
9994 debug ('ext_emp_cat_cd '|| g_ext_asg_details(p_assignment_id).ext_emp_cat_cd);
9995 IF (g_ext_asg_details(p_assignment_id).ext_emp_cat_cd ='F' ) THEN
9996
9997 debug (l_proc_name, 110);
9998 -- Modified the function to include any days excluded from OSP / OMP
9999 -- call osp function to derive this information
10000 -- The function should return 0 anyway
10001 l_days_excluded := pqp_gb_osp_functions.get_absence_paid_days_tp
10002 (p_assignment_id => p_assignment_id
10003 ,p_start_date => p_effective_start_date
10004 ,p_end_date => p_effective_end_date
10005 ,p_level_of_pay => 'NOBAND' -- No pay days
10006 );
10007 debug ('Days Excluded from OSP/OMP: ' || l_days_excluded);
10008 -- check whether absence elements exists for this assignment for this period
10009 -- get days excluded if element exists
10010
10011 l_days_excluded := l_days_excluded +
10012 get_eet_info
10013 (p_assignment_id => p_assignment_id
10014 ,p_tab_ele_ids => g_tab_abs_ele_ids
10015 ,p_effective_start_date => p_effective_start_date
10016 ,p_effective_end_date => p_effective_end_date
10017 );
10018 ELSE
10019 debug(l_proc_name,115) ;
10020 l_days_excluded := 0;
10021 END IF ; -- (g_ext_asg_details(p_assignment_id).ext_emp_cat_cd ='F' )
10022 END IF; -- End if of l_days_excluded is null check ...
10023
10024 debug ('l_days_excluded: '|| to_char(l_days_excluded),120);
10025
10026 -- Bug fix 2411951
10027 -- Floor the days excluded value to be in favour of teachers
10028
10029 l_days_excluded := floor(l_days_excluded);
10030
10031 debug ('Total Days Excluded: '|| to_char(l_days_excluded));
10032 --
10033 -- hr_utility.set_location('Leaving: '||l_proc_name, 20);
10034 --
10035 debug_exit(l_proc_name);
10036
10037 return l_days_excluded;
10038
10039 EXCEPTION
10040 WHEN OTHERS THEN
10041 debug_exit(' Others in '||l_proc_name);
10042 RAISE;
10043 end get_ft_days_excluded;
10044
10045 -- ----------------------------------------------------------------------------
10046 -- |------------------------< get_pt_days_excluded >--------------------------|
10047 -- ----------------------------------------------------------------------------
10048 function get_pt_days_excluded (p_assignment_id in number
10049 ,p_effective_start_date in date
10050 ,p_effective_end_date in date
10051 ,p_days out nocopy number
10052 )
10053 return number is
10054 --
10055 l_proc_name varchar2(60) := g_proc_name || 'get_pt_days_excluded';
10056 l_tab_mult_asg t_sec_asgs_type;
10057 l_safeguarded_yn varchar2(1) := 'N';
10058 l_annual_sal_rate number;
10059 l_sec_ann_sal_rate number;
10060 l_sec_eff_start_date date;
10061 l_sec_eff_end_date date;
10062 l_days_worked number := 0;
10063 l_total_days_worked number := 0;
10064 l_days_in_period number := 0;
10065 l_days_excluded number := 0;
10066 l_return number;
10067 i number;
10068 l_primary_esd date;
10069 l_primary_eed date;
10070 l_prev_annual_sal_rate number := NULL; -- bug 6275363
10071 l_equal_sal_rate varchar2(1) := 'Y'; -- bug 6275363
10072 --
10073 begin
10074 --
10075 -- hr_utility.set_location('Entering: '||l_proc_name, 10);
10076 --
10077 debug_enter(l_proc_name);
10078
10079 -- Proceed only if primary assignment qualifies
10080 -- Bug Fix 3073562:GAP6
10081
10082
10083 -- Check if hte primary asg is valid TCHR assignment
10084 -- on the p_effective_start_date
10085
10086 -- MULT-LR --
10087 -- Use the new Function to check the effectivness of an assignment
10088 -- it takes care of multiple Leaver-Restarter events
10089 -- where as the old logic used to take into account
10090 -- only the first restarter event.
10091 IF ( chk_effective_asg (
10092 p_assignment_id => p_assignment_id
10093 ,p_effective_date => p_effective_start_date
10094 ) = 'Y'
10095 )
10096 THEN
10097
10098
10099 -- Bugfix 3641851:CBF1 : We need to calculate the days excluded
10100 -- from start of primary asg as its possible that
10101 -- primary asg bcomes a teacher after secondary
10102 l_primary_esd := GREATEST(p_effective_start_date
10103 ,g_ext_asg_details(p_assignment_id).start_date
10104 );
10105
10106 -- MULT-LR --
10107 -- Use the new Function to get the correct end date
10108 -- based on the multiple restarter events
10109 -- It takes care of multiple Leaver-Restarter events
10110 -- where as the old logic used to take into account
10111 -- only the first restarter event.
10112
10113 -- Performance changes
10114 -- no need to call tihs function as we are checking assignment status in chk_effective_asg
10115 /*
10116 l_primary_eed := get_eff_end_date (
10117 p_assignment_id => p_assignment_id
10118 ,p_effective_start_date => p_effective_start_date
10119 ,p_effective_end_date => p_effective_end_date
10120 ) ;
10121 */
10122
10123 l_primary_eed := p_effective_end_date;
10124
10125 debug('l_primary_eSd :'||to_char(l_primary_esd,'DD/MM/YY'));
10126 debug('l_primary_eEd :'||to_char(l_primary_eed,'DD/MM/YY'));
10127
10128 -- Get safeguarded information
10129
10130 l_safeguarded_yn := get_safeguarded_info
10131 (p_assignment_id => p_assignment_id
10132 -- Bugfix 3641851:CBF1 : Changed to l_primary_esd
10133 ,p_effective_date => l_primary_esd
10134 );
10135
10136 --
10137 debug(l_proc_name, 20);
10138 --
10139 -- Get annual salary rate for primary assignment
10140
10141 l_return := calc_annual_sal_rate
10142 (p_assignment_id => p_assignment_id
10143 -- Bugfix 3641851:CBF1 : Changed to l_primary_esd
10144 ,p_calculation_date => l_primary_esd
10145 ,p_safeguarded_yn => l_safeguarded_yn
10146 ,p_fte => 'N'
10147 ,p_to_time_dim => 'A'
10148 ,p_rate => l_annual_sal_rate
10149 ,p_effective_start_date => p_effective_start_date
10150 ,p_effective_end_date => p_effective_end_date
10151 );
10152
10153 -- Bugfix 3641851:CBF1 : Moved this here frm below as this
10154 -- should only be done if primary asg exists and qualifies
10155 IF l_return <> -1 THEN
10156 debug (l_proc_name, 25);
10157 l_prev_annual_sal_rate :=l_annual_sal_rate; -- bug 6275363
10158 l_total_days_worked := calc_days_worked
10159 (p_assignment_id => p_assignment_id
10160 -- Bugfix 3641851:CBF1 : Using l_primary_esd and l_primary_eed
10161 ,p_effective_start_date => l_primary_esd
10162 ,p_effective_end_date => l_primary_eed
10163 ,p_annual_sal_rate => l_annual_sal_rate
10164 );
10165 END IF;
10166 --
10167 ELSE -- primary assignment does not qualify
10168 l_return := 0;
10169 l_annual_sal_rate := 0;
10170 END IF; -- primary assignment qualifies check ...
10171
10172 if l_return <> -1 then
10173
10174 -- Get days worked for this period
10175 --
10176 debug (l_proc_name, 30);
10177 --
10178
10179 /* Bugfix 3641851:CBF1 : Moved this into IF part above as this
10180 should only be done if primary asg exists and qualifies
10181
10182 l_total_days_worked := calc_days_worked
10183 (p_assignment_id => p_assignment_id
10184 ,p_effective_start_date => p_effective_start_date
10185 ,p_effective_end_date => p_effective_end_date
10186 ,p_annual_sal_rate => l_annual_sal_rate
10187 );
10188 */
10189
10190 -- Check for multiple assignments
10191
10192 --
10193 debug(l_proc_name, 40);
10194 --
10195 -- Bugfix 3803760:FTSUPPLY : Now using g_tab_sec_asgs instead of
10196 -- calling get_eff_secondary_asgs
10197 l_tab_mult_asg := g_tab_sec_asgs;
10198
10199 if l_tab_mult_asg.count > 0 then
10200
10201 -- Change the for loop to while loop as the assignment_id is
10202 -- an index here
10203 -- BUG FIX 3470242:BUG2
10204
10205 -- Get annual salary rate for secondary assignments
10206 -- for i in l_tab_mult_asg.first..l_tab_mult_asg.last loop
10207
10208 i := l_tab_mult_asg.FIRST;
10209 WHILE i IS NOT NULL
10210 LOOP
10211
10212 --
10213 debug (l_proc_name, 50);
10214 --
10215
10216 -- Get safeguarded information
10217
10218 l_safeguarded_yn := get_safeguarded_info
10219 (p_assignment_id => l_tab_mult_asg(i).assignment_id
10220 ,p_effective_date => p_effective_start_date
10221 );
10222
10223 --
10224 debug (l_proc_name||'Asg Id:'||to_char(nvl(l_tab_mult_asg(i).assignment_id,99999)), 60);
10225
10226 l_sec_eff_start_date := greatest
10227 (p_effective_start_date
10228 ,g_ext_asg_details(l_tab_mult_asg(i).assignment_id).start_date
10229 );
10230 -- MULT-LR --
10231 -- Use the new Function to get the correct end date
10232 -- based on the multiple restarter events
10233 -- It takes care of multiple Leaver-Restarter events
10234 -- where as the old logic used to take into account
10235 -- only the first restarter event.
10236
10237 -- Performance changes
10238 -- no need to call tihs function as we are checking assignment status in chk_effective_asg
10239 /*
10240 l_sec_eff_end_date := get_eff_end_date (
10241 p_assignment_id => l_tab_mult_asg(i).assignment_id
10242 ,p_effective_start_date => p_effective_start_date
10243 ,p_effective_end_date => p_effective_end_date
10244 ) ;
10245 */
10246
10247 l_sec_eff_end_date := p_effective_end_date;
10248
10249 debug('l_sec_eff_start_date: '|| to_char(l_sec_eff_start_date,'DD/MM/YYYY'),65) ;
10250 debug('l_sec_eff_end_date: '|| to_char(l_sec_eff_end_date,'DD/MM/YYYY')) ;
10251
10252 l_return := calc_annual_sal_rate
10253 (p_assignment_id => l_tab_mult_asg(i).assignment_id
10254 ,p_calculation_date => l_sec_eff_start_date
10255 ,p_safeguarded_yn => l_safeguarded_yn
10256 ,p_fte => 'N'
10257 ,p_to_time_dim => 'A'
10258 ,p_rate => l_sec_ann_sal_rate
10259 ,p_effective_start_date => p_effective_start_date
10260 ,p_effective_end_date => p_effective_end_date
10261 );
10262
10263 if l_return <> -1 then
10264
10265 --
10266 debug (l_proc_name, 70);
10267 --
10268 -------bug 6275363 ------------------
10269 --compare with the previous salary rate and set the flag to 'N'
10270 -- as soon as a different sal_rate is found.
10271
10272 IF l_prev_annual_sal_rate is not NULL THEN
10273 IF l_sec_ann_sal_rate <> l_prev_annual_sal_rate AND l_sec_ann_sal_rate <> 0 THEN
10274 l_equal_sal_rate := 'N' ;
10275 ELSE
10276 debug('sal_rate are equal for this iteration',71);
10277 END IF;
10278 ELSE -- l_prev_annual_sal_rate is Null
10279 --The first valid assignment
10280 debug(l_proc_name, 72);
10281 l_prev_annual_sal_rate := l_sec_ann_sal_rate ;
10282 END IF ;
10283 ----------------------------------
10284 -- Calculate days worked
10285 l_days_worked := calc_days_worked
10286 (p_assignment_id => l_tab_mult_asg(i).assignment_id
10287 ,p_effective_start_date => l_sec_eff_start_date
10288 ,p_effective_end_date => l_sec_eff_end_date
10289 ,p_annual_sal_rate => l_sec_ann_sal_rate
10290 );
10291
10292 l_total_days_worked := l_total_days_worked + l_days_worked;
10293
10294 else -- secondary asg annual sal rate is in error
10295
10296 p_days := 0;
10297 --
10298 -- hr_utility.set_location ('Leaving: '||l_proc_name, 80);
10299 --
10300 debug (l_proc_name, 80);
10301
10302 debug_exit(l_proc_name);
10303
10304 return -1;
10305
10306 end if; -- end if of sec asg annual return check ...
10307 i := l_tab_mult_asg.NEXT(i);
10308
10309 end loop;
10310 debug (l_proc_name ||'Total Secondary Asgs: '||to_char(l_tab_mult_asg.COUNT), 85);
10311 debug ('l_equal_sal_rate : '|| l_equal_sal_rate, 85);
10312 end if ; -- end if of multiple asg check ...
10313
10314 --
10315 l_days_in_period := (trunc(p_effective_end_date) - trunc(p_effective_start_date)) + 1;
10316
10317 -- Bug Fix 2411951
10318 -- Ceil the days worked figure...
10319
10320 l_total_days_worked := ceil(l_total_days_worked);
10321
10322 -- DE_CALC
10323 -- Days excluded should not be more than the period length
10324 -- due to the cieling on salary values, it may be more than the period
10325 -- hence LEAST
10326 -- l_days_excluded := LEAST (l_days_in_period,ABS(l_days_in_period - l_total_days_worked));
10327 -- the logic above is incorrect.
10328
10329 -- bugfix : 4926143
10330 -- new logic
10331 -- if total days worked for all assignments taken together is > days_in_period,
10332 -- then days_excluded is 0
10333 -- else days_excluded = days_in_period - total_days_worked
10334
10335 IF l_days_in_period < l_total_days_worked
10336 THEN
10337 l_days_excluded := 0;
10338 ELSE
10339 l_days_excluded := l_days_in_period - l_total_days_worked;
10340 END IF;
10341
10342 --
10343 --
10344 -- hr_utility.set_location ('Leaving: '||l_proc_name, 80);
10345 --
10346 debug_exit(l_proc_name);
10347
10348 p_days := l_days_excluded;
10349
10350 -- bug 6275363 --------------
10351 IF p_days =0 AND l_equal_sal_rate = 'N' and
10352 g_override_ft_asg_id IS NULL and g_part_time_asg_count > 1 then
10353 return -2;
10354 ELSE
10355 RETURN 0;
10356 END IF;
10357 -------------------------------
10358 else -- primary asg annual sal is in error
10359
10360 --
10361 -- hr_utility.set_location ('Leaving: '||l_proc_name, 80);
10362 --
10363 debug_exit(l_proc_name);
10364
10365 p_days := 0;
10366 return -1;
10367
10368 end if; -- end if of prim asg annual return check ...
10369
10370 --
10371
10372 -- Added by tmehra for nocopy changes Feb'03
10373
10374 EXCEPTION
10375 WHEN OTHERS THEN
10376 debug_exit(' Others in '||l_proc_name);
10377 p_days := NULL;
10378 raise;
10379
10380 end get_pt_days_excluded;
10381
10382 --
10383 -- ----------------------------------------------------------------------------
10384 -- |------------------------< get_days_excluded_date >------------------------|
10385 -- ----------------------------------------------------------------------------
10386 function get_days_excluded_date (p_assignment_id in number
10387 ,p_effective_start_date in date
10388 ,p_effective_end_date in date
10389 ,p_emp_cat_cd in varchar2
10390 ,p_days out nocopy number
10391 )
10392 return number is
10393 --
10394 l_proc_name varchar2(60) := g_proc_name || 'get_days_excluded_date';
10395 l_return number := 0;
10396 l_days_excluded number;
10397 l_tab_mult_asg t_sec_asgs_type;
10398 l_error_msg varchar2(2000);
10399 i number;
10400 l_primary_esd date;
10401 l_primary_eed date;
10402 l_sec_eff_start_date date;
10403 l_sec_eff_end_date date;
10404 l_error NUMBER;
10405 --
10406 begin
10407 --
10408 -- hr_utility.set_location('Entering: '||l_proc_name, 10);
10409 --
10410 debug_enter(l_proc_name);
10411
10412 -- Check whether employment category is part time or full time
10413 -- As full time employment category may have multiple assignments
10414 -- so remove the check that checks for employment category
10415 -- rather go by multiple assignment check
10416
10417 -- if nvl(p_emp_cat_cd,g_ext_asg_details(p_assignment_id).ext_emp_cat_cd) = 'F' then
10418
10419 --
10420 debug(l_proc_name, 20);
10421 --
10422 -- l_days_excluded := get_ft_days_excluded
10423 -- (p_assignment_id => p_assignment_id
10424 -- ,p_effective_start_date => p_effective_start_date
10425 -- ,p_effective_end_date => p_effective_end_date
10426 -- );
10427
10428 -- elsif nvl(p_emp_cat_cd,g_ext_asg_details(p_assignment_id).ext_emp_cat_cd) = 'P' then
10429
10430 --
10431 debug(l_proc_name, 30);
10432 --
10433
10434 -- Bugfix 3803760:FTSUPPLY : Now using g_tab_sec_asgs instead of
10435 -- calling get_eff_secondary_asgs
10436 l_tab_mult_asg := g_tab_sec_asgs;
10437
10438 if (
10439 l_tab_mult_asg.count > 1
10440 )
10441 OR
10442 ( l_tab_mult_asg.count = 1
10443 AND
10444 -- Check if hte primary asg is valid TCHR assignment
10445 -- on the p_effective_start_date
10446 -- MULT-LR --
10447 -- Use the new Function to check the effectivness of an assignment
10448 -- it takes care of multiple Leaver-Restarter events
10449 -- where as the old logic used to take into account
10450 -- only the first restarter event.
10451 ( chk_effective_asg (
10452 p_assignment_id => p_assignment_id
10453 ,p_effective_date => p_effective_start_date
10454 ) = 'Y'
10455 )
10456 )
10457 then
10458 debug(l_proc_name, 40);
10459
10460 l_return := get_pt_days_excluded
10461 (p_assignment_id => p_assignment_id
10462 ,p_effective_start_date => p_effective_start_date
10463 ,p_effective_end_date => p_effective_end_date
10464 ,p_days => l_days_excluded
10465 );
10466
10467 else
10468
10469 -- check whether primary assignment qualifies for report
10470 -- Bug Fix 3073562:GAP6
10471
10472
10473 -- Check if hte primary asg is valid TCHR assignment
10474 -- on the p_effective_start_date
10475 -- MULT-LR --
10476 -- Use the new Function to check the effectivness of an assignment
10477 -- it takes care of multiple Leaver-Restarter events
10478 -- where as the old logic used to take into account
10479 -- only the first restarter event.
10480 IF ( chk_effective_asg (
10481 p_assignment_id => p_assignment_id
10482 ,p_effective_date => p_effective_start_date
10483 ) = 'Y'
10484 )
10485 THEN
10486 debug(l_proc_name, 50);
10487
10488 -- Bugfix 3641851:CBF1 : We need to calculate the days excluded
10489 -- from start of primary asg as its possible that
10490 -- primary asg bcomes a teacher after secondary
10491 l_primary_esd := GREATEST(p_effective_start_date
10492 ,g_ext_asg_details(p_assignment_id).start_date
10493 );
10494 -- MULT-LR --
10495 -- Use the new Function to get the correct end date
10496 -- based on the multiple restarter events
10497 -- It takes care of multiple Leaver-Restarter events
10498 -- where as the old logic used to take into account
10499 -- only the first restarter event.
10500
10501 -- Performance changes
10502 -- no need to call tihs function as we are checking assignment status in chk_effective_asg
10503 /*
10504 l_primary_eed := get_eff_end_date (
10505 p_assignment_id => p_assignment_id
10506 ,p_effective_start_date => p_effective_start_date
10507 ,p_effective_end_date => p_effective_end_date
10508 ) ;
10509 */
10510
10511 l_primary_eed := p_effective_end_date;
10512
10513 debug('l_primary_eSd :'||to_char(l_primary_esd,'DD/MM/YY'));
10514 debug('l_primary_eEd :'||to_char(l_primary_eed,'DD/MM/YY'));
10515
10516 l_days_excluded := get_ft_days_excluded
10517 (p_assignment_id => p_assignment_id
10518 -- Bugfix 3641851:CBF1 : Using l_primary_esd and l_primary_eed
10519 ,p_effective_start_date => l_primary_esd
10520 ,p_effective_end_date => l_primary_eed
10521 );
10522 ELSE -- primary assignment does not qualify for report
10523
10524 -- Check whether secondary assignment count is one
10525 IF l_tab_mult_asg.COUNT = 1 THEN
10526
10527 debug(l_proc_name, 60);
10528 i := l_tab_mult_asg.FIRST;
10529 l_sec_eff_start_date := greatest
10530 (p_effective_start_date
10531 ,g_ext_asg_details(l_tab_mult_asg(i).assignment_id).start_date
10532 );
10533
10534 -- MULT-LR --
10535 -- Use the new Function to get the correct end date
10536 -- based on the multiple restarter events
10537 -- It takes care of multiple Leaver-Restarter events
10538 -- where as the old logic used to take into account
10539 -- only the first restarter event.
10540
10541 -- Performance changes
10542 -- no need to call tihs function as we are checking assignment status in chk_effective_asg
10543 /*
10544 l_sec_eff_end_date := get_eff_end_date (
10545 p_assignment_id => l_tab_mult_asg(i).assignment_id
10546 ,p_effective_start_date => p_effective_start_date
10547 ,p_effective_end_date => p_effective_end_date
10548 ) ;
10549 */
10550 l_sec_eff_end_date := p_effective_end_date;
10551
10552 debug('l_sec_eff_start_date: '|| to_char(l_sec_eff_start_date,'DD/MM/YYYY'),65) ;
10553 debug('l_sec_eff_end_date: '|| to_char(l_sec_eff_end_date,'DD/MM/YYYY')) ;
10554
10555
10556 l_days_excluded := get_ft_days_excluded
10557 (p_assignment_id => l_tab_mult_asg(i).assignment_id
10558 ,p_effective_start_date => l_sec_eff_start_date
10559 ,p_effective_end_date => l_sec_eff_end_date
10560 );
10561 ELSE
10562
10563 debug(l_proc_name, 70);
10564 l_days_excluded := 0;
10565 END IF; -- End if of mult assignment count = 1 check ...
10566
10567 END IF; -- End if of primary assignment qualifies check ...
10568
10569 end if; -- end if of multiple assignment check ...
10570
10571 -- end if; -- end if of employment category check ...
10572
10573 --
10574 -- hr_utility.set_location ('Leaving: '||l_proc_name, 40);
10575 --
10576 -- bug 6275363------
10577 IF l_return = -2 THEN
10578 debug(l_proc_name, 71);
10579 debug_exit(l_proc_name);
10580 RETURN -2;
10581 END if;
10582 ----------------------
10583 if l_return <> -1 then
10584
10585 -- Check whether the days excluded has exceeded the allowed 3 digit limit
10586 debug('Days Excluded = ' ||l_days_excluded, 80);
10587 if l_days_excluded > 999 then
10588 debug(l_proc_name, 85);
10589 l_days_excluded := 999;
10590
10591 end if; -- End if of days excluded greater than the limit check ...
10592
10593 -- Cap Number of excluded days to 365, in case
10594 -- it is 366.
10595 -- Leave the value as it is if it is > 366 and
10596 -- Raise a warning cause it is a data issue
10597 -- (Warning is being raised by the FF)
10598
10599 IF l_days_excluded = 366 THEN
10600 debug(l_proc_name, 90);
10601 l_days_excluded := 365 ;
10602 END IF ;
10603
10604 p_days := l_days_excluded;
10605 debug_exit(l_proc_name);
10606 return 0;
10607
10608 else
10609 debug(l_proc_name, 110);
10610 p_days := 0;
10611 debug_exit(l_proc_name);
10612 return -1;
10613
10614 end if; -- end if of l_return check ...
10615
10616 -- Added by tmehra for nocopy changes Feb'03
10617
10618 EXCEPTION
10619 WHEN OTHERS THEN
10620 debug_exit(' Others in '||l_proc_name);
10621 p_days := NULL;
10622 raise;
10623
10624 end get_days_excluded_date;
10625
10626 --
10627 -- Check if person has multiple person records
10628 --
10629 FUNCTION chk_does_person_hv_multi_recs
10630 (p_assignment_id IN NUMBER
10631 ,p_business_group_id IN NUMBER
10632 ,p_effective_date IN DATE
10633 ,p_present_in_masterbg OUT NOCOPY BOOLEAN
10634 ,p_person_count OUT NOCOPY NUMBER
10635 ) RETURN BOOLEAN
10636 IS
10637
10638
10639 l_multiper_found BOOLEAN := FALSE;
10640 l_present_in_masterbg BOOLEAN := FALSE;
10641 l_ext_emp_cat_cd VARCHAR2(1);
10642 l_person_id per_all_people_f.person_id%TYPE;
10643
10644 l_per_details csr_asg_details_up%ROWTYPE;
10645 l_multiper c_multiper%ROWTYPE;
10646 l_person_count NUMBER :=0 ;
10647
10648 l_proc_name VARCHAR2(61):=
10649 g_proc_name||'chk_does_person_hv_multi_recs';
10650
10651 -- CROSSPER:
10652 -- new varaibles introduced to
10653 -- check for crossperson records
10654 -- Will set these variables accordng to the
10655 -- global dates set in TP1/TP2/TP4
10656 -- depending on the extract type
10657 -- and pass to c_multiper
10658 l_eff_start_date DATE;
10659 l_eff_end_date DATE;
10660
10661 BEGIN -- chk_does_person_hv_multi_recs
10662
10663 debug_enter(l_proc_name);
10664 debug('g_master_bg_id :'||to_char(nvl(g_master_bg_id,-1)), 05);
10665
10666 OPEN csr_asg_details_up(p_assignment_id => p_assignment_id
10667 ,p_effective_date => p_effective_date
10668 );
10669 FETCH csr_asg_details_up INTO l_per_details;
10670 l_person_id := l_per_details.person_id;
10671
10672 CLOSE csr_asg_details_up;
10673
10674 -- Bugfix 3073562:GAP8
10675 -- If we find a full-time assignment for this person
10676 -- then we must treat each person record seperately
10677
10678 -- Bugfix 3671727:ENH2
10679 -- This only needs to be done for the Type 1 report
10680 -- For the Type 2 and 4 we still amalgamate data
10681 IF g_extract_type IN ('TP1P', 'TP1') THEN
10682
10683
10684 debug(l_proc_name, 10);
10685
10686 -- CROSSPER: set the dates
10687 l_eff_start_date := p_effective_date;
10688 l_eff_end_date := g_pension_year_end_date ;
10689
10690 debug(' l_per_details.asg_emp_cat_cd :'|| l_per_details.asg_emp_cat_cd,11);
10691 debug(' p_effective_date :'|| to_char(p_effective_date),12);
10692 -- First chk the assignment id passed
10693 l_ext_emp_cat_cd := get_translate_asg_emp_cat_code
10694 (l_per_details.asg_emp_cat_cd
10695 ,p_effective_date
10696 ,'Pension Extracts Employment Category Code'
10697 ,p_business_group_id
10698 );
10699
10700 debug('l_ext_emp_cat_cd :'|| l_ext_emp_cat_cd,13);
10701 IF l_ext_emp_cat_cd = 'F' THEN
10702 debug(l_proc_name, 20);
10703 l_multiper_found := FALSE;
10704 l_present_in_masterbg := FALSE;
10705
10706 --Check if other asgs exists for the same person.
10707 OPEN c_multiper
10708 (p_person_id => l_person_id
10709 ,p_effective_start_date => l_eff_start_date
10710 ,p_effective_end_date => l_eff_end_date
10711 ,p_assignment_id => p_assignment_id
10712 ) ;
10713 FETCH c_multiper INTO l_multiper ;
10714 IF c_multiper%FOUND THEN
10715 l_person_count := 1 ;
10716 END IF;
10717 CLOSE c_multiper ;
10718
10719 ELSE
10720
10721 l_ext_emp_cat_cd := NULL;
10722
10723 FOR l_multiper IN c_multiper
10724 (p_person_id => l_person_id
10725 ,p_effective_start_date => l_eff_start_date
10726 ,p_effective_end_date => l_eff_end_date
10727 ,p_assignment_id => p_assignment_id
10728 )
10729 LOOP
10730
10731 debug(l_proc_name, 30);
10732 l_multiper_found := TRUE;
10733 l_person_count := l_person_count + 1;
10734
10735 IF l_multiper.business_group_id = g_master_bg_id THEN
10736 debug(l_proc_name, 40);
10737 l_present_in_masterbg := TRUE;
10738 END IF;
10739
10740 l_ext_emp_cat_cd := get_translate_asg_emp_cat_code
10741 (l_multiper.asg_emp_cat_cd
10742 ,p_effective_date
10743 ,'Pension Extracts Employment Category Code'
10744 ,p_business_group_id
10745 );
10746
10747 -- Bugfix 3073562:GAP8
10748 -- If we find a full-time assignment for this person
10749 -- then we must treat each person record seperately
10750 IF l_ext_emp_cat_cd = 'F' THEN
10751 debug( 'setting l_multiplier_found =false');
10752 l_multiper_found := FALSE;
10753 l_present_in_masterbg := FALSE;
10754 debug(l_proc_name, 50);
10755 EXIT;
10756 END IF;
10757
10758 END LOOP;
10759
10760 END IF; -- l_ext_emp_cat_cd = 'F' THEN
10761
10762 ELSE -- g_extract_type is TP4 or TP2
10763
10764 -- CROSSPER:check the extract type and set the dates
10765 IF (g_extract_type = 'TP2' ) THEN
10766 l_eff_start_date := pqp_gb_tp_type2_functions.g_effective_start_date;
10767 l_eff_end_date := pqp_gb_tp_type2_functions.g_effective_end_date;
10768 ELSIF (g_extract_type = 'TP4' ) THEN
10769 l_eff_start_date := pqp_gb_tp_pension_extracts.g_last_effective_date ;
10770 l_eff_end_date := pqp_gb_tp_pension_extracts.g_effective_run_date ;
10771 END IF;
10772
10773 FOR l_multiper IN c_multiper
10774 (p_person_id => l_person_id
10775 ,p_effective_start_date => l_eff_start_date
10776 ,p_effective_end_date => l_eff_end_date
10777 ,p_assignment_id => p_assignment_id
10778 )
10779 LOOP
10780
10781 debug(l_proc_name, 60);
10782 l_multiper_found := TRUE;
10783
10784 IF l_multiper.business_group_id = g_master_bg_id THEN
10785 debug(l_proc_name, 70);
10786 l_present_in_masterbg := TRUE;
10787 END IF;
10788
10789 -- If both the flags are set to TRUE, no need to check further
10790 IF l_present_in_masterbg
10791 AND
10792 l_multiper_found THEN
10793
10794 debug(l_proc_name, 80);
10795 EXIT;
10796
10797 END IF;
10798
10799 END LOOP;
10800
10801 END IF; -- g_extract_type check
10802
10803 debug_exit(l_proc_name);
10804
10805 -- Assign value to the OUT param value
10806 p_present_in_masterbg := l_present_in_masterbg;
10807 p_person_count := l_person_count ;
10808
10809 RETURN l_multiper_found;
10810 EXCEPTION
10811 WHEN OTHERS THEN
10812 p_present_in_masterbg := NULL;
10813 p_person_count := NULL;
10814 debug_exit('Others in '||l_proc_name);
10815 RAISE;
10816 END; -- chk_does_person_hv_multi_recs
10817
10818 --
10819 -- set_multirec_person
10820 --
10821 FUNCTION set_multirec_person(p_business_group_id IN NUMBER
10822 ,p_person_id IN NUMBER
10823 ,p_assignment_id IN NUMBER
10824 ,p_national_identifier IN VARCHAR2
10825 ,p_effective_start_date IN DATE
10826 ,p_effective_end_date IN DATE
10827 ,p_processing_status IN VARCHAR2
10828 ,p_request_id IN NUMBER
10829 ) RETURN BOOLEAN IS
10830
10831 PRAGMA AUTONOMOUS_TRANSACTION;
10832
10833 CURSOR csr_multirec_person IS
10834 SELECT *
10835 FROM pqp_ext_cross_person_records emd
10836 WHERE emd.record_type = 'X'
10837 AND emd.national_identifier = p_national_identifier
10838 AND emd.ext_dfn_id = ben_ext_thread.g_ext_dfn_id --ENH3
10839 AND emd.lea_number = g_lea_number --ENH3
10840 FOR UPDATE OF processing_status NOWAIT;
10841
10842
10843 l_report_person BOOLEAN := FALSE;
10844 l_multirec_per csr_multirec_person%ROWTYPE;
10845
10846 l_proc_name VARCHAR2(61):=
10847 g_proc_name||'set_multirec_person';
10848
10849 BEGIN
10850
10851 debug_enter(l_proc_name);
10852
10853 OPEN csr_multirec_person;
10854 FETCH csr_multirec_person INTO l_multirec_per;
10855
10856 IF csr_multirec_person%FOUND THEN
10857
10858 debug(l_proc_name, 10);
10859
10860 IF nvl(l_multirec_per.processing_status,'U') = 'U' THEN
10861 BEGIN -- Attempt an update
10862
10863 debug(l_proc_name, 20);
10864 UPDATE pqp_ext_cross_person_records
10865 SET business_group_id = p_business_group_id
10866 ,person_id = p_person_id
10867 ,national_identifier = p_national_identifier
10868 ,assignment_id = p_assignment_id
10869 ,effective_start_date = p_effective_start_date
10870 ,effective_end_date = p_effective_end_date
10871 ,processing_status = p_processing_status
10872 ,request_id = p_request_id
10873 ,last_updated_by = fnd_global.user_id
10874 ,last_update_date = SYSDATE
10875 ,last_update_login = fnd_global.login_id
10876 ,object_version_number = (l_multirec_per.object_version_number + 1)
10877 WHERE CURRENT OF csr_multirec_person;
10878
10879 l_report_person := TRUE;
10880
10881 debug(l_proc_name, 30);
10882
10883 EXCEPTION
10884 WHEN OTHERS THEN
10885
10886 debug(l_proc_name, 40);
10887 l_report_person := FALSE;
10888 -- IF the code is -54 then the row is locked and
10889 -- is being updated by another extract, we will not
10890 -- report this person in the current extract.
10891 -- If its anything other than 54, its a problem
10892 -- raise it.
10893 IF SQLCODE <> -54 THEN
10894 CLOSE csr_multirec_person;
10895 debug_exit(l_proc_name);
10896 RAISE;
10897 END IF;
10898 END; -- Attempt an update
10899
10900 debug(l_proc_name, 50);
10901 ELSE
10902 debug(l_proc_name, 60);
10903 l_report_person := FALSE;
10904 END IF;
10905
10906 ELSE -- Notfound, Need to insert
10907 debug(l_proc_name, 70);
10908 INSERT INTO pqp_ext_cross_person_records
10909 (record_type
10910 ,ext_dfn_id --ENH3
10911 ,lea_number --ENH3
10912 ,business_group_id
10913 ,person_id
10914 ,national_identifier
10915 ,assignment_id
10916 ,effective_start_date
10917 ,effective_end_date
10918 ,processing_status
10919 ,request_id
10920 ,created_by
10921 ,creation_date
10922 ,object_version_number
10923 )
10924 VALUES
10925 ('X'
10926 ,ben_ext_thread.g_ext_dfn_id --ENH3
10927 ,pqp_gb_tp_pension_extracts.g_lea_number --ENH3
10928 ,p_business_group_id
10929 ,p_person_id
10930 ,p_national_identifier
10931 ,p_assignment_id
10932 ,p_effective_start_date
10933 ,p_effective_end_date
10934 ,p_processing_status
10935 ,p_request_id
10936 ,fnd_global.user_id
10937 ,SYSDATE
10938 ,1
10939 );
10940
10941 l_report_person := TRUE;
10942
10943 END IF; -- csr_multirec_person%FOUND THEN
10944
10945 debug(l_proc_name, 80);
10946
10947 CLOSE csr_multirec_person;
10948
10949 COMMIT;
10950
10951 debug_exit(l_proc_name);
10952
10953 RETURN l_report_person;
10954
10955 EXCEPTION
10956 WHEN OTHERS THEN
10957 debug_exit(' Others in '||l_proc_name);
10958 RAISE;
10959 END; -- set_multirec_person
10960
10961 --
10962 -- chk_report_person
10963 --
10964 FUNCTION chk_report_person
10965 (p_business_group_id IN NUMBER -- context
10966 ,p_effective_date IN DATE -- context
10967 ,p_assignment_id IN NUMBER -- context
10968 ) RETURN BOOLEAN
10969 IS
10970
10971 CURSOR csr_per_details IS
10972 SELECT per.person_id person_id
10973 ,per.national_identifier national_identifier
10974 FROM per_all_assignments_f asg
10975 ,per_all_people_f per
10976 WHERE asg.assignment_id = p_assignment_id
10977 AND per.person_id = asg.person_id;
10978
10979
10980 l_person_has_multiple_recs BOOLEAN := FALSE;
10981 l_present_in_masterbg BOOLEAN := FALSE;
10982 l_report_person BOOLEAN := FALSE;
10983 l_error NUMBER ;
10984 l_multiper_dets csr_multiproc_data%ROWTYPE;
10985 l_per_details csr_per_details%ROWTYPE;
10986
10987
10988 l_proc_name VARCHAR2(61):=
10989 g_proc_name||'chk_report_person';
10990
10991 BEGIN -- chk_report_person
10992
10993 debug_enter(l_proc_name);
10994
10995 -- This function does the following checks and processing
10996 -- 1) If the current bg is cross bg reporting enabled
10997 -- then we need to chk if the current BG is the Master BG
10998 -- a) If it is, then we report this person in this, Master, BG
10999 -- But before that we need to chk if this person is
11000 -- already being reported in the current (master) BG
11001 -- as it could be a cross person in same Bg scenario.
11002 -- b) If this is not the master bg, then we check if the
11003 -- person has a record in master bg
11004 -- b.1) If yes, then v leave the person alone as he will
11005 -- get processed in the extract for master bg anyway
11006 -- b.2) If not, then we chk if this person is being
11007 -- already processed in another/same extract for cross BG
11008 -- scenario. For this we look for a row in
11009 -- pqp_ext_cross_person_records for this persons NI number
11010 -- i) If row found with 'P', then leave this person
11011 -- ii) If not found or found with NULL or 'U', then we
11012 -- insert/update the row to tell other extracts that
11013 -- mite be running parallely that this person is already
11014 -- being processed
11015
11016
11017 debug(l_proc_name, 10);
11018 OPEN csr_per_details;
11019 FETCH csr_per_details INTO l_per_details;
11020 CLOSE csr_per_details;
11021
11022 -- Now chk if this person has multi person recs
11023 g_person_count := 0;
11024 debug('p_assignment_id :'||to_char(p_assignment_id));
11025 debug('p_effective_date :'||to_char(p_effective_date));
11026
11027 l_person_has_multiple_recs :=
11028 chk_does_person_hv_multi_recs
11029 (p_assignment_id => p_assignment_id
11030 ,p_business_group_id => p_business_group_id
11031 ,p_effective_date => p_effective_date
11032 ,p_present_in_masterbg => l_present_in_masterbg -- OUT
11033 ,p_person_count => g_person_count --OUT
11034 );
11035
11036 debug('g_person_count :'||to_char(g_person_count));
11037
11038 -- Bugfix 3073562:GAP8
11039 -- We must not amalgamate person data from other person
11040 -- records within or across BGs if the person
11041 -- has a full-time assignment in any of the person recs
11042 IF l_person_has_multiple_recs THEN
11043 debug(l_proc_name,15);
11044 debug('l_person_has_multiple_recs has multiple recs ');
11045 g_cross_per_enabled := 'Y';
11046 ELSE
11047 debug('l_person_has_multiple_recs doesnt have multiple recs ');
11048 g_cross_per_enabled := 'N';
11049 END IF;
11050
11051 -- Step 1) Is cross Bg reporting enabled
11052 IF g_crossbg_enabled = 'Y' THEN
11053
11054 -- Step 2) Is this the master BG.
11055 IF g_business_group_id = g_master_bg_id THEN
11056
11057 debug(l_proc_name, 20);
11058
11059 -- Always report a person from master BG if
11060 -- there is a person record in the master BG
11061 l_report_person := TRUE;
11062
11063 -- If person has multiple records, mark the
11064 -- row in multiproc_data
11065 IF l_person_has_multiple_recs THEN
11066
11067 debug(l_proc_name, 30);
11068
11069 -- Returns true on successful update or insert
11070 l_report_person := set_multirec_person
11071 (p_business_group_id => p_business_group_id
11072 ,p_person_id => l_per_details.person_id
11073 ,p_assignment_id => p_assignment_id
11074 ,p_national_identifier => l_per_details.national_identifier
11075 ,p_effective_start_date => p_effective_date
11076 ,p_effective_end_date => NULL
11077 ,p_processing_status => 'P'
11078 ,p_request_id => fnd_global.conc_request_id
11079 );
11080
11081 END IF; -- l_person_has_multiple_recs THEN
11082
11083 ELSE -- the report is not running in the master BG
11084
11085 debug(l_proc_name, 40);
11086
11087 -- Chk if this person has a rec in master BG.
11088 IF l_present_in_masterbg THEN
11089 -- IF Yes then do not report person in current BG
11090 l_report_person := FALSE;
11091 debug(l_proc_name, 50);
11092 ELSE
11093
11094 -- If person has multiple records, try to mark the
11095 -- row in multiproc_data
11096 IF l_person_has_multiple_recs THEN
11097
11098 -- debug('National Identifier :'||l_per_details.national_identifier, 59);
11099 debug(l_proc_name, 60);
11100 IF csr_multiproc_data%ISOPEN THEN
11101 CLOSE csr_multiproc_data;
11102 END IF;
11103
11104 -- Check if the person is already being processed
11105 OPEN csr_multiproc_data(p_record_type => 'X'
11106 ,p_national_identifier => l_per_details.national_identifier
11107 );
11108 FETCH csr_multiproc_data INTO l_multiper_dets;
11109
11110 debug('Processing Status :'||l_multiper_dets.processing_status, 70);
11111
11112 IF (csr_multiproc_data%NOTFOUND -- No row for this NI
11113 OR
11114 (csr_multiproc_data%FOUND -- Row found for this NI
11115 AND
11116 nvl(l_multiper_dets.processing_status,'U') = 'U' -- Unprocessed
11117 )
11118 ) THEN
11119
11120 debug(l_proc_name, 80);
11121
11122 -- Returns true on successful update or insert
11123 l_report_person:= set_multirec_person
11124 (p_business_group_id => p_business_group_id
11125 ,p_person_id => l_per_details.person_id
11126 ,p_assignment_id => p_assignment_id
11127 ,p_national_identifier => l_per_details.national_identifier
11128 ,p_effective_start_date => p_effective_date
11129 ,p_effective_end_date => NULL
11130 ,p_processing_status => 'P'
11131 ,p_request_id => fnd_global.conc_request_id
11132 );
11133
11134 ELSE
11135 -- Person is already being processed by another BG that
11136 -- mite be running parallely. So do not process in this report
11137 debug(l_proc_name, 90);
11138 l_report_person := FALSE;
11139 END IF; -- (csr_multiproc_data%NOTFOUND -- No row for this NI
11140 CLOSE csr_multiproc_data;
11141
11142 ELSE
11143 debug(l_proc_name, 95);
11144 l_report_person := TRUE;
11145 END IF; -- l_person_has_multiple_recs THEN
11146
11147 END IF; -- l_present_in_masterbg THEN
11148
11149 END IF; -- g_business_group_id = g_master_bg_id THEN
11150
11151 ELSE -- g_crossbg_enabled = 'N'
11152
11153 -- If person has multiple records, mark the
11154 -- row in multiproc_data
11155 IF l_person_has_multiple_recs THEN
11156
11157 debug(l_proc_name, 100);
11158
11159 -- Returns true on successful update or insert
11160 l_report_person := set_multirec_person
11161 (p_business_group_id => p_business_group_id
11162 ,p_person_id => l_per_details.person_id
11163 ,p_assignment_id => p_assignment_id
11164 ,p_national_identifier => l_per_details.national_identifier
11165 ,p_effective_start_date => p_effective_date
11166 ,p_effective_end_date => NULL
11167 ,p_processing_status => 'P'
11168 ,p_request_id => fnd_global.conc_request_id
11169 );
11170
11171 ELSE
11172 debug(l_proc_name, 105);
11173 l_report_person := TRUE;
11174 END IF; -- l_person_has_multiple_recs THEN
11175
11176 debug(l_proc_name, 110);
11177 END IF; -- g_crossbg_enabled = 'Y' THEN
11178
11179 debug_exit(l_proc_name);
11180
11181 RETURN l_report_person;
11182 EXCEPTION
11183 WHEN OTHERS THEN
11184 debug('SQLCODE :'||to_char(SQLCODE), 120);
11185 debug('SQLERRM :'||SQLERRM, 130);
11186 debug_exit(' Others in '||l_proc_name);
11187 RAISE;
11188
11189 END; -- chk_report_person
11190
11191 -- Criteria for Type 1 Periodic Leavers
11192 --
11193 FUNCTION chk_tp1_criteria_periodic
11194 (p_business_group_id IN NUMBER -- context
11195 ,p_effective_date IN DATE -- context
11196 ,p_assignment_id IN NUMBER -- context
11197 ) RETURN VARCHAR2 -- Y or N
11198 IS
11199
11200 -- Variable Declaration
11201 l_inclusion_flag VARCHAR2(1) := 'Y';
11202 l_leaver VARCHAR2(1) := 'N';
11203 l_leaver_date DATE;
11204 l_already_reported VARCHAR2(1) := 'N';
11205 l_restarter VARCHAR2(1) := 'N';
11206 l_restarter_date DATE := NULL;
11207 l_look_for_sec_asgs BOOLEAN := FALSE;
11208 l_asg_count NUMBER;
11209 l_error NUMBER;
11210 -- FOR PROFILING
11211 l_start_time NUMBER;
11212 l_end_time NUMBER;
11213
11214 -- Rowtype Variable Declaration
11215 l_asg_details csr_asg_details_up%ROWTYPE;
11216 l_pqp_asg_attributes csr_pqp_asg_attributes_up%ROWTYPE;
11217 l_temp_asg_details csr_asg_details_up%ROWTYPE;
11218
11219 l_proc_name VARCHAR2(61):=
11220 g_proc_name||'chk_tp1_criteria_periodic';
11221
11222 BEGIN -- chk_tp1_criteria_periodic
11223
11224 debug_enter(l_proc_name);
11225
11226 debug('Assignment Id :'||to_char(p_assignment_id),10);
11227
11228 IF g_business_group_id IS NULL THEN
11229
11230 -- Bugifx 2848696 : Now using ben_ext_person.g_effective_date
11231 -- instead of p_effective_date
11232 set_t1_extract_globals
11233 (p_business_group_id
11234 ,ben_ext_person.g_effective_date -- p_effective_date
11235 ,p_assignment_id
11236 );
11237
11238 set_periodic_run_dates;
11239
11240 -- Fetch element ids from balance's
11241 fetch_eles_for_t1_bals (p_assignment_id => p_assignment_id
11242 ,p_effective_date => g_pension_year_start_date
11243 );
11244
11245 END IF;
11246
11247 -- Bugfix -- Bugfix 3671727: Performance enhancement
11248 -- If no location exists in the list of valid criteria
11249 -- establishments, then no point doing all checks
11250 -- Just warn once and skip every assignment
11251 IF pqp_gb_tp_pension_extracts.g_criteria_estbs.COUNT = 0 THEN
11252
11253 debug('Setting inclusion flag to N as no locations EXIST.', 15);
11254 l_inclusion_flag := 'N';
11255
11256 pqp_gb_tp_pension_extracts.g_nested_level := g_nested_level;
11257 -- Call TP4 pkg proc to warning for no locations
11258 pqp_gb_tp_pension_extracts.warn_if_no_loc_exist
11259 (p_assignment_id => p_assignment_id) ;
11260 pqp_gb_tp_pension_extracts.g_nested_level := 0;
11261
11262 ELSE -- Valid locations EXIST
11263
11264 -- Reset the supply assignment count
11265 g_supply_asg_count := 0;
11266
11267 -- Bugfix 3641851:ENH6 Reset the part time assignment count
11268 g_part_time_asg_count := 0;
11269
11270 -- Resetting cross person reporting and person count
11271 -- Moved it here from warn_anthr_tchr_asg
11272 g_cross_per_enabled := 'Y' ;
11273 g_person_count := 0 ;
11274
11275 --added for bug fix 3803760 (PRD)
11276 g_asg_count := 0;
11277
11278 -- MULT-LR --
11279 -- setting it to the primary assignment id.
11280 -- in create_service_lines, it may get overwritten
11281 g_primary_assignment_id := p_assignment_id;
11282
11283 -- Added for 5460058
11284 g_equal_sal_rate := 'Y';
11285
11286 -- PER_LVR : Person LEaver changes
11287 -- new date variable to keep track of the latest start date
11288 -- associated with a person record,
11289 -- after which there is no person leaver event
11290 -- initialize with the g_effective_run_date
11291 g_latest_start_date := g_effective_run_date;
11292
11293 -- Check if this person should be reported by the current run
11294 IF chk_report_person
11295 (p_business_group_id => p_business_group_id
11296 -- PRD : reverted the change made to date.
11297 ,p_effective_date => g_pension_year_start_date
11298 ,p_assignment_id => p_assignment_id
11299 ) THEN
11300
11301 debug('g_cross_person_enabled : '|| g_cross_per_enabled);
11302 -- Bugfix 3073562:GAP10
11303 -- Reset the global which stores dates for new lines of
11304 -- service as there mite be some dates stored for the
11305 -- prev assignment processed
11306 g_asg_events.DELETE;
11307
11308 -- 8iComp Changes
11309 -- MULT-LR changes.
11310 -- g_asg_leaver_events_table.DELETE ;
11311
11312 g_per_asg_leaver_dates.DELETE;
11313
11314 -- PERF_ENHANC_3A : Performance Enhancements
11315 -- this table of records will be used in recalc_data_elements to store
11316 -- details corresponding of assignment IDs. Instead of calling parttime and FT
11317 -- salary function multiple times, this data collection will be used
11318 g_asg_recalc_details.DELETE;
11319
11320
11321 -- Check if the assignment qualifies to be on the Periodic Returns
11322 -- Pass g_pension_year_start_date as the effective date as we are
11323 -- checking as of start date of pension year. Basically, we are
11324 -- reporting annual returns from start of pension year to
11325 -- the date a person becomes a leaver, if he becomes a leaver that is.
11326
11327 --PROFILE changes
11328 IF(NVL(g_trace,'N') = 'Y') THEN
11329 l_start_time := dbms_utility.get_time;
11330 END IF ;
11331
11332 l_inclusion_flag := chk_has_tchr_elected_pension
11333 (p_business_group_id => p_business_group_id
11334 ,p_effective_date => g_pension_year_start_date
11335 ,p_assignment_id => p_assignment_id
11336 ,p_asg_details => l_asg_details -- OUT
11337 ,p_asg_attributes => l_pqp_asg_attributes -- OUT
11338 );
11339
11340 --PROFILE changes
11341 IF (NVL(g_trace,'N') = 'Y') THEN
11342 l_end_time := dbms_utility.get_time;
11343 debug('EXECUTION_TIME: chk_has_tchr_elected_pension: '||to_char(ABS(l_end_time - l_start_time)),15) ;
11344 END IF ;
11345
11346 IF l_inclusion_flag = 'Y' THEN
11347
11348 debug('Teacher has elected pension, now doing leaver chk',20);
11349
11350 -- Check for leaver events between pension year start date and effective run date
11351 -- Basically, we are reporting annual returns starting from the
11352 -- start of the pension year to the leaver date, and we want to check
11353 -- for people who have become leavers in the same date range.
11354 -- However as we donot want to report people who have already been reported,
11355 -- we will need to look at previous run results to exclude people who
11356 -- have already been reported.
11357 -- Dates :
11358 -- Start date should be pension year start date
11359 -- End Date should be the end date of the run date range.
11360 l_leaver := chk_is_teacher_a_leaver
11361 (p_business_group_id => p_business_group_id
11362 -- PRD : Reverted the change made to Date
11363 ,p_effective_start_date => GREATEST(g_pension_year_start_date
11364 ,nvl(l_asg_details.start_date
11365 ,g_pension_year_start_date
11366 )
11367 )
11368 ,p_effective_end_date => g_effective_run_date + 1 -- LVRDATE
11369 ,p_assignment_id => p_assignment_id
11370 ,p_leaver_date => l_leaver_date -- OUT
11371 );
11372
11373
11374 IF l_leaver = 'Y' THEN
11375
11376 -- Check if the leaver is also a re-starter,
11377 -- i.e. there is break in service in this pension year
11378 -- But, do this only if the leaver date is present and
11379 -- less than the g_effective_run_date
11380 l_asg_details.restarter_date := NULL;
11381
11382 IF l_leaver = 'Y'
11383 AND
11384 l_leaver_date < g_effective_run_date THEN
11385
11386 debug('Doing restarter chk',50);
11387
11388 l_restarter := chk_is_leaver_a_restarter
11389 (p_business_group_id => p_business_group_id
11390 ,p_effective_start_date => (l_leaver_date + 1)
11391 ,p_effective_end_date => g_effective_run_date
11392 ,p_assignment_id => p_assignment_id
11393 ,p_restarter_date => l_restarter_date -- OUT
11394 );
11395
11396 IF l_restarter = 'Y' THEN
11397
11398 debug('Restarter date :'||to_char(l_restarter_date,'DDMMYY'),60);
11399
11400 l_asg_details.restarter_date := l_restarter_date;
11401
11402 END IF; -- l_restarter = 'Y' THEN
11403
11404 END IF; -- l_leaver = 'Y' AND l_leaver_date < g_effective_run_date THEN
11405 ELSE -- l_leaver = 'N' THEN
11406
11407 debug('Not a Leaver',100);
11408 -- PER_LVR : Person Leaver changes
11409 -- keep the leaver date in the global.
11410 -- There is no person level leaver after this date
11411 -- Will use this date, when checking for person level lever event.
11412 g_latest_start_date := LEAST (g_latest_start_date, l_asg_details.start_date);
11413 -- Start of Bug fix 5408932
11414 -- If this is the only assignment then he should not be reported
11415 l_inclusion_flag := 'N';
11416
11417 -- Check for Secondary assignments.
11418 l_look_for_sec_asgs := TRUE;
11419
11420 -- Teacher is not a leaver. The primary assignment should not be reported.
11421 l_asg_details.report_asg := 'N';
11422 -- End of Bug fix 5408932
11423
11424 END IF ; -- l_leaver = 'N' THEN
11425 -- Assignment has passed all checks save the details in
11426 -- 1) Type 4 global collection g_ext_asg_details
11427 -- 2) Type 1 global collection g_ext_asg_details
11428 -- Has more stuff than the Type 4 counterpart
11429 -- 3) Type 1 global collection g_ext_aat_details
11430 --
11431 -- Bug 5408932
11432 -- Store the globals only if it is the terminated assignment
11433 IF l_inclusion_flag = 'Y' THEN
11434 -- First assign the leaver date to the asg details rowtype variable
11435 debug('Storing values in globals',70);
11436 l_asg_details.leaver_date := l_leaver_date;
11437
11438 -- 1) Type 4 global collection g_ext_asg_details
11439 pqp_gb_tp_pension_extracts.g_ext_asg_details(p_assignment_id).person_id := l_asg_details.person_id;
11440 pqp_gb_tp_pension_extracts.g_ext_asg_details(p_assignment_id).assignment_id := l_asg_details.assignment_id;
11441 pqp_gb_tp_pension_extracts.g_ext_asg_details(p_assignment_id).start_date := l_asg_details.start_date;
11442 pqp_gb_tp_pension_extracts.g_ext_asg_details(p_assignment_id).effective_end_date:= l_asg_details.effective_end_date;
11443 pqp_gb_tp_pension_extracts.g_ext_asg_details(p_assignment_id).creation_date := l_asg_details.creation_date;
11444 pqp_gb_tp_pension_extracts.g_ext_asg_details(p_assignment_id).location_id := l_asg_details.location_id;
11445 pqp_gb_tp_pension_extracts.g_ext_asg_details(p_assignment_id).asg_emp_cat_cd := l_asg_details.asg_emp_cat_cd;
11446 pqp_gb_tp_pension_extracts.g_ext_asg_details(p_assignment_id).ext_emp_cat_cd := l_asg_details.ext_emp_cat_cd;
11447
11448 pqp_gb_tp_pension_extracts.g_ext_asg_details(p_assignment_id).estb_number :=
11449 pqp_gb_tp_pension_extracts.g_criteria_estbs(l_asg_details.location_id).estb_number;
11450
11451 pqp_gb_tp_pension_extracts.g_ext_asg_details(p_assignment_id).tp_safeguarded_grade :=
11452 l_pqp_asg_attributes.tp_safeguarded_grade;
11453
11454 -- 2) Type 1 global collection g_ext_asg_details
11455 g_ext_asg_details(p_assignment_id) := l_asg_details;
11456
11457 -- 3) Type 1 global collection g_ext_aat_details
11458 g_ext_asg_attributes(l_pqp_asg_attributes.assignment_id) := l_pqp_asg_attributes;
11459
11460
11461 -- Bugfix 3073562:GAP9a
11462 -- Raise a warning if the assignment is at a
11463 -- supply location and full time
11464 warn_if_supply_tchr_is_ft
11465 (p_assignment_id => p_assignment_id
11466 ,p_establishment_number =>
11467 pqp_gb_tp_pension_extracts.g_criteria_estbs(l_asg_details.location_id).estb_number
11468 ,p_ext_emp_cat_code => l_asg_details.ext_emp_cat_cd
11469 );
11470
11471 -- Bugfix 3073562:GAP9b
11472 -- Increment the supply asg count if this is a supply assignment
11473 IF pqp_gb_tp_pension_extracts.g_criteria_estbs(l_asg_details.location_id).estb_number = '0966' THEN
11474 g_supply_asg_count := g_supply_asg_count + 1;
11475 debug('Incrementing supply teacher count',75);
11476 END IF;
11477
11478 -- Bugfix 3641851:ENH6
11479 -- Increment the part time assignment count if the asg is part time
11480 IF l_asg_details.ext_emp_cat_cd = 'P' THEN
11481 g_part_time_asg_count := g_part_time_asg_count + 1;
11482 debug('Incrementing part time assignment count',76);
11483 END IF;
11484
11485 -- Bugfix 3803760:TERMASG : Incrementing asg count (PRD)
11486 g_asg_count := g_asg_count + 1;
11487
11488 debug('g_asg_count: '|| to_char(g_asg_count), 75) ;
11489 debug('Fetching secondary asgs',80);
11490
11491 debug('g_cross_person_enabled : '|| (g_cross_per_enabled),57);
11492
11493 -- This procedure also saves the secondary assignments in the global record varialbes
11494 fetch_secondary_assignments
11495 (p_primary_assignment_id => p_assignment_id
11496 ,p_person_id => l_asg_details.person_id
11497 -- PRD : reverted the change made to date
11498 ,p_effective_date => g_pension_year_start_date
11499 ,p_must_be_a_leaver => TRUE
11500 );
11501 ELSE
11502 debug('Primary Asg '|| to_char(p_assignment_id)||' is not terminated', 84) ;
11503 END IF; -- l_inclusion_flag = 'Y' Bug 5408932
11504 debug('g_asg_count: '|| to_char(g_asg_count), 85) ;
11505 debug('Number of TP1 teachers on periodic report :'||
11506 fnd_number.number_to_canonical(pqp_gb_tp_pension_extracts.g_ext_asg_details.COUNT));
11507
11508 ELSE
11509 -- Bugfix 3073562:GAP6
11510 -- Continue looking for secondary asgs
11511 l_look_for_sec_asgs := TRUE;
11512 END IF; -- l_inclusion_flag = 'Y' THEN
11513
11514 -- Bugfix 3073562:GAP6
11515 -- Even though this asg is not being included, we need to
11516 -- look for prospective secondary leaver assignments
11517 IF l_inclusion_flag = 'N'
11518 AND l_look_for_sec_asgs THEN
11519
11520 debug('Primary NOT included, checking secondary asgs',110);
11521
11522 l_asg_count := g_ext_asg_details.COUNT;
11523
11524 -- Get person id if its NULL
11525 IF l_asg_details.person_id IS NULL THEN
11526
11527 debug('Person Id is NULL, get it',120);
11528
11529 OPEN csr_asg_details_up(p_assignment_id);
11530 FETCH csr_asg_details_up INTO l_temp_asg_details;
11531 CLOSE csr_asg_details_up;
11532
11533 l_asg_details.person_id := l_temp_asg_details.person_id;
11534
11535 END IF;
11536
11537 debug('g_asg_count: '|| to_char(g_asg_count), 125) ;
11538
11539 fetch_secondary_assignments
11540 (p_primary_assignment_id => p_assignment_id
11541 ,p_person_id => l_asg_details.person_id
11542 -- PRD : reverted the change made to date.
11543 ,p_effective_date => g_pension_year_start_date
11544 ,p_must_be_a_leaver => TRUE
11545 );
11546
11547 debug('g_asg_count: '|| to_char(g_asg_count), 128) ;
11548 -- If proc fetch_secondary_assignments added any new asgs to
11549 -- global collection, resulting in higher count, then it means
11550 -- we have secondary asgs for this person.
11551 IF g_ext_asg_details.COUNT > l_asg_count THEN
11552
11553 debug('Secondary asg Teacher, report this person',130);
11554 l_inclusion_flag := 'Y';
11555
11556 END IF;
11557
11558 END IF; -- l_inclusion_flag = 'N' AND l_look_for_sec_asgs THEN
11559
11560 ELSE -- chk_report_person
11561 debug(l_proc_name,140);
11562 l_inclusion_flag := 'N';
11563 END IF; -- chk_report_person
11564
11565 debug('Inclusion Flag :'||l_inclusion_flag,150);
11566
11567 IF l_inclusion_flag = 'Y' THEN
11568
11569 -- PER_LVR change
11570 -- This piece of code checks for the person level leaver events
11571
11572 debug('g_latest_start_date : '||to_char(g_latest_start_date),160 );
11573 debug('teacher_start_date: '|| to_char(g_ext_asg_details(p_assignment_id).teacher_start_date));
11574
11575 -- 1. check if there is any one continuous assignment over the period Then person is not a leaver.
11576 IF g_latest_start_date = g_ext_asg_details(p_assignment_id).teacher_start_date THEN
11577 debug('There is atleast one continuous asg over the period...',170);
11578 l_inclusion_flag := 'N';
11579 ELSE
11580 -- check for Person level Leaver events.
11581 l_inclusion_flag := chk_person_leaver
11582 ( p_assignment_id => p_assignment_id
11583 ,p_person_id => l_asg_details.person_id
11584 );
11585
11586 -- 2. store_leaver_restarter_dates
11587 -- 3. sort_stored_events
11588 -- 4. browse events and store person level rehire dates as per g_asg_count status
11589 -- a). if leaver date found then chk if person has to be reported for this date
11590 -- b). if yes continue
11591 -- c). if no, stop, this needs to be reported.
11592 debug('l_inclusion_flag: '||l_inclusion_flag,180);
11593 END IF;
11594 debug('l_inclusion_flag: '||l_inclusion_flag,190);
11595
11596 END IF; --l_inclusion_flag = 'Y'
11597
11598 IF l_inclusion_flag = 'Y' THEN
11599
11600 debug(l_proc_name, 210 );
11601 -- Now we know that this person wll be reported
11602 -- Raise all the errors and warnings
11603
11604 -- Bugfix 3073562:GAP9b
11605 -- If this person has more than one supply assignments
11606 -- then raise a warning.
11607 IF g_supply_asg_count > 1 THEN
11608 l_error := pqp_gb_tp_extract_functions.raise_extract_warning
11609 (p_assignment_id => p_assignment_id
11610 ,p_error_text => 'BEN_93656_SUPPLY_TCHR_MULTIASG'
11611 ,p_error_number => 93656
11612 );
11613 END IF;
11614
11615 -- The following piece of code raises a warning if
11616 -- there exist more than one lea with the same lea Number within a BG.
11617 -- the warning is raised for the first valid assignment for a single Run.
11618 -- the flag for warning is set during the global setting through set_extract_globals.
11619 pqp_gb_tp_pension_extracts.g_nested_level := g_nested_level;
11620 pqp_gb_tp_pension_extracts.warn_if_multi_lea_exist (p_assignment_id => p_assignment_id);
11621 pqp_gb_tp_pension_extracts.g_nested_level := 0;
11622
11623 -- The following proc raises a warning, if there is
11624 -- one FT teaching asg for the person
11625 -- and there are multiple person records.
11626 -- the proc checks for the flags g_cross_person_enabled and g_person_count
11627 -- and resets those flags.
11628 warn_anthr_tchr_asg(p_assignment_id => p_assignment_id);
11629
11630 -- Bugfix 3803760:FTSUPPLY (PRD)
11631 -- Set the effective assignments as of teacher start date
11632 debug('g_asg_count: '|| to_char(g_asg_count), 255) ;
11633 set_effective_assignments
11634 (p_primary_assignment_id => p_assignment_id
11635 ,p_effective_date => g_ext_asg_details(p_assignment_id).teacher_start_date
11636 );
11637 debug('g_asg_count: '|| to_char(g_asg_count), 258) ;
11638 END IF ; -- l_inclusion_flag = 'Y'
11639
11640 END IF; -- pqp_gb_tp_pension_extracts.g_criteria_estbs.COUNT = 0
11641
11642 debug('l_inclusion_flag: '||l_inclusion_flag,260);
11643 debug_exit(l_proc_name);
11644
11645 RETURN l_inclusion_flag;
11646
11647 EXCEPTION
11648 WHEN OTHERS THEN
11649 debug_exit(' Others in '||l_proc_name
11650 ,'Y' -- turn trace off
11651 );
11652 RAISE;
11653 END; -- chk_tp1_criteria_periodic
11654
11655
11656 --
11657 -- Criteria for Type 1 Annual with facility to Include/Exclude Leavers
11658 --
11659 FUNCTION chk_tp1_criteria_annual
11660 (p_business_group_id IN NUMBER -- context
11661 ,p_effective_date IN DATE -- context
11662 ,p_assignment_id IN NUMBER -- context
11663 ) RETURN VARCHAR2 -- Y or N
11664 IS
11665
11666 -- Variable Declaration
11667 l_inclusion_flag VARCHAR2(1) := 'Y';
11668 l_leaver VARCHAR2(1) := 'N';
11669 l_leaver_date DATE;
11670 l_already_reported VARCHAR2(1) := 'N';
11671 l_restarter VARCHAR2(1) := 'N';
11672 l_restarter_date DATE := NULL;
11673 l_person_id per_all_people_f.person_id%TYPE;
11674 l_asg_count NUMBER;
11675 l_error NUMBER;
11676
11677 -- Rowtype Variable Declaration
11678 l_asg_details csr_asg_details_up%ROWTYPE;
11679 l_per_details csr_asg_details_up%ROWTYPE;
11680 l_pqp_asg_attributes csr_pqp_asg_attributes_up%ROWTYPE;
11681 l_temp_asg_details csr_asg_details_up%ROWTYPE;
11682
11683
11684
11685 l_proc_name VARCHAR2(61):=
11686 g_proc_name||'chk_tp1_criteria_annual';
11687
11688 BEGIN -- chk_tp1_criteria_annual
11689
11690 debug_enter(l_proc_name);
11691
11692 debug('Assignment Id :'||to_char(p_assignment_id),10);
11693 debug('Effective_date :'||to_char(p_effective_date,'dd/mm/yyyy'),15);
11694
11695 IF g_business_group_id IS NULL THEN
11696
11697 -- Bugifx 2848696 : Now using ben_ext_person.g_effective_date
11698 -- instead of p_effective_date
11699 set_t1_extract_globals
11700 (p_business_group_id
11701 ,ben_ext_person.g_effective_date -- p_effective_date
11702 ,p_assignment_id
11703 );
11704
11705
11706 -- Bugifx 2848696 : Now using ben_ext_person.g_effective_date
11707 -- instead of p_effective_date
11708 pqp_gb_tp_pension_extracts.g_nested_level := g_nested_level;
11709 g_reporting_mode := upper(pqp_gb_tp_pension_extracts.get_extract_udt_info
11710 ('Attribute Location Qualifier 1' -- column
11711 ,'Criteria' -- row
11712 ,ben_ext_person.g_effective_date -- p_effective_date
11713 )
11714 );
11715 pqp_gb_tp_pension_extracts.g_nested_level := 0;
11716
11717 set_annual_run_dates;
11718
11719 -- Fetch element ids from balance's
11720 fetch_eles_for_t1_bals (p_assignment_id => p_assignment_id
11721 ,p_effective_date => g_pension_year_start_date
11722 );
11723
11724 END IF;
11725
11726 -- Bugfix -- Bugfix 3671727: Performance enhancement
11727 -- If no location exists in the list of valid criteria
11728 -- establishments, then no point doing all checks
11729 -- Just warn once and skip every assignment
11730 IF pqp_gb_tp_pension_extracts.g_criteria_estbs.COUNT = 0 THEN
11731
11732 debug('Setting inclusion flag to N as no locations EXIST.', 15);
11733 l_inclusion_flag := 'N';
11734
11735 pqp_gb_tp_pension_extracts.g_nested_level := g_nested_level;
11736 -- Call TP4 pkg proc to warning for no locations
11737 pqp_gb_tp_pension_extracts.warn_if_no_loc_exist
11738 (p_assignment_id => p_assignment_id) ;
11739 pqp_gb_tp_pension_extracts.g_nested_level := 0;
11740
11741 ELSE -- Valid locations EXIST
11742
11743 debug('Reporting Mode for leavers is :'||g_reporting_mode,20);
11744
11745 -- Reset the supply assignment count
11746 g_supply_asg_count := 0;
11747
11748 -- Bugfix 3641851:ENH6 Reset the part time assignment count
11749 g_part_time_asg_count := 0;
11750
11751 -- Resetting cross person reporting and person count
11752 -- Moved it here from warn_anthr_tchr_asg
11753 g_cross_per_enabled := 'Y' ;
11754 g_person_count := 0 ;
11755
11756 -- Added for bugfix 3803760:TERMASG
11757 g_asg_count := 0;
11758
11759 g_teach_asg_count :=0;
11760
11761 -- MULT-LR --
11762 -- setting it to the primary assignment id.
11763 -- in create_service_lines, it may get overwritten
11764 g_primary_assignment_id := p_assignment_id;
11765
11766 -- Added for 5460058
11767 g_equal_sal_rate := 'Y';
11768
11769 g_supp_teacher := 'N';
11770
11771 -- Check if this person should be reported by the current run
11772 IF chk_report_person
11773 (p_business_group_id => p_business_group_id
11774 ,p_effective_date => g_pension_year_start_date
11775 ,p_assignment_id => p_assignment_id
11776 ) THEN
11777
11778 debug('g_cross_person_enabled : '|| g_cross_per_enabled);
11779 -- Reset the global which stores dates for new lines of
11780 -- service as there mite be some dates stored for the
11781 -- prev assignment processed
11782 g_asg_events.DELETE;
11783
11784
11785 -- PERF_ENHANC_3A : Performance Enhancements
11786 -- this table of records will be used in recalc_data_elements to store
11787 -- details corresponding of assignment IDs. Instead of calling parttime and FT
11788 -- salary function multiple times, this data collection will be used
11789 g_asg_recalc_details.DELETE;
11790
11791
11792 -- 8iComp Changes
11793 -- MULT-LR changes.
11794 -- g_asg_leaver_events_table.DELETE ;
11795
11796 g_per_asg_leaver_dates.DELETE;
11797
11798 -- Check if the assignment qualifies to be on the Periodic Returns
11799 -- Pass g_pension_year_start_date as the effective date as we are
11800 -- checking as of start date of pension year. Basically, we are
11801 -- reporting annual returns from start of pension year to
11802 -- the date a person becomes a leaver, if he becomes a leaver that is.
11803 l_inclusion_flag := chk_has_tchr_elected_pension
11804 (p_business_group_id => p_business_group_id
11805 ,p_effective_date => g_pension_year_start_date
11806 ,p_assignment_id => p_assignment_id
11807 ,p_asg_details => l_asg_details -- OUT
11808 ,p_asg_attributes => l_pqp_asg_attributes -- OUT
11809 );
11810
11811 IF l_inclusion_flag = 'Y' THEN
11812 -- 1)
11813
11814 debug('Teacher has elected pension',30);
11815
11816 -- Check for leaver events between pension year start date and effective run date
11817 -- For annual report effective run date should be pension year end date
11818 -- Basically, we are reporting annual returns starting from the
11819 -- start of the pension year to the end of pension year, and we want
11820 -- to check for people who have become leavers in the same date range.
11821 -- Dates :
11822 -- Start date should be pension year start date
11823 -- End Date should be the end date of the run date range, i.e. end of pension year
11824 l_leaver := chk_is_teacher_a_leaver
11825 (p_business_group_id => p_business_group_id
11826 ,p_effective_start_date => GREATEST(g_pension_year_start_date
11827 ,nvl(l_asg_details.start_date
11828 ,g_pension_year_start_date
11829 )
11830 )
11831 ,p_effective_end_date => nvl(g_effective_run_date
11832 ,g_pension_year_end_date)
11833 ,p_assignment_id => p_assignment_id
11834 ,p_leaver_date => l_leaver_date -- OUT
11835 );
11836
11837
11838 /* IF nvl(g_reporting_mode,'EXCLUDE') = 'EXCLUDE'
11839 AND
11840 l_leaver = 'Y' THEN
11841
11842 -- Set the inclusion flag to 'N'o as this person is a leaver
11843 -- and we are running in EXCLUDE leavers reporting mode
11844 l_inclusion_flag := 'N';
11845
11846 END IF; -- nvl(g_reporting_mode,'EXCLUDE') = 'EXCLUDE' THEN */-- commenting this chk, since it is chking primary assinments 1st leaver event
11847 -- with out considering 2ndary asgs leaver events
11848
11849 IF l_inclusion_flag = 'Y' THEN
11850 -- 2)
11851
11852 -- Assignment has passed all checks save the details in
11853 -- 1) Type 4 global collection g_ext_asg_details
11854 -- 2) Type 1 global collection g_ext_asg_details
11855 -- Has more stuff than the Type 4 counterpart
11856 -- 3) Type 1 global collection g_ext_aat_details
11857 --
11858
11859 -- Check if the leaver is also a re-starter,
11860 -- i.e. there is break in service in this pension year
11861 -- But, do this only if the leaver date is present and
11862 -- less than the g_effective_run_date
11863 l_asg_details.restarter_date := NULL;
11864
11865 IF l_leaver = 'Y'
11866 AND
11867 l_leaver_date < g_effective_run_date THEN
11868
11869 l_restarter := chk_is_leaver_a_restarter
11870 (p_business_group_id => p_business_group_id
11871 ,p_effective_start_date => (l_leaver_date + 1)
11872 ,p_effective_end_date => g_effective_run_date
11873 ,p_assignment_id => p_assignment_id
11874 ,p_restarter_date => l_restarter_date -- OUT
11875 );
11876
11877 IF l_restarter = 'Y' THEN
11878
11879 debug('Restarter',40);
11880 l_asg_details.restarter_date := l_restarter_date;
11881
11882 END IF; -- l_restarter = 'Y' THEN
11883
11884 END IF; -- l_leaver = 'Y' AND l_leaver_date < g_effective_run_date THEN
11885
11886
11887 /* Replacing this with assignment statements for individual elements as
11888 there is a plan to extent the assignment cursor to include more cols.
11889
11890 pqp_gb_tp_pension_extracts.g_ext_asg_details(p_assignment_id) := l_asg_details;
11891
11892 pqp_gb_tp_pension_extracts.g_ext_asg_details(p_assignment_id).estb_number :=
11893 pqp_gb_tp_pension_extracts.g_criteria_estbs(l_asg_details.location_id).estb_number;
11894
11895 -- already populated this in l_asg_details before received in this function
11896 -- pqp_gb_tp_pension_extracts.g_ext_asg_details(p_assignment_id).start_date := l_pension_start_date;
11897
11898 pqp_gb_tp_pension_extracts.g_ext_asg_details(p_assignment_id).tp_safeguarded_grade :=
11899 l_pqp_asg_attributes.tp_safeguarded_grade;
11900 */
11901
11902 -- First assign the leaver date to the asg details rowtype variable
11903 IF l_leaver = 'Y' THEN
11904 l_asg_details.leaver_date := l_leaver_date;
11905 ELSE -- l_leaver = 'N'
11906 l_asg_details.leaver_date := NULL;
11907 END IF; -- l_leaver = 'Y' THEN
11908
11909 debug('Storing values in globals',50);
11910
11911 -- 1) Type 4 global collection g_ext_asg_details
11912
11913 pqp_gb_tp_pension_extracts.g_ext_asg_details(p_assignment_id).person_id := l_asg_details.person_id;
11914 pqp_gb_tp_pension_extracts.g_ext_asg_details(p_assignment_id).assignment_id := l_asg_details.assignment_id;
11915 pqp_gb_tp_pension_extracts.g_ext_asg_details(p_assignment_id).start_date := l_asg_details.start_date;
11916 pqp_gb_tp_pension_extracts.g_ext_asg_details(p_assignment_id).effective_end_date := l_asg_details.effective_end_date;
11917 pqp_gb_tp_pension_extracts.g_ext_asg_details(p_assignment_id).creation_date := l_asg_details.creation_date;
11918 pqp_gb_tp_pension_extracts.g_ext_asg_details(p_assignment_id).location_id := l_asg_details.location_id;
11919 pqp_gb_tp_pension_extracts.g_ext_asg_details(p_assignment_id).asg_emp_cat_cd := l_asg_details.asg_emp_cat_cd;
11920 pqp_gb_tp_pension_extracts.g_ext_asg_details(p_assignment_id).ext_emp_cat_cd := l_asg_details.ext_emp_cat_cd;
11921
11922 pqp_gb_tp_pension_extracts.g_ext_asg_details(p_assignment_id).estb_number :=
11923 pqp_gb_tp_pension_extracts.g_criteria_estbs(l_asg_details.location_id).estb_number;
11924
11925 pqp_gb_tp_pension_extracts.g_ext_asg_details(p_assignment_id).tp_safeguarded_grade :=
11926 l_pqp_asg_attributes.tp_safeguarded_grade;
11927
11928 -- 2) Type 1 global collection g_ext_asg_details
11929 g_teach_asg_count :=g_teach_asg_count +1;
11930 g_ext_asg_details(p_assignment_id) := l_asg_details;
11931
11932 -- 3) Type 1 global collection g_ext_aat_details
11933 g_ext_asg_attributes(l_pqp_asg_attributes.assignment_id) := l_pqp_asg_attributes;
11934
11935 -- Bugfix 3073562:GAP9a
11936 -- Raise a warning if the assignment is at a
11937 -- supply location and full time
11938 warn_if_supply_tchr_is_ft
11939 (p_assignment_id => p_assignment_id
11940 ,p_establishment_number =>
11941 pqp_gb_tp_pension_extracts.g_criteria_estbs(l_asg_details.location_id).estb_number
11942 ,p_ext_emp_cat_code => l_asg_details.ext_emp_cat_cd
11943 );
11944
11945 -- Bugfix 3073562:GAP9b
11946 -- Increment the supply asg count if this is a supply assignment
11947 IF pqp_gb_tp_pension_extracts.g_criteria_estbs(l_asg_details.location_id).estb_number = '0966' THEN
11948 g_supply_asg_count := g_supply_asg_count + 1;
11949 debug('Incrementing supply teacher count',55);
11950 END IF;
11951
11952 -- Bugfix 3641851:ENH6
11953 -- Increment the part time assignment count if the asg is part time
11954 IF l_asg_details.ext_emp_cat_cd = 'P' THEN
11955 g_part_time_asg_count := g_part_time_asg_count + 1;
11956 debug('Incrementing part time assignment count',56);
11957 END IF;
11958
11959 -- Bugfix 3803760:TERMASG : Incrementing asg count
11960 g_asg_count := g_asg_count + 1;
11961
11962 debug('g_asg_count: '|| to_char(g_asg_count), 55) ;
11963
11964 debug('Fetching secondary asgs',60);
11965 -- This procedure also saves the secondary assignments in the global record varialbes
11966 fetch_secondary_assignments
11967 (p_primary_assignment_id => p_assignment_id
11968 ,p_person_id => l_asg_details.person_id
11969 ,p_effective_date => g_pension_year_start_date
11970 ,p_must_be_a_leaver => FALSE
11971 );
11972 debug('g_asg_count: '|| to_char(g_asg_count), 65) ;
11973 debug('Number of TP1 teachers on annual report :'||
11974 fnd_number.number_to_canonical(pqp_gb_tp_pension_extracts.g_ext_asg_details.COUNT),70);
11975 --
11976 END IF; -- 2) l_inclusion_flag = 'Y' THEN
11977 --
11978 ELSE -- 1) inclusion flag is 'N'
11979
11980 -- Bugfix 3073562:GAP6
11981 -- Primary asg not to be included
11982 -- but check for any secondary teaching asgs
11983
11984 debug('Primary NOT teacher, checking secondary asgs',80);
11985
11986 l_asg_count := g_ext_asg_details.COUNT;
11987
11988 -- Get person id if its NULL
11989 IF l_asg_details.person_id IS NULL THEN
11990
11991 debug('Person Id is NULL, get it',90);
11992
11993 OPEN csr_asg_details_up(p_assignment_id);
11994 FETCH csr_asg_details_up INTO l_temp_asg_details;
11995 CLOSE csr_asg_details_up;
11996
11997 l_asg_details.person_id := l_temp_asg_details.person_id;
11998
11999 END IF;
12000
12001 debug('g_asg_count: '|| to_char(g_asg_count), 95) ;
12002 fetch_secondary_assignments
12003 (p_primary_assignment_id => p_assignment_id
12004 ,p_person_id => l_asg_details.person_id
12005 ,p_effective_date => g_pension_year_start_date
12006 ,p_must_be_a_leaver => FALSE
12007 );
12008 debug('g_asg_count: '|| to_char(g_asg_count), 95) ;
12009 -- If proc fetch_secondary_assignments added any new asgs to
12010 -- global collection, resulting in higher count, then it means
12011 -- we have secondary asgs for this person.
12012 IF g_ext_asg_details.COUNT > l_asg_count THEN
12013
12014 debug('Secondary asg Teacher, report this person',100);
12015 l_inclusion_flag := 'Y';
12016
12017 END IF;
12018 --
12019 END IF; -- 1) l_inclusion_flag = 'Y' THEN
12020
12021 ELSE -- chk_report_person
12022 debug(l_proc_name,110);
12023 l_inclusion_flag := 'N';
12024 END IF; -- chk_report_person
12025
12026 debug('l_inclusion_flag : '|| l_inclusion_flag ,111);
12027
12028 IF nvl(g_reporting_mode,'EXCLUDE') = 'EXCLUDE' and l_inclusion_flag = 'Y' then
12029 -- if criteria is 'Exclude' then we have to chk persons all asgs leaver events
12030 debug('Criteria is Exclude, need to check person is leaver or not.' ,112);
12031 l_inclusion_flag := chk_person_leaver
12032 ( p_assignment_id => p_assignment_id
12033 ,p_person_id => l_asg_details.person_id
12034 );
12035 End if;
12036
12037
12038 -- Bugfix 3073562:GAP9b
12039 -- If this person has more than one supply assignments
12040 -- then raise a warning.
12041 IF g_supply_asg_count > 1 THEN
12042 l_error := pqp_gb_tp_extract_functions.raise_extract_warning
12043 (p_assignment_id => p_assignment_id
12044 ,p_error_text => 'BEN_93656_SUPPLY_TCHR_MULTIASG'
12045 ,p_error_number => 93656
12046 );
12047 END IF;
12048
12049 debug('Inclusion Flag :'||l_inclusion_flag,120);
12050
12051 IF l_inclusion_flag = 'Y' THEN
12052 -- The following piece of code raises a warning if
12053 -- there exist more than one lea with the same lea Number within a BG.
12054 -- the warning is raised for the first valid assignment for a single Run.
12055 -- the flag for warning is set during the global setting through set_extract_globals.
12056 pqp_gb_tp_pension_extracts.g_nested_level := g_nested_level;
12057 pqp_gb_tp_pension_extracts.warn_if_multi_lea_exist (p_assignment_id => p_assignment_id);
12058 pqp_gb_tp_pension_extracts.g_nested_level := 0;
12059
12060 -- The following proc raises a warning, if there is
12061 -- one FT teaching asg for the person
12062 -- and there are multiple person records.
12063 -- the proc checks for the flags g_cross_person_enabled and g_person_count
12064 -- and resets those flags.
12065 warn_anthr_tchr_asg(p_assignment_id => p_assignment_id);
12066
12067 -- Bugfix 3803760:FTSUPPLY
12068 -- Set the effective assignments as of teacher start date
12069 debug('g_asg_count: '|| to_char(g_asg_count), 130) ;
12070
12071 set_effective_assignments
12072 (p_primary_assignment_id => p_assignment_id
12073 ,p_effective_date => g_ext_asg_details(p_assignment_id).teacher_start_date
12074 );
12075 debug('g_asg_count: '|| to_char(g_asg_count), 140) ;
12076
12077
12078 END IF;
12079
12080 END IF; -- pqp_gb_tp_pension_extracts.g_criteria_estbs.COUNT = 0
12081
12082 debug_exit(l_proc_name);
12083
12084 RETURN l_inclusion_flag;
12085
12086 EXCEPTION
12087 WHEN OTHERS THEN
12088 debug_exit(' Others in '||l_proc_name
12089 ,'Y' -- turn trace off
12090 );
12091 RAISE;
12092 END; -- chk_tp1_criteria_annual
12093 --
12094 -- chk_report_assignment - overloaded
12095 --
12096 FUNCTION chk_report_assignment
12097 (p_assignment_id IN NUMBER
12098 -- Bugfix 3641851:CBF1 : Added new parameter effective date
12099 ,p_effective_date IN DATE
12100 ,p_secondary_assignment_id OUT NOCOPY NUMBER
12101 ) RETURN VARCHAR2
12102 IS
12103
12104 l_assignment_id per_all_assignments_f.assignment_id%TYPE;
12105 l_retval VARCHAR2(1) := 'Y';
12106 l_effective_date DATE;
12107
12108 l_proc_name varchar2(60) := g_proc_name || 'chk_report_assignment1';
12109
12110 BEGIN -- chk_report_assignment
12111
12112 debug_enter(l_proc_name);
12113
12114 debug('p_assignment_id :'||to_char(p_assignment_id), 10);
12115
12116 -- Bugfix 3803760:FTSUPPLY : Added the override logic
12117 IF g_override_ft_asg_id IS NULL THEN
12118
12119 IF (g_ext_asg_details.EXISTS(p_assignment_id)
12120 AND
12121 g_ext_asg_details(p_assignment_id).report_asg = 'Y'
12122 ) THEN
12123
12124 debug(l_proc_name, 20);
12125 -- Bugfix 3641851:CBF1: Added date check
12126 -- When primary asg starts at a later date than secondary asg,
12127 -- the func that evaluates an attribute from primary asg records
12128 -- can fail (and raise warning) coz there mite be no row present
12129 -- for the primary asg. However, the primary is to be reported
12130 -- frm a later date so we cannot ignore it altogether.
12131 -- Therefore, we need to use the secondary asgs row for getting
12132 -- attributes if the primary is not valid at the given eff date.
12133 --
12134 l_effective_date := nvl(p_effective_date, g_ext_asg_details(p_assignment_id).teacher_start_date);
12135 debug('l_effective_date :'||to_char(l_effective_date, 'DD/MM/YYYY'), 30);
12136
12137 -- MULT-LR --
12138 -- Use the new Function to check the effectivness of an assignment
12139 -- it takes care of multiple Leaver-Restarter events
12140 -- where as the old logic used to take into account
12141 -- only the first restarter event.
12142 IF ( chk_effective_asg (
12143 p_assignment_id => p_assignment_id
12144 ,p_effective_date => l_effective_date
12145 ) ='Y'
12146 ) THEN
12147
12148 debug(l_proc_name, 40);
12149 l_assignment_id := p_assignment_id;
12150
12151 ELSE
12152 l_assignment_id := g_ext_asg_details(p_assignment_id).secondary_assignment_id;
12153 END IF;
12154
12155 l_retval := 'Y';
12156
12157 ELSE
12158 debug(l_proc_name, 50);
12159 l_assignment_id := g_ext_asg_details(p_assignment_id).secondary_assignment_id;
12160 l_retval := 'N';
12161 END IF;
12162
12163 ELSE -- g_override_ft_asg_id is NOT NULL
12164
12165 l_assignment_id := g_override_ft_asg_id;
12166
12167 IF g_override_ft_asg_id = p_assignment_id THEN
12168 l_retval := 'Y';
12169 ELSE
12170 l_retval := 'N';
12171 END IF;
12172
12173 END IF;
12174
12175 p_secondary_assignment_id := l_assignment_id;
12176
12177 debug('p_secondary_assignment_id :'||to_char(p_secondary_assignment_id), 60);
12178 debug_exit(l_proc_name);
12179
12180 RETURN l_retval;
12181
12182 EXCEPTION
12183 WHEN OTHERS THEN
12184 p_secondary_assignment_id := NULL;
12185 debug_exit(' Others in '||l_proc_name);
12186 RAISE;
12187 END; -- chk_report_assignment
12188
12189 --
12190 -- chk_report_assignment - overloaded
12191 --
12192 FUNCTION chk_report_assignment
12193 (p_assignment_id IN NUMBER
12194 -- Bugfix 3641851:CBF1 : Added new parameter effective date
12195 ,p_effective_date IN DATE
12196 ,p_report_assignment OUT NOCOPY VARCHAR2
12197 ) RETURN NUMBER
12198 IS
12199
12200 l_assignment_id per_all_assignments_f.assignment_id%TYPE;
12201 l_retval VARCHAR2(1) := 'Y';
12202 l_effective_date DATE;
12203
12204 l_proc_name varchar2(60) := g_proc_name || 'chk_report_assignment2';
12205
12206 BEGIN -- chk_report_assignment
12207
12208 debug_enter(l_proc_name);
12209 debug('p_assignment_id :'||to_char(p_assignment_id), 10);
12210
12211 -- Bugfix 3803760:FTSUPPLY : Added the override logic
12212 IF g_override_ft_asg_id IS NULL THEN
12213
12214 IF (g_ext_asg_details.EXISTS(p_assignment_id)
12215 AND
12216 g_ext_asg_details(p_assignment_id).report_asg = 'Y'
12217 ) THEN
12218
12219 debug(l_proc_name, 20);
12220 -- Bugfix 3641851:CBF1: Added date check
12221 -- When primary asg starts at a later date than secondary asg,
12222 -- the func that evaluates an attribute from primary asg records
12223 -- can fail (and raise warning) coz there mite be no row present
12224 -- for the primary asg. However, the primary is to be reported
12225 -- frm a later date so we cannot ignore it altogether.
12226 -- Therefore, we need to use the secondary asgs row for getting
12227 -- attributes if the primary is not valid at the given eff date.
12228 --
12229 l_effective_date := nvl(p_effective_date, g_ext_asg_details(p_assignment_id).teacher_start_date);
12230 debug('l_effective_date :'||to_char(l_effective_date, 'DD/MM/YYYY'), 30);
12231
12232 -- MULT-LR --
12233 -- Use the new Function to check the effectivness of an assignment
12234 -- it takes care of multiple Leaver-Restarter events
12235 -- where as the old logic used to take into account
12236 -- only the first restarter event.
12237 IF ( chk_effective_asg (
12238 p_assignment_id => p_assignment_id
12239 ,p_effective_date => l_effective_date
12240 ) ='Y'
12241 ) THEN
12242
12243 debug(l_proc_name, 40);
12244 l_assignment_id := p_assignment_id;
12245
12246 ELSE
12247 l_assignment_id := g_ext_asg_details(p_assignment_id).secondary_assignment_id;
12248 END IF;
12249
12250 l_retval := 'Y';
12251
12252 ELSE
12253 debug(l_proc_name, 50);
12254 l_assignment_id := g_ext_asg_details(p_assignment_id).secondary_assignment_id;
12255 l_retval := 'N';
12256 END IF;
12257
12258 ELSE -- g_override_ft_asg_id is NOT NULL
12259
12260 l_assignment_id := g_override_ft_asg_id;
12261
12262 IF g_override_ft_asg_id = p_assignment_id THEN
12263 l_retval := 'Y';
12264 ELSE
12265 l_retval := 'N';
12266 END IF;
12267
12268 END IF;
12269
12270 p_report_assignment := l_retval;
12271
12272 debug('p_report_assignment :'||p_report_assignment, 60);
12273 debug('l_assignment_id :'||to_char(l_assignment_id), 70);
12274
12275 debug_exit(l_proc_name);
12276
12277 RETURN l_assignment_id;
12278
12279 EXCEPTION
12280 WHEN OTHERS THEN
12281 p_report_assignment := NULL;
12282 debug_exit(' Others in '||l_proc_name);
12283 RAISE;
12284 END; -- chk_report_assignment
12285
12286 --
12287 -- Start Date
12288 --
12289 FUNCTION get_tp1_start_date
12290 (p_assignment_id IN NUMBER
12291 )
12292 RETURN VARCHAR2
12293 IS
12294 l_start_date VARCHAR2(600);
12295 BEGIN
12296
12297 -- Bugfix 3641851:CBF1: Now returning teacher_start_date
12298 l_start_date := to_char(nvl(g_ext_asg_details(p_assignment_id).teacher_start_date
12299 ,g_ext_asg_details(p_assignment_id).start_date)
12300 ,'DDMMYY'
12301 );
12302
12303 RETURN l_start_date;
12304 END; -- get_tp1_start_date
12305 --
12306 -- End Date
12307 --
12308 FUNCTION get_tp1_end_date
12309 (p_assignment_id IN NUMBER
12310 ) RETURN VARCHAR2
12311 IS
12312
12313 BEGIN
12314
12315 RETURN to_char(LEAST(nvl(g_ext_asg_details(p_assignment_id).leaver_date
12316 ,g_effective_run_date
12317 )
12318 ,g_effective_run_date
12319 )
12320 ,'DDMMYY'
12321 );
12322 END; -- get_tp1_end_date
12323 --
12324 -- Withdrawal Confirmation
12325 --
12326 FUNCTION get_tp1_withdrawal_conf
12327 (p_assignment_id IN NUMBER
12328 ) RETURN VARCHAR2
12329 IS
12330
12331 l_withdrawal_conf ben_ext_rslt_dtl.val_15%TYPE := ' ';
12332 l_proc_name varchar2(60) := g_proc_name || 'get_tp1_withdrawal_conf';
12333
12334 BEGIN
12335
12336 debug_enter(l_proc_name);
12337 debug('g_asg_count :'||to_char(g_asg_count), 10);
12338
12339 IF g_ext_asg_details(p_assignment_id).leaver_date IS NOT NULL
12340 AND
12341 (LEAST(g_ext_asg_details(p_assignment_id).leaver_date
12342 ,g_effective_run_date
12343 )
12344 =
12345 g_ext_asg_details(p_assignment_id).leaver_date
12346 ) THEN
12347
12348 l_withdrawal_conf := 'W';
12349
12350 END IF;
12351
12352 debug_exit(l_proc_name);
12353 RETURN l_withdrawal_conf;
12354
12355 END; -- get_tp1_withdrawal_conf
12356
12357 -- ----------------------------------------------------------------------------
12358 -- |------------------------< get_tp1_days_excluded >-------------------------|
12359 -- ----------------------------------------------------------------------------
12360 function get_tp1_days_excluded (p_assignment_id in number
12361 ,p_days_excluded out nocopy varchar2
12362 )
12363 return number is
12364 --
12365 l_proc_name varchar2(60) := g_proc_name || 'get_tp1_days_excluded';
12366 l_days_excluded number;
12367 l_return number;
12368 --
12369 begin
12370 --
12371 -- hr_utility.set_location('Entering: '||l_proc_name, 10);
12372 --
12373 debug_enter(l_proc_name);
12374
12375 -- Bugfix 3803760:FTSUPPLY
12376 -- Changed start_date to teacher_start_date
12377 l_return := get_days_excluded_date
12378 (p_assignment_id => p_assignment_id
12379 ,p_effective_start_date => greatest
12380 (g_pension_year_start_date
12381 ,g_ext_asg_details(p_assignment_id).teacher_start_date
12382 )
12383 ,p_effective_end_date => least
12384 (g_effective_run_date
12385 ,nvl(g_ext_asg_details(p_assignment_id).leaver_date,
12386 g_effective_run_date)
12387 )
12388 ,p_days => l_days_excluded
12389 );
12390
12391 --
12392 -- hr_utility.set_location('Leaving: '||l_proc_name, 20);
12393 --
12394 -- bug 6275363---------
12395 IF l_return = -2 then
12396 p_days_excluded := '+00';
12397 debug_exit(l_proc_name);
12398 RETURN 0;
12399 END if;
12400 -------------------------
12401 debug_exit(l_proc_name);
12402
12403 if l_return <> -1 then
12404
12405 p_days_excluded := trim(to_char(l_days_excluded,'099'));
12406 return 0;
12407
12408 else
12409
12410 p_days_excluded := '000';
12411 return -1;
12412
12413 end if; -- end of of return check ...
12414
12415 EXCEPTION
12416 WHEN OTHERS THEN
12417 debug_exit(' Others in '||l_proc_name
12418 ,'Y' -- turn trace off
12419 );
12420 p_days_excluded := NULL;
12421 RAISE;
12422 end get_tp1_days_excluded;
12423 --
12424 -- ----------------------------------------------------------------------------
12425 -- |------------------------< get_tp1_annual_ft_sal_rate >--------------------|
12426 -- ----------------------------------------------------------------------------
12427 function get_tp1_annual_ft_sal_rate (p_assignment_id in number
12428 ,p_annual_rate out nocopy varchar2
12429 )
12430 return number is
12431 --
12432 l_proc_name varchar2(60) := g_proc_name || 'get_tp1_annual_ft_sal_rate';
12433 l_return number;
12434 l_annual_rate number;
12435 --
12436 begin
12437 --
12438 -- hr_utility.set_location('Entering: '||l_proc_name, 10);
12439 --
12440 debug_enter(l_proc_name);
12441
12442 -- Bugfix 3803760:FTSUPPLY
12443 -- Changed start_date to teacher_start_date
12444 l_return := get_annual_sal_rate_date
12445 (p_assignment_id => p_assignment_id
12446 ,p_effective_start_date => greatest
12447 (g_pension_year_start_date
12448 ,g_ext_asg_details(p_assignment_id).teacher_start_date
12449 )
12450 ,p_effective_end_date => least
12451 (g_effective_run_date
12452 ,nvl(g_ext_asg_details(p_assignment_id).leaver_date,
12453 g_effective_run_date)
12454 )
12455 ,p_rate => l_annual_rate
12456 );
12457
12458 --
12459 -- hr_utility.set_location('Leaving: '||l_proc_name, 20);
12460 --
12461 debug_exit(l_proc_name);
12462
12463 if l_return <> -1 then
12464
12465 g_annual_rate(p_assignment_id) := l_annual_rate;
12466 p_annual_rate := trim(to_char(l_annual_rate,'099999'));
12467 return 0;
12468
12469 else
12470
12471 p_annual_rate := '000000';
12472 return -1;
12473
12474 end if; -- end if of l_return check ...
12475
12476 EXCEPTION
12477 WHEN OTHERS THEN
12478 debug_exit(' Others in '||l_proc_name
12479 ,'Y' -- turn trace off
12480 );
12481 p_annual_rate := NULL;
12482 RAISE;
12483 end get_tp1_annual_ft_sal_rate;
12484
12485 --
12486 -- ----------------------------------------------------------------------------
12487 -- |------------------------< get_tp1_pt_sal_paid >---------------------------|
12488 -- ----------------------------------------------------------------------------
12489 function get_tp1_pt_sal_paid (p_assignment_id in number
12490 ,p_part_time_sal out nocopy varchar2
12491 )
12492 return number is
12493 --
12494 l_proc_name varchar2(60) := g_proc_name || 'get_tp1_pt_sal_paid';
12495 l_part_time_sal number;
12496 l_return number;
12497 --
12498 begin
12499 --
12500 -- hr_utility.set_location('Entering: '||l_proc_name, 10);
12501 --
12502 debug_enter(l_proc_name);
12503 debug('p_assignment_id '||p_assignment_id,10) ;
12504
12505 -- Get part time salary paid only if the employment category is part-time
12506
12507 if g_ext_asg_details(p_assignment_id).ext_emp_cat_cd = 'P' then
12508
12509 debug(l_proc_name,20);
12510
12511 -- Bugfix 3803760:FTSUPPLY
12512 -- Changed start_date to teacher_start_date
12513 l_part_time_sal := get_part_time_sal_date
12514 (p_assignment_id => p_assignment_id
12515 ,p_effective_start_date => greatest
12516 (g_pension_year_start_date
12517 ,g_ext_asg_details(p_assignment_id).teacher_start_date
12518 )
12519 ,p_effective_end_date => least
12520 (g_effective_run_date
12521 ,nvl(g_ext_asg_details(p_assignment_id).leaver_date,
12522 g_effective_run_date)
12523 )
12524 );
12525 debug ('l_part_time_sal '||to_char(l_part_time_sal),30);
12526
12527 -- Check whether part time sal exceeds annual salary rate
12528
12529 if g_annual_rate.exists(p_assignment_id) and
12530 g_annual_rate(p_assignment_id) < l_part_time_sal
12531 then
12532
12533 -- Fill in with zeros instead of space
12534 -- Bug fix 2353106
12535 debug ('g_annual_rate(p_assignment_id) '||to_char(g_annual_rate(p_assignment_id)),40);
12536
12537 debug_exit(l_proc_name);
12538
12539 IF sign(l_part_time_sal) = -1 THEN
12540 p_part_time_sal := '-'|| lpad(abs(l_part_time_sal),5,'0');
12541 ELSE
12542 p_part_time_sal := lpad(l_part_time_sal,6,'0');
12543 END IF;
12544
12545 -- p_part_time_sal := lpad(l_part_time_sal,6,'0');
12546 return -1;
12547
12548 else
12549
12550 -- Fill in with zeros instead of space
12551 -- Bug fix 2353106
12552 debug_exit(l_proc_name);
12553
12554 IF sign(l_part_time_sal) = -1 THEN -- added for bug 7313510
12555 p_part_time_sal := '-'|| lpad(abs(l_part_time_sal),5,'0');
12556 ELSE
12557 p_part_time_sal := lpad(l_part_time_sal,6,'0');
12558 END IF;
12559
12560 -- p_part_time_sal := lpad(l_part_time_sal,6,'0');
12561 return 0;
12562
12563 end if; -- end if of annual rate check ...
12564
12565 else -- emp cat cd is not part time
12566
12567 -- Fill in with zeros instead of space
12568 -- Bug fix 2353106
12569 debug(l_proc_name, 50) ;
12570 p_part_time_sal := '000000';
12571
12572 debug_exit(l_proc_name);
12573 return 0;
12574
12575 end if; -- end if of emp cat check ...
12576
12577 EXCEPTION
12578 WHEN OTHERS THEN
12579 debug_exit(' Others in '||l_proc_name
12580 ,'Y' -- turn trace off
12581 );
12582 p_part_time_sal := NULL;
12583 RAISE;
12584 END get_tp1_pt_sal_paid;
12585
12586 --
12587 -- Career Indicator
12588 --
12589 FUNCTION get_tp1_career_indicator
12590 (p_assignment_id IN NUMBER
12591 ) RETURN VARCHAR2
12592 IS
12593 l_return_value char(7);
12594 l_proc_name VARCHAR2(61):=
12595 g_proc_name||'get_tp1_career_indicator';
12596 l_assignment_id per_all_assignments_f.assignment_id%TYPE;
12597 l_report_asg VARCHAR2(1);
12598
12599 BEGIN -- get_tp1_career_indicator
12600
12601 debug_enter(l_proc_name);
12602
12603 -- Check if primary assignment is a teaching assignment
12604 l_assignment_id := chk_report_assignment
12605 (p_assignment_id => p_assignment_id
12606 ,p_report_assignment => l_report_asg
12607 );
12608
12609 l_return_value := Get_Grade_Fasttrack_Info
12610 (p_assignment_id => l_assignment_id
12611 ,p_effective_date => GREATEST(g_pension_year_start_date
12612 ,g_ext_asg_details(l_assignment_id).start_date
12613 )
12614 );
12615
12616 debug_exit(l_proc_name);
12617 RETURN l_return_value;
12618
12619 EXCEPTION
12620 WHEN OTHERS THEN
12621 debug_exit(' Others in '||l_proc_name
12622 ,'Y' -- turn trace off
12623 );
12624 RAISE;
12625 END; -- get_tp1_career_indicator
12626 --
12627 -- London Allowance
12628 --
12629 FUNCTION get_tp1_london_allowance
12630 (p_assignment_id IN NUMBER
12631 ) RETURN VARCHAR2
12632 IS
12633 l_return_value char(7);
12634 l_proc_name VARCHAR2(61):=
12635 g_proc_name||'get_tp1_london_allowance';
12636 l_assignment_id per_all_assignments_f.assignment_id%TYPE;
12637 l_report_asg VARCHAR2(1);
12638
12639 BEGIN -- get_tp1_london_allowance
12640
12641 debug_enter(l_proc_name);
12642
12643 -- Check if primary assignment is a teaching assignment
12644 l_assignment_id := chk_report_assignment
12645 (p_assignment_id => p_assignment_id
12646 ,p_report_assignment => l_report_asg
12647 );
12648 -- changed for 5743209
12649 /*
12650 l_return_value := Get_Allowance_Code
12651 (p_assignment_id => l_assignment_id
12652 ,p_effective_date => GREATEST(g_pension_year_start_date
12653 ,g_ext_asg_details(l_assignment_id).start_date
12654 )
12655 ,p_allowance_type => 'LONDON_ALLOWANCE_RULE'
12656 );
12657 */
12658 l_return_value := Get_Allowance_Code_New
12659 (p_assignment_id => l_assignment_id
12660 ,p_effective_date => GREATEST(g_pension_year_start_date
12661 ,g_ext_asg_details(l_assignment_id).start_date
12662 )
12663 ,p_allowance_type => 'LONDON_ALLOWANCE_RULE'
12664 );
12665
12666 debug_exit(l_proc_name);
12667 RETURN l_return_value;
12668
12669 EXCEPTION
12670 WHEN OTHERS THEN
12671 debug_exit(' Others in '||l_proc_name
12672 ,'Y' -- turn trace off
12673 );
12674 RAISE;
12675 END; -- get_tp1_london_allowance
12676
12677 --
12678 -- Special Priority Allowance
12679 --
12680 FUNCTION get_tp1_sp_allowance
12681 (p_assignment_id IN NUMBER
12682 ) RETURN VARCHAR2
12683 IS
12684 l_return_value char(7);
12685 l_proc_name VARCHAR2(61):=
12686 g_proc_name||'get_tp1_sp_allowance';
12687 l_assignment_id per_all_assignments_f.assignment_id%TYPE;
12688 l_report_asg VARCHAR2(1);
12689
12690 BEGIN -- get_tp1_sp_allowance
12691
12692 debug_enter(l_proc_name);
12693
12694 -- Check if primary assignment is a teaching assignment
12695 l_assignment_id := chk_report_assignment
12696 (p_assignment_id => p_assignment_id
12697 ,p_report_assignment => l_report_asg
12698 );
12699 -- changed for 5743209
12700 /*
12701 l_return_value := Get_Allowance_Code
12702 (p_assignment_id => l_assignment_id
12703 ,p_effective_date => GREATEST(g_pension_year_start_date
12704 ,g_ext_asg_details(l_assignment_id).start_date
12705 )
12706 ,p_allowance_type => 'SPECIAL_ALLOWANCE_RULE'
12707 );
12708 */
12709 l_return_value := Get_Allowance_Code_New
12710 (p_assignment_id => l_assignment_id
12711 ,p_effective_date => GREATEST(g_pension_year_start_date
12712 ,g_ext_asg_details(l_assignment_id).start_date
12713 )
12714 ,p_allowance_type => 'SPECIAL_ALLOWANCE_RULE'
12715 );
12716
12717 debug_exit(l_proc_name);
12718 RETURN l_return_value;
12719 EXCEPTION
12720 WHEN OTHERS THEN
12721 debug_exit(' Others in '||l_proc_name
12722 ,'Y' -- turn trace off
12723 );
12724 RAISE;
12725 END; -- get_tp1_sp_allowance
12726
12727 --
12728 -- Special Class Addition (Part-time indicator)
12729 --
12730 FUNCTION get_tp1_pt_contract_indicator
12731 (p_assignment_id IN NUMBER
12732 ) RETURN VARCHAR2
12733 IS
12734 l_return_value char(7);
12735 l_proc_name VARCHAR2(61):=
12736 g_proc_name||'get_tp1_pt_contract_indicator';
12737 l_assignment_id per_all_assignments_f.assignment_id%TYPE;
12738 l_report_asg VARCHAR2(1);
12739
12740 BEGIN -- get_tp1_pt_contract_indicator
12741
12742 debug_enter(l_proc_name);
12743
12744 -- Check if primary assignment is a teaching assignment
12745 l_assignment_id := chk_report_assignment
12746 (p_assignment_id => p_assignment_id
12747 ,p_report_assignment => l_report_asg
12748 );
12749
12750 l_return_value := Get_Special_ClassRule
12751 ( p_assignment_id => l_assignment_id
12752 ,p_effective_date => GREATEST(g_pension_year_start_date
12753 ,g_ext_asg_details(l_assignment_id).start_date
12754 )
12755 );
12756
12757 debug_exit(l_proc_name);
12758 RETURN l_return_value;
12759 EXCEPTION
12760 WHEN OTHERS THEN
12761 debug_exit(' Others in '||l_proc_name
12762 ,'Y' -- turn trace off
12763 );
12764 RAISE;
12765 END; -- get_tp1_pt_contract_indicator
12766
12767 --
12768 -- ----------------------------------------------------------------------------
12769 -- |------------------------< get_tp1_other_allowances >----------------------|
12770 -- ----------------------------------------------------------------------------
12771 function get_tp1_other_allowances (p_assignment_id in number)
12772 return varchar2 is
12773 --
12774 l_proc_name varchar2(61) := g_proc_name || 'get_tp1_other_allowances';
12775
12776 -- Fill in with zeros instead of space
12777 -- Bug fix 2353106
12778
12779 l_other_allowance varchar2(5) := '00000';
12780 l_error number;
12781 --
12782 begin
12783 --
12784 -- hr_utility.set_location('Entering: '||l_proc_name, 10);
12785 --
12786 debug_enter(l_proc_name);
12787
12788 if g_other_allowance.exists(p_assignment_id) then
12789
12790 -- 4336613 : SAL_VALIDAT_3A : Check whether Other_All value has exceeeded 4 digit limit
12791 -- If yes, raise warning.
12792 debug('Other Allowance : '||to_char(g_other_allowance(p_assignment_id)),15);
12793
12794 if g_other_allowance(p_assignment_id) > 99999 then
12795
12796 l_error := pqp_gb_tp_extract_functions.raise_extract_warning
12797 (p_assignment_id => p_assignment_id
12798 ,p_error_text => 'BEN_93043_EXT_TP1_OTH_VAL_EXC'
12799 ,p_error_number => 93043
12800 ,p_token1 => TO_CHAR(g_other_allowance(p_assignment_id)) -- bug : 4336613
12801 );
12802
12803 g_other_allowance(p_assignment_id) := 99999; -- 4336613 : SAL_VALIDAT_3A :
12804 -- set to 9999 if > 9999
12805
12806 end if; -- end if of other allowance max limit check ...
12807
12808 -- Fill in with zeros instead of space
12809 -- Bug fix 2353106
12810
12811 debug('Other Allowance : '||to_char(g_other_allowance(p_assignment_id)),20);
12812
12813 l_other_allowance := lpad(g_other_allowance(p_assignment_id),5,'0');
12814
12815 end if; -- end if of other allowance exists check...
12816
12817
12818 --
12819 -- hr_utility.set_location('Leaving: '||l_proc_name, 20);
12820 --
12821 debug_exit(l_proc_name);
12822
12823 return l_other_allowance;
12824 EXCEPTION
12825 WHEN OTHERS THEN
12826 debug_exit(' Others in '||l_proc_name
12827 ,'Y' -- turn trace off
12828 );
12829 RAISE;
12830 end get_tp1_other_allowances;
12831
12832 --
12833 -- Record Serial Number
12834 --
12835 FUNCTION get_tp1_record_serial_number
12836 (p_assignment_id IN NUMBER
12837 ) RETURN VARCHAR2
12838 IS
12839
12840 BEGIN
12841
12842 RETURN '1';
12843 END; -- get_tp1_record_serial_number
12844
12845 --
12846 -- store_emp_cat_changes - finds and stores events due to emp cat change
12847 --
12848 PROCEDURE store_emp_cat_changes(p_assignment_id IN NUMBER
12849 ,p_start_date IN DATE
12850 ,p_end_date IN DATE
12851 )
12852 IS
12853
12854 -- Variable Declaration
12855 l_no_of_events NUMBER(5);
12856 l_itr NUMBER(5);
12857 l_new_event_itr NUMBER(5);
12858
12859 l_event_group pay_event_groups.event_group_name%TYPE := 'PQP_GB_TP_ASG_EMP_CAT';
12860
12861 -- Rowtype Variable Declaration
12862 l_proration_dates pay_interpreter_pkg.t_proration_dates_table_type;
12863 l_proration_changes pay_interpreter_pkg.t_proration_type_table_type;
12864
12865 l_asg_details csr_asg_details_dn%ROWTYPE;
12866 l_prev_asg_details csr_asg_details_dn%ROWTYPE;
12867
12868 l_proc_name VARCHAR2(61):=
12869 g_proc_name||'store_emp_cat_changes';
12870
12871 i NUMBER;
12872
12873 BEGIN
12874
12875 debug_enter(l_proc_name);
12876
12877 -- a) Get events for Employment Category changes
12878 l_no_of_events := get_events(p_event_group => l_event_group
12879 ,p_assignment_id => p_assignment_id
12880 ,p_start_date => p_start_date
12881 ,p_end_date => p_end_date
12882 ,t_proration_dates => l_proration_dates
12883 ,t_proration_changes => l_proration_changes
12884 );
12885
12886 debug('Number of '||l_event_group||' Events: '||
12887 fnd_number.number_to_canonical(l_no_of_events), 10);
12888
12889 -- b) Loop through the events and check if any have changed.
12890 l_itr := l_proration_dates.FIRST;
12891 WHILE l_itr <= l_proration_dates.LAST
12892 LOOP -- through change proration dates
12893
12894 debug('Date :'||to_char(l_proration_dates(l_itr),'DD/MM/YYYY'), 20);
12895 debug('Change :'||l_proration_changes(l_itr), 30);
12896 IF l_itr = l_proration_dates.FIRST
12897 OR
12898 ( l_proration_dates(l_itr) <>
12899 l_proration_dates(l_proration_dates.PRIOR(l_itr))
12900 ) THEN
12901
12902 OPEN csr_asg_details_dn
12903 (p_assignment_id
12904 ,l_proration_dates(l_itr)
12905 );
12906 FETCH csr_asg_details_dn INTO l_asg_details;
12907
12908
12909 IF csr_asg_details_dn%FOUND THEN
12910
12911 debug(l_proc_name, 40);
12912 -- Bugfix 3073562:GAP1:GAP2
12913 -- Replacing the type4 func call with the type 1 function
12914 l_asg_details.ext_emp_cat_cd :=
12915 get_translate_asg_emp_cat_code
12916 (l_asg_details.asg_emp_cat_cd
12917 ,l_asg_details.start_date
12918 ,'Pension Extracts Employment Category Code'
12919 ,l_asg_details.business_group_id
12920 );
12921
12922 -- Get the previous assignment record
12923 FETCH csr_asg_details_dn INTO l_prev_asg_details;
12924 -- Bugfix 3073562:GAP1:GAP2
12925 -- Replacing the type4 func call with the type 1 function
12926 l_prev_asg_details.ext_emp_cat_cd :=
12927 get_translate_asg_emp_cat_code
12928 (l_prev_asg_details.asg_emp_cat_cd
12929 ,l_prev_asg_details.start_date
12930 ,'Pension Extracts Employment Category Code'
12931 ,l_prev_asg_details.business_group_id
12932 );
12933
12934 debug('Event worth considering', 50);
12935
12936 -- Check if the employment category change is a valid one to create a new line.
12937 IF l_asg_details.ext_emp_cat_cd <> l_prev_asg_details.ext_emp_cat_cd THEN
12938
12939 -- c) Found a change, log in global events collection
12940 l_new_event_itr := g_asg_events.COUNT+1;
12941
12942 g_asg_events(l_new_event_itr).event_date := l_proration_dates(l_itr);
12943 g_asg_events(l_new_event_itr).event_type := l_event_group;
12944 g_asg_events(l_new_event_itr).assignment_id := p_assignment_id;
12945
12946 -- Store the new emp cat value
12947 g_asg_events(l_new_event_itr).new_ext_emp_cat_cd := l_asg_details.ext_emp_cat_cd;
12948
12949 -- Bugfix 3734942
12950 -- If the assignment has become part time then
12951 -- we need to increment the g_part_time_asg_count
12952 -- when this event is processed. If asg has bcom
12953 -- full time then we decrement
12954 IF l_asg_details.ext_emp_cat_cd = 'P' THEN
12955 debug('PT asg count needs incrementing when event is processed', 55);
12956 g_asg_events(l_new_event_itr).pt_asg_count_change := 1;
12957 ELSE
12958 g_asg_events(l_new_event_itr).pt_asg_count_change := -1;
12959 END IF;
12960 -- Also store the new location id coz we need it
12961 -- in new LOS code to get the new estb number
12962 -- if change in emp cat has resulted in the
12963 -- pt asg count going below 2
12964 g_asg_events(l_new_event_itr).new_location_id := l_asg_details.location_id;
12965
12966 debug('Assignment has a had an employment category change', 60);
12967
12968 END IF; -- Check if the locaiton change is a valid one to report as leaver
12969 --
12970 END IF; -- csr_asg_details_dn%FOUND THEN
12971 --
12972 IF csr_asg_details_dn%ISOPEN THEN
12973 CLOSE csr_asg_details_dn;
12974 END IF;
12975 --
12976 END IF; -- if this date <> last date to eliminate duplicates
12977 --
12978 l_itr := l_proration_dates.NEXT(l_itr);
12979 --
12980 END LOOP; -- through change proration dates
12981
12982 debug_exit(l_proc_name);
12983
12984 RETURN;
12985
12986 EXCEPTION
12987 WHEN OTHERS THEN
12988 debug_exit(' Others in '||l_proc_name);
12989 RAISE;
12990 END; -- store_emp_cat_changes
12991
12992 --
12993 -- store_event_grp_changes - finds and stores events due to changes
12994 -- to any given entity identified through the event group name
12995 --
12996 PROCEDURE store_event_grp_changes
12997 (p_assignment_id IN NUMBER
12998 ,p_event_group IN pay_event_groups.event_group_name%TYPE
12999 ,p_start_date IN DATE
13000 ,p_end_date IN DATE
13001 )
13002 IS
13003
13004 -- Variable Declaration
13005 l_no_of_events NUMBER(5);
13006 l_itr NUMBER(5);
13007 l_new_event_itr NUMBER(5);
13008
13009 -- Rowtype Variable Declaration
13010 l_proration_dates pay_interpreter_pkg.t_proration_dates_table_type;
13011 l_proration_changes pay_interpreter_pkg.t_proration_type_table_type;
13012
13013 l_proc_name VARCHAR2(61):=
13014 g_proc_name||'store_event_grp_changes';
13015
13016 BEGIN
13017
13018 debug_enter(l_proc_name);
13019
13020 -- a) Get events for changes for given event group
13021 l_no_of_events := get_events(p_event_group => p_event_group
13022 ,p_assignment_id => p_assignment_id
13023 ,p_start_date => p_start_date
13024 ,p_end_date => p_end_date
13025 ,t_proration_dates => l_proration_dates
13026 ,t_proration_changes => l_proration_changes
13027 );
13028
13029 debug('Number of '||p_event_group||' Events: '||
13030 fnd_number.number_to_canonical(l_no_of_events), 10);
13031
13032 -- b) Loop through the events and check if any have changed.
13033 l_itr := l_proration_dates.FIRST;
13034 WHILE l_itr <= l_proration_dates.LAST
13035 LOOP -- through change proration dates
13036
13037 debug('Date :'||to_char(l_proration_dates(l_itr),'DD/MM/YYYY'), 20);
13038 debug('Change :'||l_proration_changes(l_itr), 30);
13039
13040 IF l_itr = l_proration_dates.FIRST
13041 OR
13042 ( l_proration_dates(l_itr) <>
13043 l_proration_dates(l_proration_dates.PRIOR(l_itr))
13044 ) THEN
13045
13046 -- c) Found a change, log in global events collection
13047 l_new_event_itr := g_asg_events.COUNT+1;
13048
13049 g_asg_events(l_new_event_itr).event_date := l_proration_dates(l_itr);
13050 g_asg_events(l_new_event_itr).event_type := p_event_group;
13051 g_asg_events(l_new_event_itr).assignment_id := p_assignment_id;
13052
13053 debug('Assignment attributes have had changes',110);
13054
13055 END IF; -- if this date <> last date to eliminate duplicates
13056 --
13057 l_itr := l_proration_dates.NEXT(l_itr);
13058 --
13059 END LOOP; -- through change proration dates
13060
13061 debug_exit(l_proc_name);
13062
13063 RETURN;
13064
13065 EXCEPTION
13066 WHEN OTHERS THEN
13067 debug_exit(' Others in '||l_proc_name);
13068 RAISE;
13069 END; -- store_event_grp_changes
13070
13071 --
13072 -- store_element_changes
13073 -- finds and stores events due to change to a pensionable element
13074 --
13075 -- WARNING : This procedure marks and unmarks the events in PPE for itself.
13076 -- Please donot mark events before calling this proc.
13077 --
13078 PROCEDURE store_element_changes(p_assignment_id IN NUMBER
13079 ,p_start_date IN DATE
13080 ,p_end_date IN DATE
13081 )
13082 IS
13083
13084 -- TYPE declaration
13085 TYPE t_rate_types IS TABLE of fnd_lookups.meaning%TYPE
13086 INDEX BY BINARY_INTEGER;
13087
13088 -- Variable Declaration
13089 l_no_of_events NUMBER(5);
13090 l_itr NUMBER(5);
13091 l_rates_itr NUMBER(5);
13092 l_new_event_itr NUMBER(5);
13093
13094 l_event_group pay_event_groups.event_group_name%TYPE;
13095
13096 -- Rowtype Variable Declaration
13097 l_proration_dates pay_interpreter_pkg.t_proration_dates_table_type;
13098 l_proration_changes pay_interpreter_pkg.t_proration_type_table_type;
13099
13100 l_rate_types t_rate_types;
13101 l_element_set csr_element_set%ROWTYPE;
13102 l_element_entries csr_element_entries%ROWTYPE;
13103
13104 l_proc_name VARCHAR2(61):=
13105 g_proc_name||'store_element_changes';
13106
13107 BEGIN
13108
13109 debug_enter(l_proc_name);
13110
13111 -- Populate the collection for rate types
13112 l_rate_types(l_rate_types.COUNT+1) := g_sal_rate_type;
13113 -- Bug fix 2786740
13114 -- London Rate type and Other rate type need not have
13115 -- a value always
13116 IF g_lon_rate_type IS NOT NULL THEN
13117 l_rate_types(l_rate_types.COUNT+1) := g_lon_rate_type;
13118 END IF; -- End if of g_lon_rate_type is not null check ...
13119
13120 IF g_oth_rate_type IS NOT NULL THEN
13121 l_rate_types(l_rate_types.COUNT+1) := g_oth_rate_type;
13122 END IF; -- End if of g_oth_rate_type is not null check ...
13123
13124 FOR l_rates_itr IN l_rate_types.FIRST..l_rate_types.LAST
13125 LOOP -- through the rate types
13126 --
13127 debug('Rate Type :'||l_rate_types(l_rates_itr), 10);
13128
13129 FOR l_element_set IN csr_element_set
13130 (c_name => l_rate_types(l_rates_itr)
13131 ,c_eff_date => g_ext_asg_details(p_assignment_id).start_date
13132 )
13133 LOOP -- Through the elements in this rate type
13134 --
13135 debug(l_proc_name, 20);
13136 FOR l_element_entries IN csr_element_entries(p_assignment_id => p_assignment_id
13137 ,p_effective_date
13138 => g_ext_asg_details(p_assignment_id).start_date
13139 ,p_element_type_id => l_element_set.element_type_id
13140 )
13141 LOOP -- Through element entries for this element type
13142
13143 -- Find Element Entry Changes
13144 l_event_group := 'PQP_GB_TP_ELEMENT_ENTRY';
13145 -- a) Get events for Element Entry changes
13146 -- Bug 3015917 : Removed set_pay_process.. and modified get_events which uses
13147 -- the new style DTI
13148 l_no_of_events := get_events(p_event_group => l_event_group
13149 ,p_assignment_id => p_assignment_id
13150 ,p_element_entry_id => l_element_entries.element_entry_id
13151 ,p_start_date => p_start_date
13152 ,p_end_date => p_end_date
13153 ,t_proration_dates => l_proration_dates
13154 ,t_proration_changes => l_proration_changes
13155 );
13156
13157 debug('Number of '||l_event_group||' Events for Element Entry Id'||
13158 l_element_entries.element_entry_id||' : '||
13159 fnd_number.number_to_canonical(l_no_of_events), 30);
13160
13161 -- b) Loop through the events and check if any have changed.
13162 l_itr := l_proration_dates.FIRST;
13163 WHILE l_itr <= l_proration_dates.LAST
13164 LOOP -- through change proration dates
13165
13166 debug('Date :'||to_char(l_proration_dates(l_itr),'DD/MM/YYYY'), 40);
13167 debug('Change :'||l_proration_changes(l_itr), 50);
13168
13169 IF l_itr = l_proration_dates.FIRST
13170 OR
13171 ( l_proration_dates(l_itr) <>
13172 l_proration_dates(l_proration_dates.PRIOR(l_itr))
13173 ) THEN
13174
13175 -- c) Found a change, log in global events collection
13176
13177 -- Bugfix 2882220 : Added the following if logic
13178 -- Only log this event if
13179 -- 1) Its not an End Date Event
13180 -- 2) Its an End DAte event but not on the g_pension_year_end_date
13181 IF l_proration_changes(l_itr) <> 'E' THEN
13182
13183 l_new_event_itr := g_asg_events.COUNT+1;
13184
13185 g_asg_events(l_new_event_itr).event_date := l_proration_dates(l_itr);
13186 g_asg_events(l_new_event_itr).event_type := l_event_group;
13187 g_asg_events(l_new_event_itr).assignment_id := p_assignment_id;
13188
13189 debug('Event Date :'||to_char(l_proration_dates(l_itr), 'DD/MM/YYYY'), 50);
13190 debug('Change :'||l_proration_changes(l_itr), 60);
13191 debug('Element Entry change has happened, UPDATE',70);
13192
13193 ELSIF l_proration_changes(l_itr) = 'E' -- End Dated Element Entry
13194 AND
13195 trunc(l_proration_dates(l_itr)) < trunc(g_pension_year_end_date) THEN
13196
13197 l_new_event_itr := g_asg_events.COUNT+1;
13198
13199 g_asg_events(l_new_event_itr).event_date := l_proration_dates(l_itr) + 1;
13200 g_asg_events(l_new_event_itr).event_type := l_event_group;
13201 g_asg_events(l_new_event_itr).assignment_id := p_assignment_id;
13202
13203 debug('Element Entry change has happened, END DATE', 80);
13204
13205 END IF; -- l_proration_changes(l_itr) <> 'E' THEN
13206 --
13207 END IF; -- if this date <> last date to eliminate duplicates
13208 --
13209 l_itr := l_proration_dates.NEXT(l_itr);
13210 --
13211 END LOOP; -- through change proration dates
13212 --
13213
13214 l_proration_dates.DELETE;
13215 l_proration_changes.DELETE;
13216
13217 -- Find Entry Value Changes for this element entry
13218 l_event_group := 'PQP_GB_TP_ENTRY_VALUE';
13219 -- a) Get events for Entry Value changes
13220 l_no_of_events := get_events(p_event_group => l_event_group
13221 ,p_assignment_id => p_assignment_id
13222 ,p_element_entry_id => l_element_entries.element_entry_id
13223 ,p_start_date => p_start_date
13224 ,p_end_date => p_end_date
13225 ,t_proration_dates => l_proration_dates
13226 ,t_proration_changes => l_proration_changes
13227 );
13228
13229 debug('Number of '||l_event_group||' Events : '||
13230 fnd_number.number_to_canonical(l_no_of_events), 90);
13231
13232 -- b) Loop through the events and check if any have changed.
13233 l_itr := l_proration_dates.FIRST;
13234 WHILE l_itr <= l_proration_dates.LAST
13235 LOOP -- through change proration dates
13236
13237 debug('Date :'||to_char(l_proration_dates(l_itr),'DD/MM/YYYY'), 100);
13238 debug('Change :'||l_proration_changes(l_itr), 110);
13239
13240 IF l_itr = l_proration_dates.FIRST
13241 OR
13242 ( l_proration_dates(l_itr) <>
13243 l_proration_dates(l_proration_dates.PRIOR(l_itr))
13244 ) THEN
13245
13246 -- c) Found a change, log in global events collection
13247 l_new_event_itr := g_asg_events.COUNT+1;
13248
13249 g_asg_events(l_new_event_itr).event_date := l_proration_dates(l_itr);
13250 g_asg_events(l_new_event_itr).event_type := l_event_group;
13251 g_asg_events(l_new_event_itr).assignment_id := p_assignment_id;
13252
13253 debug('Element Entry change has happened', 120);
13254
13255 END IF; -- if this date <> last date to eliminate duplicates
13256 --
13257 l_itr := l_proration_dates.NEXT(l_itr);
13258 --
13259 END LOOP; -- through change proration dates
13260 --
13261
13262 -- UnMark Pay process events for this element entry
13263 -- Bug 3015917 : Removed set_pay_process.. as we now use the new style DTI
13264
13265 END LOOP; -- Through element entries for this element type
13266 --
13267 END LOOP; -- Through the elements in this rate type
13268 --
13269 END LOOP; -- through the rate types
13270
13271 debug_exit(l_proc_name);
13272
13273 RETURN;
13274
13275 EXCEPTION
13276 WHEN OTHERS THEN
13277 debug_exit(' Others in '||l_proc_name);
13278 RAISE;
13279 END; -- store_element_changes
13280
13281 -- Added by sshetty
13282 PROCEDURE set_pay_process_events(p_grade_id IN NUMBER
13283 ,p_status IN VARCHAR2
13284 ,p_start_date IN DATE
13285 ,p_end_date IN DATE
13286 )
13287 IS
13288 PRAGMA AUTONOMOUS_TRANSACTION;
13289 l_proc_name VARCHAR2(61):= 'set_pay_process_events_to_process';
13290
13291 BEGIN
13292
13293 debug_enter(l_proc_name);
13294
13295 UPDATE pay_process_events ppe
13296 SET ppe.retroactive_status = p_status
13297 ,ppe.status = p_status
13298 WHERE ppe.assignment_id IS NULL
13299 AND ppe.change_type = 'REPORTS'
13300 AND ppe.effective_date -- allow all events effective as of and effective p_start_date
13301 BETWEEN p_start_date AND p_end_date
13302 AND ppe.surrogate_key = p_grade_id
13303 AND EXISTS (SELECT 1
13304 FROM pay_dated_tables pdt
13305 ,pay_event_updates peu
13306 WHERE pdt.table_name = 'PAY_GRADE_RULES_F'
13307 AND peu.dated_table_id = pdt.dated_table_id
13308 AND peu.change_type = ppe.change_type
13309 AND peu.event_update_id = ppe.event_update_id
13310 )
13311 ;
13312
13313 COMMIT;
13314
13315 debug_exit(l_proc_name);
13316
13317 END set_pay_process_events;
13318 /**********************************************
13319 --get_grade_sp_type
13320 *******************************************/
13321
13322 FUNCTION get_grade_sp_type (p_tab_ele_ids IN t_ele_ids_from_bal)
13323 RETURN VARCHAR2
13324 IS
13325
13326 l_index pay_element_types_f.element_type_id%TYPE;
13327 l_grd_type pay_grade_rules_f.rate_type%TYPE:='N';
13328 l_proc_name varchar2(61) := g_proc_name || 'get_grade_sp_type';
13329
13330 CURSOR csr_chk_pay_src(p_ele_id NUMBER) IS
13331 SELECT petf.element_type_id
13332 ,petf.eei_information2 pay_source_value
13333 FROM pay_element_type_extra_info petf
13334 WHERE petf.element_type_id =p_ele_id
13335 AND petf.eei_information_category ='PQP_UK_ELEMENT_ATTRIBUTION';
13336
13337 l_chk_pay_src csr_chk_pay_src%ROWTYPE;
13338 BEGIN
13339
13340 debug_enter(l_proc_name);
13341
13342 FOR i IN 1..p_tab_ele_ids.COUNT
13343 LOOP
13344
13345 debug(l_proc_name, 10);
13346 IF i=1 THEN
13347 l_index:=p_tab_ele_ids.FIRST;
13348 ELSE
13349 l_index:=p_tab_ele_ids.NEXT(l_index);
13350
13351 END IF;
13352 OPEN csr_chk_pay_src(p_tab_ele_ids(l_index).element_type_id);
13353 LOOP
13354 debug(l_proc_name, 20);
13355 FETCH csr_chk_pay_src INTO l_chk_pay_src;
13356 EXIT WHEN csr_chk_pay_src%NOTFOUND;
13357 IF l_chk_pay_src.pay_source_value='SP'
13358 OR l_chk_pay_src.pay_source_value='G' THEN
13359 debug(l_proc_name, 30);
13360 IF l_grd_type='N' THEN
13361 l_grd_type:=l_chk_pay_src.pay_source_value;
13362 ELSIF l_grd_type<>l_chk_pay_src.pay_source_value
13363 AND l_grd_type<>'N' THEN
13364 l_grd_type:='GSP';
13365 END IF;
13366 END IF;
13367 END LOOP;
13368 CLOSE csr_chk_pay_src;
13369
13370
13371 END LOOP;
13372
13373 debug('l_grd_type :'||l_grd_type, 40);
13374 debug_exit(l_proc_name);
13375
13376 RETURN(l_grd_type);
13377 EXCEPTION
13378 --------
13379 WHEN OTHERS THEN
13380 debug_exit(' Others in '||l_proc_name);
13381 RETURN ('N');
13382
13383 END get_grade_sp_type;
13384
13385 /*****************************************
13386 --store_grade_sp_changes
13387 *****************************************/
13388 -- Removed this procedure as it is no longer used.
13389
13390 --
13391 -- get_asg_events - gets all qualifying events for the given assignment
13392 --
13393 PROCEDURE get_asg_events(p_assignment_id IN NUMBER
13394 ,p_start_date IN DATE
13395 ,p_end_date IN DATE
13396 )
13397 IS
13398
13399 -- Variable Declaration
13400 l_new_event_itr NUMBER(5);
13401
13402 -- Rowtype Variable Declaration
13403
13404 l_proc_name VARCHAR2(61):=
13405 g_proc_name||'get_asg_events';
13406
13407 BEGIN
13408
13409 debug_enter(l_proc_name);
13410 debug('Start Date :'||to_char(p_start_date,'DD/MM/YYYY'), 10);
13411 debug('End Date :'||to_char(p_end_date,'DD/MM/YYYY'), 20);
13412
13413 -- Update the events in pay_process_events to 'P' for "in process".
13414 -- Marking all events between
13415 -- Start : Later or (Pension year start date +1) and pension start date of the person
13416 -- End : pension year end date.
13417 -- Might need to change this to use earlier of pension year end date
13418 -- and leaver date.
13419 -- Bug 3015917 : Removed set_pay_proc_events_to_process as we now use the
13420 -- new style DTI call
13421
13422 -- 1) Check for Employment Category change
13423 -- FS : A change from full to part-time service (and vice versa)
13424 store_emp_cat_changes(p_assignment_id => p_assignment_id
13425 ,p_start_date => p_start_date
13426 ,p_end_date => p_end_date
13427 );
13428
13429 -- 2) Check for safeguarded salary change
13430 -- FS : The comencement or cessation of a safeguarded salary
13431 store_event_grp_changes(p_assignment_id => p_assignment_id
13432 ,p_event_group => 'PQP_GB_TP_SAFEGUARDED_SALARY'
13433 ,p_start_date => p_start_date
13434 ,p_end_date => p_end_date
13435 );
13436
13437 -- 3) Check for elected pension flag change
13438 -- FS : A change in the teacher's pensionable employment position
13439 -- This should find events only if the elected pension flag change
13440 -- is not a leaver event, coz if the elected pension flag
13441 -- change is a leaver event, then it should have been picked
13442 -- up by the chk_is_teacher_leaver function when called
13443 -- from the criteria function.
13444 store_event_grp_changes(p_assignment_id => p_assignment_id
13445 ,p_event_group => 'PQP_GB_TP_ELECTED_PENSION'
13446 ,p_start_date => p_start_date
13447 ,p_end_date => p_end_date
13448 );
13449
13450 --
13451 -- 4) Check for fast track flag change
13452 -- FS : A change in the teacher's fast track flag
13453 store_event_grp_changes(p_assignment_id => p_assignment_id
13454 ,p_event_group => 'PQP_GB_TP_FAST_TRACK'
13455 ,p_start_date => p_start_date
13456 ,p_end_date => p_end_date
13457 );
13458
13459 --
13460 -- 5) Check for grade change on assignment
13461 -- FS : A change in salary scale
13462 store_event_grp_changes(p_assignment_id => p_assignment_id
13463 ,p_event_group => 'PQP_GB_TP_ASG_GRADE'
13464 ,p_start_date => p_start_date
13465 ,p_end_date => p_end_date
13466 );
13467
13468 --
13469 -- 6) Check for (grade step)/(spinal point placement) change on assignment
13470 -- FS : A change in salary scale
13471 store_event_grp_changes(p_assignment_id => p_assignment_id
13472 ,p_event_group => 'PQP_GB_TP_GRADE_STEP'
13473 ,p_start_date => p_start_date
13474 ,p_end_date => p_end_date
13475 );
13476
13477
13478 -- Reset the events in pay_process_events to 'U' for "Unprocessed".
13479 -- Bug 3015917 : Removed set_pay_proc_events_to_process as we now use the
13480 -- new style DTI call
13481
13482 -- 7) Check for Element entry and entry value changes
13483 -- FS :
13484 -- Checking this after unmarking events for this assignment as
13485 -- this proc marks(and resets) events on the basis of element_entry_id
13486 -- for pensionable rate types.
13487 -- Warning : Please DONOT mark events to 'P' in pay process events
13488 -- b4 calling this proc.
13489 store_element_changes(p_assignment_id => p_assignment_id
13490 ,p_start_date => p_start_date
13491 ,p_end_date => p_end_date
13492 );
13493
13494 -- 8) Check for changes to value of a grade rate or spinal point
13495 -- FS :
13496 -- Checking this after unmarking events for this assignment as
13497 -- this proc marks(and resets) events
13498 -- Warning : Please DONOT mark events to 'P' in pay process events
13499 -- b4 calling this proc.
13500 -- Added by sshetty
13501 -- Bug 3015917 : Replaced old call to store_grade_sp_changes
13502 -- with this new call. The grade rule validations are now
13503 -- done using func chk_grd_change_affects_asg which is called
13504 -- from event qualifier : GB Grade Rule Change
13505 store_event_grp_changes(p_assignment_id => p_assignment_id
13506 ,p_event_group => 'PQP_GB_TP_GRADE_RULES'
13507 ,p_start_date => p_start_date
13508 ,p_end_date => p_end_date
13509 );
13510
13511
13512 /*
13513 START : Commenting out nocopy code for 2340488
13514
13515 IMP : Commenting out nocopy Step 9 as part of bugfix for 2340488 as
13516 this is now being done for primary and secondary. And we are now
13517 looking for multiple leaver and restarter dates
13518
13519 -- 9) Check for leaver date of the secondary assignment and store the date + 1 as
13520 -- an event to create new line of service if the secondary assignment is a leaver.
13521 IF p_assignment_id <> g_primary_assignment_id THEN
13522 --
13523 IF g_ext_asg_details(p_assignment_id).leaver_date IS NOT NULL
13524 AND
13525 -- (Leaver date + 1 ) of secondary asg is before that of the primary asg
13526 ((g_ext_asg_details(p_assignment_id).leaver_date + 1)
13527 < -- Less Than
13528 nvl(g_ext_asg_details(g_primary_assignment_id).leaver_date
13529 ,g_effective_run_date
13530 )
13531 )
13532 THEN
13533
13534 -- Secondary asg is a leaver, store this as an event
13535 l_new_event_itr := g_asg_events.COUNT+1;
13536
13537 g_asg_events(l_new_event_itr).event_date := g_ext_asg_details(p_assignment_id).leaver_date + 1;
13538 g_asg_events(l_new_event_itr).event_type := 'SECONDARY_LEAVER';
13539 g_asg_events(l_new_event_itr).assignment_id := p_assignment_id;
13540
13541 END IF; -- g_ext_asg_details(p_assignment_id).leaver_date IS NOT NULL THEN
13542 --
13543
13544 -- Check if the secondary leaver bcame a restarter
13545 -- But only store if the restarter date is between his leaver date
13546 -- and least of (primary asg's leaver date and g_effective_run_date)
13547 -- the "least date bit" has been taken care of when finding the events
13548 -- so the date comparison sh almost always succeed.
13549 IF g_ext_asg_details(p_assignment_id).restarter_date IS NOT NULL
13550 AND
13551 (g_ext_asg_details(p_assignment_id).restarter_date
13552 < -- Less Than
13553 nvl(g_ext_asg_details(g_primary_assignment_id).leaver_date
13554 ,g_effective_run_date
13555 )
13556 ) THEN
13557
13558 -- Store an event for new line of service as the secondary event has now become a restarter
13559 l_new_event_itr := g_asg_events.COUNT+1;
13560
13561 g_asg_events(l_new_event_itr).event_date := g_ext_asg_details(p_assignment_id).restarter_date;
13562 g_asg_events(l_new_event_itr).event_type := 'SECONDARY_RESTARTER';
13563 g_asg_events(l_new_event_itr).assignment_id := p_assignment_id;
13564
13565
13566 END IF; -- g_ext_asg_details(p_assignment_id).restarter_date IS NOT NULL
13567 --
13568 END IF; -- p_assignment_id <> g_primary_assignment_id THEN
13569
13570 END : Commenting out nocopy code for 2340488
13571 */
13572
13573 debug_exit(l_proc_name);
13574
13575 RETURN;
13576
13577 EXCEPTION
13578 WHEN OTHERS THEN
13579 debug_exit(' Others in '||l_proc_name);
13580 RAISE;
13581 END; -- get_asg_events
13582
13583 --
13584 -- sort_stored_events - sorts the stored events in g_asg_events by date in ascending order
13585 --
13586 PROCEDURE sort_stored_events
13587 IS
13588
13589 l_saved_asg_event stored_events_type;
13590 l_asg_events t_asg_events_type;
13591
13592 TYPE t_skip_indexes_type IS TABLE OF BOOLEAN
13593 INDEX BY BINARY_INTEGER;
13594
13595 l_indexes_to_skip t_skip_indexes_type;
13596
13597 l_current NUMBER;
13598 l_g_current NUMBER:= 1;
13599 l_next NUMBER;
13600 l_proc_name VARCHAR2(61) := g_proc_name || 'sort_stored_events';
13601
13602 BEGIN
13603 -- bubble sort
13604
13605 debug_enter(l_proc_name);
13606
13607 l_asg_events := g_asg_events;
13608
13609 g_asg_events.DELETE;
13610
13611 l_current := l_asg_events.FIRST;
13612 WHILE l_current < l_asg_events.LAST
13613 LOOP
13614
13615 IF NOT l_indexes_to_skip.EXISTS(l_current) THEN
13616
13617 l_next := l_asg_events.NEXT(l_current);
13618
13619 WHILE l_next <= l_asg_events.LAST
13620 LOOP
13621
13622 IF NOT l_indexes_to_skip.EXISTS(l_next) THEN
13623
13624 IF TRUNC(l_asg_events(l_next).event_date) < --next less than current
13625 TRUNC(l_asg_events(l_current).event_date)
13626 THEN
13627 -- swap
13628 -- save next
13629 l_saved_asg_event := l_asg_events(l_next);
13630 -- overwrite next with current
13631 l_asg_events(l_next) := l_asg_events(l_current);
13632 -- overwrite current from the saved next
13633 l_asg_events(l_current) := l_saved_asg_event;
13634
13635 ELSIF TRUNC(l_asg_events(l_next).event_date) = --next equal current
13636 TRUNC(l_asg_events(l_current).event_date) THEN
13637 -- NON generic processing.
13638
13639 -- concatenate next event type with current
13640 l_asg_events(l_current).event_type :=
13641 l_asg_events(l_current).event_type||','||l_asg_events(l_next).event_type;
13642
13643 -- Bugfix 3641851:CBF3a : Now storing new_location_id and
13644 -- new_ext_emp_cat_cd if they r not NULL in the next event.
13645 -- This is needed coz there cud b more than one events
13646 -- on same date and we need the new_location_id and
13647 -- new_ext_emp_cat_cd in the New LOS code.
13648 IF l_asg_events(l_next).new_location_id IS NOT NULL THEN
13649 l_asg_events(l_current).new_location_id := l_asg_events(l_next).new_location_id;
13650 END IF;
13651 --
13652 IF l_asg_events(l_next).new_ext_emp_cat_cd IS NOT NULL THEN
13653 l_asg_events(l_current).new_ext_emp_cat_cd := l_asg_events(l_next).new_ext_emp_cat_cd;
13654 END IF;
13655
13656 -- Bugfix 3734942
13657 -- If the next event type is one of
13658 -- a) Emp Cat change
13659 -- b) Secondary Leaver
13660 -- c) Secondary Starter or Restarter
13661 -- e) Primary Leaver
13662 -- e) Primary Starter or Restarter
13663 -- then we need to accumulate the pt_asg_count_change
13664 -- for use at time of processing these events
13665 IF (INSTR(nvl(l_asg_events(l_next).event_type,'XX')
13666 ,'PQP_GB_TP_ASG_EMP_CAT'
13667 ) > 0
13668 OR
13669 INSTR(nvl(l_asg_events(l_next).event_type,'XX')
13670 ,'SECONDARY_LEAVER'
13671 ) > 0
13672 OR
13673 INSTR(nvl(l_asg_events(l_next).event_type,'XX')
13674 ,'SECONDARY_RESTARTER'
13675 ) > 0
13676 OR
13677 INSTR(nvl(l_asg_events(l_next).event_type,'XX')
13678 ,'SECONDARY_STARTER'
13679 ) > 0
13680 -- Bugfix 3880543:REHIRE : Primary leaver and restarter events
13681 -- sh also change the asg count
13682 OR
13683 INSTR(nvl(l_asg_events(l_next).event_type,'XX')
13684 ,'PRIMARY_LEAVER'
13685 ) > 0
13686 OR
13687 INSTR(nvl(l_asg_events(l_next).event_type,'XX')
13688 ,'PRIMARY_RESTARTER'
13689 ) > 0
13690 OR
13691 INSTR(nvl(l_asg_events(l_next).event_type,'XX')
13692 ,'PRIMARY_STARTER'
13693 ) > 0
13694 ) THEN
13695
13696 debug('Curr Value for PT Asg Cnt Change :'||
13697 to_char(nvl(l_asg_events(l_current).pt_asg_count_change, 0)), 30);
13698
13699 debug('Next Value for PT Asg Cnt Change :'||
13700 to_char(nvl(l_asg_events(l_next).pt_asg_count_change, 0)), 40);
13701
13702 -- Bugfix 3880543:REHIRE : If the event is on the same date
13703 -- and both the events hv a change in PT asg count
13704 -- then we don't want to add them up coz there cud
13705 -- be an employment category change on the restarter
13706 -- date of an assignment from FT to PT causing
13707 -- double addition to g_part_time_asg_count
13708 IF (l_asg_events(l_next).assignment_id
13709 = --next asg equal current
13710 l_asg_events(l_current).assignment_id
13711 )
13712 AND -- Next has a Pt asg count change event
13713 (nvl(l_asg_events(l_next).pt_asg_count_change, 0)
13714 > 0
13715 )
13716 AND -- Current too has a Pt asg count change event
13717 (nvl(l_asg_events(l_current).pt_asg_count_change, 0)
13718 > 0
13719 )THEN
13720
13721 -- Do not add the next pt_asg_count_change event into current
13722 debug('Skipping as 2 events on same date will cause Pt asg count to double, ', 50);
13723 NULL;
13724
13725 ELSE
13726 l_asg_events(l_current).pt_asg_count_change :=
13727 nvl(l_asg_events(l_current).pt_asg_count_change, 0)
13728 +
13729 nvl(l_asg_events(l_next).pt_asg_count_change, 0);
13730
13731 END IF;
13732
13733 END IF;
13734
13735 -- Bugfix 3803760:TERMASG
13736 l_asg_events(l_current).asg_count_change :=
13737 nvl(l_asg_events(l_current).asg_count_change, 0)
13738 +
13739 nvl(l_asg_events(l_next).asg_count_change, 0);
13740
13741
13742 -- mark this "next" index to be skipped
13743 l_indexes_to_skip(l_next) := TRUE;
13744
13745 END IF;
13746
13747 END IF; -- if next index is not marked to skip
13748
13749 l_next := l_asg_events.NEXT(l_next);
13750
13751 END LOOP;
13752
13753 g_asg_events(l_g_current) := l_asg_events(l_current);
13754 l_g_current := l_g_current + 1;
13755
13756 END IF; -- if current index is not marked to skip
13757
13758 l_current := l_asg_events.NEXT(l_current);
13759
13760 END LOOP;
13761
13762 IF NOT l_indexes_to_skip.EXISTS(l_asg_events.LAST) THEN
13763 g_asg_events(l_g_current) := l_asg_events(l_asg_events.LAST);
13764 END IF;
13765
13766 debug_exit(l_proc_name);
13767 -- debug only, uncomment the following code to debug
13768 /*
13769 l_current := l_indexes_to_skip.FIRST;
13770 WHILE l_current <= l_indexes_to_skip.LAST
13771 LOOP
13772 dbms_output.put_line('Skip Index: '||fnd_number.number_to_canonical(l_current));
13773 l_current := l_indexes_to_skip.NEXT(l_current);
13774 END LOOP;
13775 */
13776
13777 EXCEPTION
13778 WHEN OTHERS THEN
13779 debug_exit(' Others in '||l_proc_name);
13780 RAISE;
13781 END sort_stored_events;
13782
13783 -- recalc_data_elements
13784 --
13785 PROCEDURE recalc_data_elements
13786 (p_dtl_rec IN OUT NOCOPY csr_rslt_dtl%ROWTYPE
13787 ,p_rec_type IN VARCHAR2
13788 ,p_event_details IN stored_events_type
13789 ,p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
13790 )
13791 IS
13792
13793 -- Variable Declaration
13794 l_error NUMBER;
13795 l_days_excluded NUMBER;
13796 l_return NUMBER;
13797 l_annual_rate NUMBER;
13798 l_ret_allow NUMBER;
13799 l_part_time_sal NUMBER;
13800 l_temp_ext_emp_cat_cd VARCHAR(1) ;
13801 -- nocopy changes
13802 l_dtl_rec_nc csr_rslt_dtl%ROWTYPE;
13803
13804
13805 -- Fill in with zeros instead of space
13806 -- Bug fix 2353106
13807
13808 l_other_allowance VARCHAR2(5) := '00000';
13809 l_temp_date DATE;
13810 l_temp_date_primary DATE;
13811 l_temp_sfgrade pqp_assignment_attributes_f.tp_safeguarded_grade%TYPE;
13812 l_new_sfgrade pqp_assignment_attributes_f.tp_safeguarded_grade%TYPE;
13813 l_london_allowance ben_ext_rslt_dtl.val_21%TYPE;
13814 l_sp_allowance ben_ext_rslt_dtl.val_22%TYPE;
13815 l_contract_indicator ben_ext_rslt_dtl.val_23%TYPE;
13816 l_rowcount NUMBER:=0;
13817 l_pqp_asg_attributes_up csr_pqp_asg_attributes_up%ROWTYPE;
13818 l_asg_details csr_asg_details_up%ROWTYPE;
13819 l_temp_location_id per_all_assignments_f.location_id%TYPE;
13820
13821 l_assignment_id per_all_assignments_f.assignment_id%TYPE;
13822 l_report_primary_asg VARCHAR2(1);
13823
13824 -- Rowtype Variable Declaration
13825
13826 l_proc_name VARCHAR2(61):=
13827 g_proc_name||'recalc_data_elements';
13828
13829 -- a number;
13830
13831 BEGIN -- recalc_data_elements
13832
13833 debug_enter(l_proc_name);
13834
13835 -- nocopy changes
13836 l_dtl_rec_nc := p_dtl_rec;
13837
13838 debug('p_assignment_id: '|| to_char(p_assignment_id), 1) ;
13839
13840 debug('p_event_details_EVENT_TYPE: '|| (p_event_details.event_type), 1.1) ;
13841
13842 -- RETRO:BUG: 4135481
13843 -- Reset the global here to raise a warning from recalc_data_element
13844 -- This global will be set in adjust_pre_part_payments/adjust_post_part_payments
13845 -- called from calc_part_time_sal
13846 -- if there are proration and Retro event both for the same line of service
13847 -- and we are unable to find the exact payments.
13848 -- Still exploring the way to find out the exact payments in this case.
13849 -- Till then we will raise this warning.
13850
13851 -- REMOVE this once a solution is in place for this.
13852 g_raise_retro_warning := 'N' ;
13853
13854 -- Added by Sharath
13855 g_supp_teacher := 'N';
13856 -- End of Sharath changes
13857 -- PERF_ENHANC_3A : Performance Enhancements
13858 -- this table of records will be used in recalc_data_elements to store
13859 -- details corresponding of assignment IDs. Instead of calling parttime and FT
13860 -- salary function multiple times, this data collection will be used
13861 g_asg_recalc_details.DELETE;
13862
13863
13864
13865 -- Bugfix 2551059 : Developer : rtahilia
13866 -- At the time of doing this bugfix,
13867 -- we also discovered that all calls to_date use the format of DDMMYY
13868 -- in this procedure resulting in data being wrongly calculated
13869 -- for 2099 instead of 1999. Hence all to_date calls in this procedure
13870 -- have been changed to use the format of DDMMRR.
13871
13872 -- PS : The serial numbers below are calcualted as
13873 -- (actual position of the data element) + 1
13874 -- This serial number gives us the column name in the table
13875 -- ben_ext_rslt_dtl where the data element will be stored.
13876 -- E.g. Salary Scale will be stored in column val_11
13877
13878 -- Bugfix 3803760:FTSUPPLY
13879 -- Set the effective assignments as of effective start date
13880 -- of the current line of service
13881 debug('g_asg_count: '|| to_char(g_asg_count), 2) ;
13882
13883 set_effective_assignments
13884 (p_primary_assignment_id => p_assignment_id
13885 ,p_effective_date => to_date(p_dtl_rec.val_13,'DDMMRR')
13886 );
13887 debug('g_asg_count: '|| to_char(g_asg_count), 6) ;
13888
13889 -- Bugfix 3073562:GAP6
13890 -- Check if primary asg is to be reported
13891 l_report_primary_asg :=
13892 chk_report_assignment
13893 (p_assignment_id => p_assignment_id
13894 ,p_secondary_assignment_id => l_assignment_id
13895 -- Bugfix 3641851:CBF1 : Calling with effective start date of new line
13896 ,p_effective_date => to_date(p_dtl_rec.val_13,'DDMMRR')
13897 );
13898
13899
13900 debug('p_assignment_id :'||p_assignment_id, 10);
13901 debug('l_assignment_id :'||l_assignment_id, 20);
13902 debug('l_report_primary_asg :'||l_report_primary_asg, 21);
13903 debug('p_rec_type :'||p_rec_type, 22);
13904
13905 -- Bugfix 3880543:REHIRE : So that the unconditional refresh of
13906 -- some of the data elements works, we need to get the
13907 -- details from the asg row and apply it to the global
13908 -- collection row of l_assignment_id. But we only need
13909 -- to do this if g_override_ft_asg_id IS NULL coz if it
13910 -- is set (NOT NULL) then the refresh of asg dets in
13911 -- global collection sh hv alredy happened in the proc
13912 -- set_effective_assignments
13913 -- The refresh is mainly for the following
13914 -- a) Establishment number
13915 -- b) Employment category
13916 -- c) Grade - NOT DONE YET, mite hv to consider in future
13917 IF g_override_ft_asg_id IS NULL THEN
13918
13919 OPEN csr_asg_details_up
13920 (l_assignment_id
13921 ,to_date(p_dtl_rec.val_13,'DDMMRR')
13922 );
13923 FETCH csr_asg_details_up INTO l_asg_details;
13924 IF csr_asg_details_up%NOTFOUND THEN
13925 -- This situation should never happen,
13926 debug('IMP : This situation should never happen', 23);
13927 NULL;
13928 ELSE -- asg record FOUND
13929
13930 IF l_asg_details.location_id IS NOT NULL
13931 AND
13932 pqp_gb_tp_pension_extracts.g_criteria_estbs.EXISTS(l_asg_details.location_id) THEN
13933
13934 -- Setting the current ext_emp_cat_cd, location_id and estb_number
13935 debug('Re-evaluating l_assignment_id details', 24);
13936
13937 g_ext_asg_details(l_assignment_id).ext_emp_cat_cd :=
13938 get_translate_asg_emp_cat_code
13939 (l_asg_details.asg_emp_cat_cd
13940 ,to_date(p_dtl_rec.val_13,'DDMMRR')
13941 ,'Pension Extracts Employment Category Code'
13942 ,l_asg_details.business_group_id
13943 );
13944
13945 debug('l_asg_details.location_id :'||to_char(l_asg_details.location_id), 25);
13946 g_ext_asg_details(l_assignment_id).location_id := l_asg_details.location_id;
13947
13948 debug('Current estb number for l_assignment_id :'||
13949 g_ext_asg_details(l_assignment_id).estb_number, 26);
13950 debug('Estb number in Global :'||
13951 pqp_gb_tp_pension_extracts.g_criteria_estbs(l_asg_details.location_id).estb_number, 27);
13952 g_ext_asg_details(l_assignment_id).estb_number :=
13953 pqp_gb_tp_pension_extracts.g_criteria_estbs(l_asg_details.location_id).estb_number;
13954
13955 ELSE
13956 debug('WARNING: This asg might hv multiple leaver events', 27);
13957 END IF;
13958
13959 END IF; -- csr_asg_details_up%NOTFOUND THEN
13960
13961 CLOSE csr_asg_details_up;
13962
13963 END IF;
13964
13965 -- IF l_report_primary_asg is 'Y' then
13966 -- l_assignment_id will have the asg id of the primary assignment
13967 -- ELSE it will have the asg id of the secondary assignment
13968 --
13969 -- Guidelines on when to use l_assignment_id instead of p_assignment_id
13970 -- a) If the func u r calling does not chk if primary is to be reported
13971 -- or not, then you must pass l_assignment_id.
13972 -- E.g. Get_Grade_Fasttrack_Info
13973 -- b) If the func u r calling is intelligent and does the check on its own
13974 -- then you must pass p_assignment_id
13975 -- E.g. get_days_excluded_date
13976
13977 -- 10) Recalc School / Type of Employment Number
13978 -- Bugfix 3073562:GAP10 : Now recalculating establishment number
13979 -- as Establishment change within LEA is a new line of service event
13980
13981 -- Bugfix 3734942
13982 -- We need to adjust the part time asg count depending
13983 -- on the events that have occured. The count will get
13984 -- adjusted if we just add the pt_asg_count_change for
13985 -- the current event to g_part_time_asg_count coz its
13986 -- being set correctly when events are found and also
13987 -- being accumulated for multiple events on same date
13988 -- IMP Change : This logic has now moved up to create_new_lines
13989 debug('g_part_time_asg_count :'||to_char(g_part_time_asg_count), 30);
13990
13991 IF p_rec_type = 'NEW' THEN
13992
13993 IF g_override_ft_asg_id IS NOT NULL THEN
13994 -- Bugfix 3803760:FTSUPPLY
13995 -- If override asg has been set, we need to
13996 -- refresh estb number from this asg
13997 debug('Refreshing from override asg', 34);
13998 p_dtl_rec.val_10 :=
13999 nvl(pqp_gb_tp_pension_extracts.g_criteria_estbs
14000 (g_ext_asg_details(l_assignment_id).location_id
14001 ).estb_number
14002 ,p_dtl_rec.val_10
14003 );
14004
14005 ELSIF g_part_time_asg_count > 1 THEN
14006 -- Bugfix 3641851:ENH6 Adding this new clause
14007 -- coz for concurrent PT asgs we report 0953
14008 -- Bugfix 3734942 : Refresh the estb number as per
14009 -- the part time asg count
14010
14011 -- Multiple Pt asgs exist, estb number sh b 0953
14012 p_dtl_rec.val_10 := '0953';
14013
14014 ELSE
14015 -- PT asg count is NOT GREATER than 1
14016 -- We should only refresh the estb number if
14017 -- PT count has fallen due to assignments
14018 -- leaving or emp cat change or a location
14019 -- change event has happened
14020 -- IF Some non relevant event has happened
14021 -- we should not refresh the estb number
14022 IF (INSTR(nvl(p_event_details.event_type,'XX')
14023 ,'PQP_GB_TP_ASG_LOCATION'
14024 ) > 0
14025 OR
14026 INSTR(nvl(p_event_details.event_type,'XX')
14027 ,'PQP_GB_TP_ASG_EMP_CAT'
14028 ) > 0
14029 )
14030 -- Bugfix 3880543:REHIRE : Only consider this emp cat OR Loc
14031 -- change if it happened on the asg we r reporting for
14032 AND
14033 (p_event_details.assignment_id = l_assignment_id
14034 ) THEN
14035
14036 debug('new_location_id :'||to_char(p_event_details.new_location_id), 38);
14037 debug('val_10 :'||p_dtl_rec.val_10, 39);
14038
14039 -- Bugfix 3470242:BUG1 : Now using new_location_id, estb_number can
14040 -- always be sought using the location id
14041 -- p_dtl_rec.val_10 := nvl(p_event_details.new_estb_number, p_dtl_rec.val_10);
14042 p_dtl_rec.val_10 := nvl(pqp_gb_tp_pension_extracts.g_criteria_estbs
14043 (p_event_details.new_location_id).estb_number
14044 , p_dtl_rec.val_10
14045 );
14046
14047 ELSE
14048 -- Bugfix 3880543:REHIRE : Changed the above elsif to ELSE
14049 -- We now refresh unconditionally if none of the
14050 -- above conditions apply to fix the rehire problem
14051 debug('Refreshing from l_assignment_id', 40);
14052 p_dtl_rec.val_10
14053 := nvl(pqp_gb_tp_pension_extracts.g_criteria_estbs
14054 (g_ext_asg_details(l_assignment_id).location_id
14055 ).estb_number
14056 ,p_dtl_rec.val_10
14057 );
14058 END IF;
14059
14060 END IF; -- g_part_time_asg_count > 1 THEN
14061
14062 debug('val_10 :'||p_dtl_rec.val_10, 41);
14063
14064 END IF; -- p_rec_type = 'NEW' THEN
14065
14066 --11.1)
14067 debug('val_20 :'||p_dtl_rec.val_20, 49);
14068
14069 p_dtl_rec.val_20 := Get_Grade_Fasttrack_Info(p_assignment_id => l_assignment_id
14070 ,p_effective_date => to_date(p_dtl_rec.val_13,'DDMMRR'));
14071
14072 debug('val_20 :'||p_dtl_rec.val_20, 50);
14073
14074 -- 11.2) Salary Scale
14075 --Changed by sshetty, added elsif clause
14076 --This part added by sshetty fix for a bug# 2478516
14077 --to vaidate safeguarded grade change.
14078 IF p_rec_type = 'NEW'
14079 AND
14080 (
14081 INSTR(nvl(p_event_details.event_type,'XX')
14082 ,'PQP_GB_TP_SAFEGUARDED_SALARY'
14083 ) > 0
14084 OR
14085 INSTR(nvl(p_event_details.event_type,'XX')
14086 ,'PRIMARY_RESTARTER'
14087 ) > 0
14088 ) THEN
14089
14090 OPEN csr_pqp_asg_attributes_up(l_assignment_id,
14091 TO_DATE(p_dtl_rec.val_13,'DDMMRR'));
14092 FETCH csr_pqp_asg_attributes_up INTO l_pqp_asg_attributes_up;
14093
14094 IF csr_pqp_asg_attributes_up%NOTFOUND THEN
14095 debug(l_proc_name, 60);
14096 l_pqp_asg_attributes_up.tp_safeguarded_grade := NULL;
14097 END IF;
14098
14099 debug(l_proc_name, 70);
14100 CLOSE csr_pqp_asg_attributes_up;
14101
14102 IF l_pqp_asg_attributes_up.tp_safeguarded_grade IS NOT NULL THEN
14103
14104 pqp_gb_tp_pension_extracts.g_ext_asg_details(l_assignment_id).tp_safeguarded_grade
14105 := l_pqp_asg_attributes_up.tp_safeguarded_grade;
14106 g_ext_asg_details(l_assignment_id).tp_safeguarded_grade
14107 := l_pqp_asg_attributes_up.tp_safeguarded_grade;
14108
14109 debug(l_proc_name, 80);
14110 IF l_report_primary_asg = 'N' THEN
14111 -- We need to keep the global record for primary asg updated as well
14112 pqp_gb_tp_pension_extracts.g_ext_asg_details(p_assignment_id).tp_safeguarded_grade
14113 := l_pqp_asg_attributes_up.tp_safeguarded_grade;
14114 g_ext_asg_details(p_assignment_id).tp_safeguarded_grade
14115 := l_pqp_asg_attributes_up.tp_safeguarded_grade;
14116
14117 debug(l_proc_name, 90);
14118 END IF;
14119
14120 p_dtl_rec.val_11 := l_pqp_asg_attributes_up.tp_safeguarded_grade;
14121
14122 ELSE -- l_pqp_asg_attributes_up.tp_safeguarded_grade IS NOT NULL THEN
14123 --this validation is to make sure that we get the grade for that assignment
14124 --when safeguarded salary is made null.
14125
14126 debug(l_proc_name, 100);
14127
14128 l_temp_date :=
14129 pqp_gb_tp_pension_extracts.g_ext_asg_details(l_assignment_id).start_date;
14130
14131 -- Bugfix 3880543:GRD : We need to set the date in global
14132 -- collection for primary row as well, take a bakup
14133 l_temp_date_primary := g_ext_asg_details(p_assignment_id).teacher_start_date;
14134 l_temp_sfgrade :=
14135 pqp_gb_tp_pension_extracts.g_ext_asg_details(l_assignment_id).tp_safeguarded_grade;
14136
14137 pqp_gb_tp_pension_extracts.g_ext_asg_details(l_assignment_id).start_date
14138 := to_date(p_dtl_rec.val_13,'DDMMRR');
14139
14140 -- Bugfix 3880543:GRD : We need to set the date in global
14141 -- collection for primary row as well
14142 g_ext_asg_details(p_assignment_id).teacher_start_date := to_date(p_dtl_rec.val_13,'DDMMRR');
14143
14144 pqp_gb_tp_pension_extracts.g_ext_asg_details(l_assignment_id).tp_safeguarded_grade
14145 := NULL;
14146
14147 pqp_gb_tp_pension_extracts.g_nested_level := g_nested_level;
14148 l_new_sfgrade := pqp_gb_tp_pension_extracts.get_tp4_salary_scale
14149 (p_assignment_id => p_assignment_id
14150 );
14151 pqp_gb_tp_pension_extracts.g_nested_level := 0;
14152
14153 pqp_gb_tp_pension_extracts.g_ext_asg_details(l_assignment_id).start_date:=
14154 l_temp_date;
14155 pqp_gb_tp_pension_extracts.g_ext_asg_details(l_assignment_id).tp_safeguarded_grade:=
14156 l_temp_sfgrade;
14157
14158 -- Bugfix 3880543:GRD : We need to set the date in global
14159 -- collection for primary row as well, now restoring the date
14160 g_ext_asg_details(p_assignment_id).teacher_start_date:= l_temp_date_primary;
14161
14162 IF l_new_sfgrade = 'INVALID' THEN
14163
14164 l_error := pqp_gb_tp_extract_functions.raise_extract_warning
14165 (p_assignment_id => p_assignment_id
14166 ,p_error_text => 'BEN_93037_EXT_TP1_INV_SAL_SCL'
14167 ,p_error_number => 93037
14168 );
14169
14170 ELSIF l_new_sfgrade = 'UNKNOWN' THEN
14171
14172 l_error := pqp_gb_tp_extract_functions.raise_extract_warning
14173 (p_assignment_id => p_assignment_id
14174 ,p_error_text => 'BEN_93038_EXT_TP1_UNK_SAL_SCL'
14175 ,p_error_number => 93038
14176 );
14177
14178 ELSIF l_new_sfgrade = 'TOOMANY' THEN
14179
14180 l_error := pqp_gb_tp_extract_functions.raise_extract_warning
14181 (p_assignment_id => p_assignment_id
14182 ,p_error_text => 'BEN_93039_EXT_TP1_TOOMANY_VALS'
14183 ,p_error_number => 93039
14184 );
14185
14186
14187 ELSE -- valid value has been returned
14188 p_dtl_rec.val_11 := l_new_sfgrade;
14189 END IF;
14190 --
14191 END IF; -- l_pqp_asg_attributes_up.tp_safeguarded_grade IS NOT NULL THEN
14192 --
14193 END IF;
14194 --
14195 debug('val_11 :'||p_dtl_rec.val_11, 110);
14196 --
14197 IF p_rec_type = 'NEW'
14198 AND
14199 (
14200 (INSTR(nvl(p_event_details.event_type,'XX')
14201 ,'PQP_GB_TP_ASG_GRADE'
14202 ) > 0
14203 -- Bugfix 3470242:BUG1
14204 -- Before GAP4 enhancements, sal scale code cud only
14205 -- change at asg grade. But now coz sal scale code
14206 -- is derived from element entries or location EIT
14207 -- or spinal points, we must re-evaluate sal scale
14208 -- codes if any of these change for this asg.
14209 OR
14210 -- Bugfix 3470242:BUG1 : Re-evaluating for Element entry(EE) events
14211 INSTR(nvl(p_event_details.event_type,'XX')
14212 ,'PQP_GB_TP_ELEMENT_ENTRY'
14213 ) > 0
14214 OR
14215 -- Bugfix 3470242:BUG1 : Re-evaluating for Location change event
14216 INSTR(nvl(p_event_details.event_type,'XX')
14217 ,'PQP_GB_TP_ASG_LOCATION'
14218 ) > 0
14219 OR
14220 -- Bugfix 3470242:BUG1 : Re-evaluating for Spinal pt. change event
14221 INSTR(nvl(p_event_details.event_type,'XX')
14222 ,'PQP_GB_TP_GRADE_STEP'
14223 ) > 0
14224 OR
14225 -- Bugfix 3880543:REHIRE : Primary leaver also needs to be considered
14226 -- now as we hv the rehire fix
14227 INSTR(nvl(p_event_details.event_type,'XX')
14228 ,'PRIMARY_LEAVER'
14229 ) > 0
14230 OR
14231 INSTR(nvl(p_event_details.event_type,'XX')
14232 ,'PRIMARY_RESTARTER'
14233 ) > 0
14234 OR
14235 INSTR(nvl(p_event_details.event_type,'XX')
14236 ,'PRIMARY_STARTER'
14237 ) > 0
14238 OR
14239 INSTR(nvl(p_event_details.event_type,'XX')
14240 ,'SECONDARY_STARTER'
14241 ) > 0
14242 OR
14243 INSTR(nvl(p_event_details.event_type,'XX')
14244 ,'SECONDARY_LEAVER'
14245 ) > 0
14246 OR
14247 INSTR(nvl(p_event_details.event_type,'XX')
14248 ,'SECONDARY_RESTARTER'
14249 ) > 0
14250 OR
14251 INSTR(nvl(p_event_details.event_type,'XX')
14252 ,'PQP_GB_TP_ASG_EMP_CAT'
14253 ) > 0
14254 )
14255 AND
14256 (p_dtl_rec.val_20 <>'S'
14257 )
14258 ) THEN
14259
14260 debug(l_proc_name, 120);
14261 -- Get the new grade value
14262 -- We need to fool the type 4 function so manipulate the global variables temporarily
14263
14264 -- Make a copy of the original values
14265 l_temp_date := pqp_gb_tp_pension_extracts.g_ext_asg_details(l_assignment_id).start_date;
14266 -- Bugfix 3880543:GRD : We need to set the date in global
14267 -- collection for primary row as well, take a bakup
14268 l_temp_date_primary := g_ext_asg_details(p_assignment_id).teacher_start_date;
14269 l_temp_sfgrade := pqp_gb_tp_pension_extracts.g_ext_asg_details(l_assignment_id).tp_safeguarded_grade;
14270
14271 -- Assign the effective date we need and make the sfgrade NULL
14272 pqp_gb_tp_pension_extracts.g_ext_asg_details(l_assignment_id).start_date
14273 := to_date(p_dtl_rec.val_13,'DDMMRR');
14274
14275 -- Bugfix 3880543:GRD : We need to set the date in global
14276 -- collection for primary row as well
14277 g_ext_asg_details(p_assignment_id).teacher_start_date := to_date(p_dtl_rec.val_13,'DDMMRR');
14278 pqp_gb_tp_pension_extracts.g_ext_asg_details(l_assignment_id).tp_safeguarded_grade := NULL;
14279
14280 -- Bugfix 3470242:BUG1 : Location change has happened so we need to
14281 -- replace the location_id in tp4 global collection.
14282 -- Currently not replacing in tp1 collection as its not
14283 -- used anywhere in code from here on
14284 IF INSTR(nvl(p_event_details.event_type,'XX')
14285 ,'PQP_GB_TP_ASG_LOCATION'
14286 ) > 0 THEN
14287
14288 debug(l_proc_name, 130);
14289 -- l_temp_location_id := pqp_gb_tp_pension_extracts.g_ext_asg_details(p_assignment_id).location_id;
14290 pqp_gb_tp_pension_extracts.g_ext_asg_details(p_assignment_id).location_id :=
14291 p_event_details.new_location_id;
14292 IF pqp_gb_tp_pension_extracts.g_ext_asg_details(p_assignment_id).estb_number = '0966' AND
14293 p_dtl_rec.val_10 <> '0966' THEN
14294 g_supp_teacher := 'Y';
14295 END IF;
14296 pqp_gb_tp_pension_extracts.g_ext_asg_details(p_assignment_id).estb_number := p_dtl_rec.val_10;
14297
14298
14299 END IF;
14300
14301 pqp_gb_tp_pension_extracts.g_nested_level := g_nested_level;
14302 l_new_sfgrade := pqp_gb_tp_pension_extracts.get_tp4_salary_scale
14303 (p_assignment_id => p_assignment_id
14304 );
14305 pqp_gb_tp_pension_extracts.g_nested_level := 0;
14306
14307 IF l_new_sfgrade = 'INVALID' THEN
14308
14309 l_error := pqp_gb_tp_extract_functions.raise_extract_warning
14310 (p_assignment_id => p_assignment_id
14311 ,p_error_text => 'BEN_93037_EXT_TP1_INV_SAL_SCL'
14312 ,p_error_number => 93037
14313 );
14314
14315 ELSIF l_new_sfgrade = 'UNKNOWN' THEN
14316
14317 l_error := pqp_gb_tp_extract_functions.raise_extract_warning
14318 (p_assignment_id => p_assignment_id
14319 ,p_error_text => 'BEN_93038_EXT_TP1_UNK_SAL_SCL'
14320 ,p_error_number => 93038
14321 );
14322
14323 ELSIF l_new_sfgrade = 'TOOMANY' THEN
14324
14325 l_error := pqp_gb_tp_extract_functions.raise_extract_warning
14326 (p_assignment_id => p_assignment_id
14327 ,p_error_text => 'BEN_93039_EXT_TP1_TOOMANY_VALS'
14328 ,p_error_number => 93039
14329 );
14330
14331
14332 ELSE -- valid value has been returned
14333
14334 p_dtl_rec.val_11 := l_new_sfgrade;
14335
14336 END IF;
14337
14338 -- Assign back the original values to the global variables
14339 pqp_gb_tp_pension_extracts.g_ext_asg_details(l_assignment_id).start_date := l_temp_date;
14340 -- Bugfix 3880543:GRD : We need to set the date in global
14341 -- collection for primary row as well, now restoring the date
14342 g_ext_asg_details(p_assignment_id).teacher_start_date := l_temp_date_primary;
14343 pqp_gb_tp_pension_extracts.g_ext_asg_details(l_assignment_id).tp_safeguarded_grade := l_temp_sfgrade;
14344
14345 END IF; -- p_rec_type = 'NEW' for Salary Scale
14346 --
14347 debug('val_11 :'||p_dtl_rec.val_11, 140);
14348
14349 -- 12) Full or Part-time Indicator
14350 IF g_override_ft_asg_id IS NOT NULL THEN
14351 -- Bugfix 3803760:FTSUPPLY
14352 -- If override asg has been set, we need to
14353 -- refresh FT Pt indicator from this asg
14354
14355 p_dtl_rec.val_12 := g_ext_asg_details(l_assignment_id).ext_emp_cat_cd;
14356
14357 -- ELSE Assign the new value only if the emp cat has changed
14358 ELSIF p_rec_type = 'NEW'
14359 AND
14360 (INSTR(nvl(p_event_details.event_type,'XX')
14361 ,'PQP_GB_TP_ASG_EMP_CAT'
14362 ) > 0
14363 )
14364 -- Bugfix 3880543:REHIRE : Only consider this emp cat change
14365 -- if it happened on the asg we r reporting for
14366 AND
14367 (p_event_details.assignment_id = l_assignment_id
14368 ) THEN
14369
14370 debug('PQP_GB_TP_ASG_EMP_CAT event ',143);
14371
14372 p_dtl_rec.val_12 := nvl(p_event_details.new_ext_emp_cat_cd,p_dtl_rec.val_12);
14373
14374 debug('p_dtl_rec.val_12 '|| p_dtl_rec.val_12,144);
14375
14376 ELSE
14377 debug('Refresh Emp category anyway ',145);
14378 -- get ext_emp_cat_cd from asg table as of start date of the
14379 -- current new line of service being re-evaluated
14380 p_dtl_rec.val_12 := get_ext_emp_cat_cd
14381 (
14382 l_assignment_id,
14383 to_date(p_dtl_rec.val_13,'DDMMRR')
14384 );
14385
14386 debug('p_dtl_rec.val_12 '|| p_dtl_rec.val_12,146);
14387
14388 END IF;
14389 --
14390 debug('val_12 :'||p_dtl_rec.val_12, 150);
14391
14392 -- 15) Withdrawal conf
14393 -- Currently handled from procedure create_new_lines
14394
14395 -- Added a new param p_emp_cat_cd for Bug fix 2341170,2341276
14396
14397 -- Fix : 3823873
14398 -- Store the employment category in temporary variable and
14399 -- pass the changed emp cat to the get_days_excluded_date
14400 -- and reset after the call
14401
14402 debug('g_ext_asg_details(p_assignment_id).ext_emp_cat_cd '||g_ext_asg_details(p_assignment_id).ext_emp_cat_cd, 152 );
14403
14404 l_temp_ext_emp_cat_cd := g_ext_asg_details(p_assignment_id).ext_emp_cat_cd;
14405 g_ext_asg_details(p_assignment_id).ext_emp_cat_cd := p_dtl_rec.val_12;
14406
14407 -- 16) Days Excluded
14408 l_return := get_days_excluded_date
14409 (p_assignment_id => p_assignment_id
14410 ,p_effective_start_date => to_date(p_dtl_rec.val_13,'DDMMRR')
14411 ,p_effective_end_date => to_date(p_dtl_rec.val_14,'DDMMRR')
14412 ,p_emp_cat_cd => p_dtl_rec.val_12
14413 ,p_days => l_days_excluded -- OUT
14414 );
14415 --reset the employment category.
14416 g_ext_asg_details(p_assignment_id).ext_emp_cat_cd := l_temp_ext_emp_cat_cd;
14417 debug('g_ext_asg_details(p_assignment_id).ext_emp_cat_cd '||g_ext_asg_details(p_assignment_id).ext_emp_cat_cd, 154 );
14418
14419 if l_return = -2 THEN -- bug 6275363
14420 p_dtl_rec.val_16 := '+00';
14421
14422 elsif l_return <> -1 THEN
14423
14424 p_dtl_rec.val_16 := trim(to_char(l_days_excluded,'099'));
14425
14426 ELSE
14427
14428 p_dtl_rec.val_16 := '000';
14429
14430 END IF;
14431 l_return := NULL;
14432 --
14433 debug('val_16 :'||p_dtl_rec.val_16, 160);
14434 --
14435 -- 17) Annual Full-time Salary Rate
14436 l_return := get_annual_sal_rate_date
14437 (p_assignment_id => p_assignment_id
14438 ,p_effective_start_date => to_date(p_dtl_rec.val_13,'DDMMRR')
14439 ,p_effective_end_date => to_date(p_dtl_rec.val_14,'DDMMRR')
14440 ,p_rate => l_annual_rate
14441 );
14442
14443 IF l_return <> -1 THEN
14444
14445 g_annual_rate(p_assignment_id) := l_annual_rate;
14446 p_dtl_rec.val_17 := trim(to_char(l_annual_rate,'099999'));
14447
14448 ELSE
14449
14450 p_dtl_rec.val_17 := '000000';
14451
14452 END IF;
14453 l_return := NULL;
14454 --
14455 debug('val_17 :'||p_dtl_rec.val_17, 170);
14456 --
14457 -- 19) Part-Time Salary Paid
14458 IF p_dtl_rec.val_12 = 'P' THEN -- Part-time employment
14459
14460 l_part_time_sal := get_part_time_sal_date
14461 (p_assignment_id => p_assignment_id
14462 ,p_effective_start_date => to_date(p_dtl_rec.val_13,'DDMMRR')
14463 ,p_effective_end_date => to_date(p_dtl_rec.val_14,'DDMMRR')
14464 );
14465
14466 -- Check whether part time sal exceeds annual salary rate
14467 -- Fill in with zeros instead of space
14468 -- Bug fix 2353106
14469 -- Bug Fix 6140377
14470 IF sign(l_part_time_sal) = -1 THEN
14471 p_dtl_rec.val_19 := '-'|| lpad(abs(l_part_time_sal),5,'0');
14472 ELSE
14473 p_dtl_rec.val_19 := lpad(l_part_time_sal,6,'0');
14474 END IF;
14475 --
14476 ELSE -- emp cat cd is not part time
14477 -- Bug Fix 6140377
14478 p_dtl_rec.val_19 := '000000';
14479
14480 END IF; -- p_dtl_rec.val_12 = 'P' THEN
14481 --
14482 debug('val_19 :'||p_dtl_rec.val_19, 180);
14483 --
14484 -- 20) Safeguarded Salary Fast Track
14485 ---This part is now is 11.1
14486
14487 -- 21) London Allowance - Rate Payable
14488 /*
14489 l_london_allowance := Get_Allowance_Code(p_assignment_id => l_assignment_id
14490 ,p_effective_date => to_date(p_dtl_rec.val_13,'DDMMRR')
14491 ,p_allowance_type => 'LONDON_ALLOWANCE_RULE'
14492 );
14493 */
14494 l_london_allowance := Get_Allowance_Code_New(p_assignment_id => l_assignment_id
14495 ,p_effective_date => to_date(p_dtl_rec.val_13,'DDMMRR')
14496 ,p_allowance_type => 'LONDON_ALLOWANCE_RULE'
14497 );
14498
14499 debug('l_london_allowance :'||l_london_allowance, 190);
14500 IF l_london_allowance = 'UNKNOWN' THEN
14501
14502 l_london_allowance := ' ';
14503
14504 ELSIF l_london_allowance = 'TOOMANY' THEN
14505
14506 l_london_allowance := ' ';
14507 -- Bugfix 3516282 : Now passing assignment_id
14508 l_error := pqp_gb_tp_extract_functions.raise_extract_warning
14509 (p_assignment_id => p_assignment_id
14510 ,p_error_text => 'BEN_93032_EXT_TP1_LON_ALL_MANY'
14511 ,p_error_number => 93032
14512 );
14513
14514 END IF;
14515 --
14516 debug('l_london_allowance :'||l_london_allowance, 200);
14517 --
14518 p_dtl_rec.val_21 := substr(l_london_allowance,1,1);
14519
14520
14521 -- 22) Special Priority - Allowance Payable Special Needs
14522 /*
14523 l_sp_allowance := Get_Allowance_Code(p_assignment_id => l_assignment_id
14524 ,p_effective_date => to_date(p_dtl_rec.val_13,'DDMMRR')
14525 ,p_allowance_type => 'SPECIAL_ALLOWANCE_RULE'
14526 );
14527 */
14528 l_sp_allowance := Get_Allowance_Code_New(p_assignment_id => l_assignment_id
14529 ,p_effective_date => to_date(p_dtl_rec.val_13,'DDMMRR')
14530 ,p_allowance_type => 'SPECIAL_ALLOWANCE_RULE'
14531 );
14532
14533 debug('l_sp_allowance :'||l_sp_allowance, 210);
14534 IF l_sp_allowance = 'UNKNOWN' THEN
14535
14536 l_sp_allowance := '0';
14537
14538 ELSIF l_sp_allowance = 'TOOMANY' THEN
14539
14540 l_sp_allowance := '0';
14541 -- Bugfix 3516282 : Now passing assignment_id
14542 l_error := pqp_gb_tp_extract_functions.raise_extract_warning
14543 (p_assignment_id => p_assignment_id
14544 ,p_error_text => 'BEN_93034_EXT_TP1_SP_ALL_MANY'
14545 ,p_error_number => 93034
14546 );
14547
14548 END IF;
14549 --
14550 debug('l_sp_allowance :'||l_sp_allowance, 220);
14551 --
14552 p_dtl_rec.val_22 := substr(l_sp_allowance,1,1);
14553
14554
14555 -- 23) Special Class Additions (Part-time Indicator)
14556 l_contract_indicator := Get_Special_ClassRule(p_assignment_id => l_assignment_id
14557 ,p_effective_date => to_date(p_dtl_rec.val_13,'DDMMRR')
14558 );
14559
14560 debug('l_contract_indicator :'||l_contract_indicator, 230);
14561
14562 IF l_contract_indicator = 'UNKNOWN' THEN
14563
14564 l_contract_indicator := '0';
14565
14566 ELSIF l_contract_indicator = 'INVALID' THEN
14567
14568 l_contract_indicator := '0';
14569 -- Bugfix 3516282 : Now passing assignment_id
14570 l_error := pqp_gb_tp_extract_functions.raise_extract_warning
14571 (p_assignment_id => p_assignment_id
14572 ,p_error_text => 'BEN_93036_EXT_TP1_INV_EMP_CAT'
14573 ,p_error_number => 93036
14574 );
14575
14576 END IF;
14577 --
14578 debug('l_contract_indicator :'||l_contract_indicator, 240);
14579 --
14580 p_dtl_rec.val_23 := l_contract_indicator;
14581
14582
14583 -- 24) Other Allowances
14584 IF g_other_allowance.EXISTS(p_assignment_id) THEN
14585
14586 debug('Other Allowance : '||to_char(g_other_allowance(p_assignment_id)),245);
14587
14588 -- 4336613 : SAL_VALIDAT_3A : Check whether Other_All value has exceeeded 4 digit limit
14589 -- If yes, raise warning.
14590 if g_other_allowance(p_assignment_id) > 99999 then
14591
14592 l_error := pqp_gb_tp_extract_functions.raise_extract_warning
14593 (p_assignment_id => p_assignment_id
14594 ,p_error_text => 'BEN_93043_EXT_TP1_OTH_VAL_EXC'
14595 ,p_error_number => 93043
14596 ,p_token1 => TO_CHAR(g_other_allowance(p_assignment_id)) -- bug : 4336613
14597 );
14598
14599 g_other_allowance(p_assignment_id) := 99999; -- 4336613 : SAL_VALIDAT_3A :
14600 -- set to 9999 if > 9999
14601
14602 end if; -- end if of other allowance max limit check ...
14603
14604 -- Fill in with zeros instead of space
14605 -- Bug fix 2353106
14606
14607 debug('Other Allowance : '||to_char(g_other_allowance(p_assignment_id)),246);
14608
14609 l_other_allowance := lpad(g_other_allowance(p_assignment_id),5,'0');
14610
14611 END IF; -- end if of other allowance exists check
14612 --
14613 debug('l_other_allowance :'||l_other_allowance, 250);
14614 --
14615 p_dtl_rec.val_24 := l_other_allowance;
14616
14617 --
14618 -- 27) Annual Retention Allowance Rate
14619 -- Added for legislative updates to management and retention allowance changes
14620 l_return := calc_tp1_retention_allow_rate
14621 (p_assignment_id => p_assignment_id
14622 ,p_effective_start_date => to_date(p_dtl_rec.val_13,'DDMMRR')
14623 ,p_effective_end_date => to_date(p_dtl_rec.val_14,'DDMMRR')
14624 ,p_rate => l_ret_allow
14625 );
14626
14627 IF l_return <> -1 THEN
14628
14629 p_dtl_rec.val_27 := trim(to_char(l_ret_allow,'09999'));
14630
14631 ELSE
14632
14633 p_dtl_rec.val_27 := '00000';
14634
14635 END IF;
14636 l_return := NULL;
14637 --
14638 debug('val_27 :'||p_dtl_rec.val_27, 255);
14639 --
14640
14641 -- RETRO:BUG: 4135481
14642 IF g_raise_retro_warning = 'Y' THEN
14643 -- Raise a warning here if both Prorated/Retro payments exist
14644 -- for the LoS.
14645
14646 debug('Raising Warning for RETRO/PRORATION', 260);
14647 l_error := pqp_gb_tp_extract_functions.raise_extract_warning
14648 (p_assignment_id => p_assignment_id
14649 ,p_error_text => 'BEN_94159_EXT_TP_RETRO_PAY'
14650 ,p_error_number => 94159
14651 --,p_token1 => fnd_date.string_to_canonical(p_dtl_rec.val_13,'DDMMYY')
14652 );
14653 g_raise_retro_warning := 'N' ;
14654 END IF;
14655
14656 debug_exit(l_proc_name);
14657
14658 RETURN;
14659
14660 EXCEPTION
14661 WHEN OTHERS THEN
14662 debug('SQLCODE :'||to_char(SQLCODE), 260);
14663 debug('SQLERRM :'||SQLERRM, 270);
14664 debug_exit(' Others in '||l_proc_name);
14665 p_dtl_rec := l_dtl_rec_nc;
14666 RAISE;
14667 END; -- recalc_data_elements
14668
14669 PROCEDURE upd_rslt_dtl(p_dtl_rec IN ben_ext_rslt_dtl%ROWTYPE)
14670 IS
14671
14672 l_proc_name VARCHAR2(61):=
14673 g_proc_name||'upd_rslt_dtl';
14674
14675 BEGIN -- upd_rslt_dtl
14676
14677 debug_enter(l_proc_name);
14678
14679 UPDATE ben_ext_rslt_dtl
14680 SET VAL_01 = p_dtl_rec.VAL_01
14681 ,VAL_02 = p_dtl_rec.VAL_02
14682 ,VAL_03 = p_dtl_rec.VAL_03
14683 ,VAL_04 = p_dtl_rec.VAL_04
14684 ,VAL_05 = p_dtl_rec.VAL_05
14685 ,VAL_06 = p_dtl_rec.VAL_06
14686 ,VAL_07 = p_dtl_rec.VAL_07
14687 ,VAL_08 = p_dtl_rec.VAL_08
14688 ,VAL_09 = p_dtl_rec.VAL_09
14689 ,VAL_10 = p_dtl_rec.VAL_10
14690 ,VAL_11 = p_dtl_rec.VAL_11
14691 ,VAL_12 = p_dtl_rec.VAL_12
14692 ,VAL_13 = p_dtl_rec.VAL_13
14693 ,VAL_14 = p_dtl_rec.VAL_14
14694 ,VAL_15 = p_dtl_rec.VAL_15
14695 ,VAL_16 = p_dtl_rec.VAL_16
14696 ,VAL_17 = p_dtl_rec.VAL_17
14697 ,VAL_19 = p_dtl_rec.VAL_19
14698 ,VAL_18 = p_dtl_rec.VAL_18
14699 ,VAL_20 = p_dtl_rec.VAL_20
14700 ,VAL_21 = p_dtl_rec.VAL_21
14701 ,VAL_22 = p_dtl_rec.VAL_22
14702 ,VAL_23 = p_dtl_rec.VAL_23
14703 ,VAL_24 = p_dtl_rec.VAL_24
14704 ,VAL_25 = p_dtl_rec.VAL_25
14705 ,VAL_26 = p_dtl_rec.VAL_26
14706 ,VAL_27 = p_dtl_rec.VAL_27
14707 ,VAL_28 = p_dtl_rec.VAL_28
14708 ,VAL_29 = p_dtl_rec.VAL_29
14709 ,VAL_30 = p_dtl_rec.VAL_30
14710 ,VAL_31 = p_dtl_rec.VAL_31
14711 ,VAL_32 = p_dtl_rec.VAL_32
14712 ,VAL_33 = p_dtl_rec.VAL_33
14713 ,VAL_34 = p_dtl_rec.VAL_34
14714 ,VAL_35 = p_dtl_rec.VAL_35
14715 ,VAL_36 = p_dtl_rec.VAL_36
14716 ,VAL_37 = p_dtl_rec.VAL_37
14717 ,VAL_38 = p_dtl_rec.VAL_38
14718 ,VAL_39 = p_dtl_rec.VAL_39
14719 ,VAL_40 = p_dtl_rec.VAL_40
14720 ,VAL_41 = p_dtl_rec.VAL_41
14721 ,VAL_42 = p_dtl_rec.VAL_42
14722 ,VAL_43 = p_dtl_rec.VAL_43
14723 ,VAL_44 = p_dtl_rec.VAL_44
14724 ,VAL_45 = p_dtl_rec.VAL_45
14725 ,VAL_46 = p_dtl_rec.VAL_46
14726 ,VAL_47 = p_dtl_rec.VAL_47
14727 ,VAL_48 = p_dtl_rec.VAL_48
14728 ,VAL_49 = p_dtl_rec.VAL_49
14729 ,VAL_50 = p_dtl_rec.VAL_50
14730 ,VAL_51 = p_dtl_rec.VAL_51
14731 ,VAL_52 = p_dtl_rec.VAL_52
14732 ,VAL_53 = p_dtl_rec.VAL_53
14733 ,VAL_54 = p_dtl_rec.VAL_54
14734 ,VAL_55 = p_dtl_rec.VAL_55
14735 ,VAL_56 = p_dtl_rec.VAL_56
14736 ,VAL_57 = p_dtl_rec.VAL_57
14737 ,VAL_58 = p_dtl_rec.VAL_58
14738 ,VAL_59 = p_dtl_rec.VAL_59
14739 ,VAL_60 = p_dtl_rec.VAL_60
14740 ,VAL_61 = p_dtl_rec.VAL_61
14741 ,VAL_62 = p_dtl_rec.VAL_62
14742 ,VAL_63 = p_dtl_rec.VAL_63
14743 ,VAL_64 = p_dtl_rec.VAL_64
14744 ,VAL_65 = p_dtl_rec.VAL_65
14745 ,VAL_66 = p_dtl_rec.VAL_66
14746 ,VAL_67 = p_dtl_rec.VAL_67
14747 ,VAL_68 = p_dtl_rec.VAL_68
14748 ,VAL_69 = p_dtl_rec.VAL_69
14749 ,VAL_70 = p_dtl_rec.VAL_70
14750 ,VAL_71 = p_dtl_rec.VAL_71
14751 ,VAL_72 = p_dtl_rec.VAL_72
14752 ,VAL_73 = p_dtl_rec.VAL_73
14753 ,VAL_74 = p_dtl_rec.VAL_74
14754 ,VAL_75 = p_dtl_rec.VAL_75
14755 ,OBJECT_VERSION_NUMBER = p_dtl_rec.OBJECT_VERSION_NUMBER
14756 ,THRD_SORT_VAL = p_dtl_rec.THRD_SORT_VAL
14757 WHERE ext_rslt_dtl_id = p_dtl_rec.ext_rslt_dtl_id;
14758
14759 debug_exit(l_proc_name);
14760
14761 RETURN;
14762
14763 EXCEPTION
14764 WHEN OTHERS THEN
14765 debug_exit(' Others in '||l_proc_name);
14766 RAISE;
14767 END; -- upd_rslt_dtl
14768
14769 PROCEDURE ins_rslt_dtl(p_dtl_rec IN OUT NOCOPY ben_ext_rslt_dtl%ROWTYPE)
14770 IS
14771
14772
14773 -- nocopy changes
14774 l_dtl_rec_nc ben_ext_rslt_dtl%ROWTYPE;
14775
14776
14777 l_proc_name VARCHAR2(61):=
14778 g_proc_name||'ins_rslt_dtl';
14779
14780 BEGIN -- ins_rslt_dtl
14781
14782 debug_enter(l_proc_name);
14783
14784 -- nocopy changes
14785 l_dtl_rec_nc := p_dtl_rec;
14786
14787 SELECT ben_ext_rslt_dtl_s.NEXTVAL INTO p_dtl_rec.ext_rslt_dtl_id FROM dual;
14788
14789 INSERT INTO ben_ext_rslt_dtl
14790 (EXT_RSLT_DTL_ID
14791 ,EXT_RSLT_ID
14792 ,BUSINESS_GROUP_ID
14793 ,EXT_RCD_ID
14794 ,PERSON_ID
14795 ,VAL_01
14796 ,VAL_02
14797 ,VAL_03
14798 ,VAL_04
14799 ,VAL_05
14800 ,VAL_06
14801 ,VAL_07
14802 ,VAL_08
14803 ,VAL_09
14804 ,VAL_10
14805 ,VAL_11
14806 ,VAL_12
14807 ,VAL_13
14808 ,VAL_14
14809 ,VAL_15
14810 ,VAL_16
14811 ,VAL_17
14812 ,VAL_19
14813 ,VAL_18
14814 ,VAL_20
14815 ,VAL_21
14816 ,VAL_22
14817 ,VAL_23
14818 ,VAL_24
14819 ,VAL_25
14820 ,VAL_26
14821 ,VAL_27
14822 ,VAL_28
14823 ,VAL_29
14824 ,VAL_30
14825 ,VAL_31
14826 ,VAL_32
14827 ,VAL_33
14828 ,VAL_34
14829 ,VAL_35
14830 ,VAL_36
14831 ,VAL_37
14832 ,VAL_38
14833 ,VAL_39
14834 ,VAL_40
14835 ,VAL_41
14836 ,VAL_42
14837 ,VAL_43
14838 ,VAL_44
14839 ,VAL_45
14840 ,VAL_46
14841 ,VAL_47
14842 ,VAL_48
14843 ,VAL_49
14844 ,VAL_50
14845 ,VAL_51
14846 ,VAL_52
14847 ,VAL_53
14848 ,VAL_54
14849 ,VAL_55
14850 ,VAL_56
14851 ,VAL_57
14852 ,VAL_58
14853 ,VAL_59
14854 ,VAL_60
14855 ,VAL_61
14856 ,VAL_62
14857 ,VAL_63
14858 ,VAL_64
14859 ,VAL_65
14860 ,VAL_66
14861 ,VAL_67
14862 ,VAL_68
14863 ,VAL_69
14864 ,VAL_70
14865 ,VAL_71
14866 ,VAL_72
14867 ,VAL_73
14868 ,VAL_74
14869 ,VAL_75
14870 ,CREATED_BY
14871 ,CREATION_DATE
14872 ,LAST_UPDATE_DATE
14873 ,LAST_UPDATED_BY
14874 ,LAST_UPDATE_LOGIN
14875 ,PROGRAM_APPLICATION_ID
14876 ,PROGRAM_ID
14877 ,PROGRAM_UPDATE_DATE
14878 ,REQUEST_ID
14879 ,OBJECT_VERSION_NUMBER
14880 ,PRMY_SORT_VAL
14881 ,SCND_SORT_VAL
14882 ,THRD_SORT_VAL
14883 ,TRANS_SEQ_NUM
14884 ,RCRD_SEQ_NUM
14885 )
14886 VALUES
14887 (p_dtl_rec.EXT_RSLT_DTL_ID
14888 ,p_dtl_rec.EXT_RSLT_ID
14889 ,p_dtl_rec.BUSINESS_GROUP_ID
14890 ,p_dtl_rec.EXT_RCD_ID
14891 ,p_dtl_rec.PERSON_ID
14892 ,p_dtl_rec.VAL_01
14893 ,p_dtl_rec.VAL_02
14894 ,p_dtl_rec.VAL_03
14895 ,p_dtl_rec.VAL_04
14896 ,p_dtl_rec.VAL_05
14897 ,p_dtl_rec.VAL_06
14898 ,p_dtl_rec.VAL_07
14899 ,p_dtl_rec.VAL_08
14900 ,p_dtl_rec.VAL_09
14901 ,p_dtl_rec.VAL_10
14902 ,p_dtl_rec.VAL_11
14903 ,p_dtl_rec.VAL_12
14904 ,p_dtl_rec.VAL_13
14905 ,p_dtl_rec.VAL_14
14906 ,p_dtl_rec.VAL_15
14907 ,p_dtl_rec.VAL_16
14908 ,p_dtl_rec.VAL_17
14909 ,p_dtl_rec.VAL_19
14910 ,p_dtl_rec.VAL_18
14911 ,p_dtl_rec.VAL_20
14912 ,p_dtl_rec.VAL_21
14913 ,p_dtl_rec.VAL_22
14914 ,p_dtl_rec.VAL_23
14915 ,p_dtl_rec.VAL_24
14916 ,p_dtl_rec.VAL_25
14917 ,p_dtl_rec.VAL_26
14918 ,p_dtl_rec.VAL_27
14919 ,p_dtl_rec.VAL_28
14920 ,p_dtl_rec.VAL_29
14921 ,p_dtl_rec.VAL_30
14922 ,p_dtl_rec.VAL_31
14923 ,p_dtl_rec.VAL_32
14924 ,p_dtl_rec.VAL_33
14925 ,p_dtl_rec.VAL_34
14926 ,p_dtl_rec.VAL_35
14927 ,p_dtl_rec.VAL_36
14928 ,p_dtl_rec.VAL_37
14929 ,p_dtl_rec.VAL_38
14930 ,p_dtl_rec.VAL_39
14931 ,p_dtl_rec.VAL_40
14932 ,p_dtl_rec.VAL_41
14933 ,p_dtl_rec.VAL_42
14934 ,p_dtl_rec.VAL_43
14935 ,p_dtl_rec.VAL_44
14936 ,p_dtl_rec.VAL_45
14937 ,p_dtl_rec.VAL_46
14938 ,p_dtl_rec.VAL_47
14939 ,p_dtl_rec.VAL_48
14940 ,p_dtl_rec.VAL_49
14941 ,p_dtl_rec.VAL_50
14942 ,p_dtl_rec.VAL_51
14943 ,p_dtl_rec.VAL_52
14944 ,p_dtl_rec.VAL_53
14945 ,p_dtl_rec.VAL_54
14946 ,p_dtl_rec.VAL_55
14947 ,p_dtl_rec.VAL_56
14948 ,p_dtl_rec.VAL_57
14949 ,p_dtl_rec.VAL_58
14950 ,p_dtl_rec.VAL_59
14951 ,p_dtl_rec.VAL_60
14952 ,p_dtl_rec.VAL_61
14953 ,p_dtl_rec.VAL_62
14954 ,p_dtl_rec.VAL_63
14955 ,p_dtl_rec.VAL_64
14956 ,p_dtl_rec.VAL_65
14957 ,p_dtl_rec.VAL_66
14958 ,p_dtl_rec.VAL_67
14959 ,p_dtl_rec.VAL_68
14960 ,p_dtl_rec.VAL_69
14961 ,p_dtl_rec.VAL_70
14962 ,p_dtl_rec.VAL_71
14963 ,p_dtl_rec.VAL_72
14964 ,p_dtl_rec.VAL_73
14965 ,p_dtl_rec.VAL_74
14966 ,p_dtl_rec.VAL_75
14967 ,p_dtl_rec.CREATED_BY
14968 ,p_dtl_rec.CREATION_DATE
14969 ,p_dtl_rec.LAST_UPDATE_DATE
14970 ,p_dtl_rec.LAST_UPDATED_BY
14971 ,p_dtl_rec.LAST_UPDATE_LOGIN
14972 ,p_dtl_rec.PROGRAM_APPLICATION_ID
14973 ,p_dtl_rec.PROGRAM_ID
14974 ,p_dtl_rec.PROGRAM_UPDATE_DATE
14975 ,p_dtl_rec.REQUEST_ID
14976 ,p_dtl_rec.OBJECT_VERSION_NUMBER
14977 ,p_dtl_rec.PRMY_SORT_VAL
14978 ,p_dtl_rec.SCND_SORT_VAL
14979 ,p_dtl_rec.THRD_SORT_VAL
14980 ,p_dtl_rec.TRANS_SEQ_NUM
14981 ,p_dtl_rec.RCRD_SEQ_NUM
14982 );
14983
14984 debug_exit(l_proc_name);
14985
14986 RETURN;
14987
14988 EXCEPTION
14989 WHEN OTHERS THEN
14990 debug_exit(' Others in '||l_proc_name);
14991 p_dtl_rec := l_dtl_rec_nc;
14992 RAISE;
14993 END; -- ins_rslt_dtl
14994
14995 --
14996 -- Validate that the given date is in the range of the primary asg
14997 --
14998 FUNCTION date_in_prmy_range
14999 (p_date IN OUT NOCOPY DATE
15000 ,p_date_type IN VARCHAR2
15001 ) RETURN VARCHAR2
15002 IS
15003
15004 -- Variable Declaration
15005 l_itr NUMBER(5);
15006 l_valid VARCHAR2(20) := 'Y';
15007
15008
15009 l_proc_name VARCHAR2(61):=
15010 g_proc_name||'date_in_prmy_range';
15011
15012 -- nocopy changes
15013 l_date_nc DATE;
15014
15015 BEGIN -- date_in_prmy_range
15016
15017 debug_enter(l_proc_name);
15018
15019
15020 -- nocopy changes
15021 l_date_nc := p_date;
15022
15023 IF g_primary_leaver_dates.COUNT > 0 THEN
15024
15025 FOR l_itr IN g_primary_leaver_dates.FIRST..g_primary_leaver_dates.LAST
15026 LOOP
15027
15028 debug('p_date :'||to_char(p_date,'DD/MM/YYYY'), 10);
15029
15030 IF p_date BETWEEN g_primary_leaver_dates(l_itr).start_date
15031 AND nvl(g_primary_leaver_dates(l_itr).leaver_date
15032 ,g_effective_run_date
15033 ) THEN
15034
15035 debug('The date is valid', 20);
15036 l_valid := 'Y';
15037 EXIT;
15038
15039 ELSIF g_primary_leaver_dates(l_itr).restarter_date IS NOT NULL
15040 AND
15041 p_date >= g_primary_leaver_dates(l_itr).restarter_date THEN
15042
15043 debug('The date might be valid, continue checking', 30);
15044 l_valid := 'Y';
15045
15046 ELSIF (p_date BETWEEN g_primary_leaver_dates(l_itr).leaver_date
15047 AND nvl(g_primary_leaver_dates(l_itr).restarter_date
15048 ,g_effective_run_date
15049 )
15050 ) THEN
15051
15052 debug(l_proc_name, 40);
15053 -- Date is invalid in primary date range, but return the nearest
15054 -- leaver / restarter date of the primary asg as we want to find
15055 -- new line of service events for this secondary asg
15056 IF p_date_type = 'L' --Leaver
15057 THEN
15058
15059 p_date := LEAST(g_primary_leaver_dates(l_itr).leaver_date
15060 ,p_date
15061 );
15062
15063 l_valid := 'Y';
15064
15065 ELSE -- ='R' for Restarter
15066
15067 debug(l_proc_name, 50);
15068 IF g_primary_leaver_dates(l_itr).restarter_date IS NOT NULL THEN
15069
15070 p_date := GREATEST(g_primary_leaver_dates(l_itr).restarter_date
15071 ,p_date
15072 );
15073 l_valid := 'Y';
15074
15075 ELSE
15076
15077 l_valid := 'N';
15078
15079 END IF; -- g_primary_leaver_dates(l_itr).restarter_date IS NOT NULL THEN
15080 --
15081 END IF; -- p_date_type = 'L'
15082 --
15083 debug(l_proc_name, 60);
15084 -- Exit as validation done
15085 EXIT;
15086 --
15087 END IF; -- (p_date BETWEEN g_primary_leaver_dates(l_itr).leaver_date
15088 --
15089 END LOOP;
15090 --
15091 ELSE
15092 -- Primary asg does not have a leaver/restarter event
15093 l_valid := 'Y';
15094 END IF;
15095 --
15096 debug('l_valid :'||l_valid, 70);
15097 debug('p_date :'||to_char(p_date,'DD/MM/YYYY'), 80);
15098 debug_exit(l_proc_name);
15099
15100 RETURN l_valid;
15101
15102 EXCEPTION
15103 WHEN OTHERS THEN
15104 debug_exit(' Others in '||l_proc_name);
15105 p_date := l_date_nc;
15106 RAISE;
15107 END; -- date_in_prmy_range
15108
15109
15110 --
15111 -- Store multiple sets of leaver and restarter dates
15112 --
15113 PROCEDURE store_leaver_restarter_dates
15114 (p_assignment_id IN NUMBER -- context
15115 )
15116 IS
15117
15118 -- Variable Declaration
15119 l_new_event_itr NUMBER(5);
15120 l_leaver_dates_itr NUMBER(5);
15121 l_prefix VARCHAR2(20);
15122 l_leaver VARCHAR2(1) := 'N';
15123 l_leaver_date DATE := NULL;
15124 l_restarter VARCHAR2(1) := 'N';
15125 l_restarter_date DATE := NULL;
15126 l_continue VARCHAR2(1);
15127 l_business_group_id per_all_assignments_f.business_group_id%TYPE;
15128 l_restarter_ext_emp_cat_cd VARCHAR2(1);
15129 l_leaver_ext_emp_cat_cd VARCHAR2(1);
15130
15131 -- LVRDATE change:
15132 l_period_end_date DATE := NULL ;
15133
15134 l_proc_name VARCHAR2(61):=
15135 g_proc_name||'store_leaver_restarter_dates';
15136
15137 BEGIN -- store_leaver_restarter_dates
15138
15139 debug_enter(l_proc_name);
15140
15141 -- Bugfix 3073562:GAP1:GAP2
15142 l_business_group_id := nvl(g_ext_asg_details(p_assignment_id).business_group_id
15143 ,g_business_group_id
15144 );
15145
15146 IF p_assignment_id = g_primary_assignment_id THEN
15147
15148 l_prefix := 'PRIMARY_';
15149 debug('Processing Primary Assignment',20);
15150
15151 -- Step 1) Store the first set of leaver and restarter dates in the global collection
15152 IF g_ext_asg_details(p_assignment_id).leaver_date IS NOT NULL THEN
15153
15154 debug('Leaver Date Found',10);
15155
15156 l_new_event_itr := g_asg_events.COUNT+1;
15157 g_asg_events(l_new_event_itr).event_date := g_ext_asg_details(p_assignment_id).leaver_date;
15158 g_asg_events(l_new_event_itr).event_type := l_prefix||'LEAVER';
15159 g_asg_events(l_new_event_itr).assignment_id := p_assignment_id;
15160
15161 -- Bugfix 3880543:REHIRE : Now also changing the pt asg count
15162 -- If a part time asg is a leaver then
15163 -- we also need to decrement the g_part_time_asg_count
15164 -- when this event is processed
15165 IF g_ext_asg_details(p_assignment_id).ext_emp_cat_cd = 'P' THEN
15166 g_asg_events(l_new_event_itr).pt_asg_count_change := -1;
15167 END IF;
15168
15169 -- Bugfix 3803760:TERMASG
15170 g_asg_events(l_new_event_itr).asg_count_change := -1;
15171
15172 -- Add this leaver date to the global collection for primary assignments only
15173 l_leaver_dates_itr := g_primary_leaver_dates.COUNT+1;
15174 g_primary_leaver_dates(l_leaver_dates_itr).start_date := g_ext_asg_details(p_assignment_id).start_date;
15175 g_primary_leaver_dates(l_leaver_dates_itr).leaver_date := g_ext_asg_details(p_assignment_id).leaver_date;
15176 g_primary_leaver_dates(l_leaver_dates_itr).assignment_id := p_assignment_id;
15177
15178 IF g_ext_asg_details(p_assignment_id).restarter_date IS NOT NULL THEN
15179
15180 debug('Restarter date found',30);
15181
15182 l_new_event_itr := g_asg_events.COUNT+1;
15183 g_asg_events(l_new_event_itr).event_date := g_ext_asg_details(p_assignment_id).restarter_date;
15184 g_asg_events(l_new_event_itr).event_type := l_prefix||'RESTARTER';
15185 g_asg_events(l_new_event_itr).assignment_id := p_assignment_id;
15186
15187 -- Bugfix 3880543:REHIRE : Now also changing pt asg count
15188 -- If a leaver is a restarter then
15189 -- we also need to increment the g_part_time_asg_count
15190 -- when this event is processed
15191 l_restarter_ext_emp_cat_cd := NULL;
15192 l_restarter_ext_emp_cat_cd := get_ext_emp_cat_cd
15193 (p_assignment_id => p_assignment_id
15194 ,p_effective_date => g_ext_asg_details(p_assignment_id).restarter_date
15195 );
15196 IF l_restarter_ext_emp_cat_cd = 'P' THEN
15197 g_asg_events(l_new_event_itr).pt_asg_count_change := 1;
15198 END IF;
15199
15200 -- Bugfix 3803760:TERMASG
15201 g_asg_events(l_new_event_itr).asg_count_change := 1;
15202
15203 l_restarter_date := g_ext_asg_details(p_assignment_id).restarter_date;
15204
15205 -- Store this restarter date in the global collection for primary assignments
15206 g_primary_leaver_dates(l_leaver_dates_itr).restarter_date := l_restarter_date;
15207
15208 -- Step 2) Look for more leaver and restarter dates in a loop and store them
15209 -- If there is no leaver date or no restarter date
15210 -- then don't do this step.
15211 debug('B4 loop, # of events in global :'||to_char(g_asg_events.COUNT),40);
15212
15213 -- LVRDATE changes
15214 -- Changed the date passed based on Annual/Periodic Criteria
15215 debug ('g_extract_type: '|| g_extract_type) ;
15216
15217 IF g_extract_type = 'TP1' THEN
15218 l_period_end_date := g_effective_run_date;
15219 ELSIF g_extract_type = 'TP1P' THEN
15220 l_period_end_date := g_effective_run_date + 1;
15221 END IF ;
15222
15223 debug ('l_period_end_date: '|| l_period_end_date) ;
15224
15225 LOOP
15226
15227 -- Call the find leaver proc here.
15228 l_leaver := chk_is_teacher_a_leaver
15229 (p_business_group_id => l_business_group_id
15230 ,p_effective_start_date => (l_restarter_date+1)
15231 -- LVRDATE change: changed the date passed based on Annual/Periodic Criteria
15232 ,p_effective_end_date => l_period_end_date
15233 --,p_effective_end_date => g_effective_run_date
15234 ,p_assignment_id => p_assignment_id
15235 ,p_leaver_date => l_leaver_date -- OUT
15236 );
15237
15238 IF l_leaver = 'Y' THEN
15239
15240 l_new_event_itr := g_asg_events.COUNT+1;
15241 g_asg_events(l_new_event_itr).event_date := l_leaver_date;
15242 g_asg_events(l_new_event_itr).event_type := l_prefix||'LEAVER';
15243 g_asg_events(l_new_event_itr).assignment_id := p_assignment_id;
15244
15245 -- Bugfix 3880543:REHIRE : Now also changing the pt asg count
15246 -- If a part time asg is a leaver then
15247 -- we also need to decrement the g_part_time_asg_count
15248 -- when this event is processed
15249 l_leaver_ext_emp_cat_cd := NULL;
15250 l_leaver_ext_emp_cat_cd := get_ext_emp_cat_cd
15251 (p_assignment_id => p_assignment_id
15252 ,p_effective_date => l_leaver_date
15253 );
15254 IF l_leaver_ext_emp_cat_cd = 'P' THEN
15255 g_asg_events(l_new_event_itr).pt_asg_count_change := -1;
15256 END IF;
15257
15258 -- Bugfix 3803760:TERMASG
15259 g_asg_events(l_new_event_itr).asg_count_change := -1;
15260
15261 -- Add this leaver date to the global collection for primary assignments only
15262 l_leaver_dates_itr := g_primary_leaver_dates.COUNT+1;
15263 g_primary_leaver_dates(l_leaver_dates_itr).start_date :=
15264 g_primary_leaver_dates((l_leaver_dates_itr-1)).restarter_date;
15265 g_primary_leaver_dates(l_leaver_dates_itr).leaver_date := l_leaver_date;
15266 g_primary_leaver_dates(l_leaver_dates_itr).assignment_id := p_assignment_id;
15267
15268 -- Find a restarter date
15269 l_restarter := chk_is_leaver_a_restarter
15270 (p_business_group_id => l_business_group_id
15271 ,p_effective_start_date => (l_leaver_date + 1)
15272 ,p_effective_end_date => g_effective_run_date
15273 ,p_assignment_id => p_assignment_id
15274 ,p_restarter_date => l_restarter_date -- OUT
15275 );
15276
15277 IF l_restarter = 'Y' THEN
15278 l_new_event_itr := g_asg_events.COUNT+1;
15279 g_asg_events(l_new_event_itr).event_date := l_restarter_date;
15280 g_asg_events(l_new_event_itr).event_type := l_prefix||'RESTARTER';
15281 g_asg_events(l_new_event_itr).assignment_id := p_assignment_id;
15282
15283 -- Bugfix 3880543:REHIRE : Now also changing the pt asg count
15284 -- If a leaver is a restarter then
15285 -- we also need to increment the g_part_time_asg_count
15286 -- when this event is processed
15287 l_restarter_ext_emp_cat_cd := NULL;
15288 l_restarter_ext_emp_cat_cd := get_ext_emp_cat_cd
15289 (p_assignment_id => p_assignment_id
15290 ,p_effective_date => l_restarter_date
15291 );
15292 IF l_restarter_ext_emp_cat_cd = 'P' THEN
15293 g_asg_events(l_new_event_itr).pt_asg_count_change := 1;
15294 END IF;
15295
15296 -- Bugfix 3803760:TERMASG
15297 g_asg_events(l_new_event_itr).asg_count_change := 1;
15298
15299 -- Store this restarter date in the global collection for primary assignments
15300 g_primary_leaver_dates(l_leaver_dates_itr).restarter_date := l_restarter_date;
15301
15302 ELSE -- Restarter not found, exit here
15303 EXIT;
15304 END IF; -- l_restarter = 'Y' THEN
15305 --
15306 ELSE -- Leaver event not found, exit here
15307 EXIT;
15308 END IF; -- l_leaver = 'Y' THEN
15309 -- Reset leaver and restarter flags
15310 l_leaver := 'N';
15311 l_restarter := 'N';
15312 --
15313 END LOOP;
15314 debug('After loop, # of events in global :'||to_char(g_asg_events.COUNT),50);
15315 --
15316 END IF; -- g_ext_asg_details(p_assignment_id).restarter_date IS NOT NULL THEN
15317 --
15318 END IF; -- g_ext_asg_details(p_assignment_id).leaver_date IS NOT NULL THEN
15319 --
15320 ELSE -- p_assignment_id = g_primary_assignment_id THEN
15321
15322 -- This update was done in previous version priory to 06/07/2004
15323 -- IMPORTANT CHANGE : Currently we do not store leaver/restarter events
15324 -- for a secondary asg as we are not generating new lines of service for these
15325 -- events. We only need these leaver/restarter events for deciding the
15326 -- reporting windows of the secodary asg. and then finding out the other
15327 -- new line of service events in these windows
15328
15329 -- Bugfix 3734942 : IMPORTANT update as of 06/07/2004
15330 -- The above IMPORTANT CHANGE statement is not valid anymore,
15331 -- we are now storing secondary leaver and restarter dates
15332 -- as new LOS events. TPA keeps confusing us every time this
15333 -- issue is raised with them.
15334
15335 l_leaver := 'N';
15336 l_restarter := 'N';
15337 l_prefix := 'SECONDARY_';
15338 l_continue := 'Y';
15339
15340 debug('Processing Secondary Assignment',60);
15341
15342 l_leaver_date := g_ext_asg_details(p_assignment_id).leaver_date;
15343
15344 -- Store all valid leaver dates
15345 IF g_ext_asg_details(p_assignment_id).leaver_date IS NOT NULL THEN
15346 -- Bugfix 3880543:REHIRE : Remmoved restriction on secondary leaver restarter
15347 -- dates. They dont hv to be in primary range now
15348 -- AND
15349 -- date_in_prmy_range
15350 -- (p_date => l_leaver_date -- IN OUT
15351 -- ,p_date_type => 'L'
15352 -- ) = 'Y' THEN
15353
15354 debug('Leaver Date found',70);
15355 -- Secondary asg is a leaver, store this new LOS event as leaver date +1
15356 l_new_event_itr := g_asg_events.COUNT+1;
15357
15358 -- Bugfix 3880543:REHIRE : now storing leaver date itself insted of leaver
15359 -- date + 1
15360 g_asg_events(l_new_event_itr).event_date := l_leaver_date;
15361 g_asg_events(l_new_event_itr).event_type := l_prefix||'LEAVER';
15362 g_asg_events(l_new_event_itr).assignment_id := p_assignment_id;
15363
15364 -- Bugfix 3734942 : If a part time asg is a leaver then
15365 -- we also need to decrement the g_part_time_asg_count
15366 -- when this event is processed
15367 l_leaver_ext_emp_cat_cd := NULL;
15368 l_leaver_ext_emp_cat_cd := get_ext_emp_cat_cd
15369 (p_assignment_id => p_assignment_id
15370 ,p_effective_date => l_leaver_date
15371 );
15372 IF l_leaver_ext_emp_cat_cd = 'P' THEN
15373 g_asg_events(l_new_event_itr).pt_asg_count_change := -1;
15374 END IF;
15375
15376 /* IF g_ext_asg_details(p_assignment_id).ext_emp_cat_cd = 'P' THEN
15377 g_asg_events(l_new_event_itr).pt_asg_count_change := -1;
15378 END IF; */
15379
15380 -- Bugfix 3803760:TERMASG
15381 g_asg_events(l_new_event_itr).asg_count_change := -1;
15382
15383 -- Add this leaver date to the global collection for secondary assignments only
15384 l_leaver_dates_itr := g_sec_leaver_dates.COUNT+1;
15385 g_sec_leaver_dates(l_leaver_dates_itr).start_date := g_ext_asg_details(p_assignment_id).start_date;
15386 g_sec_leaver_dates(l_leaver_dates_itr).leaver_date := l_leaver_date;
15387 g_sec_leaver_dates(l_leaver_dates_itr).assignment_id := p_assignment_id;
15388
15389 l_restarter_date := g_ext_asg_details(p_assignment_id).restarter_date;
15390
15391 -- Check for restarter date
15392 IF g_ext_asg_details(p_assignment_id).restarter_date IS NOT NULL THEN
15393
15394 -- Bugfix 3880543:REHIRE : Remmoved restriction on secondary leaver restarter
15395 -- dates. They dont hv to be in primary range now
15396 -- AND
15397 -- date_in_prmy_range
15398 -- (p_date => l_restarter_date -- IN OUT
15399 -- ,p_date_type => 'R'
15400 -- ) = 'Y' THEN
15401
15402 debug('Restarter Date found',80);
15403
15404 -- Secondary asg is a restarter, store this as an event
15405 l_new_event_itr := g_asg_events.COUNT+1;
15406
15407 g_asg_events(l_new_event_itr).event_date := l_restarter_date;
15408 g_asg_events(l_new_event_itr).event_type := l_prefix||'RESTARTER';
15409 g_asg_events(l_new_event_itr).assignment_id := p_assignment_id;
15410
15411 -- Bugfix 3734942 : If a leaver is a restarter then
15412 -- we also need to increment the g_part_time_asg_count
15413 -- when this event is processed
15414 l_restarter_ext_emp_cat_cd := NULL;
15415 l_restarter_ext_emp_cat_cd := get_ext_emp_cat_cd
15416 (p_assignment_id => p_assignment_id
15417 ,p_effective_date => l_restarter_date
15418 );
15419 IF l_restarter_ext_emp_cat_cd = 'P' THEN
15420 g_asg_events(l_new_event_itr).pt_asg_count_change := 1;
15421 END IF;
15422
15423 -- Bugfix 3803760:TERMASG
15424 g_asg_events(l_new_event_itr).asg_count_change := 1;
15425
15426 -- Store this restarter date in the global collection for primary assignments
15427 g_sec_leaver_dates(l_leaver_dates_itr).restarter_date := l_restarter_date;
15428
15429 ELSE -- g_ext_asg_details(p_assignment_id).restarter_date IS NOT NULL
15430
15431 -- Find the restarter date between leaver date and end of pension year.
15432 -- If not found till end of pension year, then we don't
15433 -- want to look for any more leaver / restarter dates for this secondary asg
15434 l_restarter := chk_is_leaver_a_restarter
15435 (p_business_group_id => l_business_group_id
15436 ,p_effective_start_date => (l_leaver_date + 1)
15437 ,p_effective_end_date => g_effective_run_date
15438 ,p_assignment_id => p_assignment_id
15439 ,p_restarter_date => l_restarter_date -- OUT
15440 );
15441
15442 IF l_restarter = 'Y' THEN
15443 -- Bugfix 3880543:REHIRE : Remmoved restriction on secondary leaver restarter
15444 -- dates. They dont hv to be in primary range now
15445 -- AND
15446 -- date_in_prmy_range
15447 -- (p_date => l_restarter_date -- IN OUT
15448 -- ,p_date_type => 'R'
15449 -- ) = 'Y' THEN
15450
15451 debug('First restarter date found',90);
15452
15453 -- Secondary asg is a restarter, store this as an event
15454 l_new_event_itr := g_asg_events.COUNT+1;
15455
15456 g_asg_events(l_new_event_itr).event_date := l_restarter_date;
15457 g_asg_events(l_new_event_itr).event_type := l_prefix||'RESTARTER';
15458 g_asg_events(l_new_event_itr).assignment_id := p_assignment_id;
15459
15460 -- Bugfix 3734942 : If a leaver is a restarter then
15461 -- we also need to increment the g_part_time_asg_count
15462 -- when this event is processed
15463 l_restarter_ext_emp_cat_cd := NULL;
15464 l_restarter_ext_emp_cat_cd := get_ext_emp_cat_cd
15465 (p_assignment_id => p_assignment_id
15466 ,p_effective_date => l_restarter_date
15467 );
15468 IF l_restarter_ext_emp_cat_cd = 'P' THEN
15469 g_asg_events(l_new_event_itr).pt_asg_count_change := 1;
15470 END IF;
15471
15472 -- Bugfix 3803760:TERMASG
15473 g_asg_events(l_new_event_itr).asg_count_change := 1;
15474
15475 -- Store this restarter date in the global collection for primary assignments
15476 g_sec_leaver_dates(l_leaver_dates_itr).restarter_date := l_restarter_date;
15477
15478 ELSE
15479
15480 -- Don't look for any further leaver/restarter dates in this pension year
15481 l_continue := 'N';
15482
15483 END IF;
15484
15485
15486 END IF; -- g_ext_asg_details(p_assignment_id).restarter_date IS NOT NULL
15487 --
15488 -- Bugfix 3641851:CBF3b : Moved this END IF down to encompass
15489 -- the entire leaver and restarter chk logic for secondary
15490 -- assignment. We should only chk for further leaver and
15491 -- restarter events if the asg was identified as a
15492 -- leaver by criteria in the first place, otherwise no need.
15493 -- END IF; -- g_ext_asg_details(p_assignment_id).leaver_date IS NOT NULL THEN
15494
15495 -- Set restarter date to leaver date so we can find leaver events between this date
15496 -- and end of pension year
15497
15498 -- Bugfix 3641851:CBF3b : Commented out as setting restarter date is not
15499 -- needed any more coz it is set above and now v r only chking for
15500 -- further leaver and restarter dates only if the asg was identified
15501 -- as a leaver by the criteria in the first place, not otherwise.
15502 /* l_restarter_date := nvl(l_leaver_date
15503 ,nvl(g_ext_asg_details(g_primary_assignment_id).restarter_date
15504 ,g_pension_year_start_date
15505 )
15506 );
15507 */
15508 debug('Restarter Date :'||to_char(l_restarter_date, 'DD/MM/YYYY'), 85);
15509
15510 IF (l_restarter_date + 2) >= g_pension_year_end_date THEN
15511 l_continue := 'N';
15512 debug('Setting l_continue to N',90);
15513 END IF;
15514
15515 -- LVRDATE changes
15516 -- Changed the date passed based on Annual/Periodic Criteria
15517 debug ('g_extract_type: '|| g_extract_type) ;
15518
15519 IF g_extract_type = 'TP1' THEN
15520 l_period_end_date := g_effective_run_date;
15521 ELSIF g_extract_type = 'TP1P' THEN
15522 l_period_end_date := g_effective_run_date + 1;
15523 END IF ;
15524
15525 debug ('l_period_end_date: '|| l_period_end_date) ;
15526
15527 -- Look for mor leaver events
15528 WHILE l_continue = 'Y'
15529 LOOP
15530
15531 debug('Start of Loop',100);
15532 -- Call the find leaver proc here.
15533 l_leaver := chk_is_teacher_a_leaver
15534 (p_business_group_id => l_business_group_id
15535 ,p_effective_start_date => (l_restarter_date + 1)
15536 -- LVRDATE change: changed the date passed based on Annual/Periodic Criteria
15537 ,p_effective_end_date => l_period_end_date
15538 --,p_effective_end_date => g_effective_run_date
15539 ,p_assignment_id => p_assignment_id
15540 ,p_leaver_date => l_leaver_date -- OUT
15541 );
15542
15543 IF l_leaver = 'Y' THEN
15544 -- Bugfix 3880543:REHIRE : Remmoved restriction on secondary leaver restarter
15545 -- dates. They dont hv to be in primary range now
15546 -- AND
15547 -- date_in_prmy_range
15548 -- (p_date => l_leaver_date -- IN OUT
15549 -- ,p_date_type => 'L'
15550 -- ) = 'Y' THEN
15551
15552 -- Secondary asg is a leaver, store this new LOS event as leaver date +1
15553 l_new_event_itr := g_asg_events.COUNT+1;
15554
15555 -- Bugfix 3880543:REHIRE : now storing leaver date itself insted of leaver
15556 -- date + 1
15557 g_asg_events(l_new_event_itr).event_date := l_leaver_date;
15558 g_asg_events(l_new_event_itr).event_type := l_prefix||'LEAVER';
15559 g_asg_events(l_new_event_itr).assignment_id := p_assignment_id;
15560
15561 -- Bugfix 3734942 : If a part time asg is a leaver then
15562 -- we also need to decrement the g_part_time_asg_count
15563 -- when this event is processed
15564 l_leaver_ext_emp_cat_cd := NULL;
15565 l_leaver_ext_emp_cat_cd := get_ext_emp_cat_cd
15566 (p_assignment_id => p_assignment_id
15567 ,p_effective_date => l_leaver_date
15568 );
15569 IF l_leaver_ext_emp_cat_cd = 'P' THEN
15570 g_asg_events(l_new_event_itr).pt_asg_count_change := -1;
15571 END IF;
15572
15573 -- Bugfix 3803760:TERMASG
15574 g_asg_events(l_new_event_itr).asg_count_change := -1;
15575
15576 -- Add this leaver date to the global collection for secondary assignments only
15577 l_leaver_dates_itr := g_sec_leaver_dates.COUNT+1;
15578
15579 IF l_leaver_dates_itr = 1 THEN
15580 g_sec_leaver_dates(l_leaver_dates_itr).start_date :=
15581 g_ext_asg_details(p_assignment_id).start_date;
15582 ELSE
15583 g_sec_leaver_dates(l_leaver_dates_itr).start_date :=
15584 g_sec_leaver_dates(l_leaver_dates_itr-1).restarter_date;
15585 END IF;
15586 --
15587 g_sec_leaver_dates(l_leaver_dates_itr).leaver_date := l_leaver_date;
15588 g_sec_leaver_dates(l_leaver_dates_itr).assignment_id := p_assignment_id;
15589
15590 -- Find the restarter date. If not found till end of pension year,
15591 -- then we don't stop looking
15592 l_restarter := chk_is_leaver_a_restarter
15593 (p_business_group_id => l_business_group_id
15594 ,p_effective_start_date => (l_leaver_date + 1)
15595 ,p_effective_end_date => g_effective_run_date
15596 ,p_assignment_id => p_assignment_id
15597 ,p_restarter_date => l_restarter_date -- OUT
15598 );
15599
15600 IF l_restarter = 'Y' THEN
15601 -- Bugfix 3880543:REHIRE : Remmoved restriction on secondary leaver restarter
15602 -- dates. They dont hv to be in primary range now
15603 -- AND
15604 -- date_in_prmy_range
15605 -- (p_date => l_restarter_date -- IN OUT
15606 -- ,p_date_type => 'R'
15607 -- ) = 'Y' THEN
15608
15609 -- Secondary asg is a restarter, store this as an event
15610 l_new_event_itr := g_asg_events.COUNT+1;
15611
15612 g_asg_events(l_new_event_itr).event_date := l_restarter_date;
15613 g_asg_events(l_new_event_itr).event_type := l_prefix||'RESTARTER';
15614 g_asg_events(l_new_event_itr).assignment_id := p_assignment_id;
15615
15616 -- Bugfix 3734942 : If a leaver is a restarter then
15617 -- we also need to increment the g_part_time_asg_count
15618 -- when this event is processed
15619 l_restarter_ext_emp_cat_cd := NULL;
15620 l_restarter_ext_emp_cat_cd := get_ext_emp_cat_cd
15621 (p_assignment_id => p_assignment_id
15622 ,p_effective_date => l_restarter_date
15623 );
15624 IF l_restarter_ext_emp_cat_cd = 'P' THEN
15625 g_asg_events(l_new_event_itr).pt_asg_count_change := 1;
15626 END IF;
15627
15628 -- Bugfix 3803760:TERMASG
15629 g_asg_events(l_new_event_itr).asg_count_change := 1;
15630
15631 -- Store this restarter date in the global collection for primary assignments
15632 g_sec_leaver_dates(l_leaver_dates_itr).restarter_date := l_restarter_date;
15633
15634 ELSE
15635
15636 -- Don't look for any further leaver/restarter dates in this pension year
15637 l_continue := 'N';
15638 EXIT;
15639
15640 END IF;
15641 --
15642 ELSE -- not a leaver, exit now
15643
15644 l_continue := 'N';
15645 EXIT;
15646
15647 END IF;
15648 --
15649 END LOOP;
15650 --
15651
15652 -- Bugfix 3641851:CBF3b : Moved this END IF down to encompass
15653 -- the entire leaver and restarter chk logic for secondary
15654 -- assignment. We should only chk for further leaver and
15655 -- restarter events if the asg was identified as a
15656 -- leaver by criteria in the first place, otherwise no need.
15657 END IF; -- g_ext_asg_details(p_assignment_id).leaver_date IS NOT NULL THEN
15658 --
15659 END IF; -- p_assignment_id = g_primary_assignment_id THEN
15660
15661 debug_exit(l_proc_name);
15662
15663 RETURN;
15664
15665 EXCEPTION
15666 WHEN OTHERS THEN
15667 debug_exit(' Others in '||l_proc_name);
15668 RAISE;
15669 END; -- store_leaver_restarter_dates
15670
15671 --
15672 -- Store events for this asg in the PRIMARY asg's validity range
15673 --
15674 PROCEDURE get_events_in_prmy_range
15675 (p_assignment_id IN NUMBER -- context
15676 )
15677 IS
15678
15679 -- Variable Declaration
15680 -- Bugfix 3873376:ESTB
15681 l_counter NUMBER := 0 ;
15682
15683 l_proc_name VARCHAR2(61):=
15684 g_proc_name||'get_events_in_prmy_range';
15685
15686 BEGIN -- get_events_in_prmy_range
15687
15688 debug_enter(l_proc_name);
15689
15690 -- If there are leaver restarter events then find events during valid period
15691 IF g_primary_leaver_dates.COUNT > 0 THEN
15692
15693 debug('Inside If, event count more than zero',20);
15694
15695 FOR l_itr IN g_primary_leaver_dates.FIRST..g_primary_leaver_dates.LAST
15696 LOOP
15697
15698 l_counter := l_counter + 1 ;
15699 debug('Inside Loop, calling get_asg_events, l_counter: '||l_counter,30);
15700
15701 -- Bugfix 3873376:ESTB
15702 IF (l_counter = 1 ) THEN --for first period.
15703
15704 -- BUGFIX 2414035 : Changed p_end_date to leaver date - 1
15705 -- This is needed coz otherwise the Elected Pension flag
15706 -- change event gets picked up again, this time as new
15707 -- line of service event
15708 get_asg_events(p_assignment_id => p_assignment_id
15709 ,p_start_date => g_primary_leaver_dates(l_itr).start_date + 1
15710 ,p_end_date => g_primary_leaver_dates(l_itr).leaver_date - 1
15711 );
15712 ELSE --(l_counter = 1 ) --for other periods.
15713 -- check from the start date to leaver date -1
15714 get_asg_events(p_assignment_id => p_assignment_id
15715 ,p_start_date => g_primary_leaver_dates(l_itr).start_date - 1
15716 ,p_end_date => g_primary_leaver_dates(l_itr).leaver_date - 1
15717 );
15718 END IF ; --(l_counter = 1 )
15719
15720 IF g_primary_leaver_dates.NEXT(l_itr) IS NULL
15721 AND
15722 g_primary_leaver_dates(l_itr).restarter_date IS NOT NULL THEN
15723
15724 debug('Inside Loop and If, calling get_asg_events last time',40);
15725 -- Get the events between the restarter date and end of period
15726 get_asg_events(p_assignment_id => p_assignment_id -- primary assignment
15727 -- Bugfix 3873376:ESTB
15728 --,p_start_date => g_primary_leaver_dates(l_itr).restarter_date + 1
15729 --changed from restarter_date +1 to restarter_date
15730 ,p_start_date => g_primary_leaver_dates(l_itr).restarter_date - 1
15731 ,p_end_date => g_effective_run_date
15732 );
15733 END IF;
15734
15735 END LOOP;
15736
15737 ELSE -- No leaver restarter events found, so find new line events for the entire year
15738
15739 debug('No Leaver events, calling get_asg_events for pension year',50);
15740 get_asg_events(p_assignment_id => p_assignment_id
15741 ,p_start_date => GREATEST(g_pension_year_start_date
15742 ,g_ext_asg_details(p_assignment_id).start_date
15743 ) + 1 -- find events starting from next day
15744 ,p_end_date => g_effective_run_date
15745 );
15746
15747 END IF; -- g_primary_leaver_dates.COUNT > 0 THEN
15748
15749 debug_exit(l_proc_name);
15750
15751 RETURN;
15752
15753 EXCEPTION
15754 WHEN OTHERS THEN
15755 debug_exit(' Others in '||l_proc_name);
15756 RAISE;
15757 END; -- get_events_in_prmy_range
15758
15759 --
15760 -- Store events for this asg in the SECONDARY asg's validity range
15761 --
15762 PROCEDURE get_events_in_sec_range
15763 (p_assignment_id IN NUMBER -- context
15764 )
15765 IS
15766
15767 -- Variable Declaration
15768 -- Bugfix 3873376:ESTB
15769 l_counter NUMBER := 0 ;
15770
15771 l_proc_name VARCHAR2(61):=
15772 g_proc_name||'get_events_in_sec_range';
15773
15774 BEGIN -- get_events_in_sec_range
15775
15776 debug_enter(l_proc_name);
15777
15778 -- If there are leaver restarter events then find events during valid period
15779 IF g_sec_leaver_dates.COUNT > 0 THEN
15780
15781 FOR l_itr IN g_sec_leaver_dates.FIRST..g_sec_leaver_dates.LAST
15782 LOOP
15783
15784 l_counter := l_counter + 1;
15785 debug('Start of Loop, calling get_asg_events, l_counter: '||l_counter,20);
15786
15787
15788 -- Step 1c) Get valid events for each secondary assignment
15789
15790 -- Bugfix 3873376:ESTB
15791 IF (l_counter = 1) THEN --for the first period
15792
15793 -- BUGFIX 2414035 : Changed p_end_date to leaver date - 1
15794 -- This is needed coz otherwise the Elected Pension flag
15795 -- change event gets picked up again, this time as new
15796 -- line of service event
15797 get_asg_events(p_assignment_id => p_assignment_id
15798 ,p_start_date => g_sec_leaver_dates(l_itr).start_date + 1
15799 ,p_end_date => g_sec_leaver_dates(l_itr).leaver_date - 1
15800 );
15801 ELSE --(l_counter = 1) --for the next periods
15802 get_asg_events(p_assignment_id => p_assignment_id
15803 ,p_start_date => g_sec_leaver_dates(l_itr).start_date - 1
15804 ,p_end_date => g_sec_leaver_dates(l_itr).leaver_date - 1
15805 );
15806 END IF ; --(l_counter = 1)
15807
15808 IF g_sec_leaver_dates.NEXT(l_itr) IS NULL
15809 AND
15810 g_sec_leaver_dates(l_itr).restarter_date IS NOT NULL THEN
15811
15812 debug('Inside LOOP and IF, calling get_asg_events for last time',30);
15813 -- Get the events between the restarter date and end of period
15814 get_asg_events(p_assignment_id => p_assignment_id
15815 -- Bugfix 3873376:ESTB
15816 --changed from restarter_date +1 to restarter_date
15817 --,p_start_date => g_sec_leaver_dates(l_itr).restarter_date + 1
15818 ,p_start_date => g_sec_leaver_dates(l_itr).restarter_date - 1
15819 ,p_end_date => g_effective_run_date
15820 );
15821
15822 END IF;
15823 --
15824 END LOOP;
15825
15826 ELSE -- No leaver restarter events found
15827
15828 debug('No Leaver Restarter events found, getting events in secondary range',40);
15829 -- IMP: Find leaver restarter events for the SECONDARY asg
15830 -- between the PRIMARY asg's validity period as the secondary
15831 -- asg does not have any leaver/restarter dates.
15832 -- PS : we do this coz we only report events of the secondary
15833 -- asg in the validity period of the primary asg.
15834
15835 -- Bugfix 3641851:CBF3b : Commented out call to get_events_in_prmy_range
15836 -- This results in sec asg events even when sec asg has not bcome
15837 -- a teacher. Only get events for sec asgs validity range.
15838 -- And since there are no leaver and restarter events, the
15839 -- sec asg is valid from its start date to end of period.
15840 --get_events_in_prmy_range(p_assignment_id => p_assignment_id
15841 -- );
15842
15843 get_asg_events(p_assignment_id => p_assignment_id
15844 ,p_start_date => GREATEST(g_pension_year_start_date
15845 ,g_ext_asg_details(p_assignment_id).start_date
15846 ) + 1 -- find events starting from next day
15847 ,p_end_date => g_effective_run_date
15848 );
15849
15850
15851 END IF; -- g_sec_leaver_dates.COUNT > 0 THEN
15852
15853 debug_exit(l_proc_name);
15854
15855 RETURN;
15856
15857 EXCEPTION
15858 WHEN OTHERS THEN
15859 debug_exit(' Others in '||l_proc_name);
15860 RAISE;
15861 END; -- get_events_in_sec_range
15862
15863 --
15864 -- create_new_lines
15865 --
15866 PROCEDURE create_new_lines
15867 (p_assignment_id IN per_all_assignments_f.assignment_id%TYPE
15868 )
15869 IS
15870
15871 -- Variable Declaration
15872 l_rec_serial_num NUMBER(3);
15873 l_itr NUMBER(3);
15874 l_next_itr NUMBER(3);
15875 l_skip_itr NUMBER(3) := NULL;
15876 l_next_of_next_itr NUMBER(3);
15877 l_prev_asg_count NUMBER(3);
15878 l_check_new_los VARCHAR2(1) := '1';
15879
15880
15881 -- Rowtype Variable Declaration
15882 l_main_rec csr_rslt_dtl%ROWTYPE;
15883 l_new_rec csr_rslt_dtl%ROWTYPE;
15884 l_prev_new_rec csr_rslt_dtl%ROWTYPE;
15885 l_event_details stored_events_type;
15886
15887
15888 l_proc_name VARCHAR2(61):=
15889 g_proc_name||'create_new_lines';
15890
15891 BEGIN -- create_new_lines
15892
15893 debug_enter(l_proc_name);
15894
15895 debug('ben_ext_thread.g_ext_rslt_id :'||to_char(ben_ext_thread.g_ext_rslt_id),10);
15896 debug('g_ext_dtl_rcd_id :'||to_char(g_ext_dtl_rcd_id),20);
15897 debug('person id :'||to_char(g_ext_asg_details(p_assignment_id).person_id),30);
15898 debug('assignment id :'||to_char(p_assignment_id),40);
15899
15900 -- Get the main detail record
15901 OPEN csr_rslt_dtl
15902 (p_person_id => g_ext_asg_details(p_assignment_id).person_id
15903 ,p_ext_rslt_id => ben_ext_thread.g_ext_rslt_id
15904 );
15905 FETCH csr_rslt_dtl INTO l_main_rec;
15906 IF csr_rslt_dtl%NOTFOUND THEN
15907 debug('No Data Found in csr_rslt_dtl', 50);
15908 END IF;
15909 CLOSE csr_rslt_dtl;
15910
15911 debug('Original Start Date :'||l_main_rec.val_13,51);
15912 debug('Original End Date :'||l_main_rec.val_14,52);
15913
15914 --The following bugfix(sort order only) has been undone. The reason being:
15915 --DE PQP GB TP Type 1 Record Serial Number - Detail Teachers Annual Returns ( England and Wales ) has a
15916 --maximum length of 1 character. So the changes done in 115.99 are being reverted here.
15917
15918 -- **************************
15919 -- Set the sort order. Seq 26 for record serial number.
15920 -- bug fix : 4926143
15921 -- this is being done as this column in the table is of varchar2 type, due to which
15922 -- sorting using order_by was incorrect when values are like 1,2,3,4....,9,10,11,12.
15923 -- For example, 1,2..,9,10,11,12 gets sorted as 1,10,11,12,2,3...,9.
15924 -- To fix this issue, the value in the thrd_sort_val is being stored as 3 digit numbers,
15925 -- starting from 001, 002 and so on.
15926
15927 -- l_main_rec.thrd_sort_val := ltrim(rtrim(to_char(to_number(l_main_rec.val_26),'009')));
15928 -- **************************
15929
15930 -- reintroduced from version 115.98
15931 l_main_rec.thrd_sort_val := l_main_rec.val_26;
15932
15933
15934 -- Also, increment the object version number
15935 l_main_rec.object_version_number := nvl(l_main_rec.object_version_number,0) + 1;
15936
15937 -- Assign the main record to the previous record variable
15938 -- We do this so even if there are not new line events,
15939 -- i.e. g_asg_events.COUNT = 0, if there is a restarter date,
15940 -- then we need a new line for this. Doing this assignment will
15941 -- ensure that the new restarter line copies from the latest record.
15942 l_prev_new_rec := l_main_rec;
15943
15944 --TERM_LSP:global value set to N for checking terminated employees
15945 g_terminated_person := 'N';
15946
15947 -- Have we found any events?
15948 IF g_asg_events.COUNT > 0 THEN
15949
15950 debug('Number of events to process :'||to_char(g_asg_events.COUNT), 60);
15951
15952 -- Bugfix 3803760:TERMASG
15953 debug('Before : g_asg_count :'||to_char(g_asg_count), 62);
15954
15955 /* Commenting out as we will do this in the loop below
15956 l_prev_asg_count := g_asg_count;
15957 g_asg_count := g_asg_count
15958 +
15959 nvl(g_asg_events(g_asg_events.FIRST).asg_count_change
15960 , 0);
15961
15962 debug('After : g_asg_count :'||to_char(g_asg_count), 63);
15963
15964 debug('B4 g_part_time_asg_count :'||to_char(g_part_time_asg_count), 64);
15965 g_part_time_asg_count := g_part_time_asg_count
15966 +
15967 nvl(g_asg_events(g_asg_events.FIRST).pt_asg_count_change, 0);
15968
15969 debug('After g_part_time_asg_count :'||to_char(g_part_time_asg_count), 65);
15970 */
15971
15972 -- If the first event is a primary leaver event, then we need
15973 -- a W on withdrawal conf and
15974 -- the end date should be set as the event date
15975 IF (g_asg_count
15976 +
15977 nvl(g_asg_events(g_asg_events.FIRST).asg_count_change, 0)
15978 ) <= 0 THEN
15979
15980 -- Assign end date(seq 14) to the main record
15981 l_main_rec.val_14 := to_char(g_asg_events(g_asg_events.FIRST).event_date,'DDMMYY');
15982
15983 debug('Setting W on main record',70);
15984 l_main_rec.val_15 := 'W';
15985
15986 ELSE
15987
15988 -- Assign end date(seq 14) to the main record
15989 -- Bugfix 3880543:REHIRE : Set end date to event date if this
15990 -- is a leaver event otherwise event date less one
15991 IF INSTR(nvl(g_asg_events(g_asg_events.FIRST).event_type,'XX')
15992 ,'LEAVER'
15993 ) > 0 THEN
15994 l_main_rec.val_14 := to_char(g_asg_events(g_asg_events.FIRST).event_date,'DDMMYY');
15995 ELSE
15996 l_main_rec.val_14 := to_char(g_asg_events(g_asg_events.FIRST).event_date - 1,'DDMMYY');
15997 END IF;
15998
15999 -- Clear the Withdrawal conf flag
16000 l_main_rec.val_15 := ' ';
16001
16002 END IF;
16003
16004
16005
16006 debug('g_terminated_person val : '||g_terminated_person,74);
16007 debug('g_asg_events(g_asg_events.FIRST).event_type: '|| (g_asg_events(g_asg_events.FIRST).event_type),75 );
16008 IF INSTR(nvl(g_asg_events(g_asg_events.FIRST).event_type,'XX'),'PQP_GB_TP_ASG_STATUS') > 0 THEN
16009
16010 g_terminated_person := 'Y';
16011
16012 debug('Inside event check g_terminated_person val : '||g_terminated_person);
16013 ELSE
16014 g_terminated_person := 'N';
16015 END IF;
16016
16017 debug('After event check g_terminated_person val : '||g_terminated_person);
16018
16019 debug('Main Record Start Date :'||l_main_rec.val_13,80);
16020 debug('Main Record End Date :'||l_main_rec.val_14,90);
16021
16022 -- Now recalculate the data elements
16023 recalc_data_elements
16024 (p_dtl_rec => l_main_rec -- IN OUT
16025 ,p_rec_type => 'MAIN'
16026 ,p_event_details => NULL
16027 ,p_assignment_id => p_assignment_id
16028 );
16029
16030 debug('Main Record Start Date :'||l_main_rec.val_13,100);
16031 debug('Main Record End Date :'||l_main_rec.val_14,110);
16032
16033 -- Update the main record
16034 -- upd_rslt_dtl(p_dtl_rec => l_main_rec);
16035
16036 -- Assign the main record to the previous record variable
16037 l_prev_new_rec := l_main_rec;
16038 l_check_new_los := '1';
16039
16040 -- Process each event in the global collection
16041 FOR l_itr IN g_asg_events.FIRST..g_asg_events.LAST
16042 LOOP -- through the sorted stored events
16043
16044 debug('Start of Loop',120);
16045
16046 -- Bugfix 3803760:TERMASG
16047 debug('B4 g_asg_count :'||to_char(g_asg_count), 122);
16048 debug('B4 g_part_time_asg_count :'||to_char(g_part_time_asg_count), 123);
16049 l_prev_asg_count := g_asg_count;
16050 --TERM_LSP: global value set to N for checking terminated employees
16051 g_terminated_person := 'N';
16052 debug('g_asg_events(l_itr).asg_count_change :' || to_char(g_asg_events(l_itr).asg_count_change),124);
16053 debug('g_asg_events(l_itr).pt_asg_count_change :' || to_char(g_asg_events(l_itr).pt_asg_count_change),125);
16054 -- Check if this event needs to be skipped
16055 IF (l_skip_itr IS NULL
16056 OR
16057 l_itr <> l_skip_itr
16058 ) THEN
16059
16060 g_asg_count := g_asg_count
16061 +
16062 nvl(g_asg_events(l_itr).asg_count_change
16063 , 0);
16064
16065 g_part_time_asg_count := g_part_time_asg_count
16066 +
16067 nvl(g_asg_events(l_itr).pt_asg_count_change
16068 , 0);
16069
16070 debug('After g_asg_count :'||to_char(g_asg_count), 124);
16071 debug('After g_part_time_asg_count :'||to_char(g_part_time_asg_count), 125);
16072
16073 END IF;
16074
16075 -- Eliminate duplicate changes as we will be re-calculating all
16076 -- data elements that are non-static
16077 -- Also eliminate the event if its a primary leaver event as
16078 -- we process these when deciding on withdrawal conf
16079 -- Now we also skip events if they are set in l_skip_itr
16080 IF (l_itr = g_asg_events.FIRST -- The event is the first one
16081 OR -- the date is not the same as previous event date
16082 g_asg_events(l_itr).event_date <>
16083 g_asg_events(g_asg_events.PRIOR(l_itr)).event_date
16084 )
16085 AND
16086 (g_asg_count > 0
16087 )
16088 AND
16089 -- Check if this event needs to be skipped
16090 (l_skip_itr IS NULL
16091 OR
16092 l_itr <> l_skip_itr
16093 ) THEN
16094
16095 debug('Processing Event Date :'||to_char(g_asg_events(l_itr).event_date,'DD/MM/YYYY'),130);
16096 debug(' Event Type :'||g_asg_events(l_itr).event_type,140);
16097
16098 -- Copy the main or previous line of service record
16099 l_new_rec := l_prev_new_rec;
16100
16101 -- Set the start date(seq number 13)
16102 -- Bugfix 3880543:REHIRE : If the current event is a leaver
16103 -- event then we need an event date + 1 otherwise event date
16104 IF INSTR(nvl(g_asg_events(l_itr).event_type,'XX')
16105 ,'LEAVER'
16106 ) > 0 THEN
16107 l_new_rec.val_13 := to_char(g_asg_events(l_itr).event_date + 1,'DDMMYY');
16108 ELSE
16109 l_new_rec.val_13 := to_char(g_asg_events(l_itr).event_date,'DDMMYY');
16110 END IF;
16111
16112 l_next_itr := g_asg_events.NEXT(l_itr);
16113
16114 -- Bugfix 3880543:REHIRE :
16115 -- We need to pre-Evaluate the next event
16116 -- We might want to skip the next event if the
16117 -- next event date is equal to current event date+1
16118 -- as it could result in a line with start date
16119 -- greater than end date. We only want to skip
16120 -- if the next event will not result in a primary
16121 -- leaver event, meaning it will not coz g_asg_count
16122 -- to become zero.
16123 IF l_next_itr IS NOT NULL
16124 AND
16125 ( (g_asg_count
16126 +
16127 nvl(g_asg_events(l_next_itr).asg_count_change, 0)
16128 ) > 0
16129 ) THEN
16130
16131
16132 debug('Pre-Evaluating next event',141);
16133 -- The start date greater than end data problem
16134 -- can only occur in the following situation
16135 -- If the current event is a (new line) leaver event AND
16136 -- Next event is NOT a leaver event AND
16137 -- Next event date is EQUAL to current event date + 1
16138 IF (INSTR(nvl(g_asg_events(l_itr).event_type,'XX')
16139 ,'LEAVER'
16140 ) > 0
16141 )
16142 AND
16143 (INSTR(nvl(g_asg_events(l_next_itr).event_type,'XX')
16144 ,'LEAVER'
16145 ) <= 0
16146 )
16147 AND
16148 ( g_asg_events(l_itr).event_date + 1
16149 =
16150 g_asg_events(l_next_itr).event_date
16151 ) THEN
16152
16153 debug('Pre-Evaluate: Need to skip next event',142);
16154 -- We want to skip the next event, Set skip itr
16155 l_skip_itr := l_next_itr;
16156
16157 -- Since we have set l_skip_itr, we need to adjust the
16158 -- g_asg_count and g_part_time_asg_count now rather
16159 -- than later coz we need the updated globals before
16160 -- recalc_data_elements is called
16161 l_prev_asg_count := g_asg_count;
16162
16163 g_asg_count := g_asg_count
16164 +
16165 nvl(g_asg_events(l_skip_itr).asg_count_change
16166 , 0);
16167
16168 g_part_time_asg_count := g_part_time_asg_count
16169 +
16170 nvl(g_asg_events(l_skip_itr).pt_asg_count_change
16171 , 0);
16172
16173 debug('After g_asg_count :'||to_char(g_asg_count), 143);
16174 debug('After g_part_time_asg_count :'||to_char(g_part_time_asg_count), 144);
16175
16176 -- Get next-of-next and treat it as the next event
16177 l_next_of_next_itr := g_asg_events.NEXT(l_next_itr);
16178 l_next_itr := l_next_of_next_itr;
16179
16180 ELSE
16181 l_skip_itr := NULL;
16182 END IF;
16183
16184 ELSE -- Pre-Evaluating
16185
16186 debug('Pre-Evaluate: Last event OR next causing primary leaver',145);
16187 -- UnSet skip itr
16188 l_skip_itr := NULL;
16189
16190 END IF; -- Pre-Evaluating
16191
16192 -- Now doing the real processing
16193 IF l_next_itr IS NOT NULL THEN
16194
16195 debug('Next event exists',146);
16196
16197 -- Also check if the next event is a Primary Leaver event
16198 IF -- If the next event will cause g_asg_count to become zero
16199 ( (g_asg_count
16200 +
16201 nvl(g_asg_events(l_next_itr).asg_count_change, 0)
16202 ) <= 0
16203 ) THEN
16204
16205 -- Set the end date
16206 l_new_rec.val_14 := to_char(g_asg_events(l_next_itr).event_date,'DDMMYY');
16207
16208 debug('Setting W on New record',150);
16209 -- And the withdrawal conf flag
16210 l_new_rec.val_15 := 'W';
16211
16212 ELSE
16213
16214 -- Set the end date
16215 -- Bugfix 3880543:REHIRE : If the next event is a leaver
16216 -- event then we need an event date otherwise
16217 -- event date less one
16218 IF INSTR(nvl(g_asg_events(l_next_itr).event_type,'XX')
16219 ,'LEAVER'
16220 ) > 0 THEN
16221 l_new_rec.val_14 := to_char(g_asg_events(l_next_itr).event_date,'DDMMYY');
16222 ELSE
16223 l_new_rec.val_14 := to_char(g_asg_events(l_next_itr).event_date -1,'DDMMYY');
16224 END IF;
16225
16226 -- And the withdrawal conf flag
16227 l_new_rec.val_15 := ' ';
16228
16229 END IF;
16230
16231 debug('Check if ASG_STATUS event');
16232 debug('g_terminated_person val : '||g_terminated_person,170);
16233 debug('g_asg_events.current_event_type: '|| (g_asg_events(l_itr).event_type),175 );
16234 debug('g_asg_events.next_event_type: '|| (g_asg_events(l_next_itr).event_type),180 );
16235 IF INSTR(nvl(g_asg_events(l_next_itr).event_type,'XX'),'PQP_GB_TP_ASG_STATUS') > 0 THEN
16236
16237 g_terminated_person := 'Y';
16238
16239 debug('Inside event check g_terminated_person val : '||g_terminated_person);
16240 ELSE
16241 g_terminated_person := 'N';
16242 END IF;
16243 debug('After event check g_terminated_person val : '||g_terminated_person);
16244
16245 ELSE -- This is the last event
16246
16247 debug('This is the last event',160);
16248
16249 -- Set the end date as run end date
16250 l_new_rec.val_14 := to_char(g_effective_run_date,'DDMMYY');
16251
16252 -- Reset the Withdrawal conf flag
16253 l_new_rec.val_15 := ' ';
16254
16255 END IF; -- l_next_itr IS NOT NULL THEN
16256
16257
16258 --The following bugfix(sort order only) has been undone. The reason being:
16259 --DE PQP GB TP Type 1 Record Serial Number - Detail Teachers Annual Returns ( England and Wales ) has a
16260 --maximum length of 1 character. So the changes done in 115.99 are being reverted here.
16261
16262 -- **************************
16263 -- Record serial number
16264 -- bug fix : 4926143
16265 -- this is being done as this column in the table is of varchar2 type, due to which
16266 -- sorting using order_by was incorrect when values are like 1,2,3,4....,9,10,11,12.
16267 -- For example, 1,2..,9,10,11,12 gets sorted as 1,10,11,12,2,3...,9.
16268 -- To fix this issue, the value in the thrd_sort_val is being stored as 3 digit numbers,
16269 -- starting from 001, 002 and so on.
16270
16271 -- l_new_rec.val_26 := ltrim(rtrim(to_char((to_number(l_prev_new_rec.val_26) + 1),'009')));
16272 -- **************************
16273
16274 -- reintroduced from version 115.98
16275 l_new_rec.val_26 := to_char(to_number(l_prev_new_rec.val_26) + 1);
16276
16277
16278 -- Set the sorting order
16279 l_new_rec.thrd_sort_val := l_new_rec.val_26;
16280
16281
16282
16283
16284
16285 -- Now recalculate the data elements in this new record
16286 recalc_data_elements
16287 (p_dtl_rec => l_new_rec -- IN OUT
16288 ,p_rec_type => 'NEW'
16289 ,p_event_details => g_asg_events(l_itr)
16290 ,p_assignment_id => p_assignment_id
16291 );
16292
16293
16294 debug('New Record Start Date :'||l_new_rec.val_13,120);
16295 debug('New Record End Date :'||l_new_rec.val_14,130);
16296
16297 OPEN csr_chk_los_change
16298 (p_prev_new_rec => l_prev_new_rec
16299 ,p_new_rec => l_new_rec
16300 );
16301 FETCH csr_chk_los_change INTO l_check_new_los;
16302
16303 If l_new_rec.val_15 ='W' and l_prev_new_rec.val_15 = 'W' THEN -- change for bug 7173168
16304 l_check_new_los := '1';
16305 end if ;
16306
16307 IF l_check_new_los <> '0' THEN
16308 -- Update the previous record
16309 upd_rslt_dtl(p_dtl_rec => l_prev_new_rec);
16310
16311 -- Store this new line
16312 ins_rslt_dtl(p_dtl_rec => l_new_rec -- IN OUT
16313 );
16314 END IF;
16315
16316 CLOSE csr_chk_los_change; -- rahul supply
16317 -- Now assign the current new record to the previous new record
16318 -- l_prev_new_rec := l_new_rec;
16319 debug('g_effective_run_date :' || to_char(g_effective_run_date),140);
16320
16321 debug('l_check_new_los :'||l_check_new_los,141);
16322 IF l_check_new_los <> '0' THEN
16323 l_prev_new_rec := l_new_rec;
16324 debug('l_check_new_los :'||l_check_new_los,142);
16325 ELSE
16326 debug('l_check_new_los :'||l_check_new_los,143);
16327
16328 l_prev_new_rec.val_14 := l_new_rec.val_14;
16329
16330 debug('val_14 :'||l_prev_new_rec.val_14,143);
16331
16332 debug('l_new_rec.val_19 :'||l_new_rec.val_19,144);
16333
16334 debug('l_prev_new_rec.val_19 :'||l_prev_new_rec.val_19,145);
16335
16336 l_prev_new_rec.val_19 := l_prev_new_rec.val_19 + l_new_rec.val_19;
16337
16338 debug('val_19 :'||l_prev_new_rec.val_19,146);
16339
16340 IF sign(l_prev_new_rec.val_19) = -1 THEN
16341 l_prev_new_rec.val_19 := '-'|| lpad(abs(l_prev_new_rec.val_19),5,'0');
16342 ELSE
16343 l_prev_new_rec.val_19 := lpad(l_prev_new_rec.val_19,6,'0');
16344 END IF;
16345 debug('val_19 :'||l_prev_new_rec.val_19,147);
16346 IF l_next_itr IS NULL THEN
16347 debug('Before Update ',147);
16348 upd_rslt_dtl(p_dtl_rec => l_prev_new_rec);
16349 debug('After Update ',147);
16350 END IF;
16351 END IF;
16352 l_check_new_los := '1'; -- rahul supply
16353
16354 END IF; -- if this date <> last date to eliminate duplicates and primary leaver
16355 --
16356 END LOOP; -- through the sorted stored events
16357 --
16358 -- update the last record
16359 upd_rslt_dtl(p_dtl_rec => l_prev_new_rec); -- rahul supply
16360
16361 END IF; -- g_asg_events.COUNT > 0 THEN
16362
16363 debug_exit(l_proc_name);
16364
16365 RETURN;
16366
16367 EXCEPTION
16368 WHEN OTHERS THEN
16369 debug('SQLCODE :'||to_char(SQLCODE), 140);
16370 debug('SQLERRM :'||SQLERRM, 150);
16371 debug_exit(' Others in '||l_proc_name);
16372 RAISE;
16373 END; -- create_new_lines
16374
16375 -- 8iComp Changes: IMORTANT NOTE
16376 -- Changing he following function to use the 8iComp code.
16377 -- Now it does not reference g_asg_leaver_events_table global
16378 -- but references g_per_asg_leaver_dates global
16379 -- and calls get_g_per_asg_leaver_dates to get the
16380 -- collection for Leaver-Restarter dates for an assignment
16381 --
16382 -- Extended Criteria to generate new lines of service
16383 --
16384 FUNCTION create_service_lines
16385 (p_assignment_id IN NUMBER -- context
16386 ) RETURN VARCHAR2
16387 IS
16388
16389 -- Variable Declaration
16390 l_curr_asg_id per_all_assignments_f.assignment_id%TYPE;
16391 l_prev_asg_id per_all_assignments_f.assignment_id%TYPE;
16392 l_sec_asg_id per_all_assignments_f.assignment_id%TYPE;
16393
16394 -- Rowtype Variable Declaration
16395 l_all_sec_asgs t_sec_asgs_type;
16396
16397 --l_sec_asg_details csr_sec_assignments%ROWTYPE := NULL;
16398
16399
16400 -- 8iComp
16401 l_insert_rec NUMBER;
16402 l_record_count NUMBER;
16403
16404 l_proc_name VARCHAR2(61):=
16405 g_proc_name||'create_service_lines';
16406
16407 BEGIN -- create_service_lines
16408
16409 debug_enter(l_proc_name);
16410
16411 -- Step 0) Reset the global variable, it may contain events for the previous person processed
16412 -- If events will be stored in this global by the basic criteria, then the following
16413 -- line will need to be commented out
16414 -- Also, set the global variable for primary assignment id
16415
16416 -- Bugfix 3073562:GAP10
16417 -- Commenting out this line as we are now storing LEA Estb to
16418 -- LEA Estb location change as a new line of service event frm
16419 -- proc chk_is_teacher_a_leaver
16420 -- The collection is now reset from the periodic and annual criteria.
16421 -- g_asg_events.DELETE;
16422 debug('Count in g_asg_events :'||to_char(g_asg_events.COUNT), 20);
16423
16424 g_primary_leaver_dates.DELETE;
16425 g_primary_assignment_id := p_assignment_id;
16426
16427 -- Bugfix 3803760:FTSUPPLY : Resetting override ft asg id
16428 -- This is needed coz if for the frist line one of
16429 -- the secondary was FT, then chk_report_assignment
16430 -- will return N for the primary asg below and
16431 -- we will not pick up any new line and leaver restarter
16432 -- events for the primary asg
16433 g_override_ft_asg_id := NULL;
16434 g_tab_sec_asgs.DELETE;
16435
16436 -- Step 1) Get events( dates, type, assignment id)
16437 -- This procedure stores into a global collection containing the following :
16438 -- a) event_date -> to be sorted ascending later
16439 -- b) event_type -> helps in deciding which columns on the
16440 -- report need a refresh
16441 -- c) assignment_id -> assignment id
16442 --
16443
16444 -- Step 1a) Get valid events for primary assignment
16445
16446 -- Bugfix 3073562:GAP6
16447 -- But only do this if the primary asg is a teacher
16448 -- and is to be reported
16449 IF chk_report_assignment
16450 (p_assignment_id => p_assignment_id
16451 ,p_secondary_assignment_id => l_sec_asg_id
16452 ) = 'Y' THEN
16453
16454 -- PER_LVR change
16455 -- for PERIODIC REPORT : Logic to store leaver restarter dates for the assignments
16456 -- has been moved to criteria code.
16457 -- Now store these dates, only if the Extract type is ANUAL : 'TP1'
16458 -- for annual report we are calling chk_person_leaver when criteria is Exclude
16459 IF g_extract_type = 'TP1' and nvl(g_reporting_mode,'EXCLUDE') = 'INCLUDE' THEN
16460 -- Store all the leaver and restarter dates for the primary asg
16461
16462 store_leaver_restarter_dates
16463 (p_assignment_id => p_assignment_id
16464 );
16465
16466 -- MULT-LR changes
16467 -- g_asg_leaver_events_table(p_assignment_id) := g_primary_leaver_dates ;
16468
16469 --8iComp
16470 debug('inserting in new collection...', 22);
16471 l_insert_rec := set_g_per_asg_leaver_dates
16472 ( p_leaver_dates_type => g_primary_leaver_dates) ;
16473
16474 debug('l_insert_rec: '|| l_insert_rec, 24) ;
16475 -- 8iComp
16476 ELSE
16477 debug ('Leaver Restarter Dates are already stored ...',30);
16478 -- QAB1: restore the leaver dates collection.
16479 debug ('restoring the collection temporarily for primary dates',40) ;
16480
16481 -- 8iComp chagnes
16482 --g_primary_leaver_dates := g_asg_leaver_events_table(p_assignment_id) ;
16483
16484 l_record_count := get_g_per_asg_leaver_dates
16485 ( p_assignment_id => p_assignment_id
16486 ,p_leaver_dates_type => g_primary_leaver_dates
16487 ) ;
16488
16489 debug('l_record_count: '|| l_record_count, 45) ;
16490
16491 -- 8iComp Changes
16492
16493
16494 END IF;
16495
16496 -- Store new line of service events for the primary assignment
16497 get_events_in_prmy_range(p_assignment_id => p_assignment_id
16498 );
16499
16500 ELSE
16501
16502 -- Bugfix 3880543:REHIRE
16503 -- Setting the sec asg id as the primary asg
16504 -- We will treat the sec asg as promary so all
16505 -- leaver restarter events for this secondary
16506 -- will b treated as primary leaver restarter events
16507 g_primary_assignment_id := l_sec_asg_id;
16508
16509 END IF; -- IF chk_report_assignment
16510
16511 -- Step 1b) Get secondary assignments
16512 l_all_sec_asgs := get_all_secondary_asgs
16513 (p_primary_assignment_id => p_assignment_id
16514 --changed from start_date to teacher_start_date.
16515 ,p_effective_date => g_ext_asg_details(p_assignment_id).teacher_start_date
16516 );
16517
16518
16519 -- Have we found any secondary assignments?
16520 --IF l_all_sec_asgs IS NOT NULL THEN, cannot use is NOT NULL with index by tables
16521 IF l_all_sec_asgs.COUNT > 0 THEN
16522
16523 l_curr_asg_id := l_all_sec_asgs.FIRST;
16524
16525 WHILE l_curr_asg_id IS NOT NULL
16526 LOOP
16527
16528 debug('Processing Secondary Asg :'||to_char(l_curr_asg_id),50);
16529 -- Get the asg details, not needed currently,
16530 -- will uncomment if needed,both here and in declaration
16531 --l_sec_asg_details := l_all_sec_asgs(l_curr_asg_id);
16532
16533 -- PER_LVR change
16534 -- for PERIODIC REPORT : Logic to store leaver restarter dates for the assignments
16535 -- has been moved to criteria code.
16536 -- Now store these dates, only if the Extract type is ANUAL : 'TP1'
16537 -- for annual report we are calling chk_person_leaver when criteria is Exclude
16538 IF g_extract_type = 'TP1' and nvl(g_reporting_mode,'EXCLUDE') = 'INCLUDE' THEN
16539 -- Delete the global for lever restarter dates for secondary asg.
16540 g_sec_leaver_dates.DELETE;
16541
16542 -- Store all the leaver and restarter dates for the secondary asg
16543 store_leaver_restarter_dates
16544 (p_assignment_id => l_curr_asg_id
16545 );
16546
16547 -- MULT-LR changes
16548 IF l_curr_asg_id = g_primary_assignment_id THEN
16549 --g_asg_leaver_events_table(l_curr_asg_id) := g_primary_leaver_dates ;
16550
16551 --8iComp
16552 debug('inserting in new collection...', 22);
16553 l_insert_rec := set_g_per_asg_leaver_dates
16554 ( p_leaver_dates_type => g_primary_leaver_dates) ;
16555
16556 debug('l_insert_rec: '|| l_insert_rec, 24) ;
16557 -- 8iComp
16558 ELSE
16559 --g_asg_leaver_events_table(l_curr_asg_id) := g_sec_leaver_dates ;
16560 --8iComp
16561 debug('inserting in new collection...', 22);
16562 l_insert_rec := set_g_per_asg_leaver_dates
16563 ( p_leaver_dates_type => g_sec_leaver_dates) ;
16564
16565 debug('l_insert_rec: '|| l_insert_rec, 24) ;
16566 -- 8iComp
16567 END IF;
16568
16569 ELSE --g_extract_type = 'TP1'
16570 debug ('Leaver Restarter Dates are already stored ...',60);
16571
16572 -- QAB1: Restore the leaver_dates collection from the
16573 -- leaver events table as this is required in the following functions
16574 -- get_events_in_prmy_range/get_events_in_sec_range
16575
16576 IF l_curr_asg_id = g_primary_assignment_id THEN
16577 debug ('restoring the collection temporarily for primary dates',70) ;
16578
16579 -- g_primary_leaver_dates := g_asg_leaver_events_table(l_curr_asg_id) ;
16580 -- 8iComp
16581 l_record_count := get_g_per_asg_leaver_dates
16582 ( p_assignment_id => p_assignment_id
16583 ,p_leaver_dates_type => g_primary_leaver_dates
16584 ) ;
16585
16586 debug('l_record_count: '|| l_record_count, 45) ;
16587
16588 -- 8iComp Changes
16589
16590 ELSE
16591 debug ('restoring the collection temporarily for Secondary dates',80) ;
16592 -- g_sec_leaver_dates := g_asg_leaver_events_table(l_curr_asg_id) ;
16593
16594 -- 8iComp
16595 -- 8iComp
16596 l_record_count := get_g_per_asg_leaver_dates
16597 ( p_assignment_id => l_curr_asg_id
16598 ,p_leaver_dates_type => g_primary_leaver_dates
16599 ) ;
16600
16601 debug('l_record_count: '|| l_record_count, 45) ;
16602
16603 -- 8iComp Changes
16604
16605 END IF;
16606
16607 END IF; --g_extract_type = 'TP1'
16608
16609
16610 -- Bugfix 3880543:REHIRE
16611 -- If curr sec asg is being treated as the primary then
16612 -- store events in primary range otherwise in sec range
16613 IF l_curr_asg_id = g_primary_assignment_id THEN
16614
16615 -- Store new line of service events for the primary assignment
16616 get_events_in_prmy_range(p_assignment_id => l_curr_asg_id
16617 );
16618 ELSE
16619
16620 -- Store new line of service events for the SECONDARY assignment
16621 get_events_in_sec_range(p_assignment_id => l_curr_asg_id
16622 );
16623 END IF;
16624
16625 -- Assign the current asg id to prev asg id
16626 -- and reset curr asg id, ready for the next one
16627 l_prev_asg_id := l_curr_asg_id;
16628 l_curr_asg_id := NULL;
16629
16630 -- Get next secondary assignment
16631 l_curr_asg_id := l_all_sec_asgs.NEXT(l_prev_asg_id);
16632
16633 END LOOP; -- l_curr_asg_id IS NOT NULL
16634 --
16635 END IF; -- l_all_sec_asgs.COUNT > 0 THEN
16636
16637 -- MULT-LR --
16638 -- print all the events stored so far.
16639 -- Print the Events table only if Debug is switched on.
16640 IF NVL(g_trace,'N') = 'Y' THEN
16641 print_events_table ();
16642 END IF;
16643
16644 -- Bugfix 3880543:REHIRE
16645 -- Currently there is not requirement for resetting the global
16646 -- g_primary_assignment_id to the original primary asg id as it
16647 -- is not used beyond this point. If in the future we do need
16648 -- this global beyond this point, uncomment the following statement
16649
16650 -- MULT-LR: uncommented the following line.
16651 g_primary_assignment_id := p_assignment_id;
16652
16653 -- Step 1d) Sort events by Ascending Date if we have found more than 1 events
16654 IF g_asg_events.COUNT > 1 THEN
16655 sort_stored_events;
16656 END IF;
16657
16658 -- Step 2) Create new lines of service for each event.
16659 -- This proc also updates the main record
16660 create_new_lines
16661 (p_assignment_id => p_assignment_id
16662 );
16663
16664
16665 -- Step 3) Reset the global variable containing events for this person
16666 g_asg_events.DELETE;
16667
16668 debug_exit(l_proc_name);
16669
16670 RETURN 'DELETE';
16671
16672 EXCEPTION
16673 WHEN OTHERS THEN
16674
16675 -- Reset the global variable containing events for this person
16676 g_asg_events.DELETE;
16677
16678 debug('SQLCODE :'||to_char(SQLCODE), 40);
16679 debug('SQLERRM :'||SQLERRM, 50);
16680
16681 debug_exit(' Others in '||l_proc_name
16682 ,'Y' -- turn trace off
16683 );
16684 RAISE;
16685 END; -- create_service_lines
16686 --
16687 -- del_dummy_recs
16688 --
16689 PROCEDURE del_dummy_recs
16690 IS
16691
16692 -- Variable Declaration
16693 l_ext_dtl_rcd_id ben_ext_rcd.ext_rcd_id%TYPE;
16694
16695 l_proc_name VARCHAR2(61):=
16696 g_proc_name||'del_dummy_recs';
16697
16698 BEGIN -- del_dummy_recs
16699
16700 debug_enter(l_proc_name);
16701
16702 -- Get the record id for the Type 1 Hidden Detail record
16703 OPEN csr_ext_rcd_id(p_hide_flag => 'Y'
16704 ,p_rcd_type_cd => 'D'
16705 );
16706 FETCH csr_ext_rcd_id INTO l_ext_dtl_rcd_id;
16707 CLOSE csr_ext_rcd_id;
16708
16709 DELETE
16710 FROM ben_ext_rslt_dtl dtl
16711 WHERE dtl.ext_rslt_id = ben_ext_thread.g_ext_rslt_id
16712 AND dtl.ext_rcd_id = l_ext_dtl_rcd_id
16713 AND dtl.val_01 = 'DELETE';
16714
16715 debug('Number of Dummy Records Deleted :'||to_char(SQL%ROWCOUNT));
16716
16717 debug_exit(l_proc_name);
16718 RETURN;
16719
16720 EXCEPTION
16721 WHEN OTHERS THEN
16722 debug_exit(' Others in '||l_proc_name);
16723 RAISE;
16724 END; -- del_dummy_recs
16725
16726 --
16727 -- type1_post_proc_rule
16728 --
16729 FUNCTION type1_post_proc_rule
16730 (p_ext_rslt_id IN ben_ext_rslt_dtl.ext_rslt_id%TYPE
16731 ) RETURN VARCHAR2
16732 IS
16733
16734 -- Variable Declaration
16735
16736 -- Rowtype Variable Declaration
16737
16738 l_proc_name VARCHAR2(61):=
16739 g_proc_name||'type1_post_proc_rule';
16740
16741 BEGIN -- type1_post_proc_rule
16742
16743 debug_enter(l_proc_name);
16744
16745 -- Step 1) Delete detail records which are not being displayed.
16746 del_dummy_recs;
16747
16748 -- Step 2) Re-calc total in the trailer
16749 -- Not needed as now hv modified the SQL in Type 4 pkg which gets the
16750 -- total number of records to ignore all details records which have
16751 -- 'DELETE' in column val_01
16752
16753 debug_exit(l_proc_name);
16754 RETURN 'T1';
16755
16756 EXCEPTION
16757 WHEN OTHERS THEN
16758 debug_exit(' Others in '||l_proc_name
16759 ,'Y' -- turn trace off
16760 );
16761 RAISE;
16762 END; -- type1_post_proc_rule
16763
16764 --
16765 -- chk_rate_change_affects_asg
16766 --
16767 FUNCTION chk_rate_change_affects_asg
16768 (p_assignment_id IN NUMBER
16769 ,p_rate_id IN NUMBER
16770 ,p_effective_date IN DATE
16771 ) RETURN BOOLEAN IS
16772
16773 CURSOR c_rates IS
16774 SELECT * FROM pay_rates
16775 WHERE rate_id = p_rate_id;
16776
16777 CURSOR c_ele_attr(p_element_type_id IN NUMBER) IS
16778 SELECT petei.eei_information2 pay_source_value
16779 ,petei.eei_information3 Qualifier
16780 FROM pay_element_type_extra_info petei
16781 WHERE petei.element_type_id = p_element_type_id
16782 AND petei.eei_information_category ='PQP_UK_ELEMENT_ATTRIBUTION';
16783
16784 CURSOR c_element_entry(p_element_type_id IN NUMBER) IS
16785 SELECT pee.element_entry_id
16786 FROM pay_element_links_f pel
16787 ,pay_element_entries_f pee
16788 where pel.element_type_id = p_element_type_id
16789 and p_effective_date between pel.effective_start_date
16790 and pel.effective_end_date
16791 and pee.element_link_id = pel.element_link_id
16792 and p_effective_date between pee.effective_start_date
16793 and pee.effective_end_date
16794 and pee.assignment_id = p_assignment_id;
16795
16796
16797
16798 l_asg_affected BOOLEAN := FALSE;
16799 l_itr NUMBER;
16800 l_current NUMBER;
16801
16802 l_rate_dets c_rates%ROWTYPE;
16803 l_ele_attr c_ele_attr%ROWTYPE;
16804 l_element_entry c_element_entry%ROWTYPE;
16805
16806 l_pet_ids t_ele_ids_from_bal;
16807
16808 l_proc_name VARCHAR2(61):=
16809 g_proc_name||'chk_rate_change_affects_asg';
16810
16811 BEGIN -- chk_rate_change_affects_asg
16812
16813 debug_enter(l_proc_name);
16814
16815 -- Get the Rate Details
16816 OPEN c_rates;
16817 FETCH c_rates INTO l_rate_dets;
16818 CLOSE c_rates;
16819
16820 -- Replace rate type of G with GR as rates history stores GR
16821 IF l_rate_dets.rate_type = 'G' THEN
16822 debug(l_proc_name, 10);
16823 l_rate_dets.rate_type := 'GR';
16824 END IF;
16825
16826 -- For each Element Type id, check its Element Attribution
16827 -- to see if it has the Rate Type being evaluated
16828 l_itr := 1;
16829 l_current := g_tab_sal_ele_ids.FIRST;
16830
16831 WHILE l_itr <= g_tab_sal_ele_ids.COUNT
16832 LOOP -- through the element type ids in Salary Balance
16833
16834 debug(l_proc_name, 20);
16835 -- Get the element attribution info for this element type id
16836 OPEN c_ele_attr(p_element_type_id => g_tab_sal_ele_ids(l_current).element_type_id);
16837 FETCH c_ele_attr INTO l_ele_attr;
16838
16839 IF c_ele_attr%FOUND
16840 AND -- The rate Type matches
16841 l_ele_attr.pay_source_value = l_rate_dets.rate_type
16842 AND -- The Rate Name also matches
16843 l_ele_attr.qualifier = l_rate_dets.name
16844 THEN
16845
16846 debug(l_proc_name, 30);
16847 -- Add this element type id to list of valid ele ids
16848 -- so we can check if the asg has an effective Element
16849 -- entry for this Element Type id
16850 l_pet_ids(l_pet_ids.COUNT + 1) := g_tab_sal_ele_ids(l_current);
16851
16852 END IF;
16853
16854 CLOSE c_ele_attr;
16855
16856 l_current := g_tab_sal_ele_ids.NEXT(l_current);
16857 IF l_current IS NULL THEN
16858 EXIT;
16859 ELSE
16860 l_itr := l_itr + 1;
16861 END IF;
16862
16863 END LOOP; -- through the element type ids in Salary Balance
16864
16865 debug(l_proc_name, 40);
16866 l_itr := NULL;
16867
16868 -- Now LOOP through element types which have the Rate Type
16869 -- in Ele Attribution to check if the assignment has an
16870 -- Element entry for this ele type.
16871 FOR l_itr IN 1..l_pet_ids.COUNT
16872 LOOP
16873
16874 debug(l_proc_name, 50);
16875 OPEN c_element_entry(p_element_type_id => l_pet_ids(l_itr).element_type_id);
16876 FETCH c_element_entry INTO l_element_entry;
16877
16878 IF c_element_entry%FOUND THEN
16879 debug('Setting l_asg_affected to TRUE', 60);
16880 l_asg_affected := TRUE;
16881 EXIT;
16882 END IF;
16883
16884 CLOSE c_element_entry;
16885
16886 END LOOP; -- l_itr INTO 1..l_pet_ids.COUNT
16887
16888 debug_exit(l_proc_name);
16889
16890 RETURN l_asg_affected;
16891
16892 EXCEPTION
16893 WHEN OTHERS THEN
16894 debug('Other exception :'||SQLCODE||' '||SQLERRM, 70);
16895 l_asg_affected := FALSE;
16896 debug_exit(l_proc_name);
16897 RAISE;
16898
16899 END chk_rate_change_affects_asg;
16900
16901 --
16902 -- chk_grd_change_affects_asg
16903 --
16904 FUNCTION chk_grd_change_affects_asg
16905 (p_assignment_id IN NUMBER
16906 ,p_grade_rule_id IN NUMBER
16907 ,p_effective_date IN DATE
16908 ) RETURN BOOLEAN IS
16909
16910 CURSOR c_grade_rule IS
16911 SELECT effective_start_date
16912 ,effective_end_date
16913 ,rate_id
16914 ,grade_or_spinal_point_id
16915 ,rate_type
16916 FROM pay_grade_rules_f
16917 WHERE grade_rule_id = p_grade_rule_id
16918 AND p_effective_date BETWEEN effective_start_date
16919 AND effective_end_date;
16920
16921 CURSOR c_asg_grade IS
16922 SELECT grade_id
16923 FROM per_all_assignments_f
16924 WHERE assignment_id = p_assignment_id
16925 AND p_effective_date BETWEEN effective_start_date
16926 AND effective_end_date;
16927
16928 CURSOR c_asg_grade_step(p_grade_id IN NUMBER
16929 ,p_spinal_point_id IN NUMBER
16930 ) IS
16931 SELECT pspp.placement_id
16932 FROM per_spinal_point_placements_f pspp
16933 ,per_grade_spines_f pgs
16934 ,per_spinal_point_steps_f psps
16935 WHERE pspp.assignment_id = p_assignment_id
16936 AND p_effective_date BETWEEN pspp.effective_start_date
16937 AND pspp.effective_end_date
16938 AND pgs.parent_spine_id = pspp.parent_spine_id
16939 AND pgs.grade_id = p_grade_id
16940 AND p_effective_date BETWEEN pgs.effective_start_Date
16941 AND pgs.effective_end_Date
16942 AND psps.grade_spine_id = pgs.grade_spine_id
16943 AND psps.spinal_point_id = p_spinal_point_id
16944 AND p_effective_date BETWEEN psps.effective_start_Date
16945 AND psps.effective_end_Date
16946 AND psps.step_id = pspp.step_id;
16947
16948
16949 l_grade_rule c_grade_rule%ROWTYPE;
16950 l_asg_grade c_asg_grade%ROWTYPE;
16951 l_asg_grade_step c_asg_grade_step%ROWTYPE;
16952
16953 l_asg_affected BOOLEAN := FALSE;
16954
16955 l_proc_name VARCHAR2(61):=
16956 g_proc_name||'chk_grd_change_affects_asg';
16957
16958 BEGIN -- chk_grd_change_affects_asg
16959
16960 debug_enter(l_proc_name);
16961
16962 OPEN c_grade_rule;
16963 FETCH c_grade_rule INTO l_grade_rule;
16964 CLOSE c_grade_rule;
16965
16966 -- Now get the grade id, we need it anyway
16967 OPEN c_asg_grade;
16968 FETCH c_asg_grade INTO l_asg_grade;
16969 CLOSE c_asg_grade;
16970
16971 IF l_grade_rule.rate_type = 'G' THEN -- Grade Rate
16972
16973 debug('Rate Type is Grade Rate, id :'||l_grade_rule.grade_or_spinal_point_id, 10);
16974
16975 -- Grade rule grade id same as asg grade id
16976 IF l_grade_rule.grade_or_spinal_point_id = l_asg_grade.grade_id THEN
16977 debug('Setting l_asg_affected to TRUE', 20);
16978 l_asg_affected := TRUE;
16979 END IF;
16980
16981 ELSIF l_grade_rule.rate_type = 'SP' THEN
16982
16983 debug('Rate Type is Spinal Point, id :'||l_grade_rule.grade_or_spinal_point_id, 30);
16984
16985 OPEN c_asg_grade_step(p_grade_id => l_asg_grade.grade_id
16986 ,p_spinal_point_id => l_grade_rule.grade_or_spinal_point_id
16987 );
16988 FETCH c_asg_grade_step INTO l_asg_grade_step;
16989
16990 IF c_asg_grade_step%FOUND THEN
16991 debug('Setting l_asg_affected to TRUE', 40);
16992 l_asg_affected := TRUE;
16993 END IF;
16994
16995 CLOSE c_asg_grade_step;
16996
16997 ELSE -- Unrecognised Rate_Type, will return FALSE
16998 debug('Unrecognized Rate Type :'||l_grade_rule.rate_type, 50);
16999 l_asg_affected := FALSE;
17000 END IF; -- l_grade_rule.rate_type =
17001
17002 IF l_asg_affected -- by Grade change
17003 THEN -- check if asg also affected by rate change
17004
17005 IF NOT chk_rate_change_affects_asg
17006 (p_assignment_id => p_assignment_id
17007 ,p_rate_id => l_grade_rule.rate_id
17008 ,p_effective_date => p_effective_date
17009 ) THEN
17010 l_asg_affected := FALSE;
17011 END IF;
17012 --
17013 ELSE
17014 debug('Assignment Affected :FALSE', 60);
17015 END IF;
17016
17017 debug_exit(l_proc_name);
17018
17019 RETURN l_asg_affected;
17020
17021 EXCEPTION
17022 WHEN OTHERS THEN
17023 debug('Other exception :'||SQLCODE||' '||SQLERRM, 70);
17024 debug_exit(l_proc_name);
17025 RAISE;
17026 END; -- chk_grd_change_affects_asg
17027
17028 --
17029 --
17030 --
17031 --
17032 --
17033 -- The procedure raises a warning if there is a full time
17034 -- teaching assignments.
17035 -- Coz cross person reporting is not enabled, so there may be
17036 -- another teaching assignment for this person
17037
17038 PROCEDURE warn_anthr_tchr_asg (p_assignment_id IN NUMBER)
17039 IS
17040 l_proc_name VARCHAR2(61):= 'warn_anthr_tchr_asg';
17041 l_error NUMBER;
17042
17043 BEGIN
17044 debug_enter(l_proc_name);
17045
17046 -- Raise a warning if Cross person enable = N and
17047 -- there are multiple person records.
17048 IF (g_cross_per_enabled = 'N' AND g_person_count > 0) THEN
17049 l_error := pqp_gb_tp_extract_functions.raise_extract_warning
17050 (p_assignment_id => p_assignment_id
17051 ,p_error_text => 'BEN_94022_TP1_ANTHR_TCHR_ASG'
17052 ,p_error_number => 94022
17053 );
17054 END IF ;
17055
17056 debug_exit(l_proc_name);
17057 EXCEPTION
17058 WHEN OTHERS THEN
17059 debug_exit(' Others in '||l_proc_name);
17060 RAISE;
17061 END warn_anthr_tchr_asg ;
17062 --
17063
17064 PROCEDURE fetch_allow_eles_frm_udt
17065 (p_assignment_id IN NUMBER
17066 ,p_effective_date IN DATE
17067 )
17068 IS
17069 --
17070
17071 CURSOR csr_get_lon_user_rows (c_udt_id NUMBER)
17072 IS
17073 SELECT row_low_range_or_name
17074 FROM pay_user_rows_f
17075 WHERE user_table_id = c_udt_id
17076 AND p_effective_date BETWEEN effective_start_date
17077 AND effective_end_date
17078 AND row_low_range_or_name in ('LARP Inner Allowance','LARP Outer Allowance',
17079 'LARP Fringe Allowance','LARP Inner Plus Inner Supplement'
17080 )
17081 ORDER BY display_sequence;
17082
17083 CURSOR csr_get_spl_user_rows (c_udt_id NUMBER)
17084 IS
17085 SELECT row_low_range_or_name
17086 FROM pay_user_rows_f
17087 WHERE user_table_id = c_udt_id
17088 AND p_effective_date BETWEEN effective_start_date
17089 AND effective_end_date
17090 AND row_low_range_or_name in ('SPAP Lower Rate','SPAP Higher Rate',
17091 'SPAP Special Needs Lower Rate','SPAP Special Needs Higher Rate'
17092 )
17093 ORDER BY display_sequence;
17094
17095 l_proc_name VARCHAR2 (80) := g_proc_name
17096 || 'fetch_allow_eles_frm_udt';
17097 l_proc_step NUMBER;
17098 l_element_type_id NUMBER;
17099 l_tab_mng_aln_eles t_allowance_eles;
17100 l_tab_ret_aln_eles t_allowance_eles;
17101
17102 -- 115.49 : TLR
17103 l_tab_tlr_aln_eles t_allowance_eles;
17104
17105 l_user_row_name pay_user_rows_f.row_low_range_or_name%TYPE;
17106 l_udt_name pay_user_tables.user_table_name%TYPE :=
17107 'PQP_GB_TP_TYPE1_EXTRACT_DEFINITIONS';
17108 l_return NUMBER;
17109 l_udt_id NUMBER;
17110 l_user_value pay_user_column_instances_f.value%TYPE;
17111 l_error_msg VARCHAR2(2000);
17112
17113 -- RET1.a : new variables to store element_type_extra_info_id
17114 l_element_type_extra_info_id pay_element_type_extra_info.element_type_extra_info_id%type;
17115 l_retval NUMBER;
17116 l_allow_code VARCHAR2(1);
17117 --
17118 --
17119 BEGIN
17120 --
17121 debug_enter(l_proc_name);
17122 debug('p_effective_date: '|| p_effective_date);
17123
17124
17125
17126 -- Get UDT ID
17127 l_udt_id := pqp_gb_tp_pension_extracts.get_udt_id
17128 (p_udt_name => l_udt_name);
17129
17130 -- Get the user rows information for this UDT
17131 --
17132 IF l_udt_id IS NOT NULL THEN
17133
17134 debug(l_proc_name, 10);
17135
17136 --
17137 OPEN csr_get_lon_user_rows (l_udt_id);
17138 LOOP
17139 FETCH csr_get_lon_user_rows INTO l_user_row_name;
17140 EXIT WHEN csr_get_lon_user_rows%NOTFOUND;
17141
17142 -- Get the user value for this row if one exist
17143 -- for each type of allowance and store it in their
17144 -- respective collections
17145 debug('User Row Name: '
17146 || l_user_row_name,20);
17147 debug('User Column Name: Management Allowance Element Type');
17148 l_return := pqp_utilities.pqp_gb_get_table_value
17149 (p_business_group_id => g_business_group_id
17150 ,p_effective_date => p_effective_date
17151 ,p_table_name => l_udt_name
17152 ,p_column_name => 'Attribute Location Type'
17153 ,p_row_name => l_user_row_name
17154 ,p_value => l_user_value
17155 ,p_error_msg => l_error_msg
17156 );
17157 IF upper(l_user_value) in ('G','GRADE') THEN
17158 g_lon_all_grd_src := 'Y';
17159 g_tab_lon_aln_eles.DELETE;
17160 EXIT;
17161 END IF;
17162 IF upper(l_user_value) in ('E','ELEMENT','R','RATE TYPE') THEN
17163 l_return := pqp_utilities.pqp_gb_get_table_value
17164 (p_business_group_id => g_business_group_id
17165 ,p_effective_date => p_effective_date
17166 ,p_table_name => l_udt_name
17167 ,p_column_name => 'Allowance Code'
17168 ,p_row_name => l_user_row_name
17169 ,p_value => l_allow_code
17170 ,p_error_msg => l_error_msg
17171 );
17172 END IF;
17173
17174 IF upper(l_user_value) in ('E','ELEMENT') THEN
17175
17176 l_element_type_id := pqp_gb_tp_pension_extracts.get_allow_ele_info
17177 (p_assignment_id => p_assignment_id
17178 ,p_effective_date => p_effective_date
17179 ,p_table_name => l_udt_name
17180 ,p_row_name => l_user_row_name
17181 ,p_column_name => 'Attribute Location Qualifier 1'
17182 );
17183 debug('l_element_type_id : '|| to_char(l_element_type_id));
17184
17185 IF l_element_type_id IS NOT NULL
17186 THEN
17187 --
17188 -- Store it in the management allowance collection
17189 l_tab_mng_aln_eles (l_element_type_id).salary_scale_code
17190 := l_allow_code;
17191 l_tab_mng_aln_eles (l_element_type_id).element_type_id
17192 := l_element_type_id;
17193 END IF;
17194 ELSIF upper(l_user_value) in ('R','RATE TYPE') THEN-- element type id is null
17195 -- Check for rate type
17196 debug(l_proc_name, 50);
17197
17198 l_tab_mng_aln_eles := pqp_gb_tp_pension_extracts.get_allow_code_rt_ele_info
17199 (p_assignment_id => p_assignment_id
17200 ,p_effective_date => p_effective_date
17201 ,p_table_name => l_udt_name
17202 ,p_row_name => l_user_row_name
17203 ,p_column_name => 'Attribute Location Qualifier 1'
17204 ,p_tab_aln_eles => l_tab_mng_aln_eles
17205 ,p_allowance_code => l_allow_code
17206 );
17207 END IF; -- End if of element type id not null check ...
17208 -- end of code for "Management Allowance Element Type" --
17209 END LOOP;
17210 CLOSE csr_get_lon_user_rows;
17211
17212 debug('Managment collection count: '||TO_CHAR(l_tab_mng_aln_eles.COUNT));
17213 debug('Retention collection count: '||TO_CHAR(l_tab_ret_aln_eles.COUNT));
17214
17215 g_tab_lon_aln_eles := l_tab_mng_aln_eles;
17216 l_tab_mng_aln_eles.DELETE;
17217
17218 OPEN csr_get_spl_user_rows (l_udt_id);
17219 LOOP
17220 FETCH csr_get_spl_user_rows INTO l_user_row_name;
17221 EXIT WHEN csr_get_spl_user_rows%NOTFOUND;
17222
17223 -- Get the user value for this row if one exist
17224 -- for each type of allowance and store it in their
17225 -- respective collections
17226 debug('User Row Name: '
17227 || l_user_row_name,20);
17228 debug('User Column Name: Management Allowance Element Type');
17229 l_return := pqp_utilities.pqp_gb_get_table_value
17230 (p_business_group_id => g_business_group_id
17231 ,p_effective_date => p_effective_date
17232 ,p_table_name => l_udt_name
17233 ,p_column_name => 'Attribute Location Type'
17234 ,p_row_name => l_user_row_name
17235 ,p_value => l_user_value
17236 ,p_error_msg => l_error_msg
17237 );
17238
17239 IF upper(l_user_value) in ('G','GRADE') THEN
17240 g_spl_all_grd_src := 'Y';
17241 g_tab_spl_aln_eles.DELETE;
17242 EXIT;
17243 END IF;
17244
17245 IF upper(l_user_value) in ('E','ELEMENT','R','RATE TYPE') THEN
17246 l_return := pqp_utilities.pqp_gb_get_table_value
17247 (p_business_group_id => g_business_group_id
17248 ,p_effective_date => p_effective_date
17249 ,p_table_name => l_udt_name
17250 ,p_column_name => 'Allowance Code'
17251 ,p_row_name => l_user_row_name
17252 ,p_value => l_allow_code
17253 ,p_error_msg => l_error_msg
17254 );
17255 END IF;
17256
17257 IF upper(l_user_value) in ('E','ELEMENT') THEN
17258
17259 l_element_type_id := pqp_gb_tp_pension_extracts.get_allow_ele_info
17260 (p_assignment_id => p_assignment_id
17261 ,p_effective_date => p_effective_date
17262 ,p_table_name => l_udt_name
17263 ,p_row_name => l_user_row_name
17264 ,p_column_name => 'Attribute Location Qualifier 1'
17265 );
17266 debug('l_element_type_id : '|| to_char(l_element_type_id));
17267
17268 IF l_element_type_id IS NOT NULL
17269 THEN
17270 --
17271 -- Store it in the management allowance collection
17272 l_tab_mng_aln_eles (l_element_type_id).salary_scale_code
17273 := l_allow_code;
17274 l_tab_mng_aln_eles (l_element_type_id).element_type_id
17275 := l_element_type_id;
17276 END IF;
17277 ELSIF upper(l_user_value) in ('R','RATE TYPE') THEN-- element type id is null
17278 -- Check for rate type
17279 debug(l_proc_name, 50);
17280
17281 l_tab_mng_aln_eles := pqp_gb_tp_pension_extracts.get_allow_code_rt_ele_info
17282 (p_assignment_id => p_assignment_id
17283 ,p_effective_date => p_effective_date
17284 ,p_table_name => l_udt_name
17285 ,p_row_name => l_user_row_name
17286 ,p_column_name => 'Attribute Location Qualifier 1'
17287 ,p_tab_aln_eles => l_tab_mng_aln_eles
17288 ,p_allowance_code => l_allow_code
17289 );
17290 END IF; -- End if of element type id not null check ...
17291 -- end of code for "Management Allowance Element Type" --
17292 END LOOP;
17293 CLOSE csr_get_spl_user_rows;
17294
17295 END IF; -- End if of udt id is not null check ...
17296
17297 debug('Managment collection count: '||TO_CHAR(l_tab_mng_aln_eles.COUNT));
17298 debug('Retention collection count: '||TO_CHAR(l_tab_ret_aln_eles.COUNT));
17299
17300 g_tab_spl_aln_eles := l_tab_mng_aln_eles;
17301 debug_exit(l_proc_name);
17302 --
17303 END fetch_allow_eles_frm_udt;
17304 --
17305 Function Get_Allowance_Code_New ( p_assignment_id in number
17306 ,p_effective_date in date
17307 ,p_allowance_type in varchar2 ) Return varchar2 Is
17308 CURSOR csr_ele_entry_exists
17309 (c_assignment_id NUMBER
17310 ,c_element_type_id NUMBER
17311 ,c_effective_date DATE
17312 )
17313 IS
17314 SELECT 'X'
17315 FROM pay_element_entries_f pee
17316 ,pay_element_links_f pel
17317 WHERE pee.assignment_id = c_assignment_id
17318 AND pee.entry_type = 'E'
17319 AND pee.element_link_id = pel.element_link_id
17320 AND c_effective_date BETWEEN pee.effective_start_date
17321 AND pee.effective_end_date
17322 AND pel.element_type_id = c_element_type_id
17323 AND c_effective_date BETWEEN pel.effective_start_date
17324 AND pel.effective_end_date;
17325
17326 CURSOR csr_grade_val(c_assignment_id NUMBER,
17327 c_effective_date DATE,
17328 c_allowance_type varchar2
17329 ) IS
17330 SELECT decode(c_allowance_type,'LONDON_ALLOWANCE_RULE',information6,
17331 'SPECIAL_ALLOWANCE_RULE',information7
17332 ) indicator
17333 FROM per_grades pgr,per_all_assignments_f paaf
17334 WHERE paaf.assignment_id = c_assignment_id
17335 AND c_effective_date BETWEEN paaf.effective_start_date AND paaf.effective_end_date
17336 AND paaf.grade_id = pgr.grade_id
17337 AND pgr.information_category = 'GB_PQP_PENSERV_GRADE_INFO';
17338
17339 l_tab_allowances t_allowance_eles;
17340 l_return_value varchar2(1);
17341 l_exists varchar2(1);
17342 i NUMBER;
17343 l_error_value number;
17344 l_count number;
17345 l_proc_name varchar2(60) := g_proc_name || 'Get_Allowance_Code_New';
17346
17347 Begin
17348 -- hr_utility.set_location('Entering: '||l_proc_name, 5);
17349 debug_enter(l_proc_name);
17350 debug('p_allowance_type :'||p_allowance_type, 10);
17351
17352
17353
17354 IF p_allowance_type = 'LONDON_ALLOWANCE_RULE' THEN
17355 IF g_lon_all_grd_src = 'Y' THEN
17356 NULL;
17357 ELSE
17358 l_tab_allowances := g_tab_lon_aln_eles;
17359 END IF;
17360 OPEN csr_grade_val(p_assignment_id,p_effective_date,p_allowance_type);
17361 FETCH csr_grade_val INTO l_return_value;
17362 CLOSE csr_grade_val;
17363 IF l_return_value IS NOT NULL THEN
17364 return l_return_value;
17365 END IF;
17366 ELSIF p_allowance_type = 'SPECIAL_ALLOWANCE_RULE' THEN
17367 IF g_spl_all_grd_src = 'Y' THEN
17368 NULL;
17369 ELSE
17370 l_tab_allowances := g_tab_spl_aln_eles;
17371 END IF;
17372 OPEN csr_grade_val(p_assignment_id,p_effective_date,p_allowance_type);
17373 FETCH csr_grade_val INTO l_return_value;
17374 CLOSE csr_grade_val;
17375 IF l_return_value IS NOT NULL THEN
17376 return l_return_value;
17377 END IF;
17378 ELSE
17379 l_error_value := pqp_gb_tp_extract_functions.raise_extract_error
17380 (p_business_group_id => g_business_group_id
17381 ,p_assignment_id => p_assignment_id
17382 ,p_error_text =>'BEN_93024_EXT_TP1_INVALID_ALOW'
17383 ,p_error_number => 93024 );
17384 END IF;
17385
17386
17387 i := l_tab_allowances.FIRST;
17388 l_count := 1; -- initialize the lop counter..
17389
17390 WHILE i IS NOT NULL
17391 LOOP
17392 OPEN csr_ele_entry_exists (p_assignment_id
17393 ,l_tab_allowances(i).element_type_id
17394 ,p_effective_date
17395 );
17396 FETCH csr_ele_entry_exists INTO l_exists;
17397 IF csr_ele_entry_exists%FOUND THEN
17398 debug('Management Element Type: '||TO_CHAR(i), 160+l_count/100);
17399 l_return_value
17400 := TO_CHAR(l_tab_allowances(i).salary_scale_code);
17401 CLOSE csr_ele_entry_exists;
17402 EXIT;
17403 END IF; -- End if of row found check ...
17404 CLOSE csr_ele_entry_exists;
17405 i := l_tab_allowances.NEXT(i);
17406 l_count := l_count + 1;
17407 END LOOP;
17408 debug(l_proc_name, 90);
17409
17410
17411 Return l_return_value;
17412 EXCEPTION
17413 WHEN OTHERS THEN
17414 debug_exit(' Others in '||l_proc_name);
17415 RAISE;
17416 End Get_Allowance_Code_New;
17417
17418 END pqp_gb_t1_pension_extracts;