1 package body PER_ZA_PTO_ACCRUAL_PERIOD as
2 /* $Header: perzaapl.pkb 120.5.12010000.2 2009/07/21 07:50:23 rbabla ship $ */
3 /* ======================================================================
4 REM Change List:
5 REM ------------
6 REM
7 REM Name Date Version Bug Text
8 REM -------------- ---------- ------- ------- ------------------------------------+
9 REM R. Kingham 15-MAR-00 110.0 Initial Version
10 REM J.N. Louw 24-Aug-00 115.0 Updated for ZAPatch11i.01
11 REM L.Kloppers 21-Dec-00 115.1 Put 'create...' on one line
12 REM P.Vaish 07-JUL-02 115.2 Changed to calculate currect
13 REM PTO Carry Over as per Legislative Rules.
14 REM P.Vaish 15-JUL-02 115.3 Changed to calculate the
15 REM PTO Carry Over for each period correctly.
16 REM V.Kannan 17-MAR-03 115.4 2848607 Removed the rounding of l_Accrual_Rate in
17 REM za_pto_annleave_period_loop,which caused the
18 REM number of days accrued per Period inaccurate.
19 REM R.Pahune 14-Aug-03 115.5 Added Procedure
20 REM ZA_PTO_CARRYOVER_RESI_VALUE
21 REM for the bug no 2932073
22 REM if the carry over is -ve made it 0
23 REM along with earlier ZA specific
24 REM requirements. (code from version
25 REM 115.20.1158.2 by lklopper)
26 REM A. Mahanty 05-MAY-05 115.7 4293298 Modified procedure ZA_PTO_CARRYOVER_RESI_VALUE
27 REM to have correct carryover and
28 REM net entitlement value when there is
29 REM negative net entitlement.
30 REM Kaladhaur P 09-MAR-06 115.8 5043294 Modified procedure ZA_PTO_SICKLEAVE_PERIOD_LOOP
31 REM to have correct Total Accrued Sick Leave.
32 REM A. Mahanty 22-SEP-06 115.9 Modified the procedure ZA_PTO_CARRYOVER_RESI_VALUE.
33 REM The other contributions(leave adjustments) need to
34 REM be subtracted before the residual value is calculated.
35 REM The adjustments in the current accrual cycle must not
36 REM be forfeited.
37 REM R. Babla 26-NOV-07 115.12 6617789 Modified function ZA_PTO_SICKLEAVE_PERIOD_LOOP to
38 REM calculate the accrual of 1 for 26 working days for
39 REM employee's first six months of employment.
40 ==============================================================================*/
41
42 /* ======================================================================
43 Name : ZA_PTO_ANNLEAVE_PERIOD_LOOP
44 Purpose : This function is called by the ZA_PTO_ANNUAL_LEAVE_MONTHLY_ACCRUAL
45 formula, and replaces the Sub-Accrual formula which calculated
46 total PTO accrued per period.
47 Returns : Total Accrued entitlement
48 ======================================================================*/
49 function ZA_PTO_ANNLEAVE_PERIOD_LOOP (p_Assignment_ID IN Number
50 ,p_Plan_ID IN Number
51 ,p_Payroll_ID IN Number
52 ,p_calculation_date IN Date)
53 return number is
54
55 l_CSDate date;
56 l_Period_SD date;
57 l_Period_ED date;
58 l_Last_Period_SD date;
59 l_Last_Period_ED date;
60 l_Beginning_Calc_Year_SD date;
61 l_Total_Accrued_PTO number := 0;
62 l_Pay_Periods_Year number;
63 l_Period_Accrued_PTO number;
64 l_Accrual_Rate number;
65 l_Period_Others number;
66 l_Amount_Over_Ceiling number;
67 l_Annual_Rate number := 0;
68 l_Upper_Limit number := 0;
69 l_Ceiling number := 0;
70 l_Years_Service number;
71 l_Absence number;
72 l_Carryover number;
73 l_Other number;
74 l_Continue_Processing_Flag boolean := true;
75 l_Error number;
76 l_Acc_Freq char;
77 l_Acc_Mult number;
78 l_Net_PTO number;
79 /* - P.Vaish - Defined for Bug No. - 2266289 - */
80 l_calculation_year date;
81 l_last_start_period date;
82 l_last_end_period date;
83 l_six_month_current date;
84 l_Left_Over number := 0;
85 l_last_period date;
86 l_anniversary_date date;
87 l_diff number := 0;
88 begin
89 /* Get global variables. */
90 l_Last_Period_SD := per_formula_functions.get_date('LAST_PERIOD_SD');
91 l_Last_Period_ED := per_formula_functions.get_date('LAST_PERIOD_ED');
92 l_CSDate := per_formula_functions.get_date('CONTINUOUS_SERVICE_DATE');
93 l_Beginning_Calc_Year_SD := per_formula_functions.get_date('BEGINNING_OF_CALCULATION_YEAR');
94 l_Pay_Periods_Year := per_formula_functions.get_number('PAYROLL_YEAR_NUMBER_OF_PERIODS');
95 l_Acc_Freq := per_formula_functions.get_text('ACCRUING_FREQUENCY');
96 l_Acc_Mult := per_formula_functions.get_number('ACCRUING_MULTIPLIER');
97
98 hr_utility.set_location('ZA_PTO_ANNLEAVE_PERIOD_LOOP', 26);
99
100 /* - P.Vaish - Defined for Bug No. - 2266289 - */
101 l_diff := LAST_DAY(l_Last_Period_ED) - l_Last_Period_ED + 1;
102
103 IF (((l_Acc_Freq = 'W') AND (l_diff < 7))
104 OR (((l_Acc_Freq = 'M') OR (l_Acc_Freq = 'D')) AND (l_diff <= l_Acc_Mult))) THEN
105 l_last_period := l_Last_Period_ED + l_diff;
106 ELSE
107 l_last_period := l_Last_Period_ED;
108 END IF;
109
110 IF (months_between(l_Last_Period,l_Beginning_Calc_Year_SD) >= 12 ) THEN
111 hr_utility.trace('Setting l_calculation_year to l_Beginning_Calc_Year_SD + 1 ');
112 l_calculation_year := add_months(l_Beginning_Calc_Year_SD,12);
113 ELSE
114 hr_utility.trace('Setting l_calculation_year to l_Beginning_Calc_Year_SD');
115 l_calculation_year := l_Beginning_Calc_Year_SD;
116 END IF;
117
118 IF to_char(l_CSDate,'DDMM') = '2902' THEN
119 l_last_start_period := to_date('0103' || to_char(l_calculation_year,'YYYY'),'DDMMYYYY');
120 ELSE
121 l_last_start_period := to_date(to_char(l_CSDate,'DDMM') || to_char(l_calculation_year,'YYYY'),'DDMMYYYY');
122 END IF;
123
124 l_anniversary_date := l_last_start_period;
125
126 IF l_last_start_period > l_calculation_year THEN
127 l_last_end_period := add_months(l_last_start_period,-12);
128 l_last_start_period := add_months(l_last_start_period,-18);
129 l_six_month_current := add_months(l_last_end_period,6);
130 ELSE
131 l_last_end_period := l_last_start_period;
132 l_last_start_period := add_months(l_last_start_period,-6);
133 l_six_month_current := add_months(l_last_end_period,6);
134 END IF;
135
136 l_Years_Service := Floor(Months_Between(l_calculation_year,l_CSDate) / 12);
137
138 IF ((l_Years_Service > 0) and (l_six_month_current >= l_Last_Period_ED)) THEN
139 hr_utility.trace('Before Six Month');
140 l_Left_Over := per_accrual_calc_functions.GET_CARRY_OVER(p_Assignment_id, p_Plan_id, (l_last_end_period + 1), l_last_start_period) +
141 per_accrual_calc_functions.GET_OTHER_NET_CONTRIBUTION(p_Assignment_id, p_Plan_id, (l_last_end_period + 1), l_last_start_period) -
142 per_accrual_calc_functions.GET_ABSENCE(p_Assignment_id, p_Plan_id, l_last_end_period, l_last_start_period);
143
144 IF l_Left_Over < 0 THEN
145 l_Left_Over := 0;
146 END IF;
147
148 l_diff := p_calculation_date - l_anniversary_date;
149
150 IF (l_Left_Over > 0) THEN
151 IF (l_Acc_Freq = 'M') THEN
152 IF ((l_diff >= 0) AND (l_diff < (add_months(l_anniversary_date,l_Acc_Mult) - l_anniversary_date))) THEN
153 l_Continue_Processing_Flag := FALSE;
154 END IF;
155 ELSIF (l_Acc_Freq = 'W') THEN
156 IF ((l_diff >= 0) AND (l_diff < (7 * l_Acc_Mult))) THEN
157 l_Continue_Processing_Flag := FALSE;
158 END IF;
159 END IF;
160 END IF;
161
162 IF ((to_char(p_calculation_date,'DDMM') = to_char(l_CSDate - 1,'DDMM')) AND NOT l_Continue_Processing_Flag) THEN
163 l_Continue_Processing_Flag := TRUE;
164 END IF;
165 ELSIF ((l_Years_Service > 0) and (l_six_month_current < l_Last_Period_ED)) THEN
166 hr_utility.trace('After Six Month');
167 IF (per_utility_functions.get_accrual_band(p_Plan_ID, l_Years_Service) = 0 ) THEN
168 l_Left_Over := per_formula_functions.get_number('MAX_CARRY_OVER');
169 l_Annual_Rate := 0;
170 l_Upper_Limit := 0;
171 l_Ceiling := 0;
172 ELSE
173 l_Left_Over := 0;
174 END IF;
175 ELSE
176 l_Left_Over := 0;
177 END IF;
178 /**/
179
180 hr_utility.set_location('Before LOOP', 27);
181
182 while l_Continue_Processing_Flag loop
183 l_Period_SD := per_formula_functions.get_date('PERIOD_SD');
184 l_Period_ED := per_formula_functions.get_date('PERIOD_ED');
185 l_Years_Service := Floor(Months_Between(l_Period_ED,l_CSDate) / 12);
186
187 /* Accrual bands based on length of service, but could also use grades */
188 if l_Upper_Limit = 0
189 or (l_Years_service >= l_Upper_Limit) then
190 if (per_utility_functions.get_accrual_band(p_Plan_ID, l_Years_Service) = 0 ) then
191 l_Annual_Rate := per_formula_functions.get_number('ANNUAL_RATE');
192 l_Upper_Limit := per_formula_functions.get_number('UPPER_LIMIT');
193 l_Ceiling := per_formula_functions.get_number('CEILING');
194 else
195 exit;
196 end if;
197 end if;
198 --Bug:2848607.
199 l_Accrual_Rate := l_Annual_Rate / l_Pay_Periods_Year;
200
201 l_Period_Accrued_PTO := l_Accrual_Rate;
202
203 /* Extract any absence, carry over etc for the year in question */
204 l_Absence := per_accrual_calc_functions.GET_ABSENCE(p_Assignment_id, p_Plan_id, l_Period_ED, l_Beginning_Calc_Year_SD);
205
206 /* - P.Vaish - Set for Bug No. - 2266289 - */
207 l_CarryOver := l_Left_Over;
208 l_Other := per_accrual_calc_functions.GET_OTHER_NET_CONTRIBUTION(p_Assignment_id, p_Plan_id, l_Period_ED, l_Beginning_Calc_Year_SD);
209 l_Period_Others := l_CarryOver + l_Other - l_Absence;
210 l_Net_PTO := l_Total_Accrued_PTO + l_Period_Accrued_PTO + l_Period_Others;
211
212 /* Only accrue if PTO < CEILING */
213 if l_Ceiling > 0 then
214 if ((l_Net_PTO - l_Ceiling) > l_Left_Over) then
215 l_Amount_Over_Ceiling := l_Net_PTO - l_Ceiling - l_Left_Over;
216 if l_Amount_Over_Ceiling > l_Period_Accrued_PTO then
217 l_Period_Accrued_PTO := 0;
218 else
219 l_Period_Accrued_PTO := l_Period_Accrued_PTO - l_Amount_Over_Ceiling;
220 end if;
221 end if;
222 end if;
223 l_Total_Accrued_PTO := l_Total_Accrued_PTO + l_Period_Accrued_PTO;
224
225 /* End loop if final period and set globals to next payroll period */
226 if l_Period_SD >= l_Last_Period_SD then
227 l_Continue_Processing_Flag := false;
228 else
229 l_Period_ED := l_Period_ED + 1;
230 l_error := per_utility_functions.GET_PERIOD_DATES( l_Period_ED
231 ,l_Acc_Freq
232 ,l_Beginning_Calc_Year_SD
233 ,l_Acc_Mult);
234 l_error := per_formula_functions.set_date('PERIOD_SD',
235 per_formula_functions.get_date('PERIOD_START_DATE'));
236 l_error := per_formula_functions.set_date('PERIOD_ED',
237 per_formula_functions.get_date('PERIOD_END_DATE'));
238 l_Continue_Processing_Flag := true;
239 end if;
240 end loop;
241
242 l_error := per_formula_functions.set_number('TOTAL_ACCRUED_PTO', l_Total_Accrued_PTO);
243
244 Return l_Total_Accrued_PTO;
245
246 end ZA_PTO_ANNLEAVE_PERIOD_LOOP;
247 --
248 /* ======================================================================
249 Name : ZA_PTO_SICKLEAVE_PERIOD_LOOP
250 Purpose : This function is called by the ZA_PTO_SICK_LEAVE_ACCRUAL
251 formula, and replaces the Sub-Accrual formula which calculated
252 total Sick PTO accrued per period.
253 Returns : Total Sick PTO Accrued entitlement
254 ======================================================================*/
255 function ZA_PTO_SICKLEAVE_PERIOD_LOOP (p_Assignment_ID IN Number
256 ,p_Plan_ID IN Number
257 ,p_Payroll_ID IN Number)
258 return number is
259 l_Beginning_Calc_Year_SD date;
260 l_CSDate date;
261 l_Period_SD date;
262 l_Period_ED date;
263 l_Last_Period_SD date;
264 l_Last_Period_ED date;
265 l_Total_Accrued_PTO number := 0;
266 l_Continue_Processing_Flag boolean := true;
267 l_Accrual_Rate number;
268 l_Error number;
269 l_Acc_Freq char;
270 l_Acc_Mult number;
271 l_daysoff number;
272 l_proc varchar2(80) := 'PER_ZA_PTO_ACCRUAL_PERIOD.ZA_PTO_SICKLEAVE_PERIOD_LOOP';
273 l_calc_date date;
274 l_totdays number:=0;
275 l_daysoff1 number:=0;
276 l_month_PTO number:=0;
277 l_prev_period_SD date;
278 l_prev_period_ED date;
279
280 begin
281 l_Beginning_Calc_Year_SD := per_formula_functions.get_date('BEGINNING_OF_CALCULATION_YEAR');
282 l_Last_Period_SD := per_formula_functions.get_date('LAST_PERIOD_SD');
283 l_Last_Period_ED := per_formula_functions.get_date('LAST_PERIOD_ED');
284 l_CSDate := per_formula_functions.get_date('CONTINUOUS_SERVICE_DATE');
285 -- l_Accrual_Rate := per_formula_functions.get_number('ACCRUAL_RATE');
286 l_Accrual_Rate := per_formula_functions.get_number('ZA_SICK_LEAVE_ACCRUAL_RATE');
287 l_Acc_Freq := per_formula_functions.get_text('ACCRUING_FREQUENCY');
288 l_Acc_Mult := per_formula_functions.get_number('ACCRUING_MULTIPLIER');
289 --Added for Bug 8192694
290 l_calc_date := per_formula_functions.get_date('CALC_DATE');
291
292 hr_utility.set_location(l_proc,5);
293 hr_utility.trace('l_Accrual_Rate: '||to_char(l_Accrual_Rate));
294
295 --Added for Bug 8192694
296 /* l_calc_date is populated only when SICK LEAVE ACCRUAL formulaes delivered through patch 8192694
297 is used. So if copy of previous formula is created, then it may lead to endless loop. Hence If condition
298 calculates 1 leave for 26 working days if this variable is set, else the employee will accrue a percentage
299 of a leave based on the days worked (previous logic)*/
300 IF l_calc_date IS NOT NULL then
301 while l_Continue_Processing_Flag loop
302 /*Get the first period start and end dates */
303 l_Period_SD := per_formula_functions.get_date('PERIOD_SD');
304 l_Period_ED := per_formula_functions.get_date('PERIOD_ED');
305
306 --Calculate the days off in the particular period
307 l_daysoff :=PER_ZA_ABS_DURATION.ZA_DAYSOFF(l_Period_SD,l_Period_ED);
308 hr_utility.trace('l_daysoff: '||to_char(l_daysoff));
309 --Calculate the total working days in the period
310 l_totdays :=((l_Period_ED - l_Period_SD)+1) - l_daysoff;
311
312 hr_utility.trace('l_totdays:'||to_char(l_totdays));
313 hr_utility.trace('l_Period_ED:'||to_char(l_Period_ED,'dd-mon-yyyy'));
314 hr_utility.trace('l_calc_date:'||to_char(l_calc_date,'dd-mon-yyyy'));
315
316 /* If the total working days are less than 26 in the particular period, then increase the period
317 end date and loop until total working days are 26*/
318 while l_totdays < 26
319 loop
320 l_Period_ED :=l_Period_ED + 1;
324 l_month_PTO:=0;
321 if l_Period_ED >l_calc_date then
322
323 l_Continue_Processing_Flag := false;
325 hr_utility.trace('l_Period_ED >=l_calc_date');
326 l_error := per_formula_functions.set_date('PERIOD_SD',
327 l_prev_period_SD);
328 l_error := per_formula_functions.set_date('PERIOD_ED',
329 l_prev_period_ED);
330 exit;
331 else
332 l_daysoff1:=PER_ZA_ABS_DURATION.ZA_DAYSOFF(l_Period_SD,l_Period_ED);
333 l_totdays :=((l_Period_ED - l_Period_SD)+1) - l_daysoff1;
334 hr_utility.set_location('l_Period_ED:'||to_char(l_Period_ED,'dd-mon-yyyy'),10);
335 hr_utility.set_location('l_Period_SD:'||to_char(l_Period_SD,'dd-mon-yyyy'),10);
336 hr_utility.set_location('l_daysoff1:'||to_char(l_daysoff1),10);
337 hr_utility.set_location('l_totdays:'||to_char(l_totdays),10);
338 l_Continue_Processing_Flag := true;
339 end if;
340 end loop;
341
342 /* If total working days are 26, then set the PERIOD_SD and PERIOD_ED to next period dates*/
343 if l_totdays=26 then
344 l_Period_ED := l_Period_ED + 1;
345 l_month_PTO:=1;
346 l_prev_period_SD:=l_Period_SD;
347 l_prev_period_ED:=l_Period_ED -1;
348 l_error := per_formula_functions.set_date('PERIOD_SD',
349 l_Period_ED);
350 l_error := per_formula_functions.set_date('PERIOD_ED',
351 l_Period_ED + 31);
352 end if;
353
354 l_Total_Accrued_PTO:=l_Total_Accrued_PTO+l_month_PTO;
355 hr_utility.set_location('l_month_PTO:'||to_char(l_month_PTO),11);
356 hr_utility.set_location('l_Total_Accrued_PTO:'||to_char(l_Total_Accrued_PTO),11);
357 end loop;
358 -- End changes for Bug 8192694
359 else
360 while l_Continue_Processing_Flag loop
361 l_Period_SD := per_formula_functions.get_date('PERIOD_SD');
362 l_Period_ED := per_formula_functions.get_date('PERIOD_ED');
363
364 -- Bug 5043294; Removed comments and unnessary if/else logic
365 -- Calculating the working days in the period
366 l_daysoff :=PER_ZA_ABS_DURATION.ZA_DAYSOFF(l_Period_SD,l_Period_ED);
367 hr_utility.trace('l_daysoff: '||to_char(l_daysoff));
368 l_Total_Accrued_PTO := round(l_Total_Accrued_PTO + (((l_Period_ED - l_Period_SD)+1) - l_daysoff)/l_Accrual_Rate , 2);
369
370 if l_Period_SD = l_Last_Period_SD then
371 l_Continue_Processing_Flag := false;
372 else
373 l_Period_ED := l_Period_ED + 1;
374 l_error := per_utility_functions.GET_PERIOD_DATES( l_Period_ED
375 ,l_Acc_Freq
376 ,l_Beginning_Calc_Year_SD
377 ,l_Acc_Mult);
378 l_error := per_formula_functions.set_date('PERIOD_SD',
379 per_formula_functions.get_date('PERIOD_START_DATE'));
380 l_error := per_formula_functions.set_date('PERIOD_ED',
381 per_formula_functions.get_date('PERIOD_END_DATE'));
382 l_Continue_Processing_Flag := true;
383
384 end if;
385 end loop;
386 END if;
387 l_error := per_formula_functions.set_number('TOTAL_ACCRUED_PTO', l_Total_Accrued_PTO);
388 Return l_Total_Accrued_PTO;
389
390 end ZA_PTO_SICKLEAVE_PERIOD_LOOP;
391 --
392 /* Start of 2932073 and 2878657 */
393
394 /* ======================================================================
395 Name : ZA_PTO_CARRYOVER_RESI_VALUE
396 Purpose : This function is called by the pto_carry_over_for_asg for the
397 South Africa Localisation ('ZA'). And it calculate the Carry
398 over value and residual value.
399 If the carry over is -ve it will be set to ZERO (0).
400 Returns : residula value and carry over value.
401 ======================================================================*/
402
403 procedure ZA_PTO_CARRYOVER_RESI_VALUE (p_assignment_id IN Number
404 ,p_plan_id IN Number
405 ,l_payroll_id IN Number
406 ,p_business_group_id IN Number
407 ,l_effective_date IN Date
408 ,l_total_accrual IN Number
409 ,l_net_entitlement IN number
410 ,l_max_carryover IN Number
411 ,l_residual OUT NOCOPY Number
412 ,l_carryover OUT NOCOPY Number) Is
413
414 -- Declaring local variables
415 l_start_date date;
416 l_end_date date;
417 l_dummy13 date;
418 l_net_entitlement2 number;
419 l_effective_date2 date;
420 l_total_accrual2 number;
421 l_proc varchar2(80) := 'PER_ZA_PTO_ACCRUAL_PERIOD.ZA_PTO_CARRYOVER_RESI_VALUE';
422 l_carryover_pre number; --Bug 4293298
423 l_Beginning_Calc_Year date;
424 l_other2 number;
425
426 Begin
427 /*l_effective_date2 := l_effective_date + 1;
428
429 -- Get total accrual on above date, it will only return non-zero where the
430 -- carry over runs for a ZA HRMS "Semi-annual" leave cycle anniversary
431 per_accrual_calc_functions.Get_Net_Accrual (
435 ,P_Business_Group_ID => p_business_group_id
432 P_Assignment_ID => p_assignment_id
433 ,P_Plan_ID => p_plan_id
434 ,P_Payroll_ID => l_payroll_id
436 ,P_Assignment_Action_Id => -1
437 ,P_Accrual_Start_Date => null
438 ,P_Accrual_Latest_Balance => null
439 ,P_Calculation_Date => l_effective_date2
440 ,P_Start_Date => l_dummy11
441 ,P_End_Date => l_dummy12
442 ,P_Accrual_End_Date => l_dummy13
443 ,P_Accrual => l_total_accrual2
444 ,P_Net_Entitlement => l_net_entitlement2
445 );
446
447 hr_utility.set_location(l_proc, 10);
448 hr_utility.trace('l_total_accrual2: '||to_char(l_total_accrual2));
449 hr_utility.trace('l_net_entitlement2: '||to_char(l_net_entitlement2)); */
450
451 /* The above code is commented so that to avoid the calculation
452 l_net_entitlement > l_max_carryover while fixing the bug 2932073 */
453 hr_utility.set_location(l_proc,5);
454 hr_utility.trace('p_assignment_id: '||to_char(p_assignment_id));
455 hr_utility.trace('p_plan_id: '||to_char(p_plan_id));
456 hr_utility.trace('l_payroll_id: '||to_char(l_payroll_id));
457 hr_utility.trace('l_effective_date: '||to_char(l_effective_date));
458 hr_utility.trace('l_total_accrual: '||to_char(l_total_accrual));
459 hr_utility.trace('l_net_entitlement: '||to_char(l_net_entitlement));
460 hr_utility.trace('l_max_carryover: '||to_char(l_max_carryover));
461
462 if l_net_entitlement <= l_max_carryover then
463 --
464 hr_utility.set_location(l_proc,10);
465 l_Beginning_Calc_Year := per_formula_functions.get_date('BEGINNING_OF_CALCULATION_YEAR');
466 --
467 IF (l_net_entitlement <= 0
468 AND to_char(l_effective_date + 1,'MM') <> to_char(l_Beginning_Calc_Year,'MM')
469 )THEN
470 -- Bug 4293298 in case net entitlement is -ve and the carryover process is not for the
471 -- end of the annual accrual period.
472 l_carryover := 0;
473 --get the carryover in the previous half of the accrual year
474 l_carryover_pre := per_accrual_calc_functions.get_carry_over
475 (
476 p_assignment_id => p_assignment_id,
477 p_plan_id => p_plan_id,
478 p_start_date => (l_effective_date-30),
479 p_calculation_date => (l_effective_date-1));
480 hr_utility.trace('l_carryover_pre: '||to_char(l_carryover_pre));
481 IF l_carryover_pre < 0 THEN
482 l_carryover := l_carryover_pre;
483 END IF ;
484 hr_utility.set_location(l_proc,50);
485 ELSE
486 l_carryover := round(l_net_entitlement, 3);
487 hr_utility.set_location(l_proc,60);
488 END IF;
489 --End for bug no 2932073 14-Aug-2003
490 l_residual := 0;
491 --
492 else
493 --
494 l_effective_date2 := l_effective_date + 1;
495
496 -- Get total accrual on above date, it will only return non-zero where the
497 -- carry over runs for a ZA HRMS "Semi-annual" leave cycle anniversary
498 per_accrual_calc_functions.Get_Net_Accrual (
499 P_Assignment_ID => p_assignment_id
500 ,P_Plan_ID => p_plan_id
501 ,P_Payroll_ID => l_payroll_id
502 ,P_Business_Group_ID => p_business_group_id
503 ,P_Assignment_Action_Id => -1
504 ,P_Accrual_Start_Date => null
505 ,P_Accrual_Latest_Balance => null
506 ,P_Calculation_Date => l_effective_date2
507 ,P_Start_Date => l_start_date
508 ,P_End_Date => l_end_date
509 ,P_Accrual_End_Date => l_dummy13
510 ,P_Accrual => l_total_accrual2
511 ,P_Net_Entitlement => l_net_entitlement2
512 );
513
514 -- The other contributions(leave adjustments) need to be subtracted before the residual value
515 -- is calculated. The adjustments in the current accrual cycle must not be forfeited.
516 -- Only for semi-annual run.
517 l_Beginning_Calc_Year := per_formula_functions.get_date('BEGINNING_OF_CALCULATION_YEAR');
518
519 IF to_char(l_effective_date + 1,'MM') <> to_char(l_Beginning_Calc_Year,'MM') THEN
520 hr_utility.set_location(l_proc, 15);
521 l_other2 := per_accrual_calc_functions.Get_Other_Net_Contribution(
522 P_Assignment_ID => p_assignment_id
523 ,P_Plan_ID => p_plan_id
524 ,p_start_date => l_start_date
525 ,p_calculation_date => l_end_date
526 );
527 ELSE
528 l_other2 := 0;
529 END IF;
530 --
531 hr_utility.set_location(l_proc, 20);
532 hr_utility.trace('l_total_accrual2: '||to_char(l_total_accrual2));
533 hr_utility.trace('l_net_entitlement2: '||to_char(l_net_entitlement2));
534 hr_utility.trace('l_other2: '||to_char(l_other2));
535 hr_utility.trace('l_start_date: '||to_char(l_start_date));
536 hr_utility.trace('l_end_date: '||to_char(l_end_date));
537 hr_utility.trace('l_Beginning_Calc_Year: '||to_char(l_Beginning_Calc_Year));
538 hr_utility.trace('l_effective_date: '||to_char(l_effective_date));
539 --
540 hr_utility.set_location(l_proc, 30);
541 l_carryover := round(l_max_carryover, 3);
542 l_residual := round((l_net_entitlement - l_max_carryover - l_total_accrual2 - l_other2), 3);
543 --Bug 4293298 if residual value is -ve ..then it is set to 0
544 IF l_residual < 0 THEN
545 l_residual := 0;
549 hr_utility.set_location(l_proc, 40);
546 END IF ;
547 --
548 end if;
550 hr_utility.trace('l_carryover: '||to_char(l_carryover));
551 hr_utility.trace('l_residual: '||to_char(l_residual));
552
553
554 End ZA_PTO_CARRYOVER_RESI_VALUE;
555
556 /* End of 2932073 and 2878657 */
557
558 --
559 end PER_ZA_PTO_ACCRUAL_PERIOD;