DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_HWF_BUS

Source


1 Package Body ben_hwf_bus as
2 /* $Header: behwfrhi.pkb 120.0 2005/05/28 03:12:16 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_hwf_bus.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------< chk_hrs_wkd_in_perd_fctr_id >------|
12 -- ----------------------------------------------------------------------------
13 --
14 -- Description
15 --   This procedure is used to check that the primary key for the table
16 --   is created properly. It should be null on insert and
17 --   should not be able to be updated.
18 --
19 -- Pre Conditions
20 --   None.
21 --
22 -- In Parameters
23 --   hrs_wkd_in_perd_fctr_id PK of record being inserted or updated.
24 --   object_version_number Object version number of record being
25 --                         inserted or updated.
26 --
27 -- Post Success
28 --   Processing continues
29 --
30 -- Post Failure
31 --   Errors handled by the procedure
32 --
33 -- Access Status
34 --   Internal table handler use only.
35 --
36 Procedure chk_hrs_wkd_in_perd_fctr_id(p_hrs_wkd_in_perd_fctr_id                in number,
37                            p_object_version_number       in number) is
38   --
39   l_proc         varchar2(72) := g_package||'chk_hrs_wkd_in_perd_fctr_id';
40   l_api_updating boolean;
41   --
42 Begin
43   --
44   hr_utility.set_location('Entering:'||l_proc, 5);
45   --
46   l_api_updating := ben_hwf_shd.api_updating
47     (p_hrs_wkd_in_perd_fctr_id                => p_hrs_wkd_in_perd_fctr_id,
48      p_object_version_number       => p_object_version_number);
49   --
50   if (l_api_updating
51      and nvl(p_hrs_wkd_in_perd_fctr_id,hr_api.g_number)
52      <>  ben_hwf_shd.g_old_rec.hrs_wkd_in_perd_fctr_id) then
53     --
54     -- raise error as PK has changed
55     --
56     ben_hwf_shd.constraint_error('BEN_HRS_WKD_IN_PERD_FCTR_PK');
57     --
58   elsif not l_api_updating then
59     --
60     -- check if PK is null
61     --
62     if p_hrs_wkd_in_perd_fctr_id is not null then
63       --
64       -- raise error as PK is not null
65       --
66       ben_hwf_shd.constraint_error('BEN_HRS_WKD_IN_PERD_FCTR_PK');
67       --
68     end if;
69     --
70   end if;
71   --
72   hr_utility.set_location('Leaving:'||l_proc, 10);
73   --
74 End chk_hrs_wkd_in_perd_fctr_id;
75 --
76 -- ----------------------------------------------------------------------------
77 -- |------< chk_once_r_cntug_cd >------|
78 -- ----------------------------------------------------------------------------
79 --
80 -- Description
81 --   This procedure is used to check that the lookup value is valid.
82 --
83 -- Pre Conditions
84 --   None.
85 --
86 -- In Parameters
87 --   hrs_wkd_in_perd_fctr_id PK of record being inserted or updated.
88 --   once_r_cntug_cd Value of lookup code.
89 --   effective_date effective date
90 --   object_version_number Object version number of record being
91 --                         inserted or updated.
92 --
93 -- Post Success
94 --   Processing continues
95 --
96 -- Post Failure
97 --   Error handled by procedure
98 --
99 -- Access Status
100 --   Internal table handler use only.
101 --
102 Procedure chk_once_r_cntug_cd(p_hrs_wkd_in_perd_fctr_id                in number,
103                             p_once_r_cntug_cd               in varchar2,
104                             p_effective_date              in date,
105                             p_object_version_number       in number) is
106   --
107   l_proc         varchar2(72) := g_package||'chk_once_r_cntug_cd';
108   l_api_updating boolean;
109   --
110 Begin
111   --
112   hr_utility.set_location('Entering:'||l_proc, 5);
113   --
114   l_api_updating := ben_hwf_shd.api_updating
115     (p_hrs_wkd_in_perd_fctr_id                => p_hrs_wkd_in_perd_fctr_id,
116      p_object_version_number       => p_object_version_number);
117   --
118   if (l_api_updating
119       and p_once_r_cntug_cd
120       <> nvl(ben_hwf_shd.g_old_rec.once_r_cntug_cd,hr_api.g_varchar2)
121       or not l_api_updating)
122       and p_once_r_cntug_cd is not null then
123     --
124     -- check if value of lookup falls within lookup type.
125     --
126     if hr_api.not_exists_in_hr_lookups
127           (p_lookup_type    => 'BEN_ONCE_R_CNTNG',
128            p_lookup_code    => p_once_r_cntug_cd,
129            p_effective_date => p_effective_date) then
130       --
131       -- raise error as does not exist as lookup
132       --
133       fnd_message.set_name('BEN','BEN_91060_INVLD_ONCE_R_CNTG_CD');
134       fnd_message.raise_error;
135       --
136     end if;
137     --
138   end if;
139   --
140   hr_utility.set_location('Leaving:'||l_proc,10);
141   --
142 end chk_once_r_cntug_cd;
143 --
144 --
145 -- ----------------------------------------------------------------------------
146 -- |------< chk_no_mx_hrs_wkd_flag >------|
147 -- ----------------------------------------------------------------------------
148 --
149 -- Description
150 --   This procedure is used to check that the lookup value is valid.
151 --
152 -- Pre Conditions
153 --   None.
154 --
155 -- In Parameters
156 --   hrs_wkd_in_perd_fctr_id PK of record being inserted or updated.
157 --   no_mx_hrs_wkd_flag Value of lookup code.
158 --   effective_date effective date
159 --   object_version_number Object version number of record being
160 --                         inserted or updated.
161 --
162 -- Post Success
163 --   Processing continues
164 --
165 -- Post Failure
166 --   Error handled by procedure
167 --
168 -- Access Status
169 --   Internal table handler use only.
170 --
171 Procedure chk_no_mx_hrs_wkd_flag(p_hrs_wkd_in_perd_fctr_id                in number,
172                             p_no_mx_hrs_wkd_flag               in varchar2,
173                             p_effective_date              in date,
174                             p_object_version_number       in number) is
175   --
176   l_proc         varchar2(72) := g_package||'chk_no_mx_hrs_wkd_flag';
177   l_api_updating boolean;
178   --
179 Begin
180   --
181   hr_utility.set_location('Entering:'||l_proc, 5);
182   --
183   l_api_updating := ben_hwf_shd.api_updating
184     (p_hrs_wkd_in_perd_fctr_id                => p_hrs_wkd_in_perd_fctr_id,
185      p_object_version_number       => p_object_version_number);
186   --
187   if (l_api_updating
188       and p_no_mx_hrs_wkd_flag
189       <> nvl(ben_hwf_shd.g_old_rec.no_mx_hrs_wkd_flag,hr_api.g_varchar2)
190       or not l_api_updating)
191       and p_no_mx_hrs_wkd_flag is not null then
192     --
193     -- check if value of lookup falls within lookup type.
194     --
195     if hr_api.not_exists_in_hr_lookups
196           (p_lookup_type    => 'YES_NO',
197            p_lookup_code    => p_no_mx_hrs_wkd_flag,
198            p_effective_date => p_effective_date) then
199       --
200       -- raise error as does not exist as lookup
201       --
202       fnd_message.set_name('BEN','BEN_91052_INVALID_MAX_FLAG');
203       fnd_message.raise_error;
204       --
205     end if;
206     --
207   end if;
208   --
209   hr_utility.set_location('Leaving:'||l_proc,10);
210   --
211 end chk_no_mx_hrs_wkd_flag;
212 -- ----------------------------------------------------------------------------
213 -- |------< chk_no_mn_hrs_wkd_flag >------|
214 -- ----------------------------------------------------------------------------
215 --
216 -- Description
217 --   This procedure is used to check that the lookup value is valid.
218 --
219 -- Pre Conditions
220 --   None.
221 --
222 -- In Parameters
223 --   hrs_wkd_in_perd_fctr_id PK of record being inserted or updated.
224 --   no_mn_hrs_wkd_flag Value of lookup code.
225 --   effective_date effective date
226 --   object_version_number Object version number of record being
227 --                         inserted or updated.
228 --
229 -- Post Success
230 --   Processing continues
231 --
232 -- Post Failure
233 --   Error handled by procedure
234 --
235 -- Access Status
236 --   Internal table handler use only.
237 --
238 Procedure chk_no_mn_hrs_wkd_flag(p_hrs_wkd_in_perd_fctr_id                in number,
239                             p_no_mn_hrs_wkd_flag               in varchar2,
240                             p_effective_date              in date,
241                             p_object_version_number       in number) is
242   --
243   l_proc         varchar2(72) := g_package||'chk_no_mn_hrs_wkd_flag';
244   l_api_updating boolean;
245   --
246 Begin
247   --
248   hr_utility.set_location('Entering:'||l_proc, 5);
249   --
250   l_api_updating := ben_hwf_shd.api_updating
251     (p_hrs_wkd_in_perd_fctr_id                => p_hrs_wkd_in_perd_fctr_id,
252      p_object_version_number       => p_object_version_number);
253   --
254   if (l_api_updating
255       and p_no_mn_hrs_wkd_flag
256       <> nvl(ben_hwf_shd.g_old_rec.no_mn_hrs_wkd_flag,hr_api.g_varchar2)
257       or not l_api_updating)
258       and p_no_mn_hrs_wkd_flag is not null then
259     --
260     -- check if value of lookup falls within lookup type.
261     --
262     if hr_api.not_exists_in_hr_lookups
263           (p_lookup_type    => 'YES_NO',
264            p_lookup_code    => p_no_mn_hrs_wkd_flag,
265            p_effective_date => p_effective_date) then
266       --
267       -- raise error as does not exist as lookup
268       --
269       fnd_message.set_name('PAY','91051_INVALID_MIN_FLAG');
270       fnd_message.raise_error;
271       --
272     end if;
273     --
274   end if;
275   --
276   hr_utility.set_location('Leaving:'||l_proc,10);
277   --
278 end chk_no_mn_hrs_wkd_flag;
279 --
280 -- ----------------------------------------------------------------------------
281 -- |------< chk_hrs_wkd_det_rl >------|
282 -- ----------------------------------------------------------------------------
283 --
284 -- Description
285 --   This procedure is used to check that the Formula Rule is valid.
286 --
287 -- Pre Conditions
288 --   None.
289 --
290 -- In Parameters
291 --   hrs_wkd_in_perd_fctr_id PK of record being inserted or updated.
292 --   hrs_wkd_det_rl Value of formula rule id.
293 --   effective_date effective date
294 --   object_version_number Object version number of record being
295 --                                      inserted or updated.
296 --
297 -- Post Success
298 --   Processing continues
299 --
300 -- Post Failure
301 --   Error handled by procedure
302 --
303 -- Access Status
304 --   Internal table handler use only.
305 --
306 Procedure chk_hrs_wkd_det_rl(p_hrs_wkd_in_perd_fctr_id     in number,
307                              p_business_group_id        in number,
308                              p_hrs_wkd_det_rl              in number,
309                              p_hrs_wkd_det_cd              in varchar2,
310                              p_effective_date              in date,
311                              p_object_version_number       in number) is
312   --
313   l_proc         varchar2(72) := g_package||'chk_hrs_wkd_det_rl';
314   l_api_updating boolean;
315   l_dummy        varchar2(1);
316   --
317   cursor c1 is
318     select null
319     from   ff_formulas_f ff
320            ,per_business_groups pbg
321     where  ff.formula_id = p_hrs_wkd_det_rl
322     and    ff.formula_type_id = -155
323     and    pbg.business_group_id = p_business_group_id
324     and    nvl(ff.business_group_id, p_business_group_id) =
325                p_business_group_id
326     and    nvl(ff.legislation_code, pbg.legislation_code) =
327                pbg.legislation_code
328     and    p_effective_date
329            between ff.effective_start_date
330            and     ff.effective_end_date;
331   --
332 Begin
333   --
334   hr_utility.set_location('Entering:'||l_proc, 5);
335   --
336   l_api_updating := ben_hwf_shd.api_updating
337     (p_hrs_wkd_in_perd_fctr_id                => p_hrs_wkd_in_perd_fctr_id,
338      p_object_version_number       => p_object_version_number);
339   --
340   if (l_api_updating
341       and nvl(p_hrs_wkd_det_rl,hr_api.g_number)
342       <> ben_hwf_shd.g_old_rec.hrs_wkd_det_rl
343       or not l_api_updating)
344       and p_hrs_wkd_det_rl is not null then
345     --
346     -- check if value of formula rule is valid.
347     --
348     open c1;
349       --
350       -- fetch value from cursor if it returns a record then the
351       -- formula is valid otherwise its invalid
352       --
353       fetch c1 into l_dummy;
354       if c1%notfound then
355         --
356         close c1;
357         --
358         -- raise error
359         --
360         fnd_message.set_name('BEN','BEN_91062_INVLD_HRS_WKD_DET_RL');
361         fnd_message.raise_error;
362         --
363       end if;
364       --
365     close c1;
366     --
367   end if;
368   --
369   -- Unless Hours Worked Determination Code  = Rule, Hours Worked Determination rule must be blank.
370   if  nvl(p_hrs_wkd_det_cd,hr_api.g_varchar2)  <> 'RL' and p_hrs_wkd_det_rl is not null then
371       --
372       fnd_message.set_name('BEN', 'BEN_91070_HRS_WKD_RL_NOT_NULL');
373       fnd_message.raise_error;
374       --
375   elsif  nvl(p_hrs_wkd_det_cd,hr_api.g_varchar2) = 'RL' and p_hrs_wkd_det_rl is null then
376       --
377       fnd_message.set_name('BEN', 'BEN_91097_HRS_WKD_RL_NULL');
378       fnd_message.raise_error;
379       --
380   end if;
381   --
382   hr_utility.set_location('Leaving:'||l_proc,10);
383   --
384 end chk_hrs_wkd_det_rl;
385 --
386 -- ----------------------------------------------------------------------------
387 -- |------< chk_hrs_wkd_det_cd >------|
388 -- ----------------------------------------------------------------------------
389 --
390 -- Description
391 --   This procedure is used to check that the lookup value is valid.
392 --
393 -- Pre Conditions
394 --   None.
395 --
396 -- In Parameters
397 --   hrs_wkd_in_perd_fctr_id PK of record being inserted or updated.
398 --   hrs_wkd_det_cd Value of lookup code.
399 --   effective_date effective date
400 --   object_version_number Object version number of record being
401 --                         inserted or updated.
402 --
403 -- Post Success
404 --   Processing continues
405 --
406 -- Post Failure
407 --   Error handled by procedure
408 --
409 -- Access Status
410 --   Internal table handler use only.
411 --
412 Procedure chk_hrs_wkd_det_cd(p_hrs_wkd_in_perd_fctr_id                in number,
413                             p_hrs_wkd_det_cd               in varchar2,
414                             p_effective_date              in date,
415                             p_object_version_number       in number) is
416   --
417   l_proc         varchar2(72) := g_package||'chk_hrs_wkd_det_cd';
418   l_api_updating boolean;
419   --
420 Begin
421   --
422   hr_utility.set_location('Entering:'||l_proc, 5);
423   --
424   l_api_updating := ben_hwf_shd.api_updating
425     (p_hrs_wkd_in_perd_fctr_id                => p_hrs_wkd_in_perd_fctr_id,
426      p_object_version_number       => p_object_version_number);
427   --
428   if (l_api_updating
429       and p_hrs_wkd_det_cd
430       <> nvl(ben_hwf_shd.g_old_rec.hrs_wkd_det_cd,hr_api.g_varchar2)
431       or not l_api_updating)
432       and p_hrs_wkd_det_cd is not null then
433     --
434     -- check if value of lookup falls within lookup type.
435     --
436     if hr_api.not_exists_in_hr_lookups
437           (p_lookup_type    => 'BEN_HRS_WKD_DET',
438            p_lookup_code    => p_hrs_wkd_det_cd,
439            p_effective_date => p_effective_date) then
440       --
441       -- raise error as does not exist as lookup
442       --
443       fnd_message.set_name('BEN','BEN_91061_INVLD_HRS_WKD_DET_CD');
444       fnd_message.raise_error;
445       --
446     end if;
447     --
448   end if;
449   --
450   hr_utility.set_location('Leaving:'||l_proc,10);
451   --
452 end chk_hrs_wkd_det_cd;
453 --
454 -- ----------------------------------------------------------------------------
455 -- |------< chk_rndg_rl >------|
456 -- ----------------------------------------------------------------------------
457 --
458 -- Description
459 --   This procedure is used to check that the Formula Rule is valid.
460 --
461 -- Pre Conditions
462 --   None.
463 --
464 -- In Parameters
465 --   hrs_wkd_in_perd_fctr_id PK of record being inserted or updated.
466 --   rndg_rl Value of formula rule id.
467 --   effective_date effective date
468 --   object_version_number Object version number of record being
469 --                                      inserted or updated.
470 --
471 -- Post Success
472 --   Processing continues
473 --
474 -- Post Failure
475 --   Error handled by procedure
476 --
477 -- Access Status
478 --   Internal table handler use only.
479 --
480 Procedure chk_rndg_rl(p_hrs_wkd_in_perd_fctr_id                in number,
481                              p_business_group_id        in number,
482                              p_rndg_rl              in number,
483                              p_rndg_cd              in varchar2,
484                              p_effective_date              in date,
485                              p_object_version_number       in number) is
486   --
487   l_proc         varchar2(72) := g_package||'chk_rndg_rl';
488   l_api_updating boolean;
489   l_dummy        varchar2(1);
490   --
491   cursor c1 is
492     select null
493     from   ff_formulas_f ff
494            ,per_business_groups pbg
495     where  ff.formula_id = p_rndg_rl
496     and    ff.formula_type_id = -169
497     and    pbg.business_group_id = p_business_group_id
498     and    nvl(ff.business_group_id, p_business_group_id) =
499                p_business_group_id
500     and    nvl(ff.legislation_code, pbg.legislation_code) =
501                pbg.legislation_code
502     and    p_effective_date
503            between ff.effective_start_date
504            and     ff.effective_end_date;
505   --
506 Begin
507   --
508   hr_utility.set_location('Entering:'||l_proc, 5);
509   --
510   l_api_updating := ben_hwf_shd.api_updating
511     (p_hrs_wkd_in_perd_fctr_id                => p_hrs_wkd_in_perd_fctr_id,
512      p_object_version_number       => p_object_version_number);
513   --
514   if (l_api_updating
515       and nvl(p_rndg_rl,hr_api.g_number)
516       <> ben_hwf_shd.g_old_rec.rndg_rl
517       or not l_api_updating)
518       and p_rndg_rl is not null then
519     --
520     -- check if value of formula rule is valid.
521     --
522     open c1;
523       --
524       -- fetch value from cursor if it returns a record then the
525       -- formula is valid otherwise its invalid
526       --
527       fetch c1 into l_dummy;
528       if c1%notfound then
529         --
530         close c1;
531         --
532         -- raise error
533         --
534         fnd_message.set_name('BEN','BEN_91042_INVALID_RNDG_RL');
535         fnd_message.raise_error;
536         --
537       end if;
538       --
539     close c1;
540     --
541   end if;
542   --
543   -- Unless Rounding Code = Rule, Rounding rule must be blank.
544   if  nvl(p_rndg_cd,hr_api.g_varchar2)  <> 'RL' and p_rndg_rl is not null then
545       --
546       fnd_message.set_name('BEN', 'BEN_91043_RNDG_RL_NOT_NULL');
547       fnd_message.raise_error;
548       --
549   elsif  nvl(p_rndg_cd,hr_api.g_varchar2) = 'RL' and p_rndg_rl is null then
550       --
551       fnd_message.set_name('BEN', 'BEN_92340_RNDG_RL_NULL');
552       fnd_message.raise_error;
553       --
554   end if;
555   --
556   --
557   hr_utility.set_location('Leaving:'||l_proc,10);
558   --
559 end chk_rndg_rl;
560 --
561 -- ----------------------------------------------------------------------------
562 -- |------< chk_rndg_cd >------|
563 -- ----------------------------------------------------------------------------
564 --
565 -- Description
566 --   This procedure is used to check that the lookup value is valid.
567 --
568 -- Pre Conditions
569 --   None.
570 --
571 -- In Parameters
572 --   hrs_wkd_in_perd_fctr_id PK of record being inserted or updated.
573 --   rndg_cd Value of lookup code.
574 --   effective_date effective date
575 --   object_version_number Object version number of record being
576 --                         inserted or updated.
577 --
578 -- Post Success
579 --   Processing continues
580 --
581 -- Post Failure
582 --   Error handled by procedure
583 --
584 -- Access Status
585 --   Internal table handler use only.
586 --
587 Procedure chk_rndg_cd(p_hrs_wkd_in_perd_fctr_id                in number,
588                             p_rndg_cd               in varchar2,
589                             p_effective_date              in date,
590                             p_object_version_number       in number) is
591   --
592   l_proc         varchar2(72) := g_package||'chk_rndg_cd';
593   l_api_updating boolean;
594   --
595 Begin
596   --
597   hr_utility.set_location('Entering:'||l_proc, 5);
598   --
599   l_api_updating := ben_hwf_shd.api_updating
600     (p_hrs_wkd_in_perd_fctr_id                => p_hrs_wkd_in_perd_fctr_id,
601      p_object_version_number       => p_object_version_number);
602   --
603   if (l_api_updating
604       and p_rndg_cd
605       <> nvl(ben_hwf_shd.g_old_rec.rndg_cd,hr_api.g_varchar2)
606       or not l_api_updating)
607       and p_rndg_cd is not null then
608     --
609     -- check if value of lookup falls within lookup type.
610     --
611     if hr_api.not_exists_in_hr_lookups
612           (p_lookup_type    => 'BEN_RNDG',
613            p_lookup_code    => p_rndg_cd,
614            p_effective_date => p_effective_date) then
615       --
616       -- raise error as does not exist as lookup
617       --
618       fnd_message.set_name('BEN','BEN_91041_INVALID_RNDG_CD');
619       fnd_message.raise_error;
620       --
621     end if;
622     --
623   end if;
624   --
625   hr_utility.set_location('Leaving:'||l_proc,10);
626   --
627 end chk_rndg_cd;
628 --
629 -- ----------------------------------------------------------------------------
630 -- |------< chk_hrs_src_cd >------|
631 -- ----------------------------------------------------------------------------
632 --
633 -- Description
634 --   This procedure is used to check that the lookup value is valid.
635 --
636 -- Pre Conditions
637 --   None.
638 --
639 -- In Parameters
640 --   hrs_wkd_in_perd_fctr_id PK of record being inserted or updated.
641 --   hrs_src_cd Value of lookup code.
642 --   effective_date effective date
643 --   object_version_number Object version number of record being
644 --                         inserted or updated.
645 --
646 -- Post Success
647 --   Processing continues
648 --
649 -- Post Failure
650 --   Error handled by procedure
651 --
652 -- Access Status
653 --   Internal table handler use only.
654 --
655 Procedure chk_hrs_src_cd(p_hrs_wkd_in_perd_fctr_id                in number,
656                             p_hrs_src_cd               in varchar2,
657                             p_effective_date              in date,
658                             p_object_version_number       in number) is
659   --
660   l_proc         varchar2(72) := g_package||'chk_hrs_src_cd';
661   l_api_updating boolean;
662   --
663 Begin
664   --
665   hr_utility.set_location('Entering:'||l_proc, 5);
666   --
667   l_api_updating := ben_hwf_shd.api_updating
668     (p_hrs_wkd_in_perd_fctr_id                => p_hrs_wkd_in_perd_fctr_id,
669      p_object_version_number       => p_object_version_number);
670   --
671   if (l_api_updating
672       and p_hrs_src_cd
673       <> nvl(ben_hwf_shd.g_old_rec.hrs_src_cd,hr_api.g_varchar2)
674       or not l_api_updating)
675       and p_hrs_src_cd is not null then
676     --
677     -- check if value of lookup falls within lookup type.
678     --
679     if hr_api.not_exists_in_hr_lookups
680           (p_lookup_type    => 'BEN_HRS_WKD_SRC',
681            p_lookup_code    => p_hrs_src_cd,
682            p_effective_date => p_effective_date) then
683       --
684       -- raise error as does not exist as lookup
685       --
686       fnd_message.set_name('BEN','BEN_91053_INVALID_SRC_CD');
687       fnd_message.raise_error;
688       --
689     end if;
690     --
691   end if;
692   --
693   hr_utility.set_location('Leaving:'||l_proc,10);
694   --
695 end chk_hrs_src_cd;
696 --
697 -- ----------------------------------------------------------------------------
698 -- |-----------------< chk_hrs_alt_val_to_use_cd >--------------------------|
699 -- ----------------------------------------------------------------------------
700 --
701 -- Description
702 --   This procedure is used to check that the lookup value is valid.
703 --
704 -- Pre Conditions
705 --   None.
706 --
707 -- In Parameters
708 --   hrs_wkd_in_perd_fctr_id PK of record being inserted or updated.
709 --   hrs_alt_val_to_use_cd Value of lookup code.
710 --   effective_date effective date
711 --   object_version_number Object version number of record being
712 --                         inserted or updated.
713 --
714 -- Post Success
715 --   Processing continues
716 --
717 -- Post Failure
718 --   Error handled by procedure
719 --
720 -- Access Status
721 --   Internal table handler use only.
722 --
723 Procedure chk_hrs_alt_val_to_use_cd(p_hrs_wkd_in_perd_fctr_id    in number,
724                                     p_hrs_alt_val_to_use_cd      in varchar2,
725                                     p_effective_date             in date,
726                                     p_object_version_number      in number) is
727   --
728   l_proc         varchar2(72) := g_package||'chk_hrs_alt_val_to_use_cd';
729   l_api_updating boolean;
730   --
731 Begin
732   --
733   hr_utility.set_location('Entering:'||l_proc, 5);
734   --
735   l_api_updating := ben_hwf_shd.api_updating
736     (p_hrs_wkd_in_perd_fctr_id     => p_hrs_wkd_in_perd_fctr_id,
737      p_object_version_number       => p_object_version_number);
738   --
739   if (l_api_updating
740       and p_hrs_alt_val_to_use_cd
741       <> nvl(ben_hwf_shd.g_old_rec.hrs_alt_val_to_use_cd,hr_api.g_varchar2)
742       or not l_api_updating)
743       and p_hrs_alt_val_to_use_cd is not null then
744     --
745     -- check if value of lookup falls within lookup type.
746     --
747     if hr_api.not_exists_in_hr_lookups
748           (p_lookup_type    => 'BEN_HRS_ALT_VAL_TO_USE',
749            p_lookup_code    => p_hrs_alt_val_to_use_cd,
750            p_effective_date => p_effective_date) then
751       --
752       -- raise error as does not exist as lookup
753       --
754       fnd_message.set_name('BEN', 'BEN_91628_LOOKUP_TYPE_GENERIC');
755       fnd_message.set_token('FIELD', 'p_hrs_alt_val_to_use_cd');
756       fnd_message.set_token('TYPE', 'BEN_HRS_ALT_VAL_TO_USE');
757       fnd_message.raise_error;
758       --
759     end if;
760     --
761   end if;
762   --
763   hr_utility.set_location('Leaving:'||l_proc,10);  --
764 end chk_hrs_alt_val_to_use_cd;
765 --
766 -- ----------------------------------------------------------------------------
767 -- |-----------------< chk_pyrl_freq_cd >--------------------------|
768 -- ----------------------------------------------------------------------------
769 --
770 -- Description
771 --   This procedure is used to check that the lookup value is valid.
772 --
773 -- Pre Conditions
774 --   None.
775 --
776 -- In Parameters
777 --   hrs_wkd_in_perd_fctr_id PK of record being inserted or updated.
778 --   pyrl_freq_cd Value of lookup code.
779 --   effective_date effective date
780 --   object_version_number Object version number of record being
781 --                         inserted or updated.
782 --
783 -- Post Success
784 --   Processing continues
785 --
786 -- Post Failure
787 --   Error handled by procedure
788 --
789 -- Access Status
790 --   Internal table handler use only.
791 --
792 Procedure chk_pyrl_freq_cd(p_hrs_wkd_in_perd_fctr_id  in number,
793                            p_pyrl_freq_cd             in varchar2,
794                            p_effective_date           in date,
795                            p_object_version_number    in number) is
796   --
797   l_proc         varchar2(72) := g_package||'chk_pyrl_freq_cd';
798   l_api_updating boolean;
799   --
800 Begin
801   --
802   hr_utility.set_location('Entering:'||l_proc, 5);
803   --
804   l_api_updating := ben_hwf_shd.api_updating
805     (p_hrs_wkd_in_perd_fctr_id     => p_hrs_wkd_in_perd_fctr_id,
806      p_object_version_number       => p_object_version_number);
807   --
808   if (l_api_updating
809       and p_pyrl_freq_cd
810       <> nvl(ben_hwf_shd.g_old_rec.pyrl_freq_cd,hr_api.g_varchar2)
811       or not l_api_updating)
812       and p_pyrl_freq_cd is not null then
813     --
814     -- check if value of lookup falls within lookup type.
815     --
816     if hr_api.not_exists_in_hr_lookups
817           (p_lookup_type    => 'BEN_FREQ',
818            p_lookup_code    => p_pyrl_freq_cd,
819            p_effective_date => p_effective_date) then
820       --
821       -- raise error as does not exist as lookup
822       --
823       fnd_message.set_name('BEN', 'BEN_91628_LOOKUP_TYPE_GENERIC');
824       fnd_message.set_token('FIELD', 'p_pyrl_freq_cd');
825       fnd_message.set_token('TYPE', 'BEN_FREQ');
826       fnd_message.raise_error;
827       --
828     end if;
829     --
830   end if;
831   --
832   hr_utility.set_location('Leaving:'||l_proc,10);  --
833 end chk_pyrl_freq_cd;
834 --
835 -- ----------------------------------------------------------------------------
836 -- |---------------------< chk_hrs_wkd_calc_rl >------------------------------|
837 -- ----------------------------------------------------------------------------
838 --
839 -- Description
840 --   This procedure is used to check that the Formula Rule is valid.
841 --
842 -- Pre Conditions
843 --   None.
844 --
845 -- In Parameters
846 --   hrs_wkd_in_perd_fctr_id PK of record being inserted or updated.
847 --   hrs_wkd_calc_rl    Value of formula rule id.
848 --   effective_date effective date
849 --   object_version_number Object version number of record being
850 --                                      inserted or updated.
851 --
852 -- Post Success
853 --   Processing continues
854 --
855 -- Post Failure
856 --   Error handled by procedure
857 --
858 -- Access Status
859 --   Internal table handler use only.
860 --
861 Procedure chk_hrs_wkd_calc_rl(p_hrs_wkd_in_perd_fctr_id     in number,
862                               p_business_group_id           in number,
863                               p_hrs_wkd_calc_rl             in number,
864                               p_effective_date              in date,
865                               p_object_version_number       in number) is
866   --
867   l_proc         varchar2(72) := g_package||'chk_hrs_wkd_calc_rl';
868   l_api_updating boolean;
869   l_dummy        varchar2(1);
870   --
871   cursor c1 is
872     select null
873     from   ff_formulas_f ff
874            ,per_business_groups pbg
875     where  ff.formula_id = p_hrs_wkd_calc_rl
876     and    ff.formula_type_id = -516
877     and    pbg.business_group_id = p_business_group_id
878     and    nvl(ff.business_group_id, p_business_group_id) =
879                p_business_group_id
880     and    nvl(ff.legislation_code, pbg.legislation_code) =
881                pbg.legislation_code
882     and    p_effective_date
883            between ff.effective_start_date
884            and     ff.effective_end_date;
885   --
886 Begin
887   --
888   hr_utility.set_location('Entering:'||l_proc, 5);
889   --
890   l_api_updating := ben_hwf_shd.api_updating
891     (p_hrs_wkd_in_perd_fctr_id     => p_hrs_wkd_in_perd_fctr_id,
892      p_object_version_number       => p_object_version_number);
893   --
894   if (l_api_updating
895       and nvl(p_hrs_wkd_calc_rl,hr_api.g_number)
896       <> ben_hwf_shd.g_old_rec.hrs_wkd_calc_rl
897       or not l_api_updating)
898       and p_hrs_wkd_calc_rl is not null then
899     --
900     -- check if value of formula rule is valid.
901     --
902     open c1;
903       --
904       -- fetch value from cursor if it returns a record then the
905       -- formula is valid otherwise its invalid
906       --
907       fetch c1 into l_dummy;
908       if c1%notfound then
909         --
910         close c1;
911         --
912         -- raise error
913         --
914         fnd_message.set_name('BEN','BEN_91471_FORMULA_NOT_FOUND');
915         fnd_message.set_token('ID',p_hrs_wkd_calc_rl);
916         fnd_message.set_token('TYPE_ID',-516);
917         fnd_message.raise_error;
918         --
919       end if;
920       --
921     close c1;
922     --
923   end if;
924   --
925   hr_utility.set_location('Leaving:'||l_proc,10);
926   --
927 end chk_hrs_wkd_calc_rl;
928 --
929 ------------------------------------------------------------------------
930 ----
931 -- |------< chk_name >------|
932 --
933 ------------------------------------------------------------------------
934 ----
935 --
936 -- Description
937 --   This procedure is used to check that the Name is unique in a business group.
938 --
939 -- Pre Conditions
940 --   None.
941 --
942 -- In Parameters
943 --   hrs_wkd_in_perd_fctr_id PK of record being inserted or updated.
944 --   name Value of Name.
945 --   effective_date effective date
946 --   object_version_number Object version number of record being
947 --                         inserted or updated.
948 --
949 -- Post Success
950 --   Processing continues
951 --
952 -- Post Failure
953 --   Error handled by procedure
954 --
955 -- Access Status
956 --   Internal table handler use only.
957 --
958 Procedure chk_name(p_hrs_wkd_in_perd_fctr_id                in number,
959                          p_business_group_id                in number,
960                          p_name                    in varchar2,
961                          p_effective_date              in date,
962                          p_object_version_number       in number) is
963   --
964   l_proc         varchar2(72):= g_package||'chk_name';
965   l_api_updating boolean;
966   l_dummy        varchar2(1);
967   --
968   cursor c1 is
969     select null
970     from   ben_hrs_wkd_in_perd_fctr  hwf
971     where  hwf.business_group_id = p_business_group_id and
972                  hwf.name = p_name;
973 Begin
974   --
975   hr_utility.set_location('Entering:'||l_proc, 5);
976   --
977   l_api_updating := ben_hwf_shd.api_updating
978     (p_hrs_wkd_in_perd_fctr_id                => p_hrs_wkd_in_perd_fctr_id,
979      -- p_effective_date              => p_effective_date,
980      p_object_version_number       => p_object_version_number);
981   --
982   if (l_api_updating
983       and nvl(p_name,hr_api.g_varchar2)
984       <> ben_hwf_shd.g_old_rec.name
985       or not l_api_updating)
986       and p_name is not null then
987     --
988     -- check if name already used.
989     --
990     open c1;
991       --
992       -- fetch value from cursor if it returns a record then the
993 
994       -- name is invalid otherwise its valid
995       --
996       fetch c1 into l_dummy;
997       if c1%found then
998         --
999         close c1;
1000         --
1001         -- raise error
1002         --
1003         fnd_message.set_name('BEN','BEN_91009_NAME_NOT_UNIQUE');
1004         fnd_message.raise_error;
1005         --
1006       end if;
1007       --
1008     close c1;
1009   end if;
1010   --
1011   hr_utility.set_location('Leaving:'||l_proc,10);
1012   --
1013 end chk_name;
1014   --
1015 ------------------------------------------------------------------------
1016 ----
1017 -- |------< chk_mn_mx_hrs_num >------|
1018 --
1019 ------------------------------------------------------------------------
1020 ----
1021 --
1022 -- Description
1023 --   This procedure is used to check that minimum hours nuumber is always less than
1024 --    max hours number.
1025 --
1026 -- Pre Conditions
1027 --   None.
1028 --
1029 -- In Parameters
1030 --   hrs_wkd_in_perd_fctr_id PK of record being inserted or updated.
1031 --   mn_hrs_num Value of Minimum hours worked.
1032 --   mx_hrs_num Value of Maximum hours worked.
1033 --   effective_date effective date
1034 --   object_version_number Object version number of record being
1035 --                         inserted or updated.
1036 --
1037 -- Post Success
1038 --   Processing continues
1039 --
1040 -- Post Failure
1041 --   Error handled by procedure
1042 --
1043 -- Access Status
1044 --   Internal table handler use only.
1045 --
1046 Procedure chk_mn_mx_hrs_num(p_hrs_wkd_in_perd_fctr_id  in number,
1047                          p_no_mn_hrs_wkd_flag          in varchar2,
1048                          p_mn_hrs_num                  in number,
1049                          p_no_mx_hrs_wkd_flag          in varchar2,
1050                          p_mx_hrs_num                  in number,
1051                          p_hrs_wkd_calc_rl             in number,
1052                          p_object_version_number       in number) is
1053   --
1054   l_proc   varchar2(72)  := g_package || 'chk_mn_mx_hrs_num';
1055   l_api_updating   boolean;
1056   l_dummy  varchar2(1);
1057   --
1058 Begin
1059   --
1060   hr_utility.set_location('Entering:'||l_proc, 5);
1061   --
1062   -- Minimum hours Number must be < Maximum hours Number,
1063   -- if both are used.
1064   --
1065   if p_mn_hrs_num is not null and p_mx_hrs_num is not null then
1066       --
1067       -- raise error if max value not greater than min value
1068       --
1069      -- Bug fix 1873685
1070      if  (p_mx_hrs_num < p_mn_hrs_num)  then
1071      -- if  (p_mx_hrs_num <= p_mn_hrs_num)  then
1072      -- end fix 1873685
1073       fnd_message.set_name('BEN','BEN_91069_INVALID_MIN_MAX');
1074       fnd_message.raise_error;
1075     end if;
1076       --
1077       --
1078   end if;
1079     --
1080       -- If No Minimum hours flag set to "on" (Y),
1081       --    then minimum hours number and calc rule must be blank.
1082       --
1083      if  p_no_mn_hrs_wkd_flag = 'Y'
1084          and (p_mn_hrs_num is not null) then
1085          --
1086          fnd_message.set_name('BEN','BEN_91054_MIN_VAL_NOT_NULL');
1087          fnd_message.raise_error;
1088          --
1089      elsif p_no_mn_hrs_wkd_flag = 'N' and
1090         p_mn_hrs_num is null then
1091         --
1092         fnd_message.set_name('BEN','BEN_91055_MIN_VAL_REQUIRED');
1093         fnd_message.raise_error;
1094         --
1095      end if;
1096      --
1097       -- If No Maximum hrs_wkd flag set to "on" (Y),
1098       --    then maximum hrs_wkd number and calc rule must be blank.
1099       --
1100      if  p_no_mx_hrs_wkd_flag  = 'Y'
1101          and (p_mx_hrs_num is not null) then
1102          --
1103          fnd_message.set_name('BEN','BEN_91056_MAX_VAL_NOT_NULL');
1104     fnd_message.raise_error;
1105     --
1106   elsif p_no_mx_hrs_wkd_flag = 'N' and
1107     p_mx_hrs_num is null then
1108     --
1109     fnd_message.set_name('BEN','BEN_91057_MAX_VAL_REQUIRED');
1110     fnd_message.raise_error;
1111     --
1112   end if;
1113 
1114    --
1115   hr_utility.set_location('Leaving:'||l_proc,10);
1116   --
1117 end chk_mn_mx_hrs_num;
1118 --
1119 -------------------------------------------------------------------------------
1120 -- |--------------------------< chk_source >---------------------------------|
1121 -------------------------------------------------------------------------------
1122 ----
1123 --
1124 -- Description
1125 --  This procedure checks to make sure that the Defined Balance is not null
1126 --  if the hrs_src_cd = BALTYP and that the Benefits Balance Type is not null
1127 --  if the hrs_src_cd = BNFTBALTYP
1128 --
1129 -- Pre Conditions
1130 --   None.
1131 --
1132 -- In Parameters
1133 --   hrs_src_cd            Source Code.
1134 --   defined_balance_id    Defined Balance.
1135 --   bnfts_bal_id          Benefits Balance Type.
1136 --
1137 -- Post Success
1138 --   Processing continues
1139 --
1140 -- Post Failure
1141 --   Error handled by procedure
1142 --
1143 -- Access Status
1144 --   Internal table handler use only.
1145 --
1146 Procedure chk_source(p_hrs_src_cd                  in varchar2,
1147                      p_defined_balance_id          in number,
1148                      p_bnfts_bal_id                in number) is
1149   --
1150   l_proc   varchar2(72)  := g_package || 'chk_source';
1151   --
1152 Begin
1153   --
1154   hr_utility.set_location('Entering:'||l_proc, 5);
1155   --
1156   -- Defined Balance must be entered if "Balance Type" is selected for
1157   -- Source.
1158   --
1159   if p_hrs_src_cd = 'BALTYP' and p_defined_balance_id is null then
1160      --
1161      fnd_message.set_name('BEN','BEN_91975_DEFINED_BALANCE');
1162      fnd_message.raise_error;
1163      --
1164   elsif p_hrs_src_cd = 'BNFTBALTYP' and p_bnfts_bal_id is null then
1165      --
1166      fnd_message.set_name('BEN','BEN_91976_BNFTS_BALANCE_TYP');
1167      fnd_message.raise_error;
1168      --
1169   end if;
1170       --
1171   hr_utility.set_location('Leaving:'||l_proc,10);
1172   --
1173 end chk_source;
1174 --
1175 --Bug 2978945 begin
1176 
1177   -- ----------------------------------------------------------------------- --
1178 -- -----------------------< chk_child_records >-----------------------------|
1179 -- -------------------------------------------------------------------------
1180 --
1181 -- Description
1182 --   This procedure is used to check that Hours worked child records do not exist
1183 --   when the user deletes the record in the BEN_HRS_WKD_IN_PERD_FCTR table.
1184 --
1185 -- Pre Conditions
1186 --   None.
1187 --
1188 -- In Parameters
1189 --   hrs_wkd_in_perd_fctr_id        PK of record being inserted or updated.
1190 --
1191 -- Post Success
1192 --   Processing continues
1193 --
1194 -- Post Failure
1195 --   Error handled by procedure
1196 --
1197 -- Access Status
1198 --   Internal table handler use only.
1199 --
1200 procedure chk_child_records(p_hrs_wkd_in_perd_fctr_id  in number) is
1201   --
1202   l_proc         varchar2(72):= g_package||'chk_child_records';
1203 
1204 begin
1205   --
1206   hr_utility.set_location('Entering:'||l_proc, 5);
1207 
1208  --Used in eligibility profiles
1209    If (ben_batch_utils.rows_exist
1210              (p_base_table_name => 'BEN_ELIG_HRS_WKD_PRTE_F',
1211               p_base_key_column => 'hrs_wkd_in_perd_fctr_id',
1212               p_base_key_value  => p_hrs_wkd_in_perd_fctr_id
1213              )) Then
1214 		ben_utility.child_exists_error('BEN_ELIG_HRS_WKD_PRTE_F');
1215    End If;
1216 
1217    --Used in variable rate profiles
1218    If (ben_batch_utils.rows_exist
1219              (p_base_table_name => 'BEN_HRS_WKD_IN_PERD_RT_F',
1220               p_base_key_column => 'hrs_wkd_in_perd_fctr_id',
1221               p_base_key_value  => p_hrs_wkd_in_perd_fctr_id
1222              )) Then
1223 		ben_utility.child_exists_error('BEN_HRS_WKD_IN_PERD_RT_F');
1224   End If;
1225 
1226   hr_utility.set_location('Leaving:'||l_proc,10);
1227   --
1228 end chk_child_records;
1229 
1230 --Bug 2978945
1231 
1232 -- ----------------------------------------------------------------------------
1233 -- |---------------------------< insert_validate >----------------------------|
1234 -- ----------------------------------------------------------------------------
1235 Procedure insert_validate(p_rec in ben_hwf_shd.g_rec_type
1236                          ,p_effective_date in date) is
1237 --
1238   l_proc  varchar2(72) := g_package||'insert_validate';
1239 --
1240 Begin
1241   hr_utility.set_location('Entering:'||l_proc, 5);
1242   --
1243   -- Call all supporting business operations
1244   --
1245   --
1246   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
1247   --
1248   chk_hrs_wkd_in_perd_fctr_id
1249   (p_hrs_wkd_in_perd_fctr_id  => p_rec.hrs_wkd_in_perd_fctr_id,
1250    p_object_version_number    => p_rec.object_version_number);
1251   --
1252   chk_once_r_cntug_cd
1253   (p_hrs_wkd_in_perd_fctr_id  => p_rec.hrs_wkd_in_perd_fctr_id,
1254    p_once_r_cntug_cd          => p_rec.once_r_cntug_cd,
1255    p_effective_date           => p_effective_date,
1256    p_object_version_number    => p_rec.object_version_number);
1257   --
1258   chk_no_mx_hrs_wkd_flag
1259   (p_hrs_wkd_in_perd_fctr_id  => p_rec.hrs_wkd_in_perd_fctr_id,
1260    p_no_mx_hrs_wkd_flag       => p_rec.no_mx_hrs_wkd_flag,
1261    p_effective_date           => p_effective_date,
1262    p_object_version_number    => p_rec.object_version_number);
1263   --
1264   chk_no_mn_hrs_wkd_flag
1265   (p_hrs_wkd_in_perd_fctr_id  => p_rec.hrs_wkd_in_perd_fctr_id,
1266    p_no_mn_hrs_wkd_flag       => p_rec.no_mn_hrs_wkd_flag,
1267    p_effective_date           => p_effective_date,
1268    p_object_version_number    => p_rec.object_version_number);
1269   --
1270   chk_hrs_wkd_det_rl
1271   (p_hrs_wkd_in_perd_fctr_id  => p_rec.hrs_wkd_in_perd_fctr_id,
1272    p_business_group_id        => p_rec.business_group_id,
1273    p_hrs_wkd_det_rl           => p_rec.hrs_wkd_det_rl,
1274    p_hrs_wkd_det_cd           => p_rec.hrs_wkd_det_cd,
1275    p_effective_date           => p_effective_date,
1276    p_object_version_number    => p_rec.object_version_number);
1277   --
1278   chk_hrs_wkd_det_cd
1279   (p_hrs_wkd_in_perd_fctr_id  => p_rec.hrs_wkd_in_perd_fctr_id,
1280    p_hrs_wkd_det_cd           => p_rec.hrs_wkd_det_cd,
1281    p_effective_date           => p_effective_date,
1282    p_object_version_number    => p_rec.object_version_number);
1283   --
1284   chk_rndg_rl
1285   (p_hrs_wkd_in_perd_fctr_id  => p_rec.hrs_wkd_in_perd_fctr_id,
1286    p_business_group_id        => p_rec.business_group_id,
1287    p_rndg_rl                  => p_rec.rndg_rl,
1288    p_rndg_cd                  => p_rec.rndg_cd,
1289    p_effective_date           => p_effective_date,
1290    p_object_version_number    => p_rec.object_version_number);
1291   --
1292   chk_rndg_cd
1293   (p_hrs_wkd_in_perd_fctr_id  => p_rec.hrs_wkd_in_perd_fctr_id,
1294    p_rndg_cd                  => p_rec.rndg_cd,
1295    p_effective_date           => p_effective_date,
1296    p_object_version_number    => p_rec.object_version_number);
1297   --
1298   chk_hrs_src_cd
1299   (p_hrs_wkd_in_perd_fctr_id  => p_rec.hrs_wkd_in_perd_fctr_id,
1300    p_hrs_src_cd               => p_rec.hrs_src_cd,
1301    p_effective_date           => p_effective_date,
1302    p_object_version_number    => p_rec.object_version_number);
1303   --
1304   chk_hrs_alt_val_to_use_cd
1305   (p_hrs_wkd_in_perd_fctr_id  => p_rec.hrs_wkd_in_perd_fctr_id,
1306    p_hrs_alt_val_to_use_cd    => p_rec.hrs_alt_val_to_use_cd,
1307    p_effective_date           => p_effective_date,
1308    p_object_version_number    => p_rec.object_version_number);
1309   --
1310   chk_pyrl_freq_cd
1311   (p_hrs_wkd_in_perd_fctr_id => p_rec.hrs_wkd_in_perd_fctr_id,
1312    p_pyrl_freq_cd            => p_rec.pyrl_freq_cd,
1313    p_effective_date          => p_effective_date,
1314    p_object_version_number   => p_rec.object_version_number);
1315   --
1316   chk_hrs_wkd_calc_rl
1317   (p_hrs_wkd_in_perd_fctr_id   => p_rec.hrs_wkd_in_perd_fctr_id,
1318    p_business_group_id         => p_rec.business_group_id,
1319    p_hrs_wkd_calc_rl           => p_rec.hrs_wkd_calc_rl,
1320    p_effective_date            => p_effective_date,
1321    p_object_version_number     => p_rec.object_version_number);
1322   --
1323   chk_mn_mx_hrs_num
1324   (p_hrs_wkd_in_perd_fctr_id  => p_rec.hrs_wkd_in_perd_fctr_id,
1325    p_no_mn_hrs_wkd_flag       => p_rec.no_mn_hrs_wkd_flag,
1326    p_mn_hrs_num               => p_rec.mn_hrs_num,
1327    p_no_mx_hrs_wkd_flag       => p_rec.no_mx_hrs_wkd_flag,
1328    p_mx_hrs_num               => p_rec.mx_hrs_num,
1329    p_hrs_wkd_calc_rl          => p_rec.hrs_wkd_calc_rl,
1330    p_object_version_number    => p_rec.object_version_number);
1331   --
1332   chk_name
1333   (p_hrs_wkd_in_perd_fctr_id  => p_rec.hrs_wkd_in_perd_fctr_id,
1334    p_business_group_id        => p_rec.business_group_id,
1335    p_name                     => p_rec.name,
1336    p_effective_date           => p_effective_date,
1337    p_object_version_number    => p_rec.object_version_number);
1338  --
1339   chk_source
1340   (p_hrs_src_cd               => p_rec.hrs_src_cd,
1341    p_defined_balance_id       => p_rec.defined_balance_id,
1342    p_bnfts_bal_id             => p_rec.bnfts_bal_id);
1343   --
1344   hr_utility.set_location(' Leaving:'||l_proc, 10);
1345 End insert_validate;
1346 --
1347 -- ----------------------------------------------------------------------------
1348 -- |---------------------------< update_validate >----------------------------|
1349 -- ----------------------------------------------------------------------------
1350 Procedure update_validate(p_rec in ben_hwf_shd.g_rec_type
1351                          ,p_effective_date in date) is
1352 --
1353   l_proc  varchar2(72) := g_package||'update_validate';
1354 --
1355 Begin
1356   hr_utility.set_location('Entering:'||l_proc, 5);
1357   --
1358   -- Call all supporting business operations
1359   --
1360   --
1361   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
1362   --
1363   chk_hrs_wkd_in_perd_fctr_id
1364   (p_hrs_wkd_in_perd_fctr_id  => p_rec.hrs_wkd_in_perd_fctr_id,
1365    p_object_version_number    => p_rec.object_version_number);
1366   --
1367   chk_once_r_cntug_cd
1368   (p_hrs_wkd_in_perd_fctr_id  => p_rec.hrs_wkd_in_perd_fctr_id,
1369    p_once_r_cntug_cd          => p_rec.once_r_cntug_cd,
1370    p_effective_date           => p_effective_date,
1371    p_object_version_number    => p_rec.object_version_number);
1372   --
1373   chk_no_mx_hrs_wkd_flag
1374   (p_hrs_wkd_in_perd_fctr_id  => p_rec.hrs_wkd_in_perd_fctr_id,
1375    p_no_mx_hrs_wkd_flag       => p_rec.no_mx_hrs_wkd_flag,
1376    p_effective_date           => p_effective_date,
1377    p_object_version_number    => p_rec.object_version_number);
1378   --
1379   chk_no_mn_hrs_wkd_flag
1380   (p_hrs_wkd_in_perd_fctr_id  => p_rec.hrs_wkd_in_perd_fctr_id,
1381    p_no_mn_hrs_wkd_flag       => p_rec.no_mn_hrs_wkd_flag,
1382    p_effective_date           => p_effective_date,
1383    p_object_version_number    => p_rec.object_version_number);
1384   --
1385   chk_hrs_wkd_det_rl
1386   (p_hrs_wkd_in_perd_fctr_id  => p_rec.hrs_wkd_in_perd_fctr_id,
1387    p_business_group_id        => p_rec.business_group_id,
1388    p_hrs_wkd_det_rl           => p_rec.hrs_wkd_det_rl,
1389    p_hrs_wkd_det_cd           => p_rec.hrs_wkd_det_cd,
1390    p_effective_date           => p_effective_date,
1391    p_object_version_number    => p_rec.object_version_number);
1392   --
1393   chk_hrs_wkd_det_cd
1394   (p_hrs_wkd_in_perd_fctr_id  => p_rec.hrs_wkd_in_perd_fctr_id,
1395    p_hrs_wkd_det_cd           => p_rec.hrs_wkd_det_cd,
1396    p_effective_date           => p_effective_date,
1397    p_object_version_number    => p_rec.object_version_number);
1398   --
1399   chk_rndg_rl
1400   (p_hrs_wkd_in_perd_fctr_id  => p_rec.hrs_wkd_in_perd_fctr_id,
1401    p_business_group_id        => p_rec.business_group_id,
1402    p_rndg_rl                  => p_rec.rndg_rl,
1403    p_rndg_cd                  => p_rec.rndg_cd,
1404    p_effective_date           => p_effective_date,
1405    p_object_version_number    => p_rec.object_version_number);
1406   --
1407   chk_rndg_cd
1408   (p_hrs_wkd_in_perd_fctr_id  => p_rec.hrs_wkd_in_perd_fctr_id,
1409    p_rndg_cd                  => p_rec.rndg_cd,
1410    p_effective_date           => p_effective_date,
1411    p_object_version_number    => p_rec.object_version_number);
1412   --
1413   chk_hrs_src_cd
1414   (p_hrs_wkd_in_perd_fctr_id  => p_rec.hrs_wkd_in_perd_fctr_id,
1415    p_hrs_src_cd               => p_rec.hrs_src_cd,
1416    p_effective_date           => p_effective_date,
1417    p_object_version_number    => p_rec.object_version_number);
1418   --
1419   chk_hrs_alt_val_to_use_cd
1420   (p_hrs_wkd_in_perd_fctr_id => p_rec.hrs_wkd_in_perd_fctr_id,
1421    p_hrs_alt_val_to_use_cd   => p_rec.hrs_alt_val_to_use_cd,
1422    p_effective_date          => p_effective_date,
1423    p_object_version_number   => p_rec.object_version_number);
1424   --
1425   chk_pyrl_freq_cd
1426   (p_hrs_wkd_in_perd_fctr_id => p_rec.hrs_wkd_in_perd_fctr_id,
1427    p_pyrl_freq_cd            => p_rec.pyrl_freq_cd,
1428    p_effective_date          => p_effective_date,
1429    p_object_version_number   => p_rec.object_version_number);
1430   --
1431   chk_hrs_wkd_calc_rl
1432   (p_hrs_wkd_in_perd_fctr_id   => p_rec.hrs_wkd_in_perd_fctr_id,
1433    p_business_group_id         => p_rec.business_group_id,
1434    p_hrs_wkd_calc_rl           => p_rec.hrs_wkd_calc_rl,
1435    p_effective_date            => p_effective_date,
1436    p_object_version_number     => p_rec.object_version_number);
1437   --
1438   chk_mn_mx_hrs_num
1439   (p_hrs_wkd_in_perd_fctr_id => p_rec.hrs_wkd_in_perd_fctr_id,
1440    p_no_mn_hrs_wkd_flag      => p_rec.no_mn_hrs_wkd_flag,
1441    p_mn_hrs_num              => p_rec.mn_hrs_num,
1442    p_no_mx_hrs_wkd_flag      => p_rec.no_mx_hrs_wkd_flag,
1443    p_mx_hrs_num              => p_rec.mx_hrs_num,
1444    p_hrs_wkd_calc_rl         => p_rec.hrs_wkd_calc_rl,
1445    p_object_version_number   => p_rec.object_version_number);
1446   --
1447   chk_name
1448   (p_hrs_wkd_in_perd_fctr_id => p_rec.hrs_wkd_in_perd_fctr_id,
1449    p_business_group_id       => p_rec.business_group_id,
1450    p_name                    => p_rec.name,
1451    p_effective_date          => p_effective_date,
1452    p_object_version_number   => p_rec.object_version_number);
1453  --
1454   chk_source
1455   (p_hrs_src_cd              => p_rec.hrs_src_cd,
1456    p_defined_balance_id      => p_rec.defined_balance_id,
1457    p_bnfts_bal_id            => p_rec.bnfts_bal_id);
1458   --
1459   hr_utility.set_location(' Leaving:'||l_proc, 10);
1460 End update_validate;
1461 --
1462 -- ----------------------------------------------------------------------------
1463 -- |---------------------------< delete_validate >----------------------------|
1464 -- ----------------------------------------------------------------------------
1465 Procedure delete_validate(p_rec in ben_hwf_shd.g_rec_type
1466                          ,p_effective_date in date) is
1467 --
1468   l_proc  varchar2(72) := g_package||'delete_validate';
1469 --
1470 Begin
1471   hr_utility.set_location('Entering:'||l_proc, 5);
1472   --
1473   -- Call all supporting business operations
1474   --
1475   chk_child_records(p_hrs_wkd_in_perd_fctr_id => p_rec.hrs_wkd_in_perd_fctr_id); --Bug 2978945
1476   hr_utility.set_location(' Leaving:'||l_proc, 10);
1477 End delete_validate;
1478 --
1479 --
1480 --  ---------------------------------------------------------------------------
1481 --  |---------------------< return_legislation_code >-------------------------|
1482 --  ---------------------------------------------------------------------------
1483 --
1484 function return_legislation_code
1485   (p_hrs_wkd_in_perd_fctr_id in number) return varchar2 is
1486   --
1487   -- Declare cursor
1488   --
1489   cursor csr_leg_code is
1490     select a.legislation_code
1491     from   per_business_groups a,
1492            ben_hrs_wkd_in_perd_fctr b
1493     where b.hrs_wkd_in_perd_fctr_id      = p_hrs_wkd_in_perd_fctr_id
1494     and   a.business_group_id = b.business_group_id;
1495   --
1496   -- Declare local variables
1497   --
1498   l_legislation_code  varchar2(150);
1499   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
1500   --
1501 begin
1502   --
1503   hr_utility.set_location('Entering:'|| l_proc, 10);
1504   --
1505   -- Ensure that all the mandatory parameter are not null
1506   --
1507   hr_api.mandatory_arg_error(p_api_name       => l_proc,
1508                              p_argument       => 'hrs_wkd_in_perd_fctr_id',
1509                              p_argument_value => p_hrs_wkd_in_perd_fctr_id);
1510   --
1511   open csr_leg_code;
1512     --
1513     fetch csr_leg_code into l_legislation_code;
1514     --
1515     if csr_leg_code%notfound then
1516       --
1517       close csr_leg_code;
1518       --
1519       -- The primary key is invalid therefore we must error
1520       --
1521       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
1522       fnd_message.raise_error;
1523       --
1524     end if;
1525     --
1526   close csr_leg_code;
1527   --
1528   hr_utility.set_location(' Leaving:'|| l_proc, 20);
1529   --
1530   return l_legislation_code;
1531   --
1532 end return_legislation_code;
1533 --
1534 end ben_hwf_bus;