[Home] [Help]
PACKAGE BODY: APPS.PAY_TDU_BUS
Source
1 Package Body pay_tdu_bus as
2 /* $Header: pytdurhi.pkb 120.2 2005/10/14 07:07 adkumar noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pay_tdu_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_time_definition_id number default null;
15 g_usage_type varchar2(30) default null;
16 --
17 -- ----------------------------------------------------------------------------
18 -- |----------------------< chk_startup_action >------------------------------|
19 -- ----------------------------------------------------------------------------
20 --
21 -- Description:
22 -- This procedure will check that the current action is allowed according
23 -- to the current startup mode.
24 --
25 -- ----------------------------------------------------------------------------
26 PROCEDURE chk_startup_action
27 (p_insert IN boolean,
28 p_time_definition_id IN number
29 ) IS
30 --
31 cursor csr_parent_bus_leg is
32 select business_group_id,
33 legislation_code
34 from pay_time_definitions
35 where time_definition_id = p_time_definition_id;
36 --
37 l_business_group_id number;
38 l_legislation_code varchar2(30);
39 --
40 BEGIN
41 --
42 -- Call the supporting procedure to check startup mode
43
44 open csr_parent_bus_leg;
45 fetch csr_parent_bus_leg into l_business_group_id, l_legislation_code;
46
47 if csr_parent_bus_leg%notfound then
48 close csr_parent_bus_leg;
49 return;
50 end if;
51
52 close csr_parent_bus_leg;
53
54 IF (p_insert) THEN
55
56 hr_startup_data_api_support.chk_startup_action
57 (p_generic_allowed => TRUE
58 ,p_startup_allowed => TRUE
59 ,p_user_allowed => TRUE
60 ,p_business_group_id => l_business_group_id
61 ,p_legislation_code => l_legislation_code
62 ,p_legislation_subgroup => null
63 );
64 ELSE
65 hr_startup_data_api_support.chk_upd_del_startup_action
66 (p_generic_allowed => TRUE
67 ,p_startup_allowed => TRUE
68 ,p_user_allowed => TRUE
69 ,p_business_group_id => l_business_group_id
70 ,p_legislation_code => l_legislation_code
71 ,p_legislation_subgroup => null
72 );
73 END IF;
74 --
75 Exception
76 when others then
77 if csr_parent_bus_leg%isopen then
78 close csr_parent_bus_leg;
79 end if;
80 raise;
81
82 END chk_startup_action;
83 --
84 -- ----------------------------------------------------------------------------
85 -- |-------------------------< chk_time_definition_id >-----------------------|
86 -- ----------------------------------------------------------------------------
87 -- {Start Of Comments}
88 --
89 -- Description:
90 -- Validates the time definition id column
91 --
92 -- Prerequisites:
93 -- None
94 --
95 -- In Arguments:
96 -- p_time_definition_id
97 --
98 -- Post Success:
99 -- Processing continues.
100 --
101 -- Post Failure:
102 -- An error is raised if the validation fails.
103 --
104 -- Access Status:
105 -- Internal Development Use Only.
106 --
107 -- {End Of Comments}
108 -- ---------------------------------------------------------------------------
109 Procedure chk_time_definition_id
110 (p_time_definition_id in number
111 ) is
112 --
113 l_proc varchar2(72) := g_package||'chk_time_definition_id';
114 l_api_updating boolean;
115 l_exists varchar2(1);
116 --
117 cursor csr_time_definition_id is
118 select null
119 from pay_time_definitions
120 where time_definition_id = p_time_definition_id;
121 --
122 Begin
123 hr_utility.set_location('Entering:'||l_proc, 5);
124 --
125
126 hr_api.mandatory_arg_error
127 (p_api_name => l_proc
128 ,p_argument => 'TIME_DEFINITION_ID'
129 ,p_argument_value => p_time_definition_id
130 );
131
132 open csr_time_definition_id;
133 fetch csr_time_definition_id into l_exists;
134
135 if csr_time_definition_id%notfound then
136
137 close csr_time_definition_id;
141 end if;
138 fnd_message.set_name('PAY','PAY_34056_FLSA_INV_TIME_DEF_ID');
139 fnd_message.raise_error;
140
142
143 close csr_time_definition_id;
144 --
145 hr_utility.set_location(' Leaving:'||l_proc, 10);
146
147 exception
148
149 when app_exception.application_exception then
150 if hr_multi_message.exception_add
151 (p_associated_column1 => 'PAY_TIME_DEF_USAGES.TIME_DEFINITION_ID') then
152 raise;
153 end if;
154
155 when others then
156 if csr_time_definition_id%isopen then
157 close csr_time_definition_id;
158 end if;
159 raise;
160
161 End chk_time_definition_id;
162 --
163 -- ----------------------------------------------------------------------------
164 -- |-----------------------------< chk_usage_type >---------------------------|
165 -- ----------------------------------------------------------------------------
166 -- {Start Of Comments}
167 --
168 -- Description:
169 -- Validates the usage type column
170 --
171 -- Prerequisites:
172 -- Time definition referred by p_time_definition_id must already exists.
173 --
174 -- In Arguments:
175 -- p_time_definition_id
176 -- p_usage_type
177 --
178 -- Post Success:
179 -- Processing continues.
180 --
181 -- Post Failure:
182 -- An error is raised if the validation fails.
183 --
184 -- Access Status:
185 -- Internal Development Use Only.
186 --
187 -- {End Of Comments}
188 -- ---------------------------------------------------------------------------
189 Procedure chk_usage_type
190 (p_time_definition_id in number,
191 p_usage_type in varchar2
192 ) is
193 --
194 l_proc varchar2(72) := g_package||'chk_usage_type';
195 l_api_updating boolean;
196 l_exists varchar2(1);
197 l_definition_type varchar2(30);
198 l_meaning varchar2(80);
199
200 cursor csr_usage_type is
201 select hrl.meaning
202 from hr_standard_lookups hrl
203 where hrl.lookup_type = 'PAY_TIME_DEFINITION_USAGE'
204 and hrl.lookup_code = p_usage_type
205 and hrl.enabled_flag = 'Y';
206
207 cursor csr_definition_type is
208 select nvl(definition_type,'P')
209 from pay_time_definitions
210 where time_definition_id = p_time_definition_id;
211
212 --
213 Begin
214 hr_utility.set_location('Entering:'||l_proc, 5);
215 --
216 if hr_multi_message.no_exclusive_error
217 (p_check_column1 => 'PAY_TIME_DEF_USAGES.TIME_DEFINITION_ID'
218 ,p_associated_column1 => 'PAY_TIME_DEF_USAGES.USAGE_TYPE'
219 ) then
220
221 hr_api.mandatory_arg_error
222 (p_api_name => l_proc
223 ,p_argument => 'USAGE_TYPE'
224 ,p_argument_value => p_usage_type
225 );
226
227 open csr_usage_type;
228 fetch csr_usage_type into l_meaning;
229
230 if csr_usage_type%notfound then
231
232 close csr_usage_type;
233
234 fnd_message.set_name('PAY','PAY_34059_FLSA_ARG_INVALID');
235 fnd_message.set_token('ARGUMENT', 'Usage Type');
236 fnd_message.raise_error;
237
238 end if;
239
240 close csr_usage_type;
241
242 open csr_definition_type;
243 fetch csr_definition_type into l_definition_type;
244 close csr_definition_type;
245
246 if l_definition_type = 'P' and p_usage_type = 'EA' then
247
248 fnd_message.set_name('PAY','PAY_34063_FLSA_INV_USAGE_TYPE');
249 fnd_message.set_token('USAGE', l_meaning);
250 fnd_message.raise_error;
251
252 end if;
253
254 if l_definition_type in ('S','E','C') and p_usage_type in ('PP','RS','P') then
255
256 fnd_message.set_name('PAY','PAY_34063_FLSA_INV_USAGE_TYPE');
257 fnd_message.set_token('USAGE', l_meaning);
258 fnd_message.raise_error;
259
260 end if;
261
262 end if;
263 --
264 hr_utility.set_location(' Leaving:'||l_proc, 10);
265
266 exception
267
268 when app_exception.application_exception then
269 if hr_multi_message.exception_add
270 (p_associated_column1 => 'PAY_TIME_DEF_USAGES.USAGE_TYPE') then
271 raise;
272 end if;
273
274 when others then
275 if csr_usage_type%isopen then
276 close csr_usage_type;
277 end if;
278 raise;
279
280 End chk_usage_type;
281 --
282 -- ----------------------------------------------------------------------------
283 -- |---------------------------< insert_validate >----------------------------|
284 -- ----------------------------------------------------------------------------
285 Procedure insert_validate
286 (p_effective_date in date
287 ,p_rec in pay_tdu_shd.g_rec_type
288 ) is
289 --
290 l_proc varchar2(72) := g_package||'insert_validate';
291 --
292 Begin
293 hr_utility.set_location('Entering:'||l_proc, 5);
294 --
295 -- Call all supporting business operations
296 --
297 chk_startup_action(true
298 ,p_rec.time_definition_id
299 );
300
301 -- "HR_STANDARD_LOOKUPS used for validation."
302 --
303 -- Validate Dependent Attributes
304 --
305 --
306
307 chk_time_definition_id
308 (p_time_definition_id => p_rec.time_definition_id);
309
310 chk_usage_type
311 (p_time_definition_id => p_rec.time_definition_id,
312 p_usage_type => p_rec.usage_type
313 );
314
315 hr_utility.set_location(' Leaving:'||l_proc, 10);
316 End insert_validate;
317 --
318 -- ----------------------------------------------------------------------------
319 -- |---------------------------< delete_validate >----------------------------|
320 -- ----------------------------------------------------------------------------
321 Procedure delete_validate
322 (p_rec in pay_tdu_shd.g_rec_type
323 ) is
324 --
325 l_proc varchar2(72) := g_package||'delete_validate';
326 --
327 Begin
328 hr_utility.set_location('Entering:'||l_proc, 5);
329 --
330 -- Call all supporting business operations
331 --
332 chk_startup_action(false
333 ,p_rec.time_definition_id
334 );
335
336 hr_utility.set_location(' Leaving:'||l_proc, 10);
337 End delete_validate;
338 --
339 end pay_tdu_bus;