24: AND UE.creator_type = 'B'
25: AND UE.legislation_code = 'US'; /* Bug: 2296797 */
26: l_defined_balance_id pay_defined_balances.defined_balance_id%TYPE;
27: BEGIN
28: hr_utility.set_location
29: ('pay_us_magw2_reporting.bal_db_item - opening cursor', 10);
30: -- Open the cursor
31: OPEN csr_defined_balance;
32: -- Fetch the value
33: FETCH csr_defined_balance
34: INTO l_defined_balance_id;
35: IF csr_defined_balance%NOTFOUND THEN
36: CLOSE csr_defined_balance;
37: hr_utility.set_location
38: ('pay_us_magw2_reporting.bal_db_item - no rows found from cursor', 20);
39: hr_utility.raise_error;
40: ELSE
41: hr_utility.set_location
35: IF csr_defined_balance%NOTFOUND THEN
36: CLOSE csr_defined_balance;
37: hr_utility.set_location
38: ('pay_us_magw2_reporting.bal_db_item - no rows found from cursor', 20);
39: hr_utility.raise_error;
40: ELSE
41: hr_utility.set_location
42: ('pay_us_magw2_reporting.bal_db_item - fetched from cursor', 30);
43: CLOSE csr_defined_balance;
37: hr_utility.set_location
38: ('pay_us_magw2_reporting.bal_db_item - no rows found from cursor', 20);
39: hr_utility.raise_error;
40: ELSE
41: hr_utility.set_location
42: ('pay_us_magw2_reporting.bal_db_item - fetched from cursor', 30);
43: CLOSE csr_defined_balance;
44: END IF;
45: /* Return the value to the call */
73: p_report_type IN OUT nocopy VARCHAR2,
74: p_business_group_id IN OUT nocopy NUMBER
75: ) IS
76: BEGIN
77: hr_utility.set_location
78: ('pay_us_magw2_reporting.get_report_parameters', 10);
79: SELECT ppa.start_date,
80: ppa.effective_date,
81: ppa.business_group_id,
92: SELECT state_code
93: INTO p_state_code
94: FROM pay_us_states
95: WHERE state_abbrev = p_state_abbrev;
96: hr_utility.set_location
97: ('pay_us_magw2_reporting.get_report_parameters', 20);
98: ELSE
99: p_state_code := '';
100: hr_utility.set_location
96: hr_utility.set_location
97: ('pay_us_magw2_reporting.get_report_parameters', 20);
98: ELSE
99: p_state_code := '';
100: hr_utility.set_location
101: ('pay_us_magw2_reporting.get_report_parameters', 30);
102: END IF;
103: IF p_state_abbrev = 'FED' AND p_report_type = 'W2' THEN
104: p_report_type := 'FEDW2';
104: p_report_type := 'FEDW2';
105: ELSIF p_report_type = 'W2' THEN
106: p_report_type := 'STW2';
107: END IF;
108: hr_utility.set_location
109: ('pay_us_magw2_reporting.get_report_parameters', 40);
110: END get_report_parameters;
111: -------------------------------------------------------------------------
112: -- Name : get_balance_value
132: p_effective_date DATE
133: ) RETURN NUMBER IS
134: l_jurisdiction_code VARCHAR2(20);
135: BEGIN
136: hr_utility.set_location
137: ('pay_us_magw2_reporting.get_balance_value', 10);
138: pay_balance_pkg.set_context('TAX_UNIT_ID', p_tax_unit_id);
139: IF p_state_abbrev <> 'FED' THEN
140: SELECT jurisdiction_code
140: SELECT jurisdiction_code
141: INTO l_jurisdiction_code
142: FROM pay_state_rules
143: WHERE state_code = p_state_abbrev;
144: hr_utility.set_location
145: ('pay_us_magw2_reporting.get_balance_value', 15);
146: pay_balance_pkg.set_context('JURISDICTION_CODE', l_jurisdiction_code);
147: END IF;
148: hr_utility.trace(p_balance_name);
144: hr_utility.set_location
145: ('pay_us_magw2_reporting.get_balance_value', 15);
146: pay_balance_pkg.set_context('JURISDICTION_CODE', l_jurisdiction_code);
147: END IF;
148: hr_utility.trace(p_balance_name);
149: hr_utility.trace('Context');
150: hr_utility.trace('Tax Unit Id: '|| p_tax_unit_id);
151: hr_utility.trace('Jurisdiction: '|| l_jurisdiction_code);
152: hr_utility.set_location
145: ('pay_us_magw2_reporting.get_balance_value', 15);
146: pay_balance_pkg.set_context('JURISDICTION_CODE', l_jurisdiction_code);
147: END IF;
148: hr_utility.trace(p_balance_name);
149: hr_utility.trace('Context');
150: hr_utility.trace('Tax Unit Id: '|| p_tax_unit_id);
151: hr_utility.trace('Jurisdiction: '|| l_jurisdiction_code);
152: hr_utility.set_location
153: ('pay_us_magw2_reporting.get_balance_value', 20);
146: pay_balance_pkg.set_context('JURISDICTION_CODE', l_jurisdiction_code);
147: END IF;
148: hr_utility.trace(p_balance_name);
149: hr_utility.trace('Context');
150: hr_utility.trace('Tax Unit Id: '|| p_tax_unit_id);
151: hr_utility.trace('Jurisdiction: '|| l_jurisdiction_code);
152: hr_utility.set_location
153: ('pay_us_magw2_reporting.get_balance_value', 20);
154: RETURN pay_balance_pkg.get_value(bal_db_item(p_balance_name),
147: END IF;
148: hr_utility.trace(p_balance_name);
149: hr_utility.trace('Context');
150: hr_utility.trace('Tax Unit Id: '|| p_tax_unit_id);
151: hr_utility.trace('Jurisdiction: '|| l_jurisdiction_code);
152: hr_utility.set_location
153: ('pay_us_magw2_reporting.get_balance_value', 20);
154: RETURN pay_balance_pkg.get_value(bal_db_item(p_balance_name),
155: p_assignment_id, p_effective_date);
148: hr_utility.trace(p_balance_name);
149: hr_utility.trace('Context');
150: hr_utility.trace('Tax Unit Id: '|| p_tax_unit_id);
151: hr_utility.trace('Jurisdiction: '|| l_jurisdiction_code);
152: hr_utility.set_location
153: ('pay_us_magw2_reporting.get_balance_value', 20);
154: RETURN pay_balance_pkg.get_value(bal_db_item(p_balance_name),
155: p_assignment_id, p_effective_date);
156: END get_balance_value;
446: CLOSE c_user_entity_id_of_bal;
447: l_package_error_status := 'Y';
448:
449: /* message to user - Database item missing */
450: hr_utility.trace('Database item for balacne missing ');
451: message_text := 'Database item missing ';
452: hr_utility.set_message(801, 'HR_7998_ALL_EXEMACRO_MESSAGE');
453: hr_utility.set_message_token('MESSAGE', message_text);
454: hr_utility.raise_error;
448:
449: /* message to user - Database item missing */
450: hr_utility.trace('Database item for balacne missing ');
451: message_text := 'Database item missing ';
452: hr_utility.set_message(801, 'HR_7998_ALL_EXEMACRO_MESSAGE');
453: hr_utility.set_message_token('MESSAGE', message_text);
454: hr_utility.raise_error;
455:
456: ELSE
449: /* message to user - Database item missing */
450: hr_utility.trace('Database item for balacne missing ');
451: message_text := 'Database item missing ';
452: hr_utility.set_message(801, 'HR_7998_ALL_EXEMACRO_MESSAGE');
453: hr_utility.set_message_token('MESSAGE', message_text);
454: hr_utility.raise_error;
455:
456: ELSE
457: CLOSE c_user_entity_id_of_bal;
450: hr_utility.trace('Database item for balacne missing ');
451: message_text := 'Database item missing ';
452: hr_utility.set_message(801, 'HR_7998_ALL_EXEMACRO_MESSAGE');
453: hr_utility.set_message_token('MESSAGE', message_text);
454: hr_utility.raise_error;
455:
456: ELSE
457: CLOSE c_user_entity_id_of_bal;
458: END IF;
462: IF c_context_tax_unit_id%NOTFOUND THEN
463: CLOSE c_context_tax_unit_id;
464: /* message to user -- unable to find the context_id for tax_unit_id */
465: message_text := 'Context_id value for tax_unit_id missing';
466: hr_utility.trace('Contxt_id value for tax unit id missing');
467: hr_utility.set_message(801, 'HR_7998_ALL_EXEMACRO_MESSAGE');
468: hr_utility.set_message_token('MESSAGE', message_text);
469: hr_utility.raise_error;
470: ELSE
463: CLOSE c_context_tax_unit_id;
464: /* message to user -- unable to find the context_id for tax_unit_id */
465: message_text := 'Context_id value for tax_unit_id missing';
466: hr_utility.trace('Contxt_id value for tax unit id missing');
467: hr_utility.set_message(801, 'HR_7998_ALL_EXEMACRO_MESSAGE');
468: hr_utility.set_message_token('MESSAGE', message_text);
469: hr_utility.raise_error;
470: ELSE
471: CLOSE c_context_tax_unit_id;
464: /* message to user -- unable to find the context_id for tax_unit_id */
465: message_text := 'Context_id value for tax_unit_id missing';
466: hr_utility.trace('Contxt_id value for tax unit id missing');
467: hr_utility.set_message(801, 'HR_7998_ALL_EXEMACRO_MESSAGE');
468: hr_utility.set_message_token('MESSAGE', message_text);
469: hr_utility.raise_error;
470: ELSE
471: CLOSE c_context_tax_unit_id;
472: END IF;
465: message_text := 'Context_id value for tax_unit_id missing';
466: hr_utility.trace('Contxt_id value for tax unit id missing');
467: hr_utility.set_message(801, 'HR_7998_ALL_EXEMACRO_MESSAGE');
468: hr_utility.set_message_token('MESSAGE', message_text);
469: hr_utility.raise_error;
470: ELSE
471: CLOSE c_context_tax_unit_id;
472: END IF;
473:
476: IF c_context_jurisdiction%NOTFOUND THEN
477: CLOSE c_context_jurisdiction;
478: /* message to User -- Unable to find to context_id for jurisdiction */
479: message_text := 'Context_id value for jurisdiction missing';
480: hr_utility.trace('Contxt_id value for jurisdction_id missing');
481: hr_utility.set_message(801, 'HR_7998_ALL_EXEMACRO_MESSAGE');
482: hr_utility.set_message_token('MESSAGE', message_text);
483: hr_utility.raise_error;
484:
477: CLOSE c_context_jurisdiction;
478: /* message to User -- Unable to find to context_id for jurisdiction */
479: message_text := 'Context_id value for jurisdiction missing';
480: hr_utility.trace('Contxt_id value for jurisdction_id missing');
481: hr_utility.set_message(801, 'HR_7998_ALL_EXEMACRO_MESSAGE');
482: hr_utility.set_message_token('MESSAGE', message_text);
483: hr_utility.raise_error;
484:
485: ELSE
478: /* message to User -- Unable to find to context_id for jurisdiction */
479: message_text := 'Context_id value for jurisdiction missing';
480: hr_utility.trace('Contxt_id value for jurisdction_id missing');
481: hr_utility.set_message(801, 'HR_7998_ALL_EXEMACRO_MESSAGE');
482: hr_utility.set_message_token('MESSAGE', message_text);
483: hr_utility.raise_error;
484:
485: ELSE
486: CLOSE c_context_jurisdiction;
479: message_text := 'Context_id value for jurisdiction missing';
480: hr_utility.trace('Contxt_id value for jurisdction_id missing');
481: hr_utility.set_message(801, 'HR_7998_ALL_EXEMACRO_MESSAGE');
482: hr_utility.set_message_token('MESSAGE', message_text);
483: hr_utility.raise_error;
484:
485: ELSE
486: CLOSE c_context_jurisdiction;
487: END IF;
497: IF c_transmitter%NOTFOUND THEN
498: CLOSE c_transmitter;
499: /* message to user -- transmitter has not been defined for the gre */
500: message_text := 'Transmitter Not denfined';
501: hr_utility.trace('Transmitter Not defined ');
502: hr_utility.set_message(801, 'HR_7998_ALL_EXEMACRO_MESSAGE');
503: hr_utility.set_message_token('MESSAGE', message_text);
504: -- hr_utility.raise_error;
505: ELSE
498: CLOSE c_transmitter;
499: /* message to user -- transmitter has not been defined for the gre */
500: message_text := 'Transmitter Not denfined';
501: hr_utility.trace('Transmitter Not defined ');
502: hr_utility.set_message(801, 'HR_7998_ALL_EXEMACRO_MESSAGE');
503: hr_utility.set_message_token('MESSAGE', message_text);
504: -- hr_utility.raise_error;
505: ELSE
506: CLOSE c_transmitter;
499: /* message to user -- transmitter has not been defined for the gre */
500: message_text := 'Transmitter Not denfined';
501: hr_utility.trace('Transmitter Not defined ');
502: hr_utility.set_message(801, 'HR_7998_ALL_EXEMACRO_MESSAGE');
503: hr_utility.set_message_token('MESSAGE', message_text);
504: -- hr_utility.raise_error;
505: ELSE
506: CLOSE c_transmitter;
507: END IF;
500: message_text := 'Transmitter Not denfined';
501: hr_utility.trace('Transmitter Not defined ');
502: hr_utility.set_message(801, 'HR_7998_ALL_EXEMACRO_MESSAGE');
503: hr_utility.set_message_token('MESSAGE', message_text);
504: -- hr_utility.raise_error;
505: ELSE
506: CLOSE c_transmitter;
507: END IF;
508:
505: ELSE
506: CLOSE c_transmitter;
507: END IF;
508:
509: hr_utility.trace('Transmetter Setting is ' || to_char(l_transmitter));
510: hr_utility.trace('Start date ' || to_char(p_year_start));
511: hr_utility.trace('End date ' || to_char(p_year_end));
512: hr_utility.trace('Bussiness_group id ' || to_char(p_business_group_id));
513:
506: CLOSE c_transmitter;
507: END IF;
508:
509: hr_utility.trace('Transmetter Setting is ' || to_char(l_transmitter));
510: hr_utility.trace('Start date ' || to_char(p_year_start));
511: hr_utility.trace('End date ' || to_char(p_year_end));
512: hr_utility.trace('Bussiness_group id ' || to_char(p_business_group_id));
513:
514:
507: END IF;
508:
509: hr_utility.trace('Transmetter Setting is ' || to_char(l_transmitter));
510: hr_utility.trace('Start date ' || to_char(p_year_start));
511: hr_utility.trace('End date ' || to_char(p_year_end));
512: hr_utility.trace('Bussiness_group id ' || to_char(p_business_group_id));
513:
514:
515: /* Check if Archiver has been run for Transmitter */
508:
509: hr_utility.trace('Transmetter Setting is ' || to_char(l_transmitter));
510: hr_utility.trace('Start date ' || to_char(p_year_start));
511: hr_utility.trace('End date ' || to_char(p_year_end));
512: hr_utility.trace('Bussiness_group id ' || to_char(p_business_group_id));
513:
514:
515: /* Check if Archiver has been run for Transmitter */
516:
517: OPEN c_gre_payroll_action (l_transmitter);
518: FETCH c_gre_payroll_action INTO l_payroll_action_id;
519:
520: IF c_gre_payroll_action%NOTFOUND THEN
521: hr_utility.trace('Transmitter has not been Archvied ');
522: CLOSE c_gre_payroll_action;
523: /* message to user -- Transmitter has not been archived */
524: message_text := 'Transmitter has not been archived';
525: hr_utility.trace('Transmitter has not been archived');
521: hr_utility.trace('Transmitter has not been Archvied ');
522: CLOSE c_gre_payroll_action;
523: /* message to user -- Transmitter has not been archived */
524: message_text := 'Transmitter has not been archived';
525: hr_utility.trace('Transmitter has not been archived');
526: hr_utility.set_message(801, 'HR_7998_ALL_EXEMACRO_MESSAGE');
527: hr_utility.set_message_token('MESSAGE', message_text);
528: -- hr_utility.raise_error;
529:
522: CLOSE c_gre_payroll_action;
523: /* message to user -- Transmitter has not been archived */
524: message_text := 'Transmitter has not been archived';
525: hr_utility.trace('Transmitter has not been archived');
526: hr_utility.set_message(801, 'HR_7998_ALL_EXEMACRO_MESSAGE');
527: hr_utility.set_message_token('MESSAGE', message_text);
528: -- hr_utility.raise_error;
529:
530: END IF;
523: /* message to user -- Transmitter has not been archived */
524: message_text := 'Transmitter has not been archived';
525: hr_utility.trace('Transmitter has not been archived');
526: hr_utility.set_message(801, 'HR_7998_ALL_EXEMACRO_MESSAGE');
527: hr_utility.set_message_token('MESSAGE', message_text);
528: -- hr_utility.raise_error;
529:
530: END IF;
531: CLOSE c_gre_payroll_action;
524: message_text := 'Transmitter has not been archived';
525: hr_utility.trace('Transmitter has not been archived');
526: hr_utility.set_message(801, 'HR_7998_ALL_EXEMACRO_MESSAGE');
527: hr_utility.set_message_token('MESSAGE', message_text);
528: -- hr_utility.raise_error;
529:
530: END IF;
531: CLOSE c_gre_payroll_action;
532:
532:
533: /* end of Transmitter Checking */
534:
535:
536: hr_utility.set_location('pay_us_magw2_reporting.preprocess_check', 10);
537:
538: FOR gre_rec IN c_get_gre LOOP
539: /* set l_gre to gre Fethched */
540: l_gre := gre_rec.gre;
549: IF c_arch_errored_asg%FOUND THEN
550: --Some of the assignments have not been archived
551:
552:
553: hr_utility.set_location('pay_us_magw2_reporting.preprocess_check', 70);
554: hr_utility.set_message(801, 'PAY_72729_ASG_NOT_ARCH');
555: l_package_error_status := 'Y';
556: /* message to user -- assignment has errored out */
557: -- hr_utility.raise_error;
550: --Some of the assignments have not been archived
551:
552:
553: hr_utility.set_location('pay_us_magw2_reporting.preprocess_check', 70);
554: hr_utility.set_message(801, 'PAY_72729_ASG_NOT_ARCH');
555: l_package_error_status := 'Y';
556: /* message to user -- assignment has errored out */
557: -- hr_utility.raise_error;
558: END IF;
553: hr_utility.set_location('pay_us_magw2_reporting.preprocess_check', 70);
554: hr_utility.set_message(801, 'PAY_72729_ASG_NOT_ARCH');
555: l_package_error_status := 'Y';
556: /* message to user -- assignment has errored out */
557: -- hr_utility.raise_error;
558: END IF;
559: CLOSE c_arch_errored_asg;
560: OPEN c_arch_retry_pending (l_payroll_action_id);
561: FETCH c_arch_retry_pending INTO l_asg_retry_pend;
560: OPEN c_arch_retry_pending (l_payroll_action_id);
561: FETCH c_arch_retry_pending INTO l_asg_retry_pend;
562: IF c_arch_retry_pending%FOUND THEN
563: --Some of the assignments have been marked for retry
564: hr_utility.set_location('pay_us_magw2_reporting.preprocess_check', 80);
565: hr_utility.set_message(801, 'PAY_72730_ASG_MARKED_FOR_RETRY');
566: l_package_error_status := 'Y';
567: -- hr_utility.raise_error;
568: END IF;
561: FETCH c_arch_retry_pending INTO l_asg_retry_pend;
562: IF c_arch_retry_pending%FOUND THEN
563: --Some of the assignments have been marked for retry
564: hr_utility.set_location('pay_us_magw2_reporting.preprocess_check', 80);
565: hr_utility.set_message(801, 'PAY_72730_ASG_MARKED_FOR_RETRY');
566: l_package_error_status := 'Y';
567: -- hr_utility.raise_error;
568: END IF;
569: CLOSE c_arch_retry_pending;
563: --Some of the assignments have been marked for retry
564: hr_utility.set_location('pay_us_magw2_reporting.preprocess_check', 80);
565: hr_utility.set_message(801, 'PAY_72730_ASG_MARKED_FOR_RETRY');
566: l_package_error_status := 'Y';
567: -- hr_utility.raise_error;
568: END IF;
569: CLOSE c_arch_retry_pending;
570:
571: /* CHECK IF THERE IS NEED TO DO STATE TAX_RULES CHECKING */
575: l_context_tax_unit_id ,
576: l_gre ,
577: l_context_jursidiction );
578: FETCH c_person_in_state into l_person_in_state;
579: hr_utility.trace( to_char(l_gre) || ' GRE-ID has atleast one person in the state ' || p_state_abbrev);
580: IF c_person_in_state%FOUND THEN
581: /* Check to set if state tax rules have been defined */
582:
583: OPEN c_chk_archive_state_code (l_gre,l_payroll_action_id);
581: /* Check to set if state tax rules have been defined */
582:
583: OPEN c_chk_archive_state_code (l_gre,l_payroll_action_id);
584: FETCH c_chk_archive_state_code INTO l_state_tax_rules_exist;
585: hr_utility.trace('GRE:' || TO_CHAR(l_gre));
586: hr_utility.trace('payroll_action_id - '|| to_char(l_payroll_action_id));
587: IF c_chk_archive_state_code%NOTFOUND THEN
588: --State Tax rules have not been defined
589: /* message to user -- State Tax rules not defined for the state ') */
582:
583: OPEN c_chk_archive_state_code (l_gre,l_payroll_action_id);
584: FETCH c_chk_archive_state_code INTO l_state_tax_rules_exist;
585: hr_utility.trace('GRE:' || TO_CHAR(l_gre));
586: hr_utility.trace('payroll_action_id - '|| to_char(l_payroll_action_id));
587: IF c_chk_archive_state_code%NOTFOUND THEN
588: --State Tax rules have not been defined
589: /* message to user -- State Tax rules not defined for the state ') */
590: message_text := 'State Tax Rules not Defind for GRE ' || to_char(l_gre) || ' for ' || P_state_abbrev;
601: p_pactid,
602: 'P', -- payroll action level.
603: message_text);
604: commit;
605: hr_utility.set_message(801, 'HR_7998_ALL_EXEMACRO_MESSAGE');
606: hr_utility.set_message_token('MESSAGE', message_text);
607: l_package_error_status := 'Y';
608: --hr_utility.raise_error;
609: END IF;
602: 'P', -- payroll action level.
603: message_text);
604: commit;
605: hr_utility.set_message(801, 'HR_7998_ALL_EXEMACRO_MESSAGE');
606: hr_utility.set_message_token('MESSAGE', message_text);
607: l_package_error_status := 'Y';
608: --hr_utility.raise_error;
609: END IF;
610: CLOSE c_chk_archive_state_code;
604: commit;
605: hr_utility.set_message(801, 'HR_7998_ALL_EXEMACRO_MESSAGE');
606: hr_utility.set_message_token('MESSAGE', message_text);
607: l_package_error_status := 'Y';
608: --hr_utility.raise_error;
609: END IF;
610: CLOSE c_chk_archive_state_code;
611: CLOSE c_person_in_state;
612: ELSE
613: CLOSE c_person_in_state;
614: END IF; -- END OF C_person_in state not found if
615: END IF; -- REPORT TYPE = STATE
616:
617: hr_utility.trace('GRE:' || TO_CHAR(l_gre));
618: hr_utility.trace('payroll_action_id - '|| to_char(l_payroll_action_id));
619: hr_utility.trace('No. of GREs picked so far - '|| to_char(l_no_of_gres_picked));
620: l_no_of_gres_picked := l_no_of_gres_picked + 1;
621: ELSE
614: END IF; -- END OF C_person_in state not found if
615: END IF; -- REPORT TYPE = STATE
616:
617: hr_utility.trace('GRE:' || TO_CHAR(l_gre));
618: hr_utility.trace('payroll_action_id - '|| to_char(l_payroll_action_id));
619: hr_utility.trace('No. of GREs picked so far - '|| to_char(l_no_of_gres_picked));
620: l_no_of_gres_picked := l_no_of_gres_picked + 1;
621: ELSE
622: /* The GRE has not been archived so check for valid Persons in the GRE
615: END IF; -- REPORT TYPE = STATE
616:
617: hr_utility.trace('GRE:' || TO_CHAR(l_gre));
618: hr_utility.trace('payroll_action_id - '|| to_char(l_payroll_action_id));
619: hr_utility.trace('No. of GREs picked so far - '|| to_char(l_no_of_gres_picked));
620: l_no_of_gres_picked := l_no_of_gres_picked + 1;
621: ELSE
622: /* The GRE has not been archived so check for valid Persons in the GRE
623: who have been paid for the run YEAR
624:
625: Open Cursor as per your Report type to check if GRE needs to be archived
626: or Not */
627: IF p_report_type = 'FEDW2' THEN --federal W2
628: hr_utility.set_location('pay_us_magw2_reporting.preprocess_check', 99);
629: OPEN c_gre_fed(gre_rec.gre);
630: ELSIF p_report_type = 'STW2' THEN --state W2
631: OPEN c_gre_state(gre_rec.gre);
632: END IF;
635: IF p_report_type = 'FEDW2' THEN
636: FETCH c_gre_fed INTO l_person
637: ,l_assignment
638: ,l_asg_effective_dt;
639: hr_utility.set_location('pay_us_magw2_reporting.preprocess_check',20);
640: hr_utility.trace('GRE:' || TO_CHAR(l_gre));
641: hr_utility.trace('Assignment ID:' || TO_CHAR(l_assignment));
642: hr_utility.trace('Person ID:' || TO_CHAR(l_person));
643: hr_utility.trace('Effective Date:' || TO_CHAR(l_asg_effective_dt));
636: FETCH c_gre_fed INTO l_person
637: ,l_assignment
638: ,l_asg_effective_dt;
639: hr_utility.set_location('pay_us_magw2_reporting.preprocess_check',20);
640: hr_utility.trace('GRE:' || TO_CHAR(l_gre));
641: hr_utility.trace('Assignment ID:' || TO_CHAR(l_assignment));
642: hr_utility.trace('Person ID:' || TO_CHAR(l_person));
643: hr_utility.trace('Effective Date:' || TO_CHAR(l_asg_effective_dt));
644: IF c_gre_fed%NOTFOUND THEN
637: ,l_assignment
638: ,l_asg_effective_dt;
639: hr_utility.set_location('pay_us_magw2_reporting.preprocess_check',20);
640: hr_utility.trace('GRE:' || TO_CHAR(l_gre));
641: hr_utility.trace('Assignment ID:' || TO_CHAR(l_assignment));
642: hr_utility.trace('Person ID:' || TO_CHAR(l_person));
643: hr_utility.trace('Effective Date:' || TO_CHAR(l_asg_effective_dt));
644: IF c_gre_fed%NOTFOUND THEN
645: EXIT;
638: ,l_asg_effective_dt;
639: hr_utility.set_location('pay_us_magw2_reporting.preprocess_check',20);
640: hr_utility.trace('GRE:' || TO_CHAR(l_gre));
641: hr_utility.trace('Assignment ID:' || TO_CHAR(l_assignment));
642: hr_utility.trace('Person ID:' || TO_CHAR(l_person));
643: hr_utility.trace('Effective Date:' || TO_CHAR(l_asg_effective_dt));
644: IF c_gre_fed%NOTFOUND THEN
645: EXIT;
646: END IF;
639: hr_utility.set_location('pay_us_magw2_reporting.preprocess_check',20);
640: hr_utility.trace('GRE:' || TO_CHAR(l_gre));
641: hr_utility.trace('Assignment ID:' || TO_CHAR(l_assignment));
642: hr_utility.trace('Person ID:' || TO_CHAR(l_person));
643: hr_utility.trace('Effective Date:' || TO_CHAR(l_asg_effective_dt));
644: IF c_gre_fed%NOTFOUND THEN
645: EXIT;
646: END IF;
647: ELSIF p_report_type = 'STW2' THEN
647: ELSIF p_report_type = 'STW2' THEN
648: FETCH c_gre_state INTO l_person
649: ,l_assignment
650: ,l_asg_effective_dt;
651: hr_utility.set_location('pay_us_magw2_reporting.preprocess_check', 40);
652: hr_utility.trace('GRE:' || TO_CHAR(l_gre));
653: hr_utility.trace('Assignment ID:' || TO_CHAR(l_assignment));
654: hr_utility.trace('Person ID:' || TO_CHAR(l_person));
655: hr_utility.trace('Effective Date:' || TO_CHAR(l_asg_effective_dt));
648: FETCH c_gre_state INTO l_person
649: ,l_assignment
650: ,l_asg_effective_dt;
651: hr_utility.set_location('pay_us_magw2_reporting.preprocess_check', 40);
652: hr_utility.trace('GRE:' || TO_CHAR(l_gre));
653: hr_utility.trace('Assignment ID:' || TO_CHAR(l_assignment));
654: hr_utility.trace('Person ID:' || TO_CHAR(l_person));
655: hr_utility.trace('Effective Date:' || TO_CHAR(l_asg_effective_dt));
656: IF c_gre_state%NOTFOUND THEN
649: ,l_assignment
650: ,l_asg_effective_dt;
651: hr_utility.set_location('pay_us_magw2_reporting.preprocess_check', 40);
652: hr_utility.trace('GRE:' || TO_CHAR(l_gre));
653: hr_utility.trace('Assignment ID:' || TO_CHAR(l_assignment));
654: hr_utility.trace('Person ID:' || TO_CHAR(l_person));
655: hr_utility.trace('Effective Date:' || TO_CHAR(l_asg_effective_dt));
656: IF c_gre_state%NOTFOUND THEN
657: EXIT;
650: ,l_asg_effective_dt;
651: hr_utility.set_location('pay_us_magw2_reporting.preprocess_check', 40);
652: hr_utility.trace('GRE:' || TO_CHAR(l_gre));
653: hr_utility.trace('Assignment ID:' || TO_CHAR(l_assignment));
654: hr_utility.trace('Person ID:' || TO_CHAR(l_person));
655: hr_utility.trace('Effective Date:' || TO_CHAR(l_asg_effective_dt));
656: IF c_gre_state%NOTFOUND THEN
657: EXIT;
658: END IF;
651: hr_utility.set_location('pay_us_magw2_reporting.preprocess_check', 40);
652: hr_utility.trace('GRE:' || TO_CHAR(l_gre));
653: hr_utility.trace('Assignment ID:' || TO_CHAR(l_assignment));
654: hr_utility.trace('Person ID:' || TO_CHAR(l_person));
655: hr_utility.trace('Effective Date:' || TO_CHAR(l_asg_effective_dt));
656: IF c_gre_state%NOTFOUND THEN
657: EXIT;
658: END IF;
659: END IF; /* report type = 'STW2' and etc */
656: IF c_gre_state%NOTFOUND THEN
657: EXIT;
658: END IF;
659: END IF; /* report type = 'STW2' and etc */
660: hr_utility.trace('pay_us_magw2_reporting.preprocess_check');
661: hr_utility.trace('GRE - '||to_char(l_gre));
662: IF p_report_type = 'FEDW2' THEN
663: IF get_balance_value('GROSS_EARNINGS_PER_GRE_YTD',
664: l_gre, p_state_abbrev, l_assignment,
657: EXIT;
658: END IF;
659: END IF; /* report type = 'STW2' and etc */
660: hr_utility.trace('pay_us_magw2_reporting.preprocess_check');
661: hr_utility.trace('GRE - '||to_char(l_gre));
662: IF p_report_type = 'FEDW2' THEN
663: IF get_balance_value('GROSS_EARNINGS_PER_GRE_YTD',
664: l_gre, p_state_abbrev, l_assignment,
665: LEAST(p_year_end, l_asg_effective_dt)) > 0 THEN
682: close c_gre_fed;
683: else
684: close c_gre_state;
685: end if;
686: hr_utility.set_location(
687: 'pay_us_magw2_reporting.preprocess_check', 12);
688: hr_utility.set_message(801, 'PAY_72728_ARCH_GRE_NOT_FOUND');
689: /* Check for state tax rules for the gre */
690: OPEN c_chk_archive_state_code (l_gre,l_payroll_action_id);
684: close c_gre_state;
685: end if;
686: hr_utility.set_location(
687: 'pay_us_magw2_reporting.preprocess_check', 12);
688: hr_utility.set_message(801, 'PAY_72728_ARCH_GRE_NOT_FOUND');
689: /* Check for state tax rules for the gre */
690: OPEN c_chk_archive_state_code (l_gre,l_payroll_action_id);
691: FETCH c_chk_archive_state_code INTO l_state_tax_rules_exist;
692: hr_utility.trace('GRE:' || TO_CHAR(l_gre));
688: hr_utility.set_message(801, 'PAY_72728_ARCH_GRE_NOT_FOUND');
689: /* Check for state tax rules for the gre */
690: OPEN c_chk_archive_state_code (l_gre,l_payroll_action_id);
691: FETCH c_chk_archive_state_code INTO l_state_tax_rules_exist;
692: hr_utility.trace('GRE:' || TO_CHAR(l_gre));
693: hr_utility.trace('payroll_action_id - '|| to_char(l_payroll_action_id));
694: IF c_chk_archive_state_code%NOTFOUND THEN
695: --State Tax rules have not been defined
696: /* message to user -- State Tax rules not defined for the state ') */
689: /* Check for state tax rules for the gre */
690: OPEN c_chk_archive_state_code (l_gre,l_payroll_action_id);
691: FETCH c_chk_archive_state_code INTO l_state_tax_rules_exist;
692: hr_utility.trace('GRE:' || TO_CHAR(l_gre));
693: hr_utility.trace('payroll_action_id - '|| to_char(l_payroll_action_id));
694: IF c_chk_archive_state_code%NOTFOUND THEN
695: --State Tax rules have not been defined
696: /* message to user -- State Tax rules not defined for the state ') */
697: message_text := 'GRE_id ' || to_char(l_gre) || 'not archived- STR State ' || P_state_abbrev;
708: p_pactid,
709: 'P', -- payroll action level.
710: message_text);
711: commit;
712: hr_utility.set_message(801, 'HR_7998_ALL_EXEMACRO_MESSAGE');
713: hr_utility.set_message_token('MESSAGE', message_text);
714: l_package_error_status := 'Y';
715: hr_utility.raise_error;
716: END IF;
709: 'P', -- payroll action level.
710: message_text);
711: commit;
712: hr_utility.set_message(801, 'HR_7998_ALL_EXEMACRO_MESSAGE');
713: hr_utility.set_message_token('MESSAGE', message_text);
714: l_package_error_status := 'Y';
715: hr_utility.raise_error;
716: END IF;
717: CLOSE c_chk_archive_state_code;
711: commit;
712: hr_utility.set_message(801, 'HR_7998_ALL_EXEMACRO_MESSAGE');
713: hr_utility.set_message_token('MESSAGE', message_text);
714: l_package_error_status := 'Y';
715: hr_utility.raise_error;
716: END IF;
717: CLOSE c_chk_archive_state_code;
718: --hr_utility.raise_error;
719: end if; /* balance exists */
714: l_package_error_status := 'Y';
715: hr_utility.raise_error;
716: END IF;
717: CLOSE c_chk_archive_state_code;
718: --hr_utility.raise_error;
719: end if; /* balance exists */
720: l_no_of_gres_picked := l_no_of_gres_picked + 1;
721: l_balance_exists := 0;
722: END LOOP; --Main Loop
731: END LOOP; /* end of for statement */
732:
733: IF l_package_error_status = 'Y' THEN
734: message_text := 'Package error - Message lines have detail';
735: hr_utility.set_message(801, 'HR_7998_ALL_EXEMACRO_MESSAGE');
736: hr_utility.set_message_token('MESSAGE', message_text);
737: hr_utility.raise_error;
738: END IF;
739:
732:
733: IF l_package_error_status = 'Y' THEN
734: message_text := 'Package error - Message lines have detail';
735: hr_utility.set_message(801, 'HR_7998_ALL_EXEMACRO_MESSAGE');
736: hr_utility.set_message_token('MESSAGE', message_text);
737: hr_utility.raise_error;
738: END IF;
739:
740: IF l_no_of_gres_picked = 0 THEN
733: IF l_package_error_status = 'Y' THEN
734: message_text := 'Package error - Message lines have detail';
735: hr_utility.set_message(801, 'HR_7998_ALL_EXEMACRO_MESSAGE');
736: hr_utility.set_message_token('MESSAGE', message_text);
737: hr_utility.raise_error;
738: END IF;
739:
740: IF l_no_of_gres_picked = 0 THEN
741: --It means that no archived GRE was
739:
740: IF l_no_of_gres_picked = 0 THEN
741: --It means that no archived GRE was
742: --found for the Organization. This is an error.
743: hr_utility.set_location('pay_us_magw2_reporting.preprocess_check', 110);
744: hr_utility.set_message(801, 'PAY_72728_ARCH_GRE_NOT_FOUND');
745: /* message to User -- No Gre Found for the archive */
746: hr_utility.raise_error;
747: END IF;
740: IF l_no_of_gres_picked = 0 THEN
741: --It means that no archived GRE was
742: --found for the Organization. This is an error.
743: hr_utility.set_location('pay_us_magw2_reporting.preprocess_check', 110);
744: hr_utility.set_message(801, 'PAY_72728_ARCH_GRE_NOT_FOUND');
745: /* message to User -- No Gre Found for the archive */
746: hr_utility.raise_error;
747: END IF;
748: hr_utility.set_location( 'pay_us_magw2_reporting.preprocess_check', 120);
742: --found for the Organization. This is an error.
743: hr_utility.set_location('pay_us_magw2_reporting.preprocess_check', 110);
744: hr_utility.set_message(801, 'PAY_72728_ARCH_GRE_NOT_FOUND');
745: /* message to User -- No Gre Found for the archive */
746: hr_utility.raise_error;
747: END IF;
748: hr_utility.set_location( 'pay_us_magw2_reporting.preprocess_check', 120);
749: RETURN TRUE;
750: exception
744: hr_utility.set_message(801, 'PAY_72728_ARCH_GRE_NOT_FOUND');
745: /* message to User -- No Gre Found for the archive */
746: hr_utility.raise_error;
747: END IF;
748: hr_utility.set_location( 'pay_us_magw2_reporting.preprocess_check', 120);
749: RETURN TRUE;
750: exception
751: when others then
752: -- add message for this
750: exception
751: when others then
752: -- add message for this
753: message_text := message_text || '+ Exception';
754: hr_utility.set_message(801, 'HR_7998_ALL_EXEMACRO_MESSAGE');
755: hr_utility.set_message_token('MESSAGE', message_text);
756: hr_utility.raise_error;
757:
758: END preprocess_check;
751: when others then
752: -- add message for this
753: message_text := message_text || '+ Exception';
754: hr_utility.set_message(801, 'HR_7998_ALL_EXEMACRO_MESSAGE');
755: hr_utility.set_message_token('MESSAGE', message_text);
756: hr_utility.raise_error;
757:
758: END preprocess_check;
759: --
752: -- add message for this
753: message_text := message_text || '+ Exception';
754: hr_utility.set_message(801, 'HR_7998_ALL_EXEMACRO_MESSAGE');
755: hr_utility.set_message_token('MESSAGE', message_text);
756: hr_utility.raise_error;
757:
758: END preprocess_check;
759: --
760: ----------------------------------------------------------------------------
780: p_state_abbrev VARCHAR2(3);
781: p_state_code VARCHAR2(2);
782: p_report_type VARCHAR2(30);
783: BEGIN
784: hr_utility.set_location( 'pay_us_magw2_reporting.range_cursor', 10);
785: get_report_parameters(
786: p_pactid,
787: p_year_start,
788: p_year_end,
790: p_state_code,
791: p_report_type,
792: p_business_group_id
793: );
794: hr_utility.set_location( 'pay_us_magw2_reporting.range_cursor', 20);
795: IF preprocess_check(p_pactid,
796: p_year_start,
797: p_year_end,
798: p_business_group_id,
825: and hoi.org_information_context =
826: ''1099R Magnetic Report Rules'')
827: ORDER BY paf.person_id
828: ';
829: hr_utility.set_location( 'pay_us_magw2_reporting.range_cursor',
830: 30);
831: ELSIF p_report_type = 'STW2' THEN
832: p_sqlstr := '
833: SELECT DISTINCT
874: and hoi.org_information_context =
875: ''1099R Magnetic Report Rules''
876: )
877: order by to_number(paa.serial_number)';
878: hr_utility.set_location( 'pay_us_magw2_reporting.range_cursor',
879: 40);
880: END IF;
881: END IF;
882: END range_cursor;
1032: l_group_by_gre BOOLEAN;
1033: l_w2_box17 NUMBER; --SIT Wages
1034: BEGIN
1035: -- Get the report parameters. These define the report being run.
1036: hr_utility.set_location( 'pay_us_magw2_reporting.create_assignement_act',
1037: 10);
1038: get_report_parameters(
1039: p_pactid,
1040: l_year_start,
1046: );
1047: --Currently all reports group by GRE
1048: l_group_by_gre := TRUE;
1049: --Open the appropriate cursor
1050: hr_utility.set_location( 'pay_us_magw2_reporting.create_assignement_act',
1051: 20);
1052: IF l_report_type = 'FEDW2' THEN
1053: OPEN c_federal;
1054: ELSIF l_report_type = 'STW2' THEN
1060: l_assignment_id,
1061: l_tax_unit_id,
1062: l_effective_end_date,
1063: l_assignment_action_id;
1064: hr_utility.set_location(
1065: 'pay_us_magw2_reporting.create_assignement_act', 30);
1066: EXIT WHEN c_federal%NOTFOUND;
1067: ELSIF l_report_type = 'STW2' THEN
1068: FETCH c_state INTO l_person_id,
1070: l_tax_unit_id,
1071: l_effective_end_date,
1072: l_assignment_action_id,
1073: l_w2_box17;
1074: hr_utility.set_location(
1075: 'pay_us_magw2_reporting.create_assignement_act', 40);
1076: EXIT WHEN c_state%NOTFOUND;
1077: END IF;
1078: --Based on the groupin criteria, check if the record is the same
1084: l_tax_unit_id = l_prev_tax_unit_id) OR
1085: (NOT l_group_by_gre AND
1086: l_person_id = l_prev_person_id)) THEN
1087: --Do Nothing
1088: hr_utility.set_location(
1089: 'pay_us_magw2_reporting.create_assignement_act', 50);
1090: NULL;
1091: ELSE
1092: --Create the assignment action for the record
1089: 'pay_us_magw2_reporting.create_assignement_act', 50);
1090: NULL;
1091: ELSE
1092: --Create the assignment action for the record
1093: hr_utility.trace('Assignment Fetched - ');
1094: hr_utility.trace('Assignment Id : '|| to_char(l_assignment_id));
1095: hr_utility.trace('Person Id : '|| to_char(l_person_id));
1096: hr_utility.trace('tax unit id : '|| to_char(l_tax_unit_id));
1097: hr_utility.trace('Effective End Date : '||
1090: NULL;
1091: ELSE
1092: --Create the assignment action for the record
1093: hr_utility.trace('Assignment Fetched - ');
1094: hr_utility.trace('Assignment Id : '|| to_char(l_assignment_id));
1095: hr_utility.trace('Person Id : '|| to_char(l_person_id));
1096: hr_utility.trace('tax unit id : '|| to_char(l_tax_unit_id));
1097: hr_utility.trace('Effective End Date : '||
1098: to_char(l_effective_end_date));
1091: ELSE
1092: --Create the assignment action for the record
1093: hr_utility.trace('Assignment Fetched - ');
1094: hr_utility.trace('Assignment Id : '|| to_char(l_assignment_id));
1095: hr_utility.trace('Person Id : '|| to_char(l_person_id));
1096: hr_utility.trace('tax unit id : '|| to_char(l_tax_unit_id));
1097: hr_utility.trace('Effective End Date : '||
1098: to_char(l_effective_end_date));
1099: IF l_report_type = 'FEDW2' then
1092: --Create the assignment action for the record
1093: hr_utility.trace('Assignment Fetched - ');
1094: hr_utility.trace('Assignment Id : '|| to_char(l_assignment_id));
1095: hr_utility.trace('Person Id : '|| to_char(l_person_id));
1096: hr_utility.trace('tax unit id : '|| to_char(l_tax_unit_id));
1097: hr_utility.trace('Effective End Date : '||
1098: to_char(l_effective_end_date));
1099: IF l_report_type = 'FEDW2' then
1100: open csr_get_fed_wages(l_assignment_action_id, l_tax_unit_id);
1093: hr_utility.trace('Assignment Fetched - ');
1094: hr_utility.trace('Assignment Id : '|| to_char(l_assignment_id));
1095: hr_utility.trace('Person Id : '|| to_char(l_person_id));
1096: hr_utility.trace('tax unit id : '|| to_char(l_tax_unit_id));
1097: hr_utility.trace('Effective End Date : '||
1098: to_char(l_effective_end_date));
1099: IF l_report_type = 'FEDW2' then
1100: open csr_get_fed_wages(l_assignment_action_id, l_tax_unit_id);
1101: fetch csr_get_fed_wages into l_value;
1108: (l_report_type = 'STW2') then
1109: SELECT pay_assignment_actions_s.nextval
1110: INTO lockingactid
1111: FROM dual;
1112: hr_utility.set_location(
1113: 'pay_us_magw2_reporting.create_assignement_act', 60);
1114: hr_nonrun_asact.insact(lockingactid, l_assignment_id, p_pactid,
1115: p_chunk, l_tax_unit_id);
1116: hr_utility.set_location(
1112: hr_utility.set_location(
1113: 'pay_us_magw2_reporting.create_assignement_act', 60);
1114: hr_nonrun_asact.insact(lockingactid, l_assignment_id, p_pactid,
1115: p_chunk, l_tax_unit_id);
1116: hr_utility.set_location(
1117: 'pay_us_magw2_reporting.create_assignement_act', 70);
1118: --update serial number for highly compensated people for the
1119: --state W2.
1120: IF l_report_type = 'STW2' THEN
1117: 'pay_us_magw2_reporting.create_assignement_act', 70);
1118: --update serial number for highly compensated people for the
1119: --state W2.
1120: IF l_report_type = 'STW2' THEN
1121: hr_utility.set_location(
1122: 'pay_us_magw2_reporting.create_assignement_act', 80);
1123: IF l_w2_box17 > 9999999.99 THEN
1124: UPDATE pay_assignment_actions
1125: SET serial_number = 999999
1126: WHERE assignment_action_id = lockingactid;
1127: END IF;
1128: END IF;
1129: hr_nonrun_asact.insint(lockingactid, l_assignment_action_id);
1130: hr_utility.set_location(
1131: 'pay_us_magw2_reporting.create_assignement_act', 90);
1132: hr_utility.trace('Interlock Created - ');
1133: hr_utility.trace('Locking Action : '|| to_char(lockingactid));
1134: hr_utility.trace('Locked Action : '|| to_char(l_assignment_action_id));
1128: END IF;
1129: hr_nonrun_asact.insint(lockingactid, l_assignment_action_id);
1130: hr_utility.set_location(
1131: 'pay_us_magw2_reporting.create_assignement_act', 90);
1132: hr_utility.trace('Interlock Created - ');
1133: hr_utility.trace('Locking Action : '|| to_char(lockingactid));
1134: hr_utility.trace('Locked Action : '|| to_char(l_assignment_action_id));
1135: --Store the current person/GRE for comparision during the
1136: --next iteration.
1129: hr_nonrun_asact.insint(lockingactid, l_assignment_action_id);
1130: hr_utility.set_location(
1131: 'pay_us_magw2_reporting.create_assignement_act', 90);
1132: hr_utility.trace('Interlock Created - ');
1133: hr_utility.trace('Locking Action : '|| to_char(lockingactid));
1134: hr_utility.trace('Locked Action : '|| to_char(l_assignment_action_id));
1135: --Store the current person/GRE for comparision during the
1136: --next iteration.
1137: l_prev_person_id := l_person_id;
1130: hr_utility.set_location(
1131: 'pay_us_magw2_reporting.create_assignement_act', 90);
1132: hr_utility.trace('Interlock Created - ');
1133: hr_utility.trace('Locking Action : '|| to_char(lockingactid));
1134: hr_utility.trace('Locked Action : '|| to_char(l_assignment_action_id));
1135: --Store the current person/GRE for comparision during the
1136: --next iteration.
1137: l_prev_person_id := l_person_id;
1138: l_prev_tax_unit_id := l_tax_unit_id;
1146: END IF;
1147: END create_assignment_act;
1148:
1149: --begin
1150: -- hr_utility.trace_on(NULL, 'VIP');
1151:
1152: END pay_us_magw2_reporting;