DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_PAY_PROPOSALS_POPULATE

Source


1 PACKAGE BODY PER_PAY_PROPOSALS_POPULATE AS
2 /* $Header: pepaprpo.pkb 120.1 2006/10/30 13:54:13 abhshriv noship $ */
3 g_package  	varchar2(33) := 'per_pay_proposals_populate.';
4 g_debug boolean := hr_utility.debug_enabled;
5 --------------------------------------------------------------------------
6 /* Procedure to get the grade that a person is on given the
7    date, assginment_id and business_group_id. If the person
8    has not had a grade set at that date then nothing is
9    returned */
10 
11   PROCEDURE GET_GRADE(p_date             DATE,
12                       p_assignment_id    NUMBER,
13                       p_business_group_id NUMBER,
14                       p_grade            OUT NOCOPY VARCHAR2,
15                       p_minimum_salary   OUT NOCOPY NUMBER,
16                       p_maximum_salary   OUT NOCOPY NUMBER,
17                       p_midpoint_salary  OUT NOCOPY NUMBER,
18                       p_grade_uom        OUT NOCOPY VARCHAR2)
19 IS
20 
21 cursor grade_rates IS
22     SELECT fnd_number.canonical_to_number(PGR.MINIMUM)
23     ,      fnd_number.canonical_to_number(PGR.MAXIMUM)
24     ,      fnd_number.canonical_to_number(PGR.MID_VALUE)
25     ,      PRV.RATE_UOM
26     FROM   PER_PAY_BASES PPB
27     ,      PAY_GRADE_RULES_F PGR
28     ,      PAY_RATES_V PRV
29     ,      PER_ALL_ASSIGNMENTS_F ASG
30     WHERE  ASG.ASSIGNMENT_ID=p_assignment_id
31     AND    PPB.PAY_BASIS_ID=ASG.PAY_BASIS_ID
32     AND    PPB.RATE_ID=PGR.RATE_ID
33     AND    PPB.RATE_ID=PRV.RATE_ID
34     AND    ASG.GRADE_ID=PGR.GRADE_OR_SPINAL_POINT_ID
35     AND    p_date BETWEEN asg.effective_start_date
36                   AND     asg.effective_end_date
37     AND    p_date BETWEEN pgr.effective_start_date
38                   AND     pgr.effective_end_date;
39 
40 cursor grade_name IS
41     SELECT GRA.NAME
42     FROM   PER_GRADES_VL GRA
43     ,      PER_ALL_ASSIGNMENTS_F ASG
44     WHERE  ASG.ASSIGNMENT_ID=p_assignment_id
45     AND    ASG.GRADE_ID=GRA.GRADE_ID
46     AND    p_date BETWEEN asg.effective_start_date
47                   AND     asg.effective_end_date;
48 
49   l_proc    varchar2(72) := g_package||'get_grade';
50 BEGIN
51     hr_utility.set_location('Entering:'||l_proc,5);
52       open grade_rates;
53       fetch grade_rates
54       INTO p_minimum_salary,
55            p_maximum_salary,
56            p_midpoint_salary,
57            p_grade_uom;
58       close grade_rates;
59 
60       open grade_name;
61       fetch grade_name
62       INTO p_grade;
63       close grade_name;
64 
65   EXCEPTION
66     WHEN others THEN null;
67 
68 END GET_GRADE;
69 -------------------------------------------------------------------------------
70 /* Procedure to get the previous element_entry_id ( and salary) given the date,
71   assignment_id and business_group_id */
72 
73   PROCEDURE GET_ELEMENT_ID(p_assignment_id     IN    NUMBER,
74                            p_business_group_id IN    NUMBER,
75                            p_change_date       IN    DATE,
76                            p_payroll_value       OUT NOCOPY NUMBER,
77                            p_element_entry_id    OUT NOCOPY NUMBER)
78 IS
79 
80 cursor get_element IS
81  select fnd_number.canonical_to_number(pev.screen_entry_value)
82    ,      pee.element_entry_id
83    from   pay_element_entry_values_f pev
84    ,      pay_element_entries_f pee
85    ,      per_pay_bases ppb
86    ,      per_all_assignments_f asg
87    where  asg.assignment_id=p_assignment_id
88    and    NVL(p_change_date,to_date('31-12-4127','DD-MM-YYYY')) between
89           asg.effective_start_date and asg.effective_end_date
90    and    NVL(p_change_date,to_date('31-12-4127','DD-MM-YYYY')) between
91           pev.effective_start_date and pev.effective_end_date
92    and    pev.element_entry_id=pee.element_entry_id
93    and    asg.assignment_id=pee.assignment_id
94    and    NVL(p_change_date,to_date('31-12-4127','DD-MM-YYYY')) between
95           pee.effective_start_date and pee.effective_end_date
96    and    pev.input_value_id+0=ppb.input_value_id
97    and    asg.pay_basis_id=ppb.pay_basis_id
98    -- the below line added for bug Fix# 3192448
99    and    pee.creator_type = 'SP';
100 
101   l_proc    varchar2(72) := g_package||'get_element_id';
102 BEGIN
103     hr_utility.set_location('Entering:'||l_proc,5);
104 
105       open get_element;
106       fetch get_element
107       INTO p_payroll_value,p_element_entry_id;
108       close get_element;
109     EXCEPTION WHEN no_data_found THEN
110       p_payroll_value:=null;
111       p_element_entry_id:=null;
112 
113 END GET_ELEMENT_ID;
114 ------------------------------------------------------------
115 
116 PROCEDURE GET_CURRENCY_FORMAT(curcode VARCHAR2,
117                               fstring IN OUT NOCOPY VARCHAR2) IS
118   l_format_mask VARCHAR2(40);
119 
120   l_proc    varchar2(72) := g_package||'get_currency_format';
121 BEGIN
122   hr_utility.set_location('Entering:'||l_proc,5);
123   hr_utility.set_location('curcode= '||curcode,10);
124 
125   l_format_mask:= FND_CURRENCY.GET_FORMAT_MASK(curcode,30);
126   hr_utility.set_location('format= '||l_format_mask,15);
127   fstring:=l_format_mask;
128   hr_utility.set_location('format= '||fstring,15);
129 
130 END GET_CURRENCY_FORMAT;
131 ------------------------------------------------------------
132 
133 PROCEDURE GET_NUMBER_FORMAT(fstring IN OUT NOCOPY VARCHAR2) IS
134   l_format_mask VARCHAR2(40);
135 
136   l_proc    varchar2(72) := g_package||'get_currency_format';
137 BEGIN
138   hr_utility.set_location('Entering:'||l_proc,5);
139 
140   FND_CURRENCY.BUILD_FORMAT_MASK(format_mask   => l_format_mask
141                                 ,field_length  => 30
142                                 ,precision     => 5
143                                 ,min_acct_unit => null);
144   hr_utility.set_location('format= '||l_format_mask,15);
145   fstring:=l_format_mask;
146   hr_utility.set_location('format= '||fstring,15);
147 
148 END GET_NUMBER_FORMAT;
149 --------------------------------------------------------------------------------
150 /* Procedure the populate the default values for a new salary proposal,
151    given the date and assignment_id */
152   PROCEDURE GET_DEFAULTS(p_assignment_id           IN     NUMBER
153                         ,p_date                    IN OUT NOCOPY DATE
154                         ,p_business_group_id          OUT NOCOPY NUMBER
155                         ,p_currency                   OUT NOCOPY VARCHAR2
156                         ,p_format_string              OUT NOCOPY VARCHAR2
157                         ,p_salary_basis_name          OUT NOCOPY VARCHAR2
158                         ,p_pay_basis_name             OUT NOCOPY VARCHAR2
159                         ,p_pay_basis                  OUT NOCOPY VARCHAR2
160                         ,p_pay_annualization_factor   OUT NOCOPY NUMBER
161                         ,p_grade                      OUT NOCOPY VARCHAR2
162                         ,p_grade_annualization_factor OUT NOCOPY NUMBER
163                         ,p_minimum_salary             OUT NOCOPY NUMBER
164                         ,p_maximum_salary             OUT NOCOPY NUMBER
165                         ,p_midpoint_salary            OUT NOCOPY NUMBER
166                         ,p_prev_salary                OUT NOCOPY NUMBER
167                         ,p_last_change_date           OUT NOCOPY DATE
168                         ,p_element_entry_id           OUT NOCOPY NUMBER
169                         ,p_basis_changed              OUT NOCOPY BOOLEAN
170                         ,p_uom                        OUT NOCOPY VARCHAR2
171                         ,p_grade_uom                  OUT NOCOPY VARCHAR2) IS
172 
173   Cursor bus_grp IS
174   select business_group_id
175   from   per_all_assignments_f
176   where  assignment_id=p_assignment_id
177   and    p_date BETWEEN
178          effective_start_date AND
179          effective_end_date;
180 
181   l_business_group_id      NUMBER;
182   l_currency               VARCHAR2(15);
183   l_salary_basis_name      VARCHAR2(30);
184   l_pay_basis_name         VARCHAR2(80);
185   l_pay_annualization_factor   NUMBER;
186   l_grade_annualization_factor   NUMBER;
187   l_grade                  VARCHAR2(240);
188   l_grade_basis            VARCHAR2(80);
189   l_minimum_rate           NUMBER;
190   l_maximum_rate           NUMBER;
191   l_midpoint_rate          NUMBER;
192   l_next_sal_review_date   DATE default NULL;
193   l_dummy_n                NUMBER;
194   l_change_date            DATE;
195   l_previous_salary        NUMBER;
196   l_last_change_date       DATE;
197   l_format_string          VARCHAR2(40);
198   l_basis_changed          BOOLEAN;
199   l_pay_basis              VARCHAR2(30);
200   l_uom                    VARCHAR2(30);
201   l_grade_uom              VARCHAR2(30);
202 
203   l_proc    varchar2(72) := g_package||'get_defaults';
204   BEGIN
205     hr_utility.set_location('Entering:'||l_proc,5);
206 
207   l_change_date:=p_date;
208 
209   GET_PREV_SALARY(l_change_date
210                  ,p_assignment_id
211                  ,l_previous_salary
212                  ,l_last_change_date
213                  ,l_basis_changed);
214 
215   p_date:=l_change_date;
216   p_prev_salary:=l_previous_salary;
217   p_last_change_date:=l_last_change_date;
218   p_basis_changed:=l_basis_changed;
219 
220     open bus_grp;
221     fetch bus_grp INTO l_business_group_id;
222     close  bus_grp;
223 
224     p_business_group_id:=l_business_group_id;
225             GET_BASIS_DETAILS(p_date
226                              ,p_assignment_id
227                              ,l_currency
228                              ,l_salary_basis_name
229                              ,l_pay_basis_name
230                              ,l_pay_basis
231                              ,l_pay_annualization_factor
232                              ,l_grade_basis
233                              ,l_grade_annualization_factor
234                              ,l_dummy_n
235                              ,l_uom);
236 
237     p_currency:=l_currency;
238     p_salary_basis_name:=l_salary_basis_name;
239     p_pay_basis_name:=l_pay_basis_name;
240     p_pay_basis:=l_pay_basis;
241     p_pay_annualization_factor:=l_pay_annualization_factor;
242     p_grade_annualization_factor:=l_grade_annualization_factor;
243     p_uom:=l_uom;
244     GET_CURRENCY_FORMAT(l_currency
245                        ,l_format_string);
246     p_format_string:=l_format_string;
247 
248     GET_GRADE(p_date
249              ,p_assignment_id
250              ,l_business_group_id
251              ,l_grade
252              ,l_minimum_rate
253              ,l_maximum_rate
254              ,l_midpoint_rate
255              ,l_grade_uom);
256 
257     p_grade:=l_grade;
258     p_minimum_salary:=l_minimum_rate*l_grade_annualization_factor;
259     p_maximum_salary:=l_maximum_rate*l_grade_annualization_factor;
260     p_midpoint_salary:=l_midpoint_rate*l_grade_annualization_factor;
261     p_grade_uom:=l_grade_uom;
262 
263   GET_ELEMENT_ID(p_assignment_id,
264                      l_business_group_id,
265                      p_date,
266                      l_dummy_n,
267                      p_element_entry_id);
268 
269 
270   END GET_DEFAULTS;
271 -----------------------------------------------------------------------------
272 /* gets the information about the pay basis associated with an assignment */
273   PROCEDURE GET_BASIS_DETAILS(p_effective_date             DATE
274                              ,p_assignment_id              NUMBER
275                              ,p_currency                   OUT NOCOPY VARCHAR2
276                              ,p_salary_basis_name          OUT NOCOPY VARCHAR2
277                              ,p_pay_basis_name             OUT NOCOPY VARCHAR2
278                              ,p_pay_basis                  OUT NOCOPY VARCHAR2
279                              ,p_pay_annualization_factor   OUT NOCOPY NUMBER
280                              ,p_grade_basis                OUT NOCOPY VARCHAR2
281                              ,p_grade_annualization_factor OUT NOCOPY NUMBER
282                              ,p_element_type_id            OUT NOCOPY NUMBER
283                              ,p_uom                        OUT NOCOPY VARCHAR2) IS
284 
285 l_dummy VARCHAR2(30);
286 l_grade_basis VARCHAR2(30);
287 l_pay_basis VARCHAR2(30);
288 l_pay_basis_id NUMBER;
289 l_grade_annualization_factor NUMBER;
290 l_pay_annualization_factor NUMBER;
291 
292   CURSOR c_pay_basis is
293   SELECT PAF.PAY_BASIS_ID
294   FROM PER_ALL_ASSIGNMENTS_F        PAF
295   WHERE PAF.ASSIGNMENT_ID=p_assignment_id
296   AND p_effective_date  BETWEEN
297   PAF.EFFECTIVE_START_DATE AND
298   PAF.EFFECTIVE_END_DATE;
299   --
300   CURSOR Currency IS
301   SELECT PET.INPUT_CURRENCY_CODE
302 , PPB.NAME
303 , HR_GENERAL.DECODE_LOOKUP('PAY_BASIS',PPB.PAY_BASIS)
304 , PPB.PAY_ANNUALIZATION_FACTOR
305 , PPB.GRADE_ANNUALIZATION_FACTOR
306 , PPB.PAY_BASIS
307 , PPB.RATE_BASIS
308 , PET.ELEMENT_TYPE_ID
309 , PIV.UOM
310   FROM PAY_ELEMENT_TYPES_F PET
311 , PAY_INPUT_VALUES_F       PIV
312 , PER_PAY_BASES            PPB
313 --
314   WHERE PPB.PAY_BASIS_ID=L_PAY_BASIS_ID
315 --
316   AND PPB.INPUT_VALUE_ID=PIV.INPUT_VALUE_ID
317   AND p_effective_date  BETWEEN
318   PIV.EFFECTIVE_START_DATE AND
319   PIV.EFFECTIVE_END_DATE
320 --
321   AND PIV.ELEMENT_TYPE_ID=PET.ELEMENT_TYPE_ID
322   AND p_effective_date  BETWEEN
323   PET.EFFECTIVE_START_DATE AND
324   PET.EFFECTIVE_END_DATE;
325 
326   l_proc    varchar2(72) := g_package||'get_basis_details';
327   BEGIN
328     hr_utility.set_location('Entering:'||l_proc,5);
329     open c_pay_basis;
330     fetch c_pay_basis into l_pay_basis_id;
331     close c_pay_basis;
332     --
333     open Currency;
334     fetch Currency
335     into p_currency
336 ,   p_salary_basis_name
337 ,   p_pay_basis_name
338 ,   l_pay_annualization_factor
339 ,   l_grade_annualization_factor
340 ,   l_pay_basis
341 ,   l_grade_basis
342 ,   p_element_type_id
343 ,   p_uom;
344 --
345     hr_utility.set_location(l_proc,10);
346 --
347     close Currency;
348 
349     if(l_pay_basis ='PERIOD' and l_pay_annualization_factor is null) then
350     hr_utility.set_location(l_proc,15);
351 --
352      GET_PAYROLL(p_assignment_id
353                        ,p_effective_date
354                        ,l_dummy
355                        ,l_pay_annualization_factor);
356     end if;
357 --
358     if(l_grade_basis ='PERIOD' and l_grade_annualization_factor is null) then
359     hr_utility.set_location(l_proc,20);
360 
361      GET_PAYROLL(p_assignment_id
362                        ,p_effective_date
363                        ,l_dummy
364                        ,l_grade_annualization_factor);
365     end if;
366 --
367     p_pay_basis:=l_pay_basis;
368     p_grade_basis:=l_grade_basis;
369     p_pay_annualization_factor:=l_pay_annualization_factor;
370     p_grade_annualization_factor:=l_grade_annualization_factor;
371     hr_utility.set_location('Leaving:'||l_proc,25);
372 
373   END GET_BASIS_DETAILS;
374 ---------------------------------------------------------------------------
375 /* procedure to get the previous change date */
376   PROCEDURE GET_PREV_SALARY(p_date          IN OUT NOCOPY    DATE
377                            ,p_assignment_id IN     NUMBER
378                            ,p_prev_salary      OUT NOCOPY NUMBER
379                            ,p_last_change_date OUT NOCOPY DATE
380                            ,p_basis_changed    OUT NOCOPY BOOLEAN) IS
381 
382 
383       CURSOR previous_pay is
384       select pro.proposed_salary_n
385       ,      pro.change_date
386       from per_pay_proposals pro
387       where pro.assignment_id = p_assignment_id
388       and pro.change_date =(select max(pro2.change_date)
389                             from per_pay_proposals pro2
390                             where pro2.assignment_id = p_assignment_id
391                             and pro2.change_date<p_date);
392 
393 
394   l_element_id       NUMBER;
395   l_last_element_id  NUMBER;
396   l_dummy_v          VARCHAR2(100);
397   l_dummy_n          NUMBER;
398   l_last_change_date DATE;
399 
400   l_proc    varchar2(72) := g_package||'get_prev_salary';
401      BEGIN
402     hr_utility.set_location('Entering:'||l_proc,5);
403       --
404        open previous_pay;
405         fetch previous_pay
406         into p_prev_salary
407         ,    l_last_change_date;
408 
409        if previous_pay%found then
410          close previous_pay;
411 --
412          p_last_change_date:=l_last_change_date;
413 --
414          if (l_last_change_date > p_date) THEN
415            p_date:= l_last_change_date+1;
416          end if;
417             GET_BASIS_DETAILS(p_date
418                              ,p_assignment_id
419                              ,l_dummy_v
420                              ,l_dummy_v
421                              ,l_dummy_v
422                              ,l_dummy_v
423                              ,l_dummy_n
424                              ,l_dummy_v
425                             ,l_dummy_n
426                              ,l_element_id
427                              ,l_dummy_v);
428             GET_BASIS_DETAILS(l_last_change_date
429                              ,p_assignment_id
430                              ,l_dummy_v
431                              ,l_dummy_v
432                              ,l_dummy_v
433                              ,l_dummy_v
434                              ,l_dummy_n
435                              ,l_dummy_v
436                              ,l_dummy_n
437                              ,l_last_element_id
438                              ,l_dummy_v);
439 
440           if (l_element_id <> l_last_element_id) then
441         /**
442 	 * Bug Fix: 2279048
443 	 * Description: fixed to get the previous salary
444 	 **/
445 	  -- p_prev_salary:=null;
446             p_basis_changed:=TRUE;
447           else
448             p_basis_changed:=FALSE;
449           end if;
450         else
451           close previous_pay;
452           p_prev_salary:=null;
453           p_last_change_date:=null;
454        end if;
455 
456       EXCEPTION
457 
458       WHEN NO_DATA_FOUND THEN
459          NULL;
460 
461   END GET_PREV_SALARY;
462 ---------------------------------------------------------------------------
463 /* gets the payroll name and frequency for an assignment */
464   PROCEDURE GET_PAYROLL(p_assignment_id         NUMBER
465                        ,p_date                  DATE
466                        ,p_payroll           OUT NOCOPY VARCHAR2
467                        ,p_payrolls_per_year OUT NOCOPY NUMBER) IS
468 
469   cursor payroll is
470   select prl.payroll_name
471   ,      tpt.number_per_fiscal_year
472   from pay_all_payrolls_f prl
473   ,    per_all_assignments_f paf
474   ,    per_time_period_types tpt
475   where paf.assignment_id=p_assignment_id
476   and p_date between paf.effective_start_date
477       and paf.effective_end_date
478   and paf.payroll_id=prl.payroll_id
479   and p_date between prl.effective_start_date
480       and prl.effective_end_date
481   and prl.period_type = tpt.period_type(+);
482 
483   l_proc    varchar2(72) := g_package||'get_payroll';
484   begin
485     hr_utility.set_location('Entering:'||l_proc,5);
486 
487   open payroll;
488   fetch payroll into p_payroll,p_payrolls_per_year;
489   close payroll;
490 
491   end get_payroll;
492 -----------------------------------------------------------------------------
493 /* gets the working hours for the person, first of all from the assignment
494    then if that is null, from the position, then if that is null, from
495    the organization then if that is null, from the business group */
496 
497   procedure get_hours(p_assignment_id      NUMBER
498                      ,p_date               DATE
499                      ,p_hours_per_year OUT NOCOPY NUMBER)is
500 
501   l_hours_per_year number;
502 
503   l_proc    varchar2(72) := g_package||'get_hours';
504   begin
505     hr_utility.set_location('Entering:'||l_proc,5);
506 
507     get_asg_hours(p_assignment_id
508                  ,p_date
509                  ,l_hours_per_year);
510 
511     if(nvl(l_hours_per_year,0) =0) then
512       get_norm_hours(p_assignment_id
513                     ,p_date
514                     ,l_hours_per_year);
515     end if;
516     p_hours_per_year:=l_hours_per_year;
517   end get_hours;
518 -----------------------------------------------------------------------------
519 /* gets the assignment working hours for the person */
520 
521   procedure get_asg_hours(p_assignment_id      NUMBER
522                          ,p_date               DATE
523                          ,p_hours_per_year OUT NOCOPY NUMBER)is
524 
525   cursor get_asg_hours is
526   select asg.normal_hours
527   ,      decode(asg.frequency
528                ,'Y',1
529                ,'M',12
530                ,'W',52
531                ,'D',365
532                ,1)
533   from   per_all_assignments_f asg
534   where  asg.assignment_id =p_assignment_id
535   and    p_date between asg.effective_start_date
536          and asg.effective_end_date;
537 
538   l_hours NUMBER;
539   l_frequency NUMBER;
540 
541   l_proc    varchar2(72) := g_package||'get_asg_hours';
542   begin
543     hr_utility.set_location('Entering:'||l_proc,5);
544 
545   open get_asg_hours;
546   fetch get_asg_hours into l_hours,l_frequency;
547 
548   if (get_asg_hours%found and l_hours is not null) THEN
549     p_hours_per_year:=nvl(l_hours,0)*l_frequency;
550   else
551     p_hours_per_year:=null;
552   end if;
553     close get_asg_hours;
554 
555   end get_asg_hours;
556 ------------------------------------------------------------------------------
557 -----------------------------------------------------------------------------
558 /* gets the working hours for the person, first of all from the position,
559    then if that is null, from
560    the organization then if that is null, from the business group */
561   procedure get_norm_hours(p_assignment_id      NUMBER
562                      ,p_date               DATE
563                      ,p_hours_per_year OUT NOCOPY NUMBER)is
564 
565   --
566   -- Changed 01-Oct-99 SCNair (per_all_positions ro hr_all_positions) Date tracked positions requirement
567   --
568   --
569   -- Changed 30-OCT-06 ABHSHRIV Error Handling for cases when the org_information3/working_hours
570   -- are of invalid character type (BUG 5622048)
571   --
572   cursor get_pos_hours is
573   select pos.working_hours
574   ,      decode(pos.frequency
575                ,'Y',1
576                ,'M',12
577                ,'W',52
578                ,'D',365
579                ,1)
580   from   hr_all_positions pos
581   ,      per_all_assignments_f asg
582   where  asg.assignment_id =p_assignment_id
583   and    p_date between asg.effective_start_date
584          and asg.effective_end_date
585   and    asg.position_id=pos.position_id;
586 
587   cursor get_org_hours is
588   select fnd_number.canonical_to_number(org.org_information3) normal_hours
589   ,      decode(org.org_information4
590                ,'Y',1
591                ,'M',12
592                ,'W',52
593                ,'D',365
594                ,1)
595   from   HR_ORGANIZATION_INFORMATION org
596   ,      per_all_assignments_f asg
597   where  asg.assignment_id =p_assignment_id
598   and    p_date between asg.effective_start_date
599          and asg.effective_end_date
600   and    asg.organization_id=org.organization_id(+)
601   and    org.org_information_context(+) = 'Work Day Information';
602 
603  cursor get_bus_hours is
604   select fnd_number.canonical_to_number(bus.working_hours) normal_hours
605   ,      decode(bus.frequency
606                ,'Y',1
607                ,'M',12
608                ,'W',52
609                ,'D',365
610                ,1)
611   from   per_business_groups bus
612   ,      per_all_assignments_f asg
613   where  asg.assignment_id =p_assignment_id
614   and    p_date between asg.effective_start_date
615          and asg.effective_end_date
616   and    asg.business_group_id=bus.business_group_id;
617 
618   l_hours NUMBER;
619   l_frequency NUMBER;
620 
621   l_proc    varchar2(72) := g_package||'get_norm_hours';
622   begin
623   if g_debug then
624     hr_utility.set_location('Entering:'||l_proc,5);
625   end if;
626 
627     open get_pos_hours;
628     fetch get_pos_hours into l_hours,l_frequency;
629     close get_pos_hours;
630 
631     if l_hours is null or l_frequency is null then
632         begin
633              if g_debug then
634                 hr_utility.set_location('get_org_hours',7);
635              end if;
636             open get_org_hours;
637             fetch get_org_hours into l_hours,l_frequency;
638             close get_org_hours;
639         exception
640             when others then
641              if g_debug then
642                 hr_utility.set_location('get_org_hours exception',8);
643              end if;
644                 l_hours := null;
645                 l_frequency := null;
646         end;
647       if l_hours is null or l_frequency is null then
648         begin
649              if g_debug then
650                 hr_utility.set_location('get_bus_hours',10);
651              end if;
652            open get_bus_hours;
653            fetch get_bus_hours into l_hours,l_frequency;
654            close get_bus_hours;
655         exception
656            when others then
657              if g_debug then
658                 hr_utility.set_location('get_bus_hours exception',12);
659              end if;
660                 l_hours := null;
661                 l_frequency := null;
662         end;
663       end if;
664     end if;
665     p_hours_per_year:=nvl(l_hours,0)*l_frequency;
666              if g_debug then
667                 hr_utility.set_location('Leaving:'||l_proc,15);
668              end if;
669   end get_norm_hours;
670 
671 
672 ------------------------------------------------------------------------------
673 END PER_PAY_PROPOSALS_POPULATE;