[Home] [Help]
PACKAGE BODY: APPS.PAY_PAY_BUS
Source
1 Package Body pay_pay_bus as
2 /* $Header: pypayrhi.pkb 120.0.12000000.3 2007/03/08 09:23:27 mshingan noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pay_pay_bus.'; -- Global package name
9 g_exists varchar2(1);
10
11 --
12 -- The following two global variables are only to be
13 -- used by the return_legislation_code function.
14 --
15 g_legislation_code varchar2(150) default null;
16 g_payroll_id number default null;
17 --
18 -- ---------------------------------------------------------------------------
19 -- |----------------------< set_security_group_id >--------------------------|
20 -- ---------------------------------------------------------------------------
21 --
22 Procedure set_security_group_id
23 (p_payroll_id in number
24 ,p_associated_column1 in varchar2 default null
25 ) is
26 --
27 -- Declare cursor
28 --
29 cursor csr_sec_grp is
30 select pbg.security_group_id,
31 pbg.legislation_code
32 from per_business_groups_perf pbg
33 , pay_all_payrolls_f pay
34 where pay.payroll_id = p_payroll_id
35 and pbg.business_group_id = pay.business_group_id;
36 --
37 -- Declare local variables
38 --
39 l_security_group_id number;
40 l_proc varchar2(72) := g_package||'set_security_group_id';
41 l_legislation_code varchar2(150);
42 --
43 begin
44 --
45 hr_utility.set_location('Entering:'|| l_proc, 10);
46 --
47 -- Ensure that all the mandatory parameters are not null
48 --
49 hr_api.mandatory_arg_error
50 (p_api_name => l_proc
51 ,p_argument => 'payroll_id'
52 ,p_argument_value => p_payroll_id
53 );
54 --
55 open csr_sec_grp;
56 fetch csr_sec_grp into l_security_group_id
57 , l_legislation_code;
58 --
59 if csr_sec_grp%notfound then
60 --
61 close csr_sec_grp;
62 --
63 -- The primary key is invalid therefore we must error
64 --
65 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
66 hr_multi_message.add
67 (p_associated_column1
68 => nvl(p_associated_column1,'PAYROLL_ID')
69 );
70 --
71 else
72 --
73 close csr_sec_grp;
74 --
75 -- Set the security_group_id in CLIENT_INFO
76 --
77 hr_api.set_security_group_id(p_security_group_id => l_security_group_id );
78 --
79 -- Set the sessions legislation context in HR_SESSION_DATA
80 --
81 hr_api.set_legislation_context(l_legislation_code);
82 --
83 end if;
84 --
85 hr_utility.set_location(' Leaving:'|| l_proc, 20);
86 --
87 end set_security_group_id;
88 --
89 -- ---------------------------------------------------------------------------
90 -- |---------------------< return_legislation_code >-------------------------|
91 -- ---------------------------------------------------------------------------
92 --
93 Function return_legislation_code
94 (p_payroll_id in number
95 )
96 Return Varchar2 Is
97 --
98 -- Declare cursor
99 --
100 cursor csr_leg_code is
101 select pbg.legislation_code
102 from per_business_groups_perf pbg
103 , pay_all_payrolls_f pay
104 where pay.payroll_id = p_payroll_id
105 and pbg.business_group_id = pay.business_group_id;
106 --
107 -- Declare local variables
108 --
109 l_legislation_code varchar2(150);
110 l_proc varchar2(72) := g_package||'return_legislation_code';
111 --
112 Begin
113 --
114 hr_utility.set_location('Entering:'|| l_proc, 10);
115 --
116 -- Ensure that all the mandatory parameter are not null
117 --
118 hr_api.mandatory_arg_error
119 (p_api_name => l_proc
120 ,p_argument => 'payroll_id'
121 ,p_argument_value => p_payroll_id
122 );
123 --
124 if ( nvl(pay_pay_bus.g_payroll_id, hr_api.g_number) = p_payroll_id) then
125 --
126 -- The legislation code has already been found with a previous
127 -- call to this function. Just return the value in the global
128 -- variable.
129 --
130 l_legislation_code := pay_pay_bus.g_legislation_code;
131 hr_utility.set_location(l_proc, 20);
132 --
133 else
134 --
135 -- The ID is different to the last call to this function
136 -- or this is the first call to this function.
137 --
138 open csr_leg_code;
139 fetch csr_leg_code into l_legislation_code;
140 --
141 if csr_leg_code%notfound then
142 --
143 -- The primary key is invalid therefore we must error
144 --
145 close csr_leg_code;
146 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
147 fnd_message.raise_error;
148 --
149 end if;
150 --
151 hr_utility.set_location(l_proc,30);
152 --
153 -- Set the global variables so the values are
154 -- available for the next call to this function.
155 --
156 close csr_leg_code;
157 pay_pay_bus.g_payroll_id := p_payroll_id;
158 pay_pay_bus.g_legislation_code := l_legislation_code;
159 --
160 end if;
161 hr_utility.set_location(' Leaving:'|| l_proc, 40);
162 return l_legislation_code;
163 --
164 end return_legislation_code;
165 --
166 -- ----------------------------------------------------------------------------
167 -- |-----------------------------< chk_ddf >----------------------------------|
168 -- ----------------------------------------------------------------------------
169 --
170 -- Description:
171 -- Validates all the Developer Descriptive Flexfield values.
172 --
173 -- Prerequisites:
174 -- All other columns have been validated. Must be called as the
175 -- last step from insert_validate and update_validate.
176 --
177 -- In Arguments:
178 -- p_rec
179 --
180 -- Post Success:
181 -- If the Developer Descriptive Flexfield structure column and data values
182 -- are all valid this procedure will end normally and processing will
183 -- continue.
184 --
185 -- Post Failure:
186 -- If the Developer Descriptive Flexfield structure column value or any of
187 -- the data values are invalid then an application error is raised as
188 -- a PL/SQL exception.
189 --
190 -- Access Status:
191 -- Internal Row Handler Use Only.
192 --
193 -- ----------------------------------------------------------------------------
194 --
195 procedure chk_ddf
196 (p_rec in pay_pay_shd.g_rec_type
197 ) is
198 --
199 l_proc varchar2(72) := g_package || 'chk_ddf';
200 --
201 begin
202 hr_utility.set_location('Entering:'||l_proc,10);
203 --
204 if ((p_rec.payroll_id is not null) and (
205 nvl(pay_pay_shd.g_old_rec.prl_information_category, hr_api.g_varchar2) <>
206 nvl(p_rec.prl_information_category, hr_api.g_varchar2) or
207 nvl(pay_pay_shd.g_old_rec.prl_information1, hr_api.g_varchar2) <>
208 nvl(p_rec.prl_information1, hr_api.g_varchar2) or
209 nvl(pay_pay_shd.g_old_rec.prl_information2, hr_api.g_varchar2) <>
210 nvl(p_rec.prl_information2, hr_api.g_varchar2) or
211 nvl(pay_pay_shd.g_old_rec.prl_information3, hr_api.g_varchar2) <>
212 nvl(p_rec.prl_information3, hr_api.g_varchar2) or
213 nvl(pay_pay_shd.g_old_rec.prl_information4, hr_api.g_varchar2) <>
214 nvl(p_rec.prl_information4, hr_api.g_varchar2) or
215 nvl(pay_pay_shd.g_old_rec.prl_information5, hr_api.g_varchar2) <>
216 nvl(p_rec.prl_information5, hr_api.g_varchar2) or
217 nvl(pay_pay_shd.g_old_rec.prl_information6, hr_api.g_varchar2) <>
218 nvl(p_rec.prl_information6, hr_api.g_varchar2) or
219 nvl(pay_pay_shd.g_old_rec.prl_information7, hr_api.g_varchar2) <>
220 nvl(p_rec.prl_information7, hr_api.g_varchar2) or
221 nvl(pay_pay_shd.g_old_rec.prl_information8, hr_api.g_varchar2) <>
222 nvl(p_rec.prl_information8, hr_api.g_varchar2) or
223 nvl(pay_pay_shd.g_old_rec.prl_information9, hr_api.g_varchar2) <>
224 nvl(p_rec.prl_information9, hr_api.g_varchar2) or
225 nvl(pay_pay_shd.g_old_rec.prl_information10, hr_api.g_varchar2) <>
226 nvl(p_rec.prl_information10, hr_api.g_varchar2) or
227 nvl(pay_pay_shd.g_old_rec.prl_information11, hr_api.g_varchar2) <>
228 nvl(p_rec.prl_information11, hr_api.g_varchar2) or
229 nvl(pay_pay_shd.g_old_rec.prl_information12, hr_api.g_varchar2) <>
230 nvl(p_rec.prl_information12, hr_api.g_varchar2) or
231 nvl(pay_pay_shd.g_old_rec.prl_information13, hr_api.g_varchar2) <>
232 nvl(p_rec.prl_information13, hr_api.g_varchar2) or
233 nvl(pay_pay_shd.g_old_rec.prl_information14, hr_api.g_varchar2) <>
234 nvl(p_rec.prl_information14, hr_api.g_varchar2) or
235 nvl(pay_pay_shd.g_old_rec.prl_information15, hr_api.g_varchar2) <>
236 nvl(p_rec.prl_information15, hr_api.g_varchar2) or
237 nvl(pay_pay_shd.g_old_rec.prl_information16, hr_api.g_varchar2) <>
238 nvl(p_rec.prl_information16, hr_api.g_varchar2) or
239 nvl(pay_pay_shd.g_old_rec.prl_information17, hr_api.g_varchar2) <>
240 nvl(p_rec.prl_information17, hr_api.g_varchar2) or
241 nvl(pay_pay_shd.g_old_rec.prl_information18, hr_api.g_varchar2) <>
242 nvl(p_rec.prl_information18, hr_api.g_varchar2) or
243 nvl(pay_pay_shd.g_old_rec.prl_information19, hr_api.g_varchar2) <>
244 nvl(p_rec.prl_information19, hr_api.g_varchar2) or
245 nvl(pay_pay_shd.g_old_rec.prl_information20, hr_api.g_varchar2) <>
246 nvl(p_rec.prl_information20, hr_api.g_varchar2) or
247 nvl(pay_pay_shd.g_old_rec.prl_information21, hr_api.g_varchar2) <>
248 nvl(p_rec.prl_information21, hr_api.g_varchar2) or
249 nvl(pay_pay_shd.g_old_rec.prl_information22, hr_api.g_varchar2) <>
250 nvl(p_rec.prl_information22, hr_api.g_varchar2) or
251 nvl(pay_pay_shd.g_old_rec.prl_information23, hr_api.g_varchar2) <>
252 nvl(p_rec.prl_information23, hr_api.g_varchar2) or
253 nvl(pay_pay_shd.g_old_rec.prl_information24, hr_api.g_varchar2) <>
254 nvl(p_rec.prl_information24, hr_api.g_varchar2) or
255 nvl(pay_pay_shd.g_old_rec.prl_information25, hr_api.g_varchar2) <>
256 nvl(p_rec.prl_information25, hr_api.g_varchar2) or
257 nvl(pay_pay_shd.g_old_rec.prl_information26, hr_api.g_varchar2) <>
258 nvl(p_rec.prl_information26, hr_api.g_varchar2) or
259 nvl(pay_pay_shd.g_old_rec.prl_information27, hr_api.g_varchar2) <>
260 nvl(p_rec.prl_information27, hr_api.g_varchar2) or
261 nvl(pay_pay_shd.g_old_rec.prl_information28, hr_api.g_varchar2) <>
262 nvl(p_rec.prl_information28, hr_api.g_varchar2) or
263 nvl(pay_pay_shd.g_old_rec.prl_information29, hr_api.g_varchar2) <>
264 nvl(p_rec.prl_information29, hr_api.g_varchar2) or
265 nvl(pay_pay_shd.g_old_rec.prl_information30, hr_api.g_varchar2) <>
266 nvl(p_rec.prl_information30, hr_api.g_varchar2) ))
267 or (p_rec.payroll_id is null) then
268 --
269 -- Only execute the validation if absolutely necessary:
270 -- a) During update, the structure column value or any
271 -- of the attribute values have actually changed.
272 -- b) During insert.
273 --
274
275 hr_dflex_utility.ins_or_upd_descflex_attribs
276 (p_appl_short_name => 'PAY'
277 ,p_descflex_name => 'Payroll Developer DF'
278 ,p_attribute_category => p_rec.prl_information_category
279 ,p_attribute1_name => 'PRL_INFORMATION1'
280 ,p_attribute1_value => p_rec.prl_information1
281 ,p_attribute2_name => 'PRL_INFORMATION2'
282 ,p_attribute2_value => p_rec.prl_information2
283 ,p_attribute3_name => 'PRL_INFORMATION3'
284 ,p_attribute3_value => p_rec.prl_information3
285 ,p_attribute4_name => 'PRL_INFORMATION4'
286 ,p_attribute4_value => p_rec.prl_information4
287 ,p_attribute5_name => 'PRL_INFORMATION5'
288 ,p_attribute5_value => p_rec.prl_information5
289 ,p_attribute6_name => 'PRL_INFORMATION6'
290 ,p_attribute6_value => p_rec.prl_information6
291 ,p_attribute7_name => 'PRL_INFORMATION7'
292 ,p_attribute7_value => p_rec.prl_information7
293 ,p_attribute8_name => 'PRL_INFORMATION8'
294 ,p_attribute8_value => p_rec.prl_information8
295 ,p_attribute9_name => 'PRL_INFORMATION9'
296 ,p_attribute9_value => p_rec.prl_information9
297 ,p_attribute10_name => 'PRL_INFORMATION10'
298 ,p_attribute10_value => p_rec.prl_information10
299 ,p_attribute11_name => 'PRL_INFORMATION11'
300 ,p_attribute11_value => p_rec.prl_information11
301 ,p_attribute12_name => 'PRL_INFORMATION12'
302 ,p_attribute12_value => p_rec.prl_information12
303 ,p_attribute13_name => 'PRL_INFORMATION13'
304 ,p_attribute13_value => p_rec.prl_information13
305 ,p_attribute14_name => 'PRL_INFORMATION14'
306 ,p_attribute14_value => p_rec.prl_information14
307 ,p_attribute15_name => 'PRL_INFORMATION15'
308 ,p_attribute15_value => p_rec.prl_information15
309 ,p_attribute16_name => 'PRL_INFORMATION16'
310 ,p_attribute16_value => p_rec.prl_information16
311 ,p_attribute17_name => 'PRL_INFORMATION17'
312 ,p_attribute17_value => p_rec.prl_information17
313 ,p_attribute18_name => 'PRL_INFORMATION18'
314 ,p_attribute18_value => p_rec.prl_information18
315 ,p_attribute19_name => 'PRL_INFORMATION19'
316 ,p_attribute19_value => p_rec.prl_information19
317 ,p_attribute20_name => 'PRL_INFORMATION20'
318 ,p_attribute20_value => p_rec.prl_information20
319 ,p_attribute21_name => 'PRL_INFORMATION21'
320 ,p_attribute21_value => p_rec.prl_information21
321 ,p_attribute22_name => 'PRL_INFORMATION22'
322 ,p_attribute22_value => p_rec.prl_information22
323 ,p_attribute23_name => 'PRL_INFORMATION23'
324 ,p_attribute23_value => p_rec.prl_information23
325 ,p_attribute24_name => 'PRL_INFORMATION24'
326 ,p_attribute24_value => p_rec.prl_information24
327 ,p_attribute25_name => 'PRL_INFORMATION25'
328 ,p_attribute25_value => p_rec.prl_information25
329 ,p_attribute26_name => 'PRL_INFORMATION26'
330 ,p_attribute26_value => p_rec.prl_information26
331 ,p_attribute27_name => 'PRL_INFORMATION27'
332 ,p_attribute27_value => p_rec.prl_information27
333 ,p_attribute28_name => 'PRL_INFORMATION28'
334 ,p_attribute28_value => p_rec.prl_information28
338 ,p_attribute30_value => p_rec.prl_information30
335 ,p_attribute29_name => 'PRL_INFORMATION29'
336 ,p_attribute29_value => p_rec.prl_information29
337 ,p_attribute30_name => 'PRL_INFORMATION30'
339 );
340 end if;
341 --
342 hr_utility.set_location(' Leaving:'||l_proc,20);
343 end chk_ddf;
344 --
345 -- ----------------------------------------------------------------------------
346 -- |------------------------------< chk_df >----------------------------------|
347 -- ----------------------------------------------------------------------------
348 --
349 -- Description:
350 -- Validates all the Descriptive Flexfield values.
351 --
352 -- Prerequisites:
353 -- All other columns have been validated. Must be called as the
354 -- last step from insert_validate and update_validate.
355 --
356 -- In Arguments:
357 -- p_rec
358 --
359 -- Post Success:
360 -- If the Descriptive Flexfield structure column and data values are
361 -- all valid this procedure will end normally and processing will
362 -- continue.
363 --
364 -- Post Failure:
365 -- If the Descriptive Flexfield structure column value or any of
366 -- the data values are invalid then an application error is raised as
367 -- a PL/SQL exception.
368 --
369 -- Access Status:
370 -- Internal Row Handler Use Only.
371 --
372 -- ----------------------------------------------------------------------------
373 procedure chk_df
374 (p_rec in pay_pay_shd.g_rec_type
375 ) is
376 --
377 l_proc varchar2(72) := g_package || 'chk_df';
378 --
379 begin
380 hr_utility.set_location('Entering:'||l_proc,10);
381 --
382 if ((p_rec.payroll_id is not null) and (
383 nvl(pay_pay_shd.g_old_rec.attribute_category, hr_api.g_varchar2) <>
384 nvl(p_rec.attribute_category, hr_api.g_varchar2) or
385 nvl(pay_pay_shd.g_old_rec.attribute1, hr_api.g_varchar2) <>
386 nvl(p_rec.attribute1, hr_api.g_varchar2) or
387 nvl(pay_pay_shd.g_old_rec.attribute2, hr_api.g_varchar2) <>
388 nvl(p_rec.attribute2, hr_api.g_varchar2) or
389 nvl(pay_pay_shd.g_old_rec.attribute3, hr_api.g_varchar2) <>
390 nvl(p_rec.attribute3, hr_api.g_varchar2) or
391 nvl(pay_pay_shd.g_old_rec.attribute4, hr_api.g_varchar2) <>
392 nvl(p_rec.attribute4, hr_api.g_varchar2) or
393 nvl(pay_pay_shd.g_old_rec.attribute5, hr_api.g_varchar2) <>
394 nvl(p_rec.attribute5, hr_api.g_varchar2) or
395 nvl(pay_pay_shd.g_old_rec.attribute6, hr_api.g_varchar2) <>
396 nvl(p_rec.attribute6, hr_api.g_varchar2) or
397 nvl(pay_pay_shd.g_old_rec.attribute7, hr_api.g_varchar2) <>
398 nvl(p_rec.attribute7, hr_api.g_varchar2) or
399 nvl(pay_pay_shd.g_old_rec.attribute8, hr_api.g_varchar2) <>
400 nvl(p_rec.attribute8, hr_api.g_varchar2) or
401 nvl(pay_pay_shd.g_old_rec.attribute9, hr_api.g_varchar2) <>
402 nvl(p_rec.attribute9, hr_api.g_varchar2) or
403 nvl(pay_pay_shd.g_old_rec.attribute10, hr_api.g_varchar2) <>
404 nvl(p_rec.attribute10, hr_api.g_varchar2) or
405 nvl(pay_pay_shd.g_old_rec.attribute11, hr_api.g_varchar2) <>
406 nvl(p_rec.attribute11, hr_api.g_varchar2) or
407 nvl(pay_pay_shd.g_old_rec.attribute12, hr_api.g_varchar2) <>
408 nvl(p_rec.attribute12, hr_api.g_varchar2) or
409 nvl(pay_pay_shd.g_old_rec.attribute13, hr_api.g_varchar2) <>
410 nvl(p_rec.attribute13, hr_api.g_varchar2) or
411 nvl(pay_pay_shd.g_old_rec.attribute14, hr_api.g_varchar2) <>
412 nvl(p_rec.attribute14, hr_api.g_varchar2) or
413 nvl(pay_pay_shd.g_old_rec.attribute15, hr_api.g_varchar2) <>
414 nvl(p_rec.attribute15, hr_api.g_varchar2) or
415 nvl(pay_pay_shd.g_old_rec.attribute16, hr_api.g_varchar2) <>
416 nvl(p_rec.attribute16, hr_api.g_varchar2) or
417 nvl(pay_pay_shd.g_old_rec.attribute17, hr_api.g_varchar2) <>
418 nvl(p_rec.attribute17, hr_api.g_varchar2) or
419 nvl(pay_pay_shd.g_old_rec.attribute18, hr_api.g_varchar2) <>
420 nvl(p_rec.attribute18, hr_api.g_varchar2) or
421 nvl(pay_pay_shd.g_old_rec.attribute19, hr_api.g_varchar2) <>
422 nvl(p_rec.attribute19, hr_api.g_varchar2) or
423 nvl(pay_pay_shd.g_old_rec.attribute20, hr_api.g_varchar2) <>
424 nvl(p_rec.attribute20, hr_api.g_varchar2) ))
425 or (p_rec.payroll_id is null) then
426 --
427 -- Only execute the validation if absolutely necessary:
428 -- a) During update, the structure column value or any
429 -- of the attribute values have actually changed.
430 -- b) During insert.
431 --
432 hr_dflex_utility.ins_or_upd_descflex_attribs
433 (p_appl_short_name => 'PAY'
434 ,p_descflex_name => 'PAY_PAYROLLS'
435 ,p_attribute_category => p_rec.attribute_category
436 ,p_attribute1_name => 'ATTRIBUTE1'
437 ,p_attribute1_value => p_rec.attribute1
438 ,p_attribute2_name => 'ATTRIBUTE2'
439 ,p_attribute2_value => p_rec.attribute2
440 ,p_attribute3_name => 'ATTRIBUTE3'
441 ,p_attribute3_value => p_rec.attribute3
442 ,p_attribute4_name => 'ATTRIBUTE4'
443 ,p_attribute4_value => p_rec.attribute4
444 ,p_attribute5_name => 'ATTRIBUTE5'
448 ,p_attribute7_name => 'ATTRIBUTE7'
445 ,p_attribute5_value => p_rec.attribute5
446 ,p_attribute6_name => 'ATTRIBUTE6'
447 ,p_attribute6_value => p_rec.attribute6
449 ,p_attribute7_value => p_rec.attribute7
450 ,p_attribute8_name => 'ATTRIBUTE8'
451 ,p_attribute8_value => p_rec.attribute8
452 ,p_attribute9_name => 'ATTRIBUTE9'
453 ,p_attribute9_value => p_rec.attribute9
454 ,p_attribute10_name => 'ATTRIBUTE10'
455 ,p_attribute10_value => p_rec.attribute10
456 ,p_attribute11_name => 'ATTRIBUTE11'
457 ,p_attribute11_value => p_rec.attribute11
458 ,p_attribute12_name => 'ATTRIBUTE12'
459 ,p_attribute12_value => p_rec.attribute12
460 ,p_attribute13_name => 'ATTRIBUTE13'
461 ,p_attribute13_value => p_rec.attribute13
462 ,p_attribute14_name => 'ATTRIBUTE14'
463 ,p_attribute14_value => p_rec.attribute14
464 ,p_attribute15_name => 'ATTRIBUTE15'
465 ,p_attribute15_value => p_rec.attribute15
466 ,p_attribute16_name => 'ATTRIBUTE16'
467 ,p_attribute16_value => p_rec.attribute16
468 ,p_attribute17_name => 'ATTRIBUTE17'
469 ,p_attribute17_value => p_rec.attribute17
470 ,p_attribute18_name => 'ATTRIBUTE18'
471 ,p_attribute18_value => p_rec.attribute18
472 ,p_attribute19_name => 'ATTRIBUTE19'
473 ,p_attribute19_value => p_rec.attribute19
474 ,p_attribute20_name => 'ATTRIBUTE20'
475 ,p_attribute20_value => p_rec.attribute20
476 );
477 --
478 end if;
479 --
480 hr_utility.set_location(' Leaving:'||l_proc,20);
481 --
482 end chk_df;
483 --
484 -- ----------------------------------------------------------------------------
485 -- |-----------------------< chk_non_updateable_args >------------------------|
486 -- ----------------------------------------------------------------------------
487 -- {Start Of Comments}
488 --
489 -- Description:
490 -- This procedure is used to ensure that non updateable attributes have
491 -- not been updated. If an attribute has been updated an error is generated.
492 --
493 -- Pre Conditions:
494 -- g_old_rec has been populated with details of the values currently in
495 -- the database.
496 --
497 -- In Arguments:
498 -- p_rec has been populated with the updated values the user would like the
499 -- record set to.
500 --
501 -- Post Success:
502 -- Processing continues if all the non updateable attributes have not
503 -- changed.
504 --
505 -- Post Failure:
506 -- An application error is raised if any of the non updatable attributes
507 -- have been altered.
508 --
509 -- {End Of Comments}
510 -- ----------------------------------------------------------------------------
511 Procedure chk_non_updateable_args
512 (p_effective_date in date
513 ,p_rec in out nocopy pay_pay_shd.g_rec_type
514 ) IS
515 --
516 l_proc varchar2(72) := g_package || 'chk_non_updateable_args';
517 --
518 Begin
519 --
520 -- Only proceed with the validation if a row exists for the current
521 -- record in the HR Schema.
522 --
523 IF NOT pay_pay_shd.api_updating
524 (p_payroll_id => p_rec.payroll_id
525 ,p_effective_date => p_effective_date
526 ,p_object_version_number => p_rec.object_version_number
527 ) THEN
528 fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
529 fnd_message.set_token('PROCEDURE ', l_proc);
530 fnd_message.set_token('STEP ', '5');
531 fnd_message.raise_error;
532 END IF;
533
534 if nvl(p_rec.gl_set_of_books_id, hr_api.g_number) <>
535 nvl(pay_pay_shd.g_old_rec.gl_set_of_books_id, hr_api.g_number) then
536 --
537 hr_api.argument_changed_error
538 (p_api_name => l_proc
539 ,p_argument => 'GL_SET_OF_BOOKS_ID'
540 ,p_base_table => pay_pay_shd.g_tab_nam
541 );
542 --
543 end if;
544
545 if nvl(p_rec.period_type, hr_api.g_varchar2) <>
546 nvl(pay_pay_shd.g_old_rec.period_type, hr_api.g_varchar2) then
547 --
548 hr_api.argument_changed_error
549 (p_api_name => l_proc
550 ,p_argument => 'PERIOD_TYPE'
551 ,p_base_table => pay_pay_shd.g_tab_nam
552 );
553 --
554 end if;
555
556 if nvl(p_rec.organization_id, hr_api.g_number) <>
557 nvl(pay_pay_shd.g_old_rec.organization_id, hr_api.g_number) then
558 --
559 hr_api.argument_changed_error
560 (p_api_name => l_proc
561 ,p_argument => 'ORGANIZATION_ID'
562 ,p_base_table => pay_pay_shd.g_tab_nam
563 );
564 --
565 end if;
566
567 if nvl(p_rec.cut_off_date_offset , hr_api.g_number) <>
568 nvl(pay_pay_shd.g_old_rec.cut_off_date_offset, hr_api.g_number) then
569 --
570 hr_api.argument_changed_error
574 );
571 (p_api_name => l_proc
572 ,p_argument => 'CUT_OFF_DATE_OFFSET'
573 ,p_base_table => pay_pay_shd.g_tab_nam
575 --
576 end if;
577
578 if nvl(p_rec.direct_deposit_date_offset , hr_api.g_number) <>
579 nvl(pay_pay_shd.g_old_rec.direct_deposit_date_offset, hr_api.g_number) then
580 --
581 hr_api.argument_changed_error
582 (p_api_name => l_proc
583 ,p_argument => 'DIRECT_DEPOSIT_DATE_OFFSET'
584 ,p_base_table => pay_pay_shd.g_tab_nam
585 );
586 --
587 end if;
588
589 if nvl(p_rec.first_period_end_date , hr_api.g_date) <>
590 nvl(pay_pay_shd.g_old_rec.first_period_end_date, hr_api.g_date) then
591 --
592 hr_api.argument_changed_error
593 (p_api_name => l_proc
594 ,p_argument => 'FIRST_PERIOD_END_DATE'
595 ,p_base_table => pay_pay_shd.g_tab_nam
596 );
597 --
598 end if;
599
600 if nvl(p_rec.pay_advice_date_offset , hr_api.g_number) <>
601 nvl(pay_pay_shd.g_old_rec.pay_advice_date_offset, hr_api.g_number) then
602 --
603 hr_api.argument_changed_error
604 (p_api_name => l_proc
605 ,p_argument => 'PAY_ADVICE_DATE_OFFSET'
606 ,p_base_table => pay_pay_shd.g_tab_nam
607 );
608 --
609 end if;
610
611 if nvl(p_rec.pay_date_offset , hr_api.g_number) <>
612 nvl(pay_pay_shd.g_old_rec.pay_date_offset, hr_api.g_number) then
613 --
614 hr_api.argument_changed_error
615 (p_api_name => l_proc
616 ,p_argument => 'PAY_DATE_OFFSET'
617 ,p_base_table => pay_pay_shd.g_tab_nam
618 );
619 --
620 end if;
621
622 if nvl(p_rec.midpoint_offset , hr_api.g_number) <>
623 nvl(pay_pay_shd.g_old_rec.midpoint_offset, hr_api.g_number) then
624 --
625 hr_api.argument_changed_error
626 (p_api_name => l_proc
627 ,p_argument => 'MIDPOINT_OFFSET'
628 ,p_base_table => pay_pay_shd.g_tab_nam
629 );
630 --
631 end if;
632
633 if nvl(p_rec.payroll_type , hr_api.g_varchar2) <>
634 nvl(pay_pay_shd.g_old_rec.payroll_type, hr_api.g_varchar2) then
635 --
636 hr_api.argument_changed_error
637 (p_api_name => l_proc
638 ,p_argument => 'PAYROLL_TYPE'
639 ,p_base_table => pay_pay_shd.g_tab_nam
640 );
641 --
642 end if;
643
644 if nvl(p_rec.period_reset_years, hr_api.g_varchar2) <>
645 nvl(pay_pay_shd.g_old_rec.period_reset_years, hr_api.g_varchar2) then
646 --
647 hr_api.argument_changed_error
648 (p_api_name => l_proc
649 ,p_argument => 'PERIOD_RESET_YEARS'
650 ,p_base_table => pay_pay_shd.g_tab_nam
651 );
652 --
653 end if;
654 --
655 End chk_non_updateable_args;
656 --
657 -- ----------------------------------------------------------------------------
658 -- |--------------------------< dt_update_validate >--------------------------|
659 -- ----------------------------------------------------------------------------
660 -- {Start Of Comments}
661 --
662 -- Description:
663 -- This procedure is used for referential integrity of datetracked
664 -- parent entities when a datetrack update operation is taking place
665 -- and where there is no cascading of update defined for this entity.
666 --
667 -- Prerequisites:
668 -- This procedure is called from the update_validate.
669 --
670 -- In Parameters:
671 --
672 -- Post Success:
673 -- Processing continues.
674 --
675 -- Post Failure:
676 --
677 -- Developer Implementation Notes:
678 -- This procedure should not need maintenance unless the HR Schema model
679 -- changes.
680 --
681 -- Access Status:
682 -- Internal Row Handler Use Only.
683 --
684 -- {End Of Comments}
685 -- ----------------------------------------------------------------------------
686 Procedure dt_update_validate
687 (p_org_payment_method_id in number default hr_api.g_number
688 ,p_datetrack_mode in varchar2
689 ,p_validation_start_date in date
690 ,p_validation_end_date in date
691 ) Is
692 --
693 l_proc varchar2(72) := g_package||'dt_update_validate';
694 --
695 Begin
696 --
697 -- Ensure that the p_datetrack_mode argument is not null
698 --
699 hr_api.mandatory_arg_error
700 (p_api_name => l_proc
701 ,p_argument => 'datetrack_mode'
702 ,p_argument_value => p_datetrack_mode
703 );
704 --
705 -- Mode will be valid, as this is checked at the start of the upd.
706 --
707 -- Ensure the arguments are not null
708 --
709 hr_api.mandatory_arg_error
710 (p_api_name => l_proc
711 ,p_argument => 'validation_start_date'
712 ,p_argument_value => p_validation_start_date
713 );
714 --
715 hr_api.mandatory_arg_error
716 (p_api_name => l_proc
717 ,p_argument => 'validation_end_date'
718 ,p_argument_value => p_validation_end_date
719 );
720 --
721 If ((nvl(p_org_payment_method_id, hr_api.g_number) <> hr_api.g_number) and
722 NOT (dt_api.check_min_max_dates
726 ,p_from_date => p_validation_start_date
723 (p_base_table_name => 'pay_org_payment_methods_f'
724 ,p_base_key_column => 'ORG_PAYMENT_METHOD_ID'
725 ,p_base_key_value => p_org_payment_method_id
727 ,p_to_date => p_validation_end_date))) Then
728 fnd_message.set_name('PAY', 'HR_7216_DT_UPD_INTEGRITY_ERR');
729 fnd_message.set_token('TABLE_NAME','org payment methods');
730 hr_multi_message.add
731 (p_associated_column1 => pay_pay_shd.g_tab_nam || '.ORG_PAYMENT_METHOD_ID');
732 --
733 End If;
734 --
735
736 Exception
737 When Others Then
738 --
739 -- An unhandled or unexpected error has occurred which
740 -- we must report
741 --
742 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
743 fnd_message.set_token('PROCEDURE', l_proc);
744 fnd_message.set_token('STEP','15');
745 fnd_message.raise_error;
746 --
747 End dt_update_validate;
748 --
749 -- ----------------------------------------------------------------------------
750 -- |--------------------------< dt_delete_validate >--------------------------|
751 -- ----------------------------------------------------------------------------
752 -- {Start Of Comments}
753 --
754 -- Description:
755 -- This procedure is used for referential integrity of datetracked
756 -- child entities when either a datetrack DELETE or ZAP is in operation
757 -- and where there is no cascading of delete defined for this entity.
758 -- For the datetrack mode of DELETE or ZAP we must ensure that no
759 -- datetracked child rows exist between the validation start and end
760 -- dates.
761 --
762 -- Prerequisites:
763 -- This procedure is called from the delete_validate.
764 --
765 -- In Parameters:
766 --
767 -- Post Success:
768 -- Processing continues.
769 --
770 -- Post Failure:
771 -- If a row exists by determining the returning Boolean value from the
772 -- generic dt_api.rows_exist function then we must supply an error via
773 -- the use of the local exception handler l_rows_exist.
774 --
775 -- Developer Implementation Notes:
776 -- This procedure should not need maintenance unless the HR Schema model
777 -- changes.
778 --
779 -- Access Status:
780 -- Internal Row Handler Use Only.
781 --
782 -- {End Of Comments}
783 -- ----------------------------------------------------------------------------
784 Procedure dt_delete_validate
785 (p_payroll_id in number
786 ,p_datetrack_mode in varchar2
787 ,p_validation_start_date in date
788 ,p_validation_end_date in date
789 ) Is
790 --
791 l_proc varchar2(72) := g_package||'dt_delete_validate';
792
793 l_rows_exist Exception;
794 l_table_name all_tables.table_name%TYPE;
795
796 --
797 Begin
798 --
799 -- Ensure that the p_datetrack_mode argument is not null
800 --
801 hr_utility.set_location('Entering:'||l_proc, 5);
802 hr_api.mandatory_arg_error
803 (p_api_name => l_proc
804 ,p_argument => 'datetrack_mode'
805 ,p_argument_value => p_datetrack_mode
806 );
807 --
808 -- Only perform the validation if the datetrack mode is either
809 -- DELETE or ZAP
810 --
811 If (p_datetrack_mode = hr_api.g_delete or
812 p_datetrack_mode = hr_api.g_zap) then
813 --
814 --
815 -- Ensure the arguments are not null
816 --
817 hr_api.mandatory_arg_error
818 (p_api_name => l_proc
819 ,p_argument => 'validation_start_date'
820 ,p_argument_value => p_validation_start_date
821 );
822 --
823 hr_api.mandatory_arg_error
824 (p_api_name => l_proc
825 ,p_argument => 'validation_end_date'
826 ,p_argument_value => p_validation_end_date
827 );
828 --
829 hr_api.mandatory_arg_error
830 (p_api_name => l_proc
831 ,p_argument => 'payroll_id'
832 ,p_argument_value => p_payroll_id
833 );
834 --
835 --
836 If (dt_api.rows_exist
837 (p_base_table_name => 'per_all_assignments_f'
838 ,p_base_key_column => 'payroll_id'
839 ,p_base_key_value => p_payroll_id
840 ,p_from_date => p_validation_start_date
841 ,p_to_date => p_validation_end_date
842 )) Then
843 --
844 l_table_name := 'PER_ALL_ASSIGNMENTS_F';
845 raise l_rows_exist;
846 --
847 End If;
848 --
849 If (dt_api.rows_exist
850 (p_base_table_name => 'pay_element_links_f'
851 ,p_base_key_column => 'payroll_id'
852 ,p_base_key_value => p_payroll_id
853 ,p_from_date => p_validation_start_date
854 ,p_to_date => p_validation_end_date
855 )) Then
856 --
857 l_table_name := 'PAY_ELEMENT_LINKS_F';
858 raise l_rows_exist;
859 --
860 End If;
861 --
862 If (dt_api.rows_exist
863 (p_base_table_name => 'hr_all_positions_f'
864 ,p_base_key_column => 'pay_freq_payroll_id'
868 )) Then
865 ,p_base_key_value => p_payroll_id
866 ,p_from_date => p_validation_start_date
867 ,p_to_date => p_validation_end_date
869 --
870 l_table_name := 'HR_ALL_POSITIONS_F';
871 raise l_rows_exist;
872 --
873 End If;
874 --
875 hr_utility.set_location('Leaving:'||l_proc, 50);
876 End If;
877 --
878 Exception
879 When l_rows_exist Then
880 --
881 -- A referential integrity check was violated therefore
882 -- we must error
883 --
884 fnd_message.set_name('PAY', 'HR_7215_DT_CHILD_EXISTS');
885 fnd_message.set_token('TABLE_NAME', l_table_name);
886 fnd_message.raise_error;
887
888 When Others Then
889 --
890 -- An unhandled or unexpected error has occurred which
891 -- we must report
892 --
893 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
894 fnd_message.set_token('PROCEDURE', l_proc);
895 fnd_message.set_token('STEP','15');
896 fnd_message.raise_error;
897 --
898 End dt_delete_validate;
899 --
900 --
901 -- ----------------------------------------------------------------------------
902 -- |----------------------< chk_default_payment_method_id >-------------------|
903 -- ----------------------------------------------------------------------------
904 --
905 -- Description
906 -- This procedure is used to validate the business rules for column
907 -- default_payment_method_id.
908 -------------------------------------------------------------------------------
909 procedure chk_default_payment_method_id
910 (
911 p_effective_date in date
912 ,p_business_group_id in number
913 ,p_default_payment_method_id in number
914 ) is
915 --
916 cursor csr_chk_parent is
917 select opm.effective_start_date
918 ,opm.effective_end_date
919 from pay_org_payment_methods_f opm
920 where opm.org_payment_method_id = p_default_payment_method_id
921 order by opm.effective_start_date
922 for update;
923 --
924 cursor csr_pay_catg_ass_remun is
925 select null
926 from pay_org_payment_methods_f opm, pay_payment_types pt
927 ,pay_defined_balances dfb, pay_balance_types bt
928 where opm.org_payment_method_id = p_default_payment_method_id
929 and opm.business_group_id +0 = p_business_group_id
930 and pt.payment_type_id = opm.payment_type_id
931 and pt.category in ('CA','CH')
932 and dfb.defined_balance_id = opm.defined_balance_id
933 and bt.balance_type_id = dfb.balance_type_id
934 and bt.assignment_remuneration_flag = 'Y'
935 and p_effective_date between opm.effective_start_date
936 and opm.effective_end_date;
937 --
938 v_start_date date;
939 v_end_date date;
940 v_count number;
941 --
942 begin
943 --
944 open csr_chk_parent;
945 loop
946 fetch csr_chk_parent into v_start_date, v_end_date;
947 v_count := csr_chk_parent%rowcount;
948 exit when csr_chk_parent%notfound;
949 end loop;
950 close csr_chk_parent;
951 --
952 -- Payment method must exist in PAY_ORG_PAYMENT_METHODS_F
953 --
954 if v_count = 0 then
955 fnd_message.set_name('PAY','PAY_33085_INVALID_FK');
956 fnd_message.set_token('COLUMN','DEFAULT_PAYMENT_METHOD_ID');
957 fnd_message.set_token('TABLE','PAY_ORG_PAYMENT_METHODS_F');
958 fnd_message.raise_error;
959 end if;
960 --
961 -- Payment method must be valid for the lifetime of payroll
962 --
963 if v_start_date > p_effective_date or v_end_date < hr_api.g_eot then
964 --
965 fnd_message.set_name('PAY', 'HR_7096_PAYM_PYRLL_DFLT_INVID');
966 fnd_message.raise_error;
967 --
968 end if;
969 --
970 -- Payment Method category must be either 'Cash' or 'Cheque' and
971 -- balance remuneration must be 'Yes'
972 --
973 open csr_pay_catg_ass_remun;
974 fetch csr_pay_catg_ass_remun into g_exists;
975 if csr_pay_catg_ass_remun%notfound then
976 --
977 close csr_pay_catg_ass_remun;
978 fnd_message.set_name('PAY', 'PAY_34175_PRL_CATG_ASS_REM');
979 fnd_message.raise_error;
980 --
981 end if;
982 close csr_pay_catg_ass_remun;
983 --
984 end chk_default_payment_method_id;
985 --
986 -- ----------------------------------------------------------------------------
987 -- |---------------------------< chk_period_type >----------------------------|
988 -- ----------------------------------------------------------------------------
989 --
990 -- Description
991 -- This procedure is used to validate the business rules for column
992 -- period_type.
993 -------------------------------------------------------------------------------
994 procedure chk_period_type
995 (
996 p_period_type in varchar2
997 ,p_legislation_code in varchar2
998 ,p_basic_period_type out nocopy varchar2
999 ,p_periods_per_period out nocopy number
1000 ) is
1001 --
1002 cursor csr_chk_parent is
1003 select null
1004 from per_time_period_types tpt
1005 where tpt.period_type = p_period_type;
1006 --
1010 from per_time_period_rules tpr
1007 cursor csr_basic_period_type is
1008 select tpr.basic_period_type
1009 ,tpr.periods_per_period
1011 ,per_time_period_types tpt
1012 where tpr.number_per_fiscal_year = tpt.number_per_fiscal_year
1013 and tpt.period_type = p_period_type;
1014 --
1015 begin
1016 --
1017 -- Period Type must exist in PER_TIME_PERIOD_TYPES
1018 --
1019 open csr_chk_parent;
1020 fetch csr_chk_parent into g_exists;
1021 if csr_chk_parent%notfound then
1022 --
1023 close csr_chk_parent;
1024 fnd_message.set_name('PAY','PAY_6601_PAYROLL_INV_PERIOD_TP');
1025 fnd_message.raise_error;
1026 --
1027 end if;
1028 close csr_chk_parent;
1029 --
1030 open csr_basic_period_type;
1031 fetch csr_basic_period_type into p_basic_period_type, p_periods_per_period;
1032 if csr_basic_period_type%notfound then
1033 --
1034 close csr_basic_period_type;
1035 fnd_message.set_name('PAY', 'ALL_PROCEDURE_FAIL');
1036 fnd_message.set_token('PROCEDURE','chk_period_type');
1037 fnd_message.set_token('STEP', 1);
1038 fnd_message.raise_error;
1039 --
1040 end if;
1041 close csr_basic_period_type;
1042 --
1043 -- For 'GB' legislation, the basic period type must not be Semi-Month.
1044 --
1045 if (p_legislation_code = 'GB' and p_basic_period_type = 'SM') then
1046 --
1047 fnd_message.set_name('PAY','PAY_34176_PRL_INVLD_GB_PRD');
1048 fnd_message.raise_error;
1049 --
1050 end if;
1051 --
1052 end chk_period_type;
1053 --
1054 /*
1055 * Validate the p_consolidation_set_id parameter and return
1056 * business_group_id and payroll_id values at the same time.
1057 */
1058 procedure chk_consolidation_set_id
1059 (
1060 p_consolidation_set_id in number,
1061 p_business_group_id out nocopy number
1062 ) is
1063 begin
1064
1065 -- Get the business_group_id using consolidation set.
1066 select con.business_group_id
1067 into p_business_group_id
1068 from pay_consolidation_sets con
1069 where con.consolidation_set_id = p_consolidation_set_id;
1070
1071
1072 exception
1073 when no_data_found then
1074 fnd_message.set_name('PAY','PAY_33085_INVALID_FK');
1075 fnd_message.set_token('COLUMN','CONSOLIDATION_SET_ID');
1076 fnd_message.set_token('TABLE','PAY_CONSOLIDATION_SETS');
1077 fnd_message.raise_error;
1078 end chk_consolidation_set_id;
1079 --
1080 -- ----------------------------------------------------------------------------
1081 -- |-------------------------< get_legislation_rules >------------------------|
1082 -- ----------------------------------------------------------------------------
1083 --
1084 -- Description
1085 -- This procedure is used to retrieve the legislation rules with rule type:
1086 -- PAYWSDPG_OFFSET4, PAYWSDPG_OFFSET2, PAYWSDPG_OFFSET3, PDO, ADVANCE
1087 -------------------------------------------------------------------------------
1088 procedure get_legislation_rules
1089 (
1090 p_legislation_code in varchar2
1091 ,p_rule_type in varchar2 default null
1092 ,p_cutoff_date_rule out nocopy varchar2
1093 ,p_dd_date_rule out nocopy varchar2
1094 ,p_pay_adv_date_rule out nocopy varchar2
1095 ,p_pay_date_rule out nocopy varchar2
1096 ,p_arrears_flag_rule out nocopy varchar2
1097 ) is
1098 --
1099 cursor c_get_legislation_rule is
1100 select rule_type, rule_mode
1101 from pay_legislation_rules lru
1102 where lru.legislation_code = p_legislation_code
1103 and lru.rule_type = nvl(p_rule_type,lru.rule_type);
1104 --
1105 begin
1106 --
1107 for l_rules in c_get_legislation_rule
1108 loop
1109 if l_rules.rule_type = 'PAYWSDPG_OFFSET4' then
1110 --
1111 p_cutoff_date_rule := l_rules.rule_mode;
1112 --
1113 elsif l_rules.rule_type = 'PAYWSDPG_OFFSET2' then
1114 --
1115 p_dd_date_rule := l_rules.rule_mode;
1116 --
1117 elsif l_rules.rule_type = 'PAYWSDPG_OFFSET3' then
1118 --
1119 p_pay_adv_date_rule := l_rules.rule_mode;
1120 --
1121 elsif l_rules.rule_type = 'PDO' then
1122 --
1123 p_pay_date_rule := l_rules.rule_mode;
1124 --
1125 elsif l_rules.rule_type = 'ADVANCE' then
1126 --
1127 p_arrears_flag_rule := l_rules.rule_mode;
1128 --
1129 end if;
1130 end loop;
1131 --
1132 end get_legislation_rules;
1133 --
1134
1135 --
1136 -- ----------------------------------------------------------------------------
1137 -- |---------------------------< chk_date_offsets >---------------------------|
1138 -- ----------------------------------------------------------------------------
1139 --
1140 -- Description
1141 -- This procedure is used to validate the business rules for date offsets
1142 -- depending on a set of legislation rules.
1143 -------------------------------------------------------------------------------
1144 procedure chk_date_offsets
1145 (
1146 p_pay_date_offset in number
1147 ,p_direct_deposit_date_offset in number
1148 ,p_pay_advice_date_offset in number
1149 ,p_cut_off_date_offset in number
1153 ,p_arrears_flag_rule out nocopy varchar2
1150 ,p_legislation_code in varchar2
1151 ,p_basic_period_type in varchar2
1152 ,p_periods_per_period in number
1154 ) is
1155 --
1156 l_max_offset number;
1157 l_cutoff_date_rule pay_legislation_rules.rule_mode%type;
1158 l_dd_date_rule pay_legislation_rules.rule_mode%type;
1159 l_pay_adv_date_rule pay_legislation_rules.rule_mode%type;
1160 l_pay_date_rule pay_legislation_rules.rule_mode%type;
1161 --
1162 begin
1163 --
1164 get_legislation_rules
1165 (p_legislation_code => p_legislation_code
1166 ,p_cutoff_date_rule => l_cutoff_date_rule
1167 ,p_dd_date_rule => l_dd_date_rule
1168 ,p_pay_adv_date_rule => l_pay_adv_date_rule
1169 ,p_pay_date_rule => l_pay_date_rule
1170 ,p_arrears_flag_rule => p_arrears_flag_rule
1171 );
1172 --
1173 if p_cut_off_date_offset <> 0 and l_cutoff_date_rule = 'N' then
1174 fnd_message.set_name('PAY','PAY_34174_PRL_INVALID_LEG_RULE');
1175 fnd_message.set_token('COLUMN','Cut Off Date Offset');
1176 fnd_message.raise_error;
1177 end if;
1178 --
1179 if p_direct_deposit_date_offset <> 0 and l_dd_date_rule = 'N' then
1180 fnd_message.set_name('PAY','PAY_34174_PRL_INVALID_LEG_RULE');
1181 fnd_message.set_token('COLUMN','Direct Deposit Date Offset');
1182 fnd_message.raise_error;
1183 end if;
1184 --
1185 if p_pay_advice_date_offset <> 0 and l_pay_adv_date_rule = 'N' then
1186 fnd_message.set_name('PAY','PAY_34174_PRL_INVALID_LEG_RULE');
1187 fnd_message.set_token('COLUMN','Pay Advice Date Offset');
1188 fnd_message.raise_error;
1189 end if;
1190 --
1191 if l_pay_date_rule = 'N' then
1192 --
1193 -- Calculate the maximum allowable offset which will result
1194 -- in a pay date within the period.
1195 --
1196 if p_basic_period_type = 'SM' then
1197 --
1198 l_max_offset := -12;
1199 --
1200 elsif p_basic_period_type = 'W' then
1201 --
1202 l_max_offset := (-7 * p_periods_per_period) + 1;
1203 --
1204 elsif p_basic_period_type = 'CM' then
1205 --
1206 l_max_offset := (-31 * p_periods_per_period) + 1;
1207 --
1208 end if;
1209 --
1210 -- Make sure the offset is set such that the pay date will
1211 -- lie within the period ie. is between 0 and the maximum
1212 -- allowable offset.
1213 --
1214 if p_pay_date_offset > 0 or p_pay_date_offset < l_max_offset then
1215 --
1216 fnd_message.set_name('PAY', 'PAY_6992_PAY_OFFSET_RANGE');
1217 fnd_message.set_token('MAX_OFFSET', to_char(l_max_offset), false);
1218 fnd_message.raise_error;
1219 --
1220 end if;
1221 --
1222 end if;
1223 --
1224 end chk_date_offsets;
1225 --
1226 --
1227 -- ----------------------------------------------------------------------------
1228 -- |-------------------< chk_negative_pay_allowed_flag >----------------------|
1229 -- ----------------------------------------------------------------------------
1230 --
1231 -- Description
1232 -- Negative Pay Allowed must be either 'Y' or 'N'.
1233 -------------------------------------------------------------------------------
1234 procedure chk_negative_pay_allowed_flag
1235 (
1236 p_effective_date in date
1237 ,p_negative_pay_allowed_flag in varchar2
1238 ) is
1239 begin
1240 if hr_api.not_exists_in_hr_lookups
1241 (p_effective_date
1242 ,'YES_NO'
1243 ,p_negative_pay_allowed_flag) then
1244 --
1245 fnd_message.set_name('PAY','HR_52966_INVALID_LOOKUP');
1246 fnd_message.set_token('COLUMN','NEGATIVE_PAY_ALLOWED_FLAG');
1247 fnd_message.set_token('LOOKUP_TYPE','YES_NO');
1248 fnd_message.raise_error;
1249 --
1250 end If;
1251 end chk_negative_pay_allowed_flag;
1252 --
1253 --
1254 -- ----------------------------------------------------------------------------
1255 -- |--------------------------< chk_number_of_years >-------------------------|
1256 -- ----------------------------------------------------------------------------
1257 --
1258 -- Description
1259 -- This procedure is used to validate the business rules for the column
1260 -- number_of_years.
1261 -------------------------------------------------------------------------------
1262 procedure chk_number_of_years
1263 (
1264 p_effective_date in date
1265 ,p_number_of_years in number
1266 ,p_payroll_id in number default null
1267 ) is
1268 --
1269 cursor csr_current_values is
1270 select prl.payroll_name
1271 ,prl.number_of_years
1272 ,min(effective_start_date) min_payroll_start_date
1273 ,max(prl.effective_end_date) max_payroll_end_date
1274 from pay_payrolls_f prl
1275 where prl.payroll_id = p_payroll_id
1276 group by prl.payroll_name, prl.number_of_years;
1277 --
1278 l_values_rec csr_current_values%rowtype;
1279 l_max_payroll_years number;
1280 --
1281 begin
1282 --
1283 -- The number of years must be greater than zero.
1284 --
1285 if p_number_of_years <= 0 then
1286 --
1287 fnd_message.set_name('PAY','HR_6485_PAYROLL_YEARS');
1288 fnd_message.raise_error;
1289 --
1293 -- row has not been committed then do not need to check
1290 end if;
1291 --
1292 -- Make sure that the number of years can only be increased NB. if the current
1294 if p_payroll_id is not null then
1295 --
1296 open csr_current_values;
1297 fetch csr_current_values into l_values_rec;
1298 close csr_current_values;
1299 --
1300 if p_number_of_years < l_values_rec.number_of_years then
1301 --
1302 fnd_message.set_name('PAY', 'HR_6495_PAY_UPD_YEARS');
1303 fnd_message.raise_error;
1304 --
1305 end if;
1306 --
1307 -- The number of years should be within the lifetime of the payroll
1308 --
1309 l_max_payroll_years :=
1310 round(months_between(l_values_rec.max_payroll_end_date,l_values_rec.min_payroll_start_date))/12;
1311
1312 if p_number_of_years > l_max_payroll_years then
1313 --
1314 fnd_message.set_name('PAY','PAY_34165_PAYROLL_YEARS');
1315 fnd_message.set_token('YEARS',to_char(l_max_payroll_years));
1316 fnd_message.raise_error;
1317 --
1318 end if;
1319 --
1320 end if;
1321 --
1322 end chk_number_of_years;
1323 --
1324 --
1325 -- ----------------------------------------------------------------------------
1326 -- |---------------------------< chk_payroll_name >---------------------------|
1327 -- ----------------------------------------------------------------------------
1328 --
1329 -- Description
1330 -- Payroll Name must be unique within a business group.
1331 -------------------------------------------------------------------------------
1332 procedure chk_payroll_name
1333 (
1334 p_payroll_name in varchar2
1335 ,p_business_group_id in number
1336 ,p_payroll_id in number default null
1337 ) is
1338 --
1339 begin
1340 --
1341 pay_payrolls_f_pkg.chk_payroll_unique
1342 (p_payroll_id
1343 ,p_payroll_name
1344 ,p_business_group_id
1345 );
1346 --
1347 end chk_payroll_name;
1348 --
1349 --
1350 -- ----------------------------------------------------------------------------
1351 -- |---------------------------< chk_arrears_flag >---------------------------|
1352 -- ----------------------------------------------------------------------------
1353 --
1354 -- Description
1355 -- This procedure is used to validate the business rules of column
1356 -- arrears_flag.
1357 -------------------------------------------------------------------------------
1358 procedure chk_arrears_flag
1359 (
1360 p_effective_date in date
1361 ,p_arrears_flag in varchar2
1362 ,p_arrears_flag_rule in varchar2
1363 ) is
1364 begin
1365 if hr_api.not_exists_in_hr_lookups
1366 (p_effective_date
1367 ,'YES_NO'
1368 ,p_arrears_flag) then
1369 --
1370 fnd_message.set_name('PAY','HR_52966_INVALID_LOOKUP');
1371 fnd_message.set_token('COLUMN','ARREARS_FLAG');
1372 fnd_message.set_token('LOOKUP_TYPE','YES_NO');
1373 fnd_message.raise_error;
1374 --
1375 end if;
1376 --
1377 if (p_arrears_flag = 'Y' and p_arrears_flag_rule is null) then
1378 --
1379 fnd_message.set_name('PAY','PAY_34174_PRL_INVALID_LEG_RULE');
1380 fnd_message.set_token('COLUMN','Arrears Flag');
1381 fnd_message.raise_error;
1382 --
1383 end if;
1384 --
1385 end chk_arrears_flag;
1386 --
1387 --
1388 -- ----------------------------------------------------------------------------
1389 -- |---------------------------< chk_payroll_type >---------------------------|
1390 -- ----------------------------------------------------------------------------
1391 --
1392 -- Description
1393 -- Payroll Type must correspond to the lookup codes for lookup type
1394 -- 'PAYROLL_TYPE' in HR_LOOKUPS.
1395 -------------------------------------------------------------------------------
1396 procedure chk_payroll_type
1397 (
1398 p_effective_date in date
1399 ,p_payroll_type in varchar2
1400 ) is
1401 begin
1402 --
1403 -- Check that the value supplied for payroll type exists in HR_LOOKUPS
1404 --
1405 if hr_api.not_exists_in_hr_lookups
1406 (p_effective_date
1407 ,'PAYROLL_TYPE'
1408 ,p_payroll_type) then
1409 --
1410 fnd_message.set_name('PAY','HR_51901_INVALID_PAYROLL_TYPE');
1411 fnd_message.raise_error;
1412 --
1413 end if;
1414 --
1415 end chk_payroll_type;
1416 --
1417 --
1418 -- ----------------------------------------------------------------------------
1419 -- |----------------------< chk_multi_assignments_flag >----------------------|
1420 -- ----------------------------------------------------------------------------
1421 --
1422 -- Description
1423 -- This procedure is used to validate the business rules for column
1424 -- multi_assignments_flag.
1425 -------------------------------------------------------------------------------
1426 procedure chk_multi_assignments_flag
1427 (
1428 p_effective_date in date
1429 ,p_multi_assignments_flag in varchar2
1430 ,p_legislation_code in varchar2
1431 ) is
1432 --
1433 cursor get_legislation_rule is
1434 select rule_mode
1435 from pay_legislative_field_info lfi
1436 where lfi.validation_name = 'ITEM_PROPERTY'
1437 and lfi.validation_type = 'DISPLAY'
1438 and lfi.rule_type = 'DISPLAY'
1442 --
1439 and lfi.field_name = 'MULTI_ASSIGNMENTS_FLAG'
1440 and lfi.target_location = 'PAYWSDPG'
1441 and lfi.legislation_code = p_legislation_code;
1443 l_rule_mode pay_legislative_field_info.rule_mode%type;
1444 --
1445 begin
1446 --
1447 -- Multi_assignments_flag must be NULL when there is no legislation rule
1448 -- or rule_mode is 'N'.
1449 --
1450 open get_legislation_rule;
1451 fetch get_legislation_rule into l_rule_mode;
1452 if get_legislation_rule%notfound then
1453 --
1454 close get_legislation_rule;
1455 fnd_message.set_name('PAY','PAY_34174_PRL_INVALID_LEG_RULE');
1456 fnd_message.set_token('COLUMN','Multi Assignments Flag');
1457 fnd_message.raise_error;
1458 --
1459 elsif l_rule_mode = 'N' then
1460 --
1461 close get_legislation_rule;
1462 fnd_message.set_name('PAY','PAY_34174_PRL_INVALID_LEG_RULE');
1463 fnd_message.set_token('COLUMN','Multi Assignments Flag');
1464 fnd_message.raise_error;
1465 --
1466 end if;
1467 close get_legislation_rule;
1468 --
1469 -- Multi_assignments_flag must exist in HR_LOOKUPS
1470 --
1471 if hr_api.not_exists_in_hr_lookups
1472 (p_effective_date
1473 ,'YES_NO'
1474 ,p_multi_assignments_flag) then
1475 --
1476 fnd_message.set_name('PAY','HR_52966_INVALID_LOOKUP');
1477 fnd_message.set_token('COLUMN','MULTI_ASSIGNMENTS_FLAG');
1478 fnd_message.set_token('LOOKUP_TYPE','YES_NO');
1479 fnd_message.raise_error;
1480 --
1481 end if;
1482 --
1483 end chk_multi_assignments_flag;
1484 --
1485 -- ----------------------------------------------------------------------------
1486 -- |------------------------< chk_period_reset_years >------------------------|
1487 -- ----------------------------------------------------------------------------
1488 --
1489 -- Description
1490 -- Period Reset Years cannot be greater than Number Of Years.
1491 -------------------------------------------------------------------------------
1492 procedure chk_period_reset_years
1493 (
1494 p_period_reset_years in varchar2
1495 ,p_number_of_years in number
1496 ) is
1497 --
1498 l_proc varchar2(72) := g_package||'chk_period_reset_years';
1499 --
1500 begin
1501 --
1502 if (fnd_profile.value('PAY_PERIOD_RESET_YEARS') <> 'Y' and
1503 p_period_reset_years is not null) then
1504 --
1505 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
1506 fnd_message.set_token('PROCEDURE', l_proc);
1507 fnd_message.set_token('STEP','10');
1508 fnd_message.raise_error;
1509 --
1510 end if;
1511 --
1512 if p_number_of_years is not null and p_period_reset_years not in ('N','L','F') then
1513 --
1514 fnd_message.set_name('PAY','PAY_34177_RESET_YRS_INVALID');
1515 fnd_message.raise_error;
1516 --
1517 end if;
1518 --
1519 end chk_period_reset_years;
1520 --
1521 --
1522 -- ----------------------------------------------------------------------------
1523 -- |---------------------< chk_workload_shifting_level >----------------------|
1524 -- ----------------------------------------------------------------------------
1525 --
1526 -- Description
1527 -- workload shifting level must be one of the code of the lookup type
1528 -- WORKLOAD_SHIFTING_LEVEL.
1529 -------------------------------------------------------------------------------
1530 procedure chk_workload_shifting_level
1531 (
1532 p_effective_date in date
1533 ,p_workload_shifting_level in varchar2
1534 ) is
1535 begin
1536 if hr_api.not_exists_in_hr_lookups
1537 (p_effective_date
1538 ,'WORKLOAD_SHIFTING_LEVEL'
1539 ,p_workload_shifting_level) then
1540 --
1541 fnd_message.set_name('PAY','HR_52966_INVALID_LOOKUP');
1542 fnd_message.set_token('COLUMN','WORKLOAD_SHIFTING_LEVEL');
1543 fnd_message.set_token('LOOKUP_TYPE','WORKLOAD_SHIFTING_LEVEL');
1544 fnd_message.raise_error;
1545 --
1546 end If;
1547 end chk_workload_shifting_level;
1548 --
1549 -- ----------------------------------------------------------------------------
1550 -- |----------------------< chk_keyflex_and_other_ids >-----------------------|
1551 -- ----------------------------------------------------------------------------
1552 --
1553 -- Description
1554 -- This procedure is to used for foreign key validation of -
1555 -- cost_allocation_keyflex_id
1556 -- suspense_account_keyflex_id
1557 -- gl_set_of_books_id
1558 -- soft_coding_keyflex_id
1559 -- organization_id
1560 -------------------------------------------------------------------------------
1561 procedure chk_keyflex_and_other_ids
1562 (
1563 p_cost_allocation_keyflex_id in number default null
1564 ,p_suspense_account_keyflex_id in number default null
1565 ,p_gl_set_of_books_id in number default null
1566 ,p_soft_coding_keyflex_id in number default null
1567 ,p_organization_id in number default null
1568 ,p_datetrack_mode in varchar2 default null
1569 ) is
1570 --
1571 cursor csr_chk_keyflexs(p_cost_kff_id number) is
1572 select null
1573 from pay_cost_allocation_keyflex
1574 where cost_allocation_keyflex_id = p_cost_kff_id;
1575 --
1576 cursor csr_chk_set_of_books is
1577 select null
1578 from gl_sets_of_books
1579 where set_of_books_id = p_gl_set_of_books_id;
1580 --
1581 cursor csr_chk_soft_coding_kff is
1585 --
1582 select null
1583 from hr_soft_coding_keyflex
1584 where soft_coding_keyflex_id = p_soft_coding_keyflex_id;
1586 cursor csr_chk_org is
1587 select null
1588 from hr_organization_units
1589 where organization_id = p_organization_id;
1590 --
1591 begin
1592 --
1593 if (p_datetrack_mode = hr_api.g_insert and
1594 p_cost_allocation_keyflex_id is not null)
1595 or ((p_datetrack_mode <> hr_api.g_insert) and
1596 (p_cost_allocation_keyflex_id <>
1597 nvl(pay_pay_shd.g_old_rec.COST_ALLOCATION_KEYFLEX_ID, hr_api.g_number)))
1598 then
1599 --
1600 open csr_chk_keyflexs (p_cost_allocation_keyflex_id);
1601 fetch csr_chk_keyflexs into g_exists;
1602 if csr_chk_keyflexs%notfound then
1603 --
1604 close csr_chk_keyflexs;
1605 fnd_message.set_name('PAY','PAY_33085_INVALID_FK');
1606 fnd_message.set_token('COLUMN','COST_ALLOCATION_KEYFLEX_ID');
1607 fnd_message.set_token('TABLE','PAY_COST_ALLOCATION_KEYFLEX');
1608 fnd_message.raise_error;
1609 --
1610 end if;
1611 close csr_chk_keyflexs;
1612 --
1613 end if;
1614 --
1615 if (p_datetrack_mode = hr_api.g_insert and
1616 p_suspense_account_keyflex_id is not null)
1617 or ((p_datetrack_mode <> hr_api.g_insert) and
1618 (p_suspense_account_keyflex_id <>
1619 nvl(pay_pay_shd.g_old_rec.suspense_account_keyflex_id, hr_api.g_number)))
1620 then
1621 --
1622 open csr_chk_keyflexs (p_suspense_account_keyflex_id);
1623 fetch csr_chk_keyflexs into g_exists;
1624 if csr_chk_keyflexs%notfound then
1625 --
1626 close csr_chk_keyflexs;
1627 fnd_message.set_name('PAY','PAY_33085_INVALID_FK');
1628 fnd_message.set_token('COLUMN','SUSPENSE_ACCOUNT_KEYFLEX_ID');
1629 fnd_message.set_token('TABLE','PAY_COST_ALLOCATION_KEYFLEX');
1630 fnd_message.raise_error;
1631 --
1632 end if;
1633 close csr_chk_keyflexs;
1634 --
1635 end if;
1636 --
1637 if (p_datetrack_mode = hr_api.g_insert and
1638 p_soft_coding_keyflex_id is not null)
1639 or ((p_datetrack_mode <> hr_api.g_insert) and
1640 (p_soft_coding_keyflex_id <>
1641 nvl(pay_pay_shd.g_old_rec.soft_coding_keyflex_id, hr_api.g_number)))
1642 then
1643 --
1644 open csr_chk_soft_coding_kff;
1645 fetch csr_chk_soft_coding_kff into g_exists;
1646 if csr_chk_soft_coding_kff%notfound then
1647 --
1648 close csr_chk_soft_coding_kff;
1649 fnd_message.set_name('PAY','PAY_33085_INVALID_FK');
1650 fnd_message.set_token('COLUMN','SOFT_CODING_KEYFLEX_ID');
1651 fnd_message.set_token('TABLE','HR_SOFT_CODING_KEYFLEX');
1652 fnd_message.raise_error;
1653 --
1654 end if;
1655 close csr_chk_soft_coding_kff;
1656 --
1657 end if;
1658 --
1659 if (p_datetrack_mode = hr_api.g_insert and
1660 p_gl_set_of_books_id is not null)
1661 then
1662 --
1663 open csr_chk_set_of_books;
1664 fetch csr_chk_set_of_books into g_exists;
1665 if csr_chk_set_of_books%notfound then
1666 --
1667 close csr_chk_set_of_books;
1668 fnd_message.set_name('PAY','PAY_33085_INVALID_FK');
1669 fnd_message.set_token('COLUMN','GL_SET_OF_BOOKS_ID');
1670 fnd_message.set_token('TABLE','GL_SETS_OF_BOOKS');
1671 fnd_message.raise_error;
1672 --
1673 end if;
1674 --
1675 close csr_chk_set_of_books;
1676 end if;
1677 --
1678 if (p_datetrack_mode = hr_api.g_insert and
1679 p_organization_id is not null)
1680 then
1681 open csr_chk_org;
1682 fetch csr_chk_org into g_exists;
1683 if csr_chk_org%notfound then
1684 --
1685 close csr_chk_org;
1686 fnd_message.set_name('PAY','PAY_33085_INVALID_FK');
1687 fnd_message.set_token('COLUMN','ORGANIZATION_ID');
1688 fnd_message.set_token('TABLE','HR_ORGANIZATION_UNITS');
1689 fnd_message.raise_error;
1690 --
1691 end if;
1692 --
1693 close csr_chk_org;
1694 end if;
1695 --
1696 end chk_keyflex_and_other_ids;
1697 --
1698 --
1699 --
1700 -- ----------------------------------------------------------------------------
1701 -- |---------------------------< insert_validate >----------------------------|
1702 -- ----------------------------------------------------------------------------
1703 Procedure insert_validate
1704 (p_rec in out nocopy pay_pay_shd.g_rec_type
1705 ,p_effective_date in date
1706 ,p_datetrack_mode in varchar2
1707 ,p_validation_start_date in date
1708 ,p_validation_end_date in date
1709 ) is
1710 --
1711 l_proc varchar2(72) := g_package||'insert_validate';
1712 l_business_group_id number(15);
1713
1714 l_basic_period_type per_time_period_rules.basic_period_type%type;
1715 l_periods_per_period per_time_period_rules.periods_per_period%type;
1716 l_arrears_flag_rule pay_legislation_rules.rule_mode%type;
1717 --
1718 Begin
1719 hr_utility.set_location('Entering:'||l_proc, 5);
1720 --
1721 -- Call all supporting business operations
1722 --
1723 -- Check the consolidation_set_id and get the respective business group.
1724 --
1725 pay_pay_bus.chk_consolidation_set_id(p_rec.consolidation_set_id,
1726 l_business_group_id);
1727 p_rec.business_group_id := l_business_group_id;
1728
1729 hr_api.validate_bus_grp_id
1730 (p_business_group_id => p_rec.business_group_id
1731 ,p_associated_column1 => pay_pay_shd.g_tab_nam
1732 || '.BUSINESS_GROUP_ID');
1733 --
1734 -- After validating the set of important attributes,
1735 -- if Multiple Message detection is enabled and at least
1736 -- one error has been found then abort further validation.
1737 --
1738 hr_multi_message.end_validation_set;
1739 --
1740 -- Validate Dependent Attributes
1741 --
1742
1743 if p_rec.default_payment_method_id is not null then
1744 --
1745 chk_default_payment_method_id
1746 (p_effective_date => p_effective_date
1747 ,p_business_group_id => p_rec.business_group_id
1748 ,p_default_payment_method_id => p_rec.default_payment_method_id
1749 );
1750 --
1751 end if;
1752
1753 g_legislation_code := hr_api.return_legislation_code(p_rec.business_group_id);
1754
1755 chk_period_type
1756 (p_period_type => p_rec.period_type
1757 ,p_legislation_code => g_legislation_code
1758 ,p_basic_period_type => l_basic_period_type
1759 ,p_periods_per_period => l_periods_per_period
1760 );
1761
1762 chk_date_offsets
1763 (p_pay_date_offset => p_rec.pay_date_offset
1764 ,p_direct_deposit_date_offset => p_rec.direct_deposit_date_offset
1765 ,p_pay_advice_date_offset => p_rec.pay_advice_date_offset
1766 ,p_cut_off_date_offset => p_rec.cut_off_date_offset
1767 ,p_legislation_code => g_legislation_code
1768 ,p_basic_period_type => l_basic_period_type
1769 ,p_periods_per_period => l_periods_per_period
1770 ,p_arrears_flag_rule => l_arrears_flag_rule
1771 );
1772
1773 chk_negative_pay_allowed_flag
1774 (p_effective_date => p_effective_date
1775 ,p_negative_pay_allowed_flag => p_rec.negative_pay_allowed_flag
1776 );
1777
1778 chk_number_of_years
1779 (p_effective_date => p_effective_date
1780 ,p_number_of_years => p_rec.number_of_years
1781 );
1782
1783 chk_payroll_name
1784 (p_payroll_name => p_rec.payroll_name
1785 ,p_business_group_id => p_rec.business_group_id
1786 );
1787
1788 if p_rec.arrears_flag is not null then
1789 --
1790 chk_arrears_flag
1791 (p_effective_date => p_effective_date
1792 ,p_arrears_flag => p_rec.arrears_flag
1793 ,p_arrears_flag_rule => l_arrears_flag_rule
1794 );
1795 --
1796 end if;
1797
1798 if p_rec.payroll_type is not null then
1799 --
1800 chk_payroll_type
1801 (p_effective_date => p_effective_date
1802 ,p_payroll_type => p_rec.payroll_type
1803 );
1804 --
1805 end if;
1806
1807 -- if p_rec.multi_assignments_flag is not null then
1808 -- bug 5609830 / 5144323
1809 -- if condition changed to call the validation only when the
1810 -- multi assignment flag value equal to Y.
1811 if p_rec.multi_assignments_flag = 'Y' then
1812 --
1813 chk_multi_assignments_flag
1814 (p_effective_date => p_effective_date
1815 ,p_multi_assignments_flag => p_rec.multi_assignments_flag
1816 ,p_legislation_code => g_legislation_code
1817 );
1818 --
1819 end if;
1820
1821 if p_rec.period_reset_years is not null then
1822 --
1823 chk_period_reset_years
1824 (p_period_reset_years => p_rec.period_reset_years
1825 ,p_number_of_years => p_rec.number_of_years
1826 );
1827 --
1828 end if;
1829
1830 chk_keyflex_and_other_ids
1834 ,p_soft_coding_keyflex_id => p_rec.soft_coding_keyflex_id
1831 (p_cost_allocation_keyflex_id => p_rec.cost_allocation_keyflex_id
1832 ,p_suspense_account_keyflex_id => p_rec.suspense_account_keyflex_id
1833 ,p_gl_set_of_books_id => p_rec.gl_set_of_books_id
1835 ,p_organization_id => p_rec.organization_id
1836 ,p_datetrack_mode => hr_api.g_insert
1837 );
1838 --
1839 chk_workload_shifting_level
1840 (p_effective_date => p_effective_date
1841 ,p_workload_shifting_level => p_rec.workload_shifting_level);
1842 --
1843 pay_pay_bus.chk_ddf(p_rec);
1844 --
1845 pay_pay_bus.chk_df(p_rec);
1846 --
1847 hr_utility.set_location(' Leaving:'||l_proc, 10);
1848 End insert_validate;
1849 --
1850 -- ----------------------------------------------------------------------------
1851 -- |---------------------------< update_validate >----------------------------|
1852 -- ----------------------------------------------------------------------------
1853 Procedure update_validate
1854 (p_rec in out nocopy pay_pay_shd.g_rec_type
1855 ,p_effective_date in date
1856 ,p_datetrack_mode in varchar2
1857 ,p_validation_start_date in date
1858 ,p_validation_end_date in date
1859 ) is
1860 --
1861 l_proc varchar2(72) := g_package||'update_validate';
1862 l_dummy varchar2(15);
1863 l_arrears_flag_rule pay_legislation_rules.rule_mode%type;
1864 l_business_group_id pay_all_payrolls_f.business_group_id%type;
1865
1866 --
1867 Begin
1868 hr_utility.set_location('Entering:'||l_proc, 5);
1869 --
1870 -- Call all supporting business operations
1871 --
1872 hr_api.validate_bus_grp_id
1873 (p_business_group_id => p_rec.business_group_id
1874 ,p_associated_column1 => pay_pay_shd.g_tab_nam
1875 || '.BUSINESS_GROUP_ID');
1876
1877 hr_multi_message.end_validation_set;
1878 --
1879 if p_rec.default_payment_method_id <>
1880 nvl(pay_pay_shd.g_old_rec.default_payment_method_id, hr_api.g_number) then
1881 pay_pay_bus.chk_default_payment_method_id
1882 (p_effective_date => p_effective_date
1883 ,p_business_group_id => p_rec.business_group_id
1884 ,p_default_payment_method_id => p_rec.default_payment_method_id
1885 );
1886 end if;
1887 --
1888 if p_rec.consolidation_set_id <>
1889 nvl(pay_pay_shd.g_old_rec.consolidation_set_id, hr_api.g_number) then
1890 --
1891 pay_pay_bus.chk_consolidation_set_id( p_rec.consolidation_set_id,
1892 l_business_group_id );
1893 if (l_business_group_id <> p_rec.business_group_id) then
1894 --
1895 fnd_message.set_name('PAY', 'PAY_KR_INV_CS_BG');
1896 fnd_message.raise_error;
1897 --
1898 end if;
1899 --
1900 End if;
1901 --
1902 --
1903 if p_rec.negative_pay_allowed_flag <>
1904 nvl(pay_pay_shd.g_old_rec.negative_pay_allowed_flag, hr_api.g_varchar2) then
1905 --
1906 pay_pay_bus.chk_negative_pay_allowed_flag
1907 (p_effective_date => p_effective_date
1908 ,p_negative_pay_allowed_flag => p_rec.negative_pay_allowed_flag
1909 );
1910 --
1911 end if;
1912 --
1913 if p_rec.number_of_years <> pay_pay_shd.g_old_rec.number_of_years then
1914 --
1915 pay_pay_bus.chk_number_of_years
1916 (p_effective_date => p_effective_date
1917 ,p_number_of_years => p_rec.number_of_years
1918 ,p_payroll_id => p_rec.payroll_id
1919 );
1920 --
1921 end if;
1922 --
1923 if p_rec.payroll_name <> pay_pay_shd.g_old_rec.payroll_name then
1924 --
1925 pay_pay_bus.chk_payroll_name
1926 (p_payroll_name => p_rec.payroll_name
1927 ,p_business_group_id => p_rec.business_group_id
1928 ,p_payroll_id => p_rec.payroll_id
1929 );
1930 --
1931 end if;
1932 --
1933 pay_pay_bus.get_legislation_rules
1934 (p_legislation_code => g_legislation_code
1935 ,p_rule_type => 'ADVANCE'
1936 ,p_cutoff_date_rule => l_dummy
1937 ,p_dd_date_rule => l_dummy
1938 ,p_pay_adv_date_rule => l_dummy
1939 ,p_pay_date_rule => l_dummy
1940 ,p_arrears_flag_rule => l_arrears_flag_rule
1941 );
1942 --
1943 if p_rec.arrears_flag <> nvl(pay_pay_shd.g_old_rec.arrears_flag, hr_api.g_varchar2) then
1944 --
1945 pay_pay_bus.chk_arrears_flag
1946 (p_effective_date => p_effective_date
1947 ,p_arrears_flag => p_rec.arrears_flag
1948 ,p_arrears_flag_rule => l_arrears_flag_rule
1949 );
1950 --
1951 end if;
1952 --
1953 if p_rec.multi_assignments_flag <>
1954 nvl(pay_pay_shd.g_old_rec.multi_assignments_flag, hr_api.g_varchar2) then
1955 --
1956 pay_pay_bus.chk_multi_assignments_flag
1957 (p_effective_date => p_effective_date
1958 ,p_multi_assignments_flag => p_rec.multi_assignments_flag
1959 ,p_legislation_code => g_legislation_code
1960 );
1961 --
1965 (p_cost_allocation_keyflex_id => p_rec.cost_allocation_keyflex_id
1962 end if;
1963 --
1964 pay_pay_bus.chk_keyflex_and_other_ids
1966 ,p_suspense_account_keyflex_id => p_rec.suspense_account_keyflex_id
1967 ,p_soft_coding_keyflex_id => p_rec.soft_coding_keyflex_id
1968 ,p_datetrack_mode => p_datetrack_mode
1969 );
1970
1971 --
1972 chk_workload_shifting_level
1973 (p_effective_date => p_effective_date
1974 ,p_workload_shifting_level => p_rec.workload_shifting_level);
1975 --
1976 -- After validating the set of important attributes,
1977 -- if Multiple Message detection is enabled and at least
1978 -- one error has been found then abort further validation.
1979 --
1980 hr_multi_message.end_validation_set;
1981 --
1982 -- Validate Dependent Attributes
1983 --
1984 -- Call the datetrack update integrity operation
1985 --
1986 pay_pay_bus.dt_update_validate
1987 (p_org_payment_method_id => p_rec.default_payment_method_id
1988 ,p_datetrack_mode => p_datetrack_mode
1989 ,p_validation_start_date => p_validation_start_date
1990 ,p_validation_end_date => p_validation_end_date
1991 );
1992 --
1993 pay_pay_bus.chk_non_updateable_args
1994 (p_effective_date => p_effective_date
1995 ,p_rec => p_rec
1996 );
1997 --
1998 hr_multi_message.end_validation_set;
1999 --
2000 pay_pay_bus.chk_ddf(p_rec);
2001 --
2002 pay_pay_bus.chk_df(p_rec);
2003 --
2004 hr_utility.set_location(' Leaving:'||l_proc, 10);
2005 End update_validate;
2006 --
2007 -- ----------------------------------------------------------------------------
2008 -- |---------------------------< delete_validate >----------------------------|
2009 -- ----------------------------------------------------------------------------
2010 Procedure delete_validate
2011 (p_rec in pay_pay_shd.g_rec_type
2012 ,p_effective_date in date
2013 ,p_datetrack_mode in varchar2
2014 ,p_validation_start_date in date
2015 ,p_validation_end_date in date
2016 ) is
2017 --
2018 l_proc varchar2(72) := g_package||'delete_validate';
2019 --
2020 Begin
2021 hr_utility.set_location('Entering:'||l_proc, 5);
2022 --
2023 -- Call all supporting business operations
2024 --
2025 dt_delete_validate
2026 (p_datetrack_mode => p_datetrack_mode
2027 ,p_validation_start_date => p_validation_start_date
2028 ,p_validation_end_date => p_validation_end_date
2029 ,p_payroll_id => p_rec.payroll_id
2030 );
2031 --
2032 --Added to check for the other validations.
2033 --
2034 pay_payrolls_f_pkg.validate_delete_payroll
2035 ( p_payroll_id => p_rec.payroll_id
2036 ,p_default_payment_method_id => pay_pay_shd.g_old_rec.default_payment_method_id
2037 ,p_dt_delete_mode => p_datetrack_mode
2038 ,p_validation_start_date => p_validation_start_date
2039 ,p_validation_end_date => p_validation_end_date
2040 );
2041 --
2042 hr_utility.set_location(' Leaving:'||l_proc, 10);
2043 --
2044 End delete_validate;
2045 --
2046
2047 end pay_pay_bus;