[Home] [Help]
PACKAGE BODY: APPS.PAY_IPD_SHD
Source
1 Package Body pay_ipd_shd as
2 /* $Header: pyipdrhi.pkb 120.2 2005/09/30 06:49:56 vikgupta noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pay_ipd_shd.'; -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |---------------------------< constraint_error >---------------------------|
12 -- ----------------------------------------------------------------------------
13 Procedure constraint_error
14 (p_constraint_name in all_constraints.constraint_name%TYPE
15 ) Is
16 --
17 l_proc varchar2(72) := g_package||'constraint_error';
18 --
19 Begin
20 --
21 If (p_constraint_name = 'PAY_IE_PAYE_DETAILS_F_PK') Then
22 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
23 fnd_message.set_token('PROCEDURE', l_proc);
24 fnd_message.set_token('STEP','5');
25 fnd_message.raise_error;
26 Else
27 fnd_message.set_name('PAY', 'HR_7877_API_INVALID_CONSTRAINT');
28 fnd_message.set_token('PROCEDURE', l_proc);
29 fnd_message.set_token('CONSTRAINT_NAME', p_constraint_name);
30 fnd_message.raise_error;
31 End If;
32 --
33 End constraint_error;
34 --
35 -- ----------------------------------------------------------------------------
36 -- |-----------------------------< api_updating >-----------------------------|
37 -- ----------------------------------------------------------------------------
38 Function api_updating
39 (p_effective_date in date
40 ,p_paye_details_id in number
41 ,p_object_version_number in number
42 ) Return Boolean Is
43 --
44 -- Cursor selects the 'current' row from the HR Schema
45 --
46 Cursor C_Sel1 is
47 select
48 paye_details_id
49 ,effective_start_date
50 ,effective_end_date
51 ,object_version_number
52 ,assignment_id
53 ,info_source
54 ,comm_period_no
55 ,tax_basis
56 ,certificate_start_date
57 ,certificate_end_date
58 ,tax_assess_basis
59 ,weekly_tax_credit
60 ,weekly_std_rate_cut_off
61 ,monthly_tax_credit
62 ,monthly_std_rate_cut_off
63 ,request_id
64 ,program_application_id
65 ,program_id
66 ,program_update_date
67 ,certificate_issue_date
68 from pay_ie_paye_details_f
69 where paye_details_id = p_paye_details_id
70 and p_effective_date
71 between effective_start_date and effective_end_date;
72 --
73 l_fct_ret boolean;
74 --
75 Begin
76 --
77 If (p_effective_date is null or
78 p_paye_details_id is null or
79 p_object_version_number is null) Then
80 --
81 -- One of the primary key arguments is null therefore we must
82 -- set the returning function value to false
83 --
84 l_fct_ret := false;
85 Else
86 If (p_paye_details_id =
87 pay_ipd_shd.g_old_rec.paye_details_id and
88 p_object_version_number =
89 pay_ipd_shd.g_old_rec.object_version_number
90 ) Then
91 --
92 -- The g_old_rec is current therefore we must
93 -- set the returning function to true
94 --
95 l_fct_ret := true;
96 Else
97 --
98 -- Select the current row
99 --
100 Open C_Sel1;
101 Fetch C_Sel1 Into pay_ipd_shd.g_old_rec;
102 If C_Sel1%notfound Then
103 Close C_Sel1;
104 --
105 -- The primary key is invalid therefore we must error
106 --
107 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
108 fnd_message.raise_error;
109 End If;
110 Close C_Sel1;
111 If (p_object_version_number
112 <> pay_ipd_shd.g_old_rec.object_version_number) Then
113 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
114 fnd_message.raise_error;
115 End If;
116 l_fct_ret := true;
117 End If;
118 End If;
119 Return (l_fct_ret);
120 --
121 End api_updating;
122 --
123 -- ----------------------------------------------------------------------------
124 -- |---------------------------< find_dt_upd_modes >--------------------------|
125 -- ----------------------------------------------------------------------------
126 Procedure find_dt_upd_modes
127 (p_effective_date in date
128 ,p_base_key_value in number
129 ,p_correction out nocopy boolean
130 ,p_update out nocopy boolean
131 ,p_update_override out nocopy boolean
132 ,p_update_change_insert out nocopy boolean
133 ) is
134 --
135 l_proc varchar2(72) := g_package||'find_dt_upd_modes';
136 --
137 Begin
138 hr_utility.set_location('Entering:'||l_proc, 5);
139 --
140 -- Call the corresponding datetrack api
141 --
142 dt_api.find_dt_upd_modes
143 (p_effective_date => p_effective_date
144 ,p_base_table_name => 'pay_ie_paye_details_f'
145 ,p_base_key_column => 'paye_details_id'
146 ,p_base_key_value => p_base_key_value
147 ,p_correction => p_correction
148 ,p_update => p_update
149 ,p_update_override => p_update_override
150 ,p_update_change_insert => p_update_change_insert
151 );
152 --
153 hr_utility.set_location(' Leaving:'||l_proc, 10);
154 End find_dt_upd_modes;
155 --
156 -- ----------------------------------------------------------------------------
157 -- |---------------------------< find_dt_del_modes >--------------------------|
158 -- ----------------------------------------------------------------------------
159 Procedure find_dt_del_modes
160 (p_effective_date in date
161 ,p_base_key_value in number
162 ,p_zap out nocopy boolean
163 ,p_delete out nocopy boolean
164 ,p_future_change out nocopy boolean
165 ,p_delete_next_change out nocopy boolean
166 ) is
167 --
168 l_proc varchar2(72) := g_package||'find_dt_del_modes';
169 --
170 l_parent_key_value1 number;
171 --
172 Cursor C_Sel1 Is
173 select
174 t.assignment_id
175 from pay_ie_paye_details_f t
176 where t.paye_details_id = p_base_key_value
177 and p_effective_date
178 between t.effective_start_date and t.effective_end_date;
179 --
180 Begin
181 hr_utility.set_location('Entering:'||l_proc, 5);
182 Open C_sel1;
183 Fetch C_Sel1 Into
184 l_parent_key_value1;
185 If C_Sel1%NOTFOUND then
186 Close C_Sel1;
187 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
188 fnd_message.set_token('PROCEDURE',l_proc);
189 fnd_message.set_token('STEP','10');
190 fnd_message.raise_error;
191 End If;
192 Close C_Sel1;
193 --
194 -- Call the corresponding datetrack api
195 --
196 dt_api.find_dt_del_modes
197 (p_effective_date => p_effective_date
198 ,p_base_table_name => 'pay_ie_paye_details_f'
199 ,p_base_key_column => 'paye_details_id'
200 ,p_base_key_value => p_base_key_value
201 ,p_parent_table_name1 => 'per_all_assignments_f'
202 ,p_parent_key_column1 => 'assignment_id'
203 ,p_parent_key_value1 => l_parent_key_value1
204 ,p_zap => p_zap
205 ,p_delete => p_delete
206 ,p_future_change => p_future_change
207 ,p_delete_next_change => p_delete_next_change
208 );
209 --
210 hr_utility.set_location(' Leaving:'||l_proc, 10);
211 End find_dt_del_modes;
212 --
213 -- ----------------------------------------------------------------------------
214 -- |-----------------------< upd_effective_end_date >-------------------------|
215 -- ----------------------------------------------------------------------------
216 Procedure upd_effective_end_date
217 (p_effective_date in date
218 ,p_base_key_value in number
219 ,p_new_effective_end_date in date
220 ,p_validation_start_date in date
221 ,p_validation_end_date in date
222 ,p_object_version_number out nocopy number
223 ) is
224 --
225 l_proc varchar2(72) := g_package||'upd_effective_end_date';
226 l_object_version_number number;
227 --
228 Begin
229 hr_utility.set_location('Entering:'||l_proc, 5);
230 --
231 -- Because we are updating a row we must get the next object
232 -- version number.
233 --
234 l_object_version_number :=
235 dt_api.get_object_version_number
236 (p_base_table_name => 'pay_ie_paye_details_f'
237 ,p_base_key_column => 'paye_details_id'
238 ,p_base_key_value => p_base_key_value
239 );
240 --
241 hr_utility.set_location(l_proc, 10);
242 --
243 --
244 -- Update the specified datetrack row setting the effective
245 -- end date to the specified new effective end date.
246 --
247 update pay_ie_paye_details_f t
248 set t.effective_end_date = p_new_effective_end_date
249 , t.object_version_number = l_object_version_number
250 where t.paye_details_id = p_base_key_value
251 and p_effective_date
252 between t.effective_start_date and t.effective_end_date;
253 --
254 --
255 p_object_version_number := l_object_version_number;
256 hr_utility.set_location(' Leaving:'||l_proc, 15);
257 --
258 End upd_effective_end_date;
259 --
260 -- ----------------------------------------------------------------------------
261 -- |---------------------------------< lck >----------------------------------|
262 -- ----------------------------------------------------------------------------
263 Procedure lck
264 (p_effective_date in date
265 ,p_datetrack_mode in varchar2
266 ,p_paye_details_id in number
267 ,p_object_version_number in number
268 ,p_validation_start_date out nocopy date
269 ,p_validation_end_date out nocopy date
270 ) is
271 --
272 l_proc varchar2(72) := g_package||'lck';
273 l_validation_start_date date;
274 l_validation_end_date date;
275 l_argument varchar2(30);
276 --
277 -- Cursor C_Sel1 selects the current locked row as of session date
278 -- ensuring that the object version numbers match.
279 --
280 Cursor C_Sel1 is
281 select
282 paye_details_id
283 ,effective_start_date
284 ,effective_end_date
285 ,object_version_number
286 ,assignment_id
287 ,info_source
288 ,comm_period_no
289 ,tax_basis
290 ,certificate_start_date
291 ,certificate_end_date
292 ,tax_assess_basis
293 ,weekly_tax_credit
294 ,weekly_std_rate_cut_off
295 ,monthly_tax_credit
296 ,monthly_std_rate_cut_off
297 ,request_id
298 ,program_application_id
299 ,program_id
300 ,program_update_date
301 ,certificate_issue_date
302 from pay_ie_paye_details_f
303 where paye_details_id = p_paye_details_id
304 and p_effective_date
305 between effective_start_date and effective_end_date
306 for update nowait;
307 --
308 --
309 --
310 Begin
311 hr_utility.set_location('Entering:'||l_proc, 5);
312 --
313 -- Ensure that all the mandatory arguments are not null
314 --
315 hr_api.mandatory_arg_error(p_api_name => l_proc
316 ,p_argument => 'effective_date'
317 ,p_argument_value => p_effective_date
318 );
319 --
320 hr_api.mandatory_arg_error(p_api_name => l_proc
321 ,p_argument => 'datetrack_mode'
322 ,p_argument_value => p_datetrack_mode
323 );
324 --
325 hr_api.mandatory_arg_error(p_api_name => l_proc
326 ,p_argument => 'paye_details_id'
327 ,p_argument_value => p_paye_details_id
328 );
329 --
330 hr_api.mandatory_arg_error(p_api_name => l_proc
331 ,p_argument => 'object_version_number'
332 ,p_argument_value => p_object_version_number
333 );
334 --
335 -- Check to ensure the datetrack mode is not INSERT.
336 --
337 If (p_datetrack_mode <> hr_api.g_insert) then
338 --
339 -- We must select and lock the current row.
340 --
341 Open C_Sel1;
342 Fetch C_Sel1 Into pay_ipd_shd.g_old_rec;
343 If C_Sel1%notfound then
344 Close C_Sel1;
345 --
346 -- The primary key is invalid therefore we must error
347 --
348 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
349 fnd_message.raise_error;
350 End If;
351 Close C_Sel1;
352 If (p_object_version_number
353 <> pay_ipd_shd.g_old_rec.object_version_number) Then
354 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
355 fnd_message.raise_error;
356 End If;
357 --
358 --
359 -- Validate the datetrack mode mode getting the validation start
360 -- and end dates for the specified datetrack operation.
361 --
362 dt_api.validate_dt_mode
363 (p_effective_date => p_effective_date
364 ,p_datetrack_mode => p_datetrack_mode
365 ,p_base_table_name => 'pay_ie_paye_details_f'
366 ,p_base_key_column => 'paye_details_id'
367 ,p_base_key_value => p_paye_details_id
368 ,p_parent_table_name1 => 'per_all_assignments_f'
369 ,p_parent_key_column1 => 'assignment_id'
370 ,p_parent_key_value1 => pay_ipd_shd.g_old_rec.assignment_id
371 ,p_enforce_foreign_locking => true
372 ,p_validation_start_date => l_validation_start_date
373 ,p_validation_end_date => l_validation_end_date
374 );
375 Else
376 --
377 -- We are doing a datetrack 'INSERT' which is illegal within this
378 -- procedure therefore we must error (note: to lck on insert the
379 -- private procedure ins_lck should be called).
380 --
381 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
382 fnd_message.set_token('PROCEDURE', l_proc);
383 fnd_message.set_token('STEP','20');
384 fnd_message.raise_error;
385 End If;
386 --
387 -- Set the validation start and end date OUT arguments
388 --
389 p_validation_start_date := l_validation_start_date;
390 p_validation_end_date := l_validation_end_date;
391 --
392 hr_utility.set_location(' Leaving:'||l_proc, 30);
393 --
394 -- We need to trap the ORA LOCK exception
395 --
396 Exception
397 When HR_Api.Object_Locked then
398 --
399 -- The object is locked therefore we need to supply a meaningful
400 -- error message.
401 --
402 fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
403 fnd_message.set_token('TABLE_NAME', 'pay_ie_paye_details_f');
404 fnd_message.raise_error;
405 End lck;
406 --
407 -- ----------------------------------------------------------------------------
408 -- |-----------------------------< convert_args >-----------------------------|
409 -- ----------------------------------------------------------------------------
410 Function convert_args
411 (p_paye_details_id in number
412 ,p_effective_start_date in date
413 ,p_effective_end_date in date
414 ,p_object_version_number in number
415 ,p_assignment_id in number
416 ,p_info_source in varchar2
417 ,p_comm_period_no in number
418 ,p_tax_basis in varchar2
419 ,p_certificate_start_date in date
420 ,p_certificate_end_date in date
421 ,p_tax_assess_basis in varchar2
422 ,p_weekly_tax_credit in number
423 ,p_weekly_std_rate_cut_off in number
424 ,p_monthly_tax_credit in number
425 ,p_monthly_std_rate_cut_off in number
426 ,p_request_id in number
427 ,p_program_application_id in number
428 ,p_program_id in number
429 ,p_program_update_date in date
430 ,p_certificate_issue_date in date
431 )
432 Return g_rec_type is
433 --
434 l_rec g_rec_type;
435 --
436 Begin
437 --
438 -- Convert arguments into local l_rec structure.
439 --
440 l_rec.paye_details_id := p_paye_details_id;
441 l_rec.effective_start_date := p_effective_start_date;
442 l_rec.effective_end_date := p_effective_end_date;
443 l_rec.object_version_number := p_object_version_number;
444 l_rec.assignment_id := p_assignment_id;
445 l_rec.info_source := p_info_source;
446 l_rec.comm_period_no := p_comm_period_no;
447 l_rec.tax_basis := p_tax_basis;
448 l_rec.certificate_start_date := p_certificate_start_date;
449 l_rec.certificate_end_date := p_certificate_end_date;
450 l_rec.tax_assess_basis := p_tax_assess_basis;
451 l_rec.weekly_tax_credit := p_weekly_tax_credit;
452 l_rec.weekly_std_rate_cut_off := p_weekly_std_rate_cut_off;
453 l_rec.monthly_tax_credit := p_monthly_tax_credit;
454 l_rec.monthly_std_rate_cut_off := p_monthly_std_rate_cut_off;
455 l_rec.request_id := p_request_id;
456 l_rec.program_application_id := p_program_application_id;
457 l_rec.program_id := p_program_id;
458 l_rec.program_update_date := p_program_update_date;
459 l_rec.certificate_issue_date := p_certificate_issue_date;
460 --
461 -- Return the plsql record structure.
462 --
463 Return(l_rec);
464 --
465 End convert_args;
466 --
467 end pay_ipd_shd;