DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_OPT_BUS

Source


1 Package Body pay_opt_bus as
2 /* $Header: pyoptrhi.pkb 115.3 2002/12/05 17:29:47 nbristow noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pay_opt_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_org_payment_method_id       number         default null;
15 g_language                    varchar2(4)    default null;
16 --
17 --  ---------------------------------------------------------------------------
18 --  |----------------------< set_security_group_id >--------------------------|
19 --  ---------------------------------------------------------------------------
20 --
21 Procedure set_security_group_id
22   (p_org_payment_method_id                in number
23   ) is
24   --
25   -- Declare cursor
26   --
27   cursor csr_sec_grp is
28     select pbg.security_group_id
29       from per_business_groups pbg
30          , pay_org_payment_methods_f opm
31      where opm.org_payment_method_id = p_org_payment_method_id
32        and pbg.business_group_id = opm.business_group_id;
33   --
34   -- Declare local variables
35   --
36   l_security_group_id number;
37   l_proc              varchar2(72)  :=  g_package||'set_security_group_id';
38   --
39 begin
40   --
41   hr_utility.set_location('Entering:'|| l_proc, 10);
42   --
43   -- Ensure that all the mandatory parameter are not null
44   --
45   hr_api.mandatory_arg_error
46     (p_api_name           => l_proc
47     ,p_argument           => 'org_payment_method_id'
48     ,p_argument_value     => p_org_payment_method_id
49     );
50   --
51   --
52   open csr_sec_grp;
53   fetch csr_sec_grp into l_security_group_id;
54   --
55   if csr_sec_grp%notfound then
56      --
57      close csr_sec_grp;
58      --
59      -- The primary key is invalid therefore we must error
60      --
61      fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
62      fnd_message.raise_error;
63      --
64   end if;
65   close csr_sec_grp;
66   --
67   -- Set the security_group_id in CLIENT_INFO
68   --
69   hr_api.set_security_group_id
70     (p_security_group_id => l_security_group_id
71     );
72   --
73   hr_utility.set_location(' Leaving:'|| l_proc, 20);
74   --
75 end set_security_group_id;
76 --
77 --  ---------------------------------------------------------------------------
78 --  |---------------------< return_legislation_code >-------------------------|
79 --  ---------------------------------------------------------------------------
80 --
81 Function return_legislation_code
82   (p_org_payment_method_id                in     number
83   ,p_language                             in     varchar2
84   )
85   Return Varchar2 Is
86   --
87   -- Declare cursor
88   --
89   cursor csr_leg_code is
90     select pbg.legislation_code
91       from per_business_groups     pbg
92          , pay_org_payment_methods_f_tl opt
93          , pay_org_payment_methods_f opm
94      where opt.org_payment_method_id = p_org_payment_method_id
95        and opt.language = p_language
96        and opm.org_payment_method_id = opt.org_payment_method_id
97        and pbg.business_group_id = opm.business_group_id;
98   --
99   -- Declare local variables
100   --
101   l_legislation_code  varchar2(150);
102   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
103   --
104 Begin
105   --
106   hr_utility.set_location('Entering:'|| l_proc, 10);
107   --
108   -- Ensure that all the mandatory parameter are not null
109   --
110   hr_api.mandatory_arg_error
111     (p_api_name           => l_proc
112     ,p_argument           => 'org_payment_method_id'
113     ,p_argument_value     => p_org_payment_method_id
114     );
115   --
116   --
117   if (( nvl(pay_opt_bus.g_org_payment_method_id, hr_api.g_number)
118        = p_org_payment_method_id)
119   and ( nvl(pay_opt_bus.g_language, hr_api.g_varchar2)
120        = p_language)) then
121     --
122     -- The legislation code has already been found with a previous
123     -- call to this function. Just return the value in the global
124     -- variable.
125     --
126     l_legislation_code := pay_opt_bus.g_legislation_code;
127     hr_utility.set_location(l_proc, 20);
128   else
129     --
130     -- The ID is different to the last call to this function
131     -- or this is the first call to this function.
132     --
133     open csr_leg_code;
134     fetch csr_leg_code into l_legislation_code;
135     --
136     if csr_leg_code%notfound then
137       --
138       -- The primary key is invalid therefore we must error
139       --
140       close csr_leg_code;
141       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
142       fnd_message.raise_error;
143     end if;
144     hr_utility.set_location(l_proc,30);
145     --
146     -- Set the global variables so the values are
147     -- available for the next call to this function.
148     --
149     close csr_leg_code;
150     pay_opt_bus.g_org_payment_method_id:= p_org_payment_method_id;
151     pay_opt_bus.g_language          := p_language;
152     pay_opt_bus.g_legislation_code  := l_legislation_code;
153   end if;
154   hr_utility.set_location(' Leaving:'|| l_proc, 40);
155   return l_legislation_code;
156 end return_legislation_code;
157 --
158 -- ----------------------------------------------------------------------------
159 -- |-----------------------< chk_non_updateable_args >------------------------|
160 -- ----------------------------------------------------------------------------
161 -- {Start Of Comments}
162 --
163 -- Description:
164 --   This procedure is used to ensure that non updateable attributes have
165 --   not been updated. If an attribute has been updated an error is generated.
166 --
167 -- Pre Conditions:
168 --   g_old_rec has been populated with details of the values currently in
169 --   the database.
170 --
171 -- In Arguments:
172 --   p_rec has been populated with the updated values the user would like the
173 --   record set to.
174 --
175 -- Post Success:
176 --   Processing continues if all the non updateable attributes have not
177 --   changed.
178 --
179 -- Post Failure:
180 --   An application error is raised if any of the non updatable attributes
181 --   have been altered.
182 --
183 -- {End Of Comments}
184 -- ----------------------------------------------------------------------------
185 Procedure chk_non_updateable_args
186   (p_rec in pay_opt_shd.g_rec_type
187   ) IS
188 --
189   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
190   l_error    EXCEPTION;
191   l_argument varchar2(30);
192 --
193 Begin
194   --
195   -- Only proceed with the validation if a row exists for the current
196   -- record in the HR Schema.
197   --
198   IF NOT pay_opt_shd.api_updating
199       (p_org_payment_method_id                => p_rec.org_payment_method_id
200       ,p_language                             => p_rec.language
201       ) THEN
202      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
203      fnd_message.set_token('PROCEDURE ', l_proc);
204      fnd_message.set_token('STEP ', '5');
205      fnd_message.raise_error;
206   END IF;
207   --
208   -- Checks to ensure non-updateable args have not been updated.
209   --
210   EXCEPTION
211     WHEN l_error THEN
212        hr_api.argument_changed_error
213          (p_api_name => l_proc
214          ,p_argument => l_argument);
215     WHEN OTHERS THEN
216        RAISE;
217 End chk_non_updateable_args;
218 --
219 -- ----------------------------------------------------------------------------
220 -- |--------------------< chk_org_payment_method_name >-----------------------|
221 -- ----------------------------------------------------------------------------
222 --
223 --  Description:
224 --    Check that the org_payment_method_name is not null.
225 --
226 --  Pre-Requisites:
227 --    None
228 --
229 --  In Parameters:
230 --    p_org_payment_method_name
231 --    p_language
232 --    p_org_payment_method_id
233 --
234 --  Post Success:
235 --    Processing continues if the org_payment_method_name is valid.
236 --
237 --  Post Failure:
238 --    An application error is raised and processing is terminated if
239 --    the org_payment_method_name is invalid.
240 --
241 --  Access Status:
242 --    Internal Row Handler Use Only.
243 --
244 Procedure chk_org_payment_method_name
245   (p_org_payment_method_name in pay_org_payment_methods_f.org_payment_method_name%TYPE
246   ,p_language                in varchar2
247   ,p_org_payment_method_id   in pay_org_payment_methods_f.org_payment_method_id%TYPE
248   ) is
249 --
250   l_proc         varchar2(72) := g_package||'chk_org_payment_method_name';
251   l_api_updating boolean;
252   l_dummy        number;
253   --
254   cursor csr_org_pay_meth_name_exists is
255      select  null
256        from  pay_org_payment_methods_f opm,
257              pay_org_payment_methods_f_tl opt
258       where  upper(opt.org_payment_method_name) = upper(p_org_payment_method_name)
259         and  opt.language = p_language
260         and  opm.org_payment_method_id = opt.org_payment_method_id
261         and  opm.org_payment_method_id <> p_org_payment_method_id
262         and  exists
263              (select null
264                 from pay_org_payment_methods_f opm1
265                where opm1.org_payment_method_id = p_org_payment_method_id
266                  and opm1.business_group_id = opm.business_group_id);
267   --
268 --
269 Begin
270   hr_utility.set_location('Entering:'||l_proc, 5);
271   --
272   --    Check mandatory org_payment_method_name exists
273   --
274   hr_api.mandatory_arg_error
275     (p_api_name                     => l_proc
276     ,p_argument                     => 'org_payment_method_name'
277     ,p_argument_value               => p_org_payment_method_name
278     );
279   --
280   --
281   hr_utility.set_location(l_proc,10);
282   --
283   -- Only proceed with SQL validation if absolutely necessary
284   --
285   if ( nvl(pay_opm_shd.g_old_rec.org_payment_method_name,hr_api.g_varchar2) <>
286        nvl(p_org_payment_method_name,hr_api.g_varchar2)) then
287      --
288      hr_utility.set_location(l_proc,20);
289      --
290      --
291      open csr_org_pay_meth_name_exists;
292      fetch csr_org_pay_meth_name_exists into l_dummy;
293      if csr_org_pay_meth_name_exists%found then
294         close csr_org_pay_meth_name_exists;
295         -- RAISE ERROR MESSAGE
296         fnd_message.set_name('PAY', 'HR_7462_PLK_INVLD_VALUE');
297         fnd_message.set_token('COLUMN_NAME', 'ORG_PAYMENT_METHOD_NAME');
298         fnd_message.raise_error;
299      end if;
300      close csr_org_pay_meth_name_exists;
301      --
302      hr_utility.set_location(l_proc,30);
303      --
304   end if;
305   --
306   --
307   hr_utility.set_location(' Leaving:'||l_proc, 100);
308 End chk_org_payment_method_name;
309 --
310 -- ----------------------------------------------------------------------------
311 -- |---------------------------< insert_validate >----------------------------|
312 -- ----------------------------------------------------------------------------
313 Procedure insert_validate
314   (p_rec                          in pay_opt_shd.g_rec_type
315   ) is
316 --
317   l_proc  varchar2(72) := g_package||'insert_validate';
318 --
319 Begin
320   hr_utility.set_location('Entering:'||l_proc, 5);
321   --
322   -- Call all supporting business operations
323   --
324   --
325   pay_opt_bus.set_security_group_id(p_org_payment_method_id
326                                     => p_rec.org_payment_method_id);
327   --
328   hr_utility.set_location(l_proc,30);
329   --
330   pay_opt_bus.chk_org_payment_method_name(p_org_payment_method_name => p_rec.org_payment_method_name
331                                           ,p_language => p_rec.language
332                                           ,p_org_payment_method_id => p_rec.org_payment_method_id);
333   --
334   hr_utility.set_location(l_proc,40);
335   --
336   hr_utility.set_location(' Leaving:'||l_proc, 10);
337 End insert_validate;
338 --
339 -- ----------------------------------------------------------------------------
340 -- |---------------------------< update_validate >----------------------------|
341 -- ----------------------------------------------------------------------------
342 Procedure update_validate
343   (p_rec                          in pay_opt_shd.g_rec_type
344   ) is
345 --
346   l_proc  varchar2(72) := g_package||'update_validate';
347 --
348 Begin
349   hr_utility.set_location('Entering:'||l_proc, 5);
350   --
351   -- Call all supporting business operations
352   --
353   --
354   pay_opt_bus.set_security_group_id(p_org_payment_method_id
355                                     => p_rec.org_payment_method_id);
356   --
357   pay_opt_bus.chk_org_payment_method_name(p_org_payment_method_name => p_rec.org_payment_method_name
358                                           ,p_language => p_rec.language
359                                           ,p_org_payment_method_id => p_rec.org_payment_method_id);
360   --
361   chk_non_updateable_args
362     (p_rec              => p_rec
363     );
364   --
365   --
366   hr_utility.set_location(' Leaving:'||l_proc, 10);
367 End update_validate;
368 --
369 -- ----------------------------------------------------------------------------
370 -- |---------------------------< delete_validate >----------------------------|
371 -- ----------------------------------------------------------------------------
372 Procedure delete_validate
373   (p_rec                          in pay_opt_shd.g_rec_type
374   ) is
375 --
376   l_proc  varchar2(72) := g_package||'delete_validate';
377 --
378 Begin
379   hr_utility.set_location('Entering:'||l_proc, 5);
380   --
381   -- Call all supporting business operations
382   --
383   hr_utility.set_location(' Leaving:'||l_proc, 10);
384 End delete_validate;
385 --
386 end pay_opt_bus;