1 package body pay_us_emp_dt_tax_rules as
2 /* $Header: pyusdtw4.pkb 120.20.12020000.2 2012/07/05 03:11:29 amnaraya ship $ */
3
4 /* Name : maintain_element_entry
5 Purpose : This procedure can be used to create as well as update the vertex
6 element entry for an assignment. It calls the element entries api
7 to insert and update the element entry record.
8 Parameters :
9 p_assignment_id -> The assignment for which the vertex elemnt entry is to be
10 created/modified.
11 p_effective_start_date -> The start date of the element entry.
12 p_effective_end_date -> The end date of the element entry.
13 p_session_date -> This will be helpful for the various update modes.
14 p_jurisdiction_code -> The jurisdiction code for which the elemnt entry is to
15 created/updated.
16 p_percentage_time -> Time in the jurisdiction.
17 p_mode -> If can have the following values :
18 'INSERT'
19 'CORRECTION',
20 'UPDATE',
21 'UPDATE_CHANGE_INSERT',
22 'UPDATE_OVERRIDE',
23 'ZAP'
24 'INSERT_OLD'
25 Note : Since the change in location might lead us to scenarios where we might
26 want to do various kinds of updates, all kinds of update modes have been
27 added.
28 */
29
30 procedure maintain_element_entry (p_assignment_id in number,
31 p_effective_start_date in date,
32 p_effective_end_date in date,
33 p_session_date in date,
34 p_jurisdiction_code in varchar2,
35 p_percentage_time in number,
36 p_mode in varchar2) is
37
38 l_inp_value_id_table hr_entry.number_table;
39 l_scr_value_table hr_entry.varchar2_table;
40
41 l_element_type_id number :=0;
42 l_inp_name varchar2(80) :=null;
43 l_inp_val_id number :=0;
44 i number := 1;
45 l_element_link_id number :=0;
46 l_element_entry_id number :=0;
47 l_effective_start_date date;
48 l_effective_end_date date;
49 l_mode varchar2(30);
50 l_delete_flag varchar2(1) := 'N';
51 l_percent number;
52 l_end_of_time date := to_date('31/12/4712','dd/mm/yyyy');
53 l_payroll_installed boolean := FALSE;
54
55 /* Cursor to get the vertex element type */
56
57 cursor csr_tax_element is
58 select pet.element_type_id,
59 piv.input_value_id,
60 piv.name
61 from PAY_INPUT_VALUES_F piv,
62 PAY_ELEMENT_TYPES_F pet
63 where p_session_date between piv.effective_start_date
64 and piv.effective_end_date
65 and pet.element_type_id = piv.element_type_id
66 and p_session_date between pet.effective_start_date
67 and pet.effective_end_date
68 and pet.element_name = 'VERTEX';
69
70 /* Cursor to get the element entry for the jurisdiction */
71
72 cursor csr_ele_entry (p_element_link number, p_inp_val number)is
73 select pee.element_entry_id
74 from PAY_ELEMENT_ENTRY_VALUES_F pev,
75 PAY_ELEMENT_ENTRIES_F pee
76 where pev.screen_entry_value = p_jurisdiction_code
77 and pev.input_value_id + 0 = p_inp_val
78 and p_session_date between pev.effective_start_date
79 and pev.effective_end_date
80 and pev.element_entry_id = pee.element_entry_id
81 and p_session_date between pee.effective_start_date
82 and pee.effective_end_date
83 and pee.element_link_id = p_element_link
84 and pee.assignment_id = p_assignment_id;
85
86 /* Cursor to get the current percentage of the element entry */
87
88 cursor csr_get_curr_percnt (p_ele_entry_id number, p_inp_val number)is
89 select pev.screen_entry_value
90 from PAY_ELEMENT_ENTRY_VALUES_F pev
91 where pev.screen_entry_value is not null
92 and pev.input_value_id + 0 = p_inp_val
93 and p_session_date between pev.effective_start_date
94 and pev.effective_end_date
95 and pev.element_entry_id = p_ele_entry_id;
96
97
98 begin
99
100 l_payroll_installed := hr_utility.chk_product_install(p_product =>'Oracle Payroll',
101 p_legislation => 'US');
102 if l_payroll_installed then
103
104 hr_utility.set_location('pay_us_emp_dt_tax_rules.maintain_element_entry'
105 ,1);
106
107 open csr_tax_element;
108
109 loop
110
111 fetch csr_tax_element into l_element_type_id,
112 l_inp_val_id,
113 l_inp_name;
114
115 exit when csr_tax_element%NOTFOUND;
116
117 if upper(l_inp_name) = 'PAY VALUE'
118 then
119 l_inp_value_id_table(1) := l_inp_val_id;
120 elsif upper(l_inp_name) = 'JURISDICTION'
121 then
122 l_inp_value_id_table(2) := l_inp_val_id;
123 elsif upper(l_inp_name) = 'PERCENTAGE'
124 then
125 l_inp_value_id_table(3) := l_inp_val_id;
126 end if;
127 end loop;
128
129 close csr_tax_element;
130
131 hr_utility.set_location('pay_us_emp_dt_tax_rules.maintain_element_entry'
132 ,2);
133
134 /* Check that all of the input value id for vertex, exists */
135
136 for i in 1..3 loop
137
138 if l_inp_value_id_table(i) = null or
139 l_inp_value_id_table(i) = 0
140 then
141 fnd_message.set_name('PAY', 'HR_13140_TAX_ELEMENT_ERROR');
142 fnd_message.set_token('1','VERTEX');
143 fnd_message.raise_error;
144 end if;
145
146 end loop;
147
148 hr_utility.set_location('pay_us_emp_dt_tax_rules.maintain_element_entry'
149 ,3);
150
151 /* Get element link */
152 l_element_link_id := hr_entry_api.get_link(
153 P_assignment_id => p_assignment_id,
154 P_element_type_id => l_element_type_id,
155 P_session_date => p_effective_start_date);
156
157 if l_element_link_id is null or l_element_link_id = 0
158 then
159 fnd_message.set_name('PAY', 'HR_13140_TAX_ELEMENT_ERROR');
160 fnd_message.set_token('1','VERTEX');
161 fnd_message.raise_error;
162 end if;
163
164 hr_utility.set_location('pay_us_emp_dt_tax_rules.maintain_element_entry'
165 ,4);
166
167 /* Store screen entry value in the table */
168
169 l_scr_value_table(1) := null;
170 l_scr_value_table(2) := p_jurisdiction_code;
171 l_scr_value_table(3) := nvl(fnd_number.number_to_canonical(p_percentage_time),'0');
172
173 /* assign the parameters to local variables because the element entry procedures
174 expect them to be in out parameters */
175
176 l_effective_start_date := p_effective_start_date;
177 l_effective_end_date := p_effective_end_date;
178 l_mode := p_mode;
179
180 if p_mode = 'INSERT' then
181
182 /* Create the vertex element entry */
183
184 hr_utility.set_location('pay_us_emp_dt_tax_rules.maintain_element_entry' ,5);
185
186 hr_entry_api.insert_element_entry( P_effective_start_date => l_effective_start_date,
187 P_effective_end_date => l_effective_end_date,
188 P_element_entry_id => l_element_entry_id,
189 P_assignment_id => p_assignment_id,
190 P_element_link_id => l_element_link_id,
191 P_creator_type => 'UT',
192 P_entry_type => 'E',
193 P_num_entry_values => 3,
194 P_input_value_id_tbl => l_inp_value_id_table,
195 P_entry_value_tbl => l_scr_value_table);
196
197 hr_utility.set_location('pay_us_emp_dt_tax_rules.maintain_element_entry' ,6);
198
199 elsif p_mode in ('CORRECTION','UPDATE', 'UPDATE_CHANGE_INSERT','UPDATE_OVERRIDE','ZAP','DELETE_NEXT_CHANGE','FUTURE_CHANGE','INSERT_OLD') then
200
201 /* Get the element entry of the vertex element entry that is to be updated
202 or deleted */
203
204 hr_utility.set_location('pay_us_emp_dt_tax_rules.maintain_element_entry' ,7);
205
206
207 open csr_ele_entry(l_element_link_id, l_inp_value_id_table(2));
208
209 fetch csr_ele_entry into l_element_entry_id;
210
211 /* Added the delete flag for the upgrade. Currently, there
212 may be state tax records which might not have a vertex
213 element entry */
214
215 if csr_ele_entry%NOTFOUND then
216 if p_mode in('ZAP','DELETE_NEXT_CHANGE','FUTURE_CHANGE') then
217
218 l_delete_flag := 'N';
219 else
220
221 close csr_ele_entry;
222 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
223 fnd_message.set_token('PROCEDURE',
224 'pay_us_emp_dt_tax_rules.maintain_element_entry');
225 fnd_message.set_token('STEP','1');
226 fnd_message.raise_error;
227
228 end if;
229
230 else /* found the element entry id */
231
232 l_delete_flag := 'Y';
233
234 end if;
235
236 close csr_ele_entry;
237
238 if p_mode = 'INSERT_OLD' then
239
240 open csr_get_curr_percnt(l_element_entry_id, l_inp_value_id_table(3));
241
242 fetch csr_get_curr_percnt into l_scr_value_table(3);
243
244 if csr_get_curr_percnt%NOTFOUND then
245
246 close csr_get_curr_percnt;
247 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
248 fnd_message.set_token('PROCEDURE',
249 'pay_us_emp_dt_tax_rules.maintain_element_entry');
250 fnd_message.set_token('STEP','2');
251 fnd_message.raise_error;
252
253 end if;
254
255 close csr_get_curr_percnt;
256
257 if p_effective_end_date = l_end_of_time then
258
259 l_mode := 'UPDATE';
260
261 else
262
263 l_mode := 'UPDATE_CHANGE_INSERT';
264
265 end if;
266
267 end if;
268
269 if p_mode in ('ZAP','DELETE_NEXT_CHANGE','FUTURE_CHANGE')
270 and l_delete_flag = 'Y' then
271
272 hr_entry_api.delete_element_entry(
273 p_dt_delete_mode => l_mode,
274 p_session_date => p_session_date,
275 p_element_entry_id => l_element_entry_id);
276
277 elsif p_mode in ('CORRECTION','UPDATE', 'UPDATE_CHANGE_INSERT','UPDATE_OVERRIDE','INSERT_OLD') then
278
279 hr_entry_api.update_element_entry(
280 p_dt_update_mode => l_mode,
281 p_session_date => p_session_date,
282 p_element_entry_id => l_element_entry_id,
283 p_num_entry_values => 3,
284 p_input_value_id_tbl => l_inp_value_id_table,
285 p_entry_value_tbl => l_scr_value_table);
286
287 end if;
288
289 end if;
290
291 end if;
292
293 end maintain_element_entry;
294
295
296 /* Name : maintain_wc_ele_entry
297 Purpose : This procedure can be used to create as well as update the worker's
298 compensation element entry for an assignment. It calls the element
299 entries api to insert and update the element entry record.
300 Parameters :
301 p_assignment_id -> The assignment for which the vertex elemnt entry is to be
302 created/modified.
303 p_effective_start_date -> The start date of the element entry.
304 p_effective_end_date -> The end date of the element entry.
305 p_session_date -> This will be helpful for changing the wc element
306 entry for change in the federal record.
307 p_jurisdiction_code -> The jurisdiction code for which the elemnt entry is to
308 created/updated.
309 p_mode -> If can have the following values :
310 'INSERT'
311 'CORRECTION',
312 'UPDATE',
313 'UPDATE_CHANGE_INSERT',
314 'UPDATE_OVERRIDE',
315 'ZAP'
316 Note : For every change in federal record, we will be changing the worker's comp element entry.
317 */
318
319 procedure maintain_wc_ele_entry (p_assignment_id in number,
320 p_effective_start_date in date,
321 p_effective_end_date in date,
322 p_session_date in date,
323 p_jurisdiction_code in varchar2,
324 p_mode in varchar2) is
325
326 l_inp_value_id_table hr_entry.number_table;
327 l_scr_value_table hr_entry.varchar2_table;
328
329 l_element_type_id number :=0;
330 l_inp_name varchar2(80) :=null;
331 l_inp_val_id number :=0;
332 l_element_link_id number :=0;
333 l_element_entry_id number :=0;
334 l_effective_start_date date := null;
335 l_effective_end_date date := null;
336 l_mode varchar2(30);
337 l_delete_flag varchar2(1);
338 l_payroll_installed boolean := FALSE;
339
340 /* Cursor to get the worker's compensation element type */
341
342 cursor csr_wc_tax_element is
343 select pet.element_type_id,
344 piv.input_value_id,
345 piv.name
346 from PAY_INPUT_VALUES_F piv,
347 PAY_ELEMENT_TYPES_F pet
348 where p_session_date between piv.effective_start_date
349 and piv.effective_end_date
350 and pet.element_type_id = piv.element_type_id
351 and p_session_date between pet.effective_start_date
352 and pet.effective_end_date
353 and pet.element_name = 'Workers Compensation'; -- Bug 3354060 FTS on PAY_ELEMENT_TYPES_F was removed. Done by removing
354 -- 'upper' from pet.element_name and 'WORKERS COMPENSATION' was changed to
355 -- 'Workers Compensation'
356
357
358 /* Cursor to get the worker's compensation element entry */
359
360 cursor csr_wc_ele_entry (p_element_link number)is
361 select pee.element_entry_id
362 from PAY_ELEMENT_ENTRIES_F pee
363 where p_session_date between pee.effective_start_date
364 and pee.effective_end_date
365 and pee.element_link_id = p_element_link
366 and pee.assignment_id = p_assignment_id;
367
368 begin
369
370 l_payroll_installed := hr_utility.chk_product_install(p_product =>'Oracle Payroll',
371 p_legislation => 'US');
372 if l_payroll_installed then
373
374 hr_utility.set_location('pay_us_emp_dt_tax_rules.maintain_wc_ele_entry'
375 ,1);
376
377 open csr_wc_tax_element;
378
379 loop
380
381 fetch csr_wc_tax_element into l_element_type_id,
382 l_inp_val_id,
383 l_inp_name;
384
385 exit when csr_wc_tax_element%NOTFOUND;
386
387 if upper(l_inp_name) = 'PAY VALUE' then
388
389 l_inp_value_id_table(1) := l_inp_val_id;
390
391 elsif upper(l_inp_name) = 'JURISDICTION' then
392
393 l_inp_value_id_table(2) := l_inp_val_id;
394
395 end if;
396
397 end loop;
398
399 close csr_wc_tax_element;
400
401 hr_utility.set_location('pay_us_emp_dt_tax_rules.maintain_wc_ele_entry'
402 ,2);
403
404 /* Check that all of the input value id for vertex, exists */
405
406 for i in 1..2 loop
407
408 if l_inp_value_id_table(i) = null or
409 l_inp_value_id_table(i) = 0 then
410
411 fnd_message.set_name('PAY', 'HR_7713_TAX_ELEMENT_ERROR');
412 fnd_message.raise_error;
413
414 end if;
415
416 end loop;
417
418 hr_utility.set_location('pay_us_emp_dt_tax_rules.maintain_wc_ele_entry'
419 ,3);
420
421 /* Get element link */
422 l_element_link_id := hr_entry_api.get_link(
423 P_assignment_id => p_assignment_id,
424 P_element_type_id => l_element_type_id,
425 P_session_date => p_effective_start_date);
426
427 if l_element_link_id is null or l_element_link_id = 0
428 then
429
430 fnd_message.set_name('PAY', 'HR_7713_TAX_ELEMENT_ERROR');
431 fnd_message.raise_error;
432
433 end if;
434
435 hr_utility.set_location('pay_us_emp_dt_tax_rules.maintain_wc_ele_entry'
436 ,4);
437
438 /* Store screen entry value in the table */
439
440 l_scr_value_table(1) := null;
441 l_scr_value_table(2) := p_jurisdiction_code;
442
443 /* assign the parameters to local variables because the element entry procedures
444 expect them to be in out parameters */
445
446 l_effective_start_date := p_effective_start_date;
447 l_effective_end_date := p_effective_end_date;
448 l_mode := p_mode;
449
450 if p_mode = 'INSERT'
451 then
452
453 /* Insert the worker's compensation element entry */
454
455 hr_utility.set_location(
456 'pay_us_emp_dt_tax_rules.maintain_wc_ele_entry' ,5);
457 hr_entry_api.insert_element_entry(
458 P_effective_start_date => l_effective_start_date,
459 P_effective_end_date => l_effective_end_date,
460 P_element_entry_id => l_element_entry_id,
461 P_assignment_id => p_assignment_id,
462 P_element_link_id => l_element_link_id,
463 P_creator_type => 'UT',
464 P_entry_type => 'E',
465 P_num_entry_values => 2,
466 P_input_value_id_tbl => l_inp_value_id_table,
467 P_entry_value_tbl => l_scr_value_table);
468
469 hr_utility.set_location(
470 'pay_us_emp_dt_tax_rules.maintain_wc_ele_entry' ,8);
471
472 elsif p_mode in ('CORRECTION', 'UPDATE', 'UPDATE_CHANGE_INSERT','UPDATE_OVERRIDE','ZAP')then
473
474 /* Update the worker's compensation element entry */
475
476 open csr_wc_ele_entry(l_element_link_id);
477
478 fetch csr_wc_ele_entry into l_element_entry_id;
479
480 if csr_wc_ele_entry%NOTFOUND then
481
482 if p_mode in('ZAP','DELETE_NEXT_CHANGE','FUTURE_CHANGE') then
483
484 l_delete_flag := 'N';
485 else
486
487 close csr_wc_ele_entry;
488 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
489 fnd_message.set_token('PROCEDURE',
490 'pay_us_emp_dt_tax_rules.maintain_wc_ele_entry');
491 fnd_message.set_token('STEP','8');
492 fnd_message.raise_error;
493
494 end if;
495
496 else /* found the wc element entry id */
497
498 l_delete_flag := 'Y';
499
500 end if;
501
502 close csr_wc_ele_entry;
503
504 if p_mode = 'ZAP' and l_delete_flag = 'Y' then
505
506 /* All of the tax %age records will be created from the date on which the
507 default tax rules criteria was met till the end of time. So, we should
508 get records for the state, county and city for the same effective start
509 date */
510
511 hr_entry_api.delete_element_entry(
512 p_dt_delete_mode => l_mode,
513 p_session_date => p_session_date,
514 p_element_entry_id => l_element_entry_id);
515
516 elsif p_mode in ('CORRECTION','UPDATE', 'UPDATE_CHANGE_INSERT','UPDATE_OVERRIDE') then
517
518 hr_entry_api.update_element_entry(
519 p_dt_update_mode => l_mode,
520 p_session_date => p_session_date,
521 p_element_entry_id => l_element_entry_id,
522 p_num_entry_values => 2,
523 p_input_value_id_tbl => l_inp_value_id_table,
524 p_entry_value_tbl => l_scr_value_table);
525
526 end if;
527
528 end if;
529
530 end if;
531
532 end maintain_wc_ele_entry;
533
534
535 /* Name : create_tax_percentage
536 Purpose : This procedure will be called whenever a state tax rule or a county
537 tax rule or a city tax rule record gets created.
538 It gets all of the location changes that have taken place for the
539 assignment and then for each of location change, it creates an element
540 entry for the jurisdiction depending upon the kind of tax rule record
541 that is getting created.
542 Parameters :
543 p_assignment_id -> The assignemnt for which the tax rule record and hence
544 the percentage record is getting created.
545 p_state_code -> If p_state_code is not null and p_county_code is null
546 and p_city_code is null then the p_state_code specifies
547 the state for which the tax %age record is being created.
548 p_county_code -> If p_state_code is not null and p_county_code is not null
549 and p_city_code is null then it specifies the county in the
550 state of p_state_code, for which the tax percentage record
551 is being created.
552 p_city_code -> If p_state_code is not null and p_county_code is not null
553 and p_city_code is not null then it specifies the city in
554 the county of p_county_code for the state of p_state_code,
555 for which the tax percentage record is being created.
556 p_time_in_state -> If a state %age record is being created then it specifies
557 the time in state.
558 p_time_in_county -> If a county %age record is being created then it specifies
559 the time in county.
560 p_time_in_city -> If a city %age record is being created then it specifies
561 the time in city.
562 */
563
564 procedure create_tax_percentage (p_assignment_id in number,
565 p_state_code in varchar2,
566 p_county_code in varchar2,
567 p_city_code in varchar2,
568 p_time_in_state in number,
569 p_time_in_county in number,
570 p_time_in_city in number) is
571
572 l_first_location_id number(15) := 0;
573 l_next_location_id number(15) := 0;
574 l_first_effective_date date := null;
575 l_first_prev_date date := null;
576 l_next_effective_date date := null;
577 l_next_prev_date date := null;
578 l_jurisdiction_code varchar2(11);
579 l_default_date date;
580 l_time number;
581 l_ctr number := 0;
582 l_mode varchar2(30);
583
584 /* Get Effective_start_Date of the federal record to set the effective date
585 of the element entry. All of the element entries should be created from
586 the date the deafulting tax rules criteria was met. Since the federal
587 record is created from the date the defaulting criteria is met,
588 taking the min(Federal effective start date) will give us the date on
589 which the defaulting criteria was met and hence the effective start date
590 of the element entry */
591
592 cursor csr_get_eff_date is
593 select min(effective_start_date)
594 from PAY_US_EMP_FED_TAX_RULES_F
595 where assignment_id = p_assignment_id;
596
597 /* Since a change in location may have taken place before the default tax
598 rules criteria is met, we will consider only those locations whose
599 effective_end_date >= default tax rules date i.e. the federal tax rules
600 date. Thus we will be breaking the percentage records only for those
601 change in locations which have taken place after the default tax rules
602 date.
603 L1 L2 L3 L4 L2
604 Asg |--------|------|-------|------|------
605
606 Federal Tax |----|---|----|---|---------------
607
608 Note, in the above example the default tax rules criteria was satisfied
609 after change in location to L2. So, we should not be considering L1.
610 Also, since the same location may get assigned after some time period,
611 we have no other alternative than to query up all the records after the
612 default criteria date and then manual identify the change in locations
613 by means of comparing the location id */
614
615 cursor csr_get_locations (passignment number, pdefault_date date) is
616 select paf1.location_id,
617 paf1.effective_start_date,
618 paf1.effective_start_date - 1
619 from per_assignments_f paf1
620 where paf1.assignment_id = passignment
621 and paf1.effective_start_date >= pdefault_date
622 order by 2;
623
624 begin
625
626 /* Form the jurisdiction code */
627
628 if p_state_code is not null and p_county_code is null and
629 p_city_code is null
630 then
631
632 l_jurisdiction_code := p_state_code || '-000-0000';
633 l_time := p_time_in_state;
634
635 elsif p_state_code is not null and p_county_code is not null and
636 p_city_code is null
637 then
638
639 l_jurisdiction_code := p_state_code || '-' || p_county_code ||
640 '-0000';
641 l_time := p_time_in_county;
642
643 elsif p_state_code is not null and p_county_code is not null and
644 p_city_code is not null
645 then
646
647 l_jurisdiction_code := p_state_code || '-' || p_county_code ||
648 '-' || p_city_code;
649 l_time := p_time_in_city;
650
651 end if;
652
653 /* Get effective Start date of the Federal Tax Rules record */
654
655 open csr_get_eff_date;
656
657 fetch csr_get_eff_date into l_default_date;
658
659 if l_default_date is null then
660
661 close csr_get_eff_date;
662 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
663 fnd_message.set_token('PROCEDURE',
664 'pay_us_emp_dt_tax_rules.create_tax_percentage');
665 fnd_message.set_token('STEP','1');
666 fnd_message.raise_error;
667
668 end if;
669
670 close csr_get_eff_date;
671
672 /* Get all of the changes in location for the assignment */
673
674 open csr_get_locations(p_assignment_id, l_default_date);
675
676 fetch csr_get_locations into l_first_location_id, l_first_effective_date,
677 l_first_prev_date;
678 l_ctr := 1;
679
680 /* The effective start date of the first location might be less than
681 the date on which the default tax criteria was met. So, set the
682 effective start date to the date on which the default tax rules
683 criteria was satisfied */
684
685 l_first_effective_date := l_default_date;
686
687 /* Initialise the next location id, next effective date and
688 next prev date before doing the fetch */
689
690 l_next_location_id := null;
691 l_next_effective_date := null;
692 l_next_prev_date := null;
693
694 loop
695
696 exit when csr_get_locations%NOTFOUND;
697
698 fetch csr_get_locations into l_next_location_id, l_next_effective_date,
699 l_next_prev_date;
700
701 if l_next_location_id <> l_first_location_id then
702
703 if l_ctr = 1 then
704
705 l_mode := 'INSERT';
706
707 else
708
709 l_mode := 'UPDATE';
710
711 end if;
712
713 /* Call maintain_element_entry for the first location */
714
715 if l_ctr = 1 then
716
717 maintain_element_entry(p_assignment_id => p_assignment_id,
718 p_effective_start_date => l_first_effective_date,
719 p_effective_end_date => to_date('31-12-4712','dd-mm-yyyy'),
720 p_session_date => l_first_effective_date,
721 p_jurisdiction_code => l_jurisdiction_code,
722 p_percentage_time => l_time,
723 p_mode => 'INSERT');
724
725 else
726
727
728 maintain_element_entry(p_assignment_id => p_assignment_id,
729 p_effective_start_date => l_first_effective_date,
730 p_effective_end_date => to_date('31-12-4712','dd-mm-yyyy'),
731 p_session_date => l_first_effective_date,
732 p_jurisdiction_code => l_jurisdiction_code,
733 p_percentage_time => l_time,
734 p_mode => 'UPDATE');
735 end if;
736
737 l_first_location_id := l_next_location_id;
738 l_first_effective_date := l_next_effective_date;
739 l_first_prev_date := l_next_prev_date;
740 /* Initialise the next location id, next effective date and
741 next prev date before doing the fetch */
742 l_next_location_id := null;
743 l_next_effective_date := null;
744 l_next_prev_date := null;
745 l_ctr := l_ctr + 1;
746
747 end if;
748
749 end loop;
750
751 close csr_get_locations;
752
753 /* Create the element entry for the last change in location . The last
754 element entry record for the percentage time should be created till
755 end of time. hence, 31-dec-4712. */
756
757 if l_ctr = 1 then
758
759
760 maintain_element_entry(p_assignment_id => p_assignment_id,
761 p_effective_start_date => l_first_effective_date,
762 p_effective_end_date => to_date('31-12-4712','dd-mm-yyyy'),
763 p_session_date => l_first_effective_date,
764 p_jurisdiction_code => l_jurisdiction_code,
765 p_percentage_time => l_time,
766 p_mode => 'INSERT');
767 else
768
769
770 maintain_element_entry(p_assignment_id => p_assignment_id,
771 p_effective_start_date => l_first_effective_date,
772 p_effective_end_date => to_date('31-12-4712','dd-mm-yyyy'),
773 p_session_date => l_first_effective_date,
774 p_jurisdiction_code => l_jurisdiction_code,
775 p_percentage_time => l_time,
776 p_mode => 'UPDATE');
777
778 end if;
779
780
781
782 end create_tax_percentage;
783
784
785 /* Name : insert_fed_tax_row
786 Purpose : To create the federal tax rule record. It also calls the
787 maintain_wc_ele_entry routine to create the worker's compensation
788 for the SUI state
789 */
790
791 procedure insert_fed_tax_row ( p_emp_fed_tax_rule_id in out nocopy number,
792 p_effective_start_date in date,
793 p_effective_end_date in date,
794 p_assignment_id in number,
795 p_sui_state_code in varchar2,
796 p_sui_jurisdiction_code in varchar2,
797 p_business_group_id in number,
798 p_additional_wa_amount in number,
799 p_filing_status_code in varchar2,
800 p_fit_override_amount in number,
801 p_fit_override_rate in number,
802 p_withholding_allowances in number,
803 p_cumulative_taxation in varchar2,
804 p_eic_filing_status_code in varchar2,
805 p_fit_additional_tax in number,
806 p_fit_exempt in varchar2,
807 p_futa_tax_exempt in varchar2,
808 p_medicare_tax_exempt in varchar2,
809 p_ss_tax_exempt in varchar2,
810 p_wage_exempt in varchar2,
811 p_statutory_employee in varchar2,
812 p_w2_filed_year in number,
813 p_supp_tax_override_rate in number,
814 p_excessive_wa_reject_date in date,
815 p_attribute_category in varchar2,
816 p_attribute1 in varchar2,
817 p_attribute2 in varchar2,
818 p_attribute3 in varchar2,
819 p_attribute4 in varchar2,
820 p_attribute5 in varchar2,
821 p_attribute6 in varchar2,
822 p_attribute7 in varchar2,
823 p_attribute8 in varchar2,
824 p_attribute9 in varchar2,
825 p_attribute10 in varchar2,
826 p_attribute11 in varchar2,
827 p_attribute12 in varchar2,
828 p_attribute13 in varchar2,
829 p_attribute14 in varchar2,
830 p_attribute15 in varchar2,
831 p_attribute16 in varchar2,
832 p_attribute17 in varchar2,
833 p_attribute18 in varchar2,
834 p_attribute19 in varchar2,
835 p_attribute20 in varchar2,
836 p_attribute21 in varchar2,
837 p_attribute22 in varchar2,
838 p_attribute23 in varchar2,
839 p_attribute24 in varchar2,
840 p_attribute25 in varchar2,
841 p_attribute26 in varchar2,
842 p_attribute27 in varchar2,
843 p_attribute28 in varchar2,
844 p_attribute29 in varchar2,
845 p_attribute30 in varchar2,
846 p_fed_information_category in varchar2,
847 p_fed_information1 in varchar2,
848 p_fed_information2 in varchar2,
849 p_fed_information3 in varchar2,
850 p_fed_information4 in varchar2,
851 p_fed_information5 in varchar2,
852 p_fed_information6 in varchar2,
853 p_fed_information7 in varchar2,
854 p_fed_information8 in varchar2,
855 p_fed_information9 in varchar2,
856 p_fed_information10 in varchar2,
857 p_fed_information11 in varchar2,
858 p_fed_information12 in varchar2,
859 p_fed_information13 in varchar2,
860 p_fed_information14 in varchar2,
861 p_fed_information15 in varchar2,
862 p_fed_information16 in varchar2,
863 p_fed_information17 in varchar2,
864 p_fed_information18 in varchar2,
865 p_fed_information19 in varchar2,
866 p_fed_information20 in varchar2,
867 p_fed_information21 in varchar2,
868 p_fed_information22 in varchar2,
869 p_fed_information23 in varchar2,
870 p_fed_information24 in varchar2,
871 p_fed_information25 in varchar2,
872 p_fed_information26 in varchar2,
873 p_fed_information27 in varchar2,
874 p_fed_information28 in varchar2,
875 p_fed_information29 in varchar2,
876 p_fed_information30 in varchar2,
877 p_mode in varchar2) is
878
879
880 l_step number;
881 l_pos number;
882
883 l_new_date date;
884 cursor csr_fed_tax_rule_id is
885 select PAY_US_EMP_FED_TAX_RULES_S.nextval
886 from sys.DUAL;
887
888 begin
889
890
891 hr_utility.set_location('pay_us_emp_dt_tax_rules.insert_fed_tax_row'||
892 ' - Opening cursor', 1);
893
894 if p_mode = 'INSERT' then
895
896 open csr_fed_tax_rule_id;
897
898 hr_utility.set_location('pay_us_emp_dt_tax_rules.insert_fed_tax_row'||
899 ' - Fetching cursor', 2);
900
901 fetch csr_fed_tax_rule_id into p_emp_fed_tax_rule_id;
902
903 hr_utility.set_location('pay_us_emp_dt_tax_rules.insert_fed_tax_row'||
904 ' - Closing cursor', 3);
905
906 close csr_fed_tax_rule_id;
907
908
909 hr_utility.set_location('pay_us_emp_dt_tax_rules.insert_fed_tax_row'||
910 ' - inserting row', 4);
911
912 end if;
913
914 l_step := 1;
915
916 if p_mode = 'UPDATE' then
917
918 select p_effective_start_date -1
919 into l_new_date
920 from DUAL;
921
922 /* Update the Federal tax record as of the p_effective_start_date */
923
924 l_step := 2;
925
926 update PAY_US_EMP_FED_TAX_RULES_F
927 set effective_end_date = l_new_date
928 where assignment_id = p_assignment_id
929 and effective_end_date = p_effective_end_date;
930
931 end if;
932
933 l_step := 3;
934
935 insert into PAY_US_EMP_FED_TAX_RULES_F
936 (emp_fed_tax_rule_id,
937 effective_start_date,
938 effective_end_date,
939 assignment_id,
940 sui_state_code,
941 sui_jurisdiction_code,
942 business_group_id,
943 additional_wa_amount,
944 filing_status_code,
945 fit_override_amount,
946 fit_override_rate,
947 withholding_allowances,
948 cumulative_taxation,
949 eic_filing_status_code,
950 fit_additional_tax,
951 fit_exempt,
952 futa_tax_exempt,
953 medicare_tax_exempt,
954 ss_tax_exempt,
955 wage_exempt,
956 statutory_employee,
957 w2_filed_year,
958 supp_tax_override_rate,
959 excessive_wa_reject_date,
960 object_version_number,
961 attribute_category,
962 attribute1,
963 attribute2,
964 attribute3,
965 attribute4,
966 attribute5,
967 attribute6,
968 attribute7,
969 attribute8,
970 attribute9,
971 attribute10,
972 attribute11,
973 attribute12,
974 attribute13,
975 attribute14,
976 attribute15,
977 attribute16,
978 attribute17,
979 attribute18,
980 attribute19,
981 attribute20,
982 attribute21,
983 attribute22,
984 attribute23,
985 attribute24,
986 attribute25,
987 attribute26,
988 attribute27,
989 attribute28,
990 attribute29,
991 attribute30,
992 fed_information_category,
993 fed_information1,
994 fed_information2,
995 fed_information3,
996 fed_information4,
997 fed_information5,
998 fed_information6,
999 fed_information7,
1000 fed_information8,
1001 fed_information9,
1002 fed_information10,
1003 fed_information11,
1004 fed_information12,
1005 fed_information13,
1006 fed_information14,
1007 fed_information15,
1008 fed_information16,
1009 fed_information17,
1010 fed_information18,
1011 fed_information19,
1012 fed_information20,
1013 fed_information21,
1014 fed_information22,
1015 fed_information23,
1016 fed_information24,
1017 fed_information25,
1018 fed_information26,
1019 fed_information27,
1020 fed_information28,
1021 fed_information29,
1022 fed_information30)
1023 values
1024 (p_emp_fed_tax_rule_id,
1025 p_effective_start_date,
1026 p_effective_end_date,
1027 p_assignment_id,
1028 p_sui_state_code,
1029 p_sui_jurisdiction_code,
1030 p_business_group_id,
1031 p_additional_wa_amount,
1032 lpad(p_filing_status_code,2,'0'),
1033 p_fit_override_amount,
1034 p_fit_override_rate,
1035 p_withholding_allowances,
1036 p_cumulative_taxation,
1037 p_eic_filing_status_code,
1038 p_fit_additional_tax,
1039 p_fit_exempt,
1040 p_futa_tax_exempt,
1041 p_medicare_tax_exempt,
1042 p_ss_tax_exempt,
1043 p_wage_exempt,
1044 p_statutory_employee,
1045 p_w2_filed_year,
1046 p_supp_tax_override_rate,
1047 p_excessive_wa_reject_date,
1048 0,
1049 p_attribute_category,
1050 p_attribute1,
1051 p_attribute2,
1052 p_attribute3,
1053 p_attribute4,
1054 p_attribute5,
1055 p_attribute6,
1056 p_attribute7,
1057 p_attribute8,
1058 p_attribute9,
1059 p_attribute10,
1060 p_attribute11,
1061 p_attribute12,
1062 p_attribute13,
1063 p_attribute14,
1064 p_attribute15,
1065 p_attribute16,
1066 p_attribute17,
1067 p_attribute18,
1068 p_attribute19,
1069 p_attribute20,
1070 p_attribute21,
1071 p_attribute22,
1072 p_attribute23,
1073 p_attribute24,
1074 p_attribute25,
1075 p_attribute26,
1076 p_attribute27,
1077 p_attribute28,
1078 p_attribute29,
1079 p_attribute30,
1080 p_fed_information_category,
1081 p_fed_information1,
1082 p_fed_information2,
1083 p_fed_information3,
1084 p_fed_information4,
1085 p_fed_information5,
1086 p_fed_information6,
1087 p_fed_information7,
1088 p_fed_information8,
1089 p_fed_information9,
1090 p_fed_information10,
1091 p_fed_information11,
1092 p_fed_information12,
1093 p_fed_information13,
1094 p_fed_information14,
1095 p_fed_information15,
1096 p_fed_information16,
1097 p_fed_information17,
1098 p_fed_information18,
1099 p_fed_information19,
1100 p_fed_information20,
1101 p_fed_information21,
1102 p_fed_information22,
1103 p_fed_information23,
1104 p_fed_information24,
1105 p_fed_information25,
1106 p_fed_information26,
1107 p_fed_information27,
1108 p_fed_information28,
1109 p_fed_information29,
1110 p_fed_information30);
1111
1112
1113 /* create workers compensation element entry for the sui state in
1114 the federal record */
1115
1116 hr_utility.set_location('pay_us_emp_dt_tax_rules.insert_fed_tax_row'||
1117 ' - inserting row', 5);
1118 l_step := 4;
1119
1120 if hr_utility.chk_product_install(p_product =>'Oracle Payroll',
1121 p_legislation => 'US') then
1122
1123 maintain_wc_ele_entry (p_assignment_id => p_assignment_id,
1124 p_effective_start_date => p_effective_start_date,
1125 p_effective_end_date => p_effective_end_date,
1126 p_session_date => p_effective_start_date,
1127 p_jurisdiction_code => p_sui_jurisdiction_code,
1128 p_mode => p_mode);
1129 end if;
1130
1131 exception
1132 when others then
1133 l_pos := instr(substr(sqlerrm,1,60),'HR_7713_TAX_ELEMENT_ERROR');
1134
1135 if l_pos = 0 then
1136 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
1137 fnd_message.set_token('PROCEDURE',
1138 'pay_us_emp_dt_tax_rules.insert_fed_tax_row - '|| substr(sqlerrm,1,60));
1139 fnd_message.set_token('STEP',to_char(l_step));
1140 fnd_message.raise_error;
1141
1142 else
1143 fnd_message.set_name('PAY', 'HR_7713_TAX_ELEMENT_ERROR');
1144 fnd_message.raise_error;
1145 end if;
1146 end insert_fed_tax_row;
1147
1148
1149 /* Name : insert_state_tax_row
1150 Purpose : To create the state tax rule record. It also calls the
1151 create_tax_percentage routine to create the %age records
1152 for the state, for every change in location of the assignment
1153 */
1154
1155 procedure insert_state_tax_row ( p_row_id in out nocopy varchar2,
1156 p_emp_state_tax_rule_id in out nocopy number,
1157 p_effective_start_date in date,
1158 p_effective_end_date in date,
1159 p_assignment_id in number,
1160 p_state_code in varchar2,
1161 p_jurisdiction_code in varchar2,
1162 p_business_group_id in number,
1163 p_additional_wa_amount in number,
1164 p_filing_status_code in varchar2,
1165 p_remainder_percent in number,
1166 p_secondary_wa in number,
1167 p_sit_additional_tax in number,
1168 p_sit_override_amount in number,
1169 p_sit_override_rate in number,
1170 p_withholding_allowances in number,
1171 p_excessive_wa_reject_date in date,
1172 p_sdi_exempt in varchar2,
1173 p_sit_exempt in varchar2,
1174 p_sit_optional_calc_ind in varchar2,
1175 p_state_non_resident_cert in varchar2,
1176 p_sui_exempt in varchar2,
1177 p_wc_exempt in varchar2,
1178 p_wage_exempt in varchar2,
1179 p_sui_wage_base_override_amt in number,
1180 p_supp_tax_override_rate in number,
1181 p_time_in_state in number,
1182 p_attribute_category in varchar2,
1183 p_attribute1 in varchar2,
1184 p_attribute2 in varchar2,
1185 p_attribute3 in varchar2,
1186 p_attribute4 in varchar2,
1187 p_attribute5 in varchar2,
1188 p_attribute6 in varchar2,
1189 p_attribute7 in varchar2,
1190 p_attribute8 in varchar2,
1191 p_attribute9 in varchar2,
1192 p_attribute10 in varchar2,
1193 p_attribute11 in varchar2,
1194 p_attribute12 in varchar2,
1195 p_attribute13 in varchar2,
1196 p_attribute14 in varchar2,
1197 p_attribute15 in varchar2,
1198 p_attribute16 in varchar2,
1199 p_attribute17 in varchar2,
1200 p_attribute18 in varchar2,
1201 p_attribute19 in varchar2,
1202 p_attribute20 in varchar2,
1203 p_attribute21 in varchar2,
1204 p_attribute22 in varchar2,
1205 p_attribute23 in varchar2,
1206 p_attribute24 in varchar2,
1207 p_attribute25 in varchar2,
1208 p_attribute26 in varchar2,
1209 p_attribute27 in varchar2,
1210 p_attribute28 in varchar2,
1211 p_attribute29 in varchar2,
1212 p_attribute30 in varchar2,
1213 p_sta_information_category in varchar2,
1214 p_sta_information1 in varchar2,
1215 p_sta_information2 in varchar2,
1216 p_sta_information3 in varchar2,
1217 p_sta_information4 in varchar2,
1218 p_sta_information5 in varchar2,
1219 p_sta_information6 in varchar2,
1220 p_sta_information7 in varchar2,
1221 p_sta_information8 in varchar2,
1222 p_sta_information9 in varchar2,
1223 p_sta_information10 in varchar2,
1224 p_sta_information11 in varchar2,
1225 p_sta_information12 in varchar2,
1226 p_sta_information13 in varchar2,
1227 p_sta_information14 in varchar2,
1228 p_sta_information15 in varchar2,
1229 p_sta_information16 in varchar2,
1230 p_sta_information17 in varchar2,
1231 p_sta_information18 in varchar2,
1232 p_sta_information19 in varchar2,
1233 p_sta_information20 in varchar2,
1234 p_sta_information21 in varchar2,
1235 p_sta_information22 in varchar2,
1236 p_sta_information23 in varchar2,
1237 p_sta_information24 in varchar2,
1238 p_sta_information25 in varchar2,
1239 p_sta_information26 in varchar2,
1240 p_sta_information27 in varchar2,
1241 p_sta_information28 in varchar2,
1242 p_sta_information29 in varchar2,
1243 p_sta_information30 in varchar2
1244 ) is
1245
1246 cursor csr_state_tax_rule_id is
1247 select PAY_US_EMP_STATE_TAX_RULES_S.nextval
1248 from sys.DUAL;
1249
1250 cursor csr_get_row_id is
1251 select rowidtochar(rowid)
1252 from PAY_US_EMP_STATE_TAX_RULES_F str
1253 where str.emp_state_tax_rule_id = p_emp_state_tax_rule_id
1254 and str.effective_start_date = p_effective_start_date
1255 and str.effective_end_date = p_effective_end_date;
1256
1257 -- Added for bug 13872151
1258 cursor csr_state_tax_rule is
1259 select null
1260 from pay_us_emp_state_tax_rules_f sta
1261 where sta.assignment_id = p_assignment_id
1262 and sta.state_code = p_state_code;
1263
1264 l_dummy VARCHAR2(5);
1265 --End of changes for bug 13872151
1266
1267 begin
1268
1269
1270 hr_utility.set_location('pay_us_emp_dt_tax_rules.ins_st_tax_row'||
1271 ' - Opening cursor', 1);
1272
1273 open csr_state_tax_rule_id;
1274
1275 hr_utility.set_location('pay_us_emp_dt_tax_rules.ins_st_tax_row'||
1276 ' - Fetching cursor', 2);
1277
1278 fetch csr_state_tax_rule_id into p_emp_state_tax_rule_id;
1279
1280 hr_utility.set_location('pay_us_emp_dt_tax_rules.ins_st_tax_row'||
1281 ' - Closing cursor', 3);
1282
1283 close csr_state_tax_rule_id;
1284
1285
1286 hr_utility.set_location('pay_us_emp_dt_tax_rules.ins_st_tax_row'||
1287 ' - inserting row', 4);
1288
1289 --Bug 13872151 :Check if the State Tax rule already exists
1290 open csr_state_tax_rule;
1291 fetch csr_state_tax_rule into l_dummy;
1292 if csr_state_tax_rule%FOUND then
1293 close csr_state_tax_rule;
1294 --
1295 -- This state tax rule already exists
1296 --
1297 hr_utility.set_message(801, 'HR_7719_TAX_ONE_RULE_ONLY');
1298 hr_utility.raise_error;
1299 end if;
1300 close csr_state_tax_rule;
1301 --End of changes for bug 13872151
1302
1303 insert into PAY_US_EMP_STATE_TAX_RULES_F
1304 (emp_state_tax_rule_id,
1305 effective_start_date,
1306 effective_end_date,
1307 assignment_id,
1308 state_code,
1309 jurisdiction_code,
1310 business_group_id,
1311 additional_wa_amount,
1312 filing_status_code,
1313 remainder_percent,
1314 secondary_wa,
1315 sit_additional_tax,
1316 sit_override_amount,
1317 sit_override_rate,
1318 withholding_allowances,
1319 excessive_wa_reject_date,
1320 sdi_exempt,
1321 sit_exempt,
1322 sit_optional_calc_ind,
1323 state_non_resident_cert,
1324 sui_exempt,
1325 wc_exempt,
1326 wage_exempt,
1327 sui_wage_base_override_amount,
1328 supp_tax_override_rate,
1329 object_version_number,
1330 attribute_category,
1331 attribute1,
1332 attribute2,
1333 attribute3,
1334 attribute4,
1335 attribute5,
1336 attribute6,
1337 attribute7,
1338 attribute8,
1339 attribute9,
1340 attribute10,
1341 attribute11,
1342 attribute12,
1343 attribute13,
1344 attribute14,
1345 attribute15,
1346 attribute16,
1347 attribute17,
1348 attribute18,
1349 attribute19,
1350 attribute20,
1351 attribute21,
1352 attribute22,
1353 attribute23,
1354 attribute24,
1355 attribute25,
1356 attribute26,
1357 attribute27,
1358 attribute28,
1359 attribute29,
1360 attribute30,
1361 sta_information_category,
1362 sta_information1,
1363 sta_information2,
1364 sta_information3,
1365 sta_information4,
1366 sta_information5,
1367 sta_information6,
1368 sta_information7,
1369 sta_information8,
1370 sta_information9,
1371 sta_information10,
1372 sta_information11,
1373 sta_information12,
1374 sta_information13,
1375 sta_information14,
1376 sta_information15,
1377 sta_information16,
1378 sta_information17,
1379 sta_information18,
1380 sta_information19,
1381 sta_information20,
1382 sta_information21,
1383 sta_information22,
1384 sta_information23,
1385 sta_information24,
1386 sta_information25,
1387 sta_information26,
1388 sta_information27,
1389 sta_information28,
1390 sta_information29,
1391 sta_information30)
1392 values
1393 (p_emp_state_tax_rule_id,
1394 p_effective_start_date,
1395 p_effective_end_date,
1396 p_assignment_id,
1397 p_state_code,
1398 p_jurisdiction_code,
1399 p_business_group_id,
1400 p_additional_wa_amount,
1401 lpad(p_filing_status_code,2,'0'),
1402 p_remainder_percent,
1403 p_secondary_wa,
1404 p_sit_additional_tax,
1405 p_sit_override_amount,
1406 p_sit_override_rate,
1407 p_withholding_allowances,
1408 p_excessive_wa_reject_date,
1409 p_sdi_exempt,
1410 p_sit_exempt,
1411 p_sit_optional_calc_ind,
1412 p_state_non_resident_cert,
1413 p_sui_exempt,
1414 p_wc_exempt,
1415 p_wage_exempt,
1416 p_sui_wage_base_override_amt,
1417 p_supp_tax_override_rate,
1418 0,
1419 p_attribute_category,
1420 p_attribute1,
1421 p_attribute2,
1422 p_attribute3,
1423 p_attribute4,
1424 p_attribute5,
1425 p_attribute6,
1426 p_attribute7,
1427 p_attribute8,
1428 p_attribute9,
1429 p_attribute10,
1430 p_attribute11,
1431 p_attribute12,
1432 p_attribute13,
1433 p_attribute14,
1434 p_attribute15,
1435 p_attribute16,
1436 p_attribute17,
1437 p_attribute18,
1438 p_attribute19,
1439 p_attribute20,
1440 p_attribute21,
1441 p_attribute22,
1442 p_attribute23,
1443 p_attribute24,
1444 p_attribute25,
1445 p_attribute26,
1446 p_attribute27,
1447 p_attribute28,
1448 p_attribute29,
1449 p_attribute30,
1450 p_sta_information_category,
1451 p_sta_information1,
1452 p_sta_information2,
1453 p_sta_information3,
1454 p_sta_information4,
1455 p_sta_information5,
1456 p_sta_information6,
1457 p_sta_information7,
1458 p_sta_information8,
1459 p_sta_information9,
1460 p_sta_information10,
1461 p_sta_information11,
1462 p_sta_information12,
1463 p_sta_information13,
1464 p_sta_information14,
1465 p_sta_information15,
1466 p_sta_information16,
1467 p_sta_information17,
1468 p_sta_information18,
1469 p_sta_information19,
1470 p_sta_information20,
1471 p_sta_information21,
1472 p_sta_information22,
1473 p_sta_information23,
1474 p_sta_information24,
1475 p_sta_information25,
1476 p_sta_information26,
1477 p_sta_information27,
1478 p_sta_information28,
1479 p_sta_information29,
1480 p_sta_information30);
1481
1482 if sql%notfound then
1483 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
1484 fnd_message.set_token('PROCEDURE',
1485 'pay_us_emp_dt_tax_rules.insert_state_tax_row');
1486 fnd_message.set_token('STEP','4');
1487 fnd_message.raise_error;
1488 end if;
1489
1490 open csr_get_row_id;
1491
1492 fetch csr_get_row_id into p_row_id;
1493
1494 if csr_get_row_id%NOTFOUND then
1495 close csr_get_row_id;
1496 raise no_data_found;
1497 end if;
1498
1499 close csr_get_row_id;
1500
1501 hr_utility.set_location('pay_us_emp_dt_tax_rules.ins_st_tax_row'||
1502 ' - creating %age record ', 5);
1503
1504 /* Get the changes in location of an assignment.
1505 For each change in location, create vertex element entry with
1506 time in state as 0% - if Payroll is installed */
1507
1508 if hr_utility.chk_product_install(p_product =>'Oracle Payroll',
1509 p_legislation => 'US') then
1510
1511 create_tax_percentage (p_assignment_id => p_assignment_id,
1512 p_state_code => p_state_code,
1513 p_county_code => null,
1514 p_city_code => null,
1515 p_time_in_state => nvl(p_time_in_state,0),
1516 p_time_in_county => 0,
1517 p_time_in_city => 0);
1518
1519 /* Insert row into the pay_us_asg_reporting table */
1520
1521 pay_asg_geo_pkg.create_asg_geo_row(P_assignment_id => p_assignment_id,
1522 P_jurisdiction => p_jurisdiction_code,
1523 P_tax_unit_id => NULL );
1524 end if;
1525
1526 end insert_state_tax_row;
1527
1528
1529 /* Name : insert_county_tax_row
1530 Purpose : To create the county tax rule record. It also calls the
1531 create_tax_percentage routine to create the %age records
1532 for the county, for every change in location of the assignment
1533 */
1534 procedure insert_county_tax_row ( p_row_id in out nocopy varchar2,
1535 p_emp_county_tax_rule_id in out nocopy number,
1536 p_effective_start_date in date,
1537 p_effective_end_date in date,
1538 p_assignment_id in number,
1539 p_state_code in varchar2,
1540 p_county_code in varchar2,
1541 p_business_group_id in number,
1542 p_additional_wa_rate in number,
1543 p_filing_status_code in varchar2,
1544 p_jurisdiction_code in varchar2,
1545 p_lit_additional_tax in number,
1546 p_lit_override_amount in number,
1547 p_lit_override_rate in number,
1548 p_withholding_allowances in number,
1549 p_lit_exempt in varchar2,
1550 p_sd_exempt in varchar2,
1551 p_ht_exempt in varchar2,
1552 p_wage_exempt in varchar2,
1553 p_school_district_code in varchar2,
1554 p_time_in_county in number,
1555 p_attribute_category in varchar2,
1556 p_attribute1 in varchar2,
1557 p_attribute2 in varchar2,
1558 p_attribute3 in varchar2,
1559 p_attribute4 in varchar2,
1560 p_attribute5 in varchar2,
1561 p_attribute6 in varchar2,
1562 p_attribute7 in varchar2,
1563 p_attribute8 in varchar2,
1564 p_attribute9 in varchar2,
1565 p_attribute10 in varchar2,
1566 p_attribute11 in varchar2,
1567 p_attribute12 in varchar2,
1568 p_attribute13 in varchar2,
1569 p_attribute14 in varchar2,
1570 p_attribute15 in varchar2,
1571 p_attribute16 in varchar2,
1572 p_attribute17 in varchar2,
1573 p_attribute18 in varchar2,
1574 p_attribute19 in varchar2,
1575 p_attribute20 in varchar2,
1576 p_attribute21 in varchar2,
1577 p_attribute22 in varchar2,
1578 p_attribute23 in varchar2,
1579 p_attribute24 in varchar2,
1580 p_attribute25 in varchar2,
1581 p_attribute26 in varchar2,
1582 p_attribute27 in varchar2,
1583 p_attribute28 in varchar2,
1584 p_attribute29 in varchar2,
1585 p_attribute30 in varchar2,
1586 p_cnt_information_category in varchar2,
1587 p_cnt_information1 in varchar2,
1588 p_cnt_information2 in varchar2,
1589 p_cnt_information3 in varchar2,
1590 p_cnt_information4 in varchar2,
1591 p_cnt_information5 in varchar2,
1592 p_cnt_information6 in varchar2,
1593 p_cnt_information7 in varchar2,
1594 p_cnt_information8 in varchar2,
1595 p_cnt_information9 in varchar2,
1596 p_cnt_information10 in varchar2,
1597 p_cnt_information11 in varchar2,
1598 p_cnt_information12 in varchar2,
1599 p_cnt_information13 in varchar2,
1600 p_cnt_information14 in varchar2,
1601 p_cnt_information15 in varchar2,
1602 p_cnt_information16 in varchar2,
1603 p_cnt_information17 in varchar2,
1604 p_cnt_information18 in varchar2,
1605 p_cnt_information19 in varchar2,
1606 p_cnt_information20 in varchar2,
1607 p_cnt_information21 in varchar2,
1608 p_cnt_information22 in varchar2,
1609 p_cnt_information23 in varchar2,
1610 p_cnt_information24 in varchar2,
1611 p_cnt_information25 in varchar2,
1612 p_cnt_information26 in varchar2,
1613 p_cnt_information27 in varchar2,
1614 p_cnt_information28 in varchar2,
1615 p_cnt_information29 in varchar2,
1616 p_cnt_information30 in varchar2) is
1617
1618 cursor csr_county_tax_rule_id is
1619 select PAY_US_EMP_COUNTY_TAX_RULES_S.nextval
1620 from sys.DUAL;
1621
1622 cursor csr_get_row_id is
1623 select rowidtochar(rowid)
1624 from PAY_US_EMP_COUNTY_TAX_RULES_F ctr
1625 where ctr.emp_county_tax_rule_id = p_emp_county_tax_rule_id
1626 and ctr.effective_start_date = p_effective_start_date
1627 and ctr.effective_end_date = p_effective_end_date;
1628
1629 /** added for bug 13872151**/
1630 cursor csr_county_tax_rule is
1631 select null
1632 from pay_us_emp_county_tax_rules_f sta
1633 where sta.assignment_id = p_assignment_id
1634 and sta.state_code = p_state_code
1635 and sta.county_code= p_county_code;
1636
1637 l_dummy varchar2(5);
1638 --End of changes for bug 13872151
1639
1640 begin
1641
1642 if p_school_district_code is not null
1643 then
1644
1645 /* Check that the school district is assigned to only one county/city
1646 at a given point in time */
1647
1648 pay_us_emp_dt_tax_val.check_school_district(
1649 p_assignment => p_assignment_id,
1650 p_start_date => p_effective_start_date,
1651 p_end_date => p_effective_end_date,
1652 p_mode => 'I',
1653 p_rowid => null);
1654 end if;
1655
1656 hr_utility.set_location('pay_us_emp_dt_tax_rules.insert_county_tax_row'||
1657 ' - Opening cursor', 1);
1658
1659 open csr_county_tax_rule_id;
1660
1661 hr_utility.set_location('pay_us_emp_dt_tax_rules.insert_county_tax_row'||
1662 ' - Fetching cursor', 2);
1663
1664 fetch csr_county_tax_rule_id into p_emp_county_tax_rule_id;
1665
1666 hr_utility.set_location('pay_us_emp_dt_tax_rules.insert_county_tax_row'||
1667 ' - Closing cursor', 3);
1668
1669 close csr_county_tax_rule_id;
1670
1671
1672 hr_utility.set_location('pay_us_emp_dt_tax_rules.insert_county_tax_row'||
1673 ' - inserting row', 4);
1674
1675 /** added for bug 13872151 - Check if the same state and county combination rule already exists**/
1676 open csr_county_tax_rule;
1677 fetch csr_county_tax_rule into l_dummy;
1678 if csr_county_tax_rule%FOUND then
1679 close csr_county_tax_rule;
1680 --
1681 -- This county tax rule already exists
1682 --
1683 hr_utility.set_message(801, 'PAY_75275_COUNTY_TAX_ONE_RULE');
1684 hr_utility.raise_error;
1685 end if;
1686 close csr_county_tax_rule;
1687 --End of changes for bug 13872151
1688
1689 insert into pay_us_emp_county_tax_rules_f
1690 (emp_county_tax_rule_id,
1691 effective_start_date,
1692 effective_end_date,
1693 assignment_id,
1694 state_code,
1695 county_code,
1696 business_group_id,
1697 additional_wa_rate,
1698 filing_status_code,
1699 jurisdiction_code,
1700 lit_additional_tax,
1701 lit_override_amount,
1702 lit_override_rate,
1703 withholding_allowances,
1704 lit_exempt,
1705 sd_exempt,
1706 ht_exempt,
1707 wage_exempt,
1708 school_district_code,
1709 object_version_number,
1710 attribute_category,
1711 attribute1,
1712 attribute2,
1713 attribute3,
1714 attribute4,
1715 attribute5,
1716 attribute6,
1717 attribute7,
1718 attribute8,
1719 attribute9,
1720 attribute10,
1721 attribute11,
1722 attribute12,
1723 attribute13,
1724 attribute14,
1725 attribute15,
1726 attribute16,
1727 attribute17,
1728 attribute18,
1729 attribute19,
1730 attribute20,
1731 attribute21,
1732 attribute22,
1733 attribute23,
1734 attribute24,
1735 attribute25,
1736 attribute26,
1737 attribute27,
1738 attribute28,
1739 attribute29,
1740 attribute30,
1741 cnt_information_category,
1742 cnt_information1,
1743 cnt_information2,
1744 cnt_information3,
1745 cnt_information4,
1746 cnt_information5,
1747 cnt_information6,
1748 cnt_information7,
1749 cnt_information8,
1750 cnt_information9,
1751 cnt_information10,
1752 cnt_information11,
1753 cnt_information12,
1754 cnt_information13,
1755 cnt_information14,
1756 cnt_information15,
1757 cnt_information16,
1758 cnt_information17,
1759 cnt_information18,
1760 cnt_information19,
1761 cnt_information20,
1762 cnt_information21,
1763 cnt_information22,
1764 cnt_information23,
1765 cnt_information24,
1766 cnt_information25,
1767 cnt_information26,
1768 cnt_information27,
1769 cnt_information28,
1770 cnt_information29,
1771 cnt_information30)
1772 values
1773 (p_emp_county_tax_rule_id,
1774 p_effective_start_date,
1775 p_effective_end_date,
1776 p_assignment_id,
1777 p_state_code,
1778 p_county_code,
1779 p_business_group_id,
1780 p_additional_wa_rate,
1781 lpad(p_filing_status_code,2,'0'),
1782 p_jurisdiction_code,
1783 p_lit_additional_tax,
1784 p_lit_override_amount,
1785 p_lit_override_rate,
1786 p_withholding_allowances,
1787 p_lit_exempt,
1788 p_sd_exempt,
1789 p_ht_exempt,
1790 p_wage_exempt,
1791 p_school_district_code,
1792 0,
1793 p_attribute_category,
1794 p_attribute1,
1795 p_attribute2,
1796 p_attribute3,
1797 p_attribute4,
1798 p_attribute5,
1799 p_attribute6,
1800 p_attribute7,
1801 p_attribute8,
1802 p_attribute9,
1803 p_attribute10,
1804 p_attribute11,
1805 p_attribute12,
1806 p_attribute13,
1807 p_attribute14,
1808 p_attribute15,
1809 p_attribute16,
1810 p_attribute17,
1811 p_attribute18,
1812 p_attribute19,
1813 p_attribute20,
1814 p_attribute21,
1815 p_attribute22,
1816 p_attribute23,
1817 p_attribute24,
1818 p_attribute25,
1819 p_attribute26,
1820 p_attribute27,
1821 p_attribute28,
1822 p_attribute29,
1823 p_attribute30,
1824 p_cnt_information_category,
1825 p_cnt_information1,
1826 p_cnt_information2,
1827 p_cnt_information3,
1828 p_cnt_information4,
1829 p_cnt_information5,
1830 p_cnt_information6,
1831 p_cnt_information7,
1832 p_cnt_information8,
1833 p_cnt_information9,
1834 p_cnt_information10,
1835 p_cnt_information11,
1836 p_cnt_information12,
1837 p_cnt_information13,
1838 p_cnt_information14,
1839 p_cnt_information15,
1840 p_cnt_information16,
1841 p_cnt_information17,
1842 p_cnt_information18,
1843 p_cnt_information19,
1844 p_cnt_information20,
1845 p_cnt_information21,
1846 p_cnt_information22,
1847 p_cnt_information23,
1848 p_cnt_information24,
1849 p_cnt_information25,
1850 p_cnt_information26,
1851 p_cnt_information27,
1852 p_cnt_information28,
1853 p_cnt_information29,
1854 p_cnt_information30);
1855
1856 if sql%notfound then
1857 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
1858 fnd_message.set_token('PROCEDURE',
1859 'pay_us_emp_dt_tax_rules.insert_county_tax_row');
1860 fnd_message.set_token('STEP','4');
1861 fnd_message.raise_error;
1862 end if;
1863
1864 open csr_get_row_id;
1865
1866 fetch csr_get_row_id into p_row_id;
1867
1868 if csr_get_row_id%NOTFOUND then
1869 close csr_get_row_id;
1870 raise no_data_found;
1871 end if;
1872
1873 close csr_get_row_id;
1874
1875 hr_utility.set_location('pay_us_emp_dt_tax_rules.insert_county_tax_row'||
1876 ' - creating %age record ', 5);
1877
1878 /* Get the changes in location of an assignment.
1879 For each change in location, create vertex element entry with
1880 time in county as 0% */
1881
1882 if hr_utility.chk_product_install(p_product =>'Oracle Payroll',
1883 p_legislation => 'US') then
1884
1885 create_tax_percentage (p_assignment_id => p_assignment_id,
1886 p_state_code => p_state_code,
1887 p_county_code => p_county_code,
1888 p_city_code => null,
1889 p_time_in_state => 0,
1890 p_time_in_county => nvl(p_time_in_county,0),
1891 p_time_in_city => 0);
1892
1893 /* Insert row into the pay_us_asg_reporting table */
1894
1895 pay_asg_geo_pkg.create_asg_geo_row(P_assignment_id => p_assignment_id,
1896 P_jurisdiction => p_jurisdiction_code,
1897 P_tax_unit_id => NULL );
1898
1899 if p_school_district_code is not null then
1900 pay_asg_geo_pkg.create_asg_geo_row(P_assignment_id => p_assignment_id,
1901 P_jurisdiction => p_state_code || '-'|| p_school_district_code,
1902 P_tax_unit_id => NULL );
1903 end if;
1904
1905 end if;
1906
1907 end insert_county_tax_row;
1908
1909
1910 /* Name : insert_city_tax_row
1911 Purpose : To create the city tax rule record. It also calls the
1912 create_tax_percentage routine to create the %age records
1913 for the city, for every change in location of the assignment
1914 */
1915
1916 procedure insert_city_tax_row ( p_row_id in out nocopy varchar2,
1917 p_emp_city_tax_rule_id in out nocopy number,
1918 p_effective_start_date in date,
1919 p_effective_end_date in date,
1920 p_assignment_id in number,
1921 p_state_code in varchar2,
1922 p_county_code in varchar2,
1923 p_city_code in varchar2,
1924 p_business_group_id in number,
1925 p_additional_wa_rate in number,
1926 p_filing_status_code in varchar2,
1927 p_jurisdiction_code in varchar2,
1928 p_lit_additional_tax in number,
1929 p_lit_override_amount in number,
1930 p_lit_override_rate in number,
1931 p_withholding_allowances in number,
1932 p_lit_exempt in varchar2,
1933 p_sd_exempt in varchar2,
1934 p_ht_exempt in varchar2,
1935 p_wage_exempt in varchar2,
1936 p_school_district_code in varchar2,
1937 p_time_in_city in number,
1938 p_attribute_category in varchar2,
1939 p_attribute1 in varchar2,
1940 p_attribute2 in varchar2,
1941 p_attribute3 in varchar2,
1942 p_attribute4 in varchar2,
1943 p_attribute5 in varchar2,
1944 p_attribute6 in varchar2,
1945 p_attribute7 in varchar2,
1946 p_attribute8 in varchar2,
1947 p_attribute9 in varchar2,
1948 p_attribute10 in varchar2,
1949 p_attribute11 in varchar2,
1950 p_attribute12 in varchar2,
1951 p_attribute13 in varchar2,
1952 p_attribute14 in varchar2,
1953 p_attribute15 in varchar2,
1954 p_attribute16 in varchar2,
1955 p_attribute17 in varchar2,
1956 p_attribute18 in varchar2,
1957 p_attribute19 in varchar2,
1958 p_attribute20 in varchar2,
1959 p_attribute21 in varchar2,
1960 p_attribute22 in varchar2,
1961 p_attribute23 in varchar2,
1962 p_attribute24 in varchar2,
1963 p_attribute25 in varchar2,
1964 p_attribute26 in varchar2,
1965 p_attribute27 in varchar2,
1966 p_attribute28 in varchar2,
1967 p_attribute29 in varchar2,
1968 p_attribute30 in varchar2,
1969 p_cty_information_category in varchar2,
1970 p_cty_information1 in varchar2,
1971 p_cty_information2 in varchar2,
1972 p_cty_information3 in varchar2,
1973 p_cty_information4 in varchar2,
1974 p_cty_information5 in varchar2,
1975 p_cty_information6 in varchar2,
1976 p_cty_information7 in varchar2,
1977 p_cty_information8 in varchar2,
1978 p_cty_information9 in varchar2,
1979 p_cty_information10 in varchar2,
1980 p_cty_information11 in varchar2,
1981 p_cty_information12 in varchar2,
1982 p_cty_information13 in varchar2,
1983 p_cty_information14 in varchar2,
1984 p_cty_information15 in varchar2,
1985 p_cty_information16 in varchar2,
1986 p_cty_information17 in varchar2,
1987 p_cty_information18 in varchar2,
1988 p_cty_information19 in varchar2,
1989 p_cty_information20 in varchar2,
1990 p_cty_information21 in varchar2,
1991 p_cty_information22 in varchar2,
1992 p_cty_information23 in varchar2,
1993 p_cty_information24 in varchar2,
1994 p_cty_information25 in varchar2,
1995 p_cty_information26 in varchar2,
1996 p_cty_information27 in varchar2,
1997 p_cty_information28 in varchar2,
1998 p_cty_information29 in varchar2,
1999 p_cty_information30 in varchar2) is
2000
2001 cursor csr_city_tax_rule_id is
2002 select PAY_US_EMP_CITY_TAX_RULES_S.nextval
2003 from sys.DUAL;
2004
2005 cursor csr_get_row_id is
2006 select rowidtochar(rowid)
2007 from PAY_US_EMP_CITY_TAX_RULES_F ctr
2008 where ctr.emp_city_tax_rule_id = p_emp_city_tax_rule_id
2009 and ctr.effective_start_date = p_effective_start_date
2010 and ctr.effective_end_date = p_effective_end_date;
2011
2012 /** added for bug 13872151 **/
2013 cursor csr_city_tax_rule is
2014 select null
2015 from pay_us_emp_city_tax_rules_f sta
2016 where sta.assignment_id = p_assignment_id
2017 and sta.state_code = p_state_code
2018 and sta.county_code= p_county_code
2019 and sta.city_code= p_city_code;
2020
2021 l_dummy varchar2(5);
2022 -- End of changes for bug 13872151
2023
2024 begin
2025
2026 if p_school_district_code is not null
2027 and p_state_code <> '39'
2028 then
2029
2030 /* Check that the school district is assigned to only one county/city
2031 at a given point in time */
2032
2033 pay_us_emp_dt_tax_val.check_school_district(
2034 p_assignment => p_assignment_id,
2035 p_start_date => p_effective_start_date,
2036 p_end_date => p_effective_end_date,
2037 p_mode => 'I',
2038 p_rowid => null);
2039 end if;
2040
2041 hr_utility.set_location('pay_us_emp_dt_tax_rules.insert_city_tax_row'||
2042 ' - Opening cursor', 1);
2043
2044 open csr_city_tax_rule_id;
2045
2046 hr_utility.set_location('pay_us_emp_dt_tax_rules.insert_city_tax_row'||
2047 ' - Fetching cursor', 2);
2048
2049 fetch csr_city_tax_rule_id into p_emp_city_tax_rule_id;
2050
2051 hr_utility.set_location('pay_us_emp_dt_tax_rules.insert_city_tax_row'||
2052 ' - Closing cursor', 3);
2053
2054 close csr_city_tax_rule_id;
2055
2056
2057 hr_utility.set_location('pay_us_emp_dt_tax_rules.insert_city_tax_row'||
2058 ' - inserting row', 4);
2059
2060 -- Bug 13872151:Check if the same state, county and city combination tax rule already exists.
2061 open csr_city_tax_rule;
2062 fetch csr_city_tax_rule into l_dummy;
2063 if csr_city_tax_rule%FOUND then
2064 close csr_city_tax_rule;
2065 --
2066 -- This city tax rule already exists
2067 --
2068 hr_utility.set_message(801, 'PAY_75276_CITY_TAX_ONE_RULE');
2069 hr_utility.raise_error;
2070 end if;
2071 close csr_city_tax_rule;
2072 -- End of changes for bug 13872151
2073
2074 insert into PAY_US_EMP_CITY_TAX_RULES_F
2075 (emp_city_tax_rule_id,
2076 effective_start_date,
2077 effective_end_date,
2078 assignment_id,
2079 state_code,
2080 county_code,
2081 city_code,
2082 business_group_id,
2083 additional_wa_rate,
2084 filing_status_code,
2085 jurisdiction_code,
2086 lit_additional_tax,
2087 lit_override_amount,
2088 lit_override_rate,
2089 withholding_allowances,
2090 lit_exempt,
2091 sd_exempt,
2092 ht_exempt,
2093 wage_exempt,
2094 school_district_code,
2095 object_version_number,
2096 attribute_category,
2097 attribute1,
2098 attribute2,
2099 attribute3,
2100 attribute4,
2101 attribute5,
2102 attribute6,
2103 attribute7,
2104 attribute8,
2105 attribute9,
2106 attribute10,
2107 attribute11,
2108 attribute12,
2109 attribute13,
2110 attribute14,
2111 attribute15,
2112 attribute16,
2113 attribute17,
2114 attribute18,
2115 attribute19,
2116 attribute20,
2117 attribute21,
2118 attribute22,
2119 attribute23,
2120 attribute24,
2121 attribute25,
2122 attribute26,
2123 attribute27,
2124 attribute28,
2125 attribute29,
2126 attribute30,
2127 cty_information_category,
2128 cty_information1,
2129 cty_information2,
2130 cty_information3,
2131 cty_information4,
2132 cty_information5,
2133 cty_information6,
2134 cty_information7,
2135 cty_information8,
2136 cty_information9,
2137 cty_information10,
2138 cty_information11,
2139 cty_information12,
2140 cty_information13,
2141 cty_information14,
2142 cty_information15,
2143 cty_information16,
2144 cty_information17,
2145 cty_information18,
2146 cty_information19,
2147 cty_information20,
2148 cty_information21,
2149 cty_information22,
2150 cty_information23,
2151 cty_information24,
2152 cty_information25,
2153 cty_information26,
2154 cty_information27,
2155 cty_information28,
2156 cty_information29,
2157 cty_information30)
2158 values
2159 (p_emp_city_tax_rule_id,
2160 p_effective_start_date,
2161 p_effective_end_date,
2162 p_assignment_id,
2163 p_state_code,
2164 p_county_code,
2165 p_city_code,
2166 p_business_group_id,
2167 p_additional_wa_rate,
2168 lpad(p_filing_status_code,2,'0'),
2169 p_jurisdiction_code,
2170 p_lit_additional_tax,
2171 p_lit_override_amount,
2172 p_lit_override_rate,
2173 p_withholding_allowances,
2174 p_lit_exempt,
2175 p_sd_exempt,
2176 p_ht_exempt,
2177 p_wage_exempt,
2178 p_school_district_code,
2179 0,
2180 p_attribute_category,
2181 p_attribute1,
2182 p_attribute2,
2183 p_attribute3,
2184 p_attribute4,
2185 p_attribute5,
2186 p_attribute6,
2187 p_attribute7,
2188 p_attribute8,
2189 p_attribute9,
2190 p_attribute10,
2191 p_attribute11,
2192 p_attribute12,
2193 p_attribute13,
2194 p_attribute14,
2195 p_attribute15,
2196 p_attribute16,
2197 p_attribute17,
2198 p_attribute18,
2199 p_attribute19,
2200 p_attribute20,
2201 p_attribute21,
2202 p_attribute22,
2203 p_attribute23,
2204 p_attribute24,
2205 p_attribute25,
2206 p_attribute26,
2207 p_attribute27,
2208 p_attribute28,
2209 p_attribute29,
2210 p_attribute30,
2211 p_cty_information_category,
2212 p_cty_information1,
2213 p_cty_information2,
2214 p_cty_information3,
2215 p_cty_information4,
2216 p_cty_information5,
2217 p_cty_information6,
2218 p_cty_information7,
2219 p_cty_information8,
2220 p_cty_information9,
2221 p_cty_information10,
2222 p_cty_information11,
2223 p_cty_information12,
2224 p_cty_information13,
2225 p_cty_information14,
2226 p_cty_information15,
2227 p_cty_information16,
2228 p_cty_information17,
2229 p_cty_information18,
2230 p_cty_information19,
2231 p_cty_information20,
2232 p_cty_information21,
2233 p_cty_information22,
2234 p_cty_information23,
2235 p_cty_information24,
2236 p_cty_information25,
2237 p_cty_information26,
2238 p_cty_information27,
2239 p_cty_information28,
2240 p_cty_information29,
2241 p_cty_information30);
2242
2243 if sql%notfound then
2244
2245 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
2246 fnd_message.set_token('PROCEDURE',
2247 'pay_us_emp_dt_tax_rules.insert_city_tax_row');
2248 fnd_message.set_token('STEP','4');
2249 fnd_message.raise_error;
2250
2251 end if;
2252
2253 open csr_get_row_id;
2254
2255 fetch csr_get_row_id into p_row_id;
2256
2257 if csr_get_row_id%NOTFOUND then
2258 close csr_get_row_id;
2259 raise no_data_found;
2260 end if;
2261
2262 close csr_get_row_id;
2263
2264
2265 hr_utility.set_location('pay_us_emp_dt_tax_rules.insert_city_tax_row'||
2266 ' - creating %age record ', 5);
2267
2268 /* Get the changes in location of an assignment.
2269 For each change in location, create vertex element entry with
2270 time in city as 0%
2271 Note: When this procedure will be called by the default_tax routine
2272 there will be only one location for which the record will be created
2273 thus resulting in only one city tax record with 100% - makes sense??
2274 In most of the cases the defaulting routine will create tax records
2275 from begin of time till end of time */
2276
2277 if hr_utility.chk_product_install(p_product =>'Oracle Payroll',
2278 p_legislation => 'US') then
2279
2280 create_tax_percentage (p_assignment_id => p_assignment_id,
2281 p_state_code => p_state_code,
2282 p_county_code => p_county_code,
2283 p_city_code => p_city_code,
2284 p_time_in_state => 0,
2285 p_time_in_county => 0,
2286 p_time_in_city => nvl(p_time_in_city,0));
2287
2288 /* Insert row into the pay_us_asg_reporting table */
2289
2290 pay_asg_geo_pkg.create_asg_geo_row(P_assignment_id => p_assignment_id,
2291 P_jurisdiction => p_jurisdiction_code,
2292 P_tax_unit_id => NULL );
2293
2294 if p_school_district_code is not null then
2295 pay_asg_geo_pkg.create_asg_geo_row(P_assignment_id => p_assignment_id,
2296 P_jurisdiction => p_state_code || '-'|| p_school_district_code,
2297 P_tax_unit_id => NULL );
2298 end if;
2299
2300 end if;
2301
2302 end insert_city_tax_row;
2303
2304
2305 /* Name : update_fed_tax_row
2306 Purpose : To update the federal tax rule record. It also calls the
2307 maintain_wc_ele_entry routine to update the worker's compensation
2308 for the SUI state
2309 */
2310
2311 procedure update_fed_tax_row ( p_row_id in varchar2,
2312 p_emp_fed_tax_rule_id in number,
2313 p_effective_start_date in date,
2314 p_effective_end_date in date,
2315 p_assignment_id in number,
2316 p_sui_state_code in varchar2,
2317 p_sui_jurisdiction_code in varchar2,
2318 p_business_group_id in number,
2319 p_additional_wa_amount in number,
2320 p_filing_status_code in varchar2,
2321 p_fit_override_amount in number,
2322 p_fit_override_rate in number,
2323 p_withholding_allowances in number,
2324 p_cumulative_taxation in varchar2,
2325 p_eic_filing_status_code in varchar2,
2326 p_fit_additional_tax in number,
2327 p_fit_exempt in varchar2,
2328 p_futa_tax_exempt in varchar2,
2329 p_medicare_tax_exempt in varchar2,
2330 p_ss_tax_exempt in varchar2,
2331 p_wage_exempt in varchar2,
2332 p_statutory_employee in varchar2,
2333 p_w2_filed_year in number,
2334 p_supp_tax_override_rate in number,
2335 p_excessive_wa_reject_date in date,
2336 p_session_date in date,
2337 p_attribute_category in varchar2,
2338 p_attribute1 in varchar2,
2339 p_attribute2 in varchar2,
2340 p_attribute3 in varchar2,
2341 p_attribute4 in varchar2,
2342 p_attribute5 in varchar2,
2343 p_attribute6 in varchar2,
2344 p_attribute7 in varchar2,
2345 p_attribute8 in varchar2,
2346 p_attribute9 in varchar2,
2347 p_attribute10 in varchar2,
2348 p_attribute11 in varchar2,
2349 p_attribute12 in varchar2,
2350 p_attribute13 in varchar2,
2351 p_attribute14 in varchar2,
2352 p_attribute15 in varchar2,
2353 p_attribute16 in varchar2,
2354 p_attribute17 in varchar2,
2355 p_attribute18 in varchar2,
2356 p_attribute19 in varchar2,
2357 p_attribute20 in varchar2,
2358 p_attribute21 in varchar2,
2359 p_attribute22 in varchar2,
2360 p_attribute23 in varchar2,
2361 p_attribute24 in varchar2,
2362 p_attribute25 in varchar2,
2363 p_attribute26 in varchar2,
2364 p_attribute27 in varchar2,
2365 p_attribute28 in varchar2,
2366 p_attribute29 in varchar2,
2367 p_attribute30 in varchar2,
2368 p_fed_information_category in varchar2,
2369 p_fed_information1 in varchar2,
2370 p_fed_information2 in varchar2,
2371 p_fed_information3 in varchar2,
2372 p_fed_information4 in varchar2,
2373 p_fed_information5 in varchar2,
2374 p_fed_information6 in varchar2,
2375 p_fed_information7 in varchar2,
2376 p_fed_information8 in varchar2,
2377 p_fed_information9 in varchar2,
2378 p_fed_information10 in varchar2,
2379 p_fed_information11 in varchar2,
2380 p_fed_information12 in varchar2,
2381 p_fed_information13 in varchar2,
2382 p_fed_information14 in varchar2,
2383 p_fed_information15 in varchar2,
2384 p_fed_information16 in varchar2,
2385 p_fed_information17 in varchar2,
2386 p_fed_information18 in varchar2,
2387 p_fed_information19 in varchar2,
2388 p_fed_information20 in varchar2,
2389 p_fed_information21 in varchar2,
2390 p_fed_information22 in varchar2,
2391 p_fed_information23 in varchar2,
2392 p_fed_information24 in varchar2,
2393 p_fed_information25 in varchar2,
2394 p_fed_information26 in varchar2,
2395 p_fed_information27 in varchar2,
2396 p_fed_information28 in varchar2,
2397 p_fed_information29 in varchar2,
2398 p_fed_information30 in varchar2,
2399 p_mode in varchar2) is
2400
2401 lv_warning VARCHAR2(300);
2402
2403 begin
2404
2405
2406 hr_utility.set_location('pay_us_emp_dt_tax_rules.update_fed_tax_row'||
2407 ' - updating row', 1);
2408 ----added by vaprakas Bug 5607135
2409 check_nra_status(p_assignment_id
2410 , p_withholding_allowances
2411 , p_filing_status_code
2412 , p_fit_exempt
2413 , p_effective_start_date
2414 , p_effective_end_date
2415 , lv_warning);
2416
2417 update PAY_US_EMP_FED_TAX_RULES_F
2418 set emp_fed_tax_rule_id = p_emp_fed_tax_rule_id,
2419 effective_start_date = p_effective_start_date,
2420 effective_end_date = p_effective_end_date,
2421 assignment_id = p_assignment_id ,
2422 sui_state_code = p_sui_state_code,
2423 sui_jurisdiction_code = p_sui_jurisdiction_code,
2424 business_group_id = p_business_group_id ,
2425 additional_wa_amount = p_additional_wa_amount,
2426 filing_status_code = lpad(p_filing_status_code,2,'0'),
2427 fit_override_amount = p_fit_override_amount,
2428 fit_override_rate = p_fit_override_rate,
2429 withholding_allowances = p_withholding_allowances,
2430 cumulative_taxation = p_cumulative_taxation,
2431 eic_filing_status_code = p_eic_filing_status_code,
2432 fit_additional_tax = p_fit_additional_tax,
2433 fit_exempt = p_fit_exempt,
2434 futa_tax_exempt = p_futa_tax_exempt,
2435 medicare_tax_exempt = p_medicare_tax_exempt,
2436 ss_tax_exempt = p_ss_tax_exempt,
2437 wage_exempt = p_wage_exempt,
2438 statutory_employee = p_statutory_employee,
2439 w2_filed_year = p_w2_filed_year,
2440 supp_tax_override_rate = p_supp_tax_override_rate,
2441 excessive_wa_reject_date = p_excessive_wa_reject_date,
2442 attribute_category = p_attribute_category,
2443 attribute1 = p_attribute1,
2444 attribute2 = p_attribute2,
2445 attribute3 = p_attribute3,
2446 attribute4 = p_attribute4,
2447 attribute5 = p_attribute5,
2448 attribute6 = p_attribute6,
2449 attribute7 = p_attribute7,
2450 attribute8 = p_attribute8,
2451 attribute9 = p_attribute9,
2452 attribute10 = p_attribute10,
2453 attribute11 = p_attribute11,
2454 attribute12 = p_attribute12,
2455 attribute13 = p_attribute13,
2456 attribute14 = p_attribute14,
2457 attribute15 = p_attribute15,
2458 attribute16 = p_attribute16,
2459 attribute17 = p_attribute17,
2460 attribute18 = p_attribute18,
2461 attribute19 = p_attribute19,
2462 attribute20 = p_attribute20,
2463 attribute21 = p_attribute21,
2464 attribute22 = p_attribute22,
2465 attribute23 = p_attribute23,
2466 attribute24 = p_attribute24,
2467 attribute25 = p_attribute25,
2468 attribute26 = p_attribute26,
2469 attribute27 = p_attribute27,
2470 attribute28 = p_attribute28,
2471 attribute29 = p_attribute29,
2472 attribute30 = p_attribute30,
2473 fed_information_category = p_fed_information_category,
2474 fed_information1 = p_fed_information1,
2475 fed_information2 = p_fed_information2,
2476 fed_information3 = p_fed_information3,
2477 fed_information4 = p_fed_information4,
2478 fed_information5 = p_fed_information5,
2479 fed_information6 = p_fed_information6,
2480 fed_information7 = p_fed_information7,
2481 fed_information8 = p_fed_information8,
2482 fed_information9 = p_fed_information9,
2483 fed_information10 = p_fed_information10,
2484 fed_information11 = p_fed_information11,
2485 fed_information12 = p_fed_information12,
2486 fed_information13 = p_fed_information13,
2487 fed_information14 = p_fed_information14,
2488 fed_information15 = p_fed_information15,
2489 fed_information16 = p_fed_information16,
2490 fed_information17 = p_fed_information17,
2491 fed_information18 = p_fed_information18,
2492 fed_information19 = p_fed_information19,
2493 fed_information20 = p_fed_information20,
2494 fed_information21 = p_fed_information21,
2495 fed_information22 = p_fed_information22,
2496 fed_information23 = p_fed_information23,
2497 fed_information24 = p_fed_information24,
2498 fed_information25 = p_fed_information25,
2499 fed_information26 = p_fed_information26,
2500 fed_information27 = p_fed_information27,
2501 fed_information28 = p_fed_information28,
2502 fed_information29 = p_fed_information29,
2503 fed_information30 = p_fed_information30
2504 where rowid = chartorowid(p_row_id);
2505
2506 if sql%notfound then
2507 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
2508 fnd_message.set_token('PROCEDURE',
2509 'pay_us_emp_dt_tax_rules.update_fed_tax');
2510 fnd_message.set_token('STEP','1');
2511 fnd_message.raise_error;
2512 end if;
2513
2514 /* Update workers compensation element entry for the sui state in
2515 the federal record */
2516
2517 maintain_wc_ele_entry (p_assignment_id => p_assignment_id,
2518 p_effective_start_date => p_effective_start_date,
2519 p_effective_end_date => p_effective_end_date,
2520 p_session_date => p_session_date,
2521 p_jurisdiction_code => p_sui_jurisdiction_code,
2522 p_mode => p_mode);
2523
2524
2525 end update_fed_tax_row;
2526
2527 /* Name : update_state_tax_row
2528 Purpose : To update the state tax rule record.
2529 */
2530
2531 procedure update_state_tax_row ( p_row_id in varchar2,
2532 p_emp_state_tax_rule_id in number,
2533 p_effective_start_date in date,
2534 p_effective_end_date in date,
2535 p_assignment_id in number,
2536 p_state_code in varchar2,
2537 p_jurisdiction_code in varchar2,
2538 p_business_group_id in number,
2539 p_additional_wa_amount in number,
2540 p_filing_status_code in varchar2,
2541 p_remainder_percent in number,
2542 p_secondary_wa in number,
2543 p_sit_additional_tax in number,
2544 p_sit_override_amount in number,
2545 p_sit_override_rate in number,
2546 p_withholding_allowances in number,
2547 p_excessive_wa_reject_date in date,
2548 p_sdi_exempt in varchar2,
2549 p_sit_exempt in varchar2,
2550 p_sit_optional_calc_ind in varchar2,
2551 p_state_non_resident_cert in varchar2,
2552 p_sui_exempt in varchar2,
2553 p_wc_exempt in varchar2,
2554 p_wage_exempt in varchar2,
2555 p_sui_wage_base_override_amt in number,
2556 p_supp_tax_override_rate in number,
2557 p_attribute_category in varchar2,
2558 p_attribute1 in varchar2,
2559 p_attribute2 in varchar2,
2560 p_attribute3 in varchar2,
2561 p_attribute4 in varchar2,
2562 p_attribute5 in varchar2,
2563 p_attribute6 in varchar2,
2564 p_attribute7 in varchar2,
2565 p_attribute8 in varchar2,
2566 p_attribute9 in varchar2,
2567 p_attribute10 in varchar2,
2568 p_attribute11 in varchar2,
2569 p_attribute12 in varchar2,
2570 p_attribute13 in varchar2,
2571 p_attribute14 in varchar2,
2572 p_attribute15 in varchar2,
2573 p_attribute16 in varchar2,
2574 p_attribute17 in varchar2,
2575 p_attribute18 in varchar2,
2576 p_attribute19 in varchar2,
2577 p_attribute20 in varchar2,
2578 p_attribute21 in varchar2,
2579 p_attribute22 in varchar2,
2580 p_attribute23 in varchar2,
2581 p_attribute24 in varchar2,
2585 p_attribute28 in varchar2,
2582 p_attribute25 in varchar2,
2583 p_attribute26 in varchar2,
2584 p_attribute27 in varchar2,
2586 p_attribute29 in varchar2,
2587 p_attribute30 in varchar2,
2588 p_sta_information_category in varchar2,
2589 p_sta_information1 in varchar2,
2590 p_sta_information2 in varchar2,
2591 p_sta_information3 in varchar2,
2592 p_sta_information4 in varchar2,
2593 p_sta_information5 in varchar2,
2594 p_sta_information6 in varchar2,
2595 p_sta_information7 in varchar2,
2596 p_sta_information8 in varchar2,
2597 p_sta_information9 in varchar2,
2598 p_sta_information10 in varchar2,
2599 p_sta_information11 in varchar2,
2600 p_sta_information12 in varchar2,
2601 p_sta_information13 in varchar2,
2602 p_sta_information14 in varchar2,
2603 p_sta_information15 in varchar2,
2604 p_sta_information16 in varchar2,
2605 p_sta_information17 in varchar2,
2606 p_sta_information18 in varchar2,
2607 p_sta_information19 in varchar2,
2608 p_sta_information20 in varchar2,
2609 p_sta_information21 in varchar2,
2610 p_sta_information22 in varchar2,
2611 p_sta_information23 in varchar2,
2612 p_sta_information24 in varchar2,
2613 p_sta_information25 in varchar2,
2614 p_sta_information26 in varchar2,
2615 p_sta_information27 in varchar2,
2616 p_sta_information28 in varchar2,
2617 p_sta_information29 in varchar2,
2618 p_sta_information30 in varchar2) is
2619 begin
2620
2621 hr_utility.set_location('pay_us_emp_dt_tax_rules.ins_st_tax_row'||
2622 ' - updating row', 1);
2623
2624 update PAY_US_EMP_STATE_TAX_RULES_F
2625 set emp_state_tax_rule_id = p_emp_state_tax_rule_id,
2626 effective_start_date = p_effective_start_date,
2627 effective_end_date = p_effective_end_date,
2628 assignment_id = p_assignment_id,
2629 state_code = p_state_code,
2630 jurisdiction_code = p_jurisdiction_code,
2631 business_group_id = p_business_group_id,
2632 additional_wa_amount = p_additional_wa_amount,
2633 filing_status_code = lpad(p_filing_status_code,2,'0'),
2634 remainder_percent = p_remainder_percent,
2635 secondary_wa = p_secondary_wa,
2636 sit_additional_tax = p_sit_additional_tax,
2637 sit_override_amount = p_sit_override_amount,
2638 sit_override_rate = p_sit_override_rate,
2639 withholding_allowances = p_withholding_allowances,
2640 excessive_wa_reject_date = p_excessive_wa_reject_date,
2641 sdi_exempt = p_sdi_exempt,
2642 sit_exempt = p_sit_exempt,
2643 sit_optional_calc_ind = p_sit_optional_calc_ind,
2644 state_non_resident_cert = p_state_non_resident_cert,
2645 sui_exempt = p_sui_exempt,
2646 wc_exempt = p_wc_exempt,
2647 wage_exempt = p_wage_exempt,
2648 sui_wage_base_override_amount = p_sui_wage_base_override_amt,
2649 supp_tax_override_rate = p_supp_tax_override_rate,
2650 attribute_category = p_attribute_category,
2651 attribute1 = p_attribute1,
2652 attribute2 = p_attribute2,
2653 attribute3 = p_attribute3,
2654 attribute4 = p_attribute4,
2655 attribute5 = p_attribute5,
2656 attribute6 = p_attribute6,
2657 attribute7 = p_attribute7,
2658 attribute8 = p_attribute8,
2659 attribute9 = p_attribute9,
2660 attribute10 = p_attribute10,
2661 attribute11 = p_attribute11,
2662 attribute12 = p_attribute12,
2663 attribute13 = p_attribute13,
2664 attribute14 = p_attribute14,
2665 attribute15 = p_attribute15,
2666 attribute16 = p_attribute16,
2667 attribute17 = p_attribute17,
2668 attribute18 = p_attribute18,
2669 attribute19 = p_attribute19,
2670 attribute20 = p_attribute20,
2671 attribute21 = p_attribute21,
2672 attribute22 = p_attribute22,
2673 attribute23 = p_attribute23,
2674 attribute24 = p_attribute24,
2675 attribute25 = p_attribute25,
2676 attribute26 = p_attribute26,
2677 attribute27 = p_attribute27,
2678 attribute28 = p_attribute28,
2679 attribute29 = p_attribute29,
2680 attribute30 = p_attribute30,
2681 sta_information_category = p_sta_information_category,
2682 sta_information1 = p_sta_information1,
2683 sta_information2 = p_sta_information2,
2684 sta_information3 = p_sta_information3,
2685 sta_information4 = p_sta_information4,
2686 sta_information5 = p_sta_information5,
2687 sta_information6 = p_sta_information6,
2688 sta_information7 = p_sta_information7,
2689 sta_information8 = p_sta_information8,
2690 sta_information9 = p_sta_information9,
2691 sta_information10 = p_sta_information10,
2692 sta_information11 = p_sta_information11,
2693 sta_information12 = p_sta_information12,
2694 sta_information13 = p_sta_information13,
2695 sta_information14 = p_sta_information14,
2696 sta_information15 = p_sta_information15,
2697 sta_information16 = p_sta_information16,
2698 sta_information17 = p_sta_information17,
2699 sta_information18 = p_sta_information18,
2700 sta_information19 = p_sta_information19,
2701 sta_information20 = p_sta_information20,
2702 sta_information21 = p_sta_information21,
2703 sta_information22 = p_sta_information22,
2704 sta_information23 = p_sta_information23,
2705 sta_information24 = p_sta_information24,
2706 sta_information25 = p_sta_information25,
2707 sta_information26 = p_sta_information26,
2708 sta_information27 = p_sta_information27,
2709 sta_information28 = p_sta_information28,
2710 sta_information29 = p_sta_information29,
2711 sta_information30 = p_sta_information30
2712 where rowid = chartorowid(p_row_id);
2713
2714 if sql%notfound then
2715 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
2716 fnd_message.set_token('PROCEDURE',
2717 'pay_us_emp_dt_tax_rules.update_state_tax_row');
2718 fnd_message.set_token('STEP','1');
2719 fnd_message.raise_error;
2720 end if;
2721
2722 hr_utility.set_location('pay_us_emp_dt_tax_rules.ins_st_tax_row'||
2723 ' - updated row', 2);
2724
2725 end update_state_tax_row;
2726
2727
2728 /* Name : update_county_tax_row
2729 Purpose : To update the county tax rule record.
2730 */
2731 procedure update_county_tax_row ( p_row_id in varchar2,
2732 p_emp_county_tax_rule_id in number,
2733 p_effective_start_date in date,
2734 p_effective_end_date in date,
2735 p_assignment_id in number,
2736 p_state_code in varchar2,
2737 p_county_code in varchar2,
2738 p_business_group_id in number,
2739 p_additional_wa_rate in number,
2740 p_filing_status_code in varchar2,
2741 p_jurisdiction_code in varchar2,
2742 p_lit_additional_tax in number,
2743 p_lit_override_amount in number,
2744 p_lit_override_rate in number,
2745 p_withholding_allowances in number,
2746 p_lit_exempt in varchar2,
2747 p_sd_exempt in varchar2,
2748 p_ht_exempt in varchar2,
2749 p_wage_exempt in varchar2,
2750 p_school_district_code in varchar2,
2751 p_attribute_category in varchar2,
2752 p_attribute1 in varchar2,
2753 p_attribute2 in varchar2,
2754 p_attribute3 in varchar2,
2755 p_attribute4 in varchar2,
2756 p_attribute5 in varchar2,
2757 p_attribute6 in varchar2,
2758 p_attribute7 in varchar2,
2759 p_attribute8 in varchar2,
2760 p_attribute9 in varchar2,
2761 p_attribute10 in varchar2,
2762 p_attribute11 in varchar2,
2763 p_attribute12 in varchar2,
2764 p_attribute13 in varchar2,
2765 p_attribute14 in varchar2,
2766 p_attribute15 in varchar2,
2767 p_attribute16 in varchar2,
2768 p_attribute17 in varchar2,
2769 p_attribute18 in varchar2,
2770 p_attribute19 in varchar2,
2771 p_attribute20 in varchar2,
2772 p_attribute21 in varchar2,
2773 p_attribute22 in varchar2,
2774 p_attribute23 in varchar2,
2775 p_attribute24 in varchar2,
2776 p_attribute25 in varchar2,
2777 p_attribute26 in varchar2,
2778 p_attribute27 in varchar2,
2779 p_attribute28 in varchar2,
2780 p_attribute29 in varchar2,
2781 p_attribute30 in varchar2,
2782 p_cnt_information_category in varchar2,
2783 p_cnt_information1 in varchar2,
2784 p_cnt_information2 in varchar2,
2785 p_cnt_information3 in varchar2,
2786 p_cnt_information4 in varchar2,
2787 p_cnt_information5 in varchar2,
2788 p_cnt_information6 in varchar2,
2789 p_cnt_information7 in varchar2,
2790 p_cnt_information8 in varchar2,
2791 p_cnt_information9 in varchar2,
2792 p_cnt_information10 in varchar2,
2793 p_cnt_information11 in varchar2,
2794 p_cnt_information12 in varchar2,
2795 p_cnt_information13 in varchar2,
2796 p_cnt_information14 in varchar2,
2797 p_cnt_information15 in varchar2,
2798 p_cnt_information16 in varchar2,
2799 p_cnt_information17 in varchar2,
2800 p_cnt_information18 in varchar2,
2801 p_cnt_information19 in varchar2,
2802 p_cnt_information20 in varchar2,
2803 p_cnt_information21 in varchar2,
2804 p_cnt_information22 in varchar2,
2805 p_cnt_information23 in varchar2,
2806 p_cnt_information24 in varchar2,
2807 p_cnt_information25 in varchar2,
2808 p_cnt_information26 in varchar2,
2809 p_cnt_information27 in varchar2,
2810 p_cnt_information28 in varchar2,
2811 p_cnt_information29 in varchar2,
2812 p_cnt_information30 in varchar2) is
2813
2814 begin
2815
2816 if p_school_district_code is not null
2817 then
2818
2819 hr_utility.set_location('pay_us_emp_dt_tax_rules.update_county_tax_row'||
2820 ' - checking sd', 1);
2821 /* Check that the school district is assigned to only one county/city
2822 at a given point in time */
2823
2824 pay_us_emp_dt_tax_val.check_school_district(
2825 p_assignment => p_assignment_id,
2826 p_start_date => p_effective_start_date,
2827 p_end_date => p_effective_end_date,
2828 p_mode => 'U',
2829 p_rowid => p_row_id);
2830 end if;
2831
2832 hr_utility.set_location('pay_us_emp_dt_tax_rules.update_county_tax_row'||
2833 ' - updating row', 2);
2834
2835 update PAY_US_EMP_COUNTY_TAX_RULES_F
2836 set emp_county_tax_rule_id = p_emp_county_tax_rule_id,
2837 effective_start_date = p_effective_start_date,
2838 effective_end_date = p_effective_end_date,
2839 assignment_id = p_assignment_id,
2840 state_code = p_state_code,
2841 county_code = p_county_code,
2842 business_group_id = p_business_group_id,
2843 additional_wa_rate = p_additional_wa_rate,
2844 filing_status_code = lpad(p_filing_status_code,2,'0'),
2845 jurisdiction_code = p_jurisdiction_code,
2846 lit_additional_tax = p_lit_additional_tax,
2847 lit_override_amount = p_lit_override_amount,
2848 lit_override_rate = p_lit_override_rate,
2849 withholding_allowances = p_withholding_allowances,
2850 lit_exempt = p_lit_exempt,
2851 sd_exempt = p_sd_exempt,
2852 ht_exempt = p_ht_exempt,
2853 wage_exempt = p_wage_exempt,
2854 school_district_code = p_school_district_code,
2855 attribute_category = p_attribute_category,
2856 attribute1 = p_attribute1,
2857 attribute2 = p_attribute2,
2858 attribute3 = p_attribute3,
2859 attribute4 = p_attribute4,
2860 attribute5 = p_attribute5,
2861 attribute6 = p_attribute6,
2862 attribute7 = p_attribute7,
2863 attribute8 = p_attribute8,
2864 attribute9 = p_attribute9,
2865 attribute10 = p_attribute10,
2866 attribute11 = p_attribute11,
2867 attribute12 = p_attribute12,
2868 attribute13 = p_attribute13,
2869 attribute14 = p_attribute14,
2870 attribute15 = p_attribute15,
2871 attribute16 = p_attribute16,
2872 attribute17 = p_attribute17,
2873 attribute18 = p_attribute18,
2874 attribute19 = p_attribute19,
2875 attribute20 = p_attribute20,
2876 attribute21 = p_attribute21,
2877 attribute22 = p_attribute22,
2878 attribute23 = p_attribute23,
2879 attribute24 = p_attribute24,
2880 attribute25 = p_attribute25,
2881 attribute26 = p_attribute26,
2882 attribute27 = p_attribute27,
2883 attribute28 = p_attribute28,
2884 attribute29 = p_attribute29,
2885 attribute30 = p_attribute30,
2886 cnt_information_category = p_cnt_information_category,
2887 cnt_information1 = p_cnt_information1,
2888 cnt_information2 = p_cnt_information2,
2889 cnt_information3 = p_cnt_information3,
2890 cnt_information4 = p_cnt_information4,
2891 cnt_information5 = p_cnt_information5,
2892 cnt_information6 = p_cnt_information6,
2893 cnt_information7 = p_cnt_information7,
2894 cnt_information8 = p_cnt_information8,
2895 cnt_information9 = p_cnt_information9,
2896 cnt_information10 = p_cnt_information10,
2897 cnt_information11 = p_cnt_information11,
2898 cnt_information12 = p_cnt_information12,
2899 cnt_information13 = p_cnt_information13,
2900 cnt_information14 = p_cnt_information14,
2901 cnt_information15 = p_cnt_information15,
2902 cnt_information16 = p_cnt_information16,
2903 cnt_information17 = p_cnt_information17,
2904 cnt_information18 = p_cnt_information18,
2905 cnt_information19 = p_cnt_information19,
2906 cnt_information20 = p_cnt_information20,
2907 cnt_information21 = p_cnt_information21,
2908 cnt_information22 = p_cnt_information22,
2909 cnt_information23 = p_cnt_information23,
2910 cnt_information24 = p_cnt_information24,
2911 cnt_information25 = p_cnt_information25,
2912 cnt_information26 = p_cnt_information26,
2913 cnt_information27 = p_cnt_information27,
2914 cnt_information28 = p_cnt_information28,
2915 cnt_information29 = p_cnt_information29,
2916 cnt_information30 = p_cnt_information30
2917 where rowid = chartorowid(p_row_id);
2918
2919 if sql%notfound then
2920 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
2921 fnd_message.set_token('PROCEDURE',
2922 'pay_us_emp_dt_tax_rules.update_county_tax_row');
2923 fnd_message.set_token('STEP','2');
2924 fnd_message.raise_error;
2925 end if;
2926
2927 if p_school_district_code is not null then
2928
2929 /* Insert row into the pay_us_asg_reporting table */
2930
2931 hr_utility.set_location('pay_us_emp_dt_tax_rules.update_county_tax_row'||
2932 ' - asg_geo row', 3);
2933
2934 pay_asg_geo_pkg.create_asg_geo_row(P_assignment_id => p_assignment_id,
2935 P_jurisdiction => p_state_code || '-'||
2936 p_school_district_code,
2937 P_tax_unit_id => NULL );
2938 end if;
2939
2940 end update_county_tax_row;
2941
2942
2943 /* Name : update_city_tax_row
2944 Purpose : To update the city tax rule record.
2945 */
2946
2947 procedure update_city_tax_row ( p_row_id in varchar2,
2948 p_emp_city_tax_rule_id in number,
2949 p_effective_start_date in date,
2950 p_effective_end_date in date,
2951 p_assignment_id in number,
2952 p_state_code in varchar2,
2953 p_county_code in varchar2,
2954 p_city_code in varchar2,
2955 p_business_group_id in number,
2956 p_additional_wa_rate in number,
2957 p_filing_status_code in varchar2,
2958 p_jurisdiction_code in varchar2,
2959 p_lit_additional_tax in number,
2960 p_lit_override_amount in number,
2961 p_lit_override_rate in number,
2962 p_withholding_allowances in number,
2963 p_lit_exempt in varchar2,
2964 p_sd_exempt in varchar2,
2965 p_ht_exempt in varchar2,
2966 p_wage_exempt in varchar2,
2967 p_school_district_code in varchar2,
2968 p_attribute_category in varchar2,
2969 p_attribute1 in varchar2,
2970 p_attribute2 in varchar2,
2971 p_attribute3 in varchar2,
2972 p_attribute4 in varchar2,
2973 p_attribute5 in varchar2,
2974 p_attribute6 in varchar2,
2975 p_attribute7 in varchar2,
2976 p_attribute8 in varchar2,
2977 p_attribute9 in varchar2,
2978 p_attribute10 in varchar2,
2979 p_attribute11 in varchar2,
2980 p_attribute12 in varchar2,
2981 p_attribute13 in varchar2,
2982 p_attribute14 in varchar2,
2983 p_attribute15 in varchar2,
2984 p_attribute16 in varchar2,
2985 p_attribute17 in varchar2,
2986 p_attribute18 in varchar2,
2987 p_attribute19 in varchar2,
2988 p_attribute20 in varchar2,
2989 p_attribute21 in varchar2,
2990 p_attribute22 in varchar2,
2991 p_attribute23 in varchar2,
2992 p_attribute24 in varchar2,
2993 p_attribute25 in varchar2,
2994 p_attribute26 in varchar2,
2995 p_attribute27 in varchar2,
2996 p_attribute28 in varchar2,
2997 p_attribute29 in varchar2,
2998 p_attribute30 in varchar2,
2999 p_cty_information_category in varchar2,
3000 p_cty_information1 in varchar2,
3001 p_cty_information2 in varchar2,
3002 p_cty_information3 in varchar2,
3003 p_cty_information4 in varchar2,
3004 p_cty_information5 in varchar2,
3005 p_cty_information6 in varchar2,
3006 p_cty_information7 in varchar2,
3007 p_cty_information8 in varchar2,
3008 p_cty_information9 in varchar2,
3009 p_cty_information10 in varchar2,
3010 p_cty_information11 in varchar2,
3011 p_cty_information12 in varchar2,
3012 p_cty_information13 in varchar2,
3013 p_cty_information14 in varchar2,
3014 p_cty_information15 in varchar2,
3015 p_cty_information16 in varchar2,
3016 p_cty_information17 in varchar2,
3017 p_cty_information18 in varchar2,
3018 p_cty_information19 in varchar2,
3019 p_cty_information20 in varchar2,
3020 p_cty_information21 in varchar2,
3021 p_cty_information22 in varchar2,
3022 p_cty_information23 in varchar2,
3023 p_cty_information24 in varchar2,
3024 p_cty_information25 in varchar2,
3025 p_cty_information26 in varchar2,
3026 p_cty_information27 in varchar2,
3027 p_cty_information28 in varchar2,
3028 p_cty_information29 in varchar2,
3029 p_cty_information30 in varchar2) is
3030 begin
3031
3032 if p_school_district_code is not null
3033 and p_state_code <> '39'
3034 then
3035
3036 hr_utility.set_location('pay_us_emp_dt_tax_rules.update_city_tax_row'||
3037 ' - checking sd', 1);
3038
3039 /* Check that the school district is assigned to only one county/city
3040 at a given point in time */
3041
3042 pay_us_emp_dt_tax_val.check_school_district(
3043 p_assignment => p_assignment_id,
3044 p_start_date => p_effective_start_date,
3045 p_end_date => p_effective_end_date,
3046 p_mode => 'U',
3047 p_rowid => p_row_id);
3048 end if;
3049
3050 hr_utility.set_location('pay_us_emp_dt_tax_rules.update_city_tax_row'||
3051 ' - updating row', 2);
3052
3053 update PAY_US_EMP_CITY_TAX_RULES_F
3054 set emp_city_tax_rule_id = p_emp_city_tax_rule_id,
3055 effective_start_date = p_effective_start_date,
3056 effective_end_date = p_effective_end_date,
3057 assignment_id = p_assignment_id,
3058 state_code = p_state_code,
3059 county_code = p_county_code,
3060 city_code = p_city_code,
3061 business_group_id = p_business_group_id,
3062 additional_wa_rate = p_additional_wa_rate,
3063 filing_status_code = lpad(p_filing_status_code,2,'0'),
3064 jurisdiction_code = p_jurisdiction_code,
3065 lit_additional_tax = p_lit_additional_tax,
3066 lit_override_amount = p_lit_override_amount,
3067 lit_override_rate = p_lit_override_rate,
3068 withholding_allowances = p_withholding_allowances,
3069 lit_exempt = p_lit_exempt,
3070 sd_exempt = p_sd_exempt,
3071 ht_exempt = p_ht_exempt,
3072 wage_exempt = p_wage_exempt,
3073 school_district_code = p_school_district_code,
3074 attribute_category = p_attribute_category,
3075 attribute1 = p_attribute1,
3076 attribute2 = p_attribute2,
3077 attribute3 = p_attribute3,
3078 attribute4 = p_attribute4,
3079 attribute5 = p_attribute5,
3080 attribute6 = p_attribute6,
3081 attribute7 = p_attribute7,
3082 attribute8 = p_attribute8,
3083 attribute9 = p_attribute9,
3084 attribute10 = p_attribute10,
3085 attribute11 = p_attribute11,
3086 attribute12 = p_attribute12,
3087 attribute13 = p_attribute13,
3088 attribute14 = p_attribute14,
3089 attribute15 = p_attribute15,
3090 attribute16 = p_attribute16,
3091 attribute17 = p_attribute17,
3092 attribute18 = p_attribute18,
3093 attribute19 = p_attribute19,
3094 attribute20 = p_attribute20,
3095 attribute21 = p_attribute21,
3096 attribute22 = p_attribute22,
3097 attribute23 = p_attribute23,
3098 attribute24 = p_attribute24,
3099 attribute25 = p_attribute25,
3100 attribute26 = p_attribute26,
3101 attribute27 = p_attribute27,
3102 attribute28 = p_attribute28,
3103 attribute29 = p_attribute29,
3104 attribute30 = p_attribute30,
3105 cty_information_category = p_cty_information_category,
3106 cty_information1 = p_cty_information1,
3107 cty_information2 = p_cty_information2,
3108 cty_information3 = p_cty_information3,
3109 cty_information4 = p_cty_information4,
3110 cty_information5 = p_cty_information5,
3111 cty_information6 = p_cty_information6,
3112 cty_information7 = p_cty_information7,
3113 cty_information8 = p_cty_information8,
3114 cty_information9 = p_cty_information9,
3115 cty_information10 = p_cty_information10,
3116 cty_information11 = p_cty_information11,
3117 cty_information12 = p_cty_information12,
3118 cty_information13 = p_cty_information13,
3119 cty_information14 = p_cty_information14,
3120 cty_information15 = p_cty_information15,
3121 cty_information16 = p_cty_information16,
3122 cty_information17 = p_cty_information17,
3123 cty_information18 = p_cty_information18,
3124 cty_information19 = p_cty_information19,
3125 cty_information20 = p_cty_information20,
3126 cty_information21 = p_cty_information21,
3127 cty_information22 = p_cty_information22,
3128 cty_information23 = p_cty_information23,
3129 cty_information24 = p_cty_information24,
3130 cty_information25 = p_cty_information25,
3131 cty_information26 = p_cty_information26,
3132 cty_information27 = p_cty_information27,
3133 cty_information28 = p_cty_information28,
3134 cty_information29 = p_cty_information29,
3135 cty_information30 = p_cty_information30
3136 where rowid = chartorowid(p_row_id);
3137
3138 if sql%notfound then
3139
3140 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
3141 fnd_message.set_token('PROCEDURE',
3142 'pay_us_emp_dt_tax_rules.update_city_tax_row');
3143 fnd_message.set_token('STEP','2');
3144 fnd_message.raise_error;
3145
3146 end if;
3147
3148 if p_school_district_code is not null then
3149
3150 /* Insert row into the pay_us_asg_reporting table */
3151
3152 hr_utility.set_location('pay_us_emp_dt_tax_rules.update_city_tax_row'||
3153 ' - asg_geo row', 3);
3154
3155 pay_asg_geo_pkg.create_asg_geo_row(P_assignment_id => p_assignment_id,
3156 P_jurisdiction => p_state_code || '-' ||
3157 p_school_district_code,
3158 P_tax_unit_id => NULL );
3159 end if;
3160
3161 end update_city_tax_row;
3162
3163
3164 /* Name : delete_tax_row
3165 Purpose : This routine will be called by the W4 form to purge a tax rule record.
3166 Only purging(i.e. ZAP) of the tax record will be allowed. No other kind
3167 of delete will be allowed for the tax record. If a state record is purged,
3168 then all of the county and city records for that state, will also be purged.
3169 Similarly, is a county record is purged then all of the city records under
3170 that county, will also be purged.
3171 Along with the tax rule record, the tax %age records associated with that
3172 tax rules record, will also be purged i.e. delete cascade
3173 Parameters :
3174 p_assignment_id -> The assignment whose tax record will be purged.
3175 p_state_code -> State whose tax record will be purged
3176 p_county_code -> County whose tax record will be purged
3177 p_city_code -> City whose tax record will be purged
3178 */
3179
3180 procedure delete_tax_row ( p_assignment_id in number,
3181 p_state_code in varchar2,
3182 p_county_code in varchar2,
3183 p_city_code in varchar2) is
3184
3185 l_ret_code number;
3186 l_ret_text varchar2(240);
3187 l_jurisdiction_code varchar2(11);
3188 l_effective_start_date date;
3189 l_payroll_installed boolean := FALSE;
3190
3191 /* Cursor to get the counties for the state */
3192 cursor csr_state_counties is
3193 select puc.jurisdiction_code
3194 from PAY_US_EMP_COUNTY_TAX_RULES_F puc
3195 where puc.assignment_id = p_assignment_id
3196 and puc.state_code = p_state_code;
3197
3198 /* Cursor to get the cities for the state */
3199 cursor csr_state_cities is
3200 select puc.jurisdiction_code
3201 from PAY_US_EMP_CITY_TAX_RULES_F puc
3202 where puc.assignment_id = p_assignment_id
3203 and puc.state_code = p_state_code;
3204
3205 /* Cursor to get the cities for the county */
3206 cursor csr_county_cities is
3207 select puc.jurisdiction_code
3208 from PAY_US_EMP_CITY_TAX_RULES_F puc
3209 where puc.assignment_id = p_assignment_id
3210 and puc.state_code = p_state_code
3211 and puc.county_code = p_county_code;
3212
3213 /* cursor to get the start date of the tax %age record.
3214 The min federal effective date is the date on which the
3215 default tax rules criteria was satisfied. */
3216
3217 cursor csr_get_eff_date is
3218 select min(effective_start_date)
3219 from PAY_US_EMP_FED_TAX_RULES_F
3220 where assignment_id = p_assignment_id;
3221
3222 begin
3223
3224 /* Check if payroll has been installed or not */
3225
3226 l_payroll_installed := hr_utility.chk_product_install(p_product =>'Oracle Payroll',
3227 p_legislation => 'US');
3228
3229 /* Now all validations done. Go ahead and delete the element entries.
3230 Once the element entries are deleted, delete the tax rules records */
3231
3232 /* Get the start date of the tax percentage records */
3233
3234 open csr_get_eff_date;
3235
3236 fetch csr_get_eff_date into l_effective_start_date;
3237
3238 if l_effective_start_date is null then
3239 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
3240 fnd_message.set_token('PROCEDURE',
3241 'pay_us_emp_dt_tax_rules.delete_tax_row');
3242 fnd_message.set_token('STEP','1');
3243 fnd_message.raise_error;
3244 end if;
3245
3246 close csr_get_eff_date;
3247
3248 /* Processing for deleteing the state tax rule record */
3249
3250 if p_state_code is not null and p_county_code is null
3251 and p_city_code is null then
3252
3253 /* Delete the element entries only if Payroll is installed */
3254
3255 if l_payroll_installed then
3256
3257 /* Get the cities for the state and call the maintain_element_entry routine
3258 to delete the city %age records for the cities in the state */
3259
3260 open csr_state_cities;
3261
3262 loop
3263
3264 fetch csr_state_cities into l_jurisdiction_code;
3265
3266 exit when csr_state_cities%NOTFOUND;
3267
3268 /* Delete the %age tax record for the jurisdiction */
3269
3270 maintain_element_entry(p_assignment_id => p_assignment_id,
3271 p_effective_start_date => l_effective_start_date,
3272 p_effective_end_date => to_date('31-12-4712','dd-mm-yyyy'),
3273 p_session_date => l_effective_start_date,
3274 p_jurisdiction_code => l_jurisdiction_code,
3275 p_percentage_time => 0,
3276 p_mode => 'ZAP');
3277
3278
3279 end loop;
3280
3281 close csr_state_cities;
3282
3283 /* Get the counties for the state and call the maintain_element_entry routine
3284 to delete the county %age records for the cities in the state */
3285
3286 open csr_state_counties;
3287
3288 loop
3289
3290 fetch csr_state_counties into l_jurisdiction_code;
3291
3292 exit when csr_state_counties%NOTFOUND;
3293
3294 /* Delete the %age tax record for the jurisdiction */
3295
3296 maintain_element_entry(p_assignment_id => p_assignment_id,
3297 p_effective_start_date => l_effective_start_date,
3298 p_effective_end_date => to_date('31-12-4712','dd-mm-yyyy'),
3299 p_session_date => l_effective_start_date,
3300 p_jurisdiction_code => l_jurisdiction_code,
3301 p_percentage_time => 0,
3302 p_mode => 'ZAP');
3303
3304 end loop;
3305
3306 close csr_state_counties;
3307
3308 /* Delete the state %age records for the state */
3309
3310 maintain_element_entry(p_assignment_id => p_assignment_id,
3311 p_effective_start_date => l_effective_start_date,
3312 p_effective_end_date => to_date('31-12-4712','dd-mm-yyyy'),
3313 p_session_date => l_effective_start_date,
3314 p_jurisdiction_code => p_state_code || '-000-0000',
3315 p_percentage_time => 0,
3316 p_mode => 'ZAP');
3317 end if;
3318
3319 /* Delete records from PAY_US_EMP_CITY_TAX_RULES_F */
3320
3321 delete PAY_US_EMP_CITY_TAX_RULES_F
3322 where assignment_id = p_assignment_id
3323 and state_code = p_state_code;
3324
3325 /* Delete records from PAY_US_EMP_COUNTY_TAX_RULES_F */
3326
3327 delete PAY_US_EMP_COUNTY_TAX_RULES_F
3328 where assignment_id = p_assignment_id
3329 and state_code = p_state_code;
3330
3331 /* Delete records from PAY_US_EMP_STATE_TAX_RULES_F */
3332
3333 delete PAY_US_EMP_STATE_TAX_RULES_F
3334 where assignment_id = p_assignment_id
3335 and state_code = p_state_code;
3336
3337 elsif p_state_code is not null and p_county_code is not null
3338 and p_city_code is null then
3339
3340 if l_payroll_installed then
3341
3342 /* Get the cities for the county and call the maintain_element_entry routine
3343 to delete the city %age records for the cities in the county */
3344
3345 open csr_county_cities;
3346
3347 loop
3348
3349 fetch csr_county_cities into l_jurisdiction_code;
3350
3351 exit when csr_county_cities%NOTFOUND;
3352
3353 /* Delete the %age tax record for the jurisdiction */
3354
3355 maintain_element_entry(p_assignment_id => p_assignment_id,
3356 p_effective_start_date => l_effective_start_date,
3357 p_effective_end_date => to_date('31-12-4712','dd-mm-yyyy'),
3358 p_session_date => l_effective_start_date,
3359 p_jurisdiction_code => l_jurisdiction_code,
3360 p_percentage_time => 0,
3361 p_mode => 'ZAP');
3362
3363 end loop;
3364
3365 close csr_county_cities;
3366
3367 /* Delete the state %age records for the county */
3368
3369 maintain_element_entry(p_assignment_id => p_assignment_id,
3370 p_effective_start_date => l_effective_start_date,
3371 p_effective_end_date => to_date('31-12-4712','dd-mm-yyyy'),
3372 p_session_date => l_effective_start_date,
3373 p_jurisdiction_code => p_state_code ||'-' ||
3374 p_county_code ||'-0000',
3375 p_percentage_time => 0,
3376 p_mode => 'ZAP');
3377 end if;
3378
3379 /* Delete records from PAY_US_EMP_CITY_TAX_RULES_F */
3380
3381 delete PAY_US_EMP_CITY_TAX_RULES_F
3382 where assignment_id = p_assignment_id
3383 and state_code = p_state_code
3384 and county_code = p_county_code;
3385
3386 /* Delete records from PAY_US_EMP_COUNTY_TAX_RULES_F */
3387
3388 delete PAY_US_EMP_COUNTY_TAX_RULES_F
3389 where assignment_id = p_assignment_id
3390 and state_code = p_state_code
3391 and county_code = p_county_code;
3392
3393 elsif p_state_code is not null and p_county_code is not null
3394 and p_city_code is not null then
3395
3396 if l_payroll_installed then
3397
3398 /* Delete the state %age records for the city */
3399
3400 maintain_element_entry(p_assignment_id => p_assignment_id,
3401 p_effective_start_date => l_effective_start_date,
3402 p_effective_end_date => to_date('31-12-4712','dd-mm-yyyy'),
3403 p_session_date => l_effective_start_date,
3404 p_jurisdiction_code => p_state_code ||'-' ||
3405 p_county_code ||'-'|| p_city_code,
3406 p_percentage_time => 0,
3407 p_mode => 'ZAP');
3408
3409 end if;
3410
3411 /* Delete records from PAY_US_EMP_CITY_TAX_RULES_F */
3412
3413 delete PAY_US_EMP_CITY_TAX_RULES_F
3414 where assignment_id = p_assignment_id
3415 and state_code = p_state_code
3416 and county_code = p_county_code
3417 and city_code = p_city_code;
3418
3419 end if;
3420
3421 end delete_tax_row;
3422
3423
3424 /* Name : lock_fed_tax_row
3425 Purpose : To lock the federal tax rule record.
3426 */
3427
3428 procedure lock_fed_tax_row ( p_row_id in varchar2,
3429 p_emp_fed_tax_rule_id in number,
3430 p_effective_start_date in date,
3431 p_effective_end_date in date,
3432 p_assignment_id in number,
3433 p_sui_state_code in varchar2,
3434 p_sui_jurisdiction_code in varchar2,
3435 p_business_group_id in number,
3436 p_additional_wa_amount in number,
3437 p_filing_status_code in varchar2,
3438 p_fit_override_amount in number,
3439 p_fit_override_rate in number,
3440 p_withholding_allowances in number,
3441 p_cumulative_taxation in varchar2,
3442 p_eic_filing_status_code in varchar2,
3443 p_fit_additional_tax in number,
3444 p_fit_exempt in varchar2,
3445 p_futa_tax_exempt in varchar2,
3446 p_medicare_tax_exempt in varchar2,
3447 p_ss_tax_exempt in varchar2,
3448 p_wage_exempt in varchar2,
3449 p_statutory_employee in varchar2,
3450 p_w2_filed_year in number,
3451 p_supp_tax_override_rate in number,
3452 p_excessive_wa_reject_date in date,
3453 p_attribute_category in varchar2,
3454 p_attribute1 in varchar2,
3455 p_attribute2 in varchar2,
3456 p_attribute3 in varchar2,
3457 p_attribute4 in varchar2,
3458 p_attribute5 in varchar2,
3459 p_attribute6 in varchar2,
3460 p_attribute7 in varchar2,
3461 p_attribute8 in varchar2,
3462 p_attribute9 in varchar2,
3463 p_attribute10 in varchar2,
3464 p_attribute11 in varchar2,
3465 p_attribute12 in varchar2,
3466 p_attribute13 in varchar2,
3467 p_attribute14 in varchar2,
3468 p_attribute15 in varchar2,
3469 p_attribute16 in varchar2,
3470 p_attribute17 in varchar2,
3471 p_attribute18 in varchar2,
3472 p_attribute19 in varchar2,
3473 p_attribute20 in varchar2,
3474 p_attribute21 in varchar2,
3475 p_attribute22 in varchar2,
3476 p_attribute23 in varchar2,
3477 p_attribute24 in varchar2,
3478 p_attribute25 in varchar2,
3479 p_attribute26 in varchar2,
3480 p_attribute27 in varchar2,
3481 p_attribute28 in varchar2,
3482 p_attribute29 in varchar2,
3483 p_attribute30 in varchar2,
3484 p_fed_information_category in varchar2,
3485 p_fed_information1 in varchar2,
3486 p_fed_information2 in varchar2,
3487 p_fed_information3 in varchar2,
3488 p_fed_information4 in varchar2,
3489 p_fed_information5 in varchar2,
3490 p_fed_information6 in varchar2,
3491 p_fed_information7 in varchar2,
3492 p_fed_information8 in varchar2,
3493 p_fed_information9 in varchar2,
3494 p_fed_information10 in varchar2,
3495 p_fed_information11 in varchar2,
3496 p_fed_information12 in varchar2,
3497 p_fed_information13 in varchar2,
3498 p_fed_information14 in varchar2,
3499 p_fed_information15 in varchar2,
3500 p_fed_information16 in varchar2,
3501 p_fed_information17 in varchar2,
3502 p_fed_information18 in varchar2,
3503 p_fed_information19 in varchar2,
3504 p_fed_information20 in varchar2,
3505 p_fed_information21 in varchar2,
3506 p_fed_information22 in varchar2,
3507 p_fed_information23 in varchar2,
3508 p_fed_information24 in varchar2,
3509 p_fed_information25 in varchar2,
3510 p_fed_information26 in varchar2,
3511 p_fed_information27 in varchar2,
3512 p_fed_information28 in varchar2,
3513 p_fed_information29 in varchar2,
3514 p_fed_information30 in varchar2 ) is
3515
3516 cursor csr_asg_rec is
3517 select assignment_id
3518 from PER_ASSIGNMENTS_F
3519 where assignment_id = p_assignment_id
3520 and p_effective_start_date between effective_start_date
3521 and effective_end_date
3522 for update of assignment_id nowait;
3523
3524 cursor csr_fed_rec is
3525 select *
3526 from PAY_US_EMP_FED_TAX_RULES_F
3527 where rowid = chartorowid(p_row_id)
3528 for update of emp_fed_tax_rule_id nowait;
3529
3530 fed_rec csr_fed_rec%rowtype;
3531 l_assignment_id number(9);
3532
3533 begin
3534
3535 open csr_asg_rec;
3536
3537 fetch csr_asg_rec into l_assignment_id;
3538
3539 if csr_asg_rec%NOTFOUND then
3540 close csr_asg_rec;
3541 fnd_message.set_name('FND', 'FORM_UNABLE_TO_RESERVE_RECORD');
3542 fnd_message.raise_error;
3543 end if;
3544
3545 close csr_asg_rec;
3546
3547 open csr_fed_rec;
3548
3549 fetch csr_fed_rec into fed_rec;
3550
3551 if csr_fed_rec%NOTFOUND then
3552 close csr_fed_rec;
3553 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
3554 fnd_message.set_token('PROCEDURE',
3555 'pay_us_emp_dt_tax_rules.lock_fed_tax_row');
3556 fnd_message.set_token('STEP', '1');
3557 fnd_message.raise_error;
3558 end if;
3559
3560 close csr_fed_rec;
3561
3562 fed_rec.sui_state_code := rtrim(fed_rec.sui_state_code);
3563 fed_rec.sui_jurisdiction_code := rtrim(fed_rec.sui_jurisdiction_code);
3564 fed_rec.filing_status_code := rtrim(fed_rec.filing_status_code);
3565 fed_rec.cumulative_taxation := rtrim(fed_rec.cumulative_taxation);
3566 fed_rec.eic_filing_status_code := rtrim(fed_rec.eic_filing_status_code);
3567 fed_rec.fit_exempt := rtrim(fed_rec.fit_exempt);
3568 fed_rec.futa_tax_exempt := rtrim(fed_rec.futa_tax_exempt);
3569 fed_rec.medicare_tax_exempt := rtrim(fed_rec.medicare_tax_exempt);
3570 fed_rec.ss_tax_exempt := rtrim(fed_rec.ss_tax_exempt);
3571 fed_rec.wage_exempt := rtrim(fed_rec.wage_exempt);
3572 fed_rec.statutory_employee := rtrim(fed_rec.statutory_employee);
3573 fed_rec.attribute_category := rtrim(fed_rec.attribute_category);
3574 fed_rec.attribute1 := rtrim(fed_rec.attribute1);
3575 fed_rec.attribute2 := rtrim(fed_rec.attribute2);
3576 fed_rec.attribute3 := rtrim(fed_rec.attribute3);
3577 fed_rec.attribute4 := rtrim(fed_rec.attribute4);
3578 fed_rec.attribute5 := rtrim(fed_rec.attribute5);
3579 fed_rec.attribute6 := rtrim(fed_rec.attribute6);
3580 fed_rec.attribute7 := rtrim(fed_rec.attribute7);
3581 fed_rec.attribute8 := rtrim(fed_rec.attribute8);
3582 fed_rec.attribute9 := rtrim(fed_rec.attribute9);
3583 fed_rec.attribute10 := rtrim(fed_rec.attribute10);
3584 fed_rec.attribute11 := rtrim(fed_rec.attribute11);
3585 fed_rec.attribute12 := rtrim(fed_rec.attribute12);
3586 fed_rec.attribute13 := rtrim(fed_rec.attribute13);
3587 fed_rec.attribute14 := rtrim(fed_rec.attribute14);
3588 fed_rec.attribute15 := rtrim(fed_rec.attribute15);
3589 fed_rec.attribute16 := rtrim(fed_rec.attribute16);
3590 fed_rec.attribute17 := rtrim(fed_rec.attribute17);
3591 fed_rec.attribute18 := rtrim(fed_rec.attribute18);
3592 fed_rec.attribute19 := rtrim(fed_rec.attribute19);
3593 fed_rec.attribute20 := rtrim(fed_rec.attribute20);
3594 fed_rec.attribute21 := rtrim(fed_rec.attribute21);
3595 fed_rec.attribute22 := rtrim(fed_rec.attribute22);
3596 fed_rec.attribute23 := rtrim(fed_rec.attribute23);
3597 fed_rec.attribute24 := rtrim(fed_rec.attribute24);
3598 fed_rec.attribute25 := rtrim(fed_rec.attribute25);
3599 fed_rec.attribute26 := rtrim(fed_rec.attribute26);
3600 fed_rec.attribute27 := rtrim(fed_rec.attribute27);
3601 fed_rec.attribute28 := rtrim(fed_rec.attribute28);
3602 fed_rec.attribute29 := rtrim(fed_rec.attribute29);
3603 fed_rec.attribute30 := rtrim(fed_rec.attribute30);
3604 fed_rec.fed_information_category := rtrim(fed_rec.fed_information_category);
3605 fed_rec.fed_information1 := rtrim(fed_rec.fed_information1);
3606 fed_rec.fed_information2 := rtrim(fed_rec.fed_information2);
3607 fed_rec.fed_information3 := rtrim(fed_rec.fed_information3);
3608 fed_rec.fed_information4 := rtrim(fed_rec.fed_information4);
3609 fed_rec.fed_information5 := rtrim(fed_rec.fed_information5);
3610 fed_rec.fed_information6 := rtrim(fed_rec.fed_information6);
3611 fed_rec.fed_information7 := rtrim(fed_rec.fed_information7);
3612 fed_rec.fed_information8 := rtrim(fed_rec.fed_information8);
3613 fed_rec.fed_information9 := rtrim(fed_rec.fed_information9);
3614 fed_rec.fed_information10 := rtrim(fed_rec.fed_information10);
3615 fed_rec.fed_information11 := rtrim(fed_rec.fed_information11);
3616 fed_rec.fed_information12 := rtrim(fed_rec.fed_information12);
3617 fed_rec.fed_information13 := rtrim(fed_rec.fed_information13);
3618 fed_rec.fed_information14 := rtrim(fed_rec.fed_information14);
3619 fed_rec.fed_information15 := rtrim(fed_rec.fed_information15);
3620 fed_rec.fed_information16 := rtrim(fed_rec.fed_information16);
3621 fed_rec.fed_information17 := rtrim(fed_rec.fed_information17);
3622 fed_rec.fed_information18 := rtrim(fed_rec.fed_information18);
3623 fed_rec.fed_information19 := rtrim(fed_rec.fed_information19);
3624 fed_rec.fed_information20 := rtrim(fed_rec.fed_information20);
3625 fed_rec.fed_information21 := rtrim(fed_rec.fed_information21);
3626 fed_rec.fed_information22 := rtrim(fed_rec.fed_information22);
3627 fed_rec.fed_information23 := rtrim(fed_rec.fed_information23);
3628 fed_rec.fed_information24 := rtrim(fed_rec.fed_information24);
3629 fed_rec.fed_information25 := rtrim(fed_rec.fed_information25);
3630 fed_rec.fed_information26 := rtrim(fed_rec.fed_information26);
3631 fed_rec.fed_information27 := rtrim(fed_rec.fed_information27);
3632 fed_rec.fed_information28 := rtrim(fed_rec.fed_information28);
3633 fed_rec.fed_information29 := rtrim(fed_rec.fed_information29);
3634 fed_rec.fed_information30 := rtrim(fed_rec.fed_information30);
3635
3636
3637 if ((fed_rec.emp_fed_tax_rule_id = p_emp_fed_tax_rule_id)
3638 or (fed_rec.emp_fed_tax_rule_id is null and
3639 p_emp_fed_tax_rule_id is null))
3640 and ((fed_rec.effective_start_date = p_effective_start_date)
3641 or (fed_rec.effective_start_date is null and
3642 p_effective_start_date is null))
3643 and ((fed_rec.effective_end_date = p_effective_end_date)
3644 or (fed_rec.effective_end_date is null and
3645 p_effective_end_date is null))
3646 and ((fed_rec.assignment_id = p_assignment_id)
3647 or (fed_rec.assignment_id is null and
3648 p_assignment_id is null))
3649 and ((fed_rec.sui_state_code = p_sui_state_code)
3650 or (fed_rec.sui_state_code is null and
3651 p_sui_state_code is null))
3652 and ((fed_rec.sui_jurisdiction_code = p_sui_jurisdiction_code)
3653 or (fed_rec.sui_jurisdiction_code is null and
3654 p_sui_jurisdiction_code is null))
3655 and ((fed_rec.business_group_id = p_business_group_id)
3656 or (fed_rec.business_group_id is null and
3657 p_business_group_id is null))
3658 and ((fed_rec.additional_wa_amount = p_additional_wa_amount)
3659 or (fed_rec.additional_wa_amount is null and
3660 p_additional_wa_amount is null))
3661 and ((fed_rec.filing_status_code = lpad(p_filing_status_code,2,'0'))
3662 or (fed_rec.filing_status_code is null and
3663 p_filing_status_code is null))
3664 and ((fed_rec.fit_override_amount = p_fit_override_amount)
3665 or (fed_rec.fit_override_amount is null and
3666 p_fit_override_amount is null))
3667 and ((fed_rec.fit_override_rate = p_fit_override_rate)
3668 or (fed_rec.fit_override_rate is null and
3669 p_fit_override_rate is null))
3670 and ((fed_rec.withholding_allowances = p_withholding_allowances)
3671 or (fed_rec.withholding_allowances is null and
3672 p_withholding_allowances is null))
3673 and ((fed_rec.cumulative_taxation = p_cumulative_taxation)
3674 or (fed_rec.cumulative_taxation is null and
3675 p_cumulative_taxation is null))
3676 and ((fed_rec.eic_filing_status_code = p_eic_filing_status_code)
3677 or (fed_rec.eic_filing_status_code is null and
3678 p_eic_filing_status_code is null))
3679 and ((fed_rec.fit_additional_tax = p_fit_additional_tax)
3680 or (fed_rec.fit_additional_tax is null and
3681 p_fit_additional_tax is null))
3682 and ((fed_rec.fit_exempt = p_fit_exempt)
3683 or (fed_rec.fit_exempt is null and
3684 p_fit_exempt is null))
3685 and ((fed_rec.futa_tax_exempt = p_futa_tax_exempt)
3686 or (fed_rec.futa_tax_exempt is null and
3687 p_futa_tax_exempt is null))
3688 and ((fed_rec.medicare_tax_exempt = p_medicare_tax_exempt)
3689 or (fed_rec.medicare_tax_exempt is null and
3690 p_medicare_tax_exempt is null))
3691 and ((fed_rec.ss_tax_exempt = p_ss_tax_exempt)
3692 or (fed_rec.ss_tax_exempt is null and
3693 p_ss_tax_exempt is null))
3694 and ((fed_rec.wage_exempt = p_wage_exempt)
3695 or (fed_rec.wage_exempt is null and
3696 p_wage_exempt is null))
3697 and ((fed_rec.statutory_employee = p_statutory_employee)
3698 or (fed_rec.statutory_employee is null and
3699 p_statutory_employee is null))
3700 and ((fed_rec.w2_filed_year = p_w2_filed_year)
3701 or (fed_rec.w2_filed_year is null and
3702 p_w2_filed_year is null))
3703 and ((fed_rec.supp_tax_override_rate = p_supp_tax_override_rate)
3704 or (fed_rec.supp_tax_override_rate is null and
3705 p_supp_tax_override_rate is null))
3706 and ((fed_rec.excessive_wa_reject_date = p_excessive_wa_reject_date)
3707 or (fed_rec.excessive_wa_reject_date is null and
3708 p_excessive_wa_reject_date is null))
3709 and ((fed_rec.attribute_category = p_attribute_category)
3710 or (fed_rec.attribute_category is null and
3711 p_attribute_category is null))
3712 and ((fed_rec.attribute1 = p_attribute1)
3713 or (fed_rec.attribute1 is null and
3714 p_attribute1 is null))
3715 and ((fed_rec.attribute2 = p_attribute2)
3716 or (fed_rec.attribute2 is null and
3717 p_attribute2 is null))
3718 and ((fed_rec.attribute3 = p_attribute3)
3719 or (fed_rec.attribute3 is null and
3720 p_attribute3 is null))
3721 and ((fed_rec.attribute4 = p_attribute4)
3722 or (fed_rec.attribute4 is null and
3723 p_attribute4 is null))
3724 and ((fed_rec.attribute5 = p_attribute5)
3725 or (fed_rec.attribute5 is null and
3726 p_attribute5 is null))
3727 and ((fed_rec.attribute6 = p_attribute6)
3728 or (fed_rec.attribute6 is null and
3729 p_attribute6 is null))
3730 and ((fed_rec.attribute7 = p_attribute7)
3731 or (fed_rec.attribute7 is null and
3732 p_attribute7 is null))
3733 and ((fed_rec.attribute8 = p_attribute8)
3734 or (fed_rec.attribute8 is null and
3735 p_attribute8 is null))
3736 and ((fed_rec.attribute9 = p_attribute9)
3737 or (fed_rec.attribute9 is null and
3738 p_attribute9 is null))
3739 and ((fed_rec.attribute10 = p_attribute10)
3740 or (fed_rec.attribute10 is null and
3741 p_attribute10 is null))
3742 and ((fed_rec.attribute11 = p_attribute11)
3743 or (fed_rec.attribute11 is null and
3744 p_attribute11 is null))
3745 and ((fed_rec.attribute12 = p_attribute12)
3746 or (fed_rec.attribute12 is null and
3747 p_attribute12 is null))
3748 and ((fed_rec.attribute13 = p_attribute13)
3749 or (fed_rec.attribute13 is null and
3750 p_attribute13 is null))
3751 and ((fed_rec.attribute14 = p_attribute14)
3752 or (fed_rec.attribute14 is null and
3753 p_attribute14 is null))
3754 and ((fed_rec.attribute15 = p_attribute15)
3755 or (fed_rec.attribute15 is null and
3756 p_attribute15 is null))
3757 and ((fed_rec.attribute16 = p_attribute16)
3758 or (fed_rec.attribute16 is null and
3759 p_attribute16 is null))
3760 and ((fed_rec.attribute17 = p_attribute17)
3761 or (fed_rec.attribute17 is null and
3762 p_attribute17 is null))
3763 and ((fed_rec.attribute18 = p_attribute18)
3764 or (fed_rec.attribute18 is null and
3765 p_attribute18 is null))
3766 and ((fed_rec.attribute19 = p_attribute19)
3767 or (fed_rec.attribute19 is null and
3768 p_attribute19 is null))
3769 and ((fed_rec.attribute20 = p_attribute20)
3770 or (fed_rec.attribute20 is null and
3771 p_attribute20 is null))
3772 and ((fed_rec.attribute21 = p_attribute21)
3773 or (fed_rec.attribute21 is null and
3774 p_attribute21 is null))
3775 and ((fed_rec.attribute22 = p_attribute22)
3776 or (fed_rec.attribute22 is null and
3777 p_attribute22 is null))
3778 and ((fed_rec.attribute23 = p_attribute23)
3779 or (fed_rec.attribute23 is null and
3780 p_attribute23 is null))
3781 and ((fed_rec.attribute24 = p_attribute24)
3782 or (fed_rec.attribute24 is null and
3783 p_attribute24 is null))
3784 and ((fed_rec.attribute25 = p_attribute25)
3785 or (fed_rec.attribute25 is null and
3786 p_attribute25 is null))
3787 and ((fed_rec.attribute26 = p_attribute26)
3788 or (fed_rec.attribute26 is null and
3789 p_attribute26 is null))
3790 and ((fed_rec.attribute27 = p_attribute27)
3791 or (fed_rec.attribute27 is null and
3792 p_attribute27 is null))
3793 and ((fed_rec.attribute28 = p_attribute28)
3794 or (fed_rec.attribute28 is null and
3795 p_attribute28 is null))
3796 and ((fed_rec.attribute29 = p_attribute29)
3797 or (fed_rec.attribute29 is null and
3798 p_attribute29 is null))
3799 and ((fed_rec.attribute30 = p_attribute30)
3800 or (fed_rec.attribute30 is null and
3801 p_attribute30 is null))
3802 and ((fed_rec.fed_information_category = p_fed_information_category)
3803 or (fed_rec.fed_information_category is null and
3804 p_fed_information_category is null))
3805 and ((fed_rec.fed_information1 = p_fed_information1)
3806 or (fed_rec.fed_information1 is null and
3807 p_fed_information1 is null))
3808 and ((fed_rec.fed_information2 = p_fed_information2)
3809 or (fed_rec.fed_information2 is null and
3810 p_fed_information2 is null))
3811 and ((fed_rec.fed_information3 = p_fed_information3)
3812 or (fed_rec.fed_information3 is null and
3813 p_fed_information3 is null))
3814 and ((fed_rec.fed_information4 = p_fed_information4)
3815 or (fed_rec.fed_information4 is null and
3816 p_fed_information4 is null))
3817 and ((fed_rec.fed_information5 = p_fed_information5)
3818 or (fed_rec.fed_information5 is null and
3819 p_fed_information5 is null))
3820 and ((fed_rec.fed_information6 = p_fed_information6)
3821 or (fed_rec.fed_information6 is null and
3822 p_fed_information6 is null))
3823 and ((fed_rec.fed_information7 = p_fed_information7)
3824 or (fed_rec.fed_information7 is null and
3825 p_fed_information7 is null))
3826 and ((fed_rec.fed_information8 = p_fed_information8)
3827 or (fed_rec.fed_information8 is null and
3828 p_fed_information8 is null))
3829 and ((fed_rec.fed_information9 = p_fed_information9)
3830 or (fed_rec.fed_information9 is null and
3831 p_fed_information9 is null))
3832 and ((fed_rec.fed_information10 = p_fed_information10)
3833 or (fed_rec.fed_information10 is null and
3834 p_fed_information10 is null))
3835 and ((fed_rec.fed_information11 = p_fed_information11)
3836 or (fed_rec.fed_information11 is null and
3837 p_fed_information11 is null))
3838 and ((fed_rec.fed_information12 = p_fed_information12)
3839 or (fed_rec.fed_information12 is null and
3840 p_fed_information12 is null))
3841 and ((fed_rec.fed_information13 = p_fed_information13)
3842 or (fed_rec.fed_information13 is null and
3843 p_fed_information13 is null))
3844 and ((fed_rec.fed_information14 = p_fed_information14)
3845 or (fed_rec.fed_information14 is null and
3846 p_fed_information14 is null))
3847 and ((fed_rec.fed_information15 = p_fed_information15)
3848 or (fed_rec.fed_information15 is null and
3849 p_fed_information15 is null))
3850 and ((fed_rec.fed_information16 = p_fed_information16)
3851 or (fed_rec.fed_information16 is null and
3852 p_fed_information16 is null))
3853 and ((fed_rec.fed_information17 = p_fed_information17)
3854 or (fed_rec.fed_information17 is null and
3855 p_fed_information17 is null))
3856 and ((fed_rec.fed_information18 = p_fed_information18)
3857 or (fed_rec.fed_information18 is null and
3858 p_fed_information18 is null))
3859 and ((fed_rec.fed_information19 = p_fed_information19)
3860 or (fed_rec.fed_information19 is null and
3861 p_fed_information19 is null))
3862 and ((fed_rec.fed_information20 = p_fed_information20)
3863 or (fed_rec.fed_information20 is null and
3864 p_fed_information20 is null))
3865 and ((fed_rec.fed_information21 = p_fed_information21)
3866 or (fed_rec.fed_information21 is null and
3867 p_fed_information21 is null))
3868 and ((fed_rec.fed_information22 = p_fed_information22)
3869 or (fed_rec.fed_information22 is null and
3870 p_fed_information22 is null))
3871 and ((fed_rec.fed_information23 = p_fed_information23)
3872 or (fed_rec.fed_information23 is null and
3873 p_fed_information23 is null))
3874 and ((fed_rec.fed_information24 = p_fed_information24)
3875 or (fed_rec.fed_information24 is null and
3876 p_fed_information24 is null))
3877 and ((fed_rec.fed_information25 = p_fed_information25)
3878 or (fed_rec.fed_information25 is null and
3879 p_fed_information25 is null))
3880 and ((fed_rec.fed_information26 = p_fed_information26)
3881 or (fed_rec.fed_information26 is null and
3882 p_fed_information26 is null))
3883 and ((fed_rec.fed_information27 = p_fed_information27)
3884 or (fed_rec.fed_information27 is null and
3885 p_fed_information27 is null))
3886 and ((fed_rec.fed_information28 = p_fed_information28)
3887 or (fed_rec.fed_information28 is null and
3888 p_fed_information28 is null))
3889 and ((fed_rec.fed_information29 = p_fed_information29)
3890 or (fed_rec.fed_information29 is null and
3891 p_fed_information29 is null))
3892 and ((fed_rec.fed_information30 = p_fed_information30)
3893 or (fed_rec.fed_information30 is null and
3894 p_fed_information30 is null))
3895 then
3896
3897 return;
3898
3899 else
3900
3901 fnd_message.set_name('PAY', 'FORM_RECORD_CHANGED');
3902 fnd_message.raise_error;
3903
3904 end if;
3905
3906 end lock_fed_tax_row;
3907
3908
3909
3910 /* Name : lock_state_tax_row
3911 Purpose : To lock the state tax rule record.
3912 */
3913
3914 procedure lock_state_tax_row ( p_row_id in varchar2,
3915 p_emp_state_tax_rule_id in number,
3916 p_effective_start_date in date,
3917 p_effective_end_date in date,
3918 p_assignment_id in number,
3919 p_state_code in varchar2,
3920 p_jurisdiction_code in varchar2,
3921 p_business_group_id in number,
3922 p_additional_wa_amount in number,
3923 p_filing_status_code in varchar2,
3924 p_remainder_percent in number,
3925 p_secondary_wa in number,
3926 p_sit_additional_tax in number,
3927 p_sit_override_amount in number,
3928 p_sit_override_rate in number,
3929 p_withholding_allowances in number,
3930 p_excessive_wa_reject_date in date,
3931 p_sdi_exempt in varchar2,
3932 p_sit_exempt in varchar2,
3933 p_sit_optional_calc_ind in varchar2,
3934 p_state_non_resident_cert in varchar2,
3935 p_sui_exempt in varchar2,
3936 p_wc_exempt in varchar2,
3937 p_wage_exempt in varchar2,
3938 p_sui_wage_base_override_amt in number,
3939 p_supp_tax_override_rate in number,
3940 p_attribute_category in varchar2,
3941 p_attribute1 in varchar2,
3942 p_attribute2 in varchar2,
3943 p_attribute3 in varchar2,
3944 p_attribute4 in varchar2,
3945 p_attribute5 in varchar2,
3946 p_attribute6 in varchar2,
3947 p_attribute7 in varchar2,
3948 p_attribute8 in varchar2,
3949 p_attribute9 in varchar2,
3950 p_attribute10 in varchar2,
3951 p_attribute11 in varchar2,
3952 p_attribute12 in varchar2,
3953 p_attribute13 in varchar2,
3954 p_attribute14 in varchar2,
3955 p_attribute15 in varchar2,
3956 p_attribute16 in varchar2,
3957 p_attribute17 in varchar2,
3958 p_attribute18 in varchar2,
3959 p_attribute19 in varchar2,
3960 p_attribute20 in varchar2,
3961 p_attribute21 in varchar2,
3962 p_attribute22 in varchar2,
3963 p_attribute23 in varchar2,
3964 p_attribute24 in varchar2,
3965 p_attribute25 in varchar2,
3966 p_attribute26 in varchar2,
3967 p_attribute27 in varchar2,
3968 p_attribute28 in varchar2,
3969 p_attribute29 in varchar2,
3970 p_attribute30 in varchar2,
3971 p_sta_information_category in varchar2,
3972 p_sta_information1 in varchar2,
3973 p_sta_information2 in varchar2,
3974 p_sta_information3 in varchar2,
3975 p_sta_information4 in varchar2,
3976 p_sta_information5 in varchar2,
3977 p_sta_information6 in varchar2,
3978 p_sta_information7 in varchar2,
3979 p_sta_information8 in varchar2,
3980 p_sta_information9 in varchar2,
3981 p_sta_information10 in varchar2,
3982 p_sta_information11 in varchar2,
3983 p_sta_information12 in varchar2,
3984 p_sta_information13 in varchar2,
3985 p_sta_information14 in varchar2,
3986 p_sta_information15 in varchar2,
3987 p_sta_information16 in varchar2,
3988 p_sta_information17 in varchar2,
3989 p_sta_information18 in varchar2,
3990 p_sta_information19 in varchar2,
3991 p_sta_information20 in varchar2,
3992 p_sta_information21 in varchar2,
3993 p_sta_information22 in varchar2,
3994 p_sta_information23 in varchar2,
3995 p_sta_information24 in varchar2,
3996 p_sta_information25 in varchar2,
3997 p_sta_information26 in varchar2,
3998 p_sta_information27 in varchar2,
3999 p_sta_information28 in varchar2,
4000 p_sta_information29 in varchar2,
4001 p_sta_information30 in varchar2 ) is
4002
4003 cursor csr_asg_rec is
4004 select assignment_id
4005 from PER_ASSIGNMENTS_F
4006 where assignment_id = p_assignment_id
4007 and p_effective_start_date between effective_start_date
4008 and effective_end_date
4009 for update of assignment_id nowait;
4010
4011 cursor csr_state_rec is
4012 select *
4013 from PAY_US_EMP_STATE_TAX_RULES_F
4014 where rowid = chartorowid(p_row_id)
4015 for update of emp_state_tax_rule_id nowait;
4016
4017 state_rec csr_state_rec%rowtype;
4018 l_assignment_id number(9);
4019
4020 begin
4021
4022 open csr_asg_rec;
4023
4024 fetch csr_asg_rec into l_assignment_id;
4025
4026 if csr_asg_rec%NOTFOUND then
4027 close csr_asg_rec;
4028 fnd_message.set_name('FND', 'FORM_UNABLE_TO_RESERVE_RECORD');
4029 fnd_message.raise_error;
4030 end if;
4031
4032 close csr_asg_rec;
4033
4034 open csr_state_rec;
4035
4036 fetch csr_state_rec into state_rec;
4037
4038 if csr_state_rec%NOTFOUND then
4039 close csr_state_rec;
4040 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
4041 fnd_message.set_token('PROCEDURE',
4042 'pay_us_emp_dt_tax_rules.lock_state_tax_row');
4043 fnd_message.set_token('STEP', '1');
4044 fnd_message.raise_error;
4045 end if;
4046
4047 close csr_state_rec;
4048
4049 state_rec.state_code := rtrim(state_rec.state_code);
4050 state_rec.jurisdiction_code := rtrim(state_rec.jurisdiction_code);
4051 state_rec.filing_status_code := rtrim(state_rec.filing_status_code);
4052 state_rec.sdi_exempt := rtrim(state_rec.sdi_exempt);
4053 state_rec.sit_exempt := rtrim(state_rec.sit_exempt);
4054 state_rec.sit_optional_calc_ind := rtrim(state_rec.sit_optional_calc_ind);
4055 state_rec.state_non_resident_cert := rtrim(state_rec.state_non_resident_cert);
4056 state_rec.sui_exempt := rtrim(state_rec.sui_exempt);
4057 state_rec.wc_exempt := rtrim(state_rec.wc_exempt);
4058 state_rec.wage_exempt := rtrim(state_rec.wage_exempt);
4059 state_rec.attribute_category := rtrim(state_rec.attribute_category);
4060 state_rec.attribute1 := rtrim(state_rec.attribute1);
4061 state_rec.attribute2 := rtrim(state_rec.attribute2);
4062 state_rec.attribute3 := rtrim(state_rec.attribute3);
4063 state_rec.attribute4 := rtrim(state_rec.attribute4);
4064 state_rec.attribute5 := rtrim(state_rec.attribute5);
4065 state_rec.attribute6 := rtrim(state_rec.attribute6);
4066 state_rec.attribute7 := rtrim(state_rec.attribute7);
4067 state_rec.attribute8 := rtrim(state_rec.attribute8);
4068 state_rec.attribute9 := rtrim(state_rec.attribute9);
4069 state_rec.attribute10 := rtrim(state_rec.attribute10);
4070 state_rec.attribute11 := rtrim(state_rec.attribute11);
4071 state_rec.attribute12 := rtrim(state_rec.attribute12);
4072 state_rec.attribute13 := rtrim(state_rec.attribute13);
4073 state_rec.attribute14 := rtrim(state_rec.attribute14);
4074 state_rec.attribute15 := rtrim(state_rec.attribute15);
4075 state_rec.attribute16 := rtrim(state_rec.attribute16);
4076 state_rec.attribute17 := rtrim(state_rec.attribute17);
4077 state_rec.attribute18 := rtrim(state_rec.attribute18);
4078 state_rec.attribute19 := rtrim(state_rec.attribute19);
4079 state_rec.attribute20 := rtrim(state_rec.attribute20);
4080 state_rec.attribute21 := rtrim(state_rec.attribute21);
4081 state_rec.attribute22 := rtrim(state_rec.attribute22);
4082 state_rec.attribute23 := rtrim(state_rec.attribute23);
4083 state_rec.attribute24 := rtrim(state_rec.attribute24);
4084 state_rec.attribute25 := rtrim(state_rec.attribute25);
4085 state_rec.attribute26 := rtrim(state_rec.attribute26);
4086 state_rec.attribute27 := rtrim(state_rec.attribute27);
4087 state_rec.attribute28 := rtrim(state_rec.attribute28);
4088 state_rec.attribute29 := rtrim(state_rec.attribute29);
4089 state_rec.attribute30 := rtrim(state_rec.attribute30);
4090 state_rec.sta_information_category := rtrim(state_rec.sta_information_category);
4091 state_rec.sta_information1 := rtrim(state_rec.sta_information1);
4092 state_rec.sta_information2 := rtrim(state_rec.sta_information2);
4093 state_rec.sta_information3 := rtrim(state_rec.sta_information3);
4094 state_rec.sta_information4 := rtrim(state_rec.sta_information4);
4095 state_rec.sta_information5 := rtrim(state_rec.sta_information5);
4096 state_rec.sta_information6 := rtrim(state_rec.sta_information6);
4097 state_rec.sta_information7 := rtrim(state_rec.sta_information7);
4098 state_rec.sta_information8 := rtrim(state_rec.sta_information8);
4099 state_rec.sta_information9 := rtrim(state_rec.sta_information9);
4100 state_rec.sta_information10 := rtrim(state_rec.sta_information10);
4101 state_rec.sta_information11 := rtrim(state_rec.sta_information11);
4102 state_rec.sta_information12 := rtrim(state_rec.sta_information12);
4103 state_rec.sta_information13 := rtrim(state_rec.sta_information13);
4104 state_rec.sta_information14 := rtrim(state_rec.sta_information14);
4105 state_rec.sta_information15 := rtrim(state_rec.sta_information15);
4106 state_rec.sta_information16 := rtrim(state_rec.sta_information16);
4107 state_rec.sta_information17 := rtrim(state_rec.sta_information17);
4108 state_rec.sta_information18 := rtrim(state_rec.sta_information18);
4109 state_rec.sta_information19 := rtrim(state_rec.sta_information19);
4110 state_rec.sta_information20 := rtrim(state_rec.sta_information20);
4111 state_rec.sta_information21 := rtrim(state_rec.sta_information21);
4112 state_rec.sta_information22 := rtrim(state_rec.sta_information22);
4113 state_rec.sta_information23 := rtrim(state_rec.sta_information23);
4114 state_rec.sta_information24 := rtrim(state_rec.sta_information24);
4115 state_rec.sta_information25 := rtrim(state_rec.sta_information25);
4116 state_rec.sta_information26 := rtrim(state_rec.sta_information26);
4117 state_rec.sta_information27 := rtrim(state_rec.sta_information27);
4118 state_rec.sta_information28 := rtrim(state_rec.sta_information28);
4119 state_rec.sta_information29 := rtrim(state_rec.sta_information29);
4120 state_rec.sta_information30 := rtrim(state_rec.sta_information30);
4121
4122 if ((state_rec.emp_state_tax_rule_id = p_emp_state_tax_rule_id)
4123 or (state_rec.emp_state_tax_rule_id is null and
4124 p_emp_state_tax_rule_id is null))
4125 and ((state_rec.effective_start_date = p_effective_start_date)
4126 or (state_rec.effective_start_date is null and
4127 p_effective_start_date is null))
4128 and ((state_rec.effective_end_date = p_effective_end_date)
4129 or (state_rec.effective_end_date is null and
4130 p_effective_end_date is null))
4131 and ((state_rec.assignment_id = p_assignment_id)
4132 or (state_rec.assignment_id is null and
4133 p_assignment_id is null))
4134 and ((state_rec.state_code = p_state_code)
4135 or (state_rec.state_code is null and
4136 p_state_code is null))
4137 and ((state_rec.jurisdiction_code = p_jurisdiction_code)
4138 or (state_rec.jurisdiction_code is null and
4139 p_jurisdiction_code is null))
4140 and ((state_rec.business_group_id = p_business_group_id)
4141 or (state_rec.business_group_id is null and
4142 p_business_group_id is null))
4143 and ((state_rec.additional_wa_amount = p_additional_wa_amount)
4144 or (state_rec.additional_wa_amount is null and
4145 p_additional_wa_amount is null))
4146 and ((state_rec.filing_status_code = lpad(p_filing_status_code,2,'0'))
4147 or (state_rec.filing_status_code is null and
4148 p_filing_status_code is null))
4149 and ((state_rec.remainder_percent = p_remainder_percent)
4150 or (state_rec.remainder_percent is null and
4151 p_remainder_percent is null))
4152 and ((state_rec.secondary_wa = p_secondary_wa)
4153 or (state_rec.secondary_wa is null and
4154 p_secondary_wa is null))
4155 and ((state_rec.sit_additional_tax = p_sit_additional_tax)
4156 or (state_rec.sit_additional_tax is null and
4157 p_sit_additional_tax is null))
4158 and ((state_rec.sit_override_amount = p_sit_override_amount)
4159 or (state_rec.sit_override_amount is null and
4160 p_sit_override_amount is null))
4161 and ((state_rec.sit_override_rate = p_sit_override_rate)
4162 or (state_rec.sit_override_rate is null and
4163 p_sit_override_rate is null))
4164 and ((state_rec.withholding_allowances = p_withholding_allowances)
4165 or (state_rec.withholding_allowances is null and
4166 p_withholding_allowances is null))
4167 and ((state_rec.excessive_wa_reject_date = p_excessive_wa_reject_date)
4168 or (state_rec.excessive_wa_reject_date is null and
4169 p_excessive_wa_reject_date is null))
4170 and ((state_rec.sdi_exempt = p_sdi_exempt)
4171 or (state_rec.sdi_exempt is null and
4172 p_sdi_exempt is null))
4173 and ((state_rec.sit_exempt = p_sit_exempt)
4174 or (state_rec.sit_exempt is null and
4175 p_sit_exempt is null))
4176 and ((state_rec.sit_optional_calc_ind = p_sit_optional_calc_ind)
4177 or (state_rec.sit_optional_calc_ind is null and
4178 p_sit_optional_calc_ind is null))
4179 and ((state_rec.state_non_resident_cert = p_state_non_resident_cert)
4180 or (state_rec.state_non_resident_cert is null and
4181 p_state_non_resident_cert is null))
4182 and ((state_rec.sui_exempt = p_sui_exempt)
4183 or (state_rec.sui_exempt is null and
4184 p_sui_exempt is null))
4185 and ((state_rec.wc_exempt = p_wc_exempt)
4186 or (state_rec.wc_exempt is null and
4187 p_wc_exempt is null))
4188 and ((state_rec.wage_exempt = p_wage_exempt)
4189 or (state_rec.wage_exempt is null and
4190 p_wage_exempt is null))
4191 and ((state_rec.sui_wage_base_override_amount = p_sui_wage_base_override_amt)
4192 or (state_rec.sui_wage_base_override_amount is null and
4193 p_sui_wage_base_override_amt is null))
4194 and ((state_rec.supp_tax_override_rate = p_supp_tax_override_rate)
4195 or (state_rec.supp_tax_override_rate is null and
4196 p_supp_tax_override_rate is null))
4197 and ((state_rec.attribute_category = p_attribute_category)
4198 or (state_rec.attribute_category is null and
4199 p_attribute_category is null))
4200 and ((state_rec.attribute1 = p_attribute1)
4201 or (state_rec.attribute1 is null and
4202 p_attribute1 is null))
4203 and ((state_rec.attribute2 = p_attribute2)
4204 or (state_rec.attribute2 is null and
4205 p_attribute2 is null))
4206 and ((state_rec.attribute3 = p_attribute3)
4207 or (state_rec.attribute3 is null and
4208 p_attribute3 is null))
4209 and ((state_rec.attribute4 = p_attribute4)
4210 or (state_rec.attribute4 is null and
4211 p_attribute4 is null))
4212 and ((state_rec.attribute5 = p_attribute5)
4213 or (state_rec.attribute5 is null and
4214 p_attribute5 is null))
4215 and ((state_rec.attribute6 = p_attribute6)
4216 or (state_rec.attribute6 is null and
4217 p_attribute6 is null))
4218 and ((state_rec.attribute7 = p_attribute7)
4219 or (state_rec.attribute7 is null and
4220 p_attribute7 is null))
4221 and ((state_rec.attribute8 = p_attribute8)
4222 or (state_rec.attribute8 is null and
4223 p_attribute8 is null))
4224 and ((state_rec.attribute9 = p_attribute9)
4225 or (state_rec.attribute9 is null and
4226 p_attribute9 is null))
4227 and ((state_rec.attribute10 = p_attribute10)
4228 or (state_rec.attribute10 is null and
4229 p_attribute10 is null))
4230 and ((state_rec.attribute11 = p_attribute11)
4231 or (state_rec.attribute11 is null and
4232 p_attribute11 is null))
4233 and ((state_rec.attribute12 = p_attribute12)
4234 or (state_rec.attribute12 is null and
4235 p_attribute12 is null))
4236 and ((state_rec.attribute13 = p_attribute13)
4237 or (state_rec.attribute13 is null and
4238 p_attribute13 is null))
4239 and ((state_rec.attribute14 = p_attribute14)
4240 or (state_rec.attribute14 is null and
4241 p_attribute14 is null))
4242 and ((state_rec.attribute15 = p_attribute15)
4243 or (state_rec.attribute15 is null and
4244 p_attribute15 is null))
4245 and ((state_rec.attribute16 = p_attribute16)
4246 or (state_rec.attribute16 is null and
4247 p_attribute16 is null))
4248 and ((state_rec.attribute17 = p_attribute17)
4249 or (state_rec.attribute17 is null and
4250 p_attribute17 is null))
4251 and ((state_rec.attribute18 = p_attribute18)
4252 or (state_rec.attribute18 is null and
4253 p_attribute18 is null))
4254 and ((state_rec.attribute19 = p_attribute19)
4255 or (state_rec.attribute19 is null and
4256 p_attribute19 is null))
4257 and ((state_rec.attribute20 = p_attribute20)
4258 or (state_rec.attribute20 is null and
4259 p_attribute20 is null))
4260 and ((state_rec.attribute21 = p_attribute21)
4261 or (state_rec.attribute21 is null and
4262 p_attribute21 is null))
4263 and ((state_rec.attribute22 = p_attribute22)
4264 or (state_rec.attribute22 is null and
4265 p_attribute22 is null))
4266 and ((state_rec.attribute23 = p_attribute23)
4267 or (state_rec.attribute23 is null and
4268 p_attribute23 is null))
4269 and ((state_rec.attribute24 = p_attribute24)
4270 or (state_rec.attribute24 is null and
4271 p_attribute24 is null))
4272 and ((state_rec.attribute25 = p_attribute25)
4273 or (state_rec.attribute25 is null and
4274 p_attribute25 is null))
4275 and ((state_rec.attribute26 = p_attribute26)
4276 or (state_rec.attribute26 is null and
4277 p_attribute26 is null))
4278 and ((state_rec.attribute27 = p_attribute27)
4279 or (state_rec.attribute27 is null and
4280 p_attribute27 is null))
4281 and ((state_rec.attribute28 = p_attribute28)
4282 or (state_rec.attribute28 is null and
4283 p_attribute28 is null))
4284 and ((state_rec.attribute29 = p_attribute29)
4285 or (state_rec.attribute29 is null and
4286 p_attribute29 is null))
4287 and ((state_rec.attribute30 = p_attribute30)
4288 or (state_rec.attribute30 is null and
4289 p_attribute30 is null))
4290 and ((state_rec.sta_information_category = p_sta_information_category)
4291 or (state_rec.sta_information_category is null and
4292 p_sta_information_category is null))
4293 and ((state_rec.sta_information1 = p_sta_information1)
4294 or (state_rec.sta_information1 is null and
4295 p_sta_information1 is null))
4296 and ((state_rec.sta_information2 = p_sta_information2)
4297 or (state_rec.sta_information2 is null and
4298 p_sta_information2 is null))
4299 and ((state_rec.sta_information3 = p_sta_information3)
4300 or (state_rec.sta_information3 is null and
4301 p_sta_information3 is null))
4302 and ((state_rec.sta_information4 = p_sta_information4)
4303 or (state_rec.sta_information4 is null and
4304 p_sta_information4 is null))
4305 and ((state_rec.sta_information5 = p_sta_information5)
4306 or (state_rec.sta_information5 is null and
4307 p_sta_information5 is null))
4308 and ((state_rec.sta_information6 = p_sta_information6)
4309 or (state_rec.sta_information6 is null and
4310 p_sta_information6 is null))
4311 and ((state_rec.sta_information7 = p_sta_information7)
4312 or (state_rec.sta_information7 is null and
4313 p_sta_information7 is null))
4314 and ((state_rec.sta_information8 = p_sta_information8)
4315 or (state_rec.sta_information8 is null and
4316 p_sta_information8 is null))
4317 and ((state_rec.sta_information9 = p_sta_information9)
4318 or (state_rec.sta_information9 is null and
4319 p_sta_information9 is null))
4320 and ((state_rec.sta_information10 = p_sta_information10)
4321 or (state_rec.sta_information10 is null and
4322 p_sta_information10 is null))
4323 and ((state_rec.sta_information11 = p_sta_information11)
4324 or (state_rec.sta_information11 is null and
4325 p_sta_information11 is null))
4326 and ((state_rec.sta_information12 = p_sta_information12)
4327 or (state_rec.sta_information12 is null and
4328 p_sta_information12 is null))
4329 and ((state_rec.sta_information13 = p_sta_information13)
4330 or (state_rec.sta_information13 is null and
4331 p_sta_information13 is null))
4332 and ((state_rec.sta_information14 = p_sta_information14)
4333 or (state_rec.sta_information14 is null and
4334 p_sta_information14 is null))
4335 and ((state_rec.sta_information15 = p_sta_information15)
4336 or (state_rec.sta_information15 is null and
4337 p_sta_information15 is null))
4338 and ((state_rec.sta_information16 = p_sta_information16)
4339 or (state_rec.sta_information16 is null and
4340 p_sta_information16 is null))
4341 and ((state_rec.sta_information17 = p_sta_information17)
4342 or (state_rec.sta_information17 is null and
4343 p_sta_information17 is null))
4344 and ((state_rec.sta_information18 = p_sta_information18)
4345 or (state_rec.sta_information18 is null and
4346 p_sta_information18 is null))
4347 and ((state_rec.sta_information19 = p_sta_information19)
4348 or (state_rec.sta_information19 is null and
4349 p_sta_information19 is null))
4350 and ((state_rec.sta_information20 = p_sta_information20)
4351 or (state_rec.sta_information20 is null and
4352 p_sta_information20 is null))
4353 and ((state_rec.sta_information21 = p_sta_information21)
4354 or (state_rec.sta_information21 is null and
4355 p_sta_information21 is null))
4356 and ((state_rec.sta_information22 = p_sta_information22)
4357 or (state_rec.sta_information22 is null and
4358 p_sta_information22 is null))
4359 and ((state_rec.sta_information23 = p_sta_information23)
4360 or (state_rec.sta_information23 is null and
4361 p_sta_information23 is null))
4362 and ((state_rec.sta_information24 = p_sta_information24)
4363 or (state_rec.sta_information24 is null and
4364 p_sta_information24 is null))
4365 and ((state_rec.sta_information25 = p_sta_information25)
4366 or (state_rec.sta_information25 is null and
4367 p_sta_information25 is null))
4368 and ((state_rec.sta_information26 = p_sta_information26)
4369 or (state_rec.sta_information26 is null and
4370 p_sta_information26 is null))
4371 and ((state_rec.sta_information27 = p_sta_information27)
4372 or (state_rec.sta_information27 is null and
4373 p_sta_information27 is null))
4374 and ((state_rec.sta_information28 = p_sta_information28)
4375 or (state_rec.sta_information28 is null and
4376 p_sta_information28 is null))
4377 and ((state_rec.sta_information29 = p_sta_information29)
4378 or (state_rec.sta_information29 is null and
4379 p_sta_information29 is null))
4380 and ((state_rec.sta_information30 = p_sta_information30)
4381 or (state_rec.sta_information30 is null and
4382 p_sta_information30 is null))
4383 then
4384
4385 return;
4386
4387 else
4388
4389 fnd_message.set_name('PAY', 'FORM_RECORD_CHANGED');
4390 fnd_message.raise_error;
4391
4392 end if;
4393
4394 end lock_state_tax_row;
4395
4396
4397 /* Name : lock_county_tax_row
4398 Purpose : To lock the county tax rule record.
4399 */
4400
4401 procedure lock_county_tax_row ( p_row_id in varchar2,
4402 p_emp_county_tax_rule_id in number,
4403 p_effective_start_date in date,
4404 p_effective_end_date in date,
4405 p_assignment_id in number,
4406 p_state_code in varchar2,
4407 p_county_code in varchar2,
4408 p_business_group_id in number,
4409 p_additional_wa_rate in number,
4410 p_filing_status_code in varchar2,
4411 p_jurisdiction_code in varchar2,
4412 p_lit_additional_tax in number,
4413 p_lit_override_amount in number,
4414 p_lit_override_rate in number,
4415 p_withholding_allowances in number,
4416 p_lit_exempt in varchar2,
4417 p_sd_exempt in varchar2,
4418 p_ht_exempt in varchar2,
4419 p_wage_exempt in varchar2,
4420 p_school_district_code in varchar2,
4421 p_attribute_category in varchar2,
4422 p_attribute1 in varchar2,
4423 p_attribute2 in varchar2,
4424 p_attribute3 in varchar2,
4425 p_attribute4 in varchar2,
4426 p_attribute5 in varchar2,
4427 p_attribute6 in varchar2,
4428 p_attribute7 in varchar2,
4429 p_attribute8 in varchar2,
4430 p_attribute9 in varchar2,
4431 p_attribute10 in varchar2,
4432 p_attribute11 in varchar2,
4433 p_attribute12 in varchar2,
4434 p_attribute13 in varchar2,
4435 p_attribute14 in varchar2,
4436 p_attribute15 in varchar2,
4437 p_attribute16 in varchar2,
4438 p_attribute17 in varchar2,
4439 p_attribute18 in varchar2,
4440 p_attribute19 in varchar2,
4441 p_attribute20 in varchar2,
4442 p_attribute21 in varchar2,
4443 p_attribute22 in varchar2,
4444 p_attribute23 in varchar2,
4445 p_attribute24 in varchar2,
4446 p_attribute25 in varchar2,
4447 p_attribute26 in varchar2,
4448 p_attribute27 in varchar2,
4449 p_attribute28 in varchar2,
4450 p_attribute29 in varchar2,
4451 p_attribute30 in varchar2,
4452 p_cnt_information_category in varchar2,
4453 p_cnt_information1 in varchar2,
4454 p_cnt_information2 in varchar2,
4455 p_cnt_information3 in varchar2,
4456 p_cnt_information4 in varchar2,
4457 p_cnt_information5 in varchar2,
4458 p_cnt_information6 in varchar2,
4459 p_cnt_information7 in varchar2,
4460 p_cnt_information8 in varchar2,
4461 p_cnt_information9 in varchar2,
4462 p_cnt_information10 in varchar2,
4463 p_cnt_information11 in varchar2,
4464 p_cnt_information12 in varchar2,
4465 p_cnt_information13 in varchar2,
4466 p_cnt_information14 in varchar2,
4467 p_cnt_information15 in varchar2,
4468 p_cnt_information16 in varchar2,
4469 p_cnt_information17 in varchar2,
4470 p_cnt_information18 in varchar2,
4471 p_cnt_information19 in varchar2,
4472 p_cnt_information20 in varchar2,
4473 p_cnt_information21 in varchar2,
4474 p_cnt_information22 in varchar2,
4475 p_cnt_information23 in varchar2,
4476 p_cnt_information24 in varchar2,
4477 p_cnt_information25 in varchar2,
4478 p_cnt_information26 in varchar2,
4479 p_cnt_information27 in varchar2,
4480 p_cnt_information28 in varchar2,
4481 p_cnt_information29 in varchar2,
4482 p_cnt_information30 in varchar2 ) is
4483
4484 cursor csr_asg_rec is
4485 select assignment_id
4486 from PER_ASSIGNMENTS_F
4487 where assignment_id = p_assignment_id
4488 and p_effective_start_date between effective_start_date
4489 and effective_end_date
4490 for update of assignment_id nowait;
4491
4492
4493 cursor csr_county_rec is
4494 select *
4495 from PAY_US_EMP_COUNTY_TAX_RULES_F
4496 where rowid = chartorowid(p_row_id)
4497 for update of emp_county_tax_rule_id nowait;
4498
4499 county_rec csr_county_rec%rowtype;
4500 l_assignment_id number(9);
4501
4502 begin
4503
4504 open csr_asg_rec;
4505
4506 fetch csr_asg_rec into l_assignment_id;
4507
4508 if csr_asg_rec%NOTFOUND then
4509 close csr_asg_rec;
4510 fnd_message.set_name('FND', 'FORM_UNABLE_TO_RESERVE_RECORD');
4511 fnd_message.raise_error;
4512 end if;
4513
4514 close csr_asg_rec;
4515
4516 open csr_county_rec;
4517
4518 fetch csr_county_rec into county_rec;
4519
4520 if csr_county_rec%NOTFOUND then
4521 close csr_county_rec;
4522 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
4523 fnd_message.set_token('PROCEDURE',
4524 'pay_us_emp_dt_tax_rules.lock_county_tax_row');
4525 fnd_message.set_token('STEP', '1');
4526 fnd_message.raise_error;
4527 end if;
4528
4529 close csr_county_rec;
4530
4531 county_rec.state_code := rtrim(county_rec.state_code);
4532 county_rec.county_code := rtrim(county_rec.county_code);
4533 county_rec.filing_status_code := rtrim(county_rec.filing_status_code);
4534 county_rec.jurisdiction_code := rtrim(county_rec.jurisdiction_code);
4535 county_rec.lit_exempt := rtrim(county_rec.lit_exempt);
4536 county_rec.sd_exempt := rtrim(county_rec.sd_exempt);
4537 county_rec.ht_exempt := rtrim(county_rec.ht_exempt);
4538 county_rec.wage_exempt := rtrim(county_rec.wage_exempt);
4539 county_rec.school_district_code := rtrim(county_rec.school_district_code);
4540 county_rec.attribute_category := rtrim(county_rec.attribute_category);
4541 county_rec.attribute1 := rtrim(county_rec.attribute1);
4542 county_rec.attribute2 := rtrim(county_rec.attribute2);
4543 county_rec.attribute3 := rtrim(county_rec.attribute3);
4544 county_rec.attribute4 := rtrim(county_rec.attribute4);
4545 county_rec.attribute5 := rtrim(county_rec.attribute5);
4546 county_rec.attribute6 := rtrim(county_rec.attribute6);
4547 county_rec.attribute7 := rtrim(county_rec.attribute7);
4548 county_rec.attribute8 := rtrim(county_rec.attribute8);
4549 county_rec.attribute9 := rtrim(county_rec.attribute9);
4550 county_rec.attribute10 := rtrim(county_rec.attribute10);
4551 county_rec.attribute11 := rtrim(county_rec.attribute11);
4552 county_rec.attribute12 := rtrim(county_rec.attribute12);
4553 county_rec.attribute13 := rtrim(county_rec.attribute13);
4554 county_rec.attribute14 := rtrim(county_rec.attribute14);
4555 county_rec.attribute15 := rtrim(county_rec.attribute15);
4556 county_rec.attribute16 := rtrim(county_rec.attribute16);
4557 county_rec.attribute17 := rtrim(county_rec.attribute17);
4558 county_rec.attribute18 := rtrim(county_rec.attribute18);
4559 county_rec.attribute19 := rtrim(county_rec.attribute19);
4560 county_rec.attribute20 := rtrim(county_rec.attribute20);
4561 county_rec.attribute21 := rtrim(county_rec.attribute21);
4562 county_rec.attribute22 := rtrim(county_rec.attribute22);
4563 county_rec.attribute23 := rtrim(county_rec.attribute23);
4564 county_rec.attribute24 := rtrim(county_rec.attribute24);
4565 county_rec.attribute25 := rtrim(county_rec.attribute25);
4566 county_rec.attribute26 := rtrim(county_rec.attribute26);
4567 county_rec.attribute27 := rtrim(county_rec.attribute27);
4568 county_rec.attribute28 := rtrim(county_rec.attribute28);
4569 county_rec.attribute29 := rtrim(county_rec.attribute29);
4570 county_rec.attribute30 := rtrim(county_rec.attribute30);
4571 county_rec.cnt_information_category := rtrim(county_rec.cnt_information_category);
4572 county_rec.cnt_information1 := rtrim(county_rec.cnt_information1);
4573 county_rec.cnt_information2 := rtrim(county_rec.cnt_information2);
4574 county_rec.cnt_information3 := rtrim(county_rec.cnt_information3);
4575 county_rec.cnt_information4 := rtrim(county_rec.cnt_information4);
4576 county_rec.cnt_information5 := rtrim(county_rec.cnt_information5);
4577 county_rec.cnt_information6 := rtrim(county_rec.cnt_information6);
4578 county_rec.cnt_information7 := rtrim(county_rec.cnt_information7);
4579 county_rec.cnt_information8 := rtrim(county_rec.cnt_information8);
4580 county_rec.cnt_information9 := rtrim(county_rec.cnt_information9);
4581 county_rec.cnt_information10 := rtrim(county_rec.cnt_information10);
4582 county_rec.cnt_information11 := rtrim(county_rec.cnt_information11);
4583 county_rec.cnt_information12 := rtrim(county_rec.cnt_information12);
4584 county_rec.cnt_information13 := rtrim(county_rec.cnt_information13);
4585 county_rec.cnt_information14 := rtrim(county_rec.cnt_information14);
4586 county_rec.cnt_information15 := rtrim(county_rec.cnt_information15);
4587 county_rec.cnt_information16 := rtrim(county_rec.cnt_information16);
4588 county_rec.cnt_information17 := rtrim(county_rec.cnt_information17);
4589 county_rec.cnt_information18 := rtrim(county_rec.cnt_information18);
4590 county_rec.cnt_information19 := rtrim(county_rec.cnt_information19);
4591 county_rec.cnt_information20 := rtrim(county_rec.cnt_information20);
4592 county_rec.cnt_information21 := rtrim(county_rec.cnt_information21);
4593 county_rec.cnt_information22 := rtrim(county_rec.cnt_information22);
4594 county_rec.cnt_information23 := rtrim(county_rec.cnt_information23);
4595 county_rec.cnt_information24 := rtrim(county_rec.cnt_information24);
4596 county_rec.cnt_information25 := rtrim(county_rec.cnt_information25);
4597 county_rec.cnt_information26 := rtrim(county_rec.cnt_information26);
4598 county_rec.cnt_information27 := rtrim(county_rec.cnt_information27);
4599 county_rec.cnt_information28 := rtrim(county_rec.cnt_information28);
4600 county_rec.cnt_information29 := rtrim(county_rec.cnt_information29);
4601 county_rec.cnt_information30 := rtrim(county_rec.cnt_information30);
4602
4603
4604 if ((county_rec.emp_county_tax_rule_id = p_emp_county_tax_rule_id)
4605 or (county_rec.emp_county_tax_rule_id is null and
4606 p_emp_county_tax_rule_id is null))
4607 and ((county_rec.effective_start_date = p_effective_start_date)
4608 or (county_rec.effective_start_date is null and
4609 p_effective_start_date is null))
4610 and ((county_rec.effective_end_date = p_effective_end_date)
4611 or (county_rec.effective_end_date is null and
4612 p_effective_end_date is null))
4613 and ((county_rec.assignment_id = p_assignment_id)
4614 or (county_rec.assignment_id is null and
4615 p_assignment_id is null))
4616 and ((county_rec.state_code = p_state_code)
4617 or (county_rec.state_code is null and
4618 p_state_code is null))
4619 and ((county_rec.county_code = p_county_code)
4620 or (county_rec.county_code is null and
4621 p_county_code is null))
4622 and ((county_rec.business_group_id = p_business_group_id)
4623 or (county_rec.business_group_id is null and
4624 p_business_group_id is null))
4625 and ((county_rec.additional_wa_rate = p_additional_wa_rate)
4626 or (county_rec.additional_wa_rate is null and
4627 p_additional_wa_rate is null))
4628 and ((county_rec.filing_status_code = lpad(p_filing_status_code,2,'0'))
4629 or (county_rec.filing_status_code is null and
4630 p_filing_status_code is null))
4631 and ((county_rec.jurisdiction_code = p_jurisdiction_code)
4632 or (county_rec.jurisdiction_code is null and
4633 p_jurisdiction_code is null))
4634 and ((county_rec.lit_additional_tax = p_lit_additional_tax)
4635 or (county_rec.lit_additional_tax is null and
4636 p_lit_additional_tax is null))
4637 and ((county_rec.lit_override_amount = p_lit_override_amount)
4638 or (county_rec.lit_override_amount is null and
4639 p_lit_override_amount is null))
4640 and ((county_rec.lit_override_rate = p_lit_override_rate)
4641 or (county_rec.lit_override_rate is null and
4642 p_lit_override_rate is null))
4643 and ((county_rec.withholding_allowances = p_withholding_allowances)
4644 or (county_rec.withholding_allowances is null and
4645 p_withholding_allowances is null))
4646 and ((county_rec.lit_exempt = p_lit_exempt)
4647 or (county_rec.lit_exempt is null and
4648 p_lit_exempt is null))
4649 and ((county_rec.sd_exempt = p_sd_exempt)
4650 or (county_rec.sd_exempt is null and
4651 p_sd_exempt is null))
4652 and ((county_rec.ht_exempt = p_ht_exempt)
4653 or (county_rec.ht_exempt is null and
4654 p_ht_exempt is null))
4655 and ((county_rec.wage_exempt = p_wage_exempt)
4656 or (county_rec.wage_exempt is null and
4657 p_wage_exempt is null))
4658 and ((county_rec.school_district_code = p_school_district_code)
4659 or (county_rec.school_district_code is null and
4660 p_school_district_code is null))
4661 and ((county_rec.attribute_category = p_attribute_category)
4662 or (county_rec.attribute_category is null and
4663 p_attribute_category is null))
4664 and ((county_rec.attribute1 = p_attribute1)
4665 or (county_rec.attribute1 is null and
4666 p_attribute1 is null))
4667 and ((county_rec.attribute2 = p_attribute2)
4668 or (county_rec.attribute2 is null and
4669 p_attribute2 is null))
4670 and ((county_rec.attribute3 = p_attribute3)
4671 or (county_rec.attribute3 is null and
4672 p_attribute3 is null))
4673 and ((county_rec.attribute4 = p_attribute4)
4674 or (county_rec.attribute4 is null and
4675 p_attribute4 is null))
4676 and ((county_rec.attribute5 = p_attribute5)
4677 or (county_rec.attribute5 is null and
4678 p_attribute5 is null))
4679 and ((county_rec.attribute6 = p_attribute6)
4680 or (county_rec.attribute6 is null and
4681 p_attribute6 is null))
4682 and ((county_rec.attribute7 = p_attribute7)
4683 or (county_rec.attribute7 is null and
4684 p_attribute7 is null))
4685 and ((county_rec.attribute8 = p_attribute8)
4686 or (county_rec.attribute8 is null and
4687 p_attribute8 is null))
4688 and ((county_rec.attribute9 = p_attribute9)
4689 or (county_rec.attribute9 is null and
4690 p_attribute9 is null))
4691 and ((county_rec.attribute10 = p_attribute10)
4692 or (county_rec.attribute10 is null and
4693 p_attribute10 is null))
4694 and ((county_rec.attribute11 = p_attribute11)
4695 or (county_rec.attribute11 is null and
4696 p_attribute11 is null))
4697 and ((county_rec.attribute12 = p_attribute12)
4698 or (county_rec.attribute12 is null and
4699 p_attribute12 is null))
4700 and ((county_rec.attribute13 = p_attribute13)
4701 or (county_rec.attribute13 is null and
4702 p_attribute13 is null))
4703 and ((county_rec.attribute14 = p_attribute14)
4704 or (county_rec.attribute14 is null and
4705 p_attribute14 is null))
4706 and ((county_rec.attribute15 = p_attribute15)
4707 or (county_rec.attribute15 is null and
4708 p_attribute15 is null))
4709 and ((county_rec.attribute16 = p_attribute16)
4710 or (county_rec.attribute16 is null and
4711 p_attribute16 is null))
4712 and ((county_rec.attribute17 = p_attribute17)
4713 or (county_rec.attribute17 is null and
4714 p_attribute17 is null))
4715 and ((county_rec.attribute18 = p_attribute18)
4716 or (county_rec.attribute18 is null and
4717 p_attribute18 is null))
4718 and ((county_rec.attribute19 = p_attribute19)
4719 or (county_rec.attribute19 is null and
4720 p_attribute19 is null))
4721 and ((county_rec.attribute20 = p_attribute20)
4722 or (county_rec.attribute20 is null and
4723 p_attribute20 is null))
4724 and ((county_rec.attribute21 = p_attribute21)
4725 or (county_rec.attribute21 is null and
4726 p_attribute21 is null))
4727 and ((county_rec.attribute22 = p_attribute22)
4728 or (county_rec.attribute22 is null and
4729 p_attribute22 is null))
4730 and ((county_rec.attribute23 = p_attribute23)
4731 or (county_rec.attribute23 is null and
4732 p_attribute23 is null))
4733 and ((county_rec.attribute24 = p_attribute24)
4734 or (county_rec.attribute24 is null and
4735 p_attribute24 is null))
4736 and ((county_rec.attribute25 = p_attribute25)
4737 or (county_rec.attribute25 is null and
4738 p_attribute25 is null))
4739 and ((county_rec.attribute26 = p_attribute26)
4740 or (county_rec.attribute26 is null and
4741 p_attribute26 is null))
4742 and ((county_rec.attribute27 = p_attribute27)
4743 or (county_rec.attribute27 is null and
4744 p_attribute27 is null))
4745 and ((county_rec.attribute28 = p_attribute28)
4746 or (county_rec.attribute28 is null and
4747 p_attribute28 is null))
4748 and ((county_rec.attribute29 = p_attribute29)
4749 or (county_rec.attribute29 is null and
4750 p_attribute29 is null))
4751 and ((county_rec.attribute30 = p_attribute30)
4752 or (county_rec.attribute30 is null and
4753 p_attribute30 is null))
4754 and ((county_rec.cnt_information_category = p_cnt_information_category)
4755 or (county_rec.cnt_information_category is null and
4756 p_cnt_information_category is null))
4757 and ((county_rec.cnt_information1 = p_cnt_information1)
4758 or (county_rec.cnt_information1 is null and
4759 p_cnt_information1 is null))
4760 and ((county_rec.cnt_information2 = p_cnt_information2)
4761 or (county_rec.cnt_information2 is null and
4762 p_cnt_information2 is null))
4763 and ((county_rec.cnt_information3 = p_cnt_information3)
4764 or (county_rec.cnt_information3 is null and
4765 p_cnt_information3 is null))
4766 and ((county_rec.cnt_information4 = p_cnt_information4)
4767 or (county_rec.cnt_information4 is null and
4768 p_cnt_information4 is null))
4769 and ((county_rec.cnt_information5 = p_cnt_information5)
4770 or (county_rec.cnt_information5 is null and
4771 p_cnt_information5 is null))
4772 and ((county_rec.cnt_information6 = p_cnt_information6)
4773 or (county_rec.cnt_information6 is null and
4774 p_cnt_information6 is null))
4775 and ((county_rec.cnt_information7 = p_cnt_information7)
4776 or (county_rec.cnt_information7 is null and
4777 p_cnt_information7 is null))
4778 and ((county_rec.cnt_information8 = p_cnt_information8)
4779 or (county_rec.cnt_information8 is null and
4780 p_cnt_information8 is null))
4781 and ((county_rec.cnt_information9 = p_cnt_information9)
4782 or (county_rec.cnt_information9 is null and
4783 p_cnt_information9 is null))
4784 and ((county_rec.cnt_information10 = p_cnt_information10)
4785 or (county_rec.cnt_information10 is null and
4786 p_cnt_information10 is null))
4787 and ((county_rec.cnt_information11 = p_cnt_information11)
4788 or (county_rec.cnt_information11 is null and
4789 p_cnt_information11 is null))
4790 and ((county_rec.cnt_information12 = p_cnt_information12)
4791 or (county_rec.cnt_information12 is null and
4792 p_cnt_information12 is null))
4793 and ((county_rec.cnt_information13 = p_cnt_information13)
4794 or (county_rec.cnt_information13 is null and
4795 p_cnt_information13 is null))
4796 and ((county_rec.cnt_information14 = p_cnt_information14)
4797 or (county_rec.cnt_information14 is null and
4798 p_cnt_information14 is null))
4799 and ((county_rec.cnt_information15 = p_cnt_information15)
4800 or (county_rec.cnt_information15 is null and
4801 p_cnt_information15 is null))
4802 and ((county_rec.cnt_information16 = p_cnt_information16)
4803 or (county_rec.cnt_information16 is null and
4804 p_cnt_information16 is null))
4805 and ((county_rec.cnt_information17 = p_cnt_information17)
4806 or (county_rec.cnt_information17 is null and
4807 p_cnt_information17 is null))
4808 and ((county_rec.cnt_information18 = p_cnt_information18)
4809 or (county_rec.cnt_information18 is null and
4810 p_cnt_information18 is null))
4811 and ((county_rec.cnt_information19 = p_cnt_information19)
4812 or (county_rec.cnt_information19 is null and
4813 p_cnt_information19 is null))
4814 and ((county_rec.cnt_information20 = p_cnt_information20)
4815 or (county_rec.cnt_information20 is null and
4816 p_cnt_information20 is null))
4817 and ((county_rec.cnt_information21 = p_cnt_information21)
4818 or (county_rec.cnt_information21 is null and
4819 p_cnt_information21 is null))
4820 and ((county_rec.cnt_information22 = p_cnt_information22)
4821 or (county_rec.cnt_information22 is null and
4822 p_cnt_information22 is null))
4823 and ((county_rec.cnt_information23 = p_cnt_information23)
4824 or (county_rec.cnt_information23 is null and
4825 p_cnt_information23 is null))
4826 and ((county_rec.cnt_information24 = p_cnt_information24)
4827 or (county_rec.cnt_information24 is null and
4828 p_cnt_information24 is null))
4829 and ((county_rec.cnt_information25 = p_cnt_information25)
4830 or (county_rec.cnt_information25 is null and
4831 p_cnt_information25 is null))
4832 and ((county_rec.cnt_information26 = p_cnt_information26)
4833 or (county_rec.cnt_information26 is null and
4834 p_cnt_information26 is null))
4835 and ((county_rec.cnt_information27 = p_cnt_information27)
4836 or (county_rec.cnt_information27 is null and
4837 p_cnt_information27 is null))
4838 and ((county_rec.cnt_information28 = p_cnt_information28)
4839 or (county_rec.cnt_information28 is null and
4840 p_cnt_information28 is null))
4841 and ((county_rec.cnt_information29 = p_cnt_information29)
4842 or (county_rec.cnt_information29 is null and
4843 p_cnt_information29 is null))
4844 and ((county_rec.cnt_information30 = p_cnt_information30)
4845 or (county_rec.cnt_information30 is null and
4846 p_cnt_information30 is null))
4847 then
4848
4849 return;
4850
4851 else
4852
4853 fnd_message.set_name('PAY', 'FORM_RECORD_CHANGED');
4854 fnd_message.raise_error;
4855
4856 end if;
4857
4858 end lock_county_tax_row;
4859
4860
4861 /* Name : lock_city_tax_row
4862 Purpose : To lock the city tax rule record.
4863 */
4864
4865 procedure lock_city_tax_row ( p_row_id in varchar2,
4866 p_emp_city_tax_rule_id in number,
4867 p_effective_start_date in date,
4868 p_effective_end_date in date,
4869 p_assignment_id in number,
4870 p_state_code in varchar2,
4871 p_county_code in varchar2,
4872 p_city_code in varchar2,
4873 p_business_group_id in number,
4874 p_additional_wa_rate in number,
4875 p_filing_status_code in varchar2,
4876 p_jurisdiction_code in varchar2,
4877 p_lit_additional_tax in number,
4878 p_lit_override_amount in number,
4879 p_lit_override_rate in number,
4880 p_withholding_allowances in number,
4881 p_lit_exempt in varchar2,
4882 p_sd_exempt in varchar2,
4883 p_ht_exempt in varchar2,
4884 p_wage_exempt in varchar2,
4885 p_school_district_code in varchar2,
4886 p_attribute_category in varchar2,
4887 p_attribute1 in varchar2,
4888 p_attribute2 in varchar2,
4889 p_attribute3 in varchar2,
4890 p_attribute4 in varchar2,
4891 p_attribute5 in varchar2,
4892 p_attribute6 in varchar2,
4893 p_attribute7 in varchar2,
4894 p_attribute8 in varchar2,
4895 p_attribute9 in varchar2,
4896 p_attribute10 in varchar2,
4897 p_attribute11 in varchar2,
4898 p_attribute12 in varchar2,
4899 p_attribute13 in varchar2,
4900 p_attribute14 in varchar2,
4901 p_attribute15 in varchar2,
4902 p_attribute16 in varchar2,
4903 p_attribute17 in varchar2,
4904 p_attribute18 in varchar2,
4905 p_attribute19 in varchar2,
4906 p_attribute20 in varchar2,
4907 p_attribute21 in varchar2,
4908 p_attribute22 in varchar2,
4909 p_attribute23 in varchar2,
4910 p_attribute24 in varchar2,
4911 p_attribute25 in varchar2,
4912 p_attribute26 in varchar2,
4913 p_attribute27 in varchar2,
4914 p_attribute28 in varchar2,
4915 p_attribute29 in varchar2,
4916 p_attribute30 in varchar2,
4917 p_cty_information_category in varchar2,
4918 p_cty_information1 in varchar2,
4919 p_cty_information2 in varchar2,
4920 p_cty_information3 in varchar2,
4921 p_cty_information4 in varchar2,
4922 p_cty_information5 in varchar2,
4923 p_cty_information6 in varchar2,
4924 p_cty_information7 in varchar2,
4925 p_cty_information8 in varchar2,
4926 p_cty_information9 in varchar2,
4927 p_cty_information10 in varchar2,
4928 p_cty_information11 in varchar2,
4929 p_cty_information12 in varchar2,
4930 p_cty_information13 in varchar2,
4931 p_cty_information14 in varchar2,
4932 p_cty_information15 in varchar2,
4933 p_cty_information16 in varchar2,
4934 p_cty_information17 in varchar2,
4935 p_cty_information18 in varchar2,
4936 p_cty_information19 in varchar2,
4937 p_cty_information20 in varchar2,
4938 p_cty_information21 in varchar2,
4939 p_cty_information22 in varchar2,
4940 p_cty_information23 in varchar2,
4941 p_cty_information24 in varchar2,
4942 p_cty_information25 in varchar2,
4943 p_cty_information26 in varchar2,
4944 p_cty_information27 in varchar2,
4945 p_cty_information28 in varchar2,
4946 p_cty_information29 in varchar2,
4947 p_cty_information30 in varchar2 ) is
4948
4949
4950 cursor csr_asg_rec is
4951 select assignment_id
4952 from PER_ASSIGNMENTS_F
4953 where assignment_id = p_assignment_id
4954 and p_effective_start_date between effective_start_date
4955 and effective_end_date
4956 for update of assignment_id nowait;
4957
4958
4959 cursor csr_city_rec is
4960 select *
4961 from PAY_US_EMP_CITY_TAX_RULES_F
4962 where rowid = chartorowid(p_row_id)
4963 for update of emp_city_tax_rule_id nowait;
4964
4965 city_rec csr_city_rec%rowtype;
4966 l_assignment_id number(9);
4967
4968 begin
4969
4970 open csr_asg_rec;
4971
4972 fetch csr_asg_rec into l_assignment_id;
4973
4974 if csr_asg_rec%NOTFOUND then
4975 close csr_asg_rec;
4976 fnd_message.set_name('FND', 'FORM_UNABLE_TO_RESERVE_RECORD');
4977 fnd_message.raise_error;
4978 end if;
4979
4980 close csr_asg_rec;
4981
4982 open csr_city_rec;
4983
4984 fetch csr_city_rec into city_rec;
4985
4986 if csr_city_rec%NOTFOUND then
4987 close csr_city_rec;
4988 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
4989 fnd_message.set_token('PROCEDURE',
4990 'pay_us_emp_dt_tax_rules.lock_city_tax_row');
4991 fnd_message.set_token('STEP', '1');
4992 fnd_message.raise_error;
4993 end if;
4994
4995 close csr_city_rec;
4996
4997 city_rec.state_code := rtrim(city_rec.state_code);
4998 city_rec.county_code := rtrim(city_rec.county_code);
4999 city_rec.city_code := rtrim(city_rec.city_code);
5000 city_rec.filing_status_code := rtrim(city_rec.filing_status_code);
5001 city_rec.jurisdiction_code := rtrim(city_rec.jurisdiction_code);
5002 city_rec.lit_exempt := rtrim(city_rec.lit_exempt);
5003 city_rec.sd_exempt := rtrim(city_rec.sd_exempt);
5004 city_rec.ht_exempt := rtrim(city_rec.ht_exempt);
5005 city_rec.wage_exempt := rtrim(city_rec.wage_exempt);
5006 city_rec.school_district_code := rtrim(city_rec.school_district_code);
5007 city_rec.attribute_category := rtrim(city_rec.attribute_category);
5008 city_rec.attribute1 := rtrim(city_rec.attribute1);
5009 city_rec.attribute2 := rtrim(city_rec.attribute2);
5010 city_rec.attribute3 := rtrim(city_rec.attribute3);
5011 city_rec.attribute4 := rtrim(city_rec.attribute4);
5012 city_rec.attribute5 := rtrim(city_rec.attribute5);
5013 city_rec.attribute6 := rtrim(city_rec.attribute6);
5014 city_rec.attribute7 := rtrim(city_rec.attribute7);
5015 city_rec.attribute8 := rtrim(city_rec.attribute8);
5016 city_rec.attribute9 := rtrim(city_rec.attribute9);
5017 city_rec.attribute10 := rtrim(city_rec.attribute10);
5018 city_rec.attribute11 := rtrim(city_rec.attribute11);
5019 city_rec.attribute12 := rtrim(city_rec.attribute12);
5020 city_rec.attribute13 := rtrim(city_rec.attribute13);
5021 city_rec.attribute14 := rtrim(city_rec.attribute14);
5022 city_rec.attribute15 := rtrim(city_rec.attribute15);
5023 city_rec.attribute16 := rtrim(city_rec.attribute16);
5024 city_rec.attribute17 := rtrim(city_rec.attribute17);
5025 city_rec.attribute18 := rtrim(city_rec.attribute18);
5026 city_rec.attribute19 := rtrim(city_rec.attribute19);
5027 city_rec.attribute20 := rtrim(city_rec.attribute20);
5028 city_rec.attribute21 := rtrim(city_rec.attribute21);
5029 city_rec.attribute22 := rtrim(city_rec.attribute22);
5030 city_rec.attribute23 := rtrim(city_rec.attribute23);
5031 city_rec.attribute24 := rtrim(city_rec.attribute24);
5032 city_rec.attribute25 := rtrim(city_rec.attribute25);
5033 city_rec.attribute26 := rtrim(city_rec.attribute26);
5034 city_rec.attribute27 := rtrim(city_rec.attribute27);
5035 city_rec.attribute28 := rtrim(city_rec.attribute28);
5036 city_rec.attribute29 := rtrim(city_rec.attribute29);
5037 city_rec.attribute30 := rtrim(city_rec.attribute30);
5038 city_rec.cty_information_category := rtrim(city_rec.cty_information_category);
5039 city_rec.cty_information1 := rtrim(city_rec.cty_information1);
5040 city_rec.cty_information2 := rtrim(city_rec.cty_information2);
5041 city_rec.cty_information3 := rtrim(city_rec.cty_information3);
5042 city_rec.cty_information4 := rtrim(city_rec.cty_information4);
5043 city_rec.cty_information5 := rtrim(city_rec.cty_information5);
5044 city_rec.cty_information6 := rtrim(city_rec.cty_information6);
5045 city_rec.cty_information7 := rtrim(city_rec.cty_information7);
5046 city_rec.cty_information8 := rtrim(city_rec.cty_information8);
5047 city_rec.cty_information9 := rtrim(city_rec.cty_information9);
5048 city_rec.cty_information10 := rtrim(city_rec.cty_information10);
5049 city_rec.cty_information11 := rtrim(city_rec.cty_information11);
5050 city_rec.cty_information12 := rtrim(city_rec.cty_information12);
5051 city_rec.cty_information13 := rtrim(city_rec.cty_information13);
5052 city_rec.cty_information14 := rtrim(city_rec.cty_information14);
5053 city_rec.cty_information15 := rtrim(city_rec.cty_information15);
5054 city_rec.cty_information16 := rtrim(city_rec.cty_information16);
5055 city_rec.cty_information17 := rtrim(city_rec.cty_information17);
5056 city_rec.cty_information18 := rtrim(city_rec.cty_information18);
5057 city_rec.cty_information19 := rtrim(city_rec.cty_information19);
5058 city_rec.cty_information20 := rtrim(city_rec.cty_information20);
5059 city_rec.cty_information21 := rtrim(city_rec.cty_information21);
5060 city_rec.cty_information22 := rtrim(city_rec.cty_information22);
5061 city_rec.cty_information23 := rtrim(city_rec.cty_information23);
5062 city_rec.cty_information24 := rtrim(city_rec.cty_information24);
5063 city_rec.cty_information25 := rtrim(city_rec.cty_information25);
5064 city_rec.cty_information26 := rtrim(city_rec.cty_information26);
5065 city_rec.cty_information27 := rtrim(city_rec.cty_information27);
5066 city_rec.cty_information28 := rtrim(city_rec.cty_information28);
5067 city_rec.cty_information29 := rtrim(city_rec.cty_information29);
5068 city_rec.cty_information30 := rtrim(city_rec.cty_information30);
5069
5070 if ((city_rec.emp_city_tax_rule_id = p_emp_city_tax_rule_id)
5071 or (city_rec.emp_city_tax_rule_id is null and
5072 p_emp_city_tax_rule_id is null))
5073 and ((city_rec.effective_start_date = p_effective_start_date)
5074 or (city_rec.effective_start_date is null and
5075 p_effective_start_date is null))
5076 and ((city_rec.effective_end_date = p_effective_end_date)
5077 or (city_rec.effective_end_date is null and
5078 p_effective_end_date is null))
5079 and ((city_rec.assignment_id = p_assignment_id)
5080 or (city_rec.assignment_id is null and
5081 p_assignment_id is null))
5082 and ((city_rec.state_code = p_state_code)
5083 or (city_rec.state_code is null and
5084 p_state_code is null))
5085 and ((city_rec.county_code = p_county_code)
5086 or (city_rec.county_code is null and
5087 p_county_code is null))
5088 and ((city_rec.city_code = p_city_code)
5089 or (city_rec.city_code is null and
5090 p_city_code is null))
5091 and ((city_rec.business_group_id = p_business_group_id)
5092 or (city_rec.business_group_id is null and
5093 p_business_group_id is null))
5094 and ((city_rec.additional_wa_rate = p_additional_wa_rate)
5095 or (city_rec.additional_wa_rate is null and
5096 p_additional_wa_rate is null))
5097 and ((city_rec.filing_status_code = lpad(p_filing_status_code,2,'0'))
5098 or (city_rec.filing_status_code is null and
5099 p_filing_status_code is null))
5100 and ((city_rec.jurisdiction_code = p_jurisdiction_code)
5101 or (city_rec.jurisdiction_code is null and
5102 p_jurisdiction_code is null))
5103 and ((city_rec.lit_additional_tax = p_lit_additional_tax)
5104 or (city_rec.lit_additional_tax is null and
5105 p_lit_additional_tax is null))
5106 and ((city_rec.lit_override_amount = p_lit_override_amount)
5107 or (city_rec.lit_override_amount is null and
5108 p_lit_override_amount is null))
5109 and ((city_rec.lit_override_rate = p_lit_override_rate)
5110 or (city_rec.lit_override_rate is null and
5111 p_lit_override_rate is null))
5112 and ((city_rec.withholding_allowances = p_withholding_allowances)
5113 or (city_rec.withholding_allowances is null and
5114 p_withholding_allowances is null))
5115 and ((city_rec.lit_exempt = p_lit_exempt)
5116 or (city_rec.lit_exempt is null and
5117 p_lit_exempt is null))
5118 and ((city_rec.sd_exempt = p_sd_exempt)
5119 or (city_rec.sd_exempt is null and
5120 p_sd_exempt is null))
5121 and ((city_rec.ht_exempt = p_ht_exempt)
5122 or (city_rec.ht_exempt is null and
5123 p_ht_exempt is null))
5124 and ((city_rec.wage_exempt = p_wage_exempt)
5125 or (city_rec.wage_exempt is null and
5126 p_wage_exempt is null))
5127 and ((city_rec.school_district_code = p_school_district_code)
5128 or (city_rec.school_district_code is null and
5129 p_school_district_code is null))
5130 and ((city_rec.attribute_category = p_attribute_category)
5131 or (city_rec.attribute_category is null and
5132 p_attribute_category is null))
5133 and ((city_rec.attribute1 = p_attribute1)
5134 or (city_rec.attribute1 is null and
5135 p_attribute1 is null))
5136 and ((city_rec.attribute2 = p_attribute2)
5137 or (city_rec.attribute2 is null and
5138 p_attribute2 is null))
5139 and ((city_rec.attribute3 = p_attribute3)
5140 or (city_rec.attribute3 is null and
5141 p_attribute3 is null))
5142 and ((city_rec.attribute4 = p_attribute4)
5143 or (city_rec.attribute4 is null and
5144 p_attribute4 is null))
5145 and ((city_rec.attribute5 = p_attribute5)
5146 or (city_rec.attribute5 is null and
5147 p_attribute5 is null))
5148 and ((city_rec.attribute6 = p_attribute6)
5149 or (city_rec.attribute6 is null and
5150 p_attribute6 is null))
5151 and ((city_rec.attribute7 = p_attribute7)
5152 or (city_rec.attribute7 is null and
5153 p_attribute7 is null))
5154 and ((city_rec.attribute8 = p_attribute8)
5155 or (city_rec.attribute8 is null and
5156 p_attribute8 is null))
5157 and ((city_rec.attribute9 = p_attribute9)
5158 or (city_rec.attribute9 is null and
5159 p_attribute9 is null))
5160 and ((city_rec.attribute10 = p_attribute10)
5161 or (city_rec.attribute10 is null and
5162 p_attribute10 is null))
5163 and ((city_rec.attribute11 = p_attribute11)
5164 or (city_rec.attribute11 is null and
5165 p_attribute11 is null))
5166 and ((city_rec.attribute12 = p_attribute12)
5167 or (city_rec.attribute12 is null and
5168 p_attribute12 is null))
5169 and ((city_rec.attribute13 = p_attribute13)
5170 or (city_rec.attribute13 is null and
5171 p_attribute13 is null))
5172 and ((city_rec.attribute14 = p_attribute14)
5173 or (city_rec.attribute14 is null and
5174 p_attribute14 is null))
5175 and ((city_rec.attribute15 = p_attribute15)
5176 or (city_rec.attribute15 is null and
5177 p_attribute15 is null))
5178 and ((city_rec.attribute16 = p_attribute16)
5179 or (city_rec.attribute16 is null and
5180 p_attribute16 is null))
5181 and ((city_rec.attribute17 = p_attribute17)
5182 or (city_rec.attribute17 is null and
5183 p_attribute17 is null))
5184 and ((city_rec.attribute18 = p_attribute18)
5185 or (city_rec.attribute18 is null and
5186 p_attribute18 is null))
5187 and ((city_rec.attribute19 = p_attribute19)
5188 or (city_rec.attribute19 is null and
5189 p_attribute19 is null))
5190 and ((city_rec.attribute20 = p_attribute20)
5191 or (city_rec.attribute20 is null and
5192 p_attribute20 is null))
5193 and ((city_rec.attribute21 = p_attribute21)
5194 or (city_rec.attribute21 is null and
5195 p_attribute21 is null))
5196 and ((city_rec.attribute22 = p_attribute22)
5197 or (city_rec.attribute22 is null and
5198 p_attribute22 is null))
5199 and ((city_rec.attribute23 = p_attribute23)
5200 or (city_rec.attribute23 is null and
5201 p_attribute23 is null))
5202 and ((city_rec.attribute24 = p_attribute24)
5203 or (city_rec.attribute24 is null and
5204 p_attribute24 is null))
5205 and ((city_rec.attribute25 = p_attribute25)
5206 or (city_rec.attribute25 is null and
5207 p_attribute25 is null))
5208 and ((city_rec.attribute26 = p_attribute26)
5209 or (city_rec.attribute26 is null and
5210 p_attribute26 is null))
5211 and ((city_rec.attribute27 = p_attribute27)
5212 or (city_rec.attribute27 is null and
5213 p_attribute27 is null))
5214 and ((city_rec.attribute28 = p_attribute28)
5215 or (city_rec.attribute28 is null and
5216 p_attribute28 is null))
5217 and ((city_rec.attribute29 = p_attribute29)
5218 or (city_rec.attribute29 is null and
5219 p_attribute29 is null))
5220 and ((city_rec.attribute30 = p_attribute30)
5221 or (city_rec.attribute30 is null and
5222 p_attribute30 is null))
5223 and ((city_rec.cty_information_category = p_cty_information_category)
5224 or (city_rec.cty_information_category is null and
5225 p_cty_information_category is null))
5226 and ((city_rec.cty_information1 = p_cty_information1)
5227 or (city_rec.cty_information1 is null and
5228 p_cty_information1 is null))
5229 and ((city_rec.cty_information2 = p_cty_information2)
5230 or (city_rec.cty_information2 is null and
5231 p_cty_information2 is null))
5232 and ((city_rec.cty_information3 = p_cty_information3)
5233 or (city_rec.cty_information3 is null and
5234 p_cty_information3 is null))
5235 and ((city_rec.cty_information4 = p_cty_information4)
5236 or (city_rec.cty_information4 is null and
5237 p_cty_information4 is null))
5238 and ((city_rec.cty_information5 = p_cty_information5)
5239 or (city_rec.cty_information5 is null and
5240 p_cty_information5 is null))
5241 and ((city_rec.cty_information6 = p_cty_information6)
5242 or (city_rec.cty_information6 is null and
5243 p_cty_information6 is null))
5244 and ((city_rec.cty_information7 = p_cty_information7)
5245 or (city_rec.cty_information7 is null and
5246 p_cty_information7 is null))
5247 and ((city_rec.cty_information8 = p_cty_information8)
5248 or (city_rec.cty_information8 is null and
5249 p_cty_information8 is null))
5250 and ((city_rec.cty_information9 = p_cty_information9)
5251 or (city_rec.cty_information9 is null and
5252 p_cty_information9 is null))
5253 and ((city_rec.cty_information10 = p_cty_information10)
5254 or (city_rec.cty_information10 is null and
5255 p_cty_information10 is null))
5256 and ((city_rec.cty_information11 = p_cty_information11)
5257 or (city_rec.cty_information11 is null and
5258 p_cty_information11 is null))
5259 and ((city_rec.cty_information12 = p_cty_information12)
5260 or (city_rec.cty_information12 is null and
5261 p_cty_information12 is null))
5262 and ((city_rec.cty_information13 = p_cty_information13)
5263 or (city_rec.cty_information13 is null and
5264 p_cty_information13 is null))
5265 and ((city_rec.cty_information14 = p_cty_information14)
5266 or (city_rec.cty_information14 is null and
5267 p_cty_information14 is null))
5268 and ((city_rec.cty_information15 = p_cty_information15)
5269 or (city_rec.cty_information15 is null and
5270 p_cty_information15 is null))
5271 and ((city_rec.cty_information16 = p_cty_information16)
5272 or (city_rec.cty_information16 is null and
5273 p_cty_information16 is null))
5274 and ((city_rec.cty_information17 = p_cty_information17)
5275 or (city_rec.cty_information17 is null and
5276 p_cty_information17 is null))
5277 and ((city_rec.cty_information18 = p_cty_information18)
5278 or (city_rec.cty_information18 is null and
5279 p_cty_information18 is null))
5280 and ((city_rec.cty_information19 = p_cty_information19)
5281 or (city_rec.cty_information19 is null and
5282 p_cty_information19 is null))
5283 and ((city_rec.cty_information20 = p_cty_information20)
5284 or (city_rec.cty_information20 is null and
5285 p_cty_information20 is null))
5286 and ((city_rec.cty_information21 = p_cty_information21)
5287 or (city_rec.cty_information21 is null and
5288 p_cty_information21 is null))
5289 and ((city_rec.cty_information22 = p_cty_information22)
5290 or (city_rec.cty_information22 is null and
5291 p_cty_information22 is null))
5292 and ((city_rec.cty_information23 = p_cty_information23)
5293 or (city_rec.cty_information23 is null and
5294 p_cty_information23 is null))
5295 and ((city_rec.cty_information24 = p_cty_information24)
5296 or (city_rec.cty_information24 is null and
5297 p_cty_information24 is null))
5298 and ((city_rec.cty_information25 = p_cty_information25)
5299 or (city_rec.cty_information25 is null and
5300 p_cty_information25 is null))
5301 and ((city_rec.cty_information26 = p_cty_information26)
5302 or (city_rec.cty_information26 is null and
5303 p_cty_information26 is null))
5304 and ((city_rec.cty_information27 = p_cty_information27)
5305 or (city_rec.cty_information27 is null and
5306 p_cty_information27 is null))
5307 and ((city_rec.cty_information28 = p_cty_information28)
5308 or (city_rec.cty_information28 is null and
5309 p_cty_information28 is null))
5310 and ((city_rec.cty_information29 = p_cty_information29)
5311 or (city_rec.cty_information29 is null and
5312 p_cty_information29 is null))
5313 and ((city_rec.cty_information30 = p_cty_information30)
5314 or (city_rec.cty_information30 is null and
5315 p_cty_information30 is null))
5316 then
5317
5318 return;
5319
5320 else
5321
5322 fnd_message.set_name('PAY', 'FORM_RECORD_CHANGED');
5323 fnd_message.raise_error;
5324
5325 end if;
5326
5327 end lock_city_tax_row;
5328
5329
5330 function insert_def_fed_rec(p_assignment_id number,
5331 p_effective_start_date date,
5332 p_effective_end_date date,
5333 p_sui_state_code varchar2,
5334 p_business_group_id number)
5335 return number is
5336
5337 l_filing_status_code varchar2(2);
5338 l_eic_fstatus_code varchar2(2);
5339 l_emp_fed_tax_rule_id number;
5340 l_mode varchar2(30);
5341
5342 /* Get the Filing Status */
5343 /*cursor csr_filing_status is
5344 select lookup_code
5345 from HR_LOOKUPS
5346 where lookup_type = 'US_FIT_FILING_STATUS'
5347 and upper(meaning) = 'SINGLE';
5348 */
5349
5350 cursor csr_filing_status is
5351 select lookup_code
5352 from FND_LOOKUP_VALUES
5353 where lookup_type = 'US_FIT_FILING_STATUS'
5354 and upper(meaning) = 'SINGLE'
5355 and language = 'US';
5356
5357 /* Get EIC Filing Status */
5358 /*CURSOR csr_eic_fstatus is
5359 select lookup_code
5360 from hr_lookups
5361 where lookup_type = 'US_EIC_FILING_STATUS'
5362 and upper(meaning) = 'NO EIC';
5363 */
5364
5365 CURSOR csr_eic_fstatus is
5366 select lookup_code
5367 from fnd_lookup_values
5368 where lookup_type = 'US_EIC_FILING_STATUS'
5369 and upper(meaning) = 'NO EIC'
5370 and language = 'US';
5371
5372 begin
5373
5374 /* Get Filing Status */
5375 hr_utility.set_location('pay_us_emp_dt_tax_rules.insert_def_fed_rec',1);
5376 --dbms_output.put_line('asg** '||to_char(p_assignment_id));
5377 --dbms_output.put_line('sd** '||to_char(p_effective_start_date));
5378 --dbms_output.put_line('ed** '||to_char(p_effective_end_date));
5379 --dbms_output.put_line('sui** '||p_sui_state_code);
5380 --dbms_output.put_line('bg** ' || to_char(p_business_group_id));
5381 hr_utility.trace('insert_def_fed_rec** ' || to_char(p_assignment_id));
5382 hr_utility.trace('insert_def_fed_rec** ' || to_char(p_effective_start_date));
5383 hr_utility.trace('insert_def_fed_rec** ' || to_char(p_effective_end_date));
5384 hr_utility.trace('insert_def_fed_rec** ' || p_sui_state_code);
5385 hr_utility.trace('insert_def_fed_rec** ' || to_char(p_business_group_id));
5386
5387 open csr_filing_status;
5388
5389 fetch csr_filing_status into l_filing_status_code;
5390
5391 if csr_filing_status%NOTFOUND then
5392 fnd_message.set_name('PAY','HR_6091_DEF_MISSING_LOOKUPS');
5393 fnd_message.set_token('LOOKUP_TYPE ','US_FIT_FILING_STATUS');
5394 fnd_message.raise_error;
5395 end if;
5396
5397 close csr_filing_status;
5398
5399 /* Get EIC Filing Status */
5400 hr_utility.set_location('pay_us_emp_dt_tax_rules.insert_def_fed_rec',2);
5401
5402 open csr_eic_fstatus;
5403
5404 fetch csr_eic_fstatus into l_eic_fstatus_code;
5405
5406 if csr_eic_fstatus%NOTFOUND then
5407
5408 fnd_message.set_name('PAY','HR_6091_DEF_MISSING_LOOKUPS');
5409 fnd_message.set_token('LOOKUP_TYPE ','US_EIC_FILING_STATUS');
5410 fnd_message.raise_error;
5411
5412 end if;
5413
5414 close csr_eic_fstatus;
5415
5416 /* Insert Federal Tax Record */
5417
5418 hr_utility.set_location('pay_us_emp_dt_tax_rules.insert_def_fed_rec',3);
5419
5420 l_mode := 'INSERT';
5421
5422 insert_fed_tax_row(p_emp_fed_tax_rule_id => l_emp_fed_tax_rule_id,
5423 p_effective_start_date => p_effective_start_date,
5424 p_effective_end_date => p_effective_end_date,
5425 p_assignment_id => p_assignment_id,
5426 p_sui_state_code => p_sui_state_code,
5427 p_sui_jurisdiction_code => p_sui_state_code || '-000-0000',
5428 p_business_group_id => p_business_group_id,
5429 p_additional_wa_amount => 0,
5430 p_filing_status_code => lpad(l_filing_status_code,2,'0'),
5431 p_fit_override_amount => 0,
5432 p_fit_override_rate => 0,
5433 p_withholding_allowances => 0,
5434 p_cumulative_taxation => 'N',
5435 p_eic_filing_status_code => l_eic_fstatus_code,
5436 p_fit_additional_tax => 0,
5437 p_fit_exempt => 'N',
5438 p_futa_tax_exempt => 'N',
5439 p_medicare_tax_exempt => 'N',
5440 p_ss_tax_exempt => 'N',
5441 p_wage_exempt => 'N',
5442 p_statutory_employee => 'N',
5443 p_w2_filed_year => null,
5444 p_supp_tax_override_rate => 0,
5445 p_excessive_wa_reject_date => null,
5446 p_attribute_category => null,
5447 p_attribute1 => null,
5448 p_attribute2 => null,
5449 p_attribute3 => null,
5450 p_attribute4 => null,
5451 p_attribute5 => null,
5452 p_attribute6 => null,
5453 p_attribute7 => null,
5454 p_attribute8 => null,
5455 p_attribute9 => null,
5456 p_attribute10 => null,
5457 p_attribute11 => null,
5458 p_attribute12 => null,
5459 p_attribute13 => null,
5460 p_attribute14 => null,
5461 p_attribute15 => null,
5462 p_attribute16 => null,
5463 p_attribute17 => null,
5464 p_attribute18 => null,
5465 p_attribute19 => null,
5466 p_attribute20 => null,
5467 p_attribute21 => null,
5468 p_attribute22 => null,
5469 p_attribute23 => null,
5470 p_attribute24 => null,
5471 p_attribute25 => null,
5472 p_attribute26 => null,
5473 p_attribute27 => null,
5474 p_attribute28 => null,
5475 p_attribute29 => null,
5476 p_attribute30 => null,
5477 p_fed_information_category => null,
5478 p_fed_information1 => null,
5479 p_fed_information2 => null,
5480 p_fed_information3 => null,
5481 p_fed_information4 => null,
5482 p_fed_information5 => null,
5483 p_fed_information6 => null,
5484 p_fed_information7 => null,
5485 p_fed_information8 => null,
5486 p_fed_information9 => null,
5487 p_fed_information10 => null,
5488 p_fed_information11 => null,
5489 p_fed_information12 => null,
5490 p_fed_information13 => null,
5491 p_fed_information14 => null,
5492 p_fed_information15 => null,
5493 p_fed_information16 => null,
5494 p_fed_information17 => null,
5495 p_fed_information18 => null,
5496 p_fed_information19 => null,
5497 p_fed_information20 => null,
5498 p_fed_information21 => null,
5499 p_fed_information22 => null,
5500 p_fed_information23 => null,
5501 p_fed_information24 => null,
5502 p_fed_information25 => null,
5503 p_fed_information26 => null,
5504 p_fed_information27 => null,
5505 p_fed_information28 => null,
5506 p_fed_information29 => null,
5507 p_fed_information30 => null,
5508 p_mode => 'INSERT');
5509
5510 hr_utility.set_location('pay_us_emp_dt_tax_rules.insert_def_fed_rec',5);
5511
5512 return l_emp_fed_tax_rule_id;
5513
5514 end insert_def_fed_rec;
5515
5516
5517 /* Insert state record */
5518
5519
5520 function insert_def_state_rec(p_assignment_id number,
5521 p_effective_start_date date,
5522 p_effective_end_date date,
5523 p_state_code varchar2,
5524 p_business_group_id number,
5525 p_percent_time number)
5526 return number is
5527
5528 l_emp_state_tax_rule_id number;
5529 l_filing_status_code varchar2(30);
5530 l_def_pref varchar2(30);
5531 ln_asg_tax_unit_id number;
5532 l_allowances number;
5533 l_row_id varchar2(30);
5534
5535 /* This cursor gets the filing status and exemptions from the federal record
5536 if needed */
5537
5538 /*
5539 cursor csr_filing_status(p_assignment number, p_state varchar2) is
5540 select hrl.lookup_code, peft.withholding_allowances
5541 from HR_LOOKUPS hrl
5542 , PAY_US_EMP_FED_TAX_RULES_V peft
5543 where hrl.lookup_type = 'US_FS_'||p_state
5544 and upper(hrl.meaning) = decode(
5545 upper(substr(peft.filing_status,1,7)),
5546 'MARRIED',
5547 'MARRIED',
5548 upper(peft.filing_status))
5549 and peft.assignment_id = p_assignment ;
5550 */
5551 cursor csr_filing_status(p_assignment number, p_state varchar2) is
5552 select flv.lookup_code, peft.withholding_allowances
5553 from FND_LOOKUP_VALUES flv
5554 , PAY_US_EMP_FED_TAX_RULES_V peft
5555 where flv.lookup_type = 'US_FS_'||p_state
5556 and upper(flv.meaning) = decode(
5557 upper(substr(peft.filing_status,1,7)),
5558 'MARRIED',
5559 'MARRIED',
5560 upper(peft.filing_status))
5561 and peft.assignment_id = p_assignment
5562 and language = 'US' ;
5563
5564
5565 cursor csr_get_asg_gre (p_assignment number)is
5566 select hsck.segment1
5567 from hr_soft_coding_keyflex hsck,
5568 per_assignments_f paf
5569 where paf.assignment_id = p_assignment
5570 and p_effective_start_date between paf.effective_start_date
5571 and paf.effective_end_date
5572 and paf.soft_coding_keyflex_id = hsck.soft_coding_keyflex_id;
5573
5574 cursor csr_fed_or_def (p_tax_unit_id in number, p_state varchar2)is
5575 select hoi.org_information12
5576 from pay_us_states pus,
5577 hr_organization_information hoi
5578 where hoi.organization_id = p_tax_unit_id
5579 and hoi.org_information_context = 'State Tax Rules'
5580 and pus.state_code = p_state
5581 and hoi.org_information1 = pus.state_abbrev;
5582
5583
5584 cursor chk_state_exists is
5585 select 'Y'
5586 from dual
5587 where exists (select null
5588 from pay_us_emp_state_tax_rules_f pst
5589 where pst.assignment_id = p_assignment_id
5590 and state_code = p_state_code
5591 and business_group_id + 0 = p_business_group_id);
5592
5593 l_flag varchar2(1) := 'N';
5594
5595 begin
5596
5597 hr_utility.set_location('pay_us_emp_dt_tax_rules.ins_def_state',1);
5598
5599 open chk_state_exists;
5600 fetch chk_state_exists into l_flag;
5601 if chk_state_exists%NOTFOUND then
5602 l_flag := 'N';
5603 end if;
5604 close chk_state_exists;
5605
5606 hr_utility.set_location('pay_us_emp_dt_tax_rules.ins_def_state',91);
5607 if l_flag = 'N'then
5608 open csr_get_asg_gre(p_assignment_id);
5609 fetch csr_get_asg_gre into ln_asg_tax_unit_id;
5610 close csr_get_asg_gre;
5611
5612 open csr_fed_or_def(ln_asg_tax_unit_id, p_state_code);
5613 fetch csr_fed_or_def into l_def_pref;
5614
5615 hr_utility.set_location('pay_us_emp_dt_tax_rules.ins_def_state',2);
5616
5617 if csr_fed_or_def%NOTFOUND then
5618 l_filing_status_code := '01';
5619 l_allowances := 0;
5620 end if;
5621 close csr_fed_or_def;
5622
5623 hr_utility.set_location('pay_us_emp_dt_tax_rules.ins_def_state',3);
5624
5625
5626 /* Bug 864068 - Added check for Connecticut (p_state_code = 07) to default
5627 the filing status for new Connecticut State Tax records to '07' instead
5628 of '01'; while '01' is single for most states and withholds state tax at
5629 the highest rate, '01' for Connecticut is married, with combined income
5630 less than $100,500 which isn't the highest tax rate. '07' is a new
5631 Vertex code for 'No Tax Form on File' which ensures withholding at
5632 the highest rate.
5633 */
5634
5635 if p_state_code = '07' then
5636 hr_utility.set_location('pay_us_emp_dt_tax_rules.ins_def_state',4);
5637 l_filing_status_code := '07';
5638 l_allowances := 0;
5639 elsif p_state_code = '22' then -- Bug No 4325326
5640 hr_utility.set_location('pay_us_emp_dt_tax_rules.ins_def_state',4.4);
5641 l_filing_status_code := '04';
5642 l_allowances := 0;
5643 elsif l_def_pref = 'SINGLE_ZERO' or l_def_pref is null then
5644 hr_utility.set_location('pay_us_emp_dt_tax_rules.ins_def_state',5);
5645 l_filing_status_code := '01';
5646 l_allowances := 0;
5647 elsif l_def_pref = 'FED_DEF' then
5648 hr_utility.set_location('pay_us_emp_dt_tax_rules.ins_def_state',6);
5649 open csr_filing_status(p_assignment_id, p_state_code);
5650 fetch csr_filing_status into l_filing_status_code, l_allowances;
5651 if csr_filing_status%NOTFOUND then
5652 hr_utility.set_location('pay_us_emp_dt_tax_rules.ins_def_state',7);
5653 l_filing_status_code := '01';
5654 l_allowances := 0;
5655 end if;
5656 close csr_filing_status;
5657
5658 end if;
5659
5660 /* Insert State Tax record */
5661
5662 hr_utility.set_location('pay_us_emp_dt_tax_rules.ins_def_state',8);
5663
5664 insert_state_tax_row ( p_row_id => l_row_id,
5665 p_emp_state_tax_rule_id => l_emp_state_tax_rule_id,
5666 p_effective_start_date => p_effective_start_date,
5667 p_effective_end_date => p_effective_end_date,
5668 p_assignment_id => p_assignment_id,
5669 p_state_code => p_state_code,
5670 p_jurisdiction_code => p_state_code ||'-000-0000',
5671 p_business_group_id => p_business_group_id,
5672 p_additional_wa_amount => 0,
5673 p_filing_status_code => lpad(l_filing_status_code,2,'0'),
5674 p_remainder_percent => 0,
5675 p_secondary_wa => 0,
5676 p_sit_additional_tax => 0,
5677 p_sit_override_amount => 0,
5678 p_sit_override_rate => 0,
5679 p_withholding_allowances => l_allowances,
5680 p_excessive_wa_reject_date => null,
5681 p_sdi_exempt => 'N',
5682 p_sit_exempt => 'N',
5683 p_sit_optional_calc_ind => null,
5684 p_state_non_resident_cert => 'N',
5685 p_sui_exempt => 'N',
5686 p_wc_exempt => null,
5687 p_wage_exempt => 'N',
5688 p_sui_wage_base_override_amt => null,
5689 p_supp_tax_override_rate => 0,
5690 p_time_in_state => nvl(p_percent_time,0),
5691 p_attribute_category => null,
5692 p_attribute1 => null,
5693 p_attribute2 => null,
5694 p_attribute3 => null,
5695 p_attribute4 => null,
5696 p_attribute5 => null,
5697 p_attribute6 => null,
5698 p_attribute7 => null,
5699 p_attribute8 => null,
5700 p_attribute9 => null,
5701 p_attribute10 => null,
5702 p_attribute11 => null,
5703 p_attribute12 => null,
5704 p_attribute13 => null,
5705 p_attribute14 => null,
5706 p_attribute15 => null,
5707 p_attribute16 => null,
5708 p_attribute17 => null,
5709 p_attribute18 => null,
5710 p_attribute19 => null,
5711 p_attribute20 => null,
5712 p_attribute21 => null,
5713 p_attribute22 => null,
5714 p_attribute23 => null,
5715 p_attribute24 => null,
5716 p_attribute25 => null,
5717 p_attribute26 => null,
5718 p_attribute27 => null,
5719 p_attribute28 => null,
5720 p_attribute29 => null,
5721 p_attribute30 => null,
5722 p_sta_information_category => null,
5723 p_sta_information1 => null,
5724 p_sta_information2 => null,
5725 p_sta_information3 => null,
5726 p_sta_information4 => null,
5727 p_sta_information5 => null,
5728 p_sta_information6 => null,
5729 p_sta_information7 => null,
5730 p_sta_information8 => null,
5731 p_sta_information9 => null,
5732 p_sta_information10 => null,
5733 p_sta_information11 => null,
5734 p_sta_information12 => null,
5735 p_sta_information13 => null,
5736 p_sta_information14 => null,
5737 p_sta_information15 => null,
5738 p_sta_information16 => null,
5739 p_sta_information17 => null,
5740 p_sta_information18 => null,
5741 p_sta_information19 => null,
5742 p_sta_information20 => null,
5743 p_sta_information21 => null,
5744 p_sta_information22 => null,
5745 p_sta_information23 => null,
5746 p_sta_information24 => null,
5747 p_sta_information25 => null,
5748 p_sta_information26 => null,
5749 p_sta_information27 => null,
5750 p_sta_information28 => null,
5751 p_sta_information29 => null,
5752 p_sta_information30 => null );
5753
5754 hr_utility.set_location('pay_us_emp_dt_tax_rules.ins_def_state',9);
5755
5756 end if;
5757
5758 hr_utility.set_location('pay_us_emp_dt_tax_rules.ins_def_state',10);
5759
5760 return l_emp_state_tax_rule_id;
5761
5762 end insert_def_state_rec;
5763
5764
5765 function insert_def_county_rec(p_assignment_id number,
5766 p_effective_start_date date,
5767 p_effective_end_date date,
5768 p_state_code varchar2,
5769 p_county_code varchar2,
5770 p_business_group_id number,
5771 p_percent_time number)
5772 return number is
5773
5774 l_filing_status_code varchar2(2);
5775 l_emp_county_tax_rule_id number;
5776 l_row_id varchar2(30);
5777
5778 /*
5779 cursor csr_filing_status is
5780 select lookup_code
5781 from HR_LOOKUPS
5782 where lookup_type = 'US_LIT_FILING_STATUS'
5783 and upper(meaning) = 'SINGLE';
5784 */
5785
5786 cursor csr_filing_status is
5787 select lookup_code
5788 from FND_LOOKUP_VALUES
5789 where lookup_type = 'US_LIT_FILING_STATUS'
5790 and upper(meaning) = 'SINGLE'
5791 and language = 'US';
5792
5793 cursor chk_county_exists is
5794 select 'Y'
5795 from dual
5796 where exists (select null
5797 from pay_us_emp_county_tax_rules_f pst
5798 where pst.assignment_id = p_assignment_id
5799 and state_code = p_state_code
5800 and county_code = p_county_code
5801 and business_group_id + 0 = p_business_group_id);
5802
5803 l_flag varchar2(1) := 'N';
5804
5805 begin
5806
5807 hr_utility.set_location('pay_us_emp_dt_tax_rules.insert_def_county_rec',1);
5808
5809 open chk_county_exists;
5810 fetch chk_county_exists into l_flag;
5811 if chk_county_exists%NOTFOUND then
5812 l_flag := 'N';
5813 end if;
5814 close chk_county_exists;
5815
5816 hr_utility.set_location('pay_us_emp_dt_tax_rules.insert_def_county_rec',91);
5817
5818 if l_flag = 'N' then
5819
5820 open csr_filing_status;
5821
5822 fetch csr_filing_status into l_filing_status_code;
5823
5824 hr_utility.set_location('pay_us_emp_dt_tax_rules.insert_def_county_rec',2);
5825
5826 if csr_filing_status%NOTFOUND then
5827
5828 fnd_message.set_name('PAY','HR_6091_DEF_MISSING_LOOKUPS');
5829 fnd_message.set_token('LOOKUP_TYPE ','US_LIT_FILING_STATUS');
5830 fnd_message.raise_error;
5831
5832 end if;
5833
5834 close csr_filing_status;
5835
5836 /* Insert County Tax record */
5837
5838 hr_utility.set_location('pay_us_emp_dt_tax_rules.insert_def_county_rec',3);
5839
5840
5841 insert_county_tax_row(p_row_id => l_row_id,
5842 p_emp_county_tax_rule_id => l_emp_county_tax_rule_id,
5843 p_effective_start_date => p_effective_start_date,
5844 p_effective_end_date => p_effective_end_date,
5845 p_assignment_id => p_assignment_id,
5846 p_state_code => p_state_code,
5847 p_county_code => p_county_code,
5848 p_business_group_id => p_business_group_id,
5849 p_additional_wa_rate => 0,
5850 p_filing_status_code => lpad(l_filing_status_code,2,'0'),
5851 p_jurisdiction_code => p_state_code || '-' ||
5852 p_county_code ||'-0000',
5853 p_lit_additional_tax => 0,
5854 p_lit_override_amount => 0,
5855 p_lit_override_rate => 0,
5856 p_withholding_allowances => 0,
5857 p_lit_exempt => 'N',
5858 p_sd_exempt => null,
5859 p_ht_exempt => null,
5860 p_wage_exempt => 'N',
5861 p_school_district_code => null,
5862 p_time_in_county => nvl(p_percent_time,0),
5863 p_attribute_category => null,
5864 p_attribute1 => null,
5865 p_attribute2 => null,
5866 p_attribute3 => null,
5867 p_attribute4 => null,
5868 p_attribute5 => null,
5869 p_attribute6 => null,
5870 p_attribute7 => null,
5871 p_attribute8 => null,
5872 p_attribute9 => null,
5873 p_attribute10 => null,
5874 p_attribute11 => null,
5875 p_attribute12 => null,
5876 p_attribute13 => null,
5877 p_attribute14 => null,
5878 p_attribute15 => null,
5879 p_attribute16 => null,
5880 p_attribute17 => null,
5881 p_attribute18 => null,
5882 p_attribute19 => null,
5883 p_attribute20 => null,
5884 p_attribute21 => null,
5885 p_attribute22 => null,
5886 p_attribute23 => null,
5887 p_attribute24 => null,
5888 p_attribute25 => null,
5889 p_attribute26 => null,
5890 p_attribute27 => null,
5891 p_attribute28 => null,
5892 p_attribute29 => null,
5893 p_attribute30 => null,
5894 p_cnt_information_category => null,
5895 p_cnt_information1 => null,
5896 p_cnt_information2 => null,
5897 p_cnt_information3 => null,
5898 p_cnt_information4 => null,
5899 p_cnt_information5 => null,
5900 p_cnt_information6 => null,
5901 p_cnt_information7 => null,
5902 p_cnt_information8 => null,
5903 p_cnt_information9 => null,
5904 p_cnt_information10 => null,
5905 p_cnt_information11 => null,
5906 p_cnt_information12 => null,
5907 p_cnt_information13 => null,
5908 p_cnt_information14 => null,
5909 p_cnt_information15 => null,
5910 p_cnt_information16 => null,
5911 p_cnt_information17 => null,
5912 p_cnt_information18 => null,
5913 p_cnt_information19 => null,
5914 p_cnt_information20 => null,
5915 p_cnt_information21 => null,
5916 p_cnt_information22 => null,
5917 p_cnt_information23 => null,
5918 p_cnt_information24 => null,
5919 p_cnt_information25 => null,
5920 p_cnt_information26 => null,
5921 p_cnt_information27 => null,
5922 p_cnt_information28 => null,
5923 p_cnt_information29 => null,
5924 p_cnt_information30 => null );
5925
5926 hr_utility.set_location('pay_us_emp_dt_tax_rules.insert_def_county_rec',4);
5927 end if;
5928 hr_utility.set_location('pay_us_emp_dt_tax_rules.insert_def_county_rec',5);
5929
5930 return l_emp_county_tax_rule_id;
5931
5932 end insert_def_county_rec;
5933
5934
5935 function insert_def_city_rec(p_assignment_id number,
5936 p_effective_start_date date,
5937 p_effective_end_date date,
5938 p_state_code varchar2,
5939 p_county_code varchar2,
5940 p_city_code varchar2,
5941 p_business_group_id number,
5942 p_percent_time number)
5943 return number is
5944
5945 l_filing_status_code varchar2(2);
5946 l_emp_city_tax_rule_id number;
5947 l_row_id varchar2(30);
5948
5949 /*
5950 cursor csr_filing_status is
5951 select lookup_code
5952 from HR_LOOKUPS
5953 where lookup_type = 'US_LIT_FILING_STATUS'
5954 and upper(meaning) = 'SINGLE';
5955 */
5956
5957 cursor csr_filing_status is
5958 select lookup_code
5959 from FND_LOOKUP_VALUES
5960 where lookup_type = 'US_LIT_FILING_STATUS'
5961 and upper(meaning) = 'SINGLE'
5962 and language = 'US';
5963
5964 cursor chk_city_exists is
5965 select 'Y'
5966 from dual
5967 where exists (select null
5968 from pay_us_emp_city_tax_rules_f pst
5969 where pst.assignment_id = p_assignment_id
5970 and state_code = p_state_code
5971 and county_code = p_county_code
5972 and city_code = p_city_code
5973 and business_group_id + 0 = p_business_group_id);
5974
5975 l_flag varchar2(1) := 'N';
5976
5977
5978 begin
5979
5980 hr_utility.set_location('pay_us_emp_dt_tax_rules.insert_def_city_rec',1);
5981
5982 open chk_city_exists;
5983 fetch chk_city_exists into l_flag;
5984 if chk_city_exists%NOTFOUND then
5985 l_flag := 'N';
5986 end if;
5987 close chk_city_exists;
5988
5989 hr_utility.set_location('pay_us_emp_dt_tax_rules.insert_def_city_rec',91);
5990
5991 if l_flag = 'N' then
5992
5993 open csr_filing_status;
5994
5995 fetch csr_filing_status into l_filing_status_code;
5996
5997 hr_utility.set_location('pay_us_emp_dt_tax_rules.insert_def_city_rec',2);
5998
5999 if csr_filing_status%NOTFOUND then
6000
6001 fnd_message.set_name('PAY','HR_6091_DEF_MISSING_LOOKUPS');
6002 fnd_message.set_token('LOOKUP_TYPE ','US_LIT_FILING_STATUS');
6003 fnd_message.raise_error;
6004
6005 end if;
6006
6007 close csr_filing_status;
6008
6009 /* Insert City Tax record */
6010
6011 hr_utility.set_location('pay_us_emp_dt_tax_rules.insert_def_city_rec',3);
6012
6013
6014 insert_city_tax_row(p_row_id => l_row_id,
6015 p_emp_city_tax_rule_id => l_emp_city_tax_rule_id,
6016 p_effective_start_date => p_effective_start_date,
6017 p_effective_end_date => p_effective_end_date,
6018 p_assignment_id => p_assignment_id,
6019 p_state_code => p_state_code,
6020 p_county_code => p_county_code,
6021 p_city_code => p_city_code,
6022 p_business_group_id => p_business_group_id,
6023 p_additional_wa_rate => 0,
6024 p_filing_status_code => lpad(l_filing_status_code,2,'0'),
6025 p_jurisdiction_code => p_state_code || '-' ||
6026 p_county_code ||'-' || p_city_code,
6027 p_lit_additional_tax => 0,
6028 p_lit_override_amount => 0,
6029 p_lit_override_rate => 0,
6030 p_withholding_allowances => 0,
6031 p_lit_exempt => 'N',
6032 p_sd_exempt => null,
6033 p_ht_exempt => null,
6034 p_wage_exempt => 'N',
6035 p_school_district_code => null,
6036 p_time_in_city => nvl(p_percent_time,0),
6037 p_attribute_category => null,
6038 p_attribute1 => null,
6039 p_attribute2 => null,
6040 p_attribute3 => null,
6041 p_attribute4 => null,
6042 p_attribute5 => null,
6043 p_attribute6 => null,
6044 p_attribute7 => null,
6045 p_attribute8 => null,
6046 p_attribute9 => null,
6047 p_attribute10 => null,
6048 p_attribute11 => null,
6049 p_attribute12 => null,
6050 p_attribute13 => null,
6051 p_attribute14 => null,
6052 p_attribute15 => null,
6053 p_attribute16 => null,
6054 p_attribute17 => null,
6055 p_attribute18 => null,
6056 p_attribute19 => null,
6057 p_attribute20 => null,
6058 p_attribute21 => null,
6059 p_attribute22 => null,
6060 p_attribute23 => null,
6061 p_attribute24 => null,
6062 p_attribute25 => null,
6063 p_attribute26 => null,
6064 p_attribute27 => null,
6065 p_attribute28 => null,
6066 p_attribute29 => null,
6067 p_attribute30 => null,
6068 p_cty_information_category => null,
6069 p_cty_information1 => null,
6070 p_cty_information2 => null,
6071 p_cty_information3 => null,
6072 p_cty_information4 => null,
6073 p_cty_information5 => null,
6074 p_cty_information6 => null,
6075 p_cty_information7 => null,
6076 p_cty_information8 => null,
6077 p_cty_information9 => null,
6078 p_cty_information10 => null,
6079 p_cty_information11 => null,
6080 p_cty_information12 => null,
6081 p_cty_information13 => null,
6082 p_cty_information14 => null,
6083 p_cty_information15 => null,
6084 p_cty_information16 => null,
6085 p_cty_information17 => null,
6086 p_cty_information18 => null,
6087 p_cty_information19 => null,
6088 p_cty_information20 => null,
6089 p_cty_information21 => null,
6090 p_cty_information22 => null,
6091 p_cty_information23 => null,
6092 p_cty_information24 => null,
6093 p_cty_information25 => null,
6094 p_cty_information26 => null,
6095 p_cty_information27 => null,
6096 p_cty_information28 => null,
6097 p_cty_information29 => null,
6098 p_cty_information30 => null );
6099
6100 hr_utility.set_location('pay_us_emp_dt_tax_rules.insert_def_city_rec',4);
6101 end if;
6102
6103 hr_utility.set_location('pay_us_emp_dt_tax_rules.insert_def_city_rec',5);
6104
6105 return l_emp_city_tax_rule_id;
6106
6107 end insert_def_city_rec;
6108
6109
6110 /* Name : zero_out_time
6111 Purpose : Zero out time in state and localities
6112 in preparation for setting the city of
6113 the new work location to 100%
6114 */
6115
6116 procedure zero_out_time(p_assignment_id in number,
6117 p_effective_start_date in date,
6118 p_effective_end_date in date) is
6119
6120 l_jurisdiction_code varchar2(11);
6121 l_eff_start_date date;
6122
6123 /* Cursor to retrieve the jurisdictions for all existing
6124 VERTEX element entries */
6125
6126 cursor csr_get_jurisdiction is
6127 select peev.screen_entry_value jurisdiction,
6128 peef.effective_start_date start_date
6129 from PAY_ELEMENT_ENTRY_VALUES_F peev,
6130 PAY_ELEMENT_ENTRIES_F peef,
6131 PAY_INPUT_VALUES_F piv,
6132 PAY_ELEMENT_TYPES_F pet
6133 where pet.element_name = 'VERTEX'
6134 and pet.element_type_id = piv.element_type_id
6135 and piv.name = 'Jurisdiction'
6136 and piv.input_value_id = 0 + peev.input_value_id
6137 and peev.element_entry_id = peef.element_entry_id
6138 and peev.effective_start_date = peef.effective_start_date
6139 and peev.effective_end_date = peef.effective_end_date
6140 and p_assignment_id = peef.assignment_id
6141 and peef.effective_start_date = p_effective_start_date
6142 and peef.effective_end_date = p_effective_end_date
6143 and peef.effective_start_date between pet.effective_start_date and pet.effective_end_date; -- Bug 3354060 added to remove MJC between
6144 -- PAY_INPUT_VALUES_F and
6145 -- PAY_ELEMENT_ENTRIES_F
6146
6147 begin
6148
6149 hr_utility.set_location('pay_us_emp_dt_tax_rules.zero_out_time',1);
6150
6151 open csr_get_jurisdiction;
6152
6153 /* Now loop through all VERTEX element entries
6154 and set them to zero. */
6155
6156 loop
6157
6158 fetch csr_get_jurisdiction into l_jurisdiction_code,
6159 l_eff_start_date;
6160
6161 exit when csr_get_jurisdiction%NOTFOUND;
6162
6163 /* For the jurisdiction, set the %age time in that
6164 jurisdiction to zero */
6165
6166 maintain_element_entry(
6167 p_assignment_id => p_assignment_id,
6168 p_effective_start_date => p_effective_start_date,
6169 p_effective_end_date => p_effective_end_date,
6170 p_session_date => l_eff_start_date,
6171 p_jurisdiction_code => l_jurisdiction_code,
6172 p_percentage_time => 0,
6173 p_mode => 'CORRECTION');
6174
6175 end loop;
6176
6177 close csr_get_jurisdiction;
6178
6179 hr_utility.set_location('pay_us_emp_dt_tax_rules.zero_out_time',2);
6180
6181 end zero_out_time;
6182
6183 /* Name : set_sui_wage_base_override
6184 Purpose : To update sui_wage_base_override_amount for the new work location,
6185 with respect to every change in location state. The procedure
6186 will also take care of the condition of changing GRE when work
6187 location state remains unchanged / changed as well Rehire condition.
6188 */
6189
6190 procedure set_sui_wage_base_override(p_assignment_id in number,
6191 p_state_code in varchar2 default null,
6192 p_session_date in date)
6193 is
6194
6195 l_sui_er_wg_lt_curr_state pay_us_state_tax_info_f.sui_er_wage_limit%type ;
6196 l_max_asg_eff_st_dt date ;
6197 l_max_pact_dt date ;
6198 l_tax_unit_id number ;
6199 l_defined_balance_id pay_defined_balances.defined_balance_id%type ;
6200 l_balance_value number ;
6201 l_oth_combined_balance number ;
6202 l_combined_balance_value number ;
6203 l_sui_wg_base number ;
6204 l_jurisdiction_code varchar2(11) ;
6205 l_count number := 0 ;
6206 l_rehired varchar2(1) := 'N' ;
6207 l_actual_balance_value number ;
6208 l_person_id number ;
6209
6210 cursor c_all_states(p_assignment_id in number,
6211 p_session_date in date) is
6212 select state_code
6213 from pay_us_emp_state_tax_rules_f
6214 where assignment_id = p_assignment_id ;
6215
6216 cursor c_tax_unit_id(p_assignment_id in number,
6217 p_session_date in date) is
6218 select to_number(segment1) tax_unit_id
6219 from hr_soft_coding_keyflex a,
6220 per_assignments_f b
6221 where b.assignment_id = p_assignment_id
6222 and b.soft_coding_keyflex_id = a.soft_coding_keyflex_id
6223 and p_session_date between b.effective_start_date and b.effective_end_date ;
6224
6225 cursor c_defined_balance_id(p_dbi_name in varchar2) is
6226 select fnd_number.canonical_to_number(UE.creator_id)
6227 from ff_user_entities UE,
6228 ff_database_items DI
6229 where DI.user_name = p_dbi_name --'SUI_ER_TAXABLE_PER_JD_GRE_YTD'
6230 and UE.user_entity_id = DI.user_entity_id
6231 and Ue.creator_type = 'B'
6232 and UE.legislation_code = 'US' ;
6233
6234 cursor c_max_asg_eff_st_date(p_assignment_id in number) is
6235 select max(effective_start_date)
6236 from per_assignments_f paf,
6237 per_assignment_status_types past
6238 where paf.assignment_id = p_assignment_id
6239 and paf.assignment_status_type_id = past.assignment_status_type_id
6240 and past.per_system_status = 'ACTIVE_ASSIGN'
6241 and ((past.business_group_id is null
6242 and past.legislation_code is null)
6243 OR (past.business_group_id is null
6244 and past.legislation_code = 'US')
6245 OR (past.legislation_code is null
6246 and exists
6247 (select 'x'
6248 from per_assignments_f paf_i
6249 where paf_i.assignment_id = p_assignment_id
6250 and paf_i.business_group_id = past.business_group_id)
6251 )
6252 )
6253 and paf.payroll_id is not null ;
6254
6255 cursor c_sui_wage_limit(p_state_code in varchar2, p_effective_date in date) is
6256 select sui_er_wage_limit
6257 from pay_us_state_tax_info_f
6258 where p_effective_date between effective_start_date
6259 and effective_end_date
6260 and sta_information_category = 'State tax limit rate info'
6261 and state_code = p_state_code ;
6262
6263 Cursor c_max_pact_dt(p_assignment_id in number,
6264 p_session_date in date) is
6265 select max(effective_date)
6266 from pay_payroll_actions ppa,
6267 pay_assignment_actions paa,
6268 per_assignments_f paf
6269 where paf.assignment_id = p_assignment_id
6270 and paf.assignment_id = paa.assignment_id
6271 and paa.payroll_action_id = ppa.payroll_action_id
6272 and ppa.action_type in ('R','Q','B','V','I')
6273 and nvl(ppa.date_earned,ppa.effective_date) between trunc(p_session_date,'Y')
6274 and last_day(add_months(trunc(p_session_date,'Y'),11)) ;
6275
6276 Cursor c_ckeck_rehire(p_assignment_id in number,
6277 p_session_date in date) is
6278 select 'Y'
6279 from per_assignments_f paf_o,
6280 per_assignment_status_types past
6281 where paf_o.assignment_id = p_assignment_id
6282 and paf_o.assignment_status_type_id = past.assignment_status_type_id
6283 and past.per_system_status = 'ACTIVE_ASSIGN'
6284 and ((past.business_group_id is null
6285 and past.legislation_code is null)
6286 OR (past.business_group_id is null
6287 and past.legislation_code = 'US')
6288 OR (past.legislation_code is null
6289 and exists
6290 (select 'x'
6291 from per_assignments_f paf_a
6292 where paf_a.assignment_id = p_assignment_id
6293 and paf_a.business_group_id = past.business_group_id)
6294 )
6295 )
6296
6297 and exists
6298 (
6299 select distinct paf_i.assignment_id
6300 from per_assignments_f paf_i,
6301 per_assignments_f paf_term
6302 where paf_i.person_id = paf_o.person_id
6303 and paf_i.person_id = paf_term.person_id
6304 and paf_i.assignment_id > paf_term.assignment_id
6305 and paf_i.effective_start_date >= paf_term.effective_end_date
6306 and ( trunc(paf_i.effective_end_date,'Y') = trunc(p_session_date,'Y')
6307 or (trunc(paf_i.effective_start_date,'Y') = trunc(p_session_date,'Y')
6308 and trunc(paf_i.effective_end_date,'Y') > trunc(p_session_date,'Y')))
6309 ) ;
6310
6311 Cursor c_get_person_id(p_assignment_id in number) is
6312 select distinct paf.person_id
6313 from per_assignments_f paf
6314 where paf.assignment_id = p_assignment_id ;
6315
6316 Cursor c_get_all_assignments(p_person_id in number,
6317 p_session_date in date) is
6318 select distinct paf.assignment_id
6319 from per_assignments_f paf
6320 where paf.person_id = p_person_id
6321 and ( trunc(paf.effective_end_date,'Y') = trunc(p_session_date,'Y')
6322 or (trunc(paf.effective_start_date,'Y') = trunc(p_session_date,'Y')
6323 and trunc(paf.effective_end_date,'Y') > trunc(p_session_date,'Y'))) ;
6324
6325
6326 type state_code_typ is table of varchar2(2) index by BINARY_INTEGER ;
6327 state_code_tab state_code_typ ;
6328 type balance_typ is table of number index by BINARY_INTEGER ;
6329 balance_tab balance_typ ;
6330 begin
6331 --hr_utility.trace_on(null,'pyusdtw4') ;
6332
6333 hr_utility.trace('Entering pay_us_emp_dt_tax_rules.set_sui_wage_base_override.') ;
6334 hr_utility.trace('p_assignment_id := ' || to_char(p_assignment_id)) ;
6335 hr_utility.trace('p_state_code := ' || p_state_code) ;
6336 hr_utility.trace('p_session_date := ' || to_char(p_session_date)) ;
6337
6338 l_balance_value := 0 ;
6339 l_combined_balance_value := 0 ;
6340 l_sui_wg_base := 0 ;
6341 l_actual_balance_value := 0 ;
6342 l_oth_combined_balance := 0 ;
6343
6344 hr_utility.trace('Getting Effective Start Date of Latest Active Assignment.') ;
6345 open c_max_asg_eff_st_date(p_assignment_id) ;
6346 fetch c_max_asg_eff_st_date into l_max_asg_eff_st_dt ;
6347 if c_max_asg_eff_st_date%notfound then
6348 close c_max_asg_eff_st_date ;
6349 raise hr_utility.hr_error ;
6350 end if ;
6351 hr_utility.trace('Effective Start Date of Latest Active Assignment: '|| to_char(l_max_asg_eff_st_dt)) ;
6352
6353 hr_utility.trace('Getting Effective Date of Latest Payroll Action ID.') ;
6354 open c_max_pact_dt(p_assignment_id, p_session_date) ;
6355 fetch c_max_pact_dt into l_max_pact_dt ;
6356 if c_max_pact_dt%notfound then
6357 close c_max_pact_dt ;
6358 raise hr_utility.hr_error ;
6359 end if ;
6360 hr_utility.trace('Effective Date of Latest Payroll Action ID: '|| to_char(l_max_pact_dt)) ;
6361
6362 hr_utility.trace('Getting Defined Balance ID for SUI_ER_TAXABLE_PER_JD_GRE_YTD.') ;
6363 open c_defined_balance_id('SUI_ER_TAXABLE_PER_JD_GRE_YTD') ;
6364 fetch c_defined_balance_id into l_defined_balance_id ;
6365 if c_defined_balance_id%notfound then
6366 close c_defined_balance_id ;
6367 raise hr_utility.hr_error ;
6368 end if ;
6369 hr_utility.trace('Defined Balance ID for SUI_ER_TAXABLE_PER_JD_GRE_YTD: '|| to_char(l_defined_balance_id)) ;
6370
6371 hr_utility.trace('Getting Tax Unit ID.') ;
6372 open c_tax_unit_id(p_assignment_id, p_session_date ) ;
6373 fetch c_tax_unit_id into l_tax_unit_id ;
6374 if c_tax_unit_id%notfound then
6375 close c_tax_unit_id ;
6376 raise hr_utility.hr_error ;
6377 end if ;
6378 hr_utility.trace('Tax Unit ID: '|| to_char(l_tax_unit_id)) ;
6379
6380 hr_utility.trace('Getting Person ID.') ;
6381 open c_get_person_id(p_assignment_id) ;
6382 fetch c_get_person_id into l_person_id ;
6383 if c_get_person_id%notfound then
6384 close c_get_person_id ;
6385 raise hr_utility.hr_error ;
6386 end if ;
6387 hr_utility.trace('Person ID: '|| to_char(l_person_id)) ;
6388
6389 hr_utility.trace('p_state_code := '||p_state_code) ;
6390 hr_utility.trace('p_assignment_id..Original := '||to_char(p_assignment_id)) ;
6391
6392 hr_utility.trace('Getting Rehire Y or N Flag.') ;
6393 open c_ckeck_rehire(p_assignment_id, p_session_date) ;
6394 fetch c_ckeck_rehire into l_rehired ;
6395 if c_ckeck_rehire%notfound then
6396 l_rehired := 'N' ;
6397 close c_ckeck_rehire ;
6398 end if ;
6399 hr_utility.trace('Rehire Flag Value: '|| l_rehired) ;
6400
6401 IF nvl(l_rehired,'N') = 'Y' THEN
6402 l_count := 1 ;
6403 /* For Rehired Condition, iterating through all the assignments for the concerned person
6404 either active for the current year or was effective from earlier and terminated within the current year */
6405 for i_get_all_assignments in c_get_all_assignments(l_person_id,p_session_date)
6406 loop
6407 hr_utility.trace('l_person_id := '||to_char(l_person_id)) ;
6408 /* For each of the above-mentioned assignment iterating through all the states the employee worked on
6409 and populating PL/SQL table with the SUI ER Taxable Balance value and corresponding State Code */
6410 for i_all_states in c_all_states(i_get_all_assignments.assignment_id,p_session_date)
6411 loop
6412 IF i_all_states.state_code <> '24' THEN
6413
6414 state_code_tab(l_count) := i_all_states.state_code ;
6415 l_jurisdiction_code := i_all_states.state_code || '-000-0000' ;
6416
6417 hr_utility.trace('l_count := '||to_char(l_count)) ;
6418 hr_utility.trace('i_get_all_assignments.assignment_id:= '||to_char(i_get_all_assignments.assignment_id)) ;
6419 hr_utility.trace('l_tax_unit_id := '||to_char(l_tax_unit_id)) ;
6420 hr_utility.trace('l_jurisdiction_code := '||l_jurisdiction_code) ;
6421
6422 pay_balance_pkg.set_context('TAX_UNIT_ID',l_tax_unit_id) ;
6423 pay_balance_pkg.set_context('JURISDICTION_CODE',l_jurisdiction_code) ;
6424
6425 l_balance_value := pay_balance_pkg.get_value(
6426 l_defined_balance_id ,
6427 p_assignment_id,
6428 nvl(l_max_pact_dt,GREATEST(l_max_asg_eff_st_dt,trunc(p_session_date,'Y')))) ;
6429
6430 balance_tab(l_count) := l_balance_value ;
6431
6432 hr_utility.trace('l_balance_value := '||to_char(l_balance_value)) ;
6433 /* Summing up the balance value */
6434 l_combined_balance_value := l_combined_balance_value + l_balance_value ;
6435
6436 hr_utility.trace('l_combined_balance_value := '||to_char(l_combined_balance_value)) ;
6437
6438 l_count := l_count + 1 ;
6439 END IF ;
6440 end loop ;
6441 end loop ;
6442 /* Eliminating the Duplicate 'State Code - Balance Value' combination and
6443 calculating the correct Summed up Balance value */
6444 IF state_code_tab.count <> 0 THEN
6445 for i in state_code_tab.first .. state_code_tab.last
6446 loop
6447 for j in 1 .. i-1
6448 loop
6449 if state_code_tab(i) = state_code_tab(j) then
6450 l_combined_balance_value := l_combined_balance_value - balance_tab(i) ;
6451 exit ;
6452 end if ;
6453 end loop ;
6454 end loop ;
6455 END IF ;
6456 hr_utility.trace('l_combined_balance_value B4 Subtracting Actual := '||to_char(l_combined_balance_value)) ;
6457 /* Looping through the current States under the Current Active Assignment
6458 and doing a balance call wrt to current jurisdiction and calculating
6459 eligible SUI Wage Base Override for the State */
6460 for i_all_curr_states in c_all_states(p_assignment_id,p_session_date)
6461 loop
6462 IF i_all_curr_states.state_code <> '24' THEN
6463
6464 l_jurisdiction_code := i_all_curr_states.state_code || '-000-0000' ;
6465
6466
6467 pay_balance_pkg.set_context('TAX_UNIT_ID',l_tax_unit_id) ;
6468 pay_balance_pkg.set_context('JURISDICTION_CODE',l_jurisdiction_code) ;
6469
6470 l_actual_balance_value := pay_balance_pkg.get_value(
6471 l_defined_balance_id ,
6472 p_assignment_id,
6473 nvl(l_max_pact_dt,GREATEST(l_max_asg_eff_st_dt,trunc(p_session_date,'Y')))) ;
6474
6475 l_oth_combined_balance := l_combined_balance_value - l_actual_balance_value ;
6476
6477 hr_utility.trace('Actual States := '||i_all_curr_states.state_code) ;
6478 hr_utility.trace('l_actual_balance_value := '||to_char(l_actual_balance_value)) ;
6479 hr_utility.trace('l_oth_combined_balance A4 Subtracting Actual := '||to_char(l_oth_combined_balance)) ;
6480
6481 open c_sui_wage_limit(i_all_curr_states.state_code, p_session_date) ;
6482 fetch c_sui_wage_limit into l_sui_er_wg_lt_curr_state ;
6483 close c_sui_wage_limit ;
6484 hr_utility.trace('SUI Wage Limit for the current State: '|| to_char(l_sui_er_wg_lt_curr_state)) ;
6485
6486 IF l_oth_combined_balance < l_sui_er_wg_lt_curr_state THEN
6487 l_sui_wg_base := l_sui_er_wg_lt_curr_state - l_oth_combined_balance ;
6488 ELSIF l_oth_combined_balance >= l_sui_er_wg_lt_curr_state THEN
6489 l_sui_wg_base := 0 ;
6490 END IF ;
6491 hr_utility.trace('l_sui_wg_base := '||to_char(l_sui_wg_base)) ;
6492
6493 IF l_oth_combined_balance > 0 OR l_actual_balance_value > 0 THEN
6494 update pay_us_emp_state_tax_rules_f
6495 set sui_wage_base_override_amount = l_sui_wg_base
6496 where assignment_id = p_assignment_id
6497 and state_code = i_all_curr_states.state_code ;
6498 ELSE
6499 update pay_us_emp_state_tax_rules_f
6500 set sui_wage_base_override_amount = null
6501 where assignment_id = p_assignment_id
6502 and state_code = i_all_curr_states.state_code ;
6503 END IF ;
6504 hr_utility.trace('SUI Wage Base Updated...') ;
6505 END IF ;
6506 end loop ;
6507 ELSE -- Not Rehired Condition
6508 hr_utility.trace('Not Rehired Condition... ') ;
6509 l_count := 1 ;
6510 /* Iterating through all the states where the employee worked for the Current Assignment
6511 and populating PL/SQL table with the State Code and SUI ER Taxable Balance value */
6512 for i_all_states in c_all_states(p_assignment_id,p_session_date)
6513 loop
6514 IF i_all_states.state_code <> '24' THEN
6515 hr_utility.trace('l_count := '||to_char(l_count)) ;
6516 state_code_tab(l_count) := i_all_states.state_code ;
6517 l_jurisdiction_code := i_all_states.state_code || '-000-0000' ;
6518
6519 hr_utility.trace('l_tax_unit_id := '||to_char(l_tax_unit_id)) ;
6520 hr_utility.trace('l_jurisdiction_code := '||l_jurisdiction_code) ;
6521
6522 pay_balance_pkg.set_context('TAX_UNIT_ID',l_tax_unit_id) ;
6523 pay_balance_pkg.set_context('JURISDICTION_CODE',l_jurisdiction_code) ;
6524
6525 l_balance_value := pay_balance_pkg.get_value(
6526 l_defined_balance_id ,
6527 p_assignment_id,
6528 nvl(l_max_pact_dt,GREATEST(l_max_asg_eff_st_dt,trunc(p_session_date,'Y')))) ;
6529
6530 balance_tab(l_count) := l_balance_value ;
6531 hr_utility.trace('l_balance_value := '||to_char(l_balance_value)) ;
6532 /* Summing up the Total Balance Value */
6533 l_combined_balance_value := l_combined_balance_value + l_balance_value ;
6534 hr_utility.trace('l_combined_balance_value := '||to_char(l_combined_balance_value)) ;
6535 l_count := l_count + 1 ;
6536
6537 END IF ;
6538 end loop ;
6539 /* Looping through the PL/SQL table to get the Eligible SUI Wage Base for each State
6540 and Updating the data */
6541 IF state_code_tab.count <> 0 THEN
6542 for i in state_code_tab.first .. state_code_tab.last
6543 loop
6544 l_oth_combined_balance := l_combined_balance_value - balance_tab(i) ;
6545
6546 open c_sui_wage_limit(state_code_tab(i), p_session_date) ;
6547 fetch c_sui_wage_limit into l_sui_er_wg_lt_curr_state ;
6548 close c_sui_wage_limit ;
6549 hr_utility.trace('SUI Wage Limit for the current State: '|| to_char(l_sui_er_wg_lt_curr_state)) ;
6550
6551 IF l_oth_combined_balance < l_sui_er_wg_lt_curr_state THEN
6552 l_sui_wg_base := l_sui_er_wg_lt_curr_state - l_oth_combined_balance ;
6553 ELSIF l_oth_combined_balance >= l_sui_er_wg_lt_curr_state THEN
6554 l_sui_wg_base := 0 ;
6555 END IF ;
6556 hr_utility.trace('State_code := '||state_code_tab(i)) ;
6557 hr_utility.trace('l_oth_combined_balance := '||to_char(l_oth_combined_balance)) ;
6558 hr_utility.trace('l_sui_wg_base := '||to_char(l_sui_wg_base)) ;
6559
6560 IF l_oth_combined_balance > 0 OR l_combined_balance_value > 0 THEN
6561 update pay_us_emp_state_tax_rules_f
6562 set sui_wage_base_override_amount = l_sui_wg_base
6563 where assignment_id = p_assignment_id
6564 and state_code = state_code_tab(i) ;
6565 ELSE
6566 update pay_us_emp_state_tax_rules_f
6567 set sui_wage_base_override_amount = null
6568 where assignment_id = p_assignment_id
6569 and state_code = state_code_tab(i) ;
6570 END IF ;
6571 hr_utility.trace('SUI Wage Base Updated...') ;
6572 end loop ;
6573 END IF ;
6574 END IF ;
6575 /* Exception for the State of Minnesota - No SUI Wage Transfer allowed */
6576 IF p_state_code = '24' THEN
6577 open c_sui_wage_limit(p_state_code, l_max_asg_eff_st_dt) ;
6578 fetch c_sui_wage_limit into l_sui_er_wg_lt_curr_state ;
6579 close c_sui_wage_limit ;
6580
6581 update pay_us_emp_state_tax_rules_f
6582 set sui_wage_base_override_amount = l_sui_er_wg_lt_curr_state
6583 where assignment_id = p_assignment_id
6584 and state_code = p_state_code ;
6585 END IF ;
6586
6587 end set_sui_wage_base_override;
6588
6589
6590 /* Name : create_new_location_rec
6591 Purpose : To create record for the new work location, with respect
6592 to every change in location and set the city record for
6593 the time period between p_validation_start_date and
6594 p_validation_end_date to 100%
6595 */
6596
6597 procedure create_new_location_rec(p_assignment_id in number,
6598 p_validation_start_date in date,
6599 p_validation_end_date in date,
6600 p_session_date in date,
6601 p_new_location_id in number,
6602 p_res_state_code in varchar2,
6603 p_res_county_code in varchar2,
6604 p_res_city_code in varchar2,
6605 p_business_group in number,
6606 p_percent in number) is
6607
6608 l_state_code varchar2(2);
6609 l_county_code varchar2(3);
6610 l_city_code varchar2(4);
6611 l_ovrd_state_code varchar2(2);
6612 l_ovrd_county_code varchar2(3);
6613 l_ovrd_city_code varchar2(4);
6614 l_jurisdiction_code varchar2(11);
6615 l_end_of_time date := to_date('31/12/4712','DD/MM/YYYY');
6616 l_ret_code number := 0;
6617 l_ret_text varchar2(240) := null;
6618 l_emp_state_tax_rule_id number;
6619 l_emp_county_tax_rule_id number;
6620 l_emp_city_tax_rule_id number;
6621 l_default_date date;
6622
6623
6624
6625 /* Cursor to get the state code, county code and the city code
6626 corresponding to a location id */
6627 /* lwthomps .. While we only want to create tax records for the
6628 primary cities, locations can corespond to vanity or secondary
6629 cities that share the same geocode. For this reason I am removing
6630 the join to pay_us_city_names for primary = 'Y' (588982) */
6631
6632 cursor csr_get_codes(p_location number) is
6633 select pus.state_code,
6634 puco.county_code,
6635 puci.city_code,
6636 pus1.state_code,
6637 puco1.county_code,
6638 puci1.city_code
6639 from PAY_US_CITY_NAMES puci1,
6640 PAY_US_COUNTIES puco1,
6641 PAY_US_STATES pus1,
6642 PAY_US_CITY_NAMES puci,
6643 PAY_US_COUNTIES puco,
6644 PAY_US_STATES pus,
6645 HR_LOCATIONS hrl
6646 where hrl.location_id = p_location
6647 and pus.state_abbrev = hrl.region_2
6648 and puco.state_code = pus.state_code
6649 and puco.county_name = hrl.region_1
6650 and puci.state_code = puco.state_code
6651 and puci.county_code = puco.county_code
6652 and puci.city_name = hrl.town_or_city
6653 and pus1.state_abbrev = nvl(hrl.loc_information17,hrl.region_2)
6654 and puco1.state_code = pus1.state_code
6655 and puco1.county_name = nvl(hrl.loc_information19,hrl.region_1)
6656 and puci1.state_code = puco1.state_code
6657 and puci1.county_code = puco1.county_code
6658 and puci1.city_name = nvl(hrl.loc_information18,hrl.town_or_city);
6659
6660 /* and puci.primary_flag = 'Y'; */
6661
6662 /* End changes by lwthomps (588982)*/
6663
6664 cursor csr_get_eff_date is
6665 select min(effective_start_date)
6666 from PAY_US_EMP_FED_TAX_RULES_F
6667 where assignment_id = p_assignment_id;
6668
6669 /* Added cursor csr_get_max_assign_end_dt
6670 for bug 2535501 to get the max(effective_end_date)
6671 of an assignment. This will ensure that the end_date
6672 of the state, county and city tax_rules_f tables
6673 will have correct end dates when a new row is created.
6674 */
6675
6676 cursor csr_get_max_assign_end_dt is
6677 select max(effective_end_date)
6678 from per_assignments_f
6679 where assignment_id = p_assignment_id;
6680
6681
6682 l_max_assign_end_dt date := NULL;
6683
6684 begin
6685
6686
6687 hr_utility.set_location('pay_us_emp_dt_tax_rules.create_new_location_rec',1);
6688 if (p_new_location_id is null) and (p_res_state_code is not null
6689 and p_res_county_code is not null
6690 and p_res_city_code is not null )then
6691
6692 /* called for residential address */
6693 l_state_code := p_res_state_code;
6694 l_county_code := p_res_county_code;
6695 l_city_code := p_res_city_code;
6696
6697 else /* called for work location */
6698
6699 /* Get the state code, county code and the city code for the
6700 new location */
6701
6702 hr_utility.set_location('pay_us_emp_dt_tax_rules.create_new_location_rec',2);
6703 open csr_get_codes(p_new_location_id);
6704 fetch csr_get_codes into l_state_code, l_county_code,l_city_code,
6705 l_ovrd_state_code, l_ovrd_county_code,
6706 l_ovrd_city_code;
6707 if csr_get_codes%NOTFOUND then
6708 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
6709 fnd_message.set_token('PROCEDURE',
6710 'pay_us_emp_dt_tax_rules.create_new_loc_rec');
6711 fnd_message.set_token('STEP','2');
6712 fnd_message.raise_error;
6713 end if;
6714 close csr_get_codes;
6715
6716 end if;
6717
6718 hr_utility.set_location('pay_us_emp_dt_tax_rules.create_new_location_rec',3);
6719 /* Get the default date from the federal tax rules record */
6720
6721 open csr_get_eff_date;
6722
6723 fetch csr_get_eff_date into l_default_date;
6724
6725 if l_default_date is null then
6726 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
6727 fnd_message.set_token('PROCEDURE',
6728 'pay_us_emp_dt_tax_rules.create_new_location_rec');
6729 fnd_message.set_token('STEP','1');
6730 fnd_message.raise_error;
6731 end if;
6732
6733 close csr_get_eff_date;
6734
6735 /* Create the new location records */
6736
6737
6738 hr_utility.set_location('pay_us_emp_dt_tax_rules.create_new_location_rec',4);
6739 l_ret_code := 0;
6740 l_ret_text := null;
6741 l_jurisdiction_code := l_state_code ||'-000-0000';
6742
6743 hr_utility.set_location('pay_us_emp_dt_tax_rules.create_new_location_rec',5);
6744 pay_us_emp_dt_tax_val.check_jurisdiction_exists(p_assignment_id => p_assignment_id,
6745 p_jurisdiction_code => l_jurisdiction_code,
6746 p_ret_code => l_ret_code,
6747 p_ret_text => l_ret_text);
6748 hr_utility.set_location('pay_us_emp_dt_tax_rules.create_new_location_rec',6);
6749
6750 /* Bug 2535501 */
6751
6752 open csr_get_max_assign_end_dt;
6753 fetch csr_get_max_assign_end_dt into l_max_assign_end_dt;
6754
6755
6756 if csr_get_max_assign_end_dt%NOTFOUND then
6757 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
6758 fnd_message.set_token('PROCEDURE',
6759 'pay_us_emp_dt_tax_rules.create_new_location_rec');
6760 fnd_message.set_token('STEP','3');
6761 fnd_message.raise_error;
6762 end if;
6763
6764 close csr_get_max_assign_end_dt;
6765
6766 /* End Bug 2535501 */
6767
6768 /* If state record does not exist then the county and city
6769 records also do not exist */
6770
6771 /* Create the state tax rule record and then create %age record
6772 for state. The ins_def_state_rec routine will create the
6773 state tax rule record from begin of time till end of time
6774 and also the state percentage record for every change in
6775 location */
6776
6777 if l_ret_code = 1 then
6778 hr_utility.set_location('pay_us_emp_dt_tax_rules.create_new_location_rec',7);
6779 l_emp_state_tax_rule_id :=
6780 insert_def_state_rec(p_assignment_id => p_assignment_id,
6781 p_effective_start_date => l_default_date,
6782 p_effective_end_date => l_max_assign_end_dt, -- Bug 2535501
6783 -- p_effective_end_date => l_end_of_time,
6784 p_state_code => l_state_code,
6785 p_business_group_id => p_business_group,
6786 p_percent_time => 0);
6787
6788 /* Create the county tax rule record and then create %age record
6789 for state. The ins_def_county_rec routine will create the
6790 county tax rule record from begin of time till end of time
6791 and also the county percentage record for every change in
6792 location */
6793 hr_utility.set_location('pay_us_emp_dt_tax_rules.create_new_location_rec',8);
6794
6795 l_emp_county_tax_rule_id :=
6796 insert_def_county_rec(p_assignment_id => p_assignment_id,
6797 p_effective_start_date => l_default_date,
6798 p_effective_end_date => l_max_assign_end_dt, -- Bug 2535501
6799 -- p_effective_end_date => l_end_of_time,
6800 p_state_code => l_state_code,
6801 p_county_code => l_county_code,
6802 p_business_group_id => p_business_group,
6803 p_percent_time => 0);
6804
6805 /* Create the city tax rule record and then create %age record
6806 for state. The ins_def_city_rec routine will create the
6807 city tax rule record from begin of time till end of time
6808 and also the city percentage record for every change in
6809 location */
6810 hr_utility.set_location('pay_us_emp_dt_tax_rules.create_new_location_rec',9);
6811
6812 l_emp_city_tax_rule_id :=
6813 insert_def_city_rec(p_assignment_id => p_assignment_id,
6814 p_effective_start_date => l_default_date,
6815 p_effective_end_date => l_max_assign_end_dt, -- Bug 2535501
6816 -- p_effective_end_date => l_end_of_time,
6817 p_state_code => l_state_code,
6818 p_county_code => l_county_code,
6819 p_city_code => l_city_code,
6820 p_business_group_id => p_business_group,
6821 p_percent_time => 0);
6822
6823 hr_utility.set_location('pay_us_emp_dt_tax_rules.create_new_location_rec',10);
6824
6825 elsif l_ret_code = 0 then
6826 hr_utility.set_location('pay_us_emp_dt_tax_rules.create_new_location_rec',101);
6827 /* State record exists. Now check if county record exists */
6828 -- Update SUI Wage Base Override Amount
6829 -- Update SUI WAGE BASE Overide amount if payroll is installed otherwise don't
6830 -- call the procedure which does the update
6831 -- Turning Off SUI Wage Base Override Functionality due to Bug# 5486281
6832 /*
6833 IF hr_utility.chk_product_install(p_product =>'Oracle Payroll',
6834 p_legislation => 'US')
6835 then
6836 hr_utility.set_location('pay_us_emp_dt_tax_rules.create_new_location_rec',102);
6837 if p_assignment_id is not null and p_session_date is not null
6838 then
6839 hr_utility.set_location('pay_us_emp_dt_tax_rules.create_new_location_rec',103);
6840 set_sui_wage_base_override(p_assignment_id,l_state_code,p_session_date) ;
6841 end if ;
6842 end if;
6843 -- End Change
6844 */
6845
6846 l_ret_code := 0;
6847 l_ret_text := null;
6848 l_jurisdiction_code := l_state_code ||'-' || l_county_code ||'-0000';
6849
6850 hr_utility.set_location('pay_us_emp_dt_tax_rules.create_new_location_rec',11);
6851 pay_us_emp_dt_tax_val.check_jurisdiction_exists(p_assignment_id => p_assignment_id,
6852 p_jurisdiction_code => l_jurisdiction_code,
6853 p_ret_code => l_ret_code,
6854 p_ret_text => l_ret_text);
6855 hr_utility.set_location('pay_us_emp_dt_tax_rules.create_new_location_rec',12);
6856 /* If county record does not exist then city will also not exist */
6857 if l_ret_code = 1 then
6858
6859 /* Create the county tax rule record and then create %age record
6860 for state. The ins_def_county_rec routine will create the
6861 county tax rule record from begin of time till end of time
6862 and also the county percentage record for every change in
6863 location */
6864
6865 hr_utility.set_location('pay_us_emp_dt_tax_rules.create_new_location_rec',13);
6866 l_emp_county_tax_rule_id :=
6867 insert_def_county_rec(p_assignment_id => p_assignment_id,
6868 p_effective_start_date => l_default_date,
6869 p_effective_end_date => l_max_assign_end_dt, -- Bug 2535501
6870 -- p_effective_end_date => l_end_of_time,
6871 p_state_code => l_state_code,
6872 p_county_code => l_county_code,
6873 p_business_group_id => p_business_group,
6874 p_percent_time => 0);
6875
6876 /* Create the city tax rule record and then create %age record
6877 for state. The ins_def_city_rec routine will create the
6878 city tax rule record from begin of time till end of time
6879 and also the city percentage record for every change in
6880 location */
6881
6882 hr_utility.set_location('pay_us_emp_dt_tax_rules.create_new_location_rec',14);
6883 l_emp_city_tax_rule_id :=
6884 insert_def_city_rec(p_assignment_id => p_assignment_id,
6885 p_effective_start_date => l_default_date,
6886 p_effective_end_date => l_max_assign_end_dt, -- Bug 2535501
6887 -- p_effective_end_date => l_end_of_time,
6888 p_state_code => l_state_code,
6889 p_county_code => l_county_code,
6890 p_city_code => l_city_code,
6891 p_business_group_id => p_business_group,
6892 p_percent_time => 0);
6893 hr_utility.set_location('pay_us_emp_dt_tax_rules.create_new_location_rec',15);
6894
6895 elsif l_ret_code = 0 then
6896 /* State and county records exist. Check if the city record exists */
6897
6898 l_ret_code := 0;
6899 l_ret_text := null;
6900 l_jurisdiction_code := l_state_code ||'-' || l_county_code ||'-'||
6901 l_city_code;
6902
6903 hr_utility.set_location('pay_us_emp_dt_tax_rules.create_new_location_rec',16);
6904 pay_us_emp_dt_tax_val.check_jurisdiction_exists(p_assignment_id => p_assignment_id,
6905 p_jurisdiction_code => l_jurisdiction_code,
6906 p_ret_code => l_ret_code,
6907 p_ret_text => l_ret_text);
6908 hr_utility.set_location('pay_us_emp_dt_tax_rules.create_new_location_rec',17);
6909
6910 /* If city record does not exist then create one */
6911
6912 if l_ret_code = 1 then
6913
6914 /* Create the city tax rule record and then create %age record
6915 for state. The ins_def_city_rec routine will create the
6916 city tax rule record from begin of time till end of time
6917 and also the city percentage record for every change in
6918 location */
6919 hr_utility.set_location('pay_us_emp_dt_tax_rules.create_new_location_rec',18);
6920
6921 l_emp_city_tax_rule_id :=
6922 insert_def_city_rec(p_assignment_id => p_assignment_id,
6923 p_effective_start_date => l_default_date,
6924 p_effective_end_date => l_max_assign_end_dt, -- Bug 2535501
6925 -- p_effective_end_date => l_end_of_time,
6926 p_state_code => l_state_code,
6927 p_county_code => l_county_code,
6928 p_city_code => l_city_code,
6929 p_business_group_id => p_business_group,
6930 p_percent_time => 0);
6931 hr_utility.set_location('pay_us_emp_dt_tax_rules.create_new_location_rec',19);
6932
6933 end if;
6934
6935 end if;
6936
6937 end if;
6938
6939 if l_ovrd_state_code <> l_state_code then
6940
6941 hr_utility.set_location('pay_us_emp_dt_tax_rules.create_new_location_rec',20);
6942 l_emp_state_tax_rule_id :=
6943 insert_def_state_rec(p_assignment_id => p_assignment_id,
6944 p_effective_start_date => l_default_date,
6945 p_effective_end_date => l_end_of_time,
6946 p_state_code => l_ovrd_state_code,
6947 p_business_group_id => p_business_group,
6948 p_percent_time => 0);
6949 hr_utility.set_location('pay_us_emp_dt_tax_rules.create_new_location_rec',21);
6950
6951 end if;
6952
6953 if (l_ovrd_state_code <> l_state_code
6954 or l_ovrd_county_code <> l_county_code) then
6955 hr_utility.set_location('pay_us_emp_dt_tax_rules.create_new_location_rec',22);
6956 l_emp_county_tax_rule_id :=
6957 insert_def_county_rec(p_assignment_id => p_assignment_id,
6958 p_effective_start_date => l_default_date,
6959 p_effective_end_date => l_end_of_time,
6960 p_state_code => l_ovrd_state_code,
6961 p_county_code => l_ovrd_county_code,
6962 p_business_group_id => p_business_group,
6963 p_percent_time => 0);
6964 hr_utility.set_location('pay_us_emp_dt_tax_rules.create_new_location_rec',23);
6965 end if;
6966
6967 if (l_ovrd_state_code <> l_state_code
6968 or l_ovrd_county_code <> l_county_code
6969 or l_ovrd_city_code <> l_city_code) then
6970 hr_utility.set_location('pay_us_emp_dt_tax_rules.create_new_location_rec',24);
6971 l_emp_city_tax_rule_id :=
6972 insert_def_city_rec(p_assignment_id => p_assignment_id,
6973 p_effective_start_date => l_default_date,
6974 p_effective_end_date => l_end_of_time,
6975 p_state_code => l_ovrd_state_code,
6976 p_county_code => l_ovrd_county_code,
6977 p_city_code => l_ovrd_city_code,
6978 p_business_group_id => p_business_group,
6979 p_percent_time => 0);
6980 hr_utility.set_location('pay_us_emp_dt_tax_rules.create_new_location_rec',25);
6981 end if;
6982
6983 /* if called for change in location then set the city to 100% */
6984
6985 if p_new_location_id is not null and
6986 p_percent = 100 and
6987 (p_res_state_code is null
6988 and p_res_county_code is null and p_res_city_code is null) then
6989
6990 hr_utility.set_location('pay_us_emp_dt_tax_rules.create_new_location_rec',26);
6991 /* Now update the city record and set it to 100% */
6992
6993 if l_state_code = l_ovrd_state_code and l_county_code = l_ovrd_county_code
6994 and l_city_code = l_ovrd_city_code then
6995 l_jurisdiction_code := l_state_code ||'-' || l_county_code ||'-'|| l_city_code;
6996 hr_utility.set_location('pay_us_emp_dt_tax_rules.create_new_location_rec',27);
6997 else
6998 l_jurisdiction_code := l_ovrd_state_code ||'-' || l_ovrd_county_code ||'-'||l_ovrd_city_code;
6999 hr_utility.set_location('pay_us_emp_dt_tax_rules.create_new_location_rec',28);
7000 end if;
7001
7002 hr_utility.set_location('pay_us_emp_dt_tax_rules.create_new_location_rec',29);
7003 maintain_element_entry (p_assignment_id => p_assignment_id,
7004 p_effective_start_date => p_validation_start_date,
7005 p_effective_end_date => p_validation_end_date,
7006 p_session_date => p_session_date,
7007 p_jurisdiction_code => l_jurisdiction_code,
7008 p_percentage_time => 100,
7009 p_mode => 'CORRECTION');
7010 hr_utility.set_location('pay_us_emp_dt_tax_rules.create_new_location_rec',30);
7011 end if;
7012
7013 end create_new_location_rec;
7014
7015
7016 /* Name : del_updt_entries_for_dates
7017 Purpose : This procedure can be used to change the effective start date
7018 and/or effective end date of the element entries and the
7019 pay_element_entry_values, for a jurisdiction of
7020 an assignment. It can also be used to delete the element entries
7021 for a given date range.
7022 Parameters :
7023 p_assignment_id -> The assignment for which the vertex elemnt entries are
7024 to be modified for their start and/or end dates.
7025 p_session_date -> The start date of the element entry.
7026 p_new_start_date -> The new start date of the element entry.
7027 p_new_end_date -> The new end date of the element entry.
7028 p_mode -> 'U' -> for update
7029 'D' -> for Delete
7030 'F' -> FUTURE_CHANGE (for Delete)
7031 'N' -> DELETE_NEXT_CHANGE
7032 */
7033
7034 procedure del_updt_entries_for_dates (p_assignment_id in number,
7035 p_jurisdiction_code in varchar2,
7036 p_session_date in date,
7037 p_new_start_date in date,
7038 p_new_end_date in date,
7039 p_mode in varchar2) is
7040
7041 l_inp_value_id_table hr_entry.number_table;
7042 l_scr_value_table hr_entry.varchar2_table;
7043
7044 l_element_type_id number :=0;
7045 l_inp_name varchar2(80) :=null;
7046 l_inp_val_id number :=0;
7047 l_element_link_id number :=0;
7048 l_element_entry_id number :=0;
7049 l_effective_start_date date;
7050 l_effective_end_date date;
7051 l_step number;
7052 l_mode varchar2(30);
7053
7054 /* Cursor to get the vertex element type */
7055
7056 cursor csr_tax_element is
7057 select pet.element_type_id,
7058 piv.input_value_id,
7059 piv.name
7060 from PAY_INPUT_VALUES_F piv,
7061 PAY_ELEMENT_TYPES_F pet
7062 where p_session_date between piv.effective_start_date
7063 and piv.effective_end_date
7064 and pet.element_type_id = piv.element_type_id
7065 and p_session_date between pet.effective_start_date
7066 and pet.effective_end_date
7067 and pet.element_name = 'VERTEX';
7068
7069 /* Cursor to get the element entry for the jurisdiction */
7070
7071 cursor csr_ele_entry (p_element_link number, p_inp_val number)is
7072 select pee.element_entry_id
7073 from PAY_ELEMENT_ENTRY_VALUES_F pev,
7074 PAY_ELEMENT_ENTRIES_F pee
7075 where pev.screen_entry_value = p_jurisdiction_code
7076 and pev.input_value_id + 0 = p_inp_val
7077 and p_session_date between pev.effective_start_date
7078 and pev.effective_end_date
7079 and pev.element_entry_id = pee.element_entry_id
7080 and pee.element_link_id = p_element_link
7081 and p_session_date between pee.effective_start_date
7082 and pee.effective_end_date
7083 and pee.assignment_id = p_assignment_id;
7084
7085 begin
7086
7087 hr_utility.set_location('pay_emp_dt_tax_rules.del_updt_entries_for_dates' ,1);
7088
7089 l_step := 1;
7090 open csr_tax_element;
7091
7092 loop
7093
7094 fetch csr_tax_element into l_element_type_id,
7095 l_inp_val_id,
7096 l_inp_name;
7097
7098 exit when csr_tax_element%NOTFOUND;
7099
7100 if upper(l_inp_name) = 'PAY VALUE'
7101 then
7102 l_inp_value_id_table(1) := l_inp_val_id;
7103 elsif upper(l_inp_name) = 'JURISDICTION'
7104 then
7105 l_inp_value_id_table(2) := l_inp_val_id;
7106 elsif upper(l_inp_name) = 'PERCENTAGE'
7107 then
7108 l_inp_value_id_table(3) := l_inp_val_id;
7109 end if;
7110 end loop;
7111
7112 close csr_tax_element;
7113
7114 hr_utility.set_location('pay_us_emp_dt_tax_rules.del_updt_entries_for_dates'
7115 ,2);
7116
7117 /* Check that all of the input value id for vertex, exists */
7118
7119 for i in 1..3 loop
7120
7121 if l_inp_value_id_table(i) = null or
7122 l_inp_value_id_table(i) = 0
7123 then
7124 fnd_message.set_name('PAY', 'HR_13140_TAX_ELEMENT_ERROR');
7125 fnd_message.set_token('1','INPUT VALUE');
7126 fnd_message.raise_error;
7127 end if;
7128
7129 end loop;
7130
7131 hr_utility.set_location('pay_us_emp_dt_tax_rules.del_updt_entries_for_dates'
7132 ,3);
7133
7134 /* Get element link */
7135 l_step := 2;
7136 l_element_link_id := hr_entry_api.get_link(
7137 P_assignment_id => p_assignment_id,
7138 P_element_type_id => l_element_type_id,
7139 P_session_date => p_session_date);
7140
7141 if l_element_link_id is null or l_element_link_id = 0
7142 then
7143 fnd_message.set_name('PAY', 'HR_13140_TAX_ELEMENT_ERROR');
7144 fnd_message.set_token('1','ELEMENT LINK');
7145 fnd_message.raise_error;
7146 end if;
7147
7148 hr_utility.set_location('pay_us_emp_dt_tax_rules.del_updt_entries_for_dates'
7149 ,4);
7150
7151 /* Get the Element Entry Id */
7152 l_step := 3;
7153 open csr_ele_entry(l_element_link_id, l_inp_value_id_table(2));
7154
7155 fetch csr_ele_entry into l_element_entry_id;
7156
7157 if csr_ele_entry%NOTFOUND then
7158
7159 close csr_ele_entry;
7160 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
7161 fnd_message.set_token('PROCEDURE',
7162 'pay_us_emp_dt_tax_rules.del_updt_entries_for_dates' ||
7163 '- SQLCODE:'|| to_char(sqlcode));
7164 fnd_message.set_token('STEP',to_char(l_step));
7165 fnd_message.raise_error;
7166
7167 end if;
7168
7169 close csr_ele_entry;
7170
7171 if p_mode = 'U' then
7172
7173 /* Update Element Entries and Element Entry values as well */
7174
7175 if p_new_start_date is not null
7176 then
7177
7178 l_step := 4;
7179 update PAY_ELEMENT_ENTRIES_F
7180 set effective_start_date = p_new_start_date
7181 where element_entry_id = l_element_entry_id
7182 and p_session_date between effective_start_date
7183 and effective_end_date;
7184
7185 l_step := 5;
7186 update PAY_ELEMENT_ENTRY_VALUES_F
7187 set effective_start_date = p_new_start_date
7188 where element_entry_id = l_element_entry_id
7189 and p_session_date between effective_start_date
7190 and effective_end_date;
7191 end if;
7192
7193 if p_new_end_date is not null
7194 then
7195
7196 l_step := 6;
7197 update PAY_ELEMENT_ENTRIES_F
7198 set effective_end_date = p_new_end_date
7199 where element_entry_id = l_element_entry_id
7200 and p_session_date between effective_start_date
7201 and effective_end_date;
7202
7203 l_step := 7;
7204 update PAY_ELEMENT_ENTRY_VALUES_F
7205 set effective_end_date = p_new_end_date
7206 where element_entry_id = l_element_entry_id
7207 and p_session_date between effective_start_date
7208 and effective_end_date;
7209 end if;
7210
7211 elsif p_mode = 'D' then
7212
7213 /* Delete the element entries */
7214
7215 l_step := 8;
7216 delete PAY_ELEMENT_ENTRY_VALUES_F
7217 where element_entry_id = l_element_entry_id
7218 and p_session_date between effective_start_date
7219 and effective_end_date;
7220
7221 /* Delete the element entry values */
7222
7223 l_step := 9;
7224 delete PAY_ELEMENT_ENTRIES_F
7225 where element_entry_id = l_element_entry_id
7226 and p_session_date between effective_start_date
7227 and effective_end_date;
7228
7229 elsif p_mode = 'N' then /* Delete next change */
7230
7231 l_mode := 'DELETE_NEXT_CHANGE';
7232 maintain_element_entry (p_assignment_id => p_assignment_id,
7233 p_effective_start_date => p_session_date,
7234 p_effective_end_date => null,
7235 p_session_date => p_session_date,
7236 p_jurisdiction_code => p_jurisdiction_code,
7237 p_percentage_time => 0,
7238 p_mode => l_mode);
7239
7240
7241 elsif p_mode = 'F' then /* Delete future change */
7242
7243 l_mode := 'FUTURE_CHANGE';
7244 maintain_element_entry (p_assignment_id => p_assignment_id,
7245 p_effective_start_date => p_session_date,
7246 p_effective_end_date => null,
7247 p_session_date => p_session_date,
7248 p_jurisdiction_code => p_jurisdiction_code,
7249 p_percentage_time => 0,
7250 p_mode => l_mode);
7251
7252 end if;
7253
7254 exception
7255 when others then
7256 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
7257 fnd_message.set_token('PROCEDURE',
7258 'pay_us_emp_dt_tax_rules.del_updt_entries_for_dates' ||
7259 '- SQLCODE:'|| to_char(sqlcode));
7260 fnd_message.set_token('STEP',to_char(l_step));
7261 fnd_message.raise_error;
7262
7263 end del_updt_entries_for_dates;
7264
7265 /* Name : upd_del_entries
7266 Purpose : Since we have to update the element entries of all the
7267 jurisdictions, we can get the jurisdictions that are
7268 valid as of the session date. from the tax rules tables.
7269 Then for each of the jurisdiction, we will call the
7270 del_updt_entries_for_dates to change their effective dates.
7271 This rotuine will also be called to delete the element entries
7272 for a specific date range.
7273 Parameters : p_assignment_id -> The assignment id.
7274 p_session_date -> The session date for which the element
7275 entries have to be updated/deleted.
7276 p_new_start_date -> The new effective start date to which
7277 the effective start date of the records
7278 needs to be changed.
7279 p_new_end_date -> The new end date for the element entries
7280 effective as of the session date.
7281 p_mode -> 'U' -> Update
7282 'D' -> Delete
7283 'F' -> FUTURE_CHANGE (for Delete)
7284 'N' -> DELETE_NEXT_CHANGE
7285 */
7286
7287 procedure upd_del_entries(p_assignment_id in number,
7288 p_session_date in date,
7289 p_new_start_date in date,
7290 p_new_end_date in date,
7291 p_mode in varchar2) is
7292
7293 l_state_code varchar2(2);
7294 l_county_code varchar2(3);
7295 l_city_code varchar2(4);
7296 l_jurisdiction_code varchar2(11);
7297
7298 cursor csr_get_states is
7299 select state_code
7300 from PAY_US_EMP_STATE_TAX_RULES_F str
7301 where str.assignment_id = p_assignment_id
7302 and p_session_date between str.effective_start_date
7303 and str.effective_end_date;
7304
7305 cursor csr_get_counties is
7306 select state_code,
7307 county_code
7308 from PAY_US_EMP_COUNTY_TAX_RULES_F ctr
7309 where ctr.assignment_id = p_assignment_id
7310 and p_session_date between ctr.effective_start_date
7311 and ctr.effective_end_date;
7312
7313 cursor csr_get_cities is
7314 select state_code,
7315 county_code,
7316 city_code
7317 from PAY_US_EMP_CITY_TAX_RULES_F ctr
7318 where ctr.assignment_id = p_assignment_id
7319 and p_session_date between ctr.effective_start_date
7320 and ctr.effective_end_date;
7321
7322 begin
7323
7324 /* First let's handle the state records */
7325
7326 open csr_get_states;
7327
7328 loop
7329
7330 fetch csr_get_states into l_state_code;
7331
7332 exit when csr_get_states%NOTFOUND;
7333
7334 /* Update the entries for their effective start and/or
7335 effective end date */
7336
7337 l_jurisdiction_code := l_state_code || '-000-0000';
7338 del_updt_entries_for_dates (p_assignment_id => p_assignment_id,
7339 p_jurisdiction_code => l_jurisdiction_code,
7340 p_session_date => p_session_date,
7341 p_new_start_date => p_new_start_date,
7342 p_new_end_date => p_new_end_date,
7343 p_mode => p_mode);
7344 end loop;
7345
7346 close csr_get_states;
7347
7348 /* Now grab the counties */
7349
7350 open csr_get_counties;
7351
7352 loop
7353
7354 fetch csr_get_counties into l_state_code,l_county_code;
7355
7356 exit when csr_get_counties%NOTFOUND;
7357
7358 /* Update the entries for their effective start and/or
7359 effective end date */
7360
7361 l_jurisdiction_code := l_state_code || '-' || l_county_code ||
7362 '-0000';
7363
7364 del_updt_entries_for_dates (p_assignment_id => p_assignment_id,
7365 p_jurisdiction_code => l_jurisdiction_code,
7366 p_session_date => p_session_date,
7367 p_new_start_date => p_new_start_date,
7368 p_new_end_date => p_new_end_date,
7369 p_mode => p_mode);
7370
7371 end loop;
7372
7373 close csr_get_counties;
7374
7375 /* Cities time */
7376
7377 open csr_get_cities;
7378
7379 loop
7380
7381 fetch csr_get_cities into l_state_code,l_county_code, l_city_code;
7382
7383 exit when csr_get_cities%NOTFOUND;
7384
7385 /* Update the entries for their effective start and/or
7386 effective end date */
7387
7388 l_jurisdiction_code := l_state_code || '-' || l_county_code ||
7389 '-' || l_city_code;
7390
7391 del_updt_entries_for_dates (p_assignment_id => p_assignment_id,
7392 p_jurisdiction_code => l_jurisdiction_code,
7393 p_session_date => p_session_date,
7394 p_new_start_date => p_new_start_date,
7395 p_new_end_date => p_new_end_date,
7396 p_mode => p_mode);
7397
7398 end loop;
7399
7400 close csr_get_cities;
7401
7402 end upd_del_entries;
7403
7404
7405
7406 /* Name : del_updt_wc_entry_for_dates
7407 Purpose : This procedure can be used to change the effective start date
7408 and/or effective end date of the workers comp.element
7409 entry and the pay_element_entry_value, for an assignment. It
7410 can also be used to delete the workers comp. element entry
7411 for a given date range.
7412 Parameters :
7413 p_assignment_id -> The assignment for which the workers
7414 comp. element entry are to be modified
7415 for their start and/or end dates.
7416 p_session_date -> The start date of the element entry.
7417 p_new_start_date -> The new start date of the element entry.
7418 p_new_end_date -> The new end date of the element entry.
7419 p_mode -> 'U' -> for update
7420 'D' -> for Delete
7421 */
7422
7423 procedure del_updt_wc_entry_for_dates (p_assignment_id in number,
7424 p_session_date in date,
7425 p_new_start_date in date,
7426 p_new_end_date in date,
7427 p_mode in varchar2) is
7428
7429
7430 l_element_type_id number :=0;
7431 l_element_link_id number :=0;
7432 l_element_entry_id number :=0;
7433 l_effective_start_date date;
7434 l_effective_end_date date;
7435 l_step number;
7436
7437 /* Cursor to get the workers comp. element type */
7438
7439 cursor csr_tax_element is
7440 select pet.element_type_id
7441 from PAY_ELEMENT_TYPES_F pet
7442 where pet.element_name = 'Workers Compensation' -- Bug 3354060 FTS on PAY_ELEMENT_TYPES_F was removed. Done by removing
7443 and p_session_date between pet.effective_start_date -- 'upper' from pet.element_name and 'WORKERS COMPENSATION' was changed to
7444 and pet.effective_end_date; -- 'Workers Compensation'
7445
7446 /* Cursor to get the element entry for the jurisdiction */
7447
7448 cursor csr_wc_ele_entry (p_element_link number)is
7449 select pee.element_entry_id
7450 from PAY_ELEMENT_ENTRIES_F pee
7451 where pee.assignment_id = p_assignment_id
7452 and p_session_date between pee.effective_start_date
7453 and pee.effective_end_date
7454 and pee.element_link_id = p_element_link;
7455
7456 begin
7457
7458 hr_utility.set_location('pay_emp_tax_dt_tax_rules.del_updt_wc_entry_for_dates' ,1);
7459
7460 l_step := 1;
7461 open csr_tax_element;
7462
7463 fetch csr_tax_element into l_element_type_id;
7464 if csr_tax_element%NOTFOUND then
7465 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
7466 fnd_message.set_token('PROCEDURE',
7467 'pay_us_emp_dt_tax_rules.del_updt_wc_entry_for_dates');
7468 fnd_message.set_token('STEP',to_char(l_step));
7469 fnd_message.raise_error;
7470 end if;
7471
7472 close csr_tax_element;
7473
7474 hr_utility.set_location('pay_us_emp_dt_tax_rules.del_updt_wc_entry_for_dates' ,2);
7475
7476 /* Get element link */
7477 l_step := 2;
7478 l_element_link_id := hr_entry_api.get_link(
7479 P_assignment_id => p_assignment_id,
7480 P_element_type_id => l_element_type_id,
7481 P_session_date => p_session_date);
7482
7483 if l_element_link_id is null or l_element_link_id = 0
7484 then
7485 fnd_message.set_name('PAY', 'HR_13140_TAX_ELEMENT_ERROR');
7486 fnd_message.set_token('1','ELEMENT LINK');
7487 fnd_message.raise_error;
7488 end if;
7489
7490 hr_utility.set_location('pay_us_emp_dt_tax_rules.del_updt_wc_entry_for_dates' ,3);
7491
7492 /* Get the Element Entry Id */
7493 l_step := 3;
7494 open csr_wc_ele_entry(l_element_link_id);
7495
7496 fetch csr_wc_ele_entry into l_element_entry_id;
7497
7498 if csr_wc_ele_entry%NOTFOUND then
7499
7500 close csr_wc_ele_entry;
7501 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
7502 fnd_message.set_token('PROCEDURE',
7503 'pay_us_emp_dt_tax_rules.del_updt_wc_entry_for_dates' ||
7504 '- SQLCODE:'|| to_char(sqlcode));
7505 fnd_message.set_token('STEP',to_char(l_step));
7506 fnd_message.raise_error;
7507
7508 end if;
7509
7510 close csr_wc_ele_entry;
7511
7512 if p_mode = 'U' then
7513
7514 /* Update Element Entries and Element Entry values as well */
7515
7516 if p_new_start_date is not null
7517 then
7518
7519 l_step := 4;
7520 update PAY_ELEMENT_ENTRIES_F
7521 set effective_start_date = p_new_start_date
7522 where element_entry_id = l_element_entry_id
7523 and p_session_date between effective_start_date
7524 and effective_end_date;
7525
7526 l_step := 5;
7527 update PAY_ELEMENT_ENTRY_VALUES_F
7528 set effective_start_date = p_new_start_date
7529 where element_entry_id = l_element_entry_id
7530 and p_session_date between effective_start_date
7531 and effective_end_date;
7532
7533 end if;
7534
7535 if p_new_end_date is not null
7536 then
7537
7538 l_step := 6;
7539 update PAY_ELEMENT_ENTRIES_F
7540 set effective_end_date = p_new_end_date
7541 where element_entry_id = l_element_entry_id
7542 and p_session_date between effective_start_date
7543 and effective_end_date;
7544
7545 l_step := 7;
7546 update PAY_ELEMENT_ENTRY_VALUES_F
7547 set effective_end_date = p_new_end_date
7548 where element_entry_id = l_element_entry_id
7549 and p_session_date between effective_start_date
7550 and effective_end_date;
7551 end if;
7552
7553 elsif p_mode = 'D' then
7554
7555 /* Delete the element entry */
7556
7557 l_step := 8;
7558 delete PAY_ELEMENT_ENTRY_VALUES_F
7559 where element_entry_id = l_element_entry_id
7560 and p_session_date between effective_start_date
7561 and effective_end_date;
7562
7563 /* Delete the element entry values */
7564
7565 l_step := 9;
7566 delete PAY_ELEMENT_ENTRIES_F
7567 where element_entry_id = l_element_entry_id
7568 and p_session_date between effective_start_date
7569 and effective_end_date;
7570 end if;
7571
7572 exception
7573 when others then
7574 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
7575 fnd_message.set_token('PROCEDURE',
7576 'pay_us_emp_dt_tax_rules.del_updt_wc_entry_for_dates' ||
7577 '- SQLCODE:'|| to_char(sqlcode));
7578 fnd_message.set_token('STEP',to_char(l_step));
7579 fnd_message.raise_error;
7580
7581 end del_updt_wc_entry_for_dates;
7582
7583
7584
7585 /* Name : change_entries
7586 Purpose : To create or update the %age tax records for
7587 all of the existing tax rules records, for a given date
7588 range i.e. from the p_start_date till p_end_date.
7589 When this procedure is called with the mode of 'INSERT_OLD'
7590 the %age passed by this routine to the maintain_element_entry
7591 routine will not be of any importance because the maintain_element_entry
7592 routine will do an update insert with the existing %age
7593 */
7594
7595 procedure change_entries(p_assignment_id in number,
7596 p_session_date in date,
7597 p_start_date in date,
7598 p_end_date in date,
7599 p_mode in varchar2) is
7600
7601 l_state_code varchar2(2);
7602 l_county_code varchar2(3);
7603 l_city_code varchar2(4);
7604 l_jurisdiction_code varchar2(11);
7605
7606 cursor csr_get_states is
7607 select state_code
7608 from PAY_US_EMP_STATE_TAX_RULES_F str
7609 where str.assignment_id = p_assignment_id
7610 and p_session_date between
7611 str.effective_start_date and str.effective_end_date;
7612
7613 cursor csr_get_counties is
7614 select state_code,
7615 county_code
7616 from PAY_US_EMP_COUNTY_TAX_RULES_F ctr
7617 where ctr.assignment_id = p_assignment_id
7618 and p_session_date between
7619 ctr.effective_start_date and ctr.effective_end_date;
7620
7621 cursor csr_get_cities is
7622 select state_code,
7623 county_code,
7624 city_code
7625 from PAY_US_EMP_CITY_TAX_RULES_F ctr
7626 where ctr.assignment_id = p_assignment_id
7627 and p_session_date between
7628 ctr.effective_start_date and ctr.effective_end_date;
7629
7630 begin
7631
7632 /* First let's handle the state records */
7633
7634 open csr_get_states;
7635
7636 loop
7637
7638 fetch csr_get_states into l_state_code;
7639
7640 exit when csr_get_states%NOTFOUND;
7641
7642 l_jurisdiction_code := l_state_code ||'-000-0000';
7643
7644 /* change the tax %age record for the state */
7645 maintain_element_entry (p_assignment_id => p_assignment_id,
7646 p_effective_start_date => p_start_date,
7647 p_effective_end_date => p_end_date,
7648 p_session_date => p_session_date,
7649 p_jurisdiction_code => l_jurisdiction_code,
7650 p_percentage_time => 0,
7651 p_mode => p_mode);
7652
7653 end loop;
7654
7655 close csr_get_states;
7656
7657 /* Now grab the counties */
7658
7659 open csr_get_counties;
7660
7661 loop
7662
7663 fetch csr_get_counties into l_state_code,l_county_code;
7664
7665 exit when csr_get_counties%NOTFOUND;
7666
7667 l_jurisdiction_code := l_state_code ||'-' ||
7668 l_county_code ||'-0000';
7669
7670 /* change the tax %age record for the county */
7671
7672 maintain_element_entry (p_assignment_id => p_assignment_id,
7673 p_effective_start_date => p_start_date,
7674 p_effective_end_date => p_end_date,
7675 p_session_date => p_session_date,
7676 p_jurisdiction_code => l_jurisdiction_code,
7677 p_percentage_time => 0,
7678 p_mode => p_mode);
7679
7680 end loop;
7681
7682 close csr_get_counties;
7683
7684 /* Cities time */
7685
7686 open csr_get_cities;
7687
7688 loop
7689
7690 fetch csr_get_cities into l_state_code,l_county_code, l_city_code;
7691
7692 exit when csr_get_cities%NOTFOUND;
7693
7694 l_jurisdiction_code := l_state_code ||'-' ||
7695 l_county_code ||'-' || l_city_code;
7696
7697 /* change the tax %age record for the city */
7698
7699 maintain_element_entry (p_assignment_id => p_assignment_id,
7700 p_effective_start_date => p_start_date,
7701 p_effective_end_date => p_end_date,
7702 p_session_date => p_session_date,
7703 p_jurisdiction_code => l_jurisdiction_code,
7704 p_percentage_time => 0,
7705 p_mode => p_mode);
7706
7707 end loop;
7708
7709 close csr_get_cities;
7710
7711 end change_entries;
7712
7713
7714 procedure pull_percentage (p_assignment_id in number,
7715 p_default_date in date,
7716 p_effective_start_date in date,
7717 p_effective_end_date in date,
7718 p_session_date in date,
7719 p_new_location_id in number,
7720 p_business_group_id in number) is
7721
7722 l_ret_code number;
7723 l_ret_text varchar2(240);
7724 l_next_date date;
7725 l_next_location number;
7726 l_ovrd_loc number;
7727 l_ovrd_percent number := 0;
7728 l_percent number := 100;
7729 l_validation_start_date date;
7730 l_validation_end_date date;
7731 l_next_end_date date;
7732 l_element_type_id number;
7733 l_element_link_id number;
7734
7735 /* cursor to get the next location */
7736
7737 cursor csr_get_next_location (p_next_eff_date date) is
7738 select paf.location_id, paf.effective_end_date
7739 from PER_ASSIGNMENTS_F paf
7740 where paf.assignment_id = p_assignment_id
7741 and p_next_eff_date between paf.effective_start_date
7742 and paf.effective_end_date;
7743
7744 /* Get the Vertex element type */
7745 cursor csr_tax_element is
7746 select pet.element_type_id
7747 from PAY_ELEMENT_TYPES_F pet
7748 where pet.element_name = 'VERTEX'
7749 and p_session_date between pet.effective_start_date
7750 and pet.effective_end_date;
7751
7752 /* cursor to get the effective end date of the next element entry record */
7753 cursor csr_get_next_date (p_element_link number, p_date date)is
7754 select pee.effective_end_date
7755 from PAY_ELEMENT_ENTRIES_F pee
7756 where pee.assignment_id = p_assignment_id
7757 and p_date between pee.effective_start_date
7758 and pee.effective_end_date
7759 and pee.element_link_id = p_element_link
7760 and rownum < 2;
7761
7762 cursor csr_get_ovrd_loc(p_assignment number, p_session_dt date) is
7763 select nvl(hsck.segment18, paf.location_id)
7764 from HR_SOFT_CODING_KEYFLEX hsck,
7765 PER_ASSIGNMENTS_F paf
7766 where paf.assignment_id = p_assignment
7767 and p_session_dt between paf.effective_start_date
7768 and paf.effective_end_date
7769 and hsck.soft_coding_keyflex_id = paf.soft_coding_keyflex_id;
7770
7771 begin
7772
7773 l_validation_start_date := p_effective_start_date;
7774
7775 /* Get the location of the assignment as of the default date */
7776 open csr_get_next_location(p_default_date);
7777 fetch csr_get_next_location into l_next_location, l_next_end_date;
7778 if csr_get_next_location%NOTFOUND
7779 then
7780 close csr_get_next_location;
7781 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
7782 fnd_message.set_token('PROCEDURE',
7783 'pay_us_emp_dt_tax_rules.pull_percentage');
7784 fnd_message.set_token('STEP','1');
7785 fnd_message.raise_error;
7786 end if;
7787
7788 close csr_get_next_location;
7789
7790 if l_next_location <> p_new_location_id then
7791
7792 l_validation_end_date := p_effective_end_date;
7793
7794
7795 /* Pull back the effective start date of the existing %age records to
7796 the validation start date */
7797 upd_del_entries(p_assignment_id => p_assignment_id,
7798 p_session_date => p_default_date,
7799 p_new_start_date => l_validation_start_date,
7800 p_new_end_date => null,
7801 p_mode => 'U');
7802
7803 /* Do an update insert for the existing %age records with the same %age */
7804
7805 change_entries(p_assignment_id => p_assignment_id,
7806 p_session_date => p_default_date,
7807 p_start_date => l_validation_start_date,
7808 p_end_date => l_next_end_date,
7809 p_mode => 'INSERT_OLD');
7810
7811 /* Zero out the time for the existing %age records for l_validation_start_date and
7812 p_effective_end_date */
7813
7814 zero_out_time(p_assignment_id => p_assignment_id,
7815 p_effective_start_date => l_validation_start_date,
7816 p_effective_end_date => l_validation_end_date);
7817
7818 /* Create %age records for the new location, for
7819 every change in location */
7820
7821 l_ovrd_percent := 0;
7822 l_percent := 100;
7823 open csr_get_ovrd_loc(p_assignment_id, p_session_date);
7824 fetch csr_get_ovrd_loc into l_ovrd_loc;
7825 if csr_get_ovrd_loc%found then
7826 if l_ovrd_loc <> p_new_location_id then
7827 l_ovrd_percent := 100;
7828 l_percent := 0;
7829 end if;
7830 end if;
7831 close csr_get_ovrd_loc;
7832
7833 create_new_location_rec(p_assignment_id => p_assignment_id,
7834 p_validation_start_date => l_validation_start_date,
7835 p_validation_end_date => l_validation_end_date,
7836 p_session_date => p_session_date,
7837 p_new_location_id => p_new_location_id,
7838 p_res_state_code => null,
7839 p_res_county_code => null,
7840 p_res_city_code => null,
7841 p_business_group => p_business_group_id,
7842 p_percent => l_percent);
7843
7844 if l_ovrd_percent = 100 then
7845 create_new_location_rec(p_assignment_id => p_assignment_id,
7846 p_validation_start_date => l_validation_start_date,
7847 p_validation_end_date => l_validation_end_date,
7848 p_session_date => p_session_date,
7849 p_new_location_id => l_ovrd_loc,
7850 p_res_state_code => null,
7851 p_res_county_code => null,
7852 p_res_city_code => null,
7853 p_business_group => p_business_group_id,
7854 p_percent => l_ovrd_percent);
7855 end if;
7856
7857 else /* next location = p_new_location_id */
7858
7859 /* get the end date of the entries corresponding to the default
7860 date as the effective start date */
7861
7862
7863 open csr_tax_element;
7864 fetch csr_tax_element into l_element_type_id;
7865 if csr_tax_element%NOTFOUND then
7866 close csr_tax_element;
7867 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
7868 fnd_message.set_token('PROCEDURE',
7869 'pay_us_emp_dt_tax_rules.pull_percentage');
7870 fnd_message.set_token('STEP','2');
7871 fnd_message.raise_error;
7872 end if;
7873 close csr_tax_element;
7874
7875 /* Get element link */
7876 l_element_link_id := hr_entry_api.get_link(
7877 P_assignment_id => p_assignment_id,
7878 P_element_type_id => l_element_type_id,
7879 P_session_date => p_session_date);
7880
7881 if l_element_link_id is null or l_element_link_id = 0
7882 then
7883 fnd_message.set_name('PAY', 'HR_13140_TAX_ELEMENT_ERROR');
7884 fnd_message.set_token('1','VERTEX');
7885 fnd_message.raise_error;
7886 end if;
7887
7888 open csr_get_next_date(l_element_link_id, p_default_date);
7889 fetch csr_get_next_date into l_validation_end_date;
7890 if csr_get_next_date%NOTFOUND
7891 then
7892 close csr_get_next_date;
7893 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
7894 fnd_message.set_token('PROCEDURE',
7895 'pay_us_emp_dt_tax_rules.pull_percentage');
7896 fnd_message.set_token('STEP','3');
7897 fnd_message.raise_error;
7898 end if;
7899
7900 close csr_get_next_date;
7901
7902
7903 /* set the effective start date of the entries to the
7904 new effective start date i.e. the l_validation_start_date */
7905
7906 upd_del_entries(p_assignment_id => p_assignment_id,
7907 p_session_date => p_default_date,
7908 p_new_start_date => l_validation_start_date,
7909 p_new_end_date => null,
7910 p_mode => 'U');
7911
7912 /* inserting rec for all jurisdcitions for the new date
7913 range */
7914 zero_out_time(p_assignment_id => p_assignment_id,
7915 p_effective_start_date => l_validation_start_date,
7916 p_effective_end_date => l_validation_end_date);
7917
7918 /* Create the tax rules records and the %age records for the
7919 new location - if required and set the city %age to 100 */
7920
7921 l_ovrd_percent := 0;
7922 l_percent := 100;
7923 open csr_get_ovrd_loc(p_assignment_id, p_session_date);
7924 fetch csr_get_ovrd_loc into l_ovrd_loc;
7925 if csr_get_ovrd_loc%found then
7926 if l_ovrd_loc <> p_new_location_id then
7927 l_ovrd_percent := 100;
7928 l_percent := 0;
7929 end if;
7930 end if;
7931 close csr_get_ovrd_loc;
7932
7933 create_new_location_rec(p_assignment_id => p_assignment_id,
7934 p_validation_start_date => l_validation_start_date,
7935 p_validation_end_date => l_validation_end_date,
7936 p_session_date => p_session_date,
7937 p_new_location_id => p_new_location_id,
7938 p_res_state_code => null,
7939 p_res_county_code => null,
7940 p_res_city_code => null,
7941 p_business_group => p_business_group_id,
7942 p_percent => l_percent);
7943 if l_ovrd_percent = 100 then
7944 create_new_location_rec(p_assignment_id => p_assignment_id,
7945 p_validation_start_date => l_validation_start_date,
7946 p_validation_end_date => l_validation_end_date,
7947 p_session_date => p_session_date,
7948 p_new_location_id => l_ovrd_loc,
7949 p_res_state_code => null,
7950 p_res_county_code => null,
7951 p_res_city_code => null,
7952 p_business_group => p_business_group_id,
7953 p_percent => l_ovrd_percent);
7954
7955 end if;
7956
7957
7958
7959 end if;
7960
7961 end pull_percentage;
7962
7963
7964 /* Name : correct_percentage
7965 Purpose : This is a nasty little procedure which is ideally
7966 supposed to handle the tax rows for a 'correction'
7967 to the assignment's location.
7968 */
7969
7970 procedure correct_percentage (p_assignment_id in number,
7971 p_effective_start_date in date,
7972 p_effective_end_date in date,
7973 p_session_date in date,
7974 p_new_location_id in number,
7975 p_business_group_id in number,
7976 p_ret_code in out nocopy number,
7977 p_ret_text in out nocopy varchar2) is
7978
7979
7980 l_default_date date;
7981 l_end_of_time date := to_date('31/12/4712','dd/mm/yyyy');
7982 l_ret_code number;
7983 l_ret_text varchar2(240);
7984 l_pef_start_date date;
7985 l_pef_new_start_date date;
7986 l_pef_end_date date;
7987 l_pef_prev_date date;
7988 l_pef_next_date date;
7989 l_next_location number;
7990 l_next_loc_end_date date;
7991 l_payroll_installed boolean := FALSE;
7992 l_termination_flag boolean := FALSE;
7993 l_validation_start_date date;
7994 l_validation_end_date date;
7995 l_element_type_id number;
7996 l_element_link_id number;
7997 l_ovrd_loc number;
7998 l_ovrd_percent number;
7999 l_percent number;
8000 /* Cursor to get the date on which the defaulting tax criteria was
8001 satisfied */
8002
8003 cursor csr_get_eff_date (passignment number) is
8004 select min(ftr.effective_start_date)
8005 from PAY_US_EMP_FED_TAX_RULES_F ftr
8006 where ftr.assignment_id = passignment;
8007
8008 /* Cursor to get the changes in assignment which in turn will help us
8009 in identifying the change in locations that has taken place within
8010 a given date range */
8011
8012 cursor csr_get_locations (passignment number, p_start_date date,
8013 p_end_date date) is
8014 select paf1.location_id,
8015 paf1.effective_start_date,
8016 paf1.effective_start_date - 1
8017 from per_assignments_f paf1
8018 where paf1.assignment_id = passignment
8019 and paf1.effective_start_date >= p_start_date
8020 and paf1.effective_end_date <= p_end_date
8021 order by 2;
8022
8023
8024 /* Get the Vertex element type */
8025 cursor csr_tax_element is
8026 select pet.element_type_id
8027 from PAY_ELEMENT_TYPES_F pet
8028 where pet.element_name = 'VERTEX'
8029 and p_session_date between pet.effective_start_date
8030 and pet.effective_end_date;
8031
8032 /* Cursor to check for multiple date effective records of the vertex
8033 element entries */
8034 cursor csr_multiple_rec(p_def_date date, p_ele_link number) is
8035 select 'Y'
8036 from pay_element_entries_f pef
8037 where pef.assignment_id = p_assignment_id
8038 and pef.element_link_id = p_ele_link
8039 and pef.effective_start_date >= p_def_date
8040 and exists (select null
8041 from pay_element_entries_f pee
8042 where pee.assignment_id = p_assignment_id
8043 and pee.element_entry_id = pef.element_entry_id
8044 and pee.effective_start_date >= p_def_date
8045 and pee.effective_start_date <> pef.effective_start_date);
8046
8047 /* Cursor to get the effective dates of the vertex element entries */
8048
8049 cursor csr_ele_entry (p_element_link number)is
8050 select pee.effective_start_date,
8051 pee.effective_end_date,
8052 pee.effective_start_date -1
8053 from PAY_ELEMENT_ENTRIES_F pee
8054 where pee.assignment_id = p_assignment_id
8055 and p_session_date between pee.effective_start_date
8056 and pee.effective_end_date
8057 and pee.element_link_id = p_element_link
8058 and rownum < 2;
8059
8060 /* cursor to get the next location */
8061
8062 cursor csr_get_next_location (p_next_eff_date date) is
8063 select paf.location_id
8064 from PER_ASSIGNMENTS_F paf
8065 where paf.assignment_id = p_assignment_id and
8066 p_next_eff_date between paf.effective_start_date
8067 and paf.effective_end_date;
8068
8069
8070
8071 /* cursor to get the effective end date of the next element entry record */
8072 cursor csr_get_next_date (p_element_link number, p_date date)is
8073 select pee.effective_end_date
8074 from PAY_ELEMENT_ENTRIES_F pee
8075 where pee.assignment_id = p_assignment_id
8076 and p_date between pee.effective_start_date
8077 and pee.effective_end_date
8078 and pee.element_link_id = p_element_link
8079 and rownum < 2;
8080
8081 cursor csr_get_ovrd_loc(p_assignment number, p_session_dt date) is
8082 select nvl(hsck.segment18, paf.location_id)
8083 from HR_SOFT_CODING_KEYFLEX hsck,
8084 PER_ASSIGNMENTS_F paf
8085 where paf.assignment_id = p_assignment
8086 and p_session_dt between paf.effective_start_date
8087 and paf.effective_end_date
8088 and hsck.soft_coding_keyflex_id = paf.soft_coding_keyflex_id;
8089
8090 procedure backward_processing(p_assignment in number,
8091 p_eff_start_date in date,
8092 p_validation_start_date in out nocopy date,
8093 p_new_location in number,
8094 p_element_link in number) is
8095
8096 l_prev_location number := 0;
8097 l_prev_processing boolean := FALSE;
8098 l_eff_prev_date date;
8099 l_validation_start_date date;
8100
8101 /* cursor to get the previous location */
8102
8103 cursor csr_get_prev_location (p_prev_eff_date date) is
8104 select paf.location_id
8105 from PER_ASSIGNMENTS_F paf
8106 where paf.assignment_id = p_assignment and
8107 p_prev_eff_date between paf.effective_start_date
8108 and paf.effective_end_date;
8109
8110 /* cursor to get the effective start date of the previous element entry record */
8111 cursor csr_get_prev_date (p_element_link number, p_date date)is
8112 select pee.effective_start_date
8113 from PAY_ELEMENT_ENTRIES_F pee
8114 where pee.assignment_id = p_assignment
8115 and pee.element_link_id = p_element_link
8116 and p_date between pee.effective_start_date
8117 and pee.effective_end_date
8118 and rownum < 2;
8119
8120 begin
8121
8122 l_validation_start_date := p_validation_start_date;
8123
8124 /* Get the effective_end_date of the previous
8125 assignment record */
8126 select p_eff_start_date -1
8127 into l_eff_prev_date
8128 from dual;
8129
8130 /* get the previous location of the assignment */
8131
8132 open csr_get_prev_location(l_eff_prev_date);
8133 fetch csr_get_prev_location into l_prev_location;
8134 if csr_get_prev_location%FOUND then
8135 l_prev_processing := TRUE;
8136 else
8137 l_prev_processing := FALSE;
8138 end if;
8139
8140 close csr_get_prev_location;
8141
8142 if l_prev_processing and l_prev_location = p_new_location then
8143
8144 l_validation_start_date := null;
8145
8146 /* get the effective start date of the previous set of %age records */
8147
8148 open csr_get_prev_date(p_element_link,l_eff_prev_date);
8149 fetch csr_get_prev_date into l_validation_start_date;
8150 if csr_get_prev_date%NOTFOUND then
8151 close csr_get_prev_date;
8152 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
8153 fnd_message.set_token('PROCEDURE',
8154 'pay_us_emp_dt_tax_rules.backward_processing');
8155 fnd_message.set_token('STEP','1');
8156 fnd_message.raise_error;
8157 end if;
8158
8159 /* deleting the previous set */
8160
8161 upd_del_entries(p_assignment_id => p_assignment_id,
8162 p_session_date => l_validation_start_date,
8163 p_new_start_date => null,
8164 p_new_end_date => null,
8165 p_mode => 'D');
8166
8167 /* Pull back the effective start date of the current set */
8168
8169 upd_del_entries(p_assignment_id => p_assignment_id,
8170 p_session_date => p_eff_start_date,
8171 p_new_start_date => l_validation_start_date,
8172 p_new_end_date => null,
8173 p_mode => 'U');
8174
8175 /* Assign the new validation start date */
8176
8177 p_validation_start_date := l_validation_start_date;
8178
8179 end if;
8180
8181 end backward_processing;
8182
8183 begin
8184
8185 hr_utility.set_location('pay_us_emp_dt_tax_rules.correct_percentage',1);
8186 l_payroll_installed := hr_utility.chk_product_install(p_product => 'Oracle Payroll',
8187 p_legislation => 'US');
8188
8189 /* Get effective Start date of the Federal Tax Rules record */
8190
8191 hr_utility.set_location('pay_us_emp_dt_tax_rules.correct_percentage',2);
8192 open csr_get_eff_date(p_assignment_id);
8193
8194 fetch csr_get_eff_date into l_default_date;
8195
8196 if l_default_date is null then
8197 close csr_get_eff_date;
8198 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
8199 fnd_message.set_token('PROCEDURE',
8200 'pay_us_emp_dt_tax_rules.correct_percentage');
8201 fnd_message.set_token('STEP','1');
8202 fnd_message.raise_error;
8203 end if;
8204
8205 close csr_get_eff_date;
8206
8207 hr_utility.set_location('pay_us_emp_dt_tax_rules.correct_percentage',3);
8208 open csr_tax_element;
8209 fetch csr_tax_element into l_element_type_id;
8210 if csr_tax_element%NOTFOUND then
8211 close csr_tax_element;
8212 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
8213 fnd_message.set_token('PROCEDURE',
8214 'pay_us_emp_dt_tax_rules.correct_percentage');
8215 fnd_message.set_token('STEP','2');
8216 fnd_message.raise_error;
8217 end if;
8218 close csr_tax_element;
8219
8220 hr_utility.set_location('pay_us_emp_dt_tax_rules.correct_percentage',4);
8221 /* Get element link */
8222 l_element_link_id := hr_entry_api.get_link(
8223 P_assignment_id => p_assignment_id,
8224 P_element_type_id => l_element_type_id,
8225 P_session_date => p_session_date);
8226
8227 if l_element_link_id is null or l_element_link_id = 0 then
8228 fnd_message.set_name('PAY', 'HR_13140_TAX_ELEMENT_ERROR');
8229 fnd_message.set_token('1','VERTEX');
8230 fnd_message.raise_error;
8231 end if;
8232
8233
8234 /* Let's handle the condition where there is just one set of
8235 %age records - from the default date till end of time or the
8236 termination date.
8237
8238 | Session date
8239 v
8240 T1 L1
8241 Asg |----------------------------------------
8242 SL1 |----------------------------------------
8243 COL1 |----------------------------------------
8244 CIL1 |----------------------------------------
8245
8246 | Session date
8247 v
8248 T1 T2 L1
8249 Asg |----------------------------------------
8250 SL1 |----------------------------------------
8251 COL1 |----------------------------------------
8252 CIL1 |----------------------------------------
8253
8254 The assignment record has not been broken up and L1 is corrected
8255 to L2. In the first scenario the defaulting criteria had been met as of the
8256 assignment effective start date. So, the tax records were created from time
8257 T1 i.e. the effective start date of the assignment. However, in the second case
8258 the defaulting criteria was met as of the date T2. So the tax records were created
8259 as of date T2 */
8260
8261 if (p_effective_start_date <= l_default_date and
8262 p_effective_end_date = l_end_of_time) then
8263 hr_utility.set_location('pay_us_emp_dt_tax_rules.correct_percentage',5);
8264
8265 if l_payroll_installed then
8266 /* Get all of the percentage records and set the percentage to zero */
8267
8268 hr_utility.set_location('pay_us_emp_dt_tax_rules.correct_percentage',6);
8269 zero_out_time(p_assignment_id => p_assignment_id,
8270 p_effective_start_date => p_effective_start_date,
8271 p_effective_end_date => p_effective_end_date);
8272 end if;
8273
8274 /* Create the tax rules records and the %age records for the
8275 new location - if required and set the city %age to 100 */
8276
8277 hr_utility.set_location('pay_us_emp_dt_tax_rules.correct_percentage',7);
8278
8279 l_ovrd_percent := 0;
8280 l_percent := 100;
8281 open csr_get_ovrd_loc(p_assignment_id, p_session_date);
8282 fetch csr_get_ovrd_loc into l_ovrd_loc;
8283 if csr_get_ovrd_loc%found then
8284 if l_ovrd_loc <> p_new_location_id then
8285 l_ovrd_percent := 100;
8286 l_percent := 0;
8287 end if;
8288 end if;
8289 close csr_get_ovrd_loc;
8290
8291 hr_utility.set_location('pay_us_emp_dt_tax_rules.correct_percentage',8);
8292 create_new_location_rec(p_assignment_id => p_assignment_id,
8293 p_validation_start_date => p_effective_start_date,
8294 p_validation_end_date => p_effective_end_date,
8295 p_session_date => p_session_date,
8296 p_new_location_id => p_new_location_id,
8297 p_res_state_code => null,
8298 p_res_county_code => null,
8299 p_res_city_code => null,
8300 p_business_group => p_business_group_id,
8301 p_percent => l_percent);
8302 hr_utility.set_location('pay_us_emp_dt_tax_rules.correct_percentage',9);
8303 if l_ovrd_percent = 100 then
8304 hr_utility.set_location('pay_us_emp_dt_tax_rules.correct_percentage',10);
8305 create_new_location_rec(p_assignment_id => p_assignment_id,
8306 p_validation_start_date => p_effective_start_date,
8307 p_validation_end_date => p_effective_end_date,
8308 p_session_date => p_session_date,
8309 p_new_location_id => l_ovrd_loc,
8310 p_res_state_code => null,
8311 p_res_county_code => null,
8312 p_res_city_code => null,
8313 p_business_group => p_business_group_id,
8314 p_percent => l_ovrd_percent);
8315 hr_utility.set_location('pay_us_emp_dt_tax_rules.correct_percentage',11);
8316 end if;
8317
8318
8319 else /* multiple locations */
8320
8321 /* Get the effective start date, effective end date and (effective start date - 1)
8322 of the %age record for the session date */
8323
8324 open csr_ele_entry(l_element_link_id);
8325
8326 fetch csr_ele_entry into l_pef_start_date, l_pef_end_date,
8327 l_pef_prev_date;
8328
8329 if csr_ele_entry%NOTFOUND then
8330 close csr_ele_entry;
8331 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
8332 fnd_message.set_token('PROCEDURE',
8333 'pay_us_emp_dt_tax_rules.correct_percentage');
8334 fnd_message.set_token('STEP','2');
8335 fnd_message.raise_error;
8336 end if;
8337
8338 close csr_ele_entry;
8339
8340 /* Set the validation start date */
8341
8342 if p_effective_start_date >= l_pef_start_date then
8343 l_validation_start_date := p_effective_start_date;
8344 else
8345 l_validation_start_date := l_pef_start_date;
8346 end if;
8347
8348 /* Time to take care of the multiple assignment records scenario
8349 - assignment end date less than the element entries end date
8350
8351 | Session Date
8352 V
8353 L1 L1
8354 Asg |----|-------------------------------------------
8355
8356 %age |------------------------------------------------
8357
8358 | Session Date
8359 V
8360 L1 L1 L2 L2 L1 L3
8361 Asg |----|-------|-----------|---|-------|-----------
8362
8363 %age |------------|---------------|-------|-----------
8364
8365 | Session Date
8366 V
8367 L1 L1 L2 L2 L2 L1 L3
8368 Asg |----|-------|-----|------|--|-------|-----------
8369
8370 %age |------------|---------------|-------|-----------
8371
8372 | Session Date
8373 V
8374 L1 L1 L2 L2 L2 L1 L3
8375 Asg |----|-------|-----|------|--|-------|-----------
8376
8377 %age |------------|---------------|-------|-----------
8378
8379 | Session Date
8380 V
8381 L1 L1 L2 L2 L1 L3
8382 Asg |----|-------|-----------|---|-------|-----------
8383
8384 %age |---------|---------------|-------|-----------
8385
8386 if the effective start date of the assignment record is less than
8387 or equal to the minimum of effective start date (i.e. the default date )
8388 of the vertex element entries then only the forward processing is required.
8389 However, if the effective start date of the assignment is equal to the
8390 effective start date of the element entries and the effective start date of the
8391 element entries is not the default date then the backward processing is also
8392 required .
8393 */
8394
8395
8396 if p_effective_end_date < l_pef_end_date then
8397
8398 /* Forward processing */
8399
8400 l_validation_end_date := p_effective_end_date;
8401
8402 /* Get the effective start date of the next assignment record */
8403 select p_effective_end_date + 1
8404 into l_pef_new_start_date
8405 from sys.DUAL;
8406
8407 /* Do an update insert for the same %age as of the l_pef_new_start_date */
8408 change_entries(p_assignment_id => p_assignment_id,
8409 p_session_date => l_pef_new_start_date,
8410 p_start_date => l_pef_start_date,
8411 p_end_date => l_pef_end_date,
8412 p_mode => 'INSERT_OLD');
8413
8414 if p_effective_start_date > l_pef_start_date then
8415
8416 /*
8417 | Session Date
8418 V
8419 L1 L1 L1 L2 L2 L1 L3
8420 Asg |----|----|--|-----------|---|-------|-----------
8421
8422 %age |------------|---------------|-------|-----------
8423 */
8424
8425 /* Do an update insert for the same %age as of the l_validation_start_date */
8426
8427 change_entries(p_assignment_id => p_assignment_id,
8428 p_session_date => l_validation_start_date,
8429 p_start_date => l_pef_start_date,
8430 p_end_date => l_validation_end_date,
8431 p_mode => 'INSERT_OLD');
8432
8433 elsif p_effective_start_date = l_pef_start_date and
8434 l_pef_start_date <> l_default_date then
8435
8436 /*
8437 | Session Date
8438 V
8439 L1 L1 L2 L2 L2 L1 L3
8440 Asg |----|-------|-----|------|--|-------|-----------
8441
8442 %age |------------|---------------|-------|-----------
8443
8444 */
8445
8446 /* Backward processing */
8447
8448 backward_processing(p_assignment => p_assignment_id,
8449 p_eff_start_date => p_effective_start_date,
8450 p_validation_start_date => l_validation_start_date,
8451 p_new_location => p_new_location_id,
8452 p_element_link => l_element_link_id);
8453 end if;
8454
8455 /* set the %age for all of the existing %age records to zero for the
8456 l_validation_start_date and l_validation_end_date */
8457
8458 zero_out_time(p_assignment_id => p_assignment_id,
8459 p_effective_start_date => l_validation_start_date,
8460 p_effective_end_date => l_validation_end_date);
8461
8462 /* create %age records for the new location, for every change in location
8463 of an assignment */
8464
8465 l_ovrd_percent := 0;
8466 l_percent := 100;
8467 open csr_get_ovrd_loc(p_assignment_id, p_session_date);
8468 fetch csr_get_ovrd_loc into l_ovrd_loc;
8469 if csr_get_ovrd_loc%found then
8470 if l_ovrd_loc <> p_new_location_id then
8471 l_ovrd_percent := 100;
8472 l_percent := 0;
8473 end if;
8474 end if;
8475 close csr_get_ovrd_loc;
8476
8477 create_new_location_rec(p_assignment_id => p_assignment_id,
8478 p_validation_start_date => l_validation_start_date,
8479 p_validation_end_date => l_validation_end_date,
8480 p_session_date => p_session_date,
8481 p_new_location_id => p_new_location_id,
8482 p_res_state_code => null,
8483 p_res_county_code => null,
8484 p_res_city_code => null,
8485 p_business_group => p_business_group_id,
8486 p_percent => l_percent);
8487 if l_ovrd_percent = 100 then
8488 create_new_location_rec(p_assignment_id => p_assignment_id,
8489 p_validation_start_date => l_validation_start_date,
8490 p_validation_end_date => l_validation_end_date,
8491 p_session_date => p_session_date,
8492 p_new_location_id => l_ovrd_loc,
8493 p_res_state_code => null,
8494 p_res_county_code => null,
8495 p_res_city_code => null,
8496 p_business_group => p_business_group_id,
8497 p_percent => l_ovrd_percent);
8498 end if;
8499
8500
8501 /* The effective end date of the location record is same as the
8502 effective end date of the corresponding %age record.
8503
8504 | Session Date
8505 V
8506 L1 L1 L2 L2 L1 L3
8507 Asg |----|-------|-----------|---|-------|-----------
8508
8509 %age |------------|---------------|-------|-----------
8510
8511 | Session Date
8512 V
8513 L1 L1 L2 L2 L1 L1
8514 Asg |----|-------|-----------|---|-------|-----------
8515
8516 %age |------------|---------------|-------------------
8517
8518
8519 */
8520
8521 elsif p_effective_end_date = l_pef_end_date then
8522
8523 l_validation_start_date := p_effective_start_date;
8524 l_validation_end_date := l_pef_end_date;
8525
8526 if l_pef_end_date <> l_end_of_time then
8527
8528 select l_validation_end_date + 1
8529 into l_pef_next_date
8530 from SYS.DUAL;
8531
8532 /* Get the next location of the assignment */
8533 open csr_get_next_location(l_pef_next_date);
8534 fetch csr_get_next_location into l_next_location;
8535 if csr_get_next_location%NOTFOUND
8536 then
8537 l_termination_flag := TRUE;
8538 else
8539 l_termination_flag := FALSE;
8540 end if;
8541 close csr_get_next_location;
8542
8543 end if;
8544
8545
8546 /* The effective end date of the location record is same as the
8547 effective end date of the corresponding %age record. However
8548 the assignment has been terminated or is till end of time.
8549
8550 | Session Date
8551 V
8552 L1 L1 L2 L2 L1
8553 Asg |----|-------|-----------|---|-------|
8554
8555 %age |------------|---------------|-------|
8556
8557 | Session Date
8558 V
8559 L1 L1 L2 L2 L1
8560 Asg |----|-------|-----------|-----|-----|
8561
8562 %age |------------|---------------|-------|
8563
8564 | Session Date
8565 V
8566 L1 L1 L2 L2 L1
8567 Asg |----|-------|-----------|---|-------
8568
8569 %age |------------|---------------|-------
8570
8571 | Session Date
8572 V
8573 L1 L1 L2 L2 L1
8574 Asg |----|-------|-----------|-----|-----
8575
8576 %age |------------|---------------|-------
8577
8578
8579 We can possibly have 2 scenarios of effective start date -
8580 p_effective start date = l_pef_effective_start_date or
8581 p_effective start date > l_pef_effective_start_date
8582 We can not have the scenario of
8583 p_effective start date < l_pef_effective_start_date under this
8584 condition. Only in the case of the first %age record , we might
8585 have this scenario when the tax %age records get created from a
8586 date later than the assignment's start date
8587 */
8588
8589 if (l_termination_flag or l_pef_end_date = l_end_of_time) then
8590
8591 if p_effective_start_date > l_pef_start_date then
8592
8593 if l_termination_flag then
8594
8595 /* Do an update insert as of the l_validation_start_date */
8596
8597 change_entries(p_assignment_id => p_assignment_id,
8598 p_session_date => l_validation_start_date,
8599 p_start_date => l_pef_start_date,
8600 p_end_date => l_pef_end_date,
8601 p_mode => 'UPDATE_CHANGE_INSERT');
8602
8603 elsif l_pef_end_date = l_end_of_time then
8604
8605 /* Do an update as of the l_validation_start_date */
8606
8607 change_entries(p_assignment_id => p_assignment_id,
8608 p_session_date => l_validation_start_date,
8609 p_start_date => l_pef_start_date,
8610 p_end_date => l_pef_end_date,
8611 p_mode => 'UPDATE');
8612
8613 end if;
8614
8615 /* zero out time for the current element entries for
8616 l_validation_start_date and l_validation_end_date */
8617
8618 zero_out_time(p_assignment_id => p_assignment_id,
8619 p_effective_start_date => l_validation_start_date,
8620 p_effective_end_date => l_validation_end_date);
8621
8622
8623 /* Create %age records for the new location, for
8624 every change in location */
8625
8626 l_ovrd_percent := 0;
8627 l_percent := 100;
8628 open csr_get_ovrd_loc(p_assignment_id, p_session_date);
8629 fetch csr_get_ovrd_loc into l_ovrd_loc;
8630 if csr_get_ovrd_loc%found then
8631 if l_ovrd_loc <> p_new_location_id then
8632 l_ovrd_percent := 100;
8633 l_percent := 0;
8634 end if;
8635 end if;
8636 close csr_get_ovrd_loc;
8637
8638 create_new_location_rec(p_assignment_id => p_assignment_id,
8639 p_validation_start_date => l_validation_start_date,
8640 p_validation_end_date => l_validation_end_date,
8641 p_session_date => p_session_date,
8642 p_new_location_id => p_new_location_id,
8643 p_res_state_code => null,
8644 p_res_county_code => null,
8645 p_res_city_code => null,
8646 p_business_group => p_business_group_id,
8647 p_percent => l_percent);
8648 if l_ovrd_percent = 100 then
8649 create_new_location_rec(p_assignment_id => p_assignment_id,
8650 p_validation_start_date => l_validation_start_date,
8651 p_validation_end_date => l_validation_end_date,
8652 p_session_date => p_session_date,
8653 p_new_location_id => l_ovrd_loc,
8654 p_res_state_code => null,
8655 p_res_county_code => null,
8656 p_res_city_code => null,
8657 p_business_group => p_business_group_id,
8658 p_percent => l_ovrd_percent);
8659 end if;
8660
8661 elsif p_effective_start_date = l_pef_start_date then
8662
8663 /* Backward processing */
8664 backward_processing(p_assignment => p_assignment_id,
8665 p_eff_start_date => p_effective_start_date,
8666 p_validation_start_date => l_validation_start_date,
8667 p_new_location => p_new_location_id,
8668 p_element_link => l_element_link_id);
8669
8670 /* zero out time for the date range between p_validation_start_date
8671 and p_validation_end_date */
8672
8673 zero_out_time(p_assignment_id => p_assignment_id,
8674 p_effective_start_date => l_validation_start_date,
8675 p_effective_end_date => l_validation_end_date);
8676
8677 /* Create the tax rules records and the %age records for the
8678 new location - if required and set the city %age to 100 */
8679
8680 l_ovrd_percent := 0;
8681 l_percent := 100;
8682 open csr_get_ovrd_loc(p_assignment_id, p_session_date);
8683 fetch csr_get_ovrd_loc into l_ovrd_loc;
8684 if csr_get_ovrd_loc%found then
8685 if l_ovrd_loc <> p_new_location_id then
8686 l_ovrd_percent := 100;
8687 l_percent := 0;
8688 end if;
8689 end if;
8690 close csr_get_ovrd_loc;
8691
8692 create_new_location_rec(p_assignment_id => p_assignment_id,
8693 p_validation_start_date => l_validation_start_date,
8694 p_validation_end_date => l_validation_end_date,
8695 p_session_date => p_session_date,
8696 p_new_location_id => p_new_location_id,
8697 p_res_state_code => null,
8698 p_res_county_code => null,
8699 p_res_city_code => null,
8700 p_business_group => p_business_group_id,
8701 p_percent => l_percent);
8702 if l_ovrd_percent = 100 then
8703 create_new_location_rec(p_assignment_id => p_assignment_id,
8704 p_validation_start_date => l_validation_start_date,
8705 p_validation_end_date => l_validation_end_date,
8706 p_session_date => p_session_date,
8707 p_new_location_id => l_ovrd_loc,
8708 p_res_state_code => null,
8709 p_res_county_code => null,
8710 p_res_city_code => null,
8711 p_business_group => p_business_group_id,
8712 p_percent => l_ovrd_percent);
8713 end if;
8714
8715
8716 end if; /* check for the p_effective_start_date > or = to the
8717 l_pef_start_date */
8718
8719 else /* Not a terminated assignment */
8720
8721 /* Processing for the condition when next location <> new location.
8722
8723 | Session Date
8724 V
8725 L1 L2 L2 L1 L3
8726 Asg |------------|-----------|---|-------|-----------
8727
8728 %age |------------|---------------|-------|-----------
8729
8730 | Session Date
8731 V
8732 L1 L2 L2 L1 L3
8733 Asg |------------|-----------|---|-------|-----------
8734
8735 %age |------------|---------------|-------|-----------
8736
8737 | Session Date
8738 V
8739 L1 L2 L1 L3
8740 Asg |------------|---------------|-------|-----------
8741
8742 %age |------------|---------------|-------|-----------
8743
8744 | Session Date
8745 V
8746 L1 L2 L2 L1 L3
8747 Asg |------------|-----------|---|-------|-----------
8748
8749 %age |-------|---------------|-------|-----------
8750
8751 In the above examples if we correct location as of the session date
8752 to L3 then new location <> next location.
8753 */
8754
8755 l_validation_start_date := p_effective_start_date;
8756 l_validation_end_date := l_pef_end_date;
8757
8758 if p_effective_start_date > l_pef_start_date then
8759
8760 /*
8761 | Session Date
8762 V
8763 L1 L2 L2 (L5) L3 L4
8764 Asg |------------|-------|-- ----|-------|-----------
8765
8766 %age |------------|---------------|-------|-----------
8767
8768
8769 | Session Date
8770 V
8771 L1 L2 L2 (L3) L3 L4
8772 Asg |------------|-------|-- ----|-------|-----------
8773
8774 %age |------------|---------------|-------|-----------
8775
8776 Note : L2 (L5) means L2 changed to L5. Similarly
8777 L2 (L3) means L2 changed to L3.
8778 */
8779
8780 /* Do an update insert as of the l_validation_start_date */
8781
8782 change_entries(p_assignment_id => p_assignment_id,
8783 p_session_date => l_validation_start_date,
8784 p_start_date => l_pef_start_date,
8785 p_end_date => l_pef_end_date,
8786 p_mode => 'UPDATE_CHANGE_INSERT');
8787
8788 /* next location = p_new_location_id */
8789
8790 if l_next_location = p_new_location_id then
8791
8792 /* Processing for the condition when next location = new location.
8793
8794 | Session Date
8795 V
8796 L1 L2 L2 L1 L3
8797 Asg |------------|-----------|---|-------|-----------
8798
8799 %age |------------|---------------|-------|-----------
8800
8801 In the above example if we correct L2 as of the session date
8802 to L1 then new location = next location. */
8803
8804
8805 /* Get the end date of the next %age records */
8806 open csr_get_next_date(l_element_link_id,l_pef_next_date);
8807 fetch csr_get_next_date into l_next_loc_end_date;
8808 if csr_get_next_date%NOTFOUND then
8809 close csr_get_next_date;
8810 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
8811 fnd_message.set_token('PROCEDURE',
8812 'pay_us_emp_dt_tax_rules.correct_percentage');
8813 fnd_message.set_token('STEP','4');
8814 fnd_message.raise_error;
8815 end if;
8816
8817 close csr_get_next_date;
8818
8819 /* set the validation end date to the end date of the next
8820 set of %age records */
8821
8822 l_validation_end_date := l_next_loc_end_date;
8823
8824 /* deleting the current set */
8825
8826 upd_del_entries(p_assignment_id => p_assignment_id,
8827 p_session_date => l_validation_start_date,
8828 p_new_start_date => null,
8829 p_new_end_date => null,
8830 p_mode => 'D');
8831
8832 /* Pull the next set to the p_validation start date */
8833
8834 upd_del_entries(p_assignment_id => p_assignment_id,
8835 p_session_date => l_pef_next_date,
8836 p_new_start_date => l_validation_start_date,
8837 p_new_end_date => null,
8838 p_mode => 'U');
8839
8840 /* call zero_out_time for p_validation_start_date and
8841 p_validation_end_date */
8842
8843 zero_out_time(p_assignment_id => p_assignment_id,
8844 p_effective_start_date => l_validation_start_date,
8845 p_effective_end_date => l_validation_end_date);
8846
8847 end if;
8848
8849 /* Create the tax rules records and the %age records for the
8850 new location - if required and set the city %age to 100 */
8851
8852 l_ovrd_percent := 0;
8853 l_percent := 100;
8854 open csr_get_ovrd_loc(p_assignment_id, p_session_date);
8855 fetch csr_get_ovrd_loc into l_ovrd_loc;
8856 if csr_get_ovrd_loc%found then
8857 if l_ovrd_loc <> p_new_location_id then
8858 l_ovrd_percent := 100;
8859 l_percent := 0;
8860 end if;
8861 end if;
8862 close csr_get_ovrd_loc;
8863
8864
8865 create_new_location_rec(p_assignment_id => p_assignment_id,
8866 p_validation_start_date => l_validation_start_date,
8867 p_validation_end_date => l_validation_end_date,
8868 p_session_date => p_session_date,
8869 p_new_location_id => p_new_location_id,
8870 p_res_state_code => null,
8871 p_res_county_code => null,
8872 p_res_city_code => null,
8873 p_business_group => p_business_group_id,
8874 p_percent => l_percent);
8875 if l_ovrd_percent = 100 then
8876 create_new_location_rec(p_assignment_id => p_assignment_id,
8877 p_validation_start_date => l_validation_start_date,
8878 p_validation_end_date => l_validation_end_date,
8879 p_session_date => p_session_date,
8880 p_new_location_id => l_ovrd_loc,
8881 p_res_state_code => null,
8882 p_res_county_code => null,
8883 p_res_city_code => null,
8884 p_business_group => p_business_group_id,
8885 p_percent => l_ovrd_percent);
8886 end if;
8887
8888 elsif p_effective_start_date = l_pef_start_date then
8889
8890
8891 /*
8892 | Session Date
8893 V
8894 L1 L2 (L5) L3 L4
8895 Asg |------------|---------------|-------|-----------
8896
8897 %age |------------|---------------|-------|-----------
8898
8899 | Session Date
8900 V
8901 L1 L2 (L1) L3 L4
8902 Asg |------------|---------------|-------|-----------
8903
8904 %age |------------|---------------|-------|-----------
8905
8906 | Session Date
8907 V
8908 L1 L2 (L1) L1 L4
8909 Asg |------------|---------------|-------|-----------
8910
8911 %age |------------|---------------|-------|-----------
8912
8913
8914 Note : L2 (L5) means L2 changed to L5. Similarly
8915 L2 (L1) means L2 changed to L1.
8916 */
8917
8918 /* Backward processing */
8919 backward_processing(p_assignment => p_assignment_id,
8920 p_eff_start_date => p_effective_start_date,
8921 p_validation_start_date => l_validation_start_date,
8922 p_new_location => p_new_location_id,
8923 p_element_link => l_element_link_id);
8924
8925 /* next location = p_new_location_id */
8926
8927 if l_next_location = p_new_location_id then
8928
8929 /* Processing for the condition when next location = new location.
8930
8931 | Session Date
8932 V
8933 L1 L2 (L1) L1 L3
8934 Asg |------------|---------------|-------|-----------
8935
8936 %age |------------|---------------|-------|-----------
8937
8938 | Session Date
8939 V
8940 L1 L2 (L3) L3 L4
8941 Asg |------------|---------------|-------|-----------
8942
8943 %age |------------|---------------|-------|-----------
8944
8945 In the above example if we correct L2 as of the session date
8946 to L1 then new location = next location. */
8947
8948
8949 /* Get the end date of the next %age records */
8950 open csr_get_next_date(l_element_link_id,l_pef_next_date);
8951 fetch csr_get_next_date into l_next_loc_end_date;
8952 if csr_get_next_date%NOTFOUND then
8953 close csr_get_next_date;
8954 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
8955 fnd_message.set_token('PROCEDURE',
8956 'pay_us_emp_dt_tax_rules.correct_percentage');
8957 fnd_message.set_token('STEP','4');
8958 fnd_message.raise_error;
8959 end if;
8960
8961 close csr_get_next_date;
8962
8963 /* set the validation end date to the end date of the next
8964 set of %age records */
8965
8966 l_validation_end_date := l_next_loc_end_date;
8967
8968 /* deleting the current set */
8969
8970 upd_del_entries(p_assignment_id => p_assignment_id,
8971 p_session_date => l_validation_start_date,
8972 p_new_start_date => null,
8973 p_new_end_date => null,
8974 p_mode => 'D');
8975
8976 /* Pull the next set to the p_validation start date */
8977
8978 upd_del_entries(p_assignment_id => p_assignment_id,
8979 p_session_date => l_pef_next_date,
8980 p_new_start_date => l_validation_start_date,
8981 p_new_end_date => null,
8982 p_mode => 'U');
8983
8984 end if;
8985
8986 /* zero out time for the date range between p_validation_start_date
8987 and p_validation_end_date */
8988
8989 zero_out_time(p_assignment_id => p_assignment_id,
8990 p_effective_start_date => l_validation_start_date,
8991 p_effective_end_date => l_validation_end_date);
8992
8993 /* Create the tax rules records and the %age records for the
8994 new location - if required and set the city %age to 100 */
8995
8996 l_ovrd_percent := 0;
8997 l_percent := 100;
8998 open csr_get_ovrd_loc(p_assignment_id, p_session_date);
8999 fetch csr_get_ovrd_loc into l_ovrd_loc;
9000 if csr_get_ovrd_loc%found then
9001 if l_ovrd_loc <> p_new_location_id then
9002 l_ovrd_percent := 100;
9003 l_percent := 0;
9004 end if;
9005 end if;
9006 close csr_get_ovrd_loc;
9007
9008 create_new_location_rec(p_assignment_id => p_assignment_id,
9009 p_validation_start_date => l_validation_start_date,
9010 p_validation_end_date => l_validation_end_date,
9011 p_session_date => p_session_date,
9012 p_new_location_id => p_new_location_id,
9013 p_res_state_code => null,
9014 p_res_county_code => null,
9015 p_res_city_code => null,
9016 p_business_group => p_business_group_id,
9017 p_percent => l_percent);
9018 if l_ovrd_percent = 100 then
9019 create_new_location_rec(p_assignment_id => p_assignment_id,
9020 p_validation_start_date => l_validation_start_date,
9021 p_validation_end_date => l_validation_end_date,
9022 p_session_date => p_session_date,
9023 p_new_location_id => l_ovrd_loc,
9024 p_res_state_code => null,
9025 p_res_county_code => null,
9026 p_res_city_code => null,
9027 p_business_group => p_business_group_id,
9028 p_percent => l_ovrd_percent);
9029 end if;
9030
9031
9032 end if;
9033
9034 end if; /* terminated /unterminated assignment */
9035
9036 end if; /* same/different effective end date */
9037
9038 end if; /* Single and multiple locations */
9039
9040 end correct_percentage;
9041
9042 procedure update_percentage (p_assignment_id in number,
9043 p_effective_start_date in date,
9044 p_effective_end_date in date,
9045 p_session_date in date,
9046 p_new_location_id in number,
9047 p_business_group_id in number,
9048 p_mode in varchar2,
9049 p_ret_code in out nocopy number,
9050 p_ret_text in out nocopy varchar2) is
9051
9052 l_validation_start_date date := null;
9053 l_validation_end_date date := null;
9054 l_prev_end_date date := null;
9055 l_next_location number;
9056 l_pef_start_date date;
9057 l_pef_end_date date;
9058 l_pef_next_date date;
9059 l_termination_flag boolean:= FALSE;
9060 l_element_type_id number;
9061 l_element_link_id number;
9062 l_new_session_date date;
9063 l_ovrd_loc number;
9064 l_ovrd_percent number := 0;
9065 l_percent number := 100;
9066
9067
9068 /* Get the Vertex element type */
9069 cursor csr_tax_element is
9070 select pet.element_type_id
9071 from PAY_ELEMENT_TYPES_F pet
9072 where pet.element_name = 'VERTEX'
9073 and p_session_date between pet.effective_start_date
9074 and pet.effective_end_date;
9075
9076 /* Cursor to get the effective dates of the %age record for the
9077 session date */
9078
9079 cursor csr_get_dates(p_element_link number, p_session_dt date) is
9080 select pef.effective_start_date,
9081 pef.effective_end_date,
9082 pef.effective_end_date + 1
9083 from PAY_ELEMENT_ENTRIES_F pef
9084 where pef.assignment_id = p_assignment_id
9085 and p_session_dt between pef.effective_start_date
9086 and pef.effective_end_date
9087 and pef.element_link_id = p_element_link
9088 and rownum < 2;
9089
9090 /* cursor to get the next location */
9091
9092 cursor csr_get_next_location (p_next_eff_date date) is
9093 select paf.location_id
9094 from PER_ASSIGNMENTS_F paf
9095 where paf.assignment_id = p_assignment_id and
9096 p_next_eff_date between paf.effective_start_date
9097 and paf.effective_end_date;
9098
9099 /* cursor to get the effective end date of the next element entry record */
9100 cursor csr_get_next_date (p_element_link number, p_date date)is
9101 select pee.effective_end_date
9102 from PAY_ELEMENT_ENTRIES_F pee
9103 where pee.assignment_id = p_assignment_id
9104 and p_date between pee.effective_start_date
9105 and pee.effective_end_date
9106 and pee.element_link_id = p_element_link
9107 and rownum < 2;
9108
9109 cursor csr_get_ovrd_loc(p_assignment number, p_session_dt date) is
9110 select nvl(hsck.segment18, paf.location_id)
9111 from HR_SOFT_CODING_KEYFLEX hsck,
9112 PER_ASSIGNMENTS_F paf
9113 where paf.assignment_id = p_assignment
9114 and p_session_dt between paf.effective_start_date
9115 and paf.effective_end_date
9116 and hsck.soft_coding_keyflex_id = paf.soft_coding_keyflex_id;
9117
9118
9119
9120 begin
9121
9122 /* Check for Update
9123
9124 | Session date
9125 V
9126 |-------------------------------------
9127
9128 */
9129
9130 if p_mode in ('UPDATE','UPDATE_OVERRIDE') then
9131
9132 l_validation_start_date := p_session_date;
9133 l_validation_end_date := to_date('31/12/4712','dd/mm/yyyy');
9134
9135 /* Do an update for the element entries for all of the
9136 existing jurisdictions of the assignment */
9137
9138 change_entries(p_assignment_id => p_assignment_id,
9139 p_session_date => p_session_date,
9140 p_start_date => p_effective_start_date,
9141 p_end_date => p_effective_end_date,
9142 p_mode => p_mode);
9143
9144 /* Create the tax rules records and the %age records for the
9145 new location - if required and set the city %age to 100 */
9146
9147 l_ovrd_percent := 0;
9148 l_percent := 100;
9149 open csr_get_ovrd_loc(p_assignment_id, p_session_date);
9150 fetch csr_get_ovrd_loc into l_ovrd_loc;
9151 if csr_get_ovrd_loc%found then
9152 if l_ovrd_loc <> p_new_location_id then
9153 l_ovrd_percent := 100;
9154 l_percent := 0;
9155 end if;
9156 end if;
9157 close csr_get_ovrd_loc;
9158
9159 create_new_location_rec(p_assignment_id => p_assignment_id,
9160 p_validation_start_date => l_validation_start_date,
9161 p_validation_end_date => l_validation_end_date,
9162 p_session_date => p_session_date,
9163 p_new_location_id => p_new_location_id,
9164 p_res_state_code => null,
9165 p_res_county_code => null,
9166 p_res_city_code => null,
9167 p_business_group => p_business_group_id,
9168 p_percent => l_percent);
9169 if l_ovrd_percent = 100 then
9170 create_new_location_rec(p_assignment_id => p_assignment_id,
9171 p_validation_start_date => l_validation_start_date,
9172 p_validation_end_date => l_validation_end_date,
9173 p_session_date => p_session_date,
9174 p_new_location_id => l_ovrd_loc,
9175 p_res_state_code => null,
9176 p_res_county_code => null,
9177 p_res_city_code => null,
9178 p_business_group => p_business_group_id,
9179 p_percent => l_ovrd_percent);
9180 end if;
9181
9182
9183 elsif p_mode = 'UPDATE_CHANGE_INSERT' then
9184
9185 open csr_tax_element;
9186
9187 fetch csr_tax_element into l_element_type_id;
9188
9189 if csr_tax_element%NOTFOUND then
9190
9191 close csr_tax_element;
9192 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
9193 fnd_message.set_token('PROCEDURE',
9194 'pay_us_emp_dt_tax_rules.update_percentage');
9195 fnd_message.set_token('STEP','1');
9196 fnd_message.raise_error;
9197
9198 end if;
9199
9200 close csr_tax_element;
9201
9202 /* Get element link */
9203
9204 l_element_link_id := hr_entry_api.get_link(
9205 P_assignment_id => p_assignment_id,
9206 P_element_type_id => l_element_type_id,
9207 P_session_date => p_session_date);
9208
9209 if l_element_link_id is null or l_element_link_id = 0 then
9210
9211 fnd_message.set_name('PAY', 'HR_13140_TAX_ELEMENT_ERROR');
9212 fnd_message.set_token('1','VERTEX');
9213 fnd_message.raise_error;
9214
9215 end if;
9216
9217 /* Get the effective start date, effective end date and (effective end date + 1)
9218 of the %age record for the session date */
9219
9220 open csr_get_dates(l_element_link_id, p_session_date);
9221
9222 fetch csr_get_dates into l_pef_start_date, l_pef_end_date, l_pef_next_date;
9223
9224 if csr_get_dates%NOTFOUND then
9225
9226 close csr_get_dates;
9227 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
9228 fnd_message.set_token('PROCEDURE',
9229 'pay_us_emp_dt_tax_rules.update_percentage');
9230 fnd_message.set_token('STEP','2');
9231 fnd_message.raise_error;
9232
9233 end if;
9234
9235 close csr_get_dates;
9236
9237 if p_effective_end_date <> l_pef_end_date then
9238
9239 l_validation_start_date := p_session_date;
9240 l_validation_end_date := p_effective_end_date;
9241
9242
9243 /* First do an update insert with the existing value of the
9244 existing jurisdictions as of the p_effective_end_date + 1 */
9245
9246 select p_effective_end_date + 1
9247 into l_new_session_date
9248 from DUAL;
9249
9250 change_entries(p_assignment_id => p_assignment_id,
9251 p_session_date => l_new_session_date,
9252 p_start_date => l_pef_start_date,
9253 p_end_date => l_pef_end_date,
9254 p_mode => 'INSERT_OLD');
9255
9256
9257 /* Again do an update insert for the element entries for all of the
9258 existing jurisdictions of the assignment, as of the session date */
9259
9260 change_entries(p_assignment_id => p_assignment_id,
9261 p_session_date => p_session_date,
9262 p_start_date => l_pef_start_date,
9263 p_end_date => l_validation_end_date,
9264 p_mode => 'UPDATE_CHANGE_INSERT');
9265
9266 /* Create the tax rules records and the %age records for the
9267 new location - if required and set the city %age to 100 */
9268
9269 l_ovrd_percent := 0;
9270 l_percent := 100;
9271 open csr_get_ovrd_loc(p_assignment_id, p_session_date);
9272 fetch csr_get_ovrd_loc into l_ovrd_loc;
9273 if csr_get_ovrd_loc%found then
9274 if l_ovrd_loc <> p_new_location_id then
9275 l_ovrd_percent := 100;
9276 l_percent := 0;
9277 end if;
9278 end if;
9279 close csr_get_ovrd_loc;
9280
9281
9282 create_new_location_rec(p_assignment_id => p_assignment_id,
9283 p_validation_start_date => l_validation_start_date,
9284 p_validation_end_date => l_validation_end_date,
9285 p_session_date => p_session_date,
9286 p_new_location_id => p_new_location_id,
9287 p_res_state_code => null,
9288 p_res_county_code => null,
9289 p_res_city_code => null,
9290 p_business_group => p_business_group_id,
9291 p_percent => l_percent);
9292 if l_ovrd_percent = 100 then
9293 create_new_location_rec(p_assignment_id => p_assignment_id,
9294 p_validation_start_date => l_validation_start_date,
9295 p_validation_end_date => l_validation_end_date,
9296 p_session_date => p_session_date,
9297 p_new_location_id => l_ovrd_loc,
9298 p_res_state_code => null,
9299 p_res_county_code => null,
9300 p_res_city_code => null,
9301 p_business_group => p_business_group_id,
9302 p_percent => l_ovrd_percent);
9303 end if;
9304
9305
9306
9307 else /* the end dates of the assignment record and the %age rec.
9308 are the same */
9309
9310 l_validation_start_date := p_session_date;
9311 l_validation_end_date := l_pef_end_date;
9312
9313 /* Get the next location of the assignment */
9314
9315 open csr_get_next_location(l_pef_next_date);
9316
9317 fetch csr_get_next_location into l_next_location;
9318
9319 if csr_get_next_location%NOTFOUND then
9320
9321 l_termination_flag := TRUE;
9322
9323 else
9324
9325 l_termination_flag := FALSE;
9326
9327 end if;
9328
9329 close csr_get_next_location;
9330
9331 if l_termination_flag = FALSE and l_next_location = p_new_location_id then
9332
9333 /* get the effective end date of the next set of %age records */
9334
9335 open csr_get_next_date(l_element_link_id, l_pef_next_date);
9336
9337 fetch csr_get_next_date into l_validation_end_date;
9338
9339 if csr_get_next_date%NOTFOUND then
9340
9341 close csr_get_next_date;
9342 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
9343 fnd_message.set_token('PROCEDURE',
9344 'pay_us_emp_dt_tax_rules.update_percentage');
9345 fnd_message.set_token('STEP','2');
9346 fnd_message.raise_error;
9347
9348 end if;
9349
9350 /* Pull forward the records as of the session date to
9351 l_validation_start_date -1 */
9352
9353 select l_validation_start_date - 1
9354 into l_prev_end_date
9355 from SYS.DUAL;
9356
9357 upd_del_entries(p_assignment_id => p_assignment_id,
9358 p_session_date => p_session_date,
9359 p_new_start_date => null,
9360 p_new_end_date => l_prev_end_date,
9361 p_mode => 'U');
9362
9363 /* Pull back the records as of the session date to
9364 p_session_date +1 */
9365
9366 upd_del_entries(p_assignment_id => p_assignment_id,
9367 p_session_date => l_pef_next_date,
9368 p_new_start_date => l_validation_start_date,
9369 p_new_end_date => null,
9370 p_mode => 'U');
9371
9372 else /* If termination flag is true or termination flag is false and
9373 change in location has taken place */
9374
9375 change_entries(p_assignment_id => p_assignment_id,
9376 p_session_date => p_session_date,
9377 p_start_date => l_pef_start_date,
9378 p_end_date => l_pef_end_date,
9379 p_mode => 'UPDATE_CHANGE_INSERT');
9380
9381 /* zero out the time for the new date range */
9382
9383 zero_out_time(p_assignment_id => p_assignment_id,
9384 p_effective_start_date => l_validation_start_date,
9385 p_effective_end_date => l_validation_end_date);
9386
9387
9388 /* Create the tax rules records and the %age records for the
9389 new location - if required and set the city %age to 100 */
9390
9391 l_ovrd_percent := 0;
9392 l_percent := 100;
9393 open csr_get_ovrd_loc(p_assignment_id, p_session_date);
9394 fetch csr_get_ovrd_loc into l_ovrd_loc;
9395 if csr_get_ovrd_loc%found then
9396 if l_ovrd_loc <> p_new_location_id then
9397 l_ovrd_percent := 100;
9398 l_percent := 0;
9399 end if;
9400 end if;
9401 close csr_get_ovrd_loc;
9402
9403 create_new_location_rec(p_assignment_id => p_assignment_id,
9404 p_validation_start_date => l_validation_start_date,
9405 p_validation_end_date => l_validation_end_date,
9406 p_session_date => p_session_date,
9407 p_new_location_id => p_new_location_id,
9408 p_res_state_code => null,
9409 p_res_county_code => null,
9410 p_res_city_code => null,
9411 p_business_group => p_business_group_id,
9412 p_percent => l_percent);
9413 if l_ovrd_percent = 100 then
9414 create_new_location_rec(p_assignment_id => p_assignment_id,
9415 p_validation_start_date => l_validation_start_date,
9416 p_validation_end_date => l_validation_end_date,
9417 p_session_date => p_session_date,
9418 p_new_location_id => l_ovrd_loc,
9419 p_res_state_code => null,
9420 p_res_county_code => null,
9421 p_res_city_code => null,
9422 p_business_group => p_business_group_id,
9423 p_percent => l_ovrd_percent);
9424 end if;
9425
9426
9427
9428 end if; /* Termination Flag is false or true */
9429
9430 end if;
9431
9432 end if;
9433
9434 end update_percentage;
9435
9436
9437 /* Name : correct_wc_entry
9438 Purpose : This will handle the workers comp element entry
9439 for a 'correction' to the assignment's location.
9440 */
9441
9442 procedure correct_wc_entry (p_assignment_id in number,
9443 p_effective_start_date in date,
9444 p_effective_end_date in date,
9445 p_session_date in date,
9446 p_new_location_id in number,
9447 p_ret_code in out nocopy number,
9448 p_ret_text in out nocopy varchar2) is
9449
9450 cursor csr_get_loc_state is
9451 select pus.state_code
9452 from PAY_US_STATES pus,
9453 HR_LOCATIONS hrl
9454 where hrl.location_id = p_new_location_id
9455 and pus.state_abbrev = nvl(hrl.loc_information17,hrl.region_2);
9456
9457 cursor csr_get_fed_rows is
9458 select pef.effective_start_date, pef.effective_end_date,
9459 pef.sui_jurisdiction_code
9460 from PAY_US_EMP_FED_TAX_RULES_F pef
9461 where pef.assignment_id = p_assignment_id
9462 and p_effective_start_date <= pef.effective_end_date
9463 and p_effective_end_date >= pef.effective_start_date;
9464
9465 cursor csr_get_fed_details (p_start_date date, p_end_date date) is
9466 select * from pay_us_emp_fed_tax_rules_f
9467 where assignment_id = p_assignment_id
9468 and effective_start_date = p_start_date
9469 and effective_end_date = p_end_date;
9470
9471 cursor csr_lck_fed_row (p_start_date date, p_end_date date)is
9472 select rowid
9473 from PAY_US_EMP_FED_TAX_RULES_F
9474 where assignment_id = p_assignment_id
9475 and effective_start_date = p_start_date
9476 and effective_end_date = p_end_date
9477 for update nowait;
9478
9479 l_eff_start_date date;
9480 l_eff_end_date date;
9481 l_row_id rowid;
9482 l_work_state_code varchar2(2);
9483 l_new_date date;
9484 l_jurisdiction_code varchar2(11);
9485 l_step number;
9486 l_fed_rec PAY_US_EMP_FED_TAX_RULES_F%rowtype;
9487
9488 begin
9489
9490 l_step := 1;
9491 /* Get the state code of the new work location */
9492 open csr_get_loc_state;
9493 fetch csr_get_loc_state into l_work_state_code;
9494 if csr_get_loc_state%NOTFOUND then
9495 close csr_get_loc_state;
9496 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
9497 fnd_message.set_token('PROCEDURE',
9498 'pay_us_emp_dt_tax_rules.correct_wc_entry');
9499 fnd_message.set_token('STEP',to_char(l_step));
9500 fnd_message.raise_error;
9501 end if;
9502 close csr_get_loc_state;
9503
9504 l_step := 2;
9505 open csr_get_fed_rows;
9506 loop
9507
9508 l_step := 3;
9509 fetch csr_get_fed_rows into l_eff_start_date, l_eff_end_date,
9510 l_jurisdiction_code;
9511 exit when csr_get_fed_rows%NOTFOUND;
9512 if l_eff_start_date >= p_effective_start_date and
9513 l_eff_end_date <= p_effective_end_date then
9514 l_step := 4;
9515 /* Lock the federal record before updating */
9516 open csr_lck_fed_row(l_eff_start_date, l_eff_end_date);
9517 l_step := 5;
9518 fetch csr_lck_fed_row into l_row_id;
9519 if csr_lck_fed_row%NOTFOUND then
9520 close csr_lck_fed_row;
9521 fnd_message.set_name('FND','FORM_UNABLE_TO_RESERVE_RECORD');
9522 fnd_message.raise_error;
9523 end if;
9524 close csr_lck_fed_row;
9525
9526 /* Update the federal tax record for the SUI state */
9527 l_step := 6;
9528 update PAY_US_EMP_FED_TAX_RULES_F
9529 set sui_state_code = l_work_state_code,
9530 sui_jurisdiction_code = l_work_state_code ||'-000-0000'
9531 where rowid = l_row_id;
9532
9533 /* correct the jurisdiction for the Workers Compensation
9534 element entry */
9535 l_step := 7;
9536
9537 maintain_wc_ele_entry (p_assignment_id => p_assignment_id,
9538 p_effective_start_date => l_eff_start_date,
9539 p_effective_end_date => l_eff_end_date,
9540 p_session_date => l_eff_start_date,
9541 p_jurisdiction_code => l_work_state_code ||'-000-0000',
9542 p_mode => 'CORRECTION');
9543
9544 elsif l_eff_start_date < p_effective_start_date and
9545 l_eff_end_date <= p_effective_end_date then
9546
9547 l_step := 8;
9548 select p_effective_start_date -1
9549 into l_new_date
9550 from DUAL;
9551
9552 l_step := 9;
9553 open csr_get_fed_details(l_eff_start_date, l_eff_end_date);
9554 fetch csr_get_fed_details into l_fed_rec;
9555 if csr_get_fed_details%NOTFOUND then
9556 close csr_get_fed_details;
9557 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
9558 fnd_message.set_token('PROCEDURE',
9559 'pay_us_emp_dt_tax_rules.correct_wc_entry');
9560 fnd_message.set_token('STEP',to_char(l_step));
9561 fnd_message.raise_error;
9562 end if;
9563 close csr_get_fed_details;
9564
9565 /* Update the Federal tax record as of the p_effective_start_date */
9566
9567 l_step := 10;
9568 update PAY_US_EMP_FED_TAX_RULES_F
9569 set effective_end_date = l_new_date
9570 where assignment_id = p_assignment_id
9571 and effective_start_date = l_eff_start_date
9572 and effective_end_date = l_eff_end_date;
9573
9574 l_step := 11;
9575 insert into PAY_US_EMP_FED_TAX_RULES_F
9576 (emp_fed_tax_rule_id,
9577 effective_start_date,
9578 effective_end_date,
9579 assignment_id,
9580 sui_state_code,
9581 sui_jurisdiction_code,
9582 business_group_id,
9583 additional_wa_amount,
9584 filing_status_code,
9585 fit_override_amount,
9586 fit_override_rate,
9587 withholding_allowances,
9588 cumulative_taxation,
9589 eic_filing_status_code,
9590 fit_additional_tax,
9591 fit_exempt,
9592 futa_tax_exempt,
9593 medicare_tax_exempt,
9594 ss_tax_exempt,
9595 wage_exempt,
9596 statutory_employee,
9597 w2_filed_year,
9598 supp_tax_override_rate,
9599 excessive_wa_reject_date,
9600 object_version_number,
9601 attribute_category,
9602 attribute1,
9603 attribute2,
9604 attribute3,
9605 attribute4,
9606 attribute5,
9607 attribute6,
9608 attribute7,
9609 attribute8,
9610 attribute9,
9611 attribute10,
9612 attribute11,
9613 attribute12,
9614 attribute13,
9615 attribute14,
9616 attribute15,
9617 attribute16,
9618 attribute17,
9619 attribute18,
9620 attribute19,
9621 attribute20,
9622 attribute21,
9623 attribute22,
9624 attribute23,
9625 attribute24,
9626 attribute25,
9627 attribute26,
9628 attribute27,
9629 attribute28,
9630 attribute29,
9631 attribute30,
9632 fed_information_category,
9633 fed_information1,
9634 fed_information2,
9635 fed_information3,
9636 fed_information4,
9637 fed_information5,
9638 fed_information6,
9639 fed_information7,
9640 fed_information8,
9641 fed_information9,
9642 fed_information10,
9643 fed_information11,
9644 fed_information12,
9645 fed_information13,
9646 fed_information14,
9647 fed_information15,
9648 fed_information16,
9649 fed_information17,
9650 fed_information18,
9651 fed_information19,
9652 fed_information20,
9653 fed_information21,
9654 fed_information22,
9655 fed_information23,
9656 fed_information24,
9657 fed_information25,
9658 fed_information26,
9659 fed_information27,
9660 fed_information28,
9661 fed_information29,
9662 fed_information30
9663 )
9664
9665 values
9666 (l_fed_rec.emp_fed_tax_rule_id,
9667 p_effective_start_date,
9668 l_fed_rec.effective_end_date,
9669 l_fed_rec.assignment_id,
9670 l_work_state_code,
9671 l_work_state_code || '-000-0000',
9672 l_fed_rec.business_group_id,
9673 l_fed_rec.additional_wa_amount,
9674 lpad(l_fed_rec.filing_status_code,2,'0'),
9675 l_fed_rec.fit_override_amount,
9676 l_fed_rec.fit_override_rate,
9677 l_fed_rec.withholding_allowances,
9678 l_fed_rec.cumulative_taxation,
9679 l_fed_rec.eic_filing_status_code,
9680 l_fed_rec.fit_additional_tax,
9681 l_fed_rec.fit_exempt,
9682 l_fed_rec.futa_tax_exempt,
9683 l_fed_rec.medicare_tax_exempt,
9684 l_fed_rec.ss_tax_exempt,
9685 l_fed_rec.wage_exempt,
9686 l_fed_rec.statutory_employee,
9687 l_fed_rec.w2_filed_year,
9688 l_fed_rec.supp_tax_override_rate,
9689 l_fed_rec.excessive_wa_reject_date,
9690 0,
9691 l_fed_rec.attribute_category,
9692 l_fed_rec.attribute1,
9693 l_fed_rec.attribute2,
9694 l_fed_rec.attribute3,
9695 l_fed_rec.attribute4,
9696 l_fed_rec.attribute5,
9697 l_fed_rec.attribute6,
9698 l_fed_rec.attribute7,
9699 l_fed_rec.attribute8,
9700 l_fed_rec.attribute9,
9701 l_fed_rec.attribute10,
9702 l_fed_rec.attribute11,
9703 l_fed_rec.attribute12,
9704 l_fed_rec.attribute13,
9705 l_fed_rec.attribute14,
9706 l_fed_rec.attribute15,
9707 l_fed_rec.attribute16,
9708 l_fed_rec.attribute17,
9709 l_fed_rec.attribute18,
9710 l_fed_rec.attribute19,
9711 l_fed_rec.attribute20,
9712 l_fed_rec.attribute21,
9713 l_fed_rec.attribute22,
9714 l_fed_rec.attribute23,
9715 l_fed_rec.attribute24,
9716 l_fed_rec.attribute25,
9717 l_fed_rec.attribute26,
9718 l_fed_rec.attribute27,
9719 l_fed_rec.attribute28,
9720 l_fed_rec.attribute29,
9721 l_fed_rec.attribute30,
9722 l_fed_rec.fed_information_category,
9723 l_fed_rec.fed_information1,
9724 l_fed_rec.fed_information2,
9725 l_fed_rec.fed_information3,
9726 l_fed_rec.fed_information4,
9727 l_fed_rec.fed_information5,
9728 l_fed_rec.fed_information6,
9729 l_fed_rec.fed_information7,
9730 l_fed_rec.fed_information8,
9731 l_fed_rec.fed_information9,
9732 l_fed_rec.fed_information10,
9733 l_fed_rec.fed_information11,
9734 l_fed_rec.fed_information12,
9735 l_fed_rec.fed_information13,
9736 l_fed_rec.fed_information14,
9737 l_fed_rec.fed_information15,
9738 l_fed_rec.fed_information16,
9739 l_fed_rec.fed_information17,
9740 l_fed_rec.fed_information18,
9741 l_fed_rec.fed_information19,
9742 l_fed_rec.fed_information20,
9743 l_fed_rec.fed_information21,
9744 l_fed_rec.fed_information22,
9745 l_fed_rec.fed_information23,
9746 l_fed_rec.fed_information24,
9747 l_fed_rec.fed_information25,
9748 l_fed_rec.fed_information26,
9749 l_fed_rec.fed_information27,
9750 l_fed_rec.fed_information28,
9751 l_fed_rec.fed_information29,
9752 l_fed_rec.fed_information30
9753 );
9754
9755 if l_eff_end_date = to_date('31/12/4712','dd/mm/yyyy') then
9756 /* Update the workers compensation for the new jurisdiction as of the
9757 p_effective_start_date */
9758 l_step := 12;
9759 maintain_wc_ele_entry (p_assignment_id => p_assignment_id,
9760 p_effective_start_date => l_eff_start_date,
9761 p_effective_end_date => l_eff_end_date,
9762 p_session_date => p_effective_start_date,
9763 p_jurisdiction_code => l_work_state_code ||'-000-0000',
9764 p_mode => 'UPDATE');
9765 else
9766 /* Update Insert the workers compensation for the new jurisdiction as of the
9767 p_effective_start_date */
9768 l_step := 13;
9769 maintain_wc_ele_entry (p_assignment_id => p_assignment_id,
9770 p_effective_start_date => l_eff_start_date ,
9771 p_effective_end_date => l_eff_end_date,
9772 p_session_date => p_effective_start_date,
9773 p_jurisdiction_code => l_work_state_code ||'-000-0000',
9774 p_mode => 'UPDATE_CHANGE_INSERT');
9775 end if;
9776
9777 elsif l_eff_start_date >= p_effective_start_date and
9778 l_eff_end_date > p_effective_end_date then
9779
9780 l_step := 14;
9781 select p_effective_end_date +1
9782 into l_new_date
9783 from DUAL;
9784
9785 open csr_get_fed_details(l_eff_start_date, l_eff_end_date);
9786 fetch csr_get_fed_details into l_fed_rec;
9787 if csr_get_fed_details%NOTFOUND then
9788 close csr_get_fed_details;
9789 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
9790 fnd_message.set_token('PROCEDURE',
9791 'pay_us_emp_dt_tax_rules.correct_wc_entry');
9792 fnd_message.set_token('STEP',to_char(l_step));
9793 fnd_message.raise_error;
9794 end if;
9795 close csr_get_fed_details;
9796
9797 /* Update the Federal tax record as of the p_effective_start_date */
9798 l_step := 15;
9799 /*
9800 insert into PAY_US_EMP_FED_TAX_RULES_F
9801 select * from pay_us_emp_fed_tax_rules_f
9802 where assignment_id = p_assignment_id
9803 and effective_start_date = l_eff_start_date
9804 and effective_end_date = l_eff_end_date;
9805 */
9806
9807 l_step := 16;
9808 update PAY_US_EMP_FED_TAX_RULES_F
9809 set effective_end_date = p_effective_end_date,
9810 sui_state_code = l_work_state_code,
9811 sui_jurisdiction_code = l_work_state_code || '-000-0000'
9812 where assignment_id = p_assignment_id
9813 and effective_start_date = l_eff_start_date
9814 and effective_end_date = l_eff_end_date
9815 and rownum < 2;
9816
9817 l_step := 17;
9818 insert into PAY_US_EMP_FED_TAX_RULES_F
9819 (emp_fed_tax_rule_id,
9820 effective_start_date,
9821 effective_end_date,
9822 assignment_id,
9823 sui_state_code,
9824 sui_jurisdiction_code,
9825 business_group_id,
9826 additional_wa_amount,
9827 filing_status_code,
9828 fit_override_amount,
9829 fit_override_rate,
9830 withholding_allowances,
9831 cumulative_taxation,
9832 eic_filing_status_code,
9833 fit_additional_tax,
9834 fit_exempt,
9835 futa_tax_exempt,
9836 medicare_tax_exempt,
9837 ss_tax_exempt,
9838 wage_exempt,
9839 statutory_employee,
9840 w2_filed_year,
9841 supp_tax_override_rate,
9842 excessive_wa_reject_date,
9843 object_version_number,
9844 attribute_category,
9845 attribute1,
9846 attribute2,
9847 attribute3,
9848 attribute4,
9849 attribute5,
9850 attribute6,
9851 attribute7,
9852 attribute8,
9853 attribute9,
9854 attribute10,
9855 attribute11,
9856 attribute12,
9857 attribute13,
9858 attribute14,
9859 attribute15,
9860 attribute16,
9861 attribute17,
9862 attribute18,
9863 attribute19,
9864 attribute20,
9865 attribute21,
9866 attribute22,
9867 attribute23,
9868 attribute24,
9869 attribute25,
9870 attribute26,
9871 attribute27,
9872 attribute28,
9873 attribute29,
9874 attribute30,
9875 fed_information_category,
9876 fed_information1,
9877 fed_information2,
9878 fed_information3,
9879 fed_information4,
9880 fed_information5,
9881 fed_information6,
9882 fed_information7,
9883 fed_information8,
9884 fed_information9,
9885 fed_information10,
9886 fed_information11,
9887 fed_information12,
9888 fed_information13,
9889 fed_information14,
9890 fed_information15,
9891 fed_information16,
9892 fed_information17,
9893 fed_information18,
9894 fed_information19,
9895 fed_information20,
9896 fed_information21,
9897 fed_information22,
9898 fed_information23,
9899 fed_information24,
9900 fed_information25,
9901 fed_information26,
9902 fed_information27,
9903 fed_information28,
9904 fed_information29,
9905 fed_information30
9906 )
9907 values
9908 (l_fed_rec.emp_fed_tax_rule_id,
9909 l_new_date,
9910 l_fed_rec.effective_end_date,
9911 l_fed_rec.assignment_id,
9912 l_fed_rec.sui_state_code,
9913 l_fed_rec.sui_jurisdiction_code,
9914 l_fed_rec.business_group_id,
9915 l_fed_rec.additional_wa_amount,
9916 lpad(l_fed_rec.filing_status_code,2,'0'),
9917 l_fed_rec.fit_override_amount,
9918 l_fed_rec.fit_override_rate,
9919 l_fed_rec.withholding_allowances,
9920 l_fed_rec.cumulative_taxation,
9921 l_fed_rec.eic_filing_status_code,
9922 l_fed_rec.fit_additional_tax,
9923 l_fed_rec.fit_exempt,
9924 l_fed_rec.futa_tax_exempt,
9925 l_fed_rec.medicare_tax_exempt,
9926 l_fed_rec.ss_tax_exempt,
9927 l_fed_rec.wage_exempt,
9928 l_fed_rec.statutory_employee,
9929 l_fed_rec.w2_filed_year,
9930 l_fed_rec.supp_tax_override_rate,
9931 l_fed_rec.excessive_wa_reject_date,
9932 0,
9933 l_fed_rec.attribute_category,
9934 l_fed_rec.attribute1,
9935 l_fed_rec.attribute2,
9936 l_fed_rec.attribute3,
9937 l_fed_rec.attribute4,
9938 l_fed_rec.attribute5,
9939 l_fed_rec.attribute6,
9940 l_fed_rec.attribute7,
9941 l_fed_rec.attribute8,
9942 l_fed_rec.attribute9,
9943 l_fed_rec.attribute10,
9944 l_fed_rec.attribute11,
9945 l_fed_rec.attribute12,
9946 l_fed_rec.attribute13,
9947 l_fed_rec.attribute14,
9948 l_fed_rec.attribute15,
9949 l_fed_rec.attribute16,
9950 l_fed_rec.attribute17,
9951 l_fed_rec.attribute18,
9952 l_fed_rec.attribute19,
9953 l_fed_rec.attribute20,
9954 l_fed_rec.attribute21,
9955 l_fed_rec.attribute22,
9956 l_fed_rec.attribute23,
9957 l_fed_rec.attribute24,
9958 l_fed_rec.attribute25,
9959 l_fed_rec.attribute26,
9960 l_fed_rec.attribute27,
9961 l_fed_rec.attribute28,
9962 l_fed_rec.attribute29,
9963 l_fed_rec.attribute30,
9964 l_fed_rec.fed_information_category,
9965 l_fed_rec.fed_information1,
9966 l_fed_rec.fed_information2,
9967 l_fed_rec.fed_information3,
9968 l_fed_rec.fed_information4,
9969 l_fed_rec.fed_information5,
9970 l_fed_rec.fed_information6,
9971 l_fed_rec.fed_information7,
9972 l_fed_rec.fed_information8,
9973 l_fed_rec.fed_information9,
9974 l_fed_rec.fed_information10,
9975 l_fed_rec.fed_information11,
9976 l_fed_rec.fed_information12,
9977 l_fed_rec.fed_information13,
9978 l_fed_rec.fed_information14,
9979 l_fed_rec.fed_information15,
9980 l_fed_rec.fed_information16,
9981 l_fed_rec.fed_information17,
9982 l_fed_rec.fed_information18,
9983 l_fed_rec.fed_information19,
9984 l_fed_rec.fed_information20,
9985 l_fed_rec.fed_information21,
9986 l_fed_rec.fed_information22,
9987 l_fed_rec.fed_information23,
9988 l_fed_rec.fed_information24,
9989 l_fed_rec.fed_information25,
9990 l_fed_rec.fed_information26,
9991 l_fed_rec.fed_information27,
9992 l_fed_rec.fed_information28,
9993 l_fed_rec.fed_information29,
9994 l_fed_rec.fed_information30
9995 );
9996
9997 l_step := 18;
9998 maintain_wc_ele_entry (p_assignment_id => p_assignment_id,
9999 p_effective_start_date => l_eff_start_date,
10000 p_effective_end_date => l_eff_end_date,
10001 p_session_date => l_eff_start_date,
10002 p_jurisdiction_code => l_work_state_code || '-000-0000',
10003 p_mode => 'CORRECTION');
10004
10005
10006 if l_eff_end_date = to_date('31/12/4712','dd/mm/yyyy') then
10007 /* Update the workers compensation for the old jurisdiction as of the
10008 l_new_date */
10009 l_step := 19;
10010 maintain_wc_ele_entry (p_assignment_id => p_assignment_id,
10011 p_effective_start_date => l_eff_start_date,
10012 p_effective_end_date => l_eff_end_date,
10013 p_session_date => l_new_date,
10014 p_jurisdiction_code => l_jurisdiction_code,
10015 p_mode => 'UPDATE');
10016 else
10017 /* Update Insert the workers compensation for the old jurisdiction as of the
10018 l_new_date */
10019 l_step := 20;
10020 maintain_wc_ele_entry (p_assignment_id => p_assignment_id,
10021 p_effective_start_date => l_eff_start_date,
10022 p_effective_end_date => l_eff_end_date,
10023 p_session_date => l_new_date,
10024 p_jurisdiction_code => l_jurisdiction_code,
10025 p_mode => 'UPDATE_CHANGE_INSERT');
10026 end if;
10027
10028 elsif l_eff_start_date < p_effective_start_date and
10029 l_eff_end_date > p_effective_end_date then
10030
10031 l_step := 21;
10032 select p_effective_end_date +1
10033 into l_new_date
10034 from DUAL;
10035
10036 open csr_get_fed_details(l_eff_start_date, l_eff_end_date);
10037 fetch csr_get_fed_details into l_fed_rec;
10038 if csr_get_fed_details%NOTFOUND then
10039 close csr_get_fed_details;
10040 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
10041 fnd_message.set_token('PROCEDURE',
10042 'pay_us_emp_dt_tax_rules.correct_wc_entry');
10043 fnd_message.set_token('STEP',to_char(l_step));
10044 fnd_message.raise_error;
10045 end if;
10046 close csr_get_fed_details;
10047
10048 /* Update the Federal tax record as of the p_effective_end_date + 1 */
10049
10050 l_step := 23;
10051 update PAY_US_EMP_FED_TAX_RULES_F
10052 set effective_end_date = p_effective_end_date
10053 where assignment_id = p_assignment_id
10054 and effective_start_date = l_eff_start_date
10055 and effective_end_date = l_eff_end_date;
10056
10057 l_step := 24;
10058 insert into PAY_US_EMP_FED_TAX_RULES_F
10059 (emp_fed_tax_rule_id,
10060 effective_start_date,
10061 effective_end_date,
10062 assignment_id,
10063 sui_state_code,
10064 sui_jurisdiction_code,
10065 business_group_id,
10066 additional_wa_amount,
10067 filing_status_code,
10068 fit_override_amount,
10069 fit_override_rate,
10070 withholding_allowances,
10071 cumulative_taxation,
10072 eic_filing_status_code,
10073 fit_additional_tax,
10074 fit_exempt,
10075 futa_tax_exempt,
10076 medicare_tax_exempt,
10077 ss_tax_exempt,
10078 wage_exempt,
10079 statutory_employee,
10080 w2_filed_year,
10081 supp_tax_override_rate,
10082 excessive_wa_reject_date,
10083 object_version_number,
10084 attribute_category,
10085 attribute1,
10086 attribute2,
10087 attribute3,
10088 attribute4,
10089 attribute5,
10090 attribute6,
10091 attribute7,
10092 attribute8,
10093 attribute9,
10094 attribute10,
10095 attribute11,
10096 attribute12,
10097 attribute13,
10098 attribute14,
10099 attribute15,
10100 attribute16,
10101 attribute17,
10102 attribute18,
10103 attribute19,
10104 attribute20,
10105 attribute21,
10106 attribute22,
10107 attribute23,
10108 attribute24,
10109 attribute25,
10110 attribute26,
10111 attribute27,
10112 attribute28,
10113 attribute29,
10114 attribute30,
10115 fed_information_category,
10116 fed_information1,
10117 fed_information2,
10118 fed_information3,
10119 fed_information4,
10120 fed_information5,
10121 fed_information6,
10122 fed_information7,
10123 fed_information8,
10124 fed_information9,
10125 fed_information10,
10126 fed_information11,
10127 fed_information12,
10128 fed_information13,
10129 fed_information14,
10130 fed_information15,
10131 fed_information16,
10132 fed_information17,
10133 fed_information18,
10134 fed_information19,
10135 fed_information20,
10136 fed_information21,
10137 fed_information22,
10138 fed_information23,
10139 fed_information24,
10140 fed_information25,
10141 fed_information26,
10142 fed_information27,
10143 fed_information28,
10144 fed_information29,
10145 fed_information30 )
10146 values
10147 (l_fed_rec.emp_fed_tax_rule_id,
10148 l_new_date,
10149 l_fed_rec.effective_end_date,
10150 l_fed_rec.assignment_id,
10151 l_fed_rec.sui_state_code,
10152 l_fed_rec.sui_jurisdiction_code,
10153 l_fed_rec.business_group_id,
10154 l_fed_rec.additional_wa_amount,
10155 lpad(l_fed_rec.filing_status_code,2,'0'),
10156 l_fed_rec.fit_override_amount,
10157 l_fed_rec.fit_override_rate,
10158 l_fed_rec.withholding_allowances,
10159 l_fed_rec.cumulative_taxation,
10160 l_fed_rec.eic_filing_status_code,
10161 l_fed_rec.fit_additional_tax,
10162 l_fed_rec.fit_exempt,
10163 l_fed_rec.futa_tax_exempt,
10164 l_fed_rec.medicare_tax_exempt,
10165 l_fed_rec.ss_tax_exempt,
10166 l_fed_rec.wage_exempt,
10167 l_fed_rec.statutory_employee,
10168 l_fed_rec.w2_filed_year,
10169 l_fed_rec.supp_tax_override_rate,
10170 l_fed_rec.excessive_wa_reject_date,
10171 0,
10172 l_fed_rec.attribute_category,
10173 l_fed_rec.attribute1,
10174 l_fed_rec.attribute2,
10175 l_fed_rec.attribute3,
10176 l_fed_rec.attribute4,
10177 l_fed_rec.attribute5,
10178 l_fed_rec.attribute6,
10179 l_fed_rec.attribute7,
10180 l_fed_rec.attribute8,
10181 l_fed_rec.attribute9,
10182 l_fed_rec.attribute10,
10183 l_fed_rec.attribute11,
10184 l_fed_rec.attribute12,
10185 l_fed_rec.attribute13,
10186 l_fed_rec.attribute14,
10187 l_fed_rec.attribute15,
10188 l_fed_rec.attribute16,
10189 l_fed_rec.attribute17,
10190 l_fed_rec.attribute18,
10191 l_fed_rec.attribute19,
10192 l_fed_rec.attribute20,
10193 l_fed_rec.attribute21,
10194 l_fed_rec.attribute22,
10195 l_fed_rec.attribute23,
10196 l_fed_rec.attribute24,
10197 l_fed_rec.attribute25,
10198 l_fed_rec.attribute26,
10199 l_fed_rec.attribute27,
10200 l_fed_rec.attribute28,
10201 l_fed_rec.attribute29,
10202 l_fed_rec.attribute30,
10203 l_fed_rec.fed_information_category,
10204 l_fed_rec.fed_information1,
10205 l_fed_rec.fed_information2,
10206 l_fed_rec.fed_information3,
10207 l_fed_rec.fed_information4,
10208 l_fed_rec.fed_information5,
10209 l_fed_rec.fed_information6,
10210 l_fed_rec.fed_information7,
10211 l_fed_rec.fed_information8,
10212 l_fed_rec.fed_information9,
10213 l_fed_rec.fed_information10,
10214 l_fed_rec.fed_information11,
10215 l_fed_rec.fed_information12,
10216 l_fed_rec.fed_information13,
10217 l_fed_rec.fed_information14,
10218 l_fed_rec.fed_information15,
10219 l_fed_rec.fed_information16,
10220 l_fed_rec.fed_information17,
10221 l_fed_rec.fed_information18,
10222 l_fed_rec.fed_information19,
10223 l_fed_rec.fed_information20,
10224 l_fed_rec.fed_information21,
10225 l_fed_rec.fed_information22,
10226 l_fed_rec.fed_information23,
10227 l_fed_rec.fed_information24,
10228 l_fed_rec.fed_information25,
10229 l_fed_rec.fed_information26,
10230 l_fed_rec.fed_information27,
10231 l_fed_rec.fed_information28,
10232 l_fed_rec.fed_information29,
10233 l_fed_rec.fed_information30
10234 );
10235
10236 if l_eff_end_date = to_date('31/12/4712','dd/mm/yyyy') then
10237 /* Update the workers compensation for the old jurisdiction as of the
10238 l_new_date */
10239
10240 l_step := 26;
10241 maintain_wc_ele_entry (p_assignment_id => p_assignment_id,
10242 p_effective_start_date => l_eff_start_date,
10243 p_effective_end_date => l_eff_end_date,
10244 p_session_date => l_new_date,
10245 p_jurisdiction_code => l_jurisdiction_code,
10246 p_mode => 'UPDATE');
10247 else
10248 /* Update Insert the workers compensation for the old jurisdiction as of the
10249 l_new_date */
10250 l_step := 27;
10251 maintain_wc_ele_entry (p_assignment_id => p_assignment_id,
10252 p_effective_start_date => l_eff_start_date,
10253 p_effective_end_date => l_eff_end_date,
10254 p_session_date => l_new_date,
10255 p_jurisdiction_code => l_jurisdiction_code,
10256 p_mode => 'UPDATE_CHANGE_INSERT');
10257 end if;
10258
10259
10260 l_step := 28;
10261 select p_effective_start_date -1
10262 into l_new_date
10263 from DUAL;
10264
10265 /* We do not ned to get the federal record again since we haev already got
10266 it above.
10267
10268 open csr_get_fed_details(l_eff_start_date, p_effective_end_date);
10269 fetch csr_get_fed_details into l_fed_rec;
10270 if csr_get_fed_details%NOTFOUND then
10271 close csr_get_fed_details;
10272 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
10273 fnd_message.set_token('PROCEDURE',
10274 'pay_us_emp_dt_tax_rules.correct_wc_entry');
10275 fnd_message.set_token('STEP',to_char(l_step));
10276 fnd_message.raise_error;
10277 end if;
10278 close csr_get_fed_details;
10279 */
10280
10281 /* Update the Federal tax record as of the p_effective_start_date */
10282
10283 l_step := 30;
10284 update PAY_US_EMP_FED_TAX_RULES_F
10285 set effective_end_date = l_new_date
10286 where assignment_id = p_assignment_id
10287 and effective_start_date = l_eff_start_date
10288 and effective_end_date = p_effective_end_date;
10289
10290 l_step := 31;
10291 insert into PAY_US_EMP_FED_TAX_RULES_F
10292 (emp_fed_tax_rule_id,
10293 effective_start_date,
10294 effective_end_date,
10295 assignment_id,
10296 sui_state_code,
10297 sui_jurisdiction_code,
10298 business_group_id,
10299 additional_wa_amount,
10300 filing_status_code,
10301 fit_override_amount,
10302 fit_override_rate,
10303 withholding_allowances,
10304 cumulative_taxation,
10305 eic_filing_status_code,
10306 fit_additional_tax,
10307 fit_exempt,
10308 futa_tax_exempt,
10309 medicare_tax_exempt,
10310 ss_tax_exempt,
10311 wage_exempt,
10312 statutory_employee,
10313 w2_filed_year,
10314 supp_tax_override_rate,
10315 excessive_wa_reject_date,
10316 object_version_number,
10317 attribute_category,
10318 attribute1,
10319 attribute2,
10320 attribute3,
10321 attribute4,
10322 attribute5,
10323 attribute6,
10324 attribute7,
10325 attribute8,
10326 attribute9,
10327 attribute10,
10328 attribute11,
10329 attribute12,
10330 attribute13,
10331 attribute14,
10332 attribute15,
10333 attribute16,
10334 attribute17,
10335 attribute18,
10336 attribute19,
10337 attribute20,
10338 attribute21,
10339 attribute22,
10340 attribute23,
10341 attribute24,
10342 attribute25,
10343 attribute26,
10344 attribute27,
10345 attribute28,
10346 attribute29,
10347 attribute30,
10348 fed_information_category,
10349 fed_information1,
10350 fed_information2,
10351 fed_information3,
10352 fed_information4,
10353 fed_information5,
10354 fed_information6,
10355 fed_information7,
10356 fed_information8,
10357 fed_information9,
10358 fed_information10,
10359 fed_information11,
10360 fed_information12,
10361 fed_information13,
10362 fed_information14,
10363 fed_information15,
10364 fed_information16,
10365 fed_information17,
10366 fed_information18,
10367 fed_information19,
10368 fed_information20,
10369 fed_information21,
10370 fed_information22,
10371 fed_information23,
10372 fed_information24,
10373 fed_information25,
10374 fed_information26,
10375 fed_information27,
10376 fed_information28,
10377 fed_information29,
10378 fed_information30 )
10379 values
10380 (l_fed_rec.emp_fed_tax_rule_id,
10381 p_effective_start_date,
10382 p_effective_end_date,
10383 l_fed_rec.assignment_id,
10384 l_work_state_code,
10385 l_work_state_code || '-000-0000',
10386 l_fed_rec.business_group_id,
10387 l_fed_rec.additional_wa_amount,
10388 lpad(l_fed_rec.filing_status_code,2,'0'),
10389 l_fed_rec.fit_override_amount,
10390 l_fed_rec.fit_override_rate,
10391 l_fed_rec.withholding_allowances,
10392 l_fed_rec.cumulative_taxation,
10393 l_fed_rec.eic_filing_status_code,
10394 l_fed_rec.fit_additional_tax,
10395 l_fed_rec.fit_exempt,
10396 l_fed_rec.futa_tax_exempt,
10397 l_fed_rec.medicare_tax_exempt,
10398 l_fed_rec.ss_tax_exempt,
10399 l_fed_rec.wage_exempt,
10400 l_fed_rec.statutory_employee,
10401 l_fed_rec.w2_filed_year,
10402 l_fed_rec.supp_tax_override_rate,
10403 l_fed_rec.excessive_wa_reject_date,
10404 0,
10405 l_fed_rec.attribute_category,
10406 l_fed_rec.attribute1,
10407 l_fed_rec.attribute2,
10408 l_fed_rec.attribute3,
10409 l_fed_rec.attribute4,
10410 l_fed_rec.attribute5,
10411 l_fed_rec.attribute6,
10412 l_fed_rec.attribute7,
10413 l_fed_rec.attribute8,
10414 l_fed_rec.attribute9,
10415 l_fed_rec.attribute10,
10416 l_fed_rec.attribute11,
10417 l_fed_rec.attribute12,
10418 l_fed_rec.attribute13,
10419 l_fed_rec.attribute14,
10420 l_fed_rec.attribute15,
10421 l_fed_rec.attribute16,
10422 l_fed_rec.attribute17,
10423 l_fed_rec.attribute18,
10424 l_fed_rec.attribute19,
10425 l_fed_rec.attribute20,
10426 l_fed_rec.attribute21,
10427 l_fed_rec.attribute22,
10428 l_fed_rec.attribute23,
10429 l_fed_rec.attribute24,
10430 l_fed_rec.attribute25,
10431 l_fed_rec.attribute26,
10432 l_fed_rec.attribute27,
10433 l_fed_rec.attribute28,
10434 l_fed_rec.attribute29,
10435 l_fed_rec.attribute30,
10436 l_fed_rec.fed_information_category,
10437 l_fed_rec.fed_information1,
10438 l_fed_rec.fed_information2,
10439 l_fed_rec.fed_information3,
10440 l_fed_rec.fed_information4,
10441 l_fed_rec.fed_information5,
10442 l_fed_rec.fed_information6,
10443 l_fed_rec.fed_information7,
10444 l_fed_rec.fed_information8,
10445 l_fed_rec.fed_information9,
10446 l_fed_rec.fed_information10,
10447 l_fed_rec.fed_information11,
10448 l_fed_rec.fed_information12,
10449 l_fed_rec.fed_information13,
10450 l_fed_rec.fed_information14,
10451 l_fed_rec.fed_information15,
10452 l_fed_rec.fed_information16,
10453 l_fed_rec.fed_information17,
10454 l_fed_rec.fed_information18,
10455 l_fed_rec.fed_information19,
10456 l_fed_rec.fed_information20,
10457 l_fed_rec.fed_information21,
10458 l_fed_rec.fed_information22,
10459 l_fed_rec.fed_information23,
10460 l_fed_rec.fed_information24,
10461 l_fed_rec.fed_information25,
10462 l_fed_rec.fed_information26,
10463 l_fed_rec.fed_information27,
10464 l_fed_rec.fed_information28,
10465 l_fed_rec.fed_information29,
10466 l_fed_rec.fed_information30
10467 );
10468
10469
10470 /* Update Insert the workers compensation for the new jurisdiction as of the
10471 p_effective_start_date */
10472 l_step := 32;
10473 maintain_wc_ele_entry (p_assignment_id => p_assignment_id,
10474 p_effective_start_date => l_eff_start_date,
10475 p_effective_end_date => p_effective_end_date,
10476 p_session_date => p_effective_start_date,
10477 p_jurisdiction_code => l_work_state_code ||'-000-0000',
10478 p_mode => 'UPDATE_CHANGE_INSERT');
10479
10480 end if;
10481 end loop;
10482 close csr_get_fed_rows;
10483
10484 exception
10485 when others then
10486 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
10487 fnd_message.set_token('PROCEDURE',
10488 'pay_us_emp_dt_tax_rules.correct_wc_entry');
10489 fnd_message.set_token('STEP',to_char(l_step));
10490 fnd_message.raise_error;
10491 end correct_wc_entry;
10492
10493
10494 procedure change_wc_entry (p_assignment_id in number,
10495 p_effective_start_date in date,
10496 p_effective_end_date in date,
10497 p_session_date in date,
10498 p_new_location_id in number,
10499 p_mode in varchar2,
10500 p_ret_code in out nocopy number,
10501 p_ret_text in out nocopy varchar2) is
10502 l_validation_start_date date;
10503 l_validation_end_date date;
10504 l_end_of_time date := to_date('31/12/4712','dd/mm/yyyy');
10505 l_ret_code number := 0;
10506 l_ret_text varchar2(2000);
10507
10508 begin
10509
10510 if p_mode = 'CORRECTION' then
10511 l_validation_start_date := p_effective_start_date;
10512 l_validation_end_date := p_effective_end_date;
10513 elsif p_mode = 'UPDATE' then
10514 l_validation_start_date := p_session_date;
10515 l_validation_end_date := l_end_of_time;
10516 elsif p_mode = 'UPDATE_CHANGE_INSERT' then
10517 l_validation_start_date := p_session_date;
10518 l_validation_end_date := p_effective_end_date;
10519 elsif p_mode = 'UPDATE_OVERRIDE' then
10520 l_validation_start_date := p_session_date;
10521 l_validation_end_date := l_end_of_time;
10522 end if;
10523
10524 hr_utility.set_location('pay_us_emp_dt_tax_rules.change_wc_entry',1);
10525 correct_wc_entry (p_assignment_id => p_assignment_id,
10526 p_effective_start_date => l_validation_start_date,
10527 p_effective_end_date => l_validation_end_date,
10528 p_session_date => p_session_date,
10529 p_new_location_id => p_new_location_id,
10530 p_ret_code => l_ret_code,
10531 p_ret_text => l_ret_text);
10532 hr_utility.set_location('pay_us_emp_dt_tax_rules.change_wc_entry',2);
10533
10534 end change_wc_entry;
10535
10536 procedure pull_tax_records( p_assignment_id in number,
10537 p_new_start_date in date,
10538 p_default_date in date) is
10539 l_ef_date DATE;
10540 l_proc VARCHAR2(50) := 'pay_us_emp_dt_tax_rules.pull_tax_records';
10541
10542 begin
10543 hr_utility.set_location('Entering: ' || l_proc, 5);
10544 /* dscully - modified to handle case where tax record changes
10545 have occured between old hire date and new hire date */
10546
10547 if p_new_start_date < p_default_date then
10548 l_ef_date := p_default_date;
10549 elsif p_new_start_date > p_default_date then
10550 l_ef_date := p_new_start_date;
10551 else -- do nothing
10552 return;
10553 end if;
10554
10555 /* First update the tax rules records */
10556
10557 update PAY_US_EMP_FED_TAX_RULES_F
10558 set effective_start_date = p_new_start_date
10559 where assignment_id = p_assignment_id
10560 and l_ef_date between effective_start_date and effective_end_date;
10561
10562 if sql%notfound then
10563 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
10564 fnd_message.set_token('PROCEDURE',l_proc);
10565 fnd_message.set_token('STEP','2');
10566 fnd_message.raise_error;
10567 end if;
10568
10569 update PAY_US_EMP_STATE_TAX_RULES_F
10570 set effective_start_date = p_new_start_date
10571 where assignment_id = p_assignment_id
10572 and l_ef_date between effective_start_date and effective_end_date;
10573
10574 if sql%notfound then
10575 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
10576 fnd_message.set_token('PROCEDURE',l_proc);
10577 fnd_message.set_token('STEP','3');
10578 fnd_message.raise_error;
10579 end if;
10580
10581 update PAY_US_EMP_COUNTY_TAX_RULES_F
10582 set effective_start_date = p_new_start_date
10583 where assignment_id = p_assignment_id
10584 and l_ef_date between effective_start_date and effective_end_date;
10585
10586 if sql%notfound then
10587 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
10588 fnd_message.set_token('PROCEDURE',l_proc);
10589 fnd_message.set_token('STEP','4');
10590 fnd_message.raise_error;
10591 end if;
10592
10593 update PAY_US_EMP_CITY_TAX_RULES_F
10594 set effective_start_date = p_new_start_date
10595 where assignment_id = p_assignment_id
10596 and l_ef_date between effective_start_date and effective_end_date;
10597
10598 if sql%notfound then
10599 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
10600 fnd_message.set_token('PROCEDURE',l_proc);
10601 fnd_message.set_token('STEP','5');
10602 fnd_message.raise_error;
10603 end if;
10604
10605 /* Next delete any orphaned rows */
10606 if p_new_start_date > p_default_date then
10607 hr_utility.set_location(l_proc, 10);
10608 delete PAY_US_EMP_FED_TAX_RULES_F
10609 where assignment_id = p_assignment_id
10610 and p_new_start_date > effective_start_date;
10611
10612 delete PAY_US_EMP_STATE_TAX_RULES_F
10613 where assignment_id = p_assignment_id
10614 and p_new_start_date > effective_start_date;
10615
10616 delete PAY_US_EMP_COUNTY_TAX_RULES_F
10617 where assignment_id = p_assignment_id
10618 and p_new_start_date > effective_start_date;
10619
10620 delete PAY_US_EMP_CITY_TAX_RULES_F
10621 where assignment_id = p_assignment_id
10622 and p_new_start_date > effective_start_date;
10623
10624 end if;
10625
10626 hr_utility.set_location('Leaving: ' || l_proc, 20);
10627
10628 end pull_tax_records;
10629
10630 procedure check_hiring_date( p_assignment_id in number,
10631 p_default_date in date,
10632 p_s_start_date in date) is
10633
10634
10635 l_payroll_installed boolean := FALSE;
10636
10637 begin
10638
10639 /* If the hiring date has been changed and pulled back, for the
10640 assignment then pull back the start date of all of the tax
10641 rules records, workers compensation and the vertex element
10642 entries */
10643
10644
10645 /* Rmonge 27-jul-2001 */
10646 /* Added an verification for tax records maintenance and payroll */
10647 /* installation. This is to make sure that */
10648 /* the HR only customers do not run into an error when this code is */
10649
10650
10651 l_payroll_installed :=
10652 hr_utility.chk_product_install(p_product =>'Oracle Payroll',
10653 p_legislation => 'US');
10654
10655
10656
10657 if hr_general.chk_maintain_tax_records = 'Y' then
10658
10659 if p_s_start_date < p_default_date then
10660
10661 pull_tax_records(p_assignment_id => p_assignment_id,
10662 p_new_start_date => p_s_start_date,
10663 p_default_date => p_default_date);
10664
10665
10666 if l_payroll_installed then
10667
10668
10669 /* Now time to update the workers comp element entry */
10670
10671 del_updt_wc_entry_for_dates (p_assignment_id => p_assignment_id,
10672 p_session_date => p_default_date,
10673 p_new_start_date => p_s_start_date,
10674 p_new_end_date => null,
10675 p_mode => 'U');
10676
10677
10678 /* Finally update the vertex element entries and close the
10679 chapter */
10680
10681 upd_del_entries(p_assignment_id => p_assignment_id,
10682 p_session_date => p_default_date,
10683 p_new_start_date => p_s_start_date,
10684 p_new_end_date => null,
10685 p_mode => 'U');
10686
10687 /* If the hiring date has been pulled forward then the person api
10688 pulls forward the element entries but does not pull forward the
10689 tax rules record. So, we will pull them forward */
10690
10691 end if; /* payroll installed */
10692
10693 elsif p_s_start_date > p_default_date then
10694
10695 pull_tax_records(p_assignment_id => p_assignment_id,
10696 p_new_start_date => p_s_start_date,
10697 p_default_date => p_default_date);
10698
10699 end if; /* start date */
10700
10701 end if; /* check maintain tax records */
10702
10703 end check_hiring_date;
10704
10705 procedure default_tax ( p_assignment_id in number,
10706 p_effective_start_date in date,
10707 p_effective_end_date in date,
10708 p_business_group_id in number,
10709 p_ret_code in number,
10710 p_ret_text in varchar2) is
10711
10712 l_res_state_code varchar2(2);
10713 l_res_county_code varchar2(3);
10714 l_res_city_code varchar2(4);
10715 l_add_state_code varchar2(2);
10716 l_add_county_code varchar2(3);
10717 l_add_city_code varchar2(4);
10718 l_work_state_code varchar2(2);
10719 l_work_county_code varchar2(3);
10720 l_work_city_code varchar2(4);
10721 l_work1_state_code varchar2(2);
10722 l_work1_county_code varchar2(3);
10723 l_work1_city_code varchar2(4);
10724 l_work2_state_code varchar2(2);
10725 l_work2_county_code varchar2(3);
10726 l_work2_city_code varchar2(4);
10727 l_work3_state_code varchar2(2);
10728 l_work3_county_code varchar2(3);
10729 l_work3_city_code varchar2(4);
10730 l_sui_state_code varchar2(2);
10731 l_loc_city varchar2(11);
10732 l_fed_tax_rule_id number;
10733 l_state_tax_rule_id number;
10734 l_county_tax_rule_id number;
10735 l_city_tax_rule_id number;
10736 l_work_state_name varchar2(35) := null;
10737 l_work_county_name varchar2(35) := null;
10738 l_work_city_name varchar2(35) := null;
10739 l_work1_state_name varchar2(35) := null;
10740 l_work1_county_name varchar2(35) := null;
10741 l_work1_city_name varchar2(35) := null;
10742 l_work2_state_name varchar2(35) := null;
10743 l_work2_county_name varchar2(35) := null;
10744 l_work2_city_name varchar2(35) := null;
10745 l_work3_state_name varchar2(35) := null;
10746 l_work3_county_name varchar2(35) := null;
10747 l_work3_city_name varchar2(35) := null;
10748 l_res_state_name varchar2(35) := null;
10749 l_res_county_name varchar2(35) := null;
10750 l_res_city_name varchar2(35) := null;
10751 l_percent number;
10752
10753 cursor csr_chk_addr_ovrd is
10754 select pus.state_code,
10755 puc.county_code,
10756 pcn.city_code
10757 from pay_us_city_names pcn,
10758 pay_us_counties puc,
10759 pay_us_states pus,
10760 per_addresses pa,
10761 per_assignments_f paf
10762 where paf.assignment_id = p_assignment_id
10763 and p_effective_start_date between paf.effective_start_date and
10764 paf.effective_end_date
10765 and pa.person_id = paf.person_id
10766 and pa.primary_flag = 'Y'
10767 and p_effective_start_date between pa.date_from and
10768 nvl(pa.date_to,to_date('12/31/4712','MM/DD/YYYY'))
10769 and pa.add_information17 is not null
10770 and pa.add_information19 is not null
10771 and pa.add_information18 is not null
10772 and pa.add_information17 = pus.state_abbrev
10773 and puc.state_code = pus.state_code
10774 and puc.county_name = pa.add_information19
10775 and pcn.state_code = puc.state_code
10776 and pcn.county_code = puc.county_code
10777 and pcn.city_name = add_information18;
10778
10779 begin
10780
10781 /* Get the resident and the work state, county and city codes */
10782
10783 hr_utility.set_location('pay_us_emp_dt_tax_rules.default_tax',1);
10784 pay_us_emp_dt_tax_val.get_orig_res_codes (p_assignment_id => p_assignment_id,
10785
10786 p_session_date => p_effective_start_date,
10787 p_res_state_code => l_res_state_code,
10788 p_res_county_code => l_res_county_code,
10789 p_res_city_code => l_res_city_code,
10790 p_res_state_name => l_res_state_name,
10791 p_res_county_name => l_res_county_name,
10792 p_res_city_name => l_res_city_name);
10793
10794 hr_utility.set_location('pay_us_emp_dt_tax_rules.default_tax',2);
10795 if l_res_state_code is null then
10796 fnd_message.set_name('PER', 'PER_52985_ADD_NO_STATE_SET');
10797 fnd_message.raise_error;
10798 end if;
10799
10800 if l_res_county_code is null then
10801 fnd_message.set_name('PER', 'PER_52984_ADD_NO_COUNTY_SET');
10802 fnd_message.raise_error;
10803 end if;
10804
10805 if l_res_city_code is null then
10806 fnd_message.set_name('PER', 'PER_52986_ADD_NO_CITY_SET');
10807 fnd_message.raise_error;
10808 end if;
10809
10810 /* Check to see if the address has an override or not . If there is
10811 an override for the address then get the non override address for
10812 the assignment and assign it to the additional state, county
10813 and city codes */
10814
10815 hr_utility.set_location('pay_us_emp_dt_tax_rules.default_tax',3);
10816 open csr_chk_addr_ovrd;
10817 fetch csr_chk_addr_ovrd into l_add_state_code,
10818 l_add_county_code,
10819 l_add_city_code;
10820 if csr_chk_addr_ovrd%NOTFOUND then
10821 l_add_state_code := null;
10822 l_add_county_code := null;
10823 l_add_city_code := null;
10824 end if;
10825 close csr_chk_addr_ovrd;
10826
10827 hr_utility.set_location('pay_us_emp_dt_tax_rules.default_tax',4);
10828 pay_us_emp_dt_tax_val.get_all_work_codes (p_assignment_id => p_assignment_id,
10829 p_session_date => p_effective_start_date,
10830 p_work_state_code => l_work_state_code,
10831 p_work_county_code => l_work_county_code,
10832 p_work_city_code => l_work_city_code,
10833 p_work_state_name => l_work_state_name,
10834 p_work_county_name => l_work_county_name,
10835 p_work_city_name => l_work_city_name,
10836 p_work1_state_code => l_work1_state_code,
10837 p_work1_county_code => l_work1_county_code,
10838 p_work1_city_code => l_work1_city_code,
10839 p_work1_state_name => l_work1_state_name,
10840 p_work1_county_name => l_work1_county_name,
10841 p_work1_city_name => l_work1_city_name,
10842 p_work2_state_code => l_work2_state_code,
10843 p_work2_county_code => l_work2_county_code,
10844 p_work2_city_code => l_work2_city_code,
10845 p_work2_state_name => l_work2_state_name,
10846 p_work2_county_name => l_work2_county_name,
10847 p_work2_city_name => l_work2_city_name,
10848 p_work3_state_code => l_work3_state_code,
10849 p_work3_county_code => l_work3_county_code,
10850 p_work3_city_code => l_work3_city_code,
10851 p_work3_state_name => l_work3_state_name,
10852 p_work3_county_name => l_work3_county_name,
10853 p_work3_city_name => l_work3_city_name,
10854 p_sui_state_code => l_sui_state_code,
10855 p_loc_city => l_loc_city
10856 );
10857
10858 if l_work_state_code is null or l_work_county_code is null
10859 or l_work_city_code is null then
10860 fnd_message.set_name('PAY', 'PY_51133_TXADJ_INVALID_CITY');
10861 fnd_message.raise_error;
10862 end if;
10863
10864 /* Insert the default Federal tax Record */
10865
10866 l_fed_tax_rule_id :=
10867 insert_def_fed_rec(p_assignment_id => p_assignment_id,
10868 p_effective_start_date => p_effective_start_date,
10869 p_effective_end_date => p_effective_end_date,
10870 p_sui_state_code => l_sui_state_code,
10871 p_business_group_id => p_business_group_id);
10872 /* Insert the default State tax record */
10873 /* Create state record for works and if needed resident state rec also */
10874 l_state_tax_rule_id :=
10875 insert_def_state_rec(p_assignment_id => p_assignment_id,
10876 p_effective_start_date => p_effective_start_date,
10877 p_effective_end_date => p_effective_end_date,
10878 p_state_code => l_work_state_code,
10879 p_business_group_id => p_business_group_id,
10880 p_percent_time => 0);
10881 if l_work1_state_code is not null then
10882 l_state_tax_rule_id :=
10883 insert_def_state_rec(p_assignment_id => p_assignment_id,
10884 p_effective_start_date => p_effective_start_date,
10885 p_effective_end_date => p_effective_end_date,
10886 p_state_code => l_work1_state_code,
10887 p_business_group_id => p_business_group_id,
10888 p_percent_time => 0);
10889 end if;
10890 if l_work2_state_code is not null then
10891 l_state_tax_rule_id :=
10892 insert_def_state_rec(p_assignment_id => p_assignment_id,
10893 p_effective_start_date => p_effective_start_date,
10894 p_effective_end_date => p_effective_end_date,
10895 p_state_code => l_work2_state_code,
10896 p_business_group_id => p_business_group_id,
10897 p_percent_time => 0);
10898 end if;
10899 if l_work3_state_code is not null then
10900 l_state_tax_rule_id :=
10901 insert_def_state_rec(p_assignment_id => p_assignment_id,
10902 p_effective_start_date => p_effective_start_date,
10903 p_effective_end_date => p_effective_end_date,
10904 p_state_code => l_work3_state_code,
10905 p_business_group_id => p_business_group_id,
10906 p_percent_time => 0);
10907 end if;
10908 if nvl(l_work_state_code,l_res_state_code) <> l_res_state_code
10909 or nvl(l_work1_state_code,l_res_state_code) <> l_res_state_code
10910 or nvl(l_work2_state_code, l_res_state_code) <> l_res_state_code
10911 or nvl(l_work3_state_code, l_res_state_code) <> l_res_state_code then
10912 l_state_tax_rule_id :=
10913 insert_def_state_rec(p_assignment_id => p_assignment_id,
10914 p_effective_start_date => p_effective_start_date,
10915 p_effective_end_date => p_effective_end_date,
10916 p_state_code => l_res_state_code,
10917 p_business_group_id => p_business_group_id,
10918 p_percent_time => 0);
10919
10920 end if;
10921
10922 /* Now check for the override state */
10923 if l_add_state_code is not null
10924 and l_res_state_code <> l_add_state_code then
10925 l_state_tax_rule_id :=
10926 insert_def_state_rec(p_assignment_id => p_assignment_id,
10927 p_effective_start_date => p_effective_start_date,
10928 p_effective_end_date => p_effective_end_date,
10929 p_state_code => l_add_state_code,
10930 p_business_group_id => p_business_group_id,
10931 p_percent_time => 0);
10932
10933 end if;
10934 /* Insert the default county tax record */
10935 l_county_tax_rule_id :=
10936 insert_def_county_rec(p_assignment_id => p_assignment_id,
10937 p_effective_start_date => p_effective_start_date,
10938 p_effective_end_date => p_effective_end_date,
10939 p_state_code => l_work_state_code,
10940 p_county_code => l_work_county_code,
10941 p_business_group_id => p_business_group_id,
10942 p_percent_time => 0);
10943 if l_work1_county_code is not null then
10944 l_county_tax_rule_id :=
10945 insert_def_county_rec(p_assignment_id => p_assignment_id,
10946 p_effective_start_date => p_effective_start_date,
10947 p_effective_end_date => p_effective_end_date,
10948 p_state_code => l_work1_state_code,
10949 p_county_code => l_work1_county_code,
10950 p_business_group_id => p_business_group_id,
10951 p_percent_time => 0);
10952 end if;
10953 if l_work2_county_code is not null then
10954 l_county_tax_rule_id :=
10955 insert_def_county_rec(p_assignment_id => p_assignment_id,
10956 p_effective_start_date => p_effective_start_date,
10957 p_effective_end_date => p_effective_end_date,
10958 p_state_code => l_work2_state_code,
10959 p_county_code => l_work2_county_code,
10960 p_business_group_id => p_business_group_id,
10961 p_percent_time => 0);
10962 end if;
10963 if l_work3_county_code is not null then
10964 l_county_tax_rule_id :=
10965 insert_def_county_rec(p_assignment_id => p_assignment_id,
10966 p_effective_start_date => p_effective_start_date,
10967 p_effective_end_date => p_effective_end_date,
10968 p_state_code => l_work3_state_code,
10969 p_county_code => l_work3_county_code,
10970 p_business_group_id => p_business_group_id,
10971 p_percent_time => 0);
10972 end if;
10973 if (l_work_state_code <> l_res_state_code or
10974 l_work_county_code <> l_res_county_code) then
10975 l_county_tax_rule_id :=
10976
10977 insert_def_county_rec(p_assignment_id => p_assignment_id,
10978 p_effective_start_date => p_effective_start_date,
10979 p_effective_end_date => p_effective_end_date,
10980 p_state_code => l_res_state_code,
10981 p_county_code => l_res_county_code,
10982 p_business_group_id => p_business_group_id,
10983 p_percent_time => 0);
10984 end if;
10985 /* Check for the override county */
10986 if l_add_county_code is not null then
10987 l_county_tax_rule_id :=
10988
10989 insert_def_county_rec(p_assignment_id => p_assignment_id,
10990 p_effective_start_date => p_effective_start_date,
10991 p_effective_end_date => p_effective_end_date,
10992 p_state_code => l_add_state_code,
10993 p_county_code => l_add_county_code,
10994 p_business_group_id => p_business_group_id,
10995 p_percent_time => 0);
10996 end if;
10997
10998 /* Insert the default city tax record */
10999 if l_loc_city = l_work_state_code ||'-'||l_work_county_code ||'-'||l_work_city_code
11000 then
11001 l_percent := 100;
11002 else
11003 l_percent := 0;
11004 end if;
11005
11006 l_city_tax_rule_id :=
11007 insert_def_city_rec(p_assignment_id => p_assignment_id,
11008 p_effective_start_date => p_effective_start_date,
11009 p_effective_end_date => p_effective_end_date,
11010 p_state_code => l_work_state_code,
11011 p_county_code => l_work_county_code,
11012 p_city_code => l_work_city_code,
11013 p_business_group_id => p_business_group_id,
11014 p_percent_time => l_percent);
11015
11016 if l_work1_city_code is not null then
11017 if l_loc_city = l_work1_state_code ||'-'||l_work1_county_code ||'-'||l_work1_city_code
11018 then
11019 l_percent := 100;
11020 else
11021 l_percent := 0;
11022 end if;
11023
11024 l_city_tax_rule_id :=
11025 insert_def_city_rec(p_assignment_id => p_assignment_id,
11026 p_effective_start_date => p_effective_start_date,
11027 p_effective_end_date => p_effective_end_date,
11028 p_state_code => l_work1_state_code,
11029 p_county_code => l_work1_county_code,
11030 p_city_code => l_work1_city_code,
11031 p_business_group_id => p_business_group_id,
11032 p_percent_time => l_percent);
11033 end if;
11034
11035 if l_work2_city_code is not null then
11036 if l_loc_city = l_work2_state_code ||'-'||l_work2_county_code ||'-'||l_work2_city_code
11037 then
11038 l_percent := 100;
11039 else
11040 l_percent := 0;
11041 end if;
11042
11043 l_city_tax_rule_id :=
11044 insert_def_city_rec(p_assignment_id => p_assignment_id,
11045 p_effective_start_date => p_effective_start_date,
11046 p_effective_end_date => p_effective_end_date,
11047 p_state_code => l_work2_state_code,
11048 p_county_code => l_work2_county_code,
11049 p_city_code => l_work2_city_code,
11050 p_business_group_id => p_business_group_id,
11051 p_percent_time => l_percent);
11052 end if;
11053
11054 if l_work3_city_code is not null then
11055 if l_loc_city = l_work3_state_code ||'-'||l_work3_county_code ||'-'||l_work3_city_code
11056 then
11057 l_percent := 100;
11058 else
11059 l_percent := 0;
11060 end if;
11061
11062 l_city_tax_rule_id :=
11063 insert_def_city_rec(p_assignment_id => p_assignment_id,
11064 p_effective_start_date => p_effective_start_date,
11065 p_effective_end_date => p_effective_end_date,
11066 p_state_code => l_work3_state_code,
11067 p_county_code => l_work3_county_code,
11068 p_city_code => l_work3_city_code,
11069 p_business_group_id => p_business_group_id,
11070 p_percent_time => l_percent);
11071 end if;
11072
11073 if (l_work_state_code <> l_res_state_code or
11074 l_work_county_code <> l_res_county_code or
11075 l_work_city_code <> l_res_city_code) then
11076 l_city_tax_rule_id :=
11077 insert_def_city_rec(p_assignment_id => p_assignment_id,
11078 p_effective_start_date => p_effective_start_date,
11079 p_effective_end_date => p_effective_end_date,
11080 p_state_code => l_res_state_code,
11081 p_county_code => l_res_county_code,
11082 p_city_code => l_res_city_code,
11083 p_business_group_id => p_business_group_id,
11084 p_percent_time => 0);
11085 end if;
11086 /* Check for override city */
11087 if l_add_city_code is not null then
11088 l_city_tax_rule_id :=
11089 insert_def_city_rec(p_assignment_id => p_assignment_id,
11090 p_effective_start_date => p_effective_start_date,
11091 p_effective_end_date => p_effective_end_date,
11092 p_state_code => l_add_state_code,
11093 p_county_code => l_add_county_code,
11094 p_city_code => l_add_city_code,
11095 p_business_group_id => p_business_group_id,
11096 p_percent_time => 0);
11097 end if;
11098 end default_tax;
11099
11100 procedure check_defaulting(p_assignment_id in number,
11101 p_effective_start_date in date,
11102 p_business_group_id in number,
11103 p_from_form in varchar2,
11104 p_fed_exists in out nocopy varchar2,
11105 p_ret_code in out nocopy number,
11106 p_ret_text in out nocopy varchar2 ) is
11107
11108
11109 /* Cursor to check if a federal record exists or not */
11110 cursor csr_chk_federal is
11111 select 'Y'
11112 from DUAL
11113 where exists ( select null
11114 from PAY_US_EMP_FED_TAX_RULES_F ftr
11115 where ftr.assignment_id = p_assignment_id);
11116
11117 /* Cursor to get the max effective end date of the assignment */
11118
11119 cursor csr_asg_end_date is
11120 select max(effective_end_date)
11121 from PER_ASSIGNMENTS_F paf
11122 where paf.assignment_id = p_assignment_id;
11123
11124 l_effective_end_date date;
11125
11126 begin
11127
11128 /* Check to see if the defaulting of tax records has already taken place
11129 or not */
11130
11131 open csr_chk_federal;
11132
11133 fetch csr_chk_federal into p_fed_exists;
11134
11135 if csr_chk_federal%NOTFOUND then
11136
11137 p_fed_exists := 'N';
11138
11139 else
11140
11141 p_fed_exists := 'Y';
11142
11143 end if;
11144
11145 close csr_chk_federal;
11146
11147 if p_fed_exists = 'N'
11148 and p_from_form in ('Assignment', 'Tax Rules','Address') then
11149 /* Check to see if future dated change in locations has taken
11150 place or not */
11151
11152 if pay_us_emp_dt_tax_val.check_locations(p_assignment_id => p_assignment_id,
11153 p_effective_start_date => p_effective_start_date,
11154 p_business_group_id => p_business_group_id)
11155 then
11156
11157 /* message('Future dated location changes exist for which the
11158 defaulting criteria might not be satisfied.') */
11159
11160 fnd_message.set_name('PAY', 'PAY_52299_TAX_FUT_LOC');
11161 fnd_message.raise_error;
11162
11163 end if;
11164
11165 /* Get the max effective end date of the assignment.
11166 This is done to take care of the terminated assignment
11167 so that the tax records do not get created for the time
11168 when the assignment is not valid. */
11169
11170 open csr_asg_end_date;
11171
11172 fetch csr_asg_end_date into l_effective_end_date;
11173
11174 if l_effective_end_date is null then
11175
11176 close csr_asg_end_date;
11177 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
11178 fnd_message.set_token('PROCEDURE',
11179 'pay_us_emp_dt_tax_rules.check_defaulting');
11180 fnd_message.set_token('STEP','1');
11181 fnd_message.raise_error;
11182
11183 end if;
11184
11185 close csr_asg_end_date;
11186
11187 /* Call the defaulting tax routine */
11188
11189 default_tax ( p_assignment_id => p_assignment_id,
11190 p_effective_start_date => p_effective_start_date,
11191 p_effective_end_date => l_effective_end_date,
11192 p_business_group_id => p_business_group_id,
11193 p_ret_code => p_ret_code,
11194 p_ret_text => p_ret_text);
11195
11196 end if;
11197
11198 end check_defaulting;
11199
11200
11201 procedure default_tax_with_validation(p_assignment_id in number,
11202 p_person_id in number,
11203 p_effective_start_date in date,
11204 p_effective_end_date in date,
11205 p_session_date in date,
11206 p_business_group_id in number,
11207 p_from_form in varchar2,
11208 p_mode in varchar2,
11209 p_location_id in number,
11210 p_return_code in out nocopy number,
11211 p_return_text in out nocopy varchar2) is
11212
11213
11214 l_code number;
11215 l_time number;
11216 l_assignment_id number;
11217 l_res_state_code varchar2(2);
11218 l_res_county_code varchar2(3);
11219 l_res_city_code varchar2(4);
11220 l_res_state_name varchar2(35);
11221 l_res_county_name varchar2(35);
11222 l_res_city_name varchar2(35);
11223 l_effective_end_date date;
11224 l_ret_code number;
11225 l_ret_text varchar2(240);
11226 l_default_date date;
11227 l_next_date date;
11228 l_payroll_installed boolean := FALSE;
11229 l_validation_start_date date;
11230 l_fed_exists varchar2(1) := 'N';
11231 l_location_found boolean := FALSE;
11232 l_end_date date;
11233 l_next_start_date date;
11234 l_ovrd_loc number;
11235
11236
11237
11238
11239
11240 /* Cursor to get the assignment if called from
11241 the address form. */
11242 /* rmonge fix bug 3429449 */
11243
11244 cursor csr_addr_get_assignment(p_person number) is
11245 select paf.assignment_id, min(paf.effective_start_date)
11246 from per_addresses pa,
11247 hr_soft_coding_keyflex hsck,
11248 per_assignments_f paf
11249 where paf.person_id = p_person
11250 and paf.assignment_type = 'E'
11251 and paf.soft_coding_keyflex_id is not null
11252 and paf.soft_coding_keyflex_id = hsck.soft_coding_keyflex_id
11253 and paf.location_id is not null
11254 and paf.payroll_id is not null
11255 and paf.pay_basis_id is not null
11256 and pa.person_id = paf.person_id
11257 -- and pa.primary_flag = 'Y'
11258 and (paf.effective_start_date between
11259 pa.date_from and nvl(pa.date_to,to_date('12/31/4712','MM/DD/YYYY'))
11260 or pa.date_from between paf.effective_start_date and paf.effective_end_date)
11261 group by assignment_id;
11262
11263
11264
11265 /* old cursor */
11266 /*
11267 cursor csr_addr_get_assignment(p_person number) is
11268 select paf.assignment_id, min(paf.effective_start_date)
11269 from per_addresses pa,
11270 hr_soft_coding_keyflex hsck,
11271 per_assignments_f paf
11272 where paf.person_id = p_person
11273 and paf.assignment_type = 'E'
11274 and paf.soft_coding_keyflex_id is not null
11275 and paf.soft_coding_keyflex_id = hsck.soft_coding_keyflex_id
11276 and paf.location_id is not null
11277 and paf.payroll_id is not null
11278 and paf.pay_basis_id is not null
11279 and pa.person_id = paf.person_id
11280 and pa.primary_flag = 'Y'
11281 -- and (paf.effective_end_date = to_date('12/31/4712','MM/DD/YYYY')
11282
11283 --Added for bug 2535501 June 10, 2003 except for the group by
11284 -- p_effective_start_date is the p_date_from in the Address table
11285 and paf.effective_end_date >= p_effective_start_date
11286
11287 group by assignment_id ;
11288 */
11289
11290 /* added a check for paf.effective_end_date for bug 1640913 */
11291
11292 cursor csr_get_assignment(p_person number) is
11293 select paf.assignment_id, min(paf.effective_start_date)
11294 from per_addresses pa,
11295 hr_soft_coding_keyflex hsck,
11296 per_assignments_f paf
11297 where paf.person_id = p_person
11298 and paf.assignment_type = 'E'
11299 and paf.soft_coding_keyflex_id is not null
11300 and paf.effective_end_date = to_date('12/31/4712','MM/DD/YYYY')
11301 and paf.soft_coding_keyflex_id = hsck.soft_coding_keyflex_id
11302 and paf.location_id is not null
11303 and paf.payroll_id is not null
11304 and paf.pay_basis_id is not null
11305 and pa.person_id = paf.person_id
11306 and pa.primary_flag = 'Y'
11307 group by assignment_id ;
11308
11309 /* Cursor to check if the default tax rules criteria is
11310 met for the assignment. keep in mind the assignment
11311 does not necessarily have to be a primary assignment */
11312
11313 cursor csr_chk_assignment(p_assignment number, p_session_date date) is
11314 select 1
11315 from per_addresses pa,
11316 per_people_f ppf,
11317 hr_soft_coding_keyflex hsck,
11318 per_assignments_f paf
11319 where paf.assignment_id = p_assignment
11320 and p_session_date between paf.effective_start_date
11321 and paf.effective_end_date
11322 and paf.soft_coding_keyflex_id is not null
11323 and paf.soft_coding_keyflex_id = hsck.soft_coding_keyflex_id
11324 and paf.location_id is not null
11325 and paf.payroll_id is not null
11326 and paf.pay_basis_id is not null
11327 and ppf.person_id = paf.person_id
11328 and pa.person_id = ppf.person_id
11329 and pa.primary_flag = 'Y';
11330
11331 /* Get the minimum effective start date of the assignment for which
11332 the defaulting criteria has been satisfied */
11333
11334 cursor csr_get_min_eff_date(p_assignment number) is
11335 select min(paf.effective_start_date)
11336 from per_addresses pa,
11337 per_people_f ppf,
11338 hr_soft_coding_keyflex hsck,
11339 per_assignments_f paf
11340 where paf.assignment_id = p_assignment
11341 and paf.soft_coding_keyflex_id is not null
11342 and paf.soft_coding_keyflex_id = hsck.soft_coding_keyflex_id
11343 and paf.location_id is not null
11344 and paf.payroll_id is not null
11345 and paf.pay_basis_id is not null
11346 and ppf.person_id = paf.person_id
11347 and pa.person_id = ppf.person_id
11348 and pa.primary_flag = 'Y';
11349
11350 cursor csr_get_default_date (p_assignment number) is
11351 select min(effective_start_date)
11352 from PAY_US_EMP_FED_TAX_RULES_F pef
11353 where pef.assignment_id = p_assignment;
11354
11355 cursor csr_get_end_date (p_assignment number,p_default_date date) is
11356 select effective_end_date
11357 from PAY_US_EMP_FED_TAX_RULES_F pef
11358 where pef.assignment_id = p_assignment
11359 and pef.effective_start_date = p_default_date;
11360
11361 cursor csr_chk_addr_ovrd(p_assignment number) is
11362 select pus.state_code,
11363 puc.county_code,
11364 pcn.city_code
11365 from pay_us_city_names pcn,
11366 pay_us_counties puc,
11367 pay_us_states pus,
11368 per_addresses pa,
11369 per_assignments_f paf
11370 where paf.assignment_id = p_assignment
11371 and p_effective_start_date between paf.effective_start_date and
11372 paf.effective_end_date
11373 and pa.person_id = paf.person_id
11374 and pa.primary_flag = 'Y'
11375 and p_effective_start_date between pa.date_from and
11376 nvl(pa.date_to,to_date('12/31/4712','MM/DD/YYYY'))
11377 and pa.add_information17 is not null
11378 and pa.add_information19 is not null
11379 and pa.add_information18 is not null
11380 and pa.add_information17 = pus.state_abbrev
11381 and puc.state_code = pus.state_code
11382 and puc.county_name = pa.add_information19
11383 and pcn.state_code = puc.state_code
11384 and pcn.county_code = puc.county_code
11385 and pcn.city_name = add_information18;
11386
11387 /* rmonge fix for 3429449 */
11388 /* adding new cursor to handle the call to csr_chk_addr_ovrd in the case of a */
11389 /* new Assignment with tax override . I need to pass p_effective_start_date */
11390 /* the original cursor does not allow me to pass it */
11391
11392 cursor csr_chk_addr_ovrd_2(p_assignment number,p_effective_start_date date ) is
11393 select pus.state_code,
11394 puc.county_code,
11395 pcn.city_code
11396 from pay_us_city_names pcn,
11397 pay_us_counties puc,
11398 pay_us_states pus,
11399 per_addresses pa,
11400 per_assignments_f paf
11401 where paf.assignment_id = p_assignment
11402 and p_effective_start_date between paf.effective_start_date and
11403 paf.effective_end_date
11404 and pa.person_id = paf.person_id
11405 and pa.primary_flag = 'Y'
11406 and p_effective_start_date between pa.date_from and
11407 nvl(pa.date_to,to_date('12/31/4712','MM/DD/YYYY'))
11408 and pa.add_information17 is not null
11409 and pa.add_information19 is not null
11410 and pa.add_information18 is not null
11411 and pa.add_information17 = pus.state_abbrev
11412 and puc.state_code = pus.state_code
11413 and puc.county_name = pa.add_information19
11414 and pcn.state_code = puc.state_code
11415 and pcn.county_code = puc.county_code
11416 and pcn.city_name = add_information18;
11417
11418 /* rmonge end of changes */
11419
11420 /* begin modifications - dscully 21-JUN-2000 */
11421 /* removed nvl to default return to location id */
11422 /* instead, if cursor is NOTFOUND, we use location id */
11423 cursor csr_get_ovrd_loc(p_assignment number, p_session_dt date) is
11424 select hsck.segment18
11425 from HR_SOFT_CODING_KEYFLEX hsck,
11426 PER_ASSIGNMENTS_F paf
11427 where paf.assignment_id = p_assignment
11428 and p_session_dt between paf.effective_start_date
11429 and paf.effective_end_date
11430 and hsck.soft_coding_keyflex_id = paf.soft_coding_keyflex_id
11431 and hsck.segment18 is not null;
11432
11433 /* end modifications - dscully 21-JUN-2000 */
11434
11435 /* begin modifications - dscully 20-jul-2000 */
11436 /* added cursors and vars for location maintenance in non payroll installs */
11437
11438 cursor csr_max_loc_date(p_assignment_id NUMBER, p_loc_id NUMBER
11439 ,p_ef_date DATE) is
11440 select min(paf.effective_start_date) - 1
11441 from per_assignments_f paf
11442 where paf.assignment_id = p_assignment_id
11443 and paf.effective_start_date > p_ef_date
11444 and paf.location_id <> p_loc_id;
11445
11446 cursor csr_min_loc_date(p_assignment_id NUMBER, p_loc_id NUMBER
11447 ,p_ef_date DATE) is
11448 select max(paf.effective_end_date) + 1
11449 from per_assignments_f paf
11450 where paf.assignment_id = p_assignment_id
11451 and paf.effective_end_date < p_ef_date
11452 and paf.location_id <> p_loc_id;
11453
11454 cursor csr_fed_tax_loc(p_assignment_id NUMBER, p_min_date DATE
11455 ,p_max_date DATE) is
11456 select *
11457 from pay_us_emp_fed_tax_rules_f ftr
11458 where ftr.assignment_id = p_assignment_id
11459 and ftr.effective_start_date <= p_max_date
11460 and ftr.effective_end_date >= p_min_date;
11461
11462 cursor csr_loc_state_code(p_location_id NUMBER) is
11463 select pus.state_code
11464 from pay_us_states pus,
11465 hr_locations hl
11466 where hl.location_id = p_location_id
11467 and pus.state_abbrev = nvl(loc_information17,region_2);
11468
11469 /* end modifications - dscully 20-jul-2000*/
11470
11471 l_loc_min_date date;
11472 l_loc_max_date date;
11473 l_loc_state_code pay_us_states.state_code%TYPE;
11474
11475
11476 l_add_state_code varchar2(2);
11477 l_add_county_code varchar2(3);
11478 l_add_city_code varchar2(4);
11479 l_loc_id hr_locations.location_id%TYPE;
11480
11481 begin
11482
11483 -- hr_utility.trace_on(null,'AMITA');
11484 hr_utility.set_location('pay_us_emp_dt_tax_rules.validate_default',1);
11485
11486 hr_utility.trace('validate_default-asg ** ' || to_char(p_assignment_id));
11487 hr_utility.trace('validate_default-person id ** ' || to_char(p_person_id));
11488 hr_utility.trace('validate_default-eff start dt ** ' || to_char(p_effective_start_date,'dd-mon-yyyy'));
11489 hr_utility.trace('validate_defaulteff end dt ** ' || to_char(p_effective_end_date,'dd-mon-yyyy'));
11490 hr_utility.trace('validate_default - session dt ** ' || to_char(p_session_date,'dd-mon-yyyy'));
11491 hr_utility.trace('validate_default- bg ** ' || to_char(p_business_group_id));
11492 hr_utility.trace('validate_default - form name ** ' || p_from_form);
11493 hr_utility.trace('validate_default - mode ** ' || p_mode);
11494 hr_utility.trace('validate_default - location id ** ' || to_char(p_location_id));
11495 --dbms_output.put_line('asg** '||to_char(p_assignment_id));
11496 --dbms_output.put_line('asg** '||to_char(p_person_id));
11497 --dbms_output.put_line('sd** '||to_char(p_effective_start_date));
11498 --dbms_output.put_line('ed** '||to_char(p_effective_end_date));
11499 --dbms_output.put_line('sd** '||to_char(p_session_date));
11500 --dbms_output.put_line('bg** ' || to_char(p_business_group_id));
11501 --dbms_output.put_line('bg** ' || p_from_form);
11502 --dbms_output.put_line('bg** ' || p_mode);
11503 --dbms_output.put_line('bg** ' || to_char(p_location_id));
11504
11505 /* First check if geocode has been installed or not. If no geocodes
11506 installed then return because there is nothing to be done by this
11507 defaulting procedure */
11508
11509 if hr_general.chk_maintain_tax_records = 'N' then
11510 return;
11511 end if;
11512
11513 /* Check if payroll has been installed or not */
11514
11515 l_payroll_installed := hr_utility.chk_product_install(p_product =>'Oracle Payroll', p_legislation => 'US');
11516
11517 /* Set up the validation start date */
11518
11519 if p_from_form = 'Assignment' then
11520
11521 if (p_mode = 'CORRECTION' or p_mode is null) then
11522 l_validation_start_date := p_effective_start_date;
11523 else
11524 l_validation_start_date := p_session_date;
11525 end if;
11526
11527 end if;
11528
11529 if p_from_form = 'Address' then
11530
11531 hr_utility.set_location('pay_us_emp_dt_tax_rules.validate_default',2);
11532
11533 /* Get all of the assignments */
11534
11535 open csr_addr_get_assignment(p_person_id);
11536
11537
11538 loop
11539
11540 fetch csr_addr_get_assignment into l_assignment_id, l_validation_start_date;
11541
11542
11543
11544 exit when csr_addr_get_assignment%NOTFOUND;
11545
11546 hr_utility.set_location('pay_us_emp_dt_tax_rules.validate_default',3);
11547
11548 /* Check whether the defaulting of tax rules has been done or not.
11549 If not then do the defaulting of tax rules else return 'Y' in
11550 l_fed_exists to indicate that the defaulting of tax rules has
11551 already taken place. */
11552
11553 check_defaulting(p_assignment_id => l_assignment_id,
11554 p_effective_start_date => l_validation_start_date,
11555 p_business_group_id => p_business_group_id,
11556 p_from_form => 'Address',
11557 p_fed_exists => l_fed_exists,
11558 p_ret_code => p_return_code,
11559 p_ret_text => p_return_text);
11560
11561 if l_fed_exists = 'Y' then
11562
11563 /* The following logic will take care of the affect of change in
11564 resident address to the tax rules records and the tax %age
11565 records.
11566 Get the state code, county code and the city code for the resident
11567 address */
11568
11569 pay_us_emp_dt_tax_val.get_orig_res_codes (p_assignment_id => l_assignment_id,
11570 p_session_date => p_effective_start_date,
11571 p_res_state_code => l_res_state_code,
11572 p_res_county_code => l_res_county_code,
11573 p_res_city_code => l_res_city_code,
11574 p_res_state_name => l_res_state_name,
11575 p_res_county_name => l_res_county_name,
11576 p_res_city_name => l_res_city_name);
11577
11578 open csr_chk_addr_ovrd_2(l_assignment_id,greatest(p_effective_start_date,l_validation_start_date ));
11579 fetch csr_chk_addr_ovrd_2 into l_add_state_code,
11580 l_add_county_code,
11581 l_add_city_code;
11582
11583
11584 if csr_chk_addr_ovrd_2%NOTFOUND then
11585 l_add_state_code := null;
11586 l_add_county_code := null;
11587 l_add_city_code := null;
11588
11589 end if;
11590 close csr_chk_addr_ovrd_2;
11591
11592 /* create the state, county and tax records for the resident address,
11593 if they do not already exist. The following routine will first
11594 check for the existence of the record. Only if the record does
11595 not exist, it will create one along with its corresponding %age
11596 record */
11597
11598
11599 if l_res_state_code is not null and l_res_county_code is not null
11600 and l_res_city_code is not null then
11601
11602 create_new_location_rec(p_assignment_id => l_assignment_id,
11603 p_validation_start_date => null,
11604 p_validation_end_date => null,
11605 p_session_date => null,
11606 p_new_location_id => null,
11607 p_res_state_code => l_res_state_code,
11608 p_res_county_code => l_res_county_code,
11609 p_res_city_code => l_res_city_code,
11610 p_business_group => p_business_group_id,
11611 p_percent => 0);
11612 end if;
11613
11614 if l_add_state_code is not null and l_add_county_code is not null
11615 and l_add_city_code is not null then
11616
11617 create_new_location_rec(p_assignment_id => l_assignment_id,
11618 p_validation_start_date => null,
11619 p_validation_end_date => null,
11620 p_session_date => null,
11621 p_new_location_id => null,
11622 p_res_state_code => l_add_state_code,
11623 p_res_county_code => l_add_county_code,
11624 p_res_city_code => l_add_city_code,
11625 p_business_group => p_business_group_id,
11626 p_percent => 0);
11627 end if;
11628
11629
11630 end if;
11631
11632 end loop;
11633
11634 close csr_addr_get_assignment;
11635
11636 end if; /* End of address form specific */
11637
11638
11639 /* The person package will call this routine if and only if the
11640 hiring date is pulled back */
11641
11642 if p_from_form = 'Person' then
11643
11644 /* Get all of the employee assignments for the person */
11645
11646 open csr_get_assignment(p_person_id);
11647
11648 loop
11649 fetch csr_get_assignment into l_assignment_id, l_validation_start_date;
11650
11651 exit when csr_get_assignment%NOTFOUND;
11652
11653 hr_utility.set_location('pay_us_emp_dt_tax_rules.validate_default',3);
11654
11655 /* Check whether the defaulting of tax rules has been done or not.
11656 If not then do the defaulting of tax rules else return 'Y' in
11657 l_fed_exists to indicate that the defaulting of tax rules has
11658 already taken place. */
11659
11660
11661 check_defaulting(p_assignment_id => l_assignment_id,
11662 p_effective_start_date => l_validation_start_date,
11663 p_business_group_id => p_business_group_id,
11664 p_from_form => 'Person',
11665 p_fed_exists => l_fed_exists,
11666 p_ret_code => p_return_code,
11667 p_ret_text => p_return_text);
11668
11669 /* If the defaulting has take place i.e. tax records exist then pull
11670 back the tax rules as well as the tax %age records */
11671
11672 if l_fed_exists = 'Y' then
11673
11674 /* Get the default date */
11675
11676 open csr_get_default_date(l_assignment_id);
11677
11678 fetch csr_get_default_date into l_default_date;
11679
11680 if l_default_date is null then
11681
11682 close csr_get_default_date;
11683 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
11684 fnd_message.set_token('PROCEDURE',
11685 'pay_us_emp_dt_tax_rules.default_tax_with_validation');
11686 fnd_message.set_token('STEP','1');
11687 fnd_message.raise_error;
11688
11689 end if;
11690
11691 close csr_get_default_date;
11692
11693 /* Now check for pull back of the hiring date */
11694
11695 check_hiring_date(p_assignment_id => l_assignment_id,
11696 p_default_date => l_default_date,
11697 p_s_start_date => p_effective_start_date);
11698
11699 end if;
11700
11701 end loop;
11702
11703 close csr_get_assignment;
11704
11705 end if; /* End of Person form processing */
11706
11707 if p_from_form = 'Assignment' or p_from_form = 'Tax Rules' then
11708
11709 hr_utility.set_location('pay_us_emp_dt_tax_rules.validate_default',5);
11710
11711 if p_from_form = 'Tax Rules' then
11712
11713 /* Get the min effective start date of the assignment for which the
11714 defaulting criteria has been met */
11715
11716 open csr_get_min_eff_date(p_assignment_id);
11717
11718 fetch csr_get_min_eff_date into l_validation_start_date;
11719
11720 if l_validation_start_date is null then
11721
11722 hr_utility.set_location('pay_us_emp_dt_tax_rules.validate_default',6);
11723
11724 p_return_code := 1;
11725 p_return_text := 'Default rules not satisfied';
11726 close csr_get_min_eff_date;
11727 return;
11728
11729 end if;
11730
11731 close csr_get_min_eff_date;
11732
11733 elsif p_from_form = 'Assignment' then
11734
11735 open csr_chk_assignment(p_assignment_id, l_validation_start_date);
11736
11737 fetch csr_chk_assignment into l_code;
11738
11739 if csr_chk_assignment%NOTFOUND then
11740
11741 hr_utility.set_location('pay_us_emp_dt_tax_rules.validate_default',7);
11742
11743 p_return_code := 1;
11744 p_return_text := 'Default rules not satisfied';
11745 close csr_chk_assignment;
11746 return;
11747
11748 end if;
11749
11750 close csr_chk_assignment;
11751
11752 end if;
11753
11754 /* Assign the assignment id to the l_assignment_id so that the same
11755 variable can be used for all of the forms, to call the default_tax
11756 routine */
11757
11758 l_assignment_id := p_assignment_id;
11759
11760 /* Check whether the defaulting of tax rules has been done or not.
11761 If not then do the defaulting of tax rules else return 'Y' in
11762 l_fed_exists to indicate that the defaulting of tax rules has
11763 already taken place. */
11764
11765 check_defaulting(p_assignment_id => p_assignment_id,
11766 p_effective_start_date => l_validation_start_date,
11767 p_business_group_id => p_business_group_id,
11768 p_from_form => p_from_form,
11769 p_fed_exists => l_fed_exists,
11770 p_ret_code => p_return_code,
11771 p_ret_text => p_return_text);
11772
11773 /* We will commit only if this routine has been called by the 'Tax Rules
11774 screen' and the defaulting of tax rules has gone through fine. We
11775 cannot commit in the Tax Rules screen because this routine gets
11776 called in the when new form instance trigger and if we commit after
11777 that the date tracked modes come up. So, commit if and only if called
11778 by the Tax Rules i.e. the W4 screen */
11779
11780 if l_fed_exists = 'N' and
11781 p_from_form = 'Tax Rules' and p_return_code = 0 then
11782
11783 commit;
11784
11785 end if;
11786
11787
11788 if l_fed_exists = 'Y' then
11789
11790 /* Get the default date */
11791
11792 open csr_get_default_date(p_assignment_id);
11793
11794 fetch csr_get_default_date into l_default_date;
11795
11796 if csr_get_default_date%NOTFOUND then
11797
11798 close csr_get_default_date;
11799 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
11800 fnd_message.set_token('PROCEDURE',
11801 'pay_us_emp_dt_tax_rules.default_tax_with_validation');
11802 fnd_message.set_token('STEP','2');
11803 fnd_message.raise_error;
11804
11805 end if;
11806
11807 close csr_get_default_date;
11808
11809 end if;
11810
11811 end if; /* This marks the end of processing when called by the 'Tax Rules */
11812
11813 hr_utility.set_location('pay_us_emp_dt_tax_rules.validate_default',8);
11814
11815
11816 /* begin modifications - dscully 21-JUN-2000 */
11817 /* added default creation of tax records for taxation location */
11818
11819 if p_from_form = 'Assignment' then
11820
11821 l_assignment_id := p_assignment_id;
11822
11823 /* check to see if there is an override location at the asg. level .
11824 If there is then set the override as p_location_id */
11825 l_loc_id := p_location_id;
11826 open csr_get_ovrd_loc(l_assignment_id, p_session_date);
11827 fetch csr_get_ovrd_loc into l_ovrd_loc;
11828 if csr_get_ovrd_loc%found then
11829 l_loc_id := l_ovrd_loc;
11830 end if;
11831 close csr_get_ovrd_loc;
11832
11833 /* if a taxation location is set on the assignment create a default tax record */
11834 if l_ovrd_loc is not null then
11835
11836 /* this procedure checks to make sure record does not yet exist */
11837 /* the date params are null because they only matter when setting non-zero
11838 percentages */
11839
11840 create_new_location_rec(p_assignment_id => p_assignment_id,
11841 p_validation_start_date => null,
11842 p_validation_end_date => null,
11843 p_session_date => null,
11844 p_new_location_id => l_ovrd_loc,
11845 p_res_state_code => null,
11846 p_res_county_code => null,
11847 p_res_city_code => null,
11848 p_business_group => p_business_group_id,
11849 p_percent => 0); /* if l_ovrd_loc is not null */
11850
11851 -- Added to take care SUI Wage Base Override enh
11852 -- Turning Off SUI Wage Base Override Functionality due to Bug# 5486281
11853 /*
11854 else
11855 -- Start of SUI Wage Base Override Change
11856 --
11857 -- Update SUI WAGE BASE Overide amount you have payroll installed otherwise don't
11858 -- call the procedure which does the update
11859
11860
11861 IF hr_utility.chk_product_install(p_product =>'Oracle Payroll',
11862 p_legislation => 'US')
11863 then
11864 if p_assignment_id is not null and p_session_date is not null
11865 then
11866 set_sui_wage_base_override(p_assignment_id,
11867 null,
11868 p_session_date) ;
11869 end if ;
11870 end if;
11871 --
11872 -- End of SUI Wage Base Override Change
11873 --
11874 */
11875 end if; /* if l_ovrd_loc is not null */
11876
11877 /* if the location changed do a bunch of element entry manipulation */
11878
11879 if (p_location_id is not null) then
11880
11881 if (l_payroll_installed) then
11882 /* end modifications - dscully 21-JUN-2000 */
11883 /* begin modifications - dscully 19-JUL-2000 */
11884 /* added code to handle location changes for non-payroll customers */
11885
11886 if p_mode = 'CORRECTION' then
11887
11888 /*
11889
11890 | Session date
11891 v
11892 L1 L2 L3 L4 L4
11893 Asg |-----|-----|-------------|--------------|------
11894 Fed |-------------|---------------------
11895 %age |-------------|---------------------
11896 */
11897
11898 if p_effective_end_date < l_default_date then
11899
11900 select p_effective_end_date + 1
11901 into l_next_date
11902 from SYS.DUAL;
11903
11904 if l_next_date < l_default_date then
11905
11906 /* There are some more assignment records without the
11907 tax records. So, error it out */
11908
11909 fnd_message.set_name('PAY', 'PAY_52292_TAX_DEF_CRT');
11910 fnd_message.raise_error;
11911
11912 else
11913
11914 /* First update the tax rules records */
11915
11916 pull_tax_records(p_assignment_id => l_assignment_id,
11917 p_new_start_date => p_effective_start_date,
11918 p_default_date => l_default_date);
11919
11920 /* set the effective start date of the wc entry to the
11921 new effective start date i.e. the p_effective_start_date */
11922
11923 del_updt_wc_entry_for_dates (p_assignment_id => l_assignment_id,
11924 p_session_date => l_default_date,
11925 p_new_start_date => p_effective_start_date,
11926 p_new_end_date => null,
11927 p_mode => 'U');
11928
11929 pull_percentage(p_assignment_id => l_assignment_id,
11930 p_default_date => l_default_date,
11931 p_effective_start_date => p_effective_start_date,
11932 p_effective_end_date => p_effective_end_date,
11933 p_session_date => p_session_date,
11934 p_new_location_id => p_location_id,
11935 p_business_group_id => p_business_group_id);
11936 end if;
11937 else
11938
11939 /* Correct the federal tax record and the worker's comp element entry for
11940 the new SUI Jurisdiction code and SUI state */
11941
11942 change_wc_entry (p_assignment_id => l_assignment_id,
11943 p_effective_start_date => p_effective_start_date,
11944 p_effective_end_date => p_effective_end_date,
11945 p_session_date => p_session_date,
11946 p_new_location_id => l_loc_id,
11947 p_mode => p_mode,
11948 p_ret_code => l_ret_code,
11949 p_ret_text => l_ret_text);
11950
11951 /* Change the tax %age records for a correction in the
11952 location of the assignment */
11953
11954 correct_percentage (p_assignment_id => l_assignment_id,
11955 p_effective_start_date => p_effective_start_date,
11956 p_effective_end_date => p_effective_end_date,
11957 p_session_date => p_session_date,
11958 p_new_location_id => p_location_id,
11959 p_business_group_id => p_business_group_id,
11960 p_ret_code => l_ret_code,
11961 p_ret_text => l_ret_text);
11962
11963 end if;
11964
11965 elsif p_mode in ('UPDATE','UPDATE_OVERRIDE','UPDATE_CHANGE_INSERT') then
11966
11967 /* Update the federal tax record and the worker's comp element entry for
11968 the new SUI Jurisdiction code and SUI state */
11969
11970 change_wc_entry (p_assignment_id => l_assignment_id,
11971 p_effective_start_date => p_effective_start_date,
11972 p_effective_end_date => p_effective_end_date,
11973 p_session_date => p_session_date,
11974 p_new_location_id => l_loc_id,
11975 p_mode => p_mode,
11976 p_ret_code => l_ret_code,
11977 p_ret_text => l_ret_text);
11978
11979 /* Change the %age records for the type of update in the
11980 location of the assignment */
11981
11982 update_percentage (p_assignment_id => l_assignment_id,
11983 p_effective_start_date => p_effective_start_date,
11984 p_effective_end_date => p_effective_end_date,
11985 p_session_date => p_session_date,
11986 p_new_location_id => p_location_id,
11987 p_business_group_id => p_business_group_id,
11988 p_mode => p_mode,
11989 p_ret_code => l_ret_code,
11990 p_ret_text => l_ret_text);
11991
11992 elsif p_mode = 'DELETE_NEXT_CHANGE' then
11993
11994 /* In case of DELETE_NEXT_CHANGE, if the next location is different from
11995 the current location then the assignment screen will error it out.
11996 If the next location is same as the current location then :
11997
11998 | Session Date
11999 L1 v L1
12000 Asg. |--------------------|-------------------------
12001 Tax Rules |-------------------------
12002 Tax %age |-------------------------
12003
12004 In this scenario, the assignment routine deletes the tax %age records
12005 but does not delete the tax rules records. So, our tax routine will have
12006 to delete the tax rules records.
12007
12008 | Session Date
12009 T1 v T2 T3 T4 T5
12010 L1 L1 L1 L1 L1
12011 Asg. |---------|---------|--------|-------|---------
12012 Tax Rules |------------------------------------
12013 Tax %age |------------------------------------
12014
12015 Here, the tax rules and the tax %age records will have to be pulled forward to
12016 time T3.
12017
12018 | Session Date
12019 L1 L1 v L1 L2 L3
12020 Asg. |---------|---------|--------|-------|---------
12021 Tax Rules |------------------------------------
12022 Tax %age |------------------|-------|---------
12023
12024 In the above scenario, the assignment routine will only delete the next
12025 assignment record and will not do anything to the tax %age records, which
12026 is fine and that's how it should be.
12027
12028 | Session Date
12029 L1 L1 L1 L3 v L3
12030 Asg. |---------|---------|--------|-------|---------
12031 Tax Rules |------------------------------------
12032 Tax %age |------------------|-----------------
12033
12034 Here also, we do not need to do anything as the %age records do not get affected
12035 by the deletion of the assignment record. */
12036
12037 open csr_get_end_date(p_assignment_id,l_default_date);
12038
12039 fetch csr_get_end_date into l_end_date;
12040
12041 if csr_get_end_date%NOTFOUND then
12042
12043 close csr_get_end_date;
12044 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
12045 fnd_message.set_token('PROCEDURE',
12046 'pay_us_emp_dt_tax_rules.default_tax_with_validation');
12047 fnd_message.set_token('STEP','3');
12048 fnd_message.raise_error;
12049
12050 end if;
12051
12052 close csr_get_end_date;
12053
12054
12055 if (l_end_date = to_date('31-12-4712','dd-mm-yyyy')) and
12056 not pay_us_emp_dt_tax_val.check_locations(p_assignment_id => p_assignment_id,
12057 p_effective_start_date => p_session_date,
12058 p_business_group_id => p_business_group_id)
12059 then
12060
12061 /* Delete records from PAY_US_EMP_CITY_TAX_RULES_F */
12062
12063 delete PAY_US_EMP_CITY_TAX_RULES_F
12064 where assignment_id = p_assignment_id
12065 and business_group_id = p_business_group_id;
12066
12067 /* Delete records from PAY_US_EMP_COUNTY_TAX_RULES_F */
12068
12069 delete PAY_US_EMP_COUNTY_TAX_RULES_F
12070 where assignment_id = p_assignment_id
12071 and business_group_id = p_business_group_id;
12072
12073 /* Delete records from PAY_US_EMP_STATE_TAX_RULES_F */
12074
12075 delete PAY_US_EMP_STATE_TAX_RULES_F
12076 where assignment_id = p_assignment_id
12077 and business_group_id = p_business_group_id;
12078
12079 /* Delete records from PAY_US_EMP_FED_TAX_RULES_F */
12080
12081 delete PAY_US_EMP_FED_TAX_RULES_F
12082 where assignment_id = p_assignment_id
12083 and business_group_id = p_business_group_id;
12084
12085 else
12086
12087 select l_default_date + 1
12088 into l_next_start_date
12089 from DUAL;
12090
12091 pull_tax_records(p_assignment_id => p_assignment_id,
12092 p_new_start_date => l_next_start_date,
12093 p_default_date => l_default_date);
12094 end if;
12095
12096 elsif p_mode = 'FUTURE_CHANGE' then
12097
12098 /* Delete the next set of %age records */
12099 upd_del_entries(p_assignment_id => l_assignment_id,
12100 p_session_date => p_session_date,
12101 p_new_start_date => null,
12102 p_new_end_date => null,
12103 p_mode => 'F');
12104
12105 end if; /* for correction/update/delete */
12106
12107 /* begin modifications - dscully 20-jul-2000 */
12108 /* added hr only location code */
12109
12110 else -- payroll is not installed
12111
12112 /* This is being added for customers with the NA Address Patch but not payroll */
12113 /* In a perfect world, we would wrap the element entry code in the location maintenance */
12114 /* with if_payroll_installed checks. However, since this is payroll, that would make too */
12115 /* much sense. Because of the amount of ugliness and QA involved in retesting it in a */
12116 /* payroll context, we are just tacking on this code instead. */
12117
12118 /* Because there are no element entries, we determine changes in location by looking at */
12119 /* the assignment record itself(which might be a better way of doing it!). */
12120
12121 /* first lets make sure the record exists */
12122
12123 hr_utility.set_location('pay_us_emp_dt_tax_rules.validate_default',100);
12124
12125 create_new_location_rec(p_assignment_id => p_assignment_id,
12126 p_validation_start_date => null,
12127 p_validation_end_date => null,
12128 p_session_date => null,
12129 p_new_location_id => p_location_id,
12130 p_res_state_code => null,
12131 p_res_county_code => null,
12132 p_res_city_code => null,
12133 p_business_group => p_business_group_id,
12134 p_percent => 0);
12135
12136
12137 /* next we get the begin and end dates for the new location being effective
12138 along with the state code of the jurisdiction */
12139
12140 hr_utility.set_location('pay_us_emp_dt_tax_rules.validate_default',105);
12141
12142 open csr_max_loc_date(p_assignment_id,p_location_id,l_validation_start_date);
12143 fetch csr_max_loc_date into l_loc_max_date;
12144 close csr_max_loc_date;
12145
12146 if l_loc_max_date is null then
12147 l_loc_max_date := hr_api.g_eot;
12148 end if;
12149
12150 --
12151
12152 hr_utility.set_location('pay_us_emp_dt_tax_rules.validate_default',110);
12153
12154 open csr_min_loc_date(p_assignment_id,p_location_id,l_validation_start_date);
12155 fetch csr_min_loc_date into l_loc_min_date;
12156 close csr_min_loc_date;
12157
12158 if l_loc_min_date is null then
12159 l_loc_min_date := hr_api.g_sot;
12160 end if;
12161
12162 --
12163 hr_utility.set_location('pay_us_emp_dt_tax_rules.validate_default',115);
12164
12165 open csr_loc_state_code(p_location_id);
12166 fetch csr_loc_state_code into l_loc_state_code;
12167
12168 if csr_loc_state_code%NOTFOUND then
12169 close csr_loc_state_code;
12170 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
12171 fnd_message.set_token('PROCEDURE',
12172 'pay_us_emp_dt_tax_rules.default_tax_with_validation');
12173 fnd_message.set_token('STEP','10');
12174 fnd_message.raise_error;
12175 end if;
12176
12177 close csr_loc_state_code;
12178
12179 --
12180
12181 /* we update all records that partially fall within that date range */
12182
12183 for tax_rec in csr_fed_tax_loc(p_assignment_id,l_loc_min_date,l_loc_max_date) loop
12184
12185 if tax_rec.effective_start_date < l_loc_min_date then
12186
12187 /* we go from:
12188 ASG --------------|-------L1-----------------
12189 TAX ----------|------------------------------
12190 to:
12191 ASG --------------|-------L1-----------------
12192 TAX ----------|---|--------------------------
12193 */
12194 hr_utility.set_location('pay_us_emp_dt_tax_rules.validate_default',120);
12195
12196 /* insert the middle record */
12197 insert_fed_tax_row(
12198 tax_rec.emp_fed_tax_rule_id,
12199 l_loc_min_date,
12200 tax_rec.effective_end_date,
12201 tax_rec.assignment_id,
12202 l_loc_state_code,
12203 l_loc_state_code || '-000-0000',
12204 tax_rec.business_group_id,
12205 tax_rec.additional_wa_amount,
12206 tax_rec.filing_status_code,
12207 tax_rec.fit_override_amount,
12208 tax_rec.fit_override_rate,
12209 tax_rec.withholding_allowances,
12210 tax_rec.cumulative_taxation,
12211 tax_rec.eic_filing_status_code,
12212 tax_rec.fit_additional_tax,
12213 tax_rec.fit_exempt,
12214 tax_rec.futa_tax_exempt,
12215 tax_rec.medicare_tax_exempt,
12216 tax_rec.ss_tax_exempt,
12217 tax_rec.wage_exempt,
12218 tax_rec.statutory_employee,
12219 tax_rec.w2_filed_year,
12220 tax_rec.supp_tax_override_rate,
12221 tax_rec.excessive_wa_reject_date,
12222 tax_rec.attribute_category,
12223 tax_rec.attribute1,
12224 tax_rec.attribute2,
12225 tax_rec.attribute3,
12226 tax_rec.attribute4,
12227 tax_rec.attribute5,
12228 tax_rec.attribute6,
12229 tax_rec.attribute7,
12230 tax_rec.attribute8,
12231 tax_rec.attribute9,
12232 tax_rec.attribute10,
12233 tax_rec.attribute11,
12234 tax_rec.attribute12,
12235 tax_rec.attribute13,
12236 tax_rec.attribute14,
12237 tax_rec.attribute15,
12238 tax_rec.attribute16,
12239 tax_rec.attribute17,
12240 tax_rec.attribute18,
12241 tax_rec.attribute19,
12242 tax_rec.attribute20,
12243 tax_rec.attribute21,
12244 tax_rec.attribute22,
12245 tax_rec.attribute23,
12246 tax_rec.attribute24,
12247 tax_rec.attribute25,
12248 tax_rec.attribute26,
12249 tax_rec.attribute27,
12250 tax_rec.attribute28,
12251 tax_rec.attribute29,
12252 tax_rec.attribute30,
12253 tax_rec.fed_information_category,
12254 tax_rec.fed_information1,
12255 tax_rec.fed_information2,
12256 tax_rec.fed_information3,
12257 tax_rec.fed_information4,
12258 tax_rec.fed_information5,
12259 tax_rec.fed_information6,
12260 tax_rec.fed_information7,
12261 tax_rec.fed_information8,
12262 tax_rec.fed_information9,
12263 tax_rec.fed_information10,
12264 tax_rec.fed_information11,
12265 tax_rec.fed_information12,
12266 tax_rec.fed_information13,
12267 tax_rec.fed_information14,
12268 tax_rec.fed_information15,
12269 tax_rec.fed_information16,
12270 tax_rec.fed_information17,
12271 tax_rec.fed_information18,
12272 tax_rec.fed_information19,
12273 tax_rec.fed_information20,
12274 tax_rec.fed_information21,
12275 tax_rec.fed_information22,
12276 tax_rec.fed_information23,
12277 tax_rec.fed_information24,
12278 tax_rec.fed_information25,
12279 tax_rec.fed_information26,
12280 tax_rec.fed_information27,
12281 tax_rec.fed_information28,
12282 tax_rec.fed_information29,
12283 tax_rec.fed_information30,
12284 'UPDATE');
12285 else
12286
12287 /* here we simply update the sui codes */
12288
12289 hr_utility.set_location('pay_us_emp_dt_tax_rules.validate_default',125);
12290
12291 update pay_us_emp_fed_tax_rules_f
12292 set sui_state_code = l_loc_state_code,
12293 sui_jurisdiction_code = l_loc_state_code || '-000-0000'
12294 where emp_fed_tax_rule_id = tax_rec.emp_fed_tax_rule_id
12295 and effective_start_date = tax_rec.effective_start_date;
12296
12297 end if;
12298
12299 if tax_rec.effective_end_date > l_loc_max_date then
12300 /* we go from the case:
12301 ASG -------L1-----------------|--------------
12302 TAX --------------------------------|--------
12303 to
12304 ASG -------L1-----------------|--------------
12305 TAX --------------------------|-----|--------
12306 */
12307
12308 hr_utility.set_location('pay_us_emp_dt_tax_rules.validate_default',130);
12309
12310 insert_fed_tax_row(
12311 tax_rec.emp_fed_tax_rule_id,
12312 l_loc_max_date + 1,
12313 tax_rec.effective_end_date,
12314 tax_rec.assignment_id,
12315 tax_rec.sui_state_code,
12316 tax_rec.sui_jurisdiction_code,
12317 tax_rec.business_group_id,
12318 tax_rec.additional_wa_amount,
12319 tax_rec.filing_status_code,
12320 tax_rec.fit_override_amount,
12321 tax_rec.fit_override_rate,
12322 tax_rec.withholding_allowances,
12323 tax_rec.cumulative_taxation,
12324 tax_rec.eic_filing_status_code,
12325 tax_rec.fit_additional_tax,
12326 tax_rec.fit_exempt,
12327 tax_rec.futa_tax_exempt,
12328 tax_rec.medicare_tax_exempt,
12329 tax_rec.ss_tax_exempt,
12330 tax_rec.wage_exempt,
12331 tax_rec.statutory_employee,
12332 tax_rec.w2_filed_year,
12333 tax_rec.supp_tax_override_rate,
12334 tax_rec.excessive_wa_reject_date,
12335 tax_rec.attribute_category,
12336 tax_rec.attribute1,
12337 tax_rec.attribute2,
12338 tax_rec.attribute3,
12339 tax_rec.attribute4,
12340 tax_rec.attribute5,
12341 tax_rec.attribute6,
12342 tax_rec.attribute7,
12343 tax_rec.attribute8,
12344 tax_rec.attribute9,
12345 tax_rec.attribute10,
12346 tax_rec.attribute11,
12347 tax_rec.attribute12,
12348 tax_rec.attribute13,
12349 tax_rec.attribute14,
12350 tax_rec.attribute15,
12351 tax_rec.attribute16,
12352 tax_rec.attribute17,
12353 tax_rec.attribute18,
12354 tax_rec.attribute19,
12355 tax_rec.attribute20,
12356 tax_rec.attribute21,
12357 tax_rec.attribute22,
12358 tax_rec.attribute23,
12359 tax_rec.attribute24,
12360 tax_rec.attribute25,
12361 tax_rec.attribute26,
12362 tax_rec.attribute27,
12363 tax_rec.attribute28,
12364 tax_rec.attribute29,
12365 tax_rec.attribute30,
12366 tax_rec.fed_information_category,
12367 tax_rec.fed_information1,
12368 tax_rec.fed_information2,
12369 tax_rec.fed_information3,
12370 tax_rec.fed_information4,
12371 tax_rec.fed_information5,
12372 tax_rec.fed_information6,
12373 tax_rec.fed_information7,
12374 tax_rec.fed_information8,
12375 tax_rec.fed_information9,
12376 tax_rec.fed_information10,
12377 tax_rec.fed_information11,
12378 tax_rec.fed_information12,
12379 tax_rec.fed_information13,
12380 tax_rec.fed_information14,
12381 tax_rec.fed_information15,
12382 tax_rec.fed_information16,
12383 tax_rec.fed_information17,
12384 tax_rec.fed_information18,
12385 tax_rec.fed_information19,
12386 tax_rec.fed_information20,
12387 tax_rec.fed_information21,
12388 tax_rec.fed_information22,
12389 tax_rec.fed_information23,
12390 tax_rec.fed_information24,
12391 tax_rec.fed_information25,
12392 tax_rec.fed_information26,
12393 tax_rec.fed_information27,
12394 tax_rec.fed_information28,
12395 tax_rec.fed_information29,
12396 tax_rec.fed_information30,
12397 'UPDATE');
12398 end if;
12399 end loop;
12400
12401 /* end modifications - dscully 20-jul-2000 */
12402 hr_utility.set_location('pay_us_emp_dt_tax_rules.validate_default',140);
12403 end if; /* for payroll installed/not installed */
12404 end if; /* for location id is not null */
12405
12406 end if; /* call from assignment form */
12407
12408
12409
12410 end; /*default_tax_with_validation */
12411 /* Name : check_nra_status
12412 Purpose : To check whether the employee is a Non Resident Alien.
12413 Internal revenue doesnot allow NRA to claim W4 allowances >1
12414 Added by vaprakas 12/5/2006 bug 5607135
12415
12416 */
12417 procedure check_nra_status(p_assignment_id in number,
12418 p_withholding_allowances in number,
12419 p_filing_status_code in varchar2,
12420 p_fit_exempt in varchar2,
12421 p_effective_start_date in date,
12422 p_effective_end_date in date,
12423 p_returned_warning OUT NOCOPY VARCHAR2)
12424 is
12425 l_information_type per_people_extra_info.information_type%TYPE;
12426 l_pei_information_category per_people_extra_info.pei_information_category%TYPE;
12427 l_pei_information5 per_people_extra_info.pei_information5%TYPE;
12428 l_pei_information9 per_people_extra_info.pei_information9%TYPE;
12429
12430 l_student_flag varchar2(3);
12431 l_student per_people_extra_info.pei_information1%TYPE;
12432 l_business_apprentice per_people_extra_info.pei_information2%TYPE;
12433 l_warning VARCHAR2(300);
12434
12435
12436 cursor csr_chk_student_status
12437 is
12438 select pei_information1,pei_information2
12439 from per_people_extra_info where person_id=(select distinct person_id from per_all_assignments_f
12440 where assignment_id=p_assignment_id
12441 and primary_flag='Y')
12442 and information_type like 'PER_US_ADDITIONAL_DETAILS'
12443 and pei_information_category like 'PER_US_ADDITIONAL_DETAILS'
12444 and (pei_information1 = 'Y'
12445 or pei_information2 = 'Y');
12446
12447 cursor csr_chk_nra_status
12448 is
12449 select information_type,pei_information_category,pei_information5,pei_information9
12450 from per_people_extra_info where person_id=(select distinct person_id from per_all_assignments_f
12451 where assignment_id=p_assignment_id
12452 and primary_flag='Y')
12453 and information_type like 'PER_US_ADDITIONAL_DETAILS'
12454 and pei_information_category like 'PER_US_ADDITIONAL_DETAILS'
12455 and pei_information5 like 'N'
12456 and pei_information9 not in ('US');
12457 begin
12458 l_student_flag :='No';
12459
12460 open csr_chk_student_status;
12461 fetch csr_chk_student_status into l_student,l_business_apprentice;
12462 if csr_chk_student_status%FOUND
12463 then l_student_flag :='Yes';
12464 end if;
12465 close csr_chk_student_status;
12466
12467 open csr_chk_nra_status;
12468 fetch csr_chk_nra_status into
12469 l_information_type,l_pei_information_category,l_pei_information5,l_pei_information9;
12470 if csr_chk_nra_status%FOUND
12471 then
12472 if p_withholding_allowances > 1 and not
12473 (l_pei_information9 in ('CA','MX','KS') or (l_student_flag ='Yes' and l_pei_information9 = 'IN'))
12474 then
12475 l_warning := 'PAY_US_CHK_NRA_W4_ALLOWANCES';
12476 fnd_message.set_name('PAY', 'PAY_US_CHK_NRA_W4_ALLOWANCES');
12477 fnd_message.raise_error;
12478 end if;
12479 if p_filing_status_code <> '01'
12480 then
12481 l_warning := 'PAY_US_CHK_NRA_FILING_STATUS';
12482 fnd_message.set_name('PAY', 'PAY_US_CHK_NRA_FILING_STATUS');
12483 fnd_message.raise_error;
12484 end if;
12485 if (p_fit_exempt = 'Y')
12486 then
12487 l_warning := 'PAY_US_CHK_NRA_FIT_EXEMPTIONS';
12488 /** fnd_message.set_name('PAY', 'PAY_US_CHK_NRA_FIT_EXEMPTIONS');
12489 fnd_message.raise_error; **/
12490 end if;
12491 end if;
12492 close csr_chk_nra_status;
12493 p_returned_warning := l_warning;
12494 end check_nra_status;
12495
12496
12497 end pay_us_emp_dt_tax_rules;
12498