DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_CNU_BUS

Source


1 Package Body pay_cnu_bus as
2 /* $Header: pycnurhi.pkb 120.0 2005/05/29 04:04:56 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pay_cnu_bus.';  -- Global package name
9 --
10 -- The following two global variables are only to be
11 -- used by the return_legislation_code function.
12 --
13 g_legislation_code            varchar2(150)  default null;
14 g_contribution_usage_id       number         default null;
15 --
16 --  ---------------------------------------------------------------------------
17 --  |----------------------< set_security_group_id >--------------------------|
18 --  ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21   (p_contribution_usage_id                in number
22   ) is
23   --
24   -- Declare cursor
25   --
26   cursor csr_sec_grp is
27     select pbg.security_group_id
28       from per_business_groups pbg
29          , pay_fr_contribution_usages con
30      where con.contribution_usage_id = p_contribution_usage_id
31        and pbg.business_group_id = con.business_group_id;
32   --
33   -- Declare local variables
34   --
35   l_security_group_id number;
36   l_proc              varchar2(72)  :=  g_package||'set_security_group_id';
37   --
38 begin
39   --
40   hr_utility.set_location('Entering:'|| l_proc, 10);
41   --
42   -- Ensure that all the mandatory parameter are not null
43   --
44   hr_api.mandatory_arg_error
45     (p_api_name           => l_proc
46     ,p_argument           => 'contribution_usage_id'
47     ,p_argument_value     => p_contribution_usage_id
48     );
49   --
50   open csr_sec_grp;
51   fetch csr_sec_grp into l_security_group_id;
52   --
53   if csr_sec_grp%notfound then
54      --
55      close csr_sec_grp;
56      --
57      -- The primary key is invalid therefore we must error
58      --
59      fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
60      fnd_message.raise_error;
61      --
62   end if;
63   close csr_sec_grp;
64   --
65   -- Set the security_group_id in CLIENT_INFO
66   --
67   hr_api.set_security_group_id
68     (p_security_group_id => l_security_group_id
69     );
70   --
71   hr_utility.set_location(' Leaving:'|| l_proc, 20);
72   --
73 end set_security_group_id;
74 --
75 --  ---------------------------------------------------------------------------
76 --  |---------------------< return_legislation_code >-------------------------|
77 --  ---------------------------------------------------------------------------
78 --
79 Function return_legislation_code
80   (p_contribution_usage_id                in     number
81   )
82   Return Varchar2 Is
83   --
84   -- Declare cursor
85   --
86   cursor csr_leg_code is
87     select pbg.legislation_code
88       from per_business_groups pbg
89          , pay_fr_contribution_usages con
90      where con.contribution_usage_id = p_contribution_usage_id
91        and pbg.business_group_id (+) = con.business_group_id;
92   --
93   -- Declare local variables
94   --
95   l_legislation_code  varchar2(150);
96   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
97   --
98 Begin
99   --
100   hr_utility.set_location('Entering:'|| l_proc, 10);
101   --
102   -- Ensure that all the mandatory parameter are not null
103   --
104   hr_api.mandatory_arg_error
105     (p_api_name           => l_proc
106     ,p_argument           => 'contribution_usage_id'
107     ,p_argument_value     => p_contribution_usage_id
108     );
109   --
110   if ( nvl(pay_cnu_bus.g_contribution_usage_id, hr_api.g_number)
111        = p_contribution_usage_id) then
112     --
113     -- The legislation code has already been found with a previous
114     -- call to this function. Just return the value in the global
115     -- variable.
116     --
117     l_legislation_code := pay_cnu_bus.g_legislation_code;
118     hr_utility.set_location(l_proc, 20);
119   else
120     --
121     -- The ID is different to the last call to this function
122     -- or this is the first call to this function.
123     --
124     open csr_leg_code;
125     fetch csr_leg_code into l_legislation_code;
126     --
127     if csr_leg_code%notfound then
128       --
129       -- The primary key is invalid therefore we must error
130       --
131       close csr_leg_code;
132       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
133       fnd_message.raise_error;
134     end if;
135     hr_utility.set_location(l_proc,30);
136     --
137     -- Set the global variables so the values are
138     -- available for the next call to this function.
139     --
140     close csr_leg_code;
141     pay_cnu_bus.g_contribution_usage_id := p_contribution_usage_id;
142     pay_cnu_bus.g_legislation_code  := l_legislation_code;
143   end if;
144   hr_utility.set_location(' Leaving:'|| l_proc, 40);
145   return l_legislation_code;
146 end return_legislation_code;
147 --
148 -- ----------------------------------------------------------------------------
149 -- |-----------------------< chk_non_updateable_args >------------------------|
150 -- ----------------------------------------------------------------------------
151 -- {Start Of Comments}
152 --
153 -- Description:
154 --   This procedure is used to ensure that non updateable attributes have
155 --   not been updated. If an attribute has been updated an error is generated.
156 --
157 -- Pre Conditions:
158 --   g_old_rec has been populated with details of the values currently in
159 --   the database.
160 --
161 -- In Arguments:
162 --   p_rec has been populated with the updated values the user would like the
163 --   record set to.
164 --
165 -- Post Success:
166 --   Processing continues if all the non updateable attributes have not
167 --   changed.
168 --
169 -- Post Failure:
170 --   An application error is raised if any of the non updatable attributes
171 --   have been altered.
172 --
173 -- {End Of Comments}
174 -- ----------------------------------------------------------------------------
175 Procedure chk_non_updateable_args
176   (p_rec in pay_cnu_shd.g_rec_type
177   ) IS
178 --
179   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
180   l_error    EXCEPTION;
181   l_argument varchar2(30);
182 --
183 Begin
184   --
185   -- Only proceed with the validation if a row exists for the current
186   -- record in the HR Schema.
187   --
188   IF NOT pay_cnu_shd.api_updating
189       (p_contribution_usage_id                => p_rec.contribution_usage_id
190       ,p_object_version_number                => p_rec.object_version_number
191       ) THEN
192      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
193      fnd_message.set_token('PROCEDURE ', l_proc);
194      fnd_message.set_token('STEP ', '5');
195      fnd_message.raise_error;
196   END IF;
197   --
198   --
199   hr_utility.set_location(' Step:'|| l_proc, 10);
200   if nvl(p_rec.contribution_usage_id, hr_api.g_number) <>
201      nvl(pay_cnu_shd.g_old_rec.contribution_usage_id, hr_api.g_number) then
202      l_argument := 'contribution_usage_id';
203      raise l_error;
204   end if;
205   --
206   hr_utility.set_location(' Step:'|| l_proc, 20);
207   if nvl(p_rec.date_from, hr_api.g_date) <>
208      nvl(pay_cnu_shd.g_old_rec.date_from, hr_api.g_date) then
209      l_argument := 'date_from';
210      raise l_error;
211   end if;
212   --
213   hr_utility.set_location(' Step:'|| l_proc, 40);
214   if nvl(p_rec.group_code, hr_api.g_varchar2) <>
215      nvl(pay_cnu_shd.g_old_rec.group_code, hr_api.g_varchar2) then
216      l_argument := 'group_code';
217      raise l_error;
218   end if;
219   --
220   hr_utility.set_location(' Step:'|| l_proc, 50);
221   if nvl(p_rec.process_type, hr_api.g_varchar2) <>
222      nvl(pay_cnu_shd.g_old_rec.process_type, hr_api.g_varchar2) then
223      l_argument := 'process_type';
224      raise l_error;
225   end if;
226   --
227   hr_utility.set_location(' Step:'|| l_proc, 60);
228   if nvl(p_rec.element_name, hr_api.g_varchar2) <>
229      nvl(pay_cnu_shd.g_old_rec.element_name, hr_api.g_varchar2) then
230      l_argument := 'element_name';
231      raise l_error;
232   end if;
233   --
234   hr_utility.set_location(' Step:'|| l_proc, 70);
235   if nvl(p_rec.rate_type, hr_api.g_varchar2) <>
236      nvl(pay_cnu_shd.g_old_rec.rate_type, hr_api.g_varchar2) then
237      l_argument := 'rate_type';
238      raise l_error;
239   end if;
240   --
241   hr_utility.set_location(' Step:'|| l_proc, 80);
242 /*  if nvl(p_rec.contribution_code, hr_api.g_varchar2) <>
243      nvl(pay_cnu_shd.g_old_rec.contribution_code, hr_api.g_varchar2) then
244      l_argument := 'contribution_code';
245      raise l_error;
246   end if;
247   --
248   hr_utility.set_location(' Step:'|| l_proc, 90);
249   if nvl(p_rec.contribution_type, hr_api.g_varchar2) <>
250      nvl(pay_cnu_shd.g_old_rec.contribution_type, hr_api.g_varchar2) then
251      l_argument := 'contribution_type';
252      raise l_error;
253   end if;*/
254   --
255   hr_utility.set_location(' Step:'|| l_proc, 100);
256   if nvl(p_rec.contribution_usage_type, hr_api.g_varchar2) <>
257      nvl(pay_cnu_shd.g_old_rec.contribution_usage_type, hr_api.g_varchar2) then
258      l_argument := 'contribution_usage_type';
259      raise l_error;
260   end if;
261   --
262   hr_utility.set_location(' Step:'|| l_proc, 110);
263   if nvl(p_rec.rate_category, hr_api.g_varchar2) <>
264      nvl(pay_cnu_shd.g_old_rec.rate_category, hr_api.g_varchar2) then
265      l_argument := 'rate_category';
266      raise l_error;
267   end if;
268   --
269   hr_utility.set_location(' Step:'|| l_proc, 120);
270   if nvl(p_rec.business_group_id, hr_api.g_number) <>
271      nvl(pay_cnu_shd.g_old_rec.business_group_id, hr_api.g_number) then
272      l_argument := 'business_group_id';
273      raise l_error;
274   end if;
275   --
276   hr_utility.set_location(' Step:'|| l_proc, 130);
277   /*if nvl(p_rec.code_rate_id, hr_api.g_number) <>
278      nvl(pay_cnu_shd.g_old_rec.code_rate_id, hr_api.g_number) then
279      l_argument := 'code_rate_id';
280      raise l_error;
281   end if;*/
282   --
283   EXCEPTION
284     WHEN l_error THEN
285        hr_api.argument_changed_error
286          (p_api_name => l_proc
287          ,p_argument => l_argument);
288     WHEN OTHERS THEN
289        RAISE;
290 End chk_non_updateable_args;
291 --
292 -- ----------------------------------------------------------------------------
293 -- |---------------------------< insert_validate >----------------------------|
294 -- ----------------------------------------------------------------------------
295 Procedure insert_validate
296   (p_effective_date               in     date
297   ,p_rec                          in pay_cnu_shd.g_rec_type
298   ,p_code_Rate_id                 out nocopy PAY_FR_CONTRIBUTION_USAGES.CODE_RATE_ID%TYPE
299   ) is
300 --
301   l_proc  varchar2(72) := g_package||'insert_validate';
302   l_code_Rate_id  PAY_FR_CONTRIBUTION_USAGES.CODE_RATE_ID%TYPE := p_rec.code_Rate_id;
303 --
304 Begin
305   hr_utility.set_location('Entering:'||l_proc, 5);
306   --
307   -- No business group context. HR_STANDARD_LOOKUPS used for validation.
308   --
309   -- Call all supporting business operations
310   --
311   --
312   if p_rec.business_group_id is not null THEN
313     hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
314   end if;
315   --
316   hr_utility.set_location(' Step:'|| l_proc, 10);
317   pay_cnu_bus1.chk_dates (
318     p_contribution_usage_id   => p_rec.contribution_usage_id
319    ,p_object_version_number   => p_rec.object_version_number
320    ,p_date_from               => p_rec.date_from
321    ,p_date_to                 => p_rec.date_to
322    ,p_group_code              => p_rec.group_code
323    ,p_process_type            => p_rec.process_type
324    ,p_element_name            => p_rec.element_name
325    ,p_contribution_usage_type => p_rec.contribution_usage_type
326    ,p_business_group_id       => p_rec.business_group_id
327    );
328   --
329 
330   hr_utility.set_location(' Step:'|| l_proc, 15);
331   pay_cnu_bus1.chk_lu_group_code (
332   p_effective_date          => p_effective_date
333  ,p_group_code              => p_rec.group_code
334    );
335   --
336   hr_utility.set_location(' Step:'|| l_proc, 20);
337   pay_cnu_bus1.chk_group_code (
338     p_group_code              => p_rec.group_code
339    ,p_process_type            => p_rec.process_type
340    ,p_element_name            => p_rec.element_name
341    ,p_contribution_usage_type => p_rec.contribution_usage_type
342    ,p_business_group_id       => p_rec.business_group_id
343    );
344   --
345   hr_utility.set_location(' Step:'|| l_proc, 30);
346   pay_cnu_bus1.chk_contribution_type (
347     p_contribution_type => p_rec.contribution_type
348    );
349   --
350   hr_utility.set_location(' Step:'|| l_proc, 40);
351   pay_cnu_bus1.chk_contribution_codes (
352   p_contribution_usage_id   => p_rec.contribution_usage_id
353  ,p_object_version_number   => p_rec.object_version_number
354  ,p_contribution_type       => p_rec.contribution_type
355  ,p_contribution_code       => p_rec.contribution_code
356  ,p_retro_contribution_code => p_rec.retro_contribution_code
357  ,p_rate_category           => p_rec.rate_category
358  );
359   --
360   hr_utility.set_location(' Step:'|| l_proc, 50);
361   pay_cnu_bus1.chk_rate_category_type (
362   p_rate_type               => p_rec.rate_type
363  ,p_rate_category           => p_rec.rate_category
364  );
365   --
366   hr_utility.set_location(' Step:'|| l_proc, 60);
367   pay_cnu_bus1.chk_business_group_id (
368   p_business_group_id       => p_rec.business_group_id
369    );
370   --
371   hr_utility.set_location(' Step:'|| l_proc, 80);
372   pay_cnu_bus1.chk_process_type (
373   p_effective_date          => p_effective_date
374  ,p_process_type            => p_rec.process_type
375    );
376   --
377   hr_utility.set_location(' Step:'|| l_proc, 90);
378   pay_cnu_bus1.chk_rate_type (
379   p_effective_date          => p_effective_date
380  ,p_rate_type               => p_rec.rate_type
381    );
382   --
383   hr_utility.set_location(' Step:'|| l_proc, 90);
384   pay_cnu_bus1.chk_contribution_usage_type (
385   p_effective_date          => p_effective_date
386  ,p_contribution_usage_type => p_rec.contribution_usage_type
387    );
388   --
389   hr_utility.set_location(' Step:'|| l_proc, 100);
390   pay_cnu_bus1.chk_element_name (
391   p_element_name            => p_rec.element_name
392    );
393   --
394   hr_utility.set_location(' Step:'|| l_proc, 110);
395   pay_cnu_bus1.chk_code_rate_id (
396   p_code_rate_id            => l_code_Rate_id
397  ,p_contribution_code       => p_rec.contribution_code
398  ,p_business_group_id       => p_rec.business_group_id
399  ,p_rate_type               => p_rec.rate_type
400  ,p_rate_category           => p_rec.rate_category
401   );
402   /* set the out parameter */
403   p_code_Rate_id := l_code_rate_id;
404   hr_utility.set_location(' Leaving:'||l_proc, 200);
405 End insert_validate;
406 --
407 -- ----------------------------------------------------------------------------
408 -- |---------------------------< update_validate >----------------------------|
409 -- ----------------------------------------------------------------------------
410 Procedure update_validate
411   (p_effective_date               in     date
412   ,p_rec                          in pay_cnu_shd.g_rec_type
413   ) is
414 --
415   l_proc  varchar2(72) := g_package||'update_validate';
416 --
417 Begin
418   hr_utility.set_location('Entering:'||l_proc, 5);
419   --
420   -- No business group context. HR_STANDARD_LOOKUPS used for validation.
421   --
422   -- Call all supporting business operations
423   --
424   --
425   chk_non_updateable_args
426     (p_rec              => p_rec
427     );
428   --
429   hr_utility.set_location(' Step:'|| l_proc, 10);
430   pay_cnu_bus1.chk_dates (
431     p_contribution_usage_id   => p_rec.contribution_usage_id
432    ,p_object_version_number   => p_rec.object_version_number
433    ,p_date_from               => p_rec.date_from
434    ,p_date_to                 => p_rec.date_to
435    ,p_group_code              => p_rec.group_code
436    ,p_process_type            => p_rec.process_type
437    ,p_element_name            => p_rec.element_name
438    ,p_contribution_usage_type => p_rec.contribution_usage_type
439    ,p_business_group_id       => p_rec.business_group_id
440    );
441    -- The contribution type is also updated.  Though the contribution
442    -- type is checked in chk_non_updateable_args, it is also checked here.
443    hr_utility.set_location(' Step:'|| l_proc, 50);
444    pay_cnu_bus1.chk_contribution_type (
445     p_contribution_type => p_rec.contribution_type
446    );
447   --
448   hr_utility.set_location(' Step:'|| l_proc, 40);
449   pay_cnu_bus1.chk_contribution_codes (
450   p_contribution_usage_id   => p_rec.contribution_usage_id
451  ,p_object_version_number   => p_rec.object_version_number
452  ,p_contribution_type       => p_rec.contribution_type
453  ,p_contribution_code       => p_rec.contribution_code
454  ,p_retro_contribution_code => p_rec.retro_contribution_code
455  ,p_rate_category           => p_rec.rate_category
456  );
457   hr_utility.set_location(' Leaving:'||l_proc, 20);
458 End update_validate;
459 --
460 -- ----------------------------------------------------------------------------
461 -- |---------------------------< delete_validate >----------------------------|
462 -- ----------------------------------------------------------------------------
463 Procedure delete_validate
464   (p_rec                          in pay_cnu_shd.g_rec_type
465   ) is
466 --
467   l_proc  varchar2(72) := g_package||'delete_validate';
468 --
469 Begin
470   hr_utility.set_location('Entering:'||l_proc, 5);
471   --
472   -- Call all supporting business operations
473   --
474   hr_utility.set_location(' Leaving:'||l_proc, 10);
475 End delete_validate;
476 --
477 end pay_cnu_bus;