[Home] [Help]
PACKAGE BODY: APPS.PAY_US_ACTION_ARCH
Source
1 PACKAGE BODY pay_us_action_arch AS
2 /* $Header: pyusxfrp.pkb 120.34.12020000.11 2013/05/03 09:06:05 pkoduri ship $ */
3 /*
4 ******************************************************************
5 * *
6 * Copyright (C) 1993 Oracle Corporation. *
7 * All rights reserved. *
8 * *
9 * This material has been provided pursuant to an agreement *
10 * containing restrictions on its use. The material is also *
11 * protected by copyright law. No part of this material may *
12 * be copied or distributed, transmitted or transcribed, in *
13 * any form or by any means, electronic, mechanical, magnetic, *
14 * manual, or otherwise, or disclosed to third parties without *
15 * the express written permission of Oracle Corporation, *
16 * 500 Oracle Parkway, Redwood City, CA, 94065. *
17 * *
18 ******************************************************************
19
20 Name : pay_us_action_arch
21
22 Description : This procedure is used by the External Process
23 Archive process to archive the Employee and
24 Employer Balances in pay_action_information table.
25
26 Change List
27 -----------
28 Date Name Vers Bug No Description
29 ----------- --------- ------ ------- --------------------------
30 02-May-2013 pkoduri 115.140 16318258 Analyzed the archiver code and
31 modified cursors to add missing where
32 condition on dates for -f tables.
33 02-May-2013 abellur 115.139 16318258 Updated get_attachment_number,
34 cursors c_get_att_no_new, jur
35 and upgrade_status modified to
36 include dates in where clause.
37 08-Mar-2013 abellur 115.138 14098797 Updated GSCC error on to_date
38 05-Mar-2013 abellur 115.137 14098797 Modified get_attachment_number,
39 element entry details fetch cursor
40 logic is changed to use the new
41 or old architecture cursor based
42 on the run result status and upgrade
43 date.
44 29-Jan-2013 nvelaga 115.136 14793173 Modified update_federal_values by
45 adding Medicare EE Taxable Over Limit
46 19-mar-2012 tclewis 115.35 13719809 fixed an issue in
47 populate_psd_tax_balances moved
48 update_psd_values to ouside of
49 the if statement for action
50 types of balance adjustment.
51 06-Mar-2012 abellur 115.134 13814029 Included code for Medical Support
52 indicator. Updated date formats for
53 earned date and payment date for
54 'US THIRD PARTY CHECKS'
55 23-Feb-2012 abellur 115.133 13029995 Updated the out variables - nocopy in
56 get_attachment_number.
57 20-Feb-2012 abellur 115.132 13029995 Added procedure get_3rdparty_check and
58 function get_attachment_number.
59 get_3rdparty_check will be called from
60 process actions and get_attachment_number
61 is called from get_3rdparty_check.
62 19-JAN-2012 nkjaladi 115.131 13436969 Modified procedure populate_psd_tax_balances
63 to pass g_cty_wk_psd_wh_def_bal_id and
64 p_ytd_balcall_aaid to parameters
65 p_defined_balance_id and p_balcall_aaid
66 inorder to derive the R/NR correctly.
67 21-OCT-3011 tclewis 115.128 10460539 change lv_rr_jurisdiction_code
68 to varchar2(30).
69 17-AUG-2011 nkjaladi 115.127 9242223 Modified cursor c_get_unproc_asg
70 in procedure action_archive_data
71 to add condition of payroll id
72 15-JUL-2010 emunisek 115.126 9872952 Modified procedure get_employee_withholding_info
73 to fetch Federal Wage Exempt Flag details and archive
74 it in ACTION_INFORMATION10 of pay_action_infromation with
75 action_information_category as 'US WITHHOLDINGS' and
76 ACTION_INFORMATION4 as 'Federal'.The same flag value
77 will be archived in ACTION_INFORMATION27 under
78 action_information_category as 'US FEDERAL', so that
79 we can control the FIT values read from US FEDERAL
80 based on this flag for Periodic Tax Filing FLS Interface.
81 09-JUL-2010 tclewis 115.125 9841827 Modified
82 populate_federal_tax_balances
83 commented out code that
84 handles loadign SS ER Taxable
85 balance. The code was using
86 The value of SS EE taxable.
87 Code now forces a direct
88 access to the SS ER Taxable
89 run results for the archive.
90 Note": The code may need to
91 be modified for Medicare ER
92 Taxable as the code is doing
93 the same there.
94 03-feb-2010 mikarthi 115.124 8688998 Adding two more parameters
95 1. p_archive_balance_info
96 2. p_legislation_code
97 while calling the procedure
98 pay_ac_action_arch.get_last_xfr_info
99 28-Jan-2010 npannamp 115.123 8768738 Removed fix done in 8688998.
100 28-Dec-2009 npannamp 115.122 8768738 Added code to update payroll_id column
101 in pay_payroll_actions table. Procedure
102 action_archinit modified.
103 19-Oct-2009 kagangul 115.121 8688998 Adding two more parameters
104 1. p_archive_balance_info
105 2. p_legislation_code
106 while calling the procedure
107 pay_ac_action_arch.get_last_xfr_info
108 24-AUG-2009 rnestor 115.120 8832183 Added Jurst check
109 18-AUG-2009 rnestor 115.119 8804636 Added date check to c_emp_state_info
110 04-MAY-2009 skpatil 115.118 8433161 To display FIt Exempt and SIT Exempt
111 status at Check writer XML
112 31-MAR-2009 sudedas 115.117 3816988 Added proc action_archdeinit
113 04-DEC-2008 tclewis 115.115 Added code for SUI 1 EE.
114 27-SEP-2008 sudedas 115.114 7418142 Changed cursor c_get_unproc_asg
115 05-SEP-2008 asgugupt 115.113 7379102 Changed c_time_period
116 03-MAR-2008 sudedas 115.112 6827021 Changed action_archive_data
117 For Multi Assignment Enabled
118 Payroll.
119 13-09-2007 sausingh 115.111 5635335 Added nvl condition in procedure
120 update_ytd_withheld for action_info8
121 and actioninfo9
122 21-08-2007 sausingh 115.110 Added Cursor get_display_name
123 to proc update_ytd_withheld
124 26-JUN-2007 asasthan 115.109 5868672 Head Tax info retrieved from
125 JIT table.
126 28-NOV-2006 saikrish 115.108 5683349 Corrected the signature of
127 pay_get_tax_exists_pkg.
128 15-NOV-2006 ahanda 115.107 5264527 Changed select for action_creation
129 code to add hints.
130 Also, changed sql statement to
131 use base table instead secure
132 views.
133 13-APR-2006 ahanda 115.106 Changed HBR code to use amount
134 from pay_hours_by_rate_v.
135 24-MAR-2006 ahanda 115.105 4924263 Changed archive code to not check
136 if tax exists in a JD for
137 Bal Adj action types.
138 27-FEB-2006 ahanda 115.104 5058507 Changed HBR code to store the
139 pay value as amount as for Retro,
140 Hours or Rate could be null.
141 27-FEB-2006 ahanda 115.103 5058507 Changed HBR code to check for
142 Zero Retro Hours.
143 12-FEB-2006 ahanda 115.102 5003054 Changed code to archive multiple
144 retro entries for same element type
145 03-FEB-2006 ahanda 115.101 5003054 Added logic to retropay and hrsXrate
146 07-OCT-2005 ahanda 115.100 4642121 Changed the logic to archive element
147 even if Gross and Net Run are zero
148 4552807 Added call to process_baladj_elements
149 to archive baladj elements.
150 4640155 Changed cursor to get distinct JD
151 20-JUL-2005 ahanda 115.99 4500097 Added Ordered hint for subquery
152 28-JUN-2005 ahanda 115.98 4449712 Changed call to get_last_xfr_info
153 to pass EMPLOYEE DETAILS.
154 Changed cursor c_get_jd to not
155 pick up Federal JD.
156 06-JUN-2005 ahanda 115.97 Changed populate_emp_hours_by_rate
157 Storing Hours and Rate in canonical
158 format.
159 14-MAR-2005 sackumar 115.96 4222032 Change in the Range Cursor removing
160 use of bind Variable -
161 :payroll_action_id
162 17-MAR-2005 ahanda 115.94 4247361 Changed cursor c_payment_info
163 to add a distinct to ensure
164 and assignment is returned
165 only once.
166 4212744 Changed cursor c_get_baladj_jd
167 to remove join to
168 pay_run_result_values and other
169 tables.
170 05-NOV-2004 ahanda 115.94 3995766 Archiver not archiving
171 Balance Adjustment and Reversal
172 03-NOV-2004 ahanda 115.93 3979501 Added support for RANGE_PERSON_ID
173 06-OCT-2004 ahanda 115.92 3940380 Added parameter p_xfr_action_id
174 to get_last_xfr_info
175 06-AUG-2004 ahanda 115.91 3814488 Added populate_emp_hours_by_rate
176 to archive all elements returned
177 by pay_hours_by_rate view.
178 05-AUG-2004 ahanda 115.90 3814488 Added logic for Hours By Rate
179 20-JUL-2004 ahanda 115.89 3780771 Changed order by in the action
180 creation code
181 23-JUN-2004 ahanda 115.88 3711280 Changed the logic for NR/R
182 Also, balance call for Medicare ER
183 and SS ER Liability
184 14-MAY-2004 rsethupa 115.87 3231253 Added Comments
185 13-MAY-2004 rsethupa 115.86 3231253 Added code to archive STEIC Advance
186 balance in the categories
187 'AC DEDUCTIONS' and 'US STATE'
188 30-APR-2004 saurgupt 115.85 3561821 Modified the procedure
189 update_ytd_withheld
190 to check for current values for
191 the balances along with the YTD
192 values before archiving.
193 16-APR-2004 rsethupa 115.84 3311866 US SS Payslip currency Format Enh.
194 Changed code to archive currency
195 data in canonical format for the
196 action info categories 'AC
197 DEDUCTIONS'and 'US WITHHOLDINGS'.
198 12-MAR-2004 rsethupa 115.83 3452149 Modified procedures process_actions
199 and action_archive_data to
200 archive Employee and W4 Information
201 for primary assignment in case
202 multiple assignments flag is checked
203 and any assignment other than the
204 primary is paid.
205 16-JAN-2004 kvsankar 115.82 3349855 Modified query for performance
206 enhancement
207 02-JAN-2004 ahanda 115.81 Changed cursor c_get_baladj_jd
208 to pick up distinct jurisdictions
209 04-DEC-2003 vpandya 115.80 Added logic to call
210 first_time_process
211 even though the Ext Proc Arch
212 has already been run for the
213 current year before.
214 25-NOV-2003 vpandya 115.79 3280589 Changed action_archive_data:
215 populating gv_multi_payroll_pymt.
216 Changed condition for Termi Asg.
217 Removed create_child_actions proc.
218 17-Nov-2003 vpandya 115.78 3262057 Changed populate_puv_tax_balances:
219 Added condition in the cursor
220 c_get_jd in the second select
221 clause.
222 07-Nov-2003 vpandya 115.77 3243503 Changed action_archive_data:
223 selecting assignment_action_id
224 in c_payment_info cursor to
225 get master pp asg act id again in
226 ln_asg_action_id variable.
227 06-Nov-2003 vpandya 115.76 3231337 Changed populate_puv_tax_balances:
228 Removed cursors c_get_sp_rr_jd and
229 c_get_rr_jd. Added cursor c_get_jd.
230 Added function check_tax_exists.
231 05-Nov-2003 vpandya 115.75 3237538 Changed action_archive_data:
232 added cursor c_all_runs.
233 31-Oct-2003 vpandya 115.74 3225286 Changed process_actions
234 Added cursor c_chk_act_type to check
235 if previous archiver is of balance
236 adjustement then call first_time..
237 procedure instead of calling
238 get_current_elements.
239 08-Oct-2003 ahanda 115.73 3181365 Changed -
240 populate_federal_tax_balances
241 and update_ytd_withheld
242 18-Sep-2003 vpandya 115.72 Changed range cursor to fix gscc
243 error on date conversion. Using
244 fnd_date.date_to_canonical instead
245 to_char and canonical_to_date
246 instead of to_date.
247 10-Sep-2003 ekim 115.71 3119792 Added check for whether the archiver
248 2880047 is run for a given payroll
249 in action_archive_data procedure.
250 This sets variable g_xfr_run_exists.
251 Added call to
252 process_additional_elements
253 Added procedure
254 change_processing_priority
255 and called this procedure before
256 insert_rows_thro_api_process.
257 Terminated Assignment check:
258 c_get_term_asg
259 06-Aug-2003 vpandya 115.70 3050620 Changed action_action_creation to
260 create assignment action for
261 zero net pay using view
262 pay_payment_information.
263 28-Jul-2003 vpandya 115.69 3053917 Passing parameter
264 p_ytd_balcall_aaid to
265 get_personal_information.
266 13-Jun-2003 ekim 115.68 3005678 Removed call update_federal_values
267 in between if..else statements
268 in populate_federal_tax_balances
269 and left one call at the end of the
270 procedure.
271 02-Apr-2003 ekim 115.67 Removed ppa.action_status='C'
272 for all queries as paa.action_status
273 ='C' is the only required.
274 28-Mar-2003 ekim 115.66 2875350 Made performance fix on
275 c_get_rr_jd, c_get_sp_rr_jd,
276 c_get_baladj_jd
277 - Added parameter
278 cp_run_effective_date in cursor.
279 2874412 Changed c_get_employee_info to
280 add pre_name_adjunt and suffix.
281 18-Mar-2003 ekim 115.65 2855261 Changed default processing
282 priority in update_ytd_withheld
283 to 10.
284 Changed processing priority
285 for all Tax Deductions.
286 06-Feb-2003 ekim 115.64 2315822 Added additional parameter
287 p_sepchk_flag,p_assignment_id
288 in get_xfr_elements procedure call.
289 31-Jan-2003 ekim 115.63 2752134 Added YTD balance to be archived
290 for EIC Advance
291 02-DEC-2002 ahanda 115.62 Changed package to fix GSCC warnings
292 25-NOV-2002 ahanda 115.61 2658611 Changed update_employee_information
293 to pass assignment_id.
294 19-NOV-2002 vpandya 115.60 Calling set_error_message function
295 of pay_emp_action_arch from all
296 exceptions to get error message
297 Remote Procedure Calls(RPC or Sub
298 program)
299 17-NOV-2002 ahanda 115.59 Added function get_balance_value
300 Balance call done only if def bal id
301 is not null.
302 01-NOV-2002 ahanda 115.58 Changed error handling.
303 14-OCT-2002 ahanda 115.57 2500413 Changed calls to update_ytd_withheld
304 to populate processing_prioirty for
305 Tax Deductions
306 2500381 Changed Code to update Employee Name
307 2562608 Changed range and action creation
308 cursor to pick up reversals.
309 15-OCT-2002 tmehra 115.56 Added code to archive the PQP
310 (Alien) balances.
311 14-OCT-2002 ahanda 115.55 Changed update_ytd_withheld to
312 populate processing priority.
313 23-SEP-2002 ahanda 115.54 2498029 Changed populate_school_tax_balances
314 2532436 and populate_state_tax_balances
315 06-SEP-2002 ahanda 115.53 Fixed GSCC Warnings.
316 17-JUN-2002 ahanda 115.52 2447717 Changed package to populate tax
317 2365908 deductions if location has changed.
318 14-MAY-2002 ahanda 115.51 Moved procedures
319 - get_last_xfr_info
320 - get_last_pymt_info
321 to pay_ac_action_arch
322 24-APR-2002 ahanda 115.50 Changed c_get_rr_jd for performance.
323 18-MAR-2002 ahanda 115.49 2204512 Changed the way we populate NR/R.
324 Fixed archiving for Bal Adj for
325 which Pre Pay flag is checked.
326 18-FEB-2002 ahanda 115.48 2200748 Changed W4 to archive the Work and
327 Resident JDs. Changed Adj Bal proc
328 to pass the bal adj action_id.
329 14-FEB-2002 ahanda 115.47 2189810 Changed c_time_period to get the
330 time_period_id from per_time_periods
331 14-FEB-2002 ahanda 115.46 Changed archinit to check for the
332 new dimension only if multi asgn
333 is enabled. This removed dependency
334 on HRGLOBAL for one off patch.
335 11-FEB-2002 ahanda 115.45 Changed fetch for cursor
336 c_get_states_jit in archinit
337 05-FEB-2002 ahanda 115.44 Changed package for Bal Adjustments.
338 26-JAN-2002 ahanda 115.43 Added dbdrv commands.
339 22-JAN-2002 ahanda 115.42 Changed package to take care
340 of Multi Assignment Processing.
341
342 ****************************************************************************
343 25-JAN-2001 asasthan 115.0 Created.
344
345 ******************************************************************************/
346
347 /******************************************************************************
348 ** Package Local Variables
349 ******************************************************************************/
350 gv_package VARCHAR2(100) := 'pay_us_action_arch';
351 gn_gross_earn_def_bal_id number := 0;
352 gn_payments_def_bal_id number := 0;
353
354 /***************************************************************************
355 Name : change_processing_priority
356 Purpose : Reset the processing priority from the element processing
357 priority to the archiver processing priority for Tax Deductions
358 **************************************************************************/
359 PROCEDURE change_processing_priority IS
360 BEGIN
361 IF pay_ac_action_arch.lrr_act_tab.count > 0 THEN
362 for i in pay_ac_action_arch.lrr_act_tab.first ..
363 pay_ac_action_arch.lrr_act_tab.last loop
364 if pay_ac_action_arch.lrr_act_tab(i).action_info_category
365 = 'AC DEDUCTIONS' then
366 if pay_ac_action_arch.lrr_act_tab(i).act_info10
367 = 'FIT Withheld' then
368 pay_ac_action_arch.lrr_act_tab(i).act_info7 := '1';
369 elsif pay_ac_action_arch.lrr_act_tab(i).act_info10
370 = 'SS EE Withheld' then
371 pay_ac_action_arch.lrr_act_tab(i).act_info7 := '2';
372 elsif pay_ac_action_arch.lrr_act_tab(i).act_info10
373 = 'SS Withheld' then
374 pay_ac_action_arch.lrr_act_tab(i).act_info7 := '2';
375 elsif pay_ac_action_arch.lrr_act_tab(i).act_info10
376 = 'Medicare EE Withheld' then
377 pay_ac_action_arch.lrr_act_tab(i).act_info7 := '3';
378 elsif pay_ac_action_arch.lrr_act_tab(i).act_info10
379 = 'EIC Advance' then
380 pay_ac_action_arch.lrr_act_tab(i).act_info7 := '4';
381 if pay_ac_action_arch.lrr_act_tab(i).act_info9 > 0 then
382 pay_ac_action_arch.lrr_act_tab(i).act_info9 :=
383 (pay_ac_action_arch.lrr_act_tab(i).act_info9 * -1);
384 end if;
385 elsif pay_ac_action_arch.lrr_act_tab(i).act_info10
386 = 'SIT Withheld' then
387 pay_ac_action_arch.lrr_act_tab(i).act_info7 := '5';
388 elsif pay_ac_action_arch.lrr_act_tab(i).act_info10
389 = 'County Withheld' then
390 pay_ac_action_arch.lrr_act_tab(i).act_info7 := '6';
391 elsif pay_ac_action_arch.lrr_act_tab(i).act_info10
392 = 'SDI Withheld' then
393 pay_ac_action_arch.lrr_act_tab(i).act_info7 := '10';
394 elsif pay_ac_action_arch.lrr_act_tab(i).act_info10
395 = 'SDI EE Withheld' then
396 pay_ac_action_arch.lrr_act_tab(i).act_info7 := '10';
397 pay_ac_action_arch.lrr_act_tab(i).act_info10 := 'SDI Withheld';
398 elsif pay_ac_action_arch.lrr_act_tab(i).act_info10
399 = 'SDI1 Withheld' then
400 pay_ac_action_arch.lrr_act_tab(i).act_info7 := '10';
401 elsif pay_ac_action_arch.lrr_act_tab(i).act_info10
402 = 'SDI1 EE Withheld' then
403 pay_ac_action_arch.lrr_act_tab(i).act_info7 := '10';
404 pay_ac_action_arch.lrr_act_tab(i).act_info10 := 'SDI1 Withheld';
405 elsif pay_ac_action_arch.lrr_act_tab(i).act_info10
406 = 'Non W2 FIT Withheld' then
407 pay_ac_action_arch.lrr_act_tab(i).act_info7 := '10';
408 elsif pay_ac_action_arch.lrr_act_tab(i).act_info10
409 = 'SUI Withheld' then
410 pay_ac_action_arch.lrr_act_tab(i).act_info7 := '10';
411 elsif pay_ac_action_arch.lrr_act_tab(i).act_info10
412 = 'SUI EE Withheld' then
413 pay_ac_action_arch.lrr_act_tab(i).act_info7 := '10';
414 pay_ac_action_arch.lrr_act_tab(i).act_info10 := 'SUI Withheld';
415 elsif pay_ac_action_arch.lrr_act_tab(i).act_info10
416 = 'SUI1 Withheld' then
417 pay_ac_action_arch.lrr_act_tab(i).act_info7 := '10';
418 elsif pay_ac_action_arch.lrr_act_tab(i).act_info10
419 = 'SUI1 EE Withheld' then
420 pay_ac_action_arch.lrr_act_tab(i).act_info7 := '10';
421 pay_ac_action_arch.lrr_act_tab(i).act_info10 := 'SUI1 Withheld';
422 elsif pay_ac_action_arch.lrr_act_tab(i).act_info10
423 = 'WC Withheld' then
424 pay_ac_action_arch.lrr_act_tab(i).act_info7 := '10';
425 elsif pay_ac_action_arch.lrr_act_tab(i).act_info10
426 = 'Workers Comp Withheld' then
427 pay_ac_action_arch.lrr_act_tab(i).act_info7 := '10';
428 pay_ac_action_arch.lrr_act_tab(i).act_info10 := 'WC Withheld';
429 elsif pay_ac_action_arch.lrr_act_tab(i).act_info10
430 = 'WC2 Withheld' then
431 pay_ac_action_arch.lrr_act_tab(i).act_info7 := '10';
432 elsif pay_ac_action_arch.lrr_act_tab(i).act_info10
433 = 'Workers Comp2 Withheld' then
434 pay_ac_action_arch.lrr_act_tab(i).act_info7 := '10';
435 pay_ac_action_arch.lrr_act_tab(i).act_info10 := 'WC2 Withheld';
436 elsif pay_ac_action_arch.lrr_act_tab(i).act_info10
437 = 'STEIC Advance' then
438 pay_ac_action_arch.lrr_act_tab(i).act_info7 := '10'; /*Bug 3231253*/
439 elsif pay_ac_action_arch.lrr_act_tab(i).act_info10
440 = 'Head Tax Withheld' then
441 pay_ac_action_arch.lrr_act_tab(i).act_info7 := '10';
442 elsif pay_ac_action_arch.lrr_act_tab(i).act_info10
443 = 'City Withheld' then
444 pay_ac_action_arch.lrr_act_tab(i).act_info7 := '10';
445 elsif pay_ac_action_arch.lrr_act_tab(i).act_info10
446 = 'School Withheld' then
447 pay_ac_action_arch.lrr_act_tab(i).act_info7 := '10';
448 end if;
449 end if;
450 end loop;
451 end if;
452 END change_processing_priority;
453
454 /******************************************************************************
455 Name : get_payroll_action_info
456 Purpose : This returns the Payroll Action level
457 information for Tax Filing (FLS)/Payslip Archiver.
458 Arguments : p_payroll_action_id - Payroll_Action_id of archiver
459 p_start_date - Start date of Archiver
460 p_end_date - End date of Archiver
461 p_business_group_id - Business Group ID
462 p_cons_set_id - Consolidation Set when submitting Archiver
463 p_payroll_id - Payroll ID when submitting Archiver
464 ******************************************************************************/
465 PROCEDURE get_payroll_action_info(p_payroll_action_id in number
466 ,p_end_date out nocopy date
467 ,p_start_date out nocopy date
468 ,p_business_group_id out nocopy number
469 ,p_cons_set_id out nocopy number
470 ,p_payroll_id out nocopy number
471 )
472 IS
473 cursor c_payroll_Action_info
474 (cp_payroll_action_id in number) is
475 select effective_date,
476 start_date,
477 business_group_id,
478 to_number(substr(legislative_parameters,
479 instr(legislative_parameters,
480 'TRANSFER_CONSOLIDATION_SET_ID=')
481 + length('TRANSFER_CONSOLIDATION_SET_ID='))),
482 to_number(ltrim(rtrim(substr(legislative_parameters,
483 instr(legislative_parameters,
484 'TRANSFER_PAYROLL_ID=')
485 + length('TRANSFER_PAYROLL_ID='),
486 (instr(legislative_parameters,
487 'TRANSFER_CONSOLIDATION_SET_ID=') - 1 )
488 - (instr(legislative_parameters,
489 'TRANSFER_PAYROLL_ID=')
490 + length('TRANSFER_PAYROLL_ID='))))))
491 from pay_payroll_actions
492 where payroll_action_id = cp_payroll_action_id;
493
494 ld_end_date DATE;
495 ld_start_date DATE;
496 ln_business_group_id NUMBER;
497 ln_cons_set_id NUMBER;
498 ln_payroll_id NUMBER;
499 lv_procedure_name VARCHAR2(100) := '.get_payroll_action_info';
500
501 lv_error_message VARCHAR2(200);
502 ln_step NUMBER;
503
504 BEGIN
505 hr_utility.set_location(gv_package || lv_procedure_name, 10);
506 ln_step := 1;
507 open c_payroll_action_info(p_payroll_action_id);
508 fetch c_payroll_action_info into ld_end_date,
509 ld_start_date,
510 ln_business_group_id,
511 ln_cons_set_id,
512 ln_payroll_id;
513 close c_payroll_action_info;
514
515 hr_utility.set_location(gv_package || lv_procedure_name, 30);
516 p_end_date := ld_end_date;
517 p_start_date := ld_start_date;
518 p_business_group_id := ln_business_group_id;
519 p_cons_set_id := ln_cons_set_id;
520 p_payroll_id := ln_payroll_id;
521 hr_utility.set_location(gv_package || lv_procedure_name, 50);
522 ln_step := 2;
523
524 EXCEPTION
525 when others then
526 lv_error_message := 'Error at step ' || ln_step || ' in ' ||
527 gv_package || lv_procedure_name;
528
529 hr_utility.trace(lv_error_message || '-' || sqlerrm);
530
531 lv_error_message :=
532 pay_emp_action_arch.set_error_message(lv_error_message);
533
534 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
535 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
536 hr_utility.raise_error;
537
538 END get_payroll_action_info;
539
540
541 /*********************************************************************
542 Name : get_defined_balance_id
543 Purpose : This function returns the defined_balance_id for a given
544 Balance Name and Dimension.
545 The function is used to get the defined_balance_id
546 of the Balance Names stored in the Action Information DF
547 flexfield for US Federal, State, County, City and School
548 Districts.
549 Arguments :
550 Notes :
551 *********************************************************************/
552 FUNCTION get_defined_balance_id(
553 p_business_group_id in number
554 ,p_balance_name in varchar2
555 ,p_balance_dimension in varchar2)
556 RETURN NUMBER
557 IS
558
559 cursor c_get_defined_balance_id (
560 cp_business_group_id in number,
561 cp_balance_name in varchar2,
562 cp_balance_dimension in varchar2 ) is
563 select pdb.defined_balance_id
564 from pay_defined_balances pdb,
565 pay_balance_dimensions pbd,
566 pay_balance_types pbt
567 where pbt.balance_name = cp_balance_name
568 and pbd.database_item_suffix= cp_balance_dimension
569 and pbt.balance_type_id = pdb.balance_type_id
570 and pbd.balance_dimension_id = pdb.balance_dimension_id
571 and ((pbt.legislation_code = 'US' and
572 pbt.business_group_id is null)
573 or (pbt.legislation_code is null and
574 pbt.business_group_id = cp_business_group_id))
575 and ((pdb.legislation_code ='US' and
576 pdb.business_group_id is null)
577 or (pdb.legislation_code is null and
578 pdb.business_group_id = cp_business_group_id));
579
580 ln_defined_balance_id NUMBER;
581
582 BEGIN
583 hr_utility.trace('opened c_get_defined_balance');
584 open c_get_defined_balance_id(p_business_group_id,
585 p_balance_name,
586 p_balance_dimension);
587
588 fetch c_get_defined_balance_id into ln_defined_balance_id;
589 if c_get_defined_balance_id%notfound then
590 hr_utility.trace('Defined balance Id not found');
591 -- Do not error out if the defined_balance_id does not exist
592 -- Pass Null instead.
593 end if;
594 close c_get_defined_balance_id;
595 hr_utility.trace('ln_defined_balance_id = ' ||
596 to_char(ln_defined_balance_id));
597
598 return (ln_defined_balance_id);
599
600 END get_defined_balance_id;
601
602
603 /******************************************************************
604 Name : action_range_cursor
605 Purpose : This returns the select statement that is
606 used to created the range rows for the
607 Tax Filing (FLS)/Payslip Archiver.
608 Arguments :
609 Notes : Calls procedure - get_payroll_action_info
610 ******************************************************************/
611 PROCEDURE action_range_cursor(
612 p_payroll_action_id in number
613 ,p_sqlstr out nocopy varchar2)
614 IS
615
616 ld_end_date DATE;
617 ld_start_date DATE;
618 ln_business_group_id NUMBER;
619 ln_cons_set_id NUMBER;
620 ln_payroll_id NUMBER;
621
622 lv_sql_string VARCHAR2(32000);
623 lv_procedure_name VARCHAR2(100) := '.action_range_cursor';
624
625 BEGIN
626 hr_utility.set_location(gv_package || lv_procedure_name, 10);
627 get_payroll_action_info(p_payroll_action_id => p_payroll_action_id
628 ,p_start_date => ld_start_date
629 ,p_end_date => ld_end_date
630 ,p_business_group_id => ln_business_group_id
631 ,p_cons_set_id => ln_cons_set_id
632 ,p_payroll_id => ln_payroll_id);
633 hr_utility.set_location(gv_package || lv_procedure_name, 20);
634
635 lv_sql_string :=
636 'select distinct paf.person_id
637 from pay_assignment_actions paa,
638 pay_payroll_actions ppa,
639 per_assignments_f paf
640 where ppa.business_group_id = ''' || ln_business_group_id || '''
641 and ppa.effective_date between fnd_date.canonical_to_date(''' ||
642 fnd_date.date_to_canonical(ld_start_date) || ''')
643 and fnd_date.canonical_to_date(''' ||
644 fnd_date.date_to_canonical(ld_end_date) || ''')
645 and ppa.action_type in (''U'',''P'',''B'',''V'')
646 and decode(ppa.action_type,
647 ''B'', nvl(ppa.future_process_mode, ''Y''),
648 ''N'') = ''N''
649 and ppa.consolidation_set_id = ''' || ln_cons_set_id || '''
650 and ppa.payroll_id = ''' || ln_payroll_id || '''
651 and ppa.payroll_action_id = paa.payroll_action_id
652 and paa.action_status = ''C''
653 and paa.source_action_id is null
654 and paf.assignment_id = paa.assignment_id
655 and ppa.effective_date between paf.effective_start_date
656 and paf.effective_end_date
657 and not exists
658 (select /*+ ORDERED */
659 1
660 from pay_action_interlocks pai,
661 pay_assignment_actions paa1,
662 pay_payroll_actions ppa1
663 where pai.locked_action_id = paa.assignment_action_id
664 and paa1.assignment_action_id = pai.locking_action_id
665 and ppa1.payroll_action_id = paa1.payroll_action_id
666 and ppa1.action_type =''X''
667 and ppa1.report_type = ''XFR_INTERFACE'')
668 and :payroll_action_id is not null
669 order by paf.person_id';
670
671 hr_utility.set_location(gv_package || lv_procedure_name, 30);
672 p_sqlstr := lv_sql_string;
673 hr_utility.set_location(gv_package || lv_procedure_name, 50);
674
675 END action_range_cursor;
676
677
678 /************************************************************
679 Name : action_action_creation
680 Purpose : This creates the assignment actions for
681 a specific chunk of people to be archived
682 by the Archiver process.
683 Arguments :
684 Notes : Calls procedure - get_payroll_action_info
685 ************************************************************/
686 PROCEDURE action_action_creation(
687 p_payroll_action_id in number
688 ,p_start_person_id in number
689 ,p_end_person_id in number
690 ,p_chunk in number)
691 IS
692
693 cursor c_get_xfr_emp( cp_start_person_id in number
694 ,cp_end_person_id in number
695 ,cp_cons_set_id in number
696 ,cp_payroll_id in number
697 ,cp_business_group_id in number
698 ,cp_start_date in date
699 ,cp_end_date in date
700 ) is
701 select /*+ INDEX(PAF PER_ASSIGNMENTS_F_N12)
702 INDEX(PPA PAY_PAYROLL_ACTIONS_N50)
703 INDEX(PAA PAY_ASSIGNMENT_ACTIONS_N51) */
704 paa.assignment_id,
705 paa.tax_unit_id,
706 ppa.effective_date,
707 ppa.date_earned,
708 ppa.action_type,
709 paa.assignment_action_id,
710 paa.payroll_action_id
711 from pay_payroll_actions ppa,
712 pay_assignment_actions paa,
713 per_assignments_f paf
714 where paf.person_id between cp_start_person_id
715 and cp_end_person_id
716 and paa.assignment_id = paf.assignment_id
717 and ppa.effective_date between paf.effective_start_date
718 and paf.effective_end_date
719 and ppa.consolidation_set_id = cp_cons_set_id
720 and paa.action_status = 'C'
721 and ppa.payroll_id = cp_payroll_id
722 and ppa.payroll_action_id = paa.payroll_action_id
723 and ppa.business_group_id = cp_business_group_id
724 and ppa.effective_date between cp_start_date
725 and cp_end_date
726 and ppa.action_type in ('U','P','B','V')
727 and decode(ppa.action_type,
728 'B', nvl(ppa.future_process_mode, 'Y'),
729 'N') = 'N'
730 and paa.source_action_id is null
731 and not exists
732 (select 'x'
733 from pay_action_interlocks pai1,
734 pay_assignment_actions paa1,
735 pay_payroll_actions ppa1
736 where pai1.locked_action_id = paa.assignment_action_id
737 and paa1.assignment_action_id = pai1.locking_action_id
738 and ppa1.payroll_action_id = paa1.payroll_action_id
739 and ppa1.action_type ='X'
740 and ppa1.report_type = 'XFR_INTERFACE')
741 order by 1,2,3,5,6;
742
743 cursor c_get_xfr_range_emp(
744 cp_payroll_action_id in number
745 ,cp_chunk_number in number
746 ,cp_cons_set_id in number
747 ,cp_payroll_id in number
748 ,cp_business_group_id in number
749 ,cp_start_date in date
750 ,cp_end_date in date
751 ) is
752 select /*+ INDEX(PPR PAY_POPULATION_RANGES_N4)
753 INDEX(PAF PER_ASSIGNMENTS_F_N12)
754 INDEX(PPA PAY_PAYROLL_ACTIONS_N50)
755 INDEX(PAA PAY_ASSIGNMENT_ACTIONS_N51) */
756 paa.assignment_id,
757 paa.tax_unit_id,
758 ppa.effective_date,
759 ppa.date_earned,
760 ppa.action_type,
761 paa.assignment_action_id,
762 paa.payroll_action_id
763 from pay_payroll_actions ppa,
764 pay_assignment_actions paa,
765 per_assignments_f paf,
766 pay_population_ranges ppr
767 where ppr.payroll_action_id = cp_payroll_action_id
768 and ppr.chunk_number = cp_chunk_number
769 and paf.person_id = ppr.person_id
770 and ppa.effective_date between paf.effective_start_date
771 and paf.effective_end_date
772 and paa.assignment_id = paf.assignment_id
773 and ppa.consolidation_set_id = cp_cons_set_id
774 and paa.action_status = 'C'
775 and ppa.payroll_id = cp_payroll_id
776 and ppa.payroll_action_id = paa.payroll_action_id
777 and ppa.business_group_id = cp_business_group_id
778 and ppa.effective_date between cp_start_date
779 and cp_end_date
780 and ppa.action_type in ('U','P','B','V')
781 and decode(ppa.action_type,
782 'B', nvl(ppa.future_process_mode, 'Y'),
783 'N') = 'N'
784 and paa.source_action_id is null
785 and not exists
786 (select 'x'
787 from pay_action_interlocks pai1,
788 pay_assignment_actions paa1,
789 pay_payroll_actions ppa1
790 where pai1.locked_action_id = paa.assignment_action_id
791 and paa1.assignment_action_id = pai1.locking_action_id
792 and ppa1.payroll_action_id = paa1.payroll_action_id
793 and ppa1.action_type ='X'
794 and ppa1.report_type = 'XFR_INTERFACE')
795 order by 1,2,3,5,6;
796
797 cursor c_master_action(cp_prepayment_action_id number) is
798 select max(paa.assignment_action_id)
799 from pay_payroll_actions ppa,
800 pay_assignment_actions paa,
801 pay_action_interlocks pai
802 where pai.locking_action_Id = cp_prepayment_action_id
803 and paa.assignment_action_id = pai.locked_action_id
804 and paa.source_action_id is null
805 and ppa.payroll_action_id = paa.payroll_action_id
806 and ppa.action_type in ('R', 'Q');
807
808 ln_assignment_id NUMBER := 0;
809 ln_tax_unit_id NUMBER := 0;
810 ld_effective_date DATE := to_date('1900/12/31','YYYY/MM/DD');
811 ld_date_earned DATE;
812 lv_action_type VARCHAR2(10);
813 ln_asg_action_id NUMBER := 0;
814 ln_payroll_action_id NUMBER := 0;
815
816 ln_master_action_id NUMBER := 0;
817
818 ld_end_date DATE;
819 ld_start_date DATE;
820 ln_business_group_id NUMBER;
821 ln_cons_set_id NUMBER;
822 ln_payroll_id NUMBER;
823
824 ln_prev_asg_action_id NUMBER := 0;
825 ln_prev_assignment_id NUMBER := 0;
826 ln_prev_tax_unit_id NUMBER := 0;
827 ld_prev_effective_date DATE := to_date('1800/12/31','YYYY/MM/DD');
828
829 ln_xfr_action_id NUMBER;
830
831 lv_serial_number VARCHAR2(30);
832 lv_procedure_name VARCHAR2(100) := '.action_action_creation';
833 lv_error_message VARCHAR2(200);
834 ln_step NUMBER;
835
836 lb_range_person BOOLEAN;
837
838 begin
839 ln_step := 1;
840 pay_emp_action_arch.gv_error_message := NULL;
841 hr_utility.set_location(gv_package || lv_procedure_name, 10);
842
843 get_payroll_action_info(p_payroll_action_id => p_payroll_action_id
844 ,p_start_date => ld_start_date
845 ,p_end_date => ld_end_date
846 ,p_business_group_id => ln_business_group_id
847 ,p_cons_set_id => ln_cons_set_id
848 ,p_payroll_id => ln_payroll_id);
849 hr_utility.set_location(gv_package || lv_procedure_name, 20);
850
851 lb_range_person := pay_ac_utility.range_person_on(
852 p_report_type => 'XFR_INTERFACE'
853 ,p_report_format => 'TAXARCH'
854 ,p_report_qualifier => 'FED'
855 ,p_report_category => 'RT');
856
857 ln_step := 2;
858 if lb_range_person then
859 open c_get_xfr_range_emp(p_payroll_action_id
860 ,p_chunk
861 ,ln_cons_set_id
862 ,ln_payroll_id
863 ,ln_business_group_id
864 ,ld_start_date
865 ,ld_end_date);
866 else
867 open c_get_xfr_emp( p_start_person_id
868 ,p_end_person_id
869 ,ln_cons_set_id
870 ,ln_payroll_id
871 ,ln_business_group_id
872 ,ld_start_date
873 ,ld_end_date);
874 end if;
875
876 -- Loop for all rows returned for SQL statement.
877 hr_utility.set_location(gv_package || lv_procedure_name, 30);
878 loop
879 if lb_range_person then
880 fetch c_get_xfr_range_emp into ln_assignment_id,
881 ln_tax_unit_id,
882 ld_effective_date,
883 ld_date_earned,
884 lv_action_type,
885 ln_asg_action_id,
886 ln_payroll_action_id;
887 exit when c_get_xfr_range_emp%notfound;
888 else
889
890 fetch c_get_xfr_emp into ln_assignment_id,
891 ln_tax_unit_id,
892 ld_effective_date,
893 ld_date_earned,
894 lv_action_type,
895 ln_asg_action_id,
896 ln_payroll_action_id;
897
898 exit when c_get_xfr_emp%notfound;
899 end if;
900
901 hr_utility.set_location(gv_package || lv_procedure_name, 40);
902 hr_utility.trace('ln_assignment_id = ' ||
903 to_char(ln_assignment_id));
904
905 /********************************************************
906 ** If Balance Adjustment, only create one assignment
907 ** action record. As there could be multiple assignment
908 ** actions for Balance Adjustment, we lock all the
909 ** balance adj record.
910 ** First time the else portion will be executed which
911 ** creates the assignment action. If the Assignment ID,
912 ** Tax Unit ID and Effective Date is same and Action
913 ** Type is Balance Adj only lock the record
914 ********************************************************/
915 if ln_assignment_id = ln_prev_assignment_id and
916 ln_tax_unit_id = ln_prev_tax_unit_id and
917 ld_effective_date = ld_prev_effective_date and
918 lv_action_type = 'B' and
919 ln_asg_action_id <> ln_prev_asg_action_id then
920
921 hr_utility.set_location(gv_package || lv_procedure_name, 50);
922 hr_utility.trace('Locking Action = ' || ln_xfr_action_id);
923 hr_utility.trace('Locked Action = ' || ln_asg_action_id);
924 hr_nonrun_asact.insint(ln_xfr_action_id
925 ,ln_asg_action_id);
926 else
927 hr_utility.set_location(gv_package || lv_procedure_name, 60);
928 hr_utility.trace('Action_type = '||lv_action_type );
929
930 select pay_assignment_actions_s.nextval
931 into ln_xfr_action_id
932 from dual;
933
934 -- insert into pay_assignment_actions.
935 hr_nonrun_asact.insact(ln_xfr_action_id,
936 ln_assignment_id,
937 p_payroll_action_id,
938 p_chunk,
939 ln_tax_unit_id,
940 null,
941 'U',
942 null);
943 hr_utility.set_location(gv_package || lv_procedure_name, 70);
944 hr_utility.trace('ln_asg_action_id = ' || ln_asg_action_id);
945 hr_utility.trace('ln_xfr_action_id = ' || ln_xfr_action_id);
946 hr_utility.trace('p_payroll_action_id = ' || p_payroll_action_id);
947 hr_utility.trace('ln_tax_unit_id = ' || ln_tax_unit_id);
948 hr_utility.set_location(gv_package || lv_procedure_name, 80);
949
950 -- insert an interlock to this action
951 hr_utility.trace('Locking Action = ' || ln_xfr_action_id);
952 hr_utility.trace('Locked Action = ' || ln_asg_action_id);
953 hr_nonrun_asact.insint(ln_xfr_action_id,
954 ln_asg_action_id);
955
956 hr_utility.set_location(gv_package || lv_procedure_name, 90);
957
958 /********************************************************
959 ** For Balance Adj we put only the first assignment action
960 ********************************************************/
961 lv_serial_number := lv_action_type || 'N' ||
962 ln_asg_action_id;
963
964 update pay_assignment_actions
965 set serial_number = lv_serial_number
966 where assignment_action_id = ln_xfr_action_id;
967
968 hr_utility.set_location(gv_package || lv_procedure_name, 100);
969
970 end if ; --ln_assignment_id ...
971
972 ln_prev_tax_unit_id := ln_tax_unit_id;
973 ld_prev_effective_date := ld_effective_date;
974 ln_prev_assignment_id := ln_assignment_id;
975 ln_prev_asg_action_id := ln_asg_action_id;
976
977 end loop;
978 if lb_range_person then
979 close c_get_xfr_range_emp;
980 else
981 close c_get_xfr_emp;
982 end if;
983
984 ln_step := 5;
985
986 EXCEPTION
987 when others then
988 lv_error_message := 'Error at step ' || ln_step || ' in ' ||
989 gv_package || lv_procedure_name;
990
991 hr_utility.trace(lv_error_message || '-' || sqlerrm);
992
993 lv_error_message :=
994 pay_emp_action_arch.set_error_message(lv_error_message);
995
996 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
997 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
998 hr_utility.raise_error;
999
1000 END action_action_creation;
1001
1002
1003 /************************************************************
1004 Name : action_archinit
1005 Purpose : This performs the context initialization.
1006 Arguments :
1007 Notes :
1008 ************************************************************/
1009 PROCEDURE action_archinit(
1010 p_payroll_action_id in number) is
1011
1012 lv_state_code VARCHAR2(2);
1013 lv_sit_exists VARCHAR2(1);
1014 lv_sdi_ee_exists VARCHAR2(1);
1015 lv_sdi_er_exists VARCHAR2(1);
1016 lv_sui_ee_exists VARCHAR2(1);
1017 lv_sui_er_exists VARCHAR2(1);
1018 ln_index NUMBER;
1019
1020 lv_jurisdiction_code VARCHAR2(11);
1021 lv_county_tax_exists VARCHAR2(1);
1022 lv_county_sd_tax_exists VARCHAR2(1);
1023 lv_county_head_tax_exists VARCHAR2(1);
1024
1025 ln_fed_count NUMBER := 0;
1026
1027 ln_state_count NUMBER := 0;
1028 -- TCL_SUI1 begin
1029 ln_state2_count NUMBER := 0;
1030 -- TCL_SUI1 end
1031
1032 ln_county_count NUMBER := 0;
1033 ln_city_count NUMBER := 0;
1034 ln_psd_count NUMBER := 0;
1035 ln_schdist_count NUMBER := 0;
1036
1037 lv_balance_name VARCHAR2(80);
1038 ln_balance_type_id NUMBER;
1039 lv_balance_dimension VARCHAR2(80);
1040
1041 ld_effective_date DATE;
1042
1043 lv_pymt_dimension VARCHAR2(50);
1044 lv_jd_pymt_dimension VARCHAR2(50);
1045 lv_subj_pymt_dimension VARCHAR2(50);
1046
1047 ld_end_date DATE;
1048 ld_start_date DATE;
1049 ln_business_group_id NUMBER;
1050 ln_cons_set_id NUMBER;
1051 ln_payroll_id NUMBER;
1052
1053 lv_error_message VARCHAR2(500);
1054 lv_procedure_name VARCHAR2(100) := '.action_archinit';
1055 ln_step NUMBER;
1056
1057 cursor c_asg_actions (cp_payroll_action_id in number) is
1058 select ppa.effective_date
1059 from pay_payroll_actions ppa
1060 where ppa.payroll_action_id = cp_payroll_action_id;
1061
1062 cursor c_get_balance_type_id (cp_balance_name in varchar2) is
1063 select balance_type_id
1064 from pay_balance_types
1065 where balance_name = cp_balance_name
1066 and legislation_code = 'US';
1067
1068 cursor c_get_balances (cp_action_context in varchar2) is
1069 select fdu.form_left_prompt, pbt.balance_type_id
1070 from fnd_descr_flex_col_usage_tl fdu,
1071 pay_balance_types pbt,
1072 fnd_application fa
1073 where fdu.descriptive_flexfield_name = 'Action Information DF'
1074 and fdu.language = 'US'
1075 and pbt.balance_name = fdu.form_left_prompt
1076 and pbt.legislation_code = 'US'
1077 and fdu.descriptive_flex_context_code = cp_action_context
1078 and fdu.form_left_prompt <> 'Resident/Non-Resident Flag'
1079 and fdu.form_left_prompt <> 'Resident Jurisdiction'
1080 and fa.application_id = fdu.application_id
1081 and fa.application_short_name = 'PAY'
1082 order by fdu.descriptive_flex_context_code, fdu.form_left_prompt;
1083
1084 cursor c_get_psd_balances (cp_action_context in varchar2) is
1085 select fdu.form_left_prompt, pbt.balance_type_id
1086 from fnd_descr_flex_col_usage_tl fdu,
1087 pay_balance_types pbt,
1088 fnd_application fa
1089 where fdu.descriptive_flexfield_name = 'Action Information DF'
1090 and fdu.language = 'US'
1091 and pbt.balance_name = substr(fdu.form_left_prompt,
1092 1 , decode(instr(fdu.form_left_prompt, 'YTD'),
1093 0, length(fdu.form_left_prompt),
1094 instr(fdu.form_left_prompt, 'YTD')-2))
1095 and pbt.legislation_code = 'US'
1096 and fdu.descriptive_flex_context_code = cp_action_context
1097 and fdu.form_left_prompt <> 'Resident/Non-Resident Flag'
1098 and fdu.form_left_prompt <> 'Resident Jurisdiction'
1099 and fa.application_id = fdu.application_id
1100 and fa.application_short_name = 'PAY'
1101 order by fdu.descriptive_flex_context_code, fdu.form_left_prompt;
1102
1103
1104 cursor c_get_states_jit (cp_effective_date in date) is
1105 select state_code,
1106 sit_exists,
1107 decode(sui_ee_wage_limit, null, 'N', 'Y'),
1108 decode(sui_er_wage_limit, null, 'N', 'Y'),
1109 decode(sdi_ee_wage_limit, null, 'N', 'Y'),
1110 decode(sdi_er_wage_limit, null, 'N', 'Y')
1111 from pay_us_state_tax_info_f
1112 where cp_effective_date between effective_start_date
1113 and effective_end_date
1114 and sta_information_category = 'State tax limit rate info'
1115 order by 1 ;
1116
1117 cursor c_get_county_jit (cp_effective_date in date) is
1118 select jurisdiction_code,
1119 county_tax,
1120 head_tax,
1121 school_tax
1122 from pay_us_county_tax_info_f
1123 where cp_effective_date between effective_start_date
1124 and effective_end_date
1125 and cnty_information_category = 'County tax status info'
1126 order by 1 ;
1127
1128 cursor c_get_act_param is
1129 select parameter_value
1130 from pay_action_parameters
1131 where parameter_name = 'INIT_PAY_ARCHIVE';
1132
1133 /* Bug 8768738 Fix */
1134 l_payroll_id NUMBER;
1135 leg_param pay_payroll_actions.legislative_parameters%TYPE;
1136 l_ppa_payroll_id pay_payroll_actions.payroll_id%TYPE;
1137 l_key varchar2(30) := 'TRANSFER_PAYROLL_ID=';
1138 l_val pay_payroll_actions.legislative_parameters%TYPE;
1139 /* Bug 8768738 Fix */
1140 BEGIN
1141 ln_step := 1;
1142 hr_utility.set_location(gv_package || lv_procedure_name, 1);
1143 pay_emp_action_arch.gv_error_message := NULL;
1144
1145 hr_utility.set_location(gv_package || lv_procedure_name, 2);
1146 get_payroll_action_info(p_payroll_action_id => p_payroll_action_id
1147 ,p_start_date => ld_start_date
1148 ,p_end_date => ld_end_date
1149 ,p_business_group_id => ln_business_group_id
1150 ,p_cons_set_id => ln_cons_set_id
1151 ,p_payroll_id => ln_payroll_id);
1152 hr_utility.set_location(gv_package || lv_procedure_name, 3);
1153
1154 /* Bug Fix 8768738 */
1155 SELECT legislative_parameters,payroll_id
1156 INTO leg_param,l_ppa_payroll_id
1157 FROM pay_payroll_actions
1158 WHERE payroll_action_id = p_payroll_action_id ;
1159
1160 if instr(leg_param, l_key) <> 0 then
1161 l_val := substr(leg_param, instr(leg_param, l_key));
1162 if instr(l_val, ' ') = 0 then
1163 l_payroll_id := substr(l_val, length(l_key)+1);
1164 else
1165 l_payroll_id := substr(l_val, length(l_key)+1, instr(l_val,' ') - length(l_key));
1166 end if;
1167 end if;
1168 hr_utility.set_location(gv_package || lv_procedure_name, 4);
1169 -- Update the Payroll Action with the Payroll ID
1170
1171 IF l_ppa_payroll_id IS NULL THEN
1172
1173 UPDATE pay_payroll_actions
1174 SET payroll_id = l_payroll_id
1175 WHERE payroll_action_id = p_payroll_action_id;
1176
1177 END IF;
1178 hr_utility.set_location(gv_package || lv_procedure_name, 5);
1179 /* Bug Fix 8768738 */
1180
1181 /*********************************************************************
1182 ** This cursor is used to call first_time_process from process_actions
1183 ** whenever it is set to either Y or end date of External Process
1184 ** Archive in YYYY/MM/DD format (canonical format).
1185 ** In other words, by setting this, it will behave like external
1186 ** process archiver is being run first time.
1187 *********************************************************************/
1188
1189 gv_act_param_val := NULL;
1190
1191 open c_get_act_param;
1192 fetch c_get_act_param into gv_act_param_val;
1193 close c_get_act_param;
1194
1195 ln_step := 2;
1196
1197 if pay_emp_action_arch.gv_multi_leg_rule is null then
1198 pay_emp_action_arch.gv_multi_leg_rule
1199 := pay_emp_action_arch.get_multi_legislative_rule('US');
1200 end if;
1201
1202 if pay_emp_action_arch.gv_multi_leg_rule = 'Y' then
1203 lv_pymt_dimension := '_ASG_PAYMENTS';
1204 lv_jd_pymt_dimension := '_ASG_PAYMENTS_JD';
1205 lv_subj_pymt_dimension := '_SUBJECT_TO_TAX_ASG_PAYMENTS';
1206 else
1207 lv_pymt_dimension := '_PAYMENTS';
1208 lv_jd_pymt_dimension := '_PAYMENTS_JD';
1209 lv_subj_pymt_dimension := '_SUBJECT_TO_TAX_PAYMENTS';
1210 end if;
1211 hr_utility.trace('pay_emp_action_arch.gv_multi_leg_rule = ' ||
1212 pay_emp_action_arch.gv_multi_leg_rule);
1213 hr_utility.trace('lv_pymt_dimension = ' || lv_pymt_dimension);
1214 hr_utility.trace('lv_jd_pymt_dimension = ' || lv_jd_pymt_dimension);
1215 hr_utility.trace('lv_subj_pymt_dimension = ' || lv_subj_pymt_dimension);
1216
1217 ln_step := 5;
1218 open c_asg_actions(p_payroll_action_id);
1219 fetch c_asg_actions into ld_effective_date;
1220 if c_asg_actions%notfound then
1221 hr_utility.set_location(gv_package || lv_procedure_name, 10);
1222 lv_error_message := 'No Assignment Actions were picked by ' ||
1223 'External Archive Process.';
1224
1225 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
1226 hr_utility.set_message_token('FORMULA_TEXT',lv_error_message);
1227 --hr_utility.raise_error;
1228 end if;
1229 close c_asg_actions;
1230
1231 hr_utility.set_location(gv_package || lv_procedure_name, 20);
1232
1233 /* Get Federal Balances */
1234 ln_step := 10;
1235 open c_get_balances('US FEDERAL');
1236 loop
1237 fetch c_get_balances into lv_balance_name, ln_balance_type_id;
1238 if c_get_balances%NOTFOUND then
1239 hr_utility.set_location(gv_package || lv_procedure_name, 30);
1240 exit;
1241 end if;
1242 hr_utility.set_location(gv_package || lv_procedure_name, 40);
1243 hr_utility.trace('lv_balance_name = ' || lv_balance_name);
1244
1245 ln_fed_count := ln_fed_count + 1;
1246 hr_utility.trace('ln_fed_count = '||ln_fed_count);
1247
1248 pay_us_action_arch.ltr_fed_tax_bal(ln_fed_count).action_info_category
1249 := 'US FEDERAL';
1250 pay_us_action_arch.ltr_fed_tax_bal(ln_fed_count).balance_name
1251 := lv_balance_name;
1252 pay_us_action_arch.ltr_fed_tax_bal(ln_fed_count).balance_type_id
1253 := ln_balance_type_id;
1254
1255 if lv_balance_name in ('Supplemental Earnings for FIT',
1256 'Supplemental Earnings for NWFIT',
1257 'Pre Tax Deductions for FIT',
1258 'Supplemental Earnings for SS',
1259 'Pre Tax Deductions for SS',
1260 'Supplemental Earnings for Medicare',
1261 'Pre Tax Deductions for Medicare',
1262 'Supplemental Earnings for FUTA',
1263 'Pre Tax Deductions for FUTA',
1264 'Supplemental Earnings for EIC',
1265 'Pre Tax Deductions for EIC') then
1266
1267 hr_utility.set_location(gv_package || lv_procedure_name, 50);
1268 pay_us_action_arch.ltr_fed_tax_bal(ln_fed_count).payment_def_bal_id
1269 := get_defined_balance_id(ln_business_group_id,
1270 lv_balance_name,
1271 lv_subj_pymt_dimension);
1272
1273 pay_us_action_arch.ltr_fed_tax_bal(ln_fed_count).asg_run_def_bal_id
1274 := get_defined_balance_id(ln_business_group_id,
1275 lv_balance_name,
1276 '_SUBJECT_TO_TAX_ASG_GRE_RUN');
1277
1278 pay_us_action_arch.ltr_fed_tax_bal(ln_fed_count).ytd_def_bal_id
1279 := get_defined_balance_id(ln_business_group_id,
1280 lv_balance_name,
1281 '_SUBJECT_TO_TAX_ASG_GRE_YTD');
1282
1283 else
1284 hr_utility.set_location(gv_package || lv_procedure_name, 60);
1285 hr_utility.trace('lv_pymt_dimension = '||lv_pymt_dimension);
1286 pay_us_action_arch.ltr_fed_tax_bal(ln_fed_count).payment_def_bal_id
1287 := get_defined_balance_id(ln_business_group_id,
1288 lv_balance_name,
1289 lv_pymt_dimension);
1290
1291 pay_us_action_arch.ltr_fed_tax_bal(ln_fed_count).asg_run_def_bal_id
1292 := get_defined_balance_id(ln_business_group_id,
1293 lv_balance_name,
1294 '_ASG_GRE_RUN');
1295
1296 pay_us_action_arch.ltr_fed_tax_bal(ln_fed_count).ytd_def_bal_id
1297 := get_defined_balance_id(ln_business_group_id,
1298 lv_balance_name,
1299 '_ASG_GRE_YTD');
1300
1301 end if;
1302 hr_utility.set_location(gv_package || lv_procedure_name, 70);
1303 end loop;
1304
1305 close c_get_balances;
1306
1307
1308 /****************************************************************
1309 Public Sector Payroll changes. The following code has
1310 been added to display and archive the FIT Alien Balances
1311 *****************************************************************/
1312 ln_step := 15;
1313 hr_utility.set_location(gv_package || lv_procedure_name, 75);
1314
1315 ln_fed_count := ln_fed_count + 1;
1316
1317 for c_rec in c_get_balance_type_id ('Non W2 FIT Withheld')
1318 loop
1319 ln_balance_type_id := c_rec.balance_type_id;
1320 end loop;
1321
1322 hr_utility.trace('ln_fed_count = ' || to_char(ln_fed_count));
1323 hr_utility.trace('ln_blance_type_id = ' || to_char(ln_balance_type_id));
1324
1325 pay_us_action_arch.ltr_fed_tax_bal(ln_fed_count).action_info_category
1326 := 'US FEDERAL';
1327 pay_us_action_arch.ltr_fed_tax_bal(ln_fed_count).balance_name
1328 := 'Non W2 FIT Withheld';
1329 pay_us_action_arch.ltr_fed_tax_bal(ln_fed_count).balance_type_id
1330 := ln_balance_type_id;
1331
1332 pay_us_action_arch.ltr_fed_tax_bal(ln_fed_count).payment_def_bal_id
1333 := get_defined_balance_id(ln_business_group_id,
1334 'Non W2 FIT Withheld',
1335 lv_pymt_dimension);
1336
1337 pay_us_action_arch.ltr_fed_tax_bal(ln_fed_count).asg_run_def_bal_id
1338 := get_defined_balance_id(ln_business_group_id,
1339 'Non W2 FIT Withheld',
1340 '_ASG_GRE_RUN');
1341
1342 pay_us_action_arch.ltr_fed_tax_bal(ln_fed_count).ytd_def_bal_id
1343 := get_defined_balance_id(ln_business_group_id,
1344 'Non W2 FIT Withheld',
1345 '_ASG_GRE_YTD');
1346
1347 /********************************************************
1348 ** Getting Defined Balance IDs for
1349 ** Gross Earnings (which is used for all normal earning
1350 ** elements) and Payments for Non Payroll Payment element.
1351 ** In archive_data, the value for an assignment action
1352 ** with these defined balances are non zero then call
1353 ** process action.
1354 ***********************************************************/
1355 gn_gross_earn_def_bal_id := nvl(get_defined_balance_id(
1356 ln_business_group_id,
1357 'Gross Earnings',
1358 '_ASG_RUN'),-1);
1359 gn_payments_def_bal_id := nvl(get_defined_balance_id(
1360 ln_business_group_id,
1361 'Payments',
1362 '_ASG_RUN'),-1);
1363
1364
1365 /****************************************************************
1366 End Public Sector Payroll changes.
1367 *****************************************************************/
1368
1369 hr_utility.set_location(gv_package || lv_procedure_name, 80);
1370
1371
1372 /* Get State Balances */
1373 ln_step := 20;
1374 open c_get_balances('US STATE');
1375 loop
1376 fetch c_get_balances into lv_balance_name, ln_balance_type_id;
1377 if c_get_balances%NOTFOUND then
1378 hr_utility.set_location(gv_package || lv_procedure_name, 90);
1379 exit;
1380 end if;
1381 hr_utility.set_location(gv_package || lv_procedure_name, 95);
1382 hr_utility.trace('lv_balance_name is '||lv_balance_name);
1383
1384 ln_state_count := ln_state_count + 1;
1385
1386 pay_us_action_arch.ltr_state_tax_bal(ln_state_count).action_info_category
1387 := 'US STATE';
1388 pay_us_action_arch.ltr_state_tax_bal(ln_state_count).balance_name
1389 := lv_balance_name;
1390 pay_us_action_arch.ltr_state_tax_bal(ln_state_count).balance_type_id
1391 := ln_balance_type_id;
1392
1393 pay_us_action_arch.ltr_state_tax_bal(ln_state_count).payment_def_bal_id
1394 := get_defined_balance_id(ln_business_group_id,
1395 lv_balance_name,
1396 lv_jd_pymt_dimension);
1397
1398 pay_us_action_arch.ltr_state_tax_bal(ln_state_count).asg_run_def_bal_id
1399 := get_defined_balance_id(ln_business_group_id,
1400 lv_balance_name,
1401 '_ASG_JD_GRE_RUN');
1402
1403 pay_us_action_arch.ltr_state_tax_bal(ln_state_count).ytd_def_bal_id
1404 := get_defined_balance_id(ln_business_group_id,
1405 lv_balance_name,
1406 '_ASG_JD_GRE_YTD');
1407
1408 hr_utility.set_location(gv_package || lv_procedure_name, 97);
1409 end loop;
1410 close c_get_balances;
1411
1412
1413 -- TCL_SUI1 begin
1414 /* NOTE The pay_us_action_arch.ltr_state2_tax_bal table is different.
1415 specifically ltr_state2_tax_bal a table structure for STATE2 */
1416 /* Get State Balances context 2*/
1417 ln_step := 23;
1418 open c_get_balances('US STATE2');
1419 loop
1420 fetch c_get_balances into lv_balance_name, ln_balance_type_id;
1421 if c_get_balances%NOTFOUND then
1422 hr_utility.set_location(gv_package || lv_procedure_name, 100);
1423 exit;
1424 end if;
1425 hr_utility.set_location(gv_package || lv_procedure_name, 105);
1426 hr_utility.trace('lv_balance_name is '||lv_balance_name);
1427
1428 ln_state2_count := ln_state2_count + 1;
1429
1430 pay_us_action_arch.ltr_state2_tax_bal(ln_state2_count).action_info_category
1431 := 'US STATE2';
1432 pay_us_action_arch.ltr_state2_tax_bal(ln_state2_count).balance_name
1433 := lv_balance_name;
1434 pay_us_action_arch.ltr_state2_tax_bal(ln_state2_count).balance_type_id
1435 := ln_balance_type_id;
1436
1437 pay_us_action_arch.ltr_state2_tax_bal(ln_state2_count).payment_def_bal_id
1438 := get_defined_balance_id(ln_business_group_id,
1439 lv_balance_name,
1440 lv_jd_pymt_dimension);
1441
1442 pay_us_action_arch.ltr_state2_tax_bal(ln_state2_count).asg_run_def_bal_id
1443 := get_defined_balance_id(ln_business_group_id,
1444 lv_balance_name,
1445 '_ASG_JD_GRE_RUN');
1446
1447 pay_us_action_arch.ltr_state2_tax_bal(ln_state2_count).ytd_def_bal_id
1448 := get_defined_balance_id(ln_business_group_id,
1449 lv_balance_name,
1450 '_ASG_JD_GRE_YTD');
1451
1452 hr_utility.set_location(gv_package || lv_procedure_name, 107);
1453 end loop;
1454 close c_get_balances;
1455
1456 -- TCL_SUI1 end
1457
1458 hr_utility.set_location(gv_package || lv_procedure_name, 120);
1459
1460 /****************************************************************
1461 Public Sector Payroll changes. The following code has
1462 been added to display and archive the SIT Alien Balances
1463 *****************************************************************/
1464 ln_step := 25;
1465 hr_utility.set_location(gv_package || lv_procedure_name, 125);
1466
1467 ln_state_count := ln_state_count + 1;
1468
1469 for c_rec in c_get_balance_type_id ('SIT Alien Withheld')
1470 loop
1471 ln_balance_type_id := c_rec.balance_type_id;
1472 end loop;
1473
1474 pay_us_action_arch.ltr_state_tax_bal(ln_state_count).action_info_category
1475 := 'US STATE';
1476 pay_us_action_arch.ltr_state_tax_bal(ln_state_count).balance_name
1477 := 'SIT Alien Withheld';
1478 pay_us_action_arch.ltr_state_tax_bal(ln_state_count).balance_type_id
1479 := ln_balance_type_id;
1480
1481 pay_us_action_arch.ltr_state_tax_bal(ln_state_count).payment_def_bal_id
1482 := get_defined_balance_id(ln_business_group_id,
1483 'SIT Alien Withheld',
1484 lv_jd_pymt_dimension);
1485
1486 pay_us_action_arch.ltr_state_tax_bal(ln_state_count).asg_run_def_bal_id
1487 := get_defined_balance_id(ln_business_group_id,
1488 'SIT Alien Withheld',
1489 '_ASG_JD_GRE_RUN');
1490
1491 pay_us_action_arch.ltr_state_tax_bal(ln_state_count).ytd_def_bal_id
1492 := get_defined_balance_id(ln_business_group_id,
1493 'SIT Alien Withheld',
1494 '_ASG_JD_GRE_YTD');
1495
1496 /****************************************************************
1497 End Public Sector Payroll changes.
1498 *****************************************************************/
1499 hr_utility.set_location(gv_package || lv_procedure_name, 126);
1500
1501
1502 /* Get County Balances */
1503 ln_step := 30;
1504 open c_get_balances('US COUNTY');
1505 loop
1506 fetch c_get_balances into lv_balance_name, ln_balance_type_id;
1507 if c_get_balances%NOTFOUND then
1508 hr_utility.set_location(gv_package || lv_procedure_name, 130);
1509 exit;
1510 end if;
1511 hr_utility.set_location(gv_package || lv_procedure_name, 140);
1512 hr_utility.trace('lv_balance_name is '||lv_balance_name);
1513
1514 ln_county_count := ln_county_count + 1;
1515
1516 pay_us_action_arch.ltr_county_tax_bal(ln_county_count).action_info_category
1517 := 'US COUNTY';
1518 pay_us_action_arch.ltr_county_tax_bal(ln_county_count).balance_name
1519 := lv_balance_name;
1520 pay_us_action_arch.ltr_county_tax_bal(ln_county_count).balance_type_id
1521 := ln_balance_type_id;
1522
1523 pay_us_action_arch.ltr_county_tax_bal(ln_county_count).payment_def_bal_id
1524 := get_defined_balance_id(ln_business_group_id,
1525 lv_balance_name,
1526 lv_jd_pymt_dimension);
1527 pay_us_action_arch.ltr_county_tax_bal(ln_county_count).asg_run_def_bal_id
1528 := get_defined_balance_id(ln_business_group_id,
1529 lv_balance_name,
1530 '_ASG_JD_GRE_RUN');
1531 pay_us_action_arch.ltr_county_tax_bal(ln_county_count).ytd_def_bal_id
1532 := get_defined_balance_id(ln_business_group_id,
1533 lv_balance_name,
1534 '_ASG_JD_GRE_YTD');
1535
1536 hr_utility.set_location(gv_package || lv_procedure_name, 150);
1537 end loop;
1538 close c_get_balances;
1539 --
1540 hr_utility.trace('Entering County Loop ' );
1541 ln_step := 35;
1542 for i in pay_us_action_arch.ltr_county_tax_bal.first ..
1543 pay_us_action_arch.ltr_county_tax_bal.last loop
1544
1545 hr_utility.trace('Count = ' || to_char(i));
1546 hr_utility.trace('Category = ' ||
1547 pay_us_action_arch.ltr_county_tax_bal(i).action_info_category);
1548 hr_utility.trace('Balance Name = ' ||
1549 pay_us_action_arch.ltr_county_tax_bal(i).balance_name);
1550 hr_utility.trace('pay_def_bal_id ' ||
1551 pay_us_action_arch.ltr_county_tax_bal(i).payment_def_bal_id);
1552 hr_utility.trace('asg_run_def_bal_id = ' ||
1553 pay_us_action_arch.ltr_county_tax_bal(i).asg_run_def_bal_id);
1554 hr_utility.trace('ytd_def_bal_id = ' ||
1555 pay_us_action_arch.ltr_county_tax_bal(i).ytd_def_bal_id);
1556 end loop;
1557 hr_utility.trace('Leaving County Loop ' );
1558 --
1559
1560 hr_utility.set_location(gv_package || lv_procedure_name, 160);
1561 /* Get City Balances */
1562 ln_step := 40;
1563 open c_get_balances('US CITY');
1564 loop
1565 fetch c_get_balances into lv_balance_name, ln_balance_type_id;
1566 if c_get_balances%notfound then
1567 hr_utility.set_location(gv_package || lv_procedure_name, 170);
1568 exit;
1569 end if;
1570 hr_utility.set_location(gv_package || lv_procedure_name, 180);
1571 hr_utility.trace('lv_balance_name is '||lv_balance_name);
1572
1573 ln_city_count := ln_city_count + 1;
1574
1575 pay_us_action_arch.ltr_city_tax_bal(ln_city_count).action_info_category
1576 := 'US CITY';
1577 pay_us_action_arch.ltr_city_tax_bal(ln_city_count).balance_name
1578 := lv_balance_name;
1579 pay_us_action_arch.ltr_city_tax_bal(ln_city_count).balance_type_id
1580 := ln_balance_type_id;
1581
1582 pay_us_action_arch.ltr_city_tax_bal(ln_city_count).payment_def_bal_id
1583 := get_defined_balance_id(ln_business_group_id,
1584 lv_balance_name,
1585 lv_jd_pymt_dimension);
1586 pay_us_action_arch.ltr_city_tax_bal(ln_city_count).asg_run_def_bal_id
1587 := get_defined_balance_id(ln_business_group_id,
1588 lv_balance_name,
1589 '_ASG_JD_GRE_RUN');
1590 pay_us_action_arch.ltr_city_tax_bal(ln_city_count).ytd_def_bal_id
1591 := get_defined_balance_id(ln_business_group_id,
1592 lv_balance_name,
1593 '_ASG_JD_GRE_YTD');
1594
1595 hr_utility.set_location(gv_package || lv_procedure_name, 190);
1596 end loop;
1597 close c_get_balances;
1598
1599 hr_utility.set_location(gv_package || lv_procedure_name, 200);
1600 /* Get School District Balances */
1601 ln_step := 45;
1602 open c_get_balances('US SCHOOL DISTRICT');
1603 loop
1604 fetch c_get_balances into lv_balance_name, ln_balance_type_id;
1605 if c_get_balances%notfound then
1606 hr_utility.set_location(gv_package || lv_procedure_name, 210);
1607 exit;
1608 end if;
1609 hr_utility.set_location(gv_package || lv_procedure_name, 220);
1610 hr_utility.trace('lv_balance_name is '||lv_balance_name);
1611
1612 ln_schdist_count := ln_schdist_count + 1;
1613
1614 pay_us_action_arch.ltr_schdist_tax_bal(ln_schdist_count).action_info_category
1615 := 'US SCHOOL DISTRICT';
1616 pay_us_action_arch.ltr_schdist_tax_bal(ln_schdist_count).balance_name
1617 := lv_balance_name;
1618 pay_us_action_arch.ltr_schdist_tax_bal(ln_schdist_count).balance_type_id
1619 := ln_balance_type_id;
1620
1621 pay_us_action_arch.ltr_schdist_tax_bal(ln_schdist_count).payment_def_bal_id
1622 := get_defined_balance_id(ln_business_group_id,
1623 lv_balance_name,
1624 lv_jd_pymt_dimension);
1625 pay_us_action_arch.ltr_schdist_tax_bal(ln_schdist_count).asg_run_def_bal_id
1626 := get_defined_balance_id(ln_business_group_id,
1627 lv_balance_name,
1628 '_ASG_JD_GRE_RUN');
1629 pay_us_action_arch.ltr_schdist_tax_bal(ln_schdist_count).ytd_def_bal_id
1630 := get_defined_balance_id(ln_business_group_id,
1631 lv_balance_name,
1632 '_ASG_JD_GRE_YTD');
1633
1634 hr_utility.set_location(gv_package || lv_procedure_name, 230);
1635 end loop;
1636 close c_get_balances;
1637
1638 -- PA32 Change begin
1639 ln_step := 47;
1640 open c_get_psd_balances('US PSD');
1641 loop
1642 fetch c_get_psd_balances into lv_balance_name, ln_balance_type_id;
1643 if c_get_psd_balances%notfound then
1644 hr_utility.set_location(gv_package || lv_procedure_name, 170);
1645 exit;
1646 end if;
1647 hr_utility.set_location(gv_package || lv_procedure_name, 180);
1648
1649 ln_psd_count := ln_psd_count + 1;
1650
1651 pay_us_action_arch.ltr_psd_tax_bal(ln_psd_count).action_info_category
1652 := 'US PSD';
1653 pay_us_action_arch.ltr_psd_tax_bal(ln_psd_count).balance_name
1654 := lv_balance_name;
1655
1656
1657 pay_us_action_arch.ltr_psd_tax_bal(ln_psd_count).balance_type_id
1658 := ln_balance_type_id;
1659
1660
1661 pay_us_action_arch.ltr_psd_tax_bal(ln_psd_count).payment_def_bal_id
1662 := get_defined_balance_id(ln_business_group_id,
1663 lv_balance_name,
1664 lv_jd_pymt_dimension);
1665
1666
1667 IF instr(lv_balance_name, 'YTD') = 0 THEN
1668
1669
1670 pay_us_action_arch.ltr_psd_tax_bal(ln_psd_count).asg_run_def_bal_id
1671 := get_defined_balance_id(ln_business_group_id,
1672 lv_balance_name,
1673 '_ASG_JD_GRE_RUN');
1674 pay_us_action_arch.ltr_psd_tax_bal(ln_psd_count).ytd_def_bal_id
1675 := NULL;
1676 ELSE
1677
1678 pay_us_action_arch.ltr_psd_tax_bal(ln_psd_count).asg_run_def_bal_id
1679 := NULL;
1680 pay_us_action_arch.ltr_psd_tax_bal(ln_psd_count).ytd_def_bal_id
1681 := get_defined_balance_id(ln_business_group_id,
1682 substr(lv_balance_name, 1 , (instr(lv_balance_name, 'YTD')-2)),
1683 '_ASG_JD_GRE_YTD');
1684 END IF;
1685
1686 hr_utility.set_location(gv_package || lv_procedure_name, 190);
1687 end loop;
1688 close c_get_psd_balances;
1689
1690 -- LOAD the global variable used to store the CITY_WK_PSD_WITHHELD_ASG_JD_GRE_RUN
1691 -- defined balance_id used to determine the resident / non resident flag
1692
1693 IF g_cty_wk_psd_wh_def_bal_id = 0 THEN
1694 g_cty_wk_psd_wh_def_bal_id := get_defined_balance_id(ln_business_group_id,
1695 'City WK PSD Withheld',
1696 '_ASG_JD_GRE_RUN');
1697 END IF;
1698
1699 -- PA32 Change end
1700
1701
1702
1703
1704
1705 hr_utility.set_location(gv_package || lv_procedure_name, 240);
1706 hr_utility.trace('Fed Balance Loop Count = ' ||
1707 pay_us_action_arch.ltr_fed_tax_bal.count);
1708 hr_utility.trace('State Balance Loop Count = ' ||
1709 pay_us_action_arch.ltr_state_tax_bal.count);
1710 hr_utility.trace('County Balance Loop Count = ' ||
1711 pay_us_action_arch.ltr_county_tax_bal.count);
1712 hr_utility.trace('City Balance Loop Count = ' ||
1713 pay_us_action_arch.ltr_city_tax_bal.count);
1714 hr_utility.trace('School Dsts Balance Loop Count = ' ||
1715 pay_us_action_arch.ltr_schdist_tax_bal.count);
1716 hr_utility.trace('PSD Balance Loop Count = ' ||
1717 pay_us_action_arch.ltr_psd_tax_bal.count);
1718
1719 hr_utility.set_location(gv_package || lv_procedure_name, 250);
1720
1721
1722 /****************************************************
1723 ** Build a PL/SQL table which has state tax info
1724 ** for all states
1725 ****************************************************/
1726 hr_utility.set_location(gv_package || lv_procedure_name, 300);
1727 ln_step := 50;
1728 open c_get_states_jit(ld_effective_date);
1729 loop
1730 fetch c_get_states_jit into lv_state_code, lv_sit_exists,
1731 lv_sui_ee_exists, lv_sui_er_exists,
1732 lv_sdi_ee_exists, lv_sdi_er_exists;
1733 if c_get_states_jit%notfound then
1734 hr_utility.set_location(gv_package || lv_procedure_name, 310);
1735 exit;
1736 end if;
1737 hr_utility.set_location(gv_package || lv_procedure_name, 320);
1738 hr_utility.trace('lv_state_code = ' || lv_state_code);
1739 hr_utility.trace('lv_sit_exists = ' || lv_sit_exists);
1740 hr_utility.trace('lv_sui_ee_exists = ' || lv_sui_ee_exists);
1741 hr_utility.trace('lv_sui_er_exists = ' || lv_sui_er_exists);
1742 hr_utility.trace('lv_sdi_ee_exists = ' || lv_sdi_ee_exists);
1743 hr_utility.trace('lv_sdi_er_exists = ' || lv_sdi_er_exists);
1744
1745 pay_us_action_arch.ltr_state_tax_info(lv_state_code).sit_exists
1746 := lv_sit_exists;
1747 pay_us_action_arch.ltr_state_tax_info(lv_state_code).sui_ee_exists
1748 := lv_sui_ee_exists;
1749 pay_us_action_arch.ltr_state_tax_info(lv_state_code).sui_er_exists
1750 := lv_sui_er_exists;
1751 pay_us_action_arch.ltr_state_tax_info(lv_state_code).sdi_ee_exists
1752 := lv_sdi_ee_exists;
1753 pay_us_action_arch.ltr_state_tax_info(lv_state_code).sdi_er_exists
1754 := lv_sdi_er_exists;
1755
1756 end loop;
1757 close c_get_states_jit;
1758
1759 hr_utility.set_location(gv_package || lv_procedure_name, 350);
1760 ln_step := 55;
1761 open c_get_county_jit(ld_effective_date);
1762 loop
1763 fetch c_get_county_jit into lv_jurisdiction_code,
1764 lv_county_tax_exists,
1765 lv_county_sd_tax_exists,
1766 lv_county_head_tax_exists;
1767 if c_get_county_jit%notfound then
1768 hr_utility.set_location(gv_package || lv_procedure_name, 360);
1769 exit;
1770 end if;
1771 hr_utility.set_location(gv_package || lv_procedure_name, 370);
1772 hr_utility.trace('lv_jurisdiction_code = ' || lv_jurisdiction_code);
1773
1774 ln_index := pay_us_action_arch.ltr_county_tax_info.count;
1775
1776 pay_us_action_arch.ltr_county_tax_info(ln_index).jurisdiction_code
1777 := lv_jurisdiction_code;
1778 pay_us_action_arch.ltr_county_tax_info(ln_index).cnty_tax_exists
1779 := lv_county_tax_exists;
1780 pay_us_action_arch.ltr_county_tax_info(ln_index).cnty_head_tax_exists
1781 := lv_county_sd_tax_exists;
1782 pay_us_action_arch.ltr_county_tax_info(ln_index).cnty_sd_tax_exists
1783 := lv_county_head_tax_exists;
1784
1785 end loop;
1786 close c_get_county_jit;
1787
1788 hr_utility.set_location(gv_package || lv_procedure_name, 400);
1789 ln_step := 60;
1790
1791 exception
1792 when others then
1793 hr_utility.set_location(gv_package || lv_procedure_name, 500);
1794 lv_error_message := 'Error at step ' || ln_step ||
1795 ' in ' || gv_package || lv_procedure_name;
1796 hr_utility.trace(lv_error_message || '-' || sqlerrm);
1797
1798 lv_error_message :=
1799 pay_emp_action_arch.set_error_message(lv_error_message);
1800
1801 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
1802 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
1803 hr_utility.raise_error;
1804
1805 END action_archinit;
1806
1807 /*********************************************************************
1808 Name : action_archdeinit
1809 Purpose : This function is the deinitialization routine for XFR_INTERFACE.
1810 Arguments : IN
1811 p_payroll_action_id number;
1812 Notes :
1813 *********************************************************************/
1814 PROCEDURE action_archdeinit(p_payroll_action_id IN NUMBER)
1815 IS
1816
1817 cursor c_effective_date (cp_payroll_action_id in number) is
1818 select effective_date
1819 from pay_payroll_actions
1820 where payroll_action_id = cp_payroll_action_id;
1821
1822 l_effective_date DATE;
1823 lv_error_message VARCHAR2(200);
1824 lv_procedure_name VARCHAR2(100) := '.deinitialization_code';
1825
1826 begin
1827 open c_effective_date (p_payroll_action_id);
1828 fetch c_effective_date into l_effective_date;
1829
1830 if c_effective_date%notfound then
1831 hr_utility.trace('Effective Date not found for p_payroll_action_id : ' || p_payroll_action_id);
1832 hr_utility.raise_error;
1833 end if;
1834 close c_effective_date;
1835
1836 pay_emp_action_arch.arch_pay_action_level_data
1837 (p_payroll_action_id => p_payroll_action_id
1838 ,p_effective_date => l_effective_date);
1839
1840 exception
1841 when others then
1842 lv_error_message := 'Error in ' ||
1843 gv_package || lv_procedure_name;
1844
1845 hr_utility.trace(lv_error_message || '-' || sqlerrm);
1846
1847 lv_error_message :=
1848 pay_emp_action_arch.set_error_message(lv_error_message);
1849
1850 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
1851 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
1852 hr_utility.raise_error;
1853 end action_archdeinit;
1854
1855
1856 /******************************************************************
1857 Name : populate_emp_hours_by_rate
1858 Purpose : The procedure set the Federal level balance value
1859 in the PL/SQL table.
1860 Arguments :
1861 Notes :
1862 ******************************************************************/
1863 PROCEDURE populate_emp_hours_by_rate(p_action_context_id in number
1864 ,p_assignment_id in number
1865 ,p_run_action_id in number)
1866 IS
1867
1868 cursor c_hbr(cp_run_action_id in number) is
1869 select hours.element_type_id,
1870 hours.element_name,
1871 hours.processing_priority,
1872 hours.rate,
1873 nvl(hours.multiple,1),
1874 hours.hours,
1875 hours.amount
1876 from pay_hours_by_rate_v hours
1877 where hours.assignment_action_id = cp_run_action_id
1878 and legislation_code = 'US'
1879 and hours.element_type_id >= 0 -- Bug 3370112
1880 order by hours.processing_priority,hours.element_type_id;
1881
1882 /*Bug# 16318258 - Start */
1883 cursor c_pymt_eff_date(cp_run_action_id in number) is
1884 select ppa.effective_date
1885 from pay_assignment_actions paa,
1886 pay_assignment_actions paa1,
1887 pay_payroll_actions ppa
1888 where paa.assignment_action_id = cp_run_action_id
1889 and paa1.assignment_action_id=to_number(substr(paa.serial_number,3))
1890 and paa1.payroll_action_id=ppa.payroll_action_id;
1891 /*Bug# 16318258 - End */
1892
1893 cursor c_retro(cp_run_action_id in number
1894 ,cp_element_type_id in number
1895 ,ln_pymt_eff_date in Date) is -- Bug# 16318258
1896 select pepd.element_entry_id,
1897 sum(decode(piv.name, 'Pay Value', prrv.result_value)),
1898 sum(decode(piv.name, 'Hours', prrv.result_value)),
1899 nvl(sum(decode(piv.name, 'Multiple', prrv.result_value)),1),
1900 sum(decode(piv.name, 'Rate', prrv.result_value))
1901 from pay_run_results prr,
1902 pay_run_result_values prrv,
1903 pay_input_values_f piv,
1904 pay_entry_process_details pepd
1905 where piv.input_value_id = prrv.input_value_id
1906 and prr.element_type_id = cp_element_type_id
1907 and prr.run_result_id = prrv.run_result_id
1908 and prr.assignment_action_id = cp_run_action_id
1909 and prr.source_type = 'E'
1910 and pepd.element_entry_id = prr.source_id
1911 and pepd.source_asg_action_id is not null
1912 and result_value is not null
1913 and ln_pymt_eff_date between piv.effective_start_date and piv.effective_end_date -- Bug# 16318258
1914 group by pepd.element_entry_id;
1915
1916 ln_element_type_id NUMBER;
1917 lv_element_name VARCHAR2(100);
1918 lv_processing_priority VARCHAR2(10);
1919 ln_rate NUMBER(15,5);
1920 ln_multiple NUMBER(15,5);
1921 ln_hours NUMBER(15,5);
1922 ln_amount NUMBER(15,5);
1923 ln_index NUMBER;
1924
1925 lv_procedure_name VARCHAR2(100);
1926 lv_error_message VARCHAR2(200);
1927
1928 ln_hrs_index NUMBER;
1929 ltr_hours_x_rate pay_ac_action_arch.hbr_table;
1930
1931 ln_retro_rate NUMBER(15,5);
1932 ln_retro_multiple NUMBER(15,5);
1933 ln_retro_hours NUMBER(15,5);
1934 ln_retro_payvalue NUMBER(15,5);
1935 ln_retro_element_entry NUMBER;
1936
1937 ln_pymt_eff_date DATE; -- Bug# 16318258
1938
1939 BEGIN
1940 --hr_utility.trace_on(null, 'HBR');
1941 lv_procedure_name := '.populate_emp_hours_by_rate';
1942 hr_utility.set_location(gv_package || lv_procedure_name, 10);
1943 ln_rate := 0;
1944 ln_hours := 0;
1945 ln_multiple := 1;
1946
1947 hr_utility.trace('p_action_context_id = ' || p_action_context_id);
1948
1949 open c_hbr(p_run_action_id);
1950 loop
1951 fetch c_hbr into ln_element_type_id
1952 ,lv_element_name
1953 ,lv_processing_priority
1954 ,ln_rate
1955 ,ln_multiple
1956 ,ln_hours
1957 ,ln_amount;
1958 hr_utility.set_location(gv_package || lv_procedure_name, 20);
1959 if c_hbr%notfound then
1960 hr_utility.set_location(gv_package || lv_procedure_name, 25);
1961 exit;
1962 end if;
1963
1964 if c_hbr%found then
1965 hr_utility.set_location(gv_package || lv_procedure_name, 30);
1966 ln_index := pay_ac_action_arch.lrr_act_tab.count;
1967 pay_ac_action_arch.lrr_act_tab(ln_index).action_info_category
1968 := 'EMPLOYEE HOURS BY RATE';
1969 pay_ac_action_arch.lrr_act_tab(ln_index).jurisdiction_code
1970 := '00-000-0000';
1971 pay_ac_action_arch.lrr_act_tab(ln_index).action_context_id
1972 := p_action_context_id;
1973 pay_ac_action_arch.lrr_act_tab(ln_index).assignment_id
1974 := p_assignment_id;
1975 pay_ac_action_arch.lrr_act_tab(ln_index).act_info1
1976 := ln_element_type_id;
1977 pay_ac_action_arch.lrr_act_tab(ln_index).act_info4
1978 := lv_element_name;
1979 pay_ac_action_arch.lrr_act_tab(ln_index).act_info5
1980 := fnd_number.number_to_canonical(ln_rate);
1981 pay_ac_action_arch.lrr_act_tab(ln_index).act_info6
1982 := fnd_number.number_to_canonical(ln_hours);
1983 pay_ac_action_arch.lrr_act_tab(ln_index).act_info7
1984 := lv_processing_priority;
1985 pay_ac_action_arch.lrr_act_tab(ln_index).act_info8
1986 := fnd_number.number_to_canonical(ln_multiple);
1987 pay_ac_action_arch.lrr_act_tab(ln_index).act_info9
1988 := fnd_number.number_to_canonical(ln_amount);
1989
1990 /******************************************************
1991 ** Insert into seperate table
1992 ******************************************************/
1993 ln_hrs_index := ltr_hours_x_rate.count;
1994 if ltr_hours_x_rate.count > 0 then
1995 for z in ltr_hours_x_rate.first .. ltr_hours_x_rate.last loop
1996 if ltr_hours_x_rate(z).element_type_id
1997 = ln_element_type_id then
1998 ln_hrs_index := z;
1999 exit;
2000 end if;
2001 end loop;
2002 end if;
2003
2004 ltr_hours_x_rate(ln_hrs_index).element_type_id := ln_element_type_id;
2005 ltr_hours_x_rate(ln_hrs_index).element_name := lv_element_name;
2006 ltr_hours_x_rate(ln_hrs_index).processing_priority := lv_processing_priority;
2007 ltr_hours_x_rate(ln_hrs_index).rate := ln_rate;
2008 ltr_hours_x_rate(ln_hrs_index).hours
2009 := nvl(ltr_hours_x_rate(ln_hrs_index).hours,0) + ln_hours;
2010 ltr_hours_x_rate(ln_hrs_index).amount
2011 := nvl(ltr_hours_x_rate(ln_hrs_index).amount,0) +
2012 ln_amount;
2013
2014 end if;
2015 end loop;
2016 close c_hbr;
2017
2018 if ltr_hours_x_rate.count > 0 then
2019 for z in ltr_hours_x_rate.first .. ltr_hours_x_rate.last loop
2020 hr_utility.trace('*******Element in Hours By Rate *************');
2021 hr_utility.trace('HBR element name = ' || ltr_hours_x_rate(z).element_name);
2022 hr_utility.trace('HBR element hour = ' || ltr_hours_x_rate(z).hours);
2023 hr_utility.trace('HBR element rate = ' || ltr_hours_x_rate(z).rate);
2024 hr_utility.trace('HBR element payvalue = ' || ltr_hours_x_rate(z).amount);
2025 end loop;
2026 end if;
2027
2028 if ltr_hours_x_rate.count > 0 then
2029 for z in ltr_hours_x_rate.first .. ltr_hours_x_rate.last loop
2030 if pay_ac_action_arch.lrr_act_tab.count > 0 then
2031 for i in pay_ac_action_arch.lrr_act_tab.first..
2032 pay_ac_action_arch.lrr_act_tab.last loop
2033 if pay_ac_action_arch.lrr_act_tab(i).action_info_category
2034 = 'AC EARNINGS' and
2035 pay_ac_action_arch.lrr_act_tab(i).action_context_id
2036 = p_action_context_id and
2037 pay_ac_action_arch.lrr_act_tab(i).act_info2
2038 = ltr_hours_x_rate(z).element_type_id then
2039 if ((ltr_hours_x_rate(z).hours <>
2040 pay_ac_action_arch.lrr_act_tab(i).act_info11) OR
2041 (ltr_hours_x_rate(z).amount <>
2042 pay_ac_action_arch.lrr_act_tab(i).act_info8)) then
2043 --call function to get the retro data
2044 hr_utility.trace('HBR diff ' || ltr_hours_x_rate(z).element_name ||
2045 ' Element ID=' || ltr_hours_x_rate(z).element_type_id ||
2046 ' AC HBR=' ||
2047 pay_ac_action_arch.lrr_act_tab(i).act_info11 ||
2048 ' HBR Hours=' || ltr_hours_x_rate(z).hours ||
2049 ' p_run_action_id='||p_run_action_id);
2050
2051 /*Bug# 16318258 - Start */
2052 open c_pymt_eff_date(p_action_context_id);
2053 fetch c_pymt_eff_date into ln_pymt_eff_date;
2054 if c_pymt_eff_date%notfound then
2055 hr_utility.trace('Effective Date not found for Prepayment_action_id :');
2056 hr_utility.raise_error;
2057 end if;
2058 close c_pymt_eff_date ;
2059 /*Bug# 16318258 - End */
2060
2061 open c_retro(p_run_action_id, ltr_hours_x_rate(z).element_type_id,ln_pymt_eff_date); -- Bug# 16318258
2062 loop
2063 hr_utility.set_location(gv_package || lv_procedure_name, 57);
2064 fetch c_retro into ln_retro_element_entry
2065 ,ln_retro_payvalue
2066 ,ln_retro_hours
2067 ,ln_retro_multiple
2068 ,ln_retro_rate;
2069 if c_retro%notfound then
2070 exit;
2071 end if;
2072
2073 hr_utility.trace('HBR Retro Values');
2074 hr_utility.trace('Pay Value='|| ln_retro_payvalue);
2075 hr_utility.trace('Hours ='|| ln_retro_hours);
2076 hr_utility.trace('Rate ='|| ln_retro_rate);
2077 hr_utility.trace('Multiple ='|| ln_retro_multiple);
2078 if ln_retro_multiple = 0 then
2079 ln_retro_multiple := 1;
2080 end if;
2081
2082 ln_index := pay_ac_action_arch.lrr_act_tab.count;
2083 pay_ac_action_arch.lrr_act_tab(ln_index).action_info_category
2084 := 'EMPLOYEE HOURS BY RATE';
2085 pay_ac_action_arch.lrr_act_tab(ln_index).jurisdiction_code
2086 := '00-000-0000';
2087 pay_ac_action_arch.lrr_act_tab(ln_index).action_context_id
2088 := p_action_context_id;
2089 pay_ac_action_arch.lrr_act_tab(ln_index).assignment_id
2090 := p_assignment_id;
2091 pay_ac_action_arch.lrr_act_tab(ln_index).act_info1
2092 := ltr_hours_x_rate(z).element_type_id;
2093 pay_ac_action_arch.lrr_act_tab(ln_index).act_info4
2094 := ltr_hours_x_rate(z).element_name;
2095 pay_ac_action_arch.lrr_act_tab(ln_index).act_info5
2096 := fnd_number.number_to_canonical(ln_retro_rate);
2097 pay_ac_action_arch.lrr_act_tab(ln_index).act_info6
2098 := fnd_number.number_to_canonical(ln_retro_hours);
2099 pay_ac_action_arch.lrr_act_tab(ln_index).act_info7
2100 := ltr_hours_x_rate(z).processing_priority;
2101 pay_ac_action_arch.lrr_act_tab(ln_index).act_info8
2102 := fnd_number.number_to_canonical(nvl(ln_retro_multiple,1));
2103 pay_ac_action_arch.lrr_act_tab(ln_index).act_info9
2104 := fnd_number.number_to_canonical(ln_retro_payvalue);
2105 hr_utility.set_location(gv_package || lv_procedure_name, 60);
2106 end loop;
2107 close c_retro;
2108 hr_utility.set_location(gv_package || lv_procedure_name, 70);
2109 end if;
2110 exit;
2111 end if;
2112 end loop;
2113 end if;
2114 end loop;
2115 end if;
2116
2117 hr_utility.set_location(gv_package || lv_procedure_name, 100);
2118 --hr_utility.trace_off;
2119
2120 EXCEPTION
2121 when others then
2122 lv_error_message := 'Error in ' ||
2123 gv_package || lv_procedure_name;
2124
2125 hr_utility.trace(lv_error_message || '-' || sqlerrm);
2126
2127 lv_error_message :=
2128 pay_emp_action_arch.set_error_message(lv_error_message);
2129
2130 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
2131 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
2132 hr_utility.raise_error;
2133
2134 END populate_emp_hours_by_rate;
2135
2136
2137 /**************************************************************
2138 Name : update_federal_values
2139 Purpose : The procedure set the Federal level balance value
2140 in the PL/SQL table.
2141 Arguments :
2142 Notes :
2143 **************************************************************/
2144 PROCEDURE update_federal_values(p_balance in varchar2
2145 ,p_bal_value in number
2146 ,p_index in number
2147 ,p_category in varchar2
2148 )
2149 IS
2150 lv_procedure_name VARCHAR2(100) := '.update_federal_values';
2151 lv_error_message VARCHAR2(200);
2152
2153 BEGIN
2154 hr_utility.set_location(gv_package || lv_procedure_name, 10);
2155 hr_utility.trace('p_index = '|| pay_ac_action_arch.lrr_act_tab.count);
2156 hr_utility.trace('p_balance = '|| p_balance);
2157 hr_utility.trace('ln_bal_value = ' || p_bal_value);
2158
2159 pay_ac_action_arch.lrr_act_tab(p_index).action_info_category
2160 := p_category;
2161 pay_ac_action_arch.lrr_act_tab(p_index).jurisdiction_code
2162 := '00-000-0000';
2163
2164 if p_balance = 'FIT Withheld' then
2165 pay_ac_action_arch.lrr_act_tab(p_index).act_info1 :=
2166 nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info1,0)
2167 + p_bal_value ;
2168 elsif p_balance = 'Regular Earnings' then
2169 pay_ac_action_arch.lrr_act_tab(p_index).act_info2 :=
2170 nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info2,0)
2171 + p_bal_value;
2172 elsif p_balance = 'Supplemental Earnings for FIT' then
2173 pay_ac_action_arch.lrr_act_tab(p_index).act_info3 :=
2174 nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info3,0)
2175 + p_bal_value;
2176 elsif p_balance = 'Supplemental Earnings for NWFIT' then
2177 pay_ac_action_arch.lrr_act_tab(p_index).act_info4 :=
2178 nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info4,0)
2179 + p_bal_value;
2180 elsif p_balance = 'Pre Tax Deductions' then
2181 pay_ac_action_arch.lrr_act_tab(p_index).act_info5 :=
2182 nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info5,0)
2183 + p_bal_value;
2184 elsif p_balance = 'Pre Tax Deductions for FIT' then
2185 pay_ac_action_arch.lrr_act_tab(p_index).act_info6 :=
2186 nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info6,0)
2187 + p_bal_value;
2188 elsif p_balance = 'SS EE Taxable' then
2189 pay_ac_action_arch.lrr_act_tab(p_index).act_info7 :=
2190 nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info7,0)
2191 + p_bal_value;
2192 elsif p_balance = 'SS EE Withheld' then
2193 pay_ac_action_arch.lrr_act_tab(p_index).act_info8 :=
2194 nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info8,0)
2195 + p_bal_value;
2196 elsif p_balance = 'SS ER Liability' then
2197 pay_ac_action_arch.lrr_act_tab(p_index).act_info9 :=
2198 nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info9,0)
2199 + p_bal_value ;
2200 elsif p_balance = 'SS ER Taxable' then
2201 pay_ac_action_arch.lrr_act_tab(p_index).act_info10 :=
2202 nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info10,0)
2203 + p_bal_value ;
2204 elsif p_balance = 'Supplemental Earnings for SS' then
2205 pay_ac_action_arch.lrr_act_tab(p_index).act_info11 :=
2206 nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info11,0)
2207 + p_bal_value;
2208 elsif p_balance = 'Pre Tax Deductions for SS' then
2209 pay_ac_action_arch.lrr_act_tab(p_index).act_info12 :=
2210 nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info12,0)
2211 + p_bal_value;
2212 elsif p_balance = 'Medicare EE Taxable' then
2213 pay_ac_action_arch.lrr_act_tab(p_index).act_info13 :=
2214 nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info13,0)
2215 + p_bal_value;
2216 elsif p_balance = 'Medicare EE Withheld' then
2217 pay_ac_action_arch.lrr_act_tab(p_index).act_info14 :=
2218 nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info14,0)
2219 + p_bal_value;
2220 elsif p_balance = 'Medicare ER Liability' then
2221 pay_ac_action_arch.lrr_act_tab(p_index).act_info15 :=
2222 nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info15,0)
2223 + p_bal_value ;
2224 elsif p_balance = 'Medicare ER Taxable' then
2225 pay_ac_action_arch.lrr_act_tab(p_index).act_info16 :=
2226 nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info16,0)
2227 + p_bal_value;
2228 elsif p_balance = 'Supplemental Earnings for Medicare' then
2229 pay_ac_action_arch.lrr_act_tab(p_index).act_info17 :=
2230 nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info17,0)
2231 + p_bal_value;
2232 elsif p_balance = 'Pre Tax Deductions for Medicare' then
2233 pay_ac_action_arch.lrr_act_tab(p_index).act_info18 :=
2234 nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info18,0)
2235 + p_bal_value;
2236 elsif p_balance = 'Supplemental Earnings for FUTA' then
2237 pay_ac_action_arch.lrr_act_tab(p_index).act_info19 :=
2238 nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info19,0)
2239 + p_bal_value;
2240 elsif p_balance = 'Pre Tax Deductions for FUTA' then
2241 pay_ac_action_arch.lrr_act_tab(p_index).act_info20 :=
2242 nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info20,0)
2243 + p_bal_value;
2244 elsif p_balance = 'FUTA Taxable' then
2245 pay_ac_action_arch.lrr_act_tab(p_index).act_info21 :=
2246 nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info21,0)
2247 + p_bal_value;
2248 elsif p_balance = 'FUTA Liability' then
2249 pay_ac_action_arch.lrr_act_tab(p_index).act_info22 :=
2250 nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info22,0)
2251 + p_bal_value;
2252 elsif p_balance = 'Gross Earnings' then
2253 pay_ac_action_arch.lrr_act_tab(p_index).act_info23 :=
2254 nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info23,0)
2255 + p_bal_value;
2256 elsif p_balance = 'Pre Tax Deductions for EIC' then
2257 pay_ac_action_arch.lrr_act_tab(p_index).act_info24 :=
2258 nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info24,0)
2259 + p_bal_value;
2260 elsif p_balance = 'Supplemental Earnings for EIC' then
2261 pay_ac_action_arch.lrr_act_tab(p_index).act_info25 :=
2262 nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info25,0)
2263 + p_bal_value;
2264 elsif p_balance = 'EIC Advance' then
2265 pay_ac_action_arch.lrr_act_tab(p_index).act_info26 :=
2266 nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info26,0)
2267 + p_bal_value;
2268 /* Added for Bug#14793173 */
2269 elsif p_balance = 'Medicare EE Taxable Over Limit' then
2270 pay_ac_action_arch.lrr_act_tab(p_index).act_info27 :=
2271 nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info27,0)
2272 + p_bal_value;
2273 end if;
2274
2275 hr_utility.set_location(gv_package || lv_procedure_name, 100);
2276
2277 EXCEPTION
2278 when others then
2279 lv_error_message := 'Error in ' ||
2280 gv_package || lv_procedure_name;
2281
2282 hr_utility.trace(lv_error_message || '-' || sqlerrm);
2283
2284 lv_error_message :=
2285 pay_emp_action_arch.set_error_message(lv_error_message);
2286
2287 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
2288 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
2289 hr_utility.raise_error;
2290
2291 END update_federal_values;
2292
2293
2294 /**************************************************************
2295 Name : update_sit_values
2296 Purpose : The procedure set the SIT level balance value
2297 in the PL/SQL table.
2298 Arguments :
2299 Notes :
2300 **************************************************************/
2301 PROCEDURE update_sit_values(p_balance in varchar2
2302 ,p_bal_value in number
2303 ,p_index in number
2304 )
2305 IS
2306 lv_procedure_name VARCHAR2(100) := '.update_sit_values';
2307 lv_error_message VARCHAR2(200);
2308
2309 BEGIN
2310 hr_utility.set_location(gv_package || lv_procedure_name, 10);
2311 hr_utility.trace('p_index = '|| pay_ac_action_arch.lrr_act_tab.count);
2312 hr_utility.trace('p_balance = '|| p_balance);
2313 hr_utility.trace('p_bal_value = ' || p_bal_value);
2314
2315 if p_balance = 'SIT Withheld' then
2316 pay_ac_action_arch.lrr_act_tab(p_index).act_info1
2317 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info1,0) +
2318 p_bal_value ;
2319 elsif p_balance = 'SIT Subj Whable' then
2320 pay_ac_action_arch.lrr_act_tab(p_index).act_info2
2321 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info2,0) +
2322 p_bal_value;
2323 elsif p_balance = 'SIT Subj NWhable' then
2324 pay_ac_action_arch.lrr_act_tab(p_index).act_info3
2325 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info3,0) +
2326 p_bal_value;
2327 elsif p_balance = 'SIT Pre Tax Redns' then
2328 pay_ac_action_arch.lrr_act_tab(p_index).act_info4
2329 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info4,0) +
2330 p_bal_value;
2331 elsif p_balance = 'SIT Gross' then
2332 pay_ac_action_arch.lrr_act_tab(p_index).act_info17
2333 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info17,0) +
2334 p_bal_value ;
2335 end if;
2336
2337 hr_utility.set_location(gv_package || lv_procedure_name, 100);
2338
2339 EXCEPTION
2340 when others then
2341 lv_error_message := 'Error in ' ||
2342 gv_package || lv_procedure_name;
2343
2344 hr_utility.trace(lv_error_message || '-' || sqlerrm);
2345
2346 lv_error_message :=
2347 pay_emp_action_arch.set_error_message(lv_error_message);
2348
2349 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
2350 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
2351 hr_utility.raise_error;
2352
2353 END update_sit_values;
2354
2355
2356 /**************************************************************
2357 Name : update_sdi_ee_values
2358 Purpose : The procedure set the SDI EE level balance value
2359 in the PL/SQL table.
2360 Arguments :
2361 Notes :
2362 **************************************************************/
2363 PROCEDURE update_sdi_ee_values(p_balance in varchar2
2364 ,p_bal_value in number
2365 ,p_index in number
2366 )
2367 IS
2368 lv_procedure_name VARCHAR2(100) := '.update_sdi_ee_values';
2369 lv_error_message VARCHAR2(200);
2370
2371 BEGIN
2372 hr_utility.set_location(gv_package || lv_procedure_name, 10);
2373 hr_utility.trace('p_index = '|| pay_ac_action_arch.lrr_act_tab.count);
2374 hr_utility.trace('p_balance = '|| p_balance);
2375 hr_utility.trace('p_bal_value = ' || p_bal_value);
2376
2377 if p_balance = 'SDI EE Withheld' then
2378 pay_ac_action_arch.lrr_act_tab(p_index).act_info5
2379 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info5,0) +
2380 p_bal_value ;
2381 elsif p_balance = 'SDI EE Taxable' then
2382 pay_ac_action_arch.lrr_act_tab(p_index).act_info6
2383 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info6,0) +
2384 p_bal_value;
2385 elsif p_balance = 'SDI EE Subj Whable' then
2386 pay_ac_action_arch.lrr_act_tab(p_index).act_info7
2387 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info7,0) +
2388 p_bal_value;
2389 elsif p_balance = 'SDI EE Pre Tax Redns' then
2390 pay_ac_action_arch.lrr_act_tab(p_index).act_info8
2391 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info8,0) +
2392 p_bal_value;
2393 elsif p_balance = 'SDI EE Gross' then
2394 pay_ac_action_arch.lrr_act_tab(p_index).act_info26
2395 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info26,0) +
2396 p_bal_value ;
2397 end if;
2398
2399 hr_utility.set_location(gv_package || lv_procedure_name, 100);
2400
2401 EXCEPTION
2402 when others then
2403 lv_error_message := 'Error in ' ||
2404 gv_package || lv_procedure_name;
2405
2406 hr_utility.trace(lv_error_message || '-' || sqlerrm);
2407
2408 lv_error_message :=
2409 pay_emp_action_arch.set_error_message(lv_error_message);
2410
2411 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
2412 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
2413 hr_utility.raise_error;
2414
2415
2416 END update_sdi_ee_values;
2417
2418
2419
2420 /**************************************************************
2421 Name : update_sdi_er_values
2422 Purpose : The procedure set the SDI ER level balance value
2423 in the PL/SQL table.
2424 Arguments :
2425 Notes :
2426 **************************************************************/
2427 PROCEDURE update_sdi_er_values(p_balance in varchar2
2428 ,p_bal_value in number
2429 ,p_index in number
2430 )
2431 IS
2432 lv_procedure_name VARCHAR2(100) := '.update_sdi_ee_values';
2433 lv_error_message VARCHAR2(200);
2434
2435 BEGIN
2436 hr_utility.set_location(gv_package || lv_procedure_name, 10);
2437 hr_utility.trace('p_index = '|| pay_ac_action_arch.lrr_act_tab.count);
2438 hr_utility.trace('p_balance = '|| p_balance);
2439 hr_utility.trace('p_bal_value = ' || p_bal_value);
2440
2441 if p_balance = 'SDI ER Liability' then
2442 pay_ac_action_arch.lrr_act_tab(p_index).act_info9
2443 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info9,0) +
2444 p_bal_value;
2445 elsif p_balance = 'SDI ER Taxable' then
2446 pay_ac_action_arch.lrr_act_tab(p_index).act_info10
2447 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info10,0) +
2448 p_bal_value;
2449 elsif p_balance = 'SDI ER Subj Whable' then
2450 pay_ac_action_arch.lrr_act_tab(p_index).act_info11
2451 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info11,0) +
2452 p_bal_value;
2453 elsif p_balance = 'SDI ER Pre Tax Redns' then
2454 pay_ac_action_arch.lrr_act_tab(p_index).act_info12
2455 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info12,0) +
2456 p_bal_value ;
2457 elsif p_balance = 'SDI ER Gross' then
2458 pay_ac_action_arch.lrr_act_tab(p_index).act_info27
2459 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info27,0) +
2460 p_bal_value;
2461 end if;
2462
2463 hr_utility.set_location(gv_package || lv_procedure_name, 100);
2464
2465 EXCEPTION
2466 when others then
2467 lv_error_message := 'Error in ' ||
2468 gv_package || lv_procedure_name;
2469
2470 hr_utility.trace(lv_error_message || '-' || sqlerrm);
2471
2472 lv_error_message :=
2473 pay_emp_action_arch.set_error_message(lv_error_message);
2474
2475 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
2476 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
2477 hr_utility.raise_error;
2478
2479 END update_sdi_er_values;
2480
2481
2482 /**************************************************************
2483 Name : update_sui_ee_values
2484 Purpose : The procedure set the SUI EE level balance value
2485 in the PL/SQL table.
2486 Arguments :
2487 Notes :
2488 **************************************************************/
2489 PROCEDURE update_sui_ee_values(p_balance in varchar2
2490 ,p_bal_value in number
2491 ,p_index in number
2492 )
2493 IS
2494 lv_procedure_name VARCHAR2(100) := '.update_sui_ee_values';
2495 lv_error_message VARCHAR2(200);
2496
2497 BEGIN
2498 hr_utility.set_location(gv_package || lv_procedure_name, 10);
2499 hr_utility.trace('p_index = '|| pay_ac_action_arch.lrr_act_tab.count);
2500 hr_utility.trace('p_balance = '|| p_balance);
2501 hr_utility.trace('p_bal_value = ' || p_bal_value);
2502
2503 if p_balance = 'SUI EE Withheld' then
2504 pay_ac_action_arch.lrr_act_tab(p_index).act_info13
2505 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info13,0) +
2506 p_bal_value;
2507 elsif p_balance = 'SUI EE Taxable' then
2508 pay_ac_action_arch.lrr_act_tab(p_index).act_info14
2509 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info14,0) +
2510 p_bal_value;
2511 elsif p_balance = 'SUI EE Subj Whable' then
2512 pay_ac_action_arch.lrr_act_tab(p_index).act_info15
2513 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info15,0) +
2514 p_bal_value;
2515 elsif p_balance = 'SUI EE Pre Tax Redns' then
2516 pay_ac_action_arch.lrr_act_tab(p_index).act_info16
2517 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info16,0) +
2518 p_bal_value;
2519 elsif p_balance = 'SUI EE Gross' then
2520 pay_ac_action_arch.lrr_act_tab(p_index).act_info28
2521 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info28,0) +
2522 p_bal_value;
2523 end if;
2524 hr_utility.set_location(gv_package || lv_procedure_name, 100);
2525
2526 EXCEPTION
2527 when others then
2528 lv_error_message := 'Error in ' ||
2529 gv_package || lv_procedure_name;
2530
2531 hr_utility.trace(lv_error_message || '-' || sqlerrm);
2532
2533 lv_error_message :=
2534 pay_emp_action_arch.set_error_message(lv_error_message);
2535
2536 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
2537 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
2538 hr_utility.raise_error;
2539
2540 END update_sui_ee_values;
2541
2542 --TCL_SUI1 begin
2543
2544 /**************************************************************
2545 Name : update_sui_ee_values
2546 Purpose : The procedure set the SUI EE level balance value
2547 in the PL/SQL table.
2548 Arguments :
2549 Notes : 04-DEC-2008 Only SUI1 EE Withheld maintained
2550 however, kept all balance's for future need.
2551 **************************************************************/
2552 PROCEDURE update_sui1_ee_values(p_balance in varchar2
2553 ,p_bal_value in number
2554 ,p_index in number
2555 )
2556 IS
2557 lv_procedure_name VARCHAR2(100) := '.update_sui1_ee_values';
2558 lv_error_message VARCHAR2(200);
2559
2560 BEGIN
2561 hr_utility.set_location(gv_package || lv_procedure_name, 10);
2562 hr_utility.trace('p_index = '|| pay_ac_action_arch.lrr_act_tab.count);
2563 hr_utility.trace('p_balance = '|| p_balance);
2564 hr_utility.trace('p_bal_value = ' || p_bal_value);
2565
2566 if p_balance = 'SUI1 EE Withheld' then
2567 pay_ac_action_arch.lrr_act_tab(p_index).act_info2
2568 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info2,0) +
2569 p_bal_value;
2570
2571 /* Not used as of 08-dec-08
2572
2573 elsif p_balance = 'SUI1 EE Taxable' then
2574 pay_ac_action_arch.lrr_act_tab(p_index).act_info14
2575 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info14,0) +
2576 p_bal_value;
2577 elsif p_balance = 'SUI1 EE Subj Whable' then
2578 pay_ac_action_arch.lrr_act_tab(p_index).act_info15
2579 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info15,0) +
2580 p_bal_value;
2581 elsif p_balance = 'SUI1 EE Pre Tax Redns' then
2582 pay_ac_action_arch.lrr_act_tab(p_index).act_info16
2583 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info16,0) +
2584 p_bal_value;
2585 elsif p_balance = 'SUI1 EE Gross' then
2586 pay_ac_action_arch.lrr_act_tab(p_index).act_info28
2587 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info28,0) +
2588 p_bal_value;
2589 */
2590 end if;
2591 hr_utility.set_location(gv_package || lv_procedure_name, 100);
2592
2593 EXCEPTION
2594 when others then
2595 lv_error_message := 'Error in ' ||
2596 gv_package || lv_procedure_name;
2597
2598 hr_utility.trace(lv_error_message || '-' || sqlerrm);
2599
2600 lv_error_message :=
2601 pay_emp_action_arch.set_error_message(lv_error_message);
2602
2603 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
2604 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
2605 hr_utility.raise_error;
2606
2607 END update_sui1_ee_values;
2608
2609 /**************************************************************
2610 Name : update_sdi_ee_values
2611 Purpose : The procedure set the SDI EE level balance value
2612 in the PL/SQL table.
2613 Arguments :
2614 Notes : 04-DEC-2008 Only SDI1 EE Withheld maintained
2615 however, kept all balance's for future need.
2616 **************************************************************/
2617 PROCEDURE update_sdi1_ee_values(p_balance in varchar2
2618 ,p_bal_value in number
2619 ,p_index in number
2620 )
2621 IS
2622 lv_procedure_name VARCHAR2(100) := '.update_sdi1_ee_values';
2623 lv_error_message VARCHAR2(200);
2624
2625 BEGIN
2626 hr_utility.set_location(gv_package || lv_procedure_name, 10);
2627 hr_utility.trace('p_index = '|| pay_ac_action_arch.lrr_act_tab.count);
2628 hr_utility.trace('p_balance = '|| p_balance);
2629 hr_utility.trace('p_bal_value = ' || p_bal_value);
2630
2631 if p_balance = 'SDI1 EE Withheld' then
2632 pay_ac_action_arch.lrr_act_tab(p_index).act_info1
2633 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info1,0) +
2634 p_bal_value;
2635
2636 /* Not used as of 08-dec-08
2637
2638 elsif p_balance = 'SDI1 EE Taxable' then
2639 pay_ac_action_arch.lrr_act_tab(p_index).act_info14
2640 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info14,0) +
2641 p_bal_value;
2642 elsif p_balance = 'SDI1 EE Subj Whable' then
2643 pay_ac_action_arch.lrr_act_tab(p_index).act_info15
2644 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info15,0) +
2645 p_bal_value;
2646 elsif p_balance = 'SDI1 EE Pre Tax Redns' then
2647 pay_ac_action_arch.lrr_act_tab(p_index).act_info16
2648 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info16,0) +
2649 p_bal_value;
2650 elsif p_balance = 'SDI1 EE Gross' then
2651 pay_ac_action_arch.lrr_act_tab(p_index).act_info28
2652 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info28,0) +
2653 p_bal_value;
2654 */
2655 end if;
2656 hr_utility.set_location(gv_package || lv_procedure_name, 100);
2657
2658 EXCEPTION
2659 when others then
2660 lv_error_message := 'Error in ' ||
2661 gv_package || lv_procedure_name;
2662
2663 hr_utility.trace(lv_error_message || '-' || sqlerrm);
2664
2665 lv_error_message :=
2666 pay_emp_action_arch.set_error_message(lv_error_message);
2667
2668 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
2669 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
2670 hr_utility.raise_error;
2671
2672 END update_sdi1_ee_values;
2673
2674 --TCL_SUI1 end
2675
2676 /**************************************************************
2677 Name : update_sui_er_values
2678 Purpose : The procedure set the SUI ER level balance value
2679 in the PL/SQL table.
2680 Arguments :
2681 Notes :
2682 **************************************************************/
2683 PROCEDURE update_sui_er_values(p_balance in varchar2
2684 ,p_bal_value in number
2685 ,p_index in number
2686 )
2687 IS
2688 lv_procedure_name VARCHAR2(100) := '.update_sui_er_values';
2689 lv_error_message VARCHAR2(200);
2690
2691 BEGIN
2692 hr_utility.set_location(gv_package || lv_procedure_name, 10);
2693 hr_utility.trace('p_index = '|| pay_ac_action_arch.lrr_act_tab.count);
2694 hr_utility.trace('p_balance = '|| p_balance);
2695 hr_utility.trace('p_bal_value = ' || p_bal_value);
2696
2697 if p_balance = 'SUI ER Taxable' then
2698 pay_ac_action_arch.lrr_act_tab(p_index).act_info18
2699 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info18,0)
2700 + p_bal_value;
2701 elsif p_balance = 'SUI ER Subj Whable' then
2702 pay_ac_action_arch.lrr_act_tab(p_index).act_info19
2703 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info19,0)
2704 + p_bal_value;
2705 elsif p_balance = 'SUI ER Pre Tax Redns' then
2706 pay_ac_action_arch.lrr_act_tab(p_index).act_info20
2707 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info20,0)
2708 + p_bal_value;
2709 elsif p_balance = 'SUI ER Liability' then
2710 pay_ac_action_arch.lrr_act_tab(p_index).act_info21
2711 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info21,0)
2712 + p_bal_value;
2713 elsif p_balance = 'SUI ER Gross' then
2714 pay_ac_action_arch.lrr_act_tab(p_index).act_info29
2715 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info29,0)
2716 + p_bal_value;
2717 end if;
2718 hr_utility.set_location(gv_package || lv_procedure_name, 100);
2719
2720 EXCEPTION
2721 when others then
2722 lv_error_message := 'Error in ' ||
2723 gv_package || lv_procedure_name;
2724
2725 hr_utility.trace(lv_error_message || '-' || sqlerrm);
2726
2727 lv_error_message :=
2728 pay_emp_action_arch.set_error_message(lv_error_message);
2729
2730 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
2731 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
2732 hr_utility.raise_error;
2733
2734 END update_sui_er_values;
2735
2736
2737 /**************************************************************
2738 Name : update_work_comp_values
2739 Purpose : The procedure set the Worker's Comp level balance
2740 value in the PL/SQL table.
2741 Arguments :
2742 Notes :
2743 **************************************************************/
2744 PROCEDURE update_work_comp_values(p_balance in varchar2
2745 ,p_bal_value in number
2746 ,p_index in number
2747 )
2748 IS
2749 lv_procedure_name VARCHAR2(100) := '.update_work_comp_values';
2750 lv_error_message VARCHAR2(200);
2751
2752 BEGIN
2753 hr_utility.set_location(gv_package || lv_procedure_name, 10);
2754 hr_utility.trace('p_index = '|| pay_ac_action_arch.lrr_act_tab.count);
2755 hr_utility.trace('p_balance = '|| p_balance);
2756 hr_utility.trace('p_bal_value = ' || p_bal_value);
2757
2758 if p_balance = 'Workers Comp Withheld' then
2759 pay_ac_action_arch.lrr_act_tab(p_index).act_info22
2760 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info22,0) +
2761 p_bal_value ;
2762 elsif p_balance = 'Workers Comp2 Withheld' then
2763 pay_ac_action_arch.lrr_act_tab(p_index).act_info23
2764 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info23,0) +
2765 p_bal_value;
2766 elsif p_balance = 'Workers Compensation2 ER' then
2767 pay_ac_action_arch.lrr_act_tab(p_index).act_info24
2768 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info24,0) +
2769 p_bal_value;
2770 elsif p_balance = 'Workers Compensation3 ER' then
2771 pay_ac_action_arch.lrr_act_tab(p_index).act_info25
2772 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info25,0) +
2773 p_bal_value;
2774 end if;
2775 hr_utility.set_location(gv_package || lv_procedure_name, 100);
2776
2777 EXCEPTION
2778 when others then
2779 lv_error_message := 'Error in ' ||
2780 gv_package || lv_procedure_name;
2781
2782 hr_utility.trace(lv_error_message || '-' || sqlerrm);
2783
2784 lv_error_message :=
2785 pay_emp_action_arch.set_error_message(lv_error_message);
2786
2787 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
2788 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
2789 hr_utility.raise_error;
2790
2791 END update_work_comp_values;
2792
2793 /*Bug 3231253*/
2794 /**************************************************************
2795 Name : update_steic_values
2796 Purpose : The procedure sets the STEIC Advance balance value
2797 in the PL/SQL table.
2798 Arguments :
2799 Notes :
2800 **************************************************************/
2801 PROCEDURE update_steic_values(p_balance in varchar2
2802 ,p_bal_value in number
2803 ,p_index in number
2804 )
2805 IS
2806 lv_procedure_name VARCHAR2(100) := '.update_steic_values';
2807 lv_error_message VARCHAR2(200);
2808
2809 BEGIN
2810 hr_utility.set_location(gv_package || lv_procedure_name, 10);
2811 hr_utility.trace('p_index = '|| pay_ac_action_arch.lrr_act_tab.count);
2812 hr_utility.trace('p_balance = '|| p_balance);
2813 hr_utility.trace('p_bal_value = ' || p_bal_value);
2814
2815 if p_balance = 'STEIC Advance' then
2816 pay_ac_action_arch.lrr_act_tab(p_index).act_info30
2817 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info30,0) +
2818 p_bal_value ;
2819 end if;
2820
2821 hr_utility.set_location(gv_package || lv_procedure_name, 100);
2822
2823 EXCEPTION
2824 when others then
2825 lv_error_message := 'Error in ' ||
2826 gv_package || lv_procedure_name;
2827
2828 hr_utility.trace(lv_error_message || '-' || sqlerrm);
2829
2830 lv_error_message :=
2831 pay_emp_action_arch.set_error_message(lv_error_message);
2832
2833 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
2834 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
2835 hr_utility.raise_error;
2836
2837 END update_steic_values;
2838
2839
2840 /**************************************************************
2841 Name : update_county_values
2842 Purpose : The procedure set the County level balance value
2843 in the PL/SQL table.
2844 Arguments :
2845 Notes :
2846 **************************************************************/
2847 PROCEDURE update_county_values(p_balance in varchar2
2848 ,p_bal_value in number
2849 ,p_index in number
2850 )
2851 IS
2852 lv_procedure_name VARCHAR2(100) := '.update_county_values';
2853 lv_error_message VARCHAR2(200);
2854
2855 BEGIN
2856 hr_utility.set_location(gv_package || lv_procedure_name, 10);
2857 hr_utility.trace('p_index = '|| pay_ac_action_arch.lrr_act_tab.count);
2858 hr_utility.trace('p_balance = '|| p_balance);
2859 hr_utility.trace('p_bal_value = ' || p_bal_value);
2860
2861 if p_balance = 'County Withheld' then
2862 pay_ac_action_arch.lrr_act_tab(p_index ).act_info1
2863 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info1,0) +
2864 p_bal_value ;
2865 elsif p_balance = 'County Subj Whable' then
2866 pay_ac_action_arch.lrr_act_tab(p_index).act_info2
2867 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info2,0) +
2868 p_bal_value;
2869 elsif p_balance = 'County Subj NWhable' then
2870 pay_ac_action_arch.lrr_act_tab(p_index).act_info3
2871 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info3,0) +
2872 p_bal_value;
2873 elsif p_balance = 'County Pre Tax Redns' then
2874 pay_ac_action_arch.lrr_act_tab(p_index).act_info4
2875 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info4,0) +
2876 p_bal_value;
2877 elsif p_balance = 'County Gross' then
2878 pay_ac_action_arch.lrr_act_tab(p_index).act_info7
2879 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info7,0) +
2880 p_bal_value ;
2881 end if;
2882 hr_utility.set_location(gv_package || lv_procedure_name, 100);
2883
2884 EXCEPTION
2885 when others then
2886 lv_error_message := 'Error in ' ||
2887 gv_package || lv_procedure_name;
2888
2889 hr_utility.trace(lv_error_message || '-' || sqlerrm);
2890
2891 lv_error_message :=
2892 pay_emp_action_arch.set_error_message(lv_error_message);
2893
2894 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
2895 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
2896 hr_utility.raise_error;
2897
2898 END update_county_values;
2899
2900
2901 /**************************************************************
2902 Name : update_county_head_values
2903 Purpose : The procedure set the County Head level balance
2904 values in the PL/SQL table.
2905 Arguments :
2906 Notes :
2907 **************************************************************/
2908 PROCEDURE update_county_head_values(p_balance in varchar2
2909 ,p_bal_value in number
2910 ,p_index in number
2911 )
2912 IS
2913 lv_procedure_name VARCHAR2(100) := '.update_county_head_values';
2914 lv_error_message VARCHAR2(200);
2915
2916 BEGIN
2917 hr_utility.set_location(gv_package || lv_procedure_name, 10);
2918 hr_utility.trace('p_index = '|| pay_ac_action_arch.lrr_act_tab.count);
2919 hr_utility.trace('p_balance = '|| p_balance);
2920 hr_utility.trace('p_bal_value = ' || p_bal_value);
2921
2922 if p_balance = 'Head Tax Liability' then
2923 pay_ac_action_arch.lrr_act_tab(p_index).act_info5
2924 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info5,0) +
2925 p_bal_value;
2926 elsif p_balance = 'Head Tax Withheld' then
2927 pay_ac_action_arch.lrr_act_tab(p_index).act_info6
2928 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info6,0) +
2929 p_bal_value;
2930 end if;
2931 hr_utility.set_location(gv_package || lv_procedure_name, 100);
2932
2933 EXCEPTION
2934 when others then
2935 lv_error_message := 'Error in ' ||
2936 gv_package || lv_procedure_name;
2937
2938 hr_utility.trace(lv_error_message || '-' || sqlerrm);
2939
2940 lv_error_message :=
2941 pay_emp_action_arch.set_error_message(lv_error_message);
2942
2943 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
2944 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
2945 hr_utility.raise_error;
2946
2947 END update_county_head_values;
2948
2949
2950 /**************************************************************
2951 Name : update_city_values
2952 Purpose : The procedure set the City level balance value
2953 in the PL/SQL table.
2954 Arguments :
2955 Notes :
2956 **************************************************************/
2957 PROCEDURE update_city_values(p_balance in varchar2
2958 ,p_bal_value in number
2959 ,p_index in number
2960 )
2961 IS
2962 lv_procedure_name VARCHAR2(100) := '.update_city_values';
2963 lv_error_message VARCHAR2(200);
2964
2965 BEGIN
2966 hr_utility.set_location(gv_package || lv_procedure_name, 10);
2967 hr_utility.trace('p_index = '|| pay_ac_action_arch.lrr_act_tab.count);
2968 hr_utility.trace('p_balance = '|| p_balance);
2969 hr_utility.trace('p_bal_value = ' || p_bal_value);
2970
2971 if p_balance = 'City Withheld' then
2972 pay_ac_action_arch.lrr_act_tab(p_index ).act_info1
2973 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info1,0) +
2974 p_bal_value;
2975 elsif p_balance = 'City Subj Whable' then
2976 pay_ac_action_arch.lrr_act_tab(p_index).act_info2
2977 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info2,0) +
2978 p_bal_value;
2979 elsif p_balance = 'City Subj NWhable' then
2980 pay_ac_action_arch.lrr_act_tab(p_index).act_info3
2981 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info3,0) +
2982 p_bal_value;
2983 elsif p_balance = 'City Pre Tax Redns' then
2984 pay_ac_action_arch.lrr_act_tab(p_index).act_info4
2985 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info4,0) +
2986 p_bal_value;
2987 elsif p_balance = 'City Gross' then
2988 pay_ac_action_arch.lrr_act_tab(p_index ).act_info7
2989 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info7,0) +
2990 p_bal_value;
2991 end if;
2992 hr_utility.set_location(gv_package || lv_procedure_name, 100);
2993
2994 EXCEPTION
2995 when others then
2996 lv_error_message := 'Error in ' ||
2997 gv_package || lv_procedure_name;
2998
2999 hr_utility.trace(lv_error_message || '-' || sqlerrm);
3000
3001 lv_error_message :=
3002 pay_emp_action_arch.set_error_message(lv_error_message);
3003
3004 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
3005 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
3006 hr_utility.raise_error;
3007
3008 END update_city_values;
3009
3010
3011 /**************************************************************
3012 Name : update_city_head_values
3013 Purpose : The procedure set the City Head level balance value
3014 in the PL/SQL table.
3015 Arguments :
3016 Notes :
3017 **************************************************************/
3018 PROCEDURE update_city_head_values(p_balance in varchar2
3019 ,p_bal_value in number
3020 ,p_index in number
3021 )
3022 IS
3023 lv_procedure_name VARCHAR2(100) := '.update_city_head_values';
3024 lv_error_message VARCHAR2(200);
3025
3026 BEGIN
3027 hr_utility.set_location(gv_package || lv_procedure_name, 10);
3028 hr_utility.trace('p_index = '|| pay_ac_action_arch.lrr_act_tab.count);
3029 hr_utility.trace('p_balance = '|| p_balance);
3030 hr_utility.trace('p_bal_value = ' || p_bal_value);
3031
3032 if p_balance = 'Head Tax Liability' then
3033 pay_ac_action_arch.lrr_act_tab(p_index).act_info5
3034 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info5,0) +
3035 p_bal_value;
3036 elsif p_balance = 'Head Tax Withheld' then
3037 pay_ac_action_arch.lrr_act_tab(p_index).act_info6
3038 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info6,0) +
3039 p_bal_value;
3040 end if;
3041 hr_utility.set_location(gv_package || lv_procedure_name, 100);
3042
3043 EXCEPTION
3044 when others then
3045 lv_error_message := 'Error in ' ||
3046 gv_package || lv_procedure_name;
3047
3048 hr_utility.trace(lv_error_message || '-' || sqlerrm);
3049
3050 lv_error_message :=
3051 pay_emp_action_arch.set_error_message(lv_error_message);
3052
3053 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
3054 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
3055 hr_utility.raise_error;
3056
3057 END update_city_head_values;
3058
3059 -- PA32 Change begin
3060
3061 /**************************************************************
3062 Name : update_psd_values
3063 Purpose : The procedure set the PSD level balance value
3064 in the PL/SQL table.
3065 Arguments :
3066 Notes :
3067 **************************************************************/
3068 PROCEDURE update_psd_values(p_balance in varchar2
3069 ,p_bal_value in number
3070 ,p_index in number
3071 )
3072 IS
3073 lv_procedure_name VARCHAR2(100) := '.update_psd_values';
3074 lv_error_message VARCHAR2(200);
3075
3076 BEGIN
3077 hr_utility.set_location(gv_package || lv_procedure_name, 10);
3078 hr_utility.trace('p_index = '|| pay_ac_action_arch.lrr_act_tab.count);
3079 hr_utility.trace('p_balance = '|| p_balance);
3080 hr_utility.trace('p_bal_value = ' || p_bal_value);
3081
3082 if p_balance = 'PSD Withheld' then
3083 pay_ac_action_arch.lrr_act_tab(p_index ).act_info1
3084 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info1,0) +
3085 p_bal_value;
3086 elsif p_balance = 'PSD Subj Whable' then
3087 pay_ac_action_arch.lrr_act_tab(p_index).act_info2
3088 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info2,0) +
3089 p_bal_value;
3090 elsif p_balance = 'City PSD Withheld' then
3091 pay_ac_action_arch.lrr_act_tab(p_index).act_info3
3092 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info3,0) +
3093 p_bal_value;
3094 elsif p_balance = 'City PSD Subj Whable' then
3095 pay_ac_action_arch.lrr_act_tab(p_index).act_info4
3096 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info4,0) +
3097 p_bal_value;
3098 elsif p_balance = 'School PSD Withheld' then
3099 pay_ac_action_arch.lrr_act_tab(p_index ).act_info5
3100 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info5,0) +
3101 p_bal_value;
3102 elsif p_balance = 'PSD Withheld YTD' then
3103 pay_ac_action_arch.lrr_act_tab(p_index ).act_info6
3104 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info6,0) +
3105 p_bal_value;
3106 elsif p_balance = 'PSD Subj Whable YTD' then
3107 pay_ac_action_arch.lrr_act_tab(p_index).act_info7
3108 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info7,0) +
3109 p_bal_value;
3110 elsif p_balance = 'City PSD Withheld YTD' then
3111 pay_ac_action_arch.lrr_act_tab(p_index).act_info8
3112 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info8,0) +
3113 p_bal_value;
3114 elsif p_balance = 'City PSD Subj Whable YTD' then
3115 pay_ac_action_arch.lrr_act_tab(p_index).act_info9
3116 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info9,0) +
3117 p_bal_value;
3118 elsif p_balance = 'School PSD Withheld YTD' then
3119 pay_ac_action_arch.lrr_act_tab(p_index ).act_info10
3120 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info10,0) +
3121 p_bal_value;
3122 end if;
3123 hr_utility.set_location(gv_package || lv_procedure_name, 100);
3124
3125 EXCEPTION
3126 when others then
3127 lv_error_message := 'Error in ' ||
3128 gv_package || lv_procedure_name;
3129
3130 hr_utility.trace(lv_error_message || '-' || sqlerrm);
3131
3132 lv_error_message :=
3133 pay_emp_action_arch.set_error_message(lv_error_message);
3134
3135 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
3136 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
3137 hr_utility.raise_error;
3138
3139 END update_psd_values;
3140
3141 -- PA32 Change end
3142
3143 /**************************************************************
3144 Name : update_school_values
3145 Purpose : The procedure set the School level balance value
3146 in the PL/SQL table.
3147 Arguments :
3148 Notes :
3149 **************************************************************/
3150 PROCEDURE update_school_values(p_balance in varchar2
3151 ,p_bal_value in number
3152 ,p_index in number
3153 )
3154 IS
3155 lv_procedure_name VARCHAR2(100) := '.update_school_values';
3156 lv_error_message VARCHAR2(200);
3157
3158 BEGIN
3159 hr_utility.set_location(gv_package || lv_procedure_name, 10);
3160 hr_utility.trace('p_index = '|| pay_ac_action_arch.lrr_act_tab.count);
3161 hr_utility.trace('p_balance = '|| p_balance);
3162 hr_utility.trace('p_bal_value = ' || p_bal_value);
3163
3164 if p_balance = 'School Withheld' then
3165 pay_ac_action_arch.lrr_act_tab(p_index ).act_info1
3166 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info1,0) +
3167 p_bal_value ;
3168 elsif p_balance = 'School Subj Whable' then
3169 pay_ac_action_arch.lrr_act_tab(p_index).act_info2
3170 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info2,0) +
3171 p_bal_value;
3172 elsif p_balance = 'School Subj NWhable' then
3173 pay_ac_action_arch.lrr_act_tab(p_index).act_info3
3174 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info3,0) +
3175 + p_bal_value;
3176 elsif p_balance = 'School Pre Tax Redns' then
3177 pay_ac_action_arch.lrr_act_tab(p_index).act_info4
3178 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info4,0) +
3179 p_bal_value;
3180 elsif p_balance = 'School Gross' then
3181 pay_ac_action_arch.lrr_act_tab(p_index).act_info5
3182 := nvl(pay_ac_action_arch.lrr_act_tab(p_index).act_info5,0) +
3183 p_bal_value;
3184 end if;
3185 hr_utility.set_location(gv_package || lv_procedure_name, 100);
3186
3187 EXCEPTION
3188 when others then
3189 lv_error_message := 'Error in ' ||
3190 gv_package || lv_procedure_name;
3191
3192 hr_utility.trace(lv_error_message || '-' || sqlerrm);
3193
3194 lv_error_message :=
3195 pay_emp_action_arch.set_error_message(lv_error_message);
3196
3197 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
3198 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
3199 hr_utility.raise_error;
3200
3201 END update_school_values;
3202
3203
3204 /**************************************************************
3205 Name : get_city_tax_info
3206 Purpose : The procedure gets the City JIT Information
3207 Arguments :
3208 Notes :
3209 **************************************************************/
3210 PROCEDURE get_city_tax_info( p_effective_date in date
3211 ,p_emp_city_jurisdiction in varchar2
3212 ,p_city_tax_exists out nocopy varchar2
3213 ,p_city_head_tax_exists out nocopy varchar2
3214 )
3215 IS
3216 lv_city_tax_exists VARCHAR2(1);
3217 lv_city_head_tax_exists VARCHAR2(1);
3218 lv_procedure_name VARCHAR2(100) := '.get_city_tax_info';
3219 lv_error_message VARCHAR2(200);
3220
3221 BEGIN
3222 hr_utility.set_location(gv_package || lv_procedure_name, 10);
3223 lv_city_tax_exists := pay_us_payroll_utils.get_tax_exists(
3224 p_tax_type => 'CITY'
3225 ,p_jurisdiction_code => p_emp_city_jurisdiction
3226 ,p_effective_date => p_effective_date) ;
3227
3228 lv_city_head_tax_exists := pay_us_payroll_utils.get_tax_exists(
3229 p_tax_type => 'HT'
3230 ,p_jurisdiction_code => p_emp_city_jurisdiction
3231 ,p_effective_date => p_effective_date) ;
3232
3233 p_city_tax_exists := lv_city_tax_exists ;
3234 p_city_head_tax_exists := lv_city_head_tax_exists;
3235 hr_utility.set_location(gv_package || lv_procedure_name, 20);
3236
3237 EXCEPTION
3238 when others then
3239 lv_error_message := 'Error in ' ||
3240 gv_package || lv_procedure_name;
3241
3242 hr_utility.trace(lv_error_message || '-' || sqlerrm);
3243
3244 lv_error_message :=
3245 pay_emp_action_arch.set_error_message(lv_error_message);
3246
3247 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
3248 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
3249 hr_utility.raise_error;
3250
3251 END get_city_tax_info;
3252
3253
3254 /******************************************************************
3255 Name : get_school_parent_jd
3256 Purpose : The procedure gets the City/County Jurisdiction for a
3257 School District Jurisdiction. This information is
3258 archived as a school distrinct can comparise of multiple
3259 Cities or Counties.
3260 Arguments :
3261 Notes :
3262 ******************************************************************/
3263 FUNCTION get_school_parent_jd(p_assignment_id in number
3264 ,p_school_jurisdiction in varchar2
3265 ,p_end_date in date
3266 ,p_start_date in date
3267 )
3268 RETURN VARCHAR2
3269 IS
3270 cursor c_get_county_school_district is
3271 select pcnt.jurisdiction_code
3272 from pay_us_emp_county_tax_rules_f pcnt
3273 where pcnt.assignment_id = p_assignment_id
3274 and pcnt.school_district_code = substr(p_school_jurisdiction,4,5)
3275 and pcnt.state_code = substr(p_school_jurisdiction,1,2)
3276 and pcnt.effective_start_date <= p_end_date
3277 and pcnt.effective_end_date >= p_start_date;
3278
3279 cursor c_get_city_school_district is
3280 select pcty.jurisdiction_code
3281 from pay_us_emp_city_tax_rules_f pcty
3282 where pcty.assignment_id = p_assignment_id
3283 and pcty.school_district_code = substr(p_school_jurisdiction,4,5)
3284 and pcty.state_code = substr(p_school_jurisdiction,1,2)
3285 and pcty.effective_start_date <= p_end_date
3286 and pcty.effective_end_date >= p_start_date;
3287
3288 lv_parent_jurisdiction_code VARCHAR2(11);
3289 lv_procedure_name VARCHAR2(100) := '.get_school_parent_jd';
3290 lv_error_message VARCHAR2(200);
3291
3292 BEGIN
3293 hr_utility.set_location(gv_package || lv_procedure_name, 10);
3294 open c_get_city_school_district;
3295 fetch c_get_city_school_district into lv_parent_jurisdiction_code ;
3296 if c_get_city_school_district%notfound then
3297 hr_utility.set_location(gv_package || lv_procedure_name, 20);
3298 open c_get_county_school_district;
3299 fetch c_get_county_school_district into lv_parent_jurisdiction_code ;
3300 close c_get_county_school_district;
3301 end if;
3302 close c_get_city_school_district;
3303
3304 hr_utility.trace('lv_parent_jurisdiction_code = '||
3305 lv_parent_jurisdiction_code);
3306 hr_utility.set_location(gv_package || lv_procedure_name, 50);
3307
3308 return(lv_parent_jurisdiction_code);
3309 EXCEPTION
3310 when others then
3311 lv_error_message := 'Error in ' ||
3312 gv_package || lv_procedure_name;
3313
3314 hr_utility.trace(lv_error_message || '-' || sqlerrm);
3315
3316 lv_error_message :=
3317 pay_emp_action_arch.set_error_message(lv_error_message);
3318
3319 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
3320 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
3321 hr_utility.raise_error;
3322
3323 END get_school_parent_jd;
3324
3325
3326 /******************************************************************
3327 Name : get_emp_residence
3328 Purpose : The procedure gets the Employee Resident JD
3329 Arguments :
3330 Notes :
3331 ******************************************************************/
3332 PROCEDURE get_emp_residence(p_assignment_id in number
3333 ,p_end_date in date
3334 ,p_run_effective_date in date
3335 ,p_resident_state_jd out nocopy varchar2
3336 ,p_resident_county_jd out nocopy varchar2
3337 ,p_resident_city_jd out nocopy varchar2
3338 )
3339
3340 IS
3341
3342 cursor c_get_emp_res_dtls(cp_assignment_id in number
3343 ,cp_run_effective_date in date) is
3344 select nvl(ADDR.add_information19,ADDR.region_1),
3345 nvl(ADDR.add_information17,ADDR.region_2),
3346 nvl(addr.add_information18,addr.town_or_city)
3347 from per_addresses addr
3348 ,per_all_assignments_f assign
3349 where cp_run_effective_date between assign.effective_start_date
3350 and assign.effective_end_date
3351 and assign.assignment_id = cp_assignment_id
3352 and addr.person_id = assign.person_id
3353 and addr.primary_flag = 'Y'
3354 and cp_run_effective_date between addr.date_from
3355 and nvl(addr.date_to,
3356 to_date('31/12/4712', 'DD/MM/YYYY'));
3357
3358 cursor c_get_emp_res_jd(cp_state_abbrev in varchar2
3359 ,cp_county_name in varchar2
3360 ,cp_city_name in varchar2) is
3361 select pcn.state_code, pcn.county_code, pcn.city_code
3362 from pay_us_states pus,
3363 pay_us_counties puc,
3364 pay_us_city_names pcn
3365 where pus.state_abbrev = cp_state_abbrev
3366 and puc.state_code = pus.state_code
3367 and puc.county_name = cp_county_name
3368 and pcn.state_code = puc.state_code
3369 and pcn.county_code = puc.county_code
3370 and pcn.city_name = cp_city_name ;
3371
3372 lv_resident_city_jd VARCHAR2(11);
3373 lv_resident_cnty_jd VARCHAR2(11);
3374 lv_resident_state_jd VARCHAR2(11);
3375
3376 lv_resident_city VARCHAR2(120);
3377 lv_resident_county VARCHAR2(120);
3378 lv_resident_state VARCHAR2(120);
3379
3380 lv_procedure_name VARCHAR2(100) := '.get_emp_residence';
3381 lv_error_message VARCHAR2(200);
3382
3383 BEGIN
3384 hr_utility.set_location(gv_package || lv_procedure_name, 10);
3385 /* get the assignments resident city,county,state jurisdictions */
3386 open c_get_emp_res_dtls(p_assignment_id
3387 ,p_run_effective_date);
3388 fetch c_get_emp_res_dtls into lv_resident_county,
3389 lv_resident_state,
3390 lv_resident_city;
3391 close c_get_emp_res_dtls;
3392
3393 open c_get_emp_res_jd(lv_resident_state,
3394 lv_resident_county,
3395 lv_resident_city);
3396 fetch c_get_emp_res_jd into lv_resident_state_jd,
3397 lv_resident_cnty_jd,
3398 lv_resident_city_jd;
3399 close c_get_emp_res_jd;
3400
3401 p_resident_state_jd := lv_resident_state_jd;
3402 p_resident_county_jd := lv_resident_cnty_jd;
3403 p_resident_city_jd := lv_resident_city_jd;
3404 hr_utility.set_location(gv_package || lv_procedure_name, 10);
3405
3406 EXCEPTION
3407 when others then
3408 lv_error_message := 'Error in ' ||
3409 gv_package || lv_procedure_name;
3410
3411 hr_utility.trace(lv_error_message || '-' || sqlerrm);
3412
3413 lv_error_message :=
3414 pay_emp_action_arch.set_error_message(lv_error_message);
3415
3416 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
3417 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
3418 hr_utility.raise_error;
3419
3420 END get_emp_residence;
3421
3422
3423 /******************************************************************
3424 Name : update_ytd_withheld
3425 Purpose : This procedure inserts the Witheld Current and YTD
3426 amounts into the PL/SQL table for Employee Taxes
3427 Arguments :
3428 Notes :
3429 ******************************************************************/
3430 PROCEDURE update_ytd_withheld(p_xfr_action_id in number
3431 ,p_balance_name in varchar2
3432 ,p_balance_type_id in varchar2
3433 ,p_processing_priority in varchar2 default 10
3434 ,p_jurisdiction in varchar2
3435 ,p_curr_withheld in number
3436 ,p_ytd_withheld in number
3437 )
3438 IS
3439
3440 CURSOR get_display_name ( cp_reporting_name in varchar2 ,
3441 cp_jurisdiction_code in varchar2) IS
3442
3443 select decode(length(cp_jurisdiction_code),
3444 11, decode(cp_jurisdiction_code,
3445 '00-000-0000', null,
3446 decode(cp_reporting_name,
3447 'Head Tax Withheld', null,
3448 pay_us_employee_payslip_web.get_jurisdiction_name(
3449 cp_jurisdiction_code) || ' ')),
3450 8, pay_us_employee_payslip_web.get_jurisdiction_name(
3451 substr(cp_jurisdiction_code,1,2)||'-000-0000') || ' ') ||
3452 decode(fl.description, '', null,
3453 nvl(fl.description, cp_reporting_name)) || ' ' ||
3454 decode(length(cp_jurisdiction_code),
3455 8, decode(substr(cp_jurisdiction_code,1,2), '36', substr(cp_jurisdiction_code, 4),
3456 pay_us_employee_payslip_web.get_jurisdiction_name(cp_jurisdiction_code)),
3457 11, decode(cp_reporting_name,
3458 'Head Tax Withheld', pay_us_employee_payslip_web.get_jurisdiction_name(
3459 cp_jurisdiction_code)))display_name
3460 from fnd_common_lookups fl
3461 where fl.lookup_type(+) = 'PAY_US_LABELS'
3462 and upper(cp_reporting_name) = fl.lookup_code(+) ;
3463
3464 lv_display_name VARCHAR2(50);
3465 ln_index NUMBER;
3466 ln_element_index NUMBER;
3467 lv_procedure_name VARCHAR2(100) := '.update_ytd_withheld';
3468 lv_error_message VARCHAR2(200);
3469
3470 BEGIN
3471 hr_utility.set_location(gv_package || lv_procedure_name, 10);
3472 if p_curr_withheld <> 0 or p_ytd_withheld <> 0 then -- Bug 3561821
3473
3474 ln_index := pay_ac_action_arch.lrr_act_tab.count;
3475 hr_utility.trace('ln_index = ' || ln_index);
3476
3477 ln_element_index := pay_ac_action_arch.emp_elements_tab.count;
3478 pay_ac_action_arch.emp_elements_tab(ln_element_index).element_classfn
3479 := 'Tax Deductions';
3480 pay_ac_action_arch.emp_elements_tab(ln_element_index).jurisdiction_code
3481 := p_jurisdiction;
3482 pay_ac_action_arch.emp_elements_tab(ln_element_index).element_reporting_name
3483 := p_balance_name;
3484 pay_ac_action_arch.emp_elements_tab(ln_element_index).element_primary_balance_id
3485 := p_balance_type_id;
3486 pay_ac_action_arch.emp_elements_tab(ln_element_index).element_processing_priority
3487 := p_processing_priority;
3488
3489 pay_ac_action_arch.lrr_act_tab(ln_index).action_info_category
3490 := 'AC DEDUCTIONS';
3491 pay_ac_action_arch.lrr_act_tab(ln_index).jurisdiction_code
3492 := p_jurisdiction;
3493 pay_ac_action_arch.lrr_act_tab(ln_index).action_context_id
3494 := p_xfr_action_id;
3495 pay_ac_action_arch.lrr_act_tab(ln_index).act_info1
3496 := 'Tax Deductions';
3497 pay_ac_action_arch.lrr_act_tab(ln_index).act_info6
3498 := p_balance_type_id ;
3499 pay_ac_action_arch.lrr_act_tab(ln_index).act_info7
3500 := p_processing_priority;
3501 pay_ac_action_arch.lrr_act_tab(ln_index).act_info8
3502 := fnd_number.number_to_canonical(nvl(p_curr_withheld,0));
3503 pay_ac_action_arch.lrr_act_tab(ln_index).act_info9
3504 := fnd_number.number_to_canonical(nvl(p_ytd_withheld,0));
3505 pay_ac_action_arch.lrr_act_tab(ln_index).act_info10
3506 := p_balance_name ;
3507 OPEN get_display_name( p_balance_name ,p_jurisdiction ) ;
3508 FETCH get_display_name INTO lv_display_name ;
3509 IF get_display_name%FOUND THEN
3510 IF substr(lv_display_name , -7,5) = 'BLANK' THEN
3511 lv_display_name := substr(lv_display_name , 1, length(lv_display_name)-8);
3512 hr_utility.trace('get_display_name inside if' || lv_display_name);
3513 END IF;
3514 ELSE
3515 lv_display_name := ' ';
3516 END IF;
3517 IF get_display_name%ISOPEN THEN
3518 close get_display_name;
3519 END IF;
3520 pay_ac_action_arch.lrr_act_tab(ln_index).act_info24
3521 := lv_display_name ;
3522 end if;
3523 hr_utility.set_location(gv_package || lv_procedure_name, 100);
3524
3525 EXCEPTION
3526 when others then
3527 lv_error_message := 'Error in ' ||
3528 gv_package || lv_procedure_name;
3529
3530 hr_utility.trace(lv_error_message || '-' || sqlerrm);
3531
3532 lv_error_message :=
3533 pay_emp_action_arch.set_error_message(lv_error_message);
3534
3535 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
3536 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
3537 hr_utility.raise_error;
3538
3539 END update_ytd_withheld;
3540
3541
3542 /******************************************************************
3543 Name : get_table_index
3544 Purpose : This function gets the index for the PL/SQL table
3545 for US Tax Balances for a given JD.
3546 For Bal Adjustments the function will return the same
3547 index for a given JD as we only archive one record for
3548 all Bal Adj. done on a given date.
3549 Arguments :
3550 Notes :
3551 ******************************************************************/
3552 FUNCTION get_table_index (p_jurisdiction_code in varchar2,
3553 p_action_info_category in varchar2)
3554 RETURN NUMBER
3555 IS
3556 ln_table_index NUMBER;
3557 lv_index_flag VARCHAR2(1) := 'N';
3558
3559 BEGIN
3560 if pay_ac_action_arch.lrr_act_tab.count > 0 then
3561 for j in pay_ac_action_arch.lrr_act_tab.first ..
3562 pay_ac_action_arch.lrr_act_tab.last loop
3563
3564 if pay_ac_action_arch.lrr_act_tab(j).jurisdiction_code
3565 = p_jurisdiction_code THEN
3566
3567 if p_action_info_category is null
3568 and pay_ac_action_arch.lrr_act_tab(j).action_info_category
3569 in ('US FEDERAL',
3570 'US COUNTY', 'US CITY',
3571 'US SCHOOL DISTRICT') then
3572 ln_table_index := j;
3573 lv_index_flag := 'Y';
3574 exit;
3575 ELSE IF pay_ac_action_arch.lrr_act_tab(j).action_info_category
3576 in ('US STATE', 'US STATE2')
3577 AND pay_ac_action_arch.lrr_act_tab(j).action_info_category
3578 = p_action_info_category
3579 THEN
3580 ln_table_index := j;
3581 lv_index_flag := 'Y';
3582 exit;
3583 END IF;
3584
3585 END if;
3586 end if;
3587 end loop;
3588 end if;
3589
3590 if lv_index_flag <> 'Y' then
3591 ln_table_index := pay_ac_action_arch.lrr_act_tab.count;
3592 end if;
3593 hr_utility.trace('ln_table_index = '|| ln_table_index);
3594
3595 return(ln_table_index);
3596
3597 END get_table_index;
3598
3599
3600 /******************************************************************
3601 Name : get_balance_value
3602 Purpose : This procedure calls the get_value function for
3603 balance calls.
3604 Arguments :
3605 Notes :
3606 ******************************************************************/
3607 FUNCTION get_balance_value(
3608 p_defined_balance_id in number
3609 ,p_balcall_aaid in number)
3610 RETURN NUMBER
3611 IS
3612 lv_error_message VARCHAR2(200);
3613 ln_bal_value NUMBER;
3614
3615 BEGIN
3616
3617 if p_defined_balance_id is not null then
3618 ln_bal_value := fnd_number.number_to_canonical(
3619 nvl(pay_balance_pkg.get_value(
3620 p_defined_balance_id,
3621 p_balcall_aaid),0));
3622 end if;
3623
3624 return (ln_bal_value);
3625
3626 EXCEPTION
3627 when others then
3628 return (null);
3629
3630 END get_balance_value;
3631
3632
3633
3634 /******************************************************************
3635 Name : populate_federal_tax_balances
3636 Purpose : This procedure gets all the federal level tax balances
3637 and populates the PL/SQL table.
3638 Arguments :
3639 Notes :
3640 ******************************************************************/
3641 PROCEDURE populate_federal_tax_balances(
3642 p_xfr_action_id in number
3643 ,p_pymt_balcall_aaid in number default null
3644 ,p_ytd_balcall_aaid in number default null
3645 ,p_rqp_action_id in number
3646 ,p_action_type in varchar2)
3647 IS
3648 ln_index NUMBER;
3649 lv_balance_name VARCHAR2(80);
3650 ln_balance_type_id NUMBER;
3651 ln_pymt_def_bal_id NUMBER;
3652 ln_ytd_def_bal_id NUMBER;
3653 ln_run_def_bal_id NUMBER;
3654
3655 ln_bal_value NUMBER(15,2);
3656
3657 ln_curr_withheld NUMBER(15,2):=0;
3658 ln_ytd_withheld NUMBER(15,2):=0;
3659 lv_procedure_name VARCHAR2(100) := '.populate_federal_tax_balances';
3660
3661 lv_error_message VARCHAR2(200);
3662 ln_step NUMBER;
3663
3664 BEGIN
3665 hr_utility.set_location(gv_package || lv_procedure_name, 10);
3666 ln_step := 1;
3667
3668 ln_index := get_table_index('00-000-0000',
3669 NULL);
3670
3671 hr_utility.trace('Fed Loop Count = ' || ln_index);
3672 for i in pay_us_action_arch.ltr_fed_tax_bal.first..
3673 pay_us_action_arch.ltr_fed_tax_bal.last LOOP
3674
3675 lv_balance_name
3676 := pay_us_action_arch.ltr_fed_tax_bal(i).balance_name;
3677 ln_balance_type_id
3678 := pay_us_action_arch.ltr_fed_tax_bal(i).balance_type_id;
3679 ln_pymt_def_bal_id
3680 := pay_us_action_arch.ltr_fed_tax_bal(i).payment_def_bal_id;
3681 ln_ytd_def_bal_id
3682 := pay_us_action_arch.ltr_fed_tax_bal(i).ytd_def_bal_id;
3683 ln_run_def_bal_id
3684 := pay_us_action_arch.ltr_fed_tax_bal(i).asg_run_def_bal_id;
3685
3686 hr_utility.trace('lv_balance_name = ' || lv_balance_name);
3687 hr_utility.trace('ln_pymt_def_bal_id = ' || ln_pymt_def_bal_id);
3688 hr_utility.trace('ln_ytd_def_bal_id = ' || ln_ytd_def_bal_id);
3689 hr_utility.trace('ln_run_def_bal_id = ' || ln_run_def_bal_id);
3690
3691 ln_step := 5;
3692 if p_action_type in ( 'U', 'P') then
3693 if lv_balance_name not in (/*'SS ER Taxable',
3694 'SS ER Liability',
3695 'Medicare ER Liability',*/
3696 'Medicare ER Taxable',
3697 'Non W2 FIT Withheld') then
3698 hr_utility.set_location(gv_package || lv_procedure_name, 30);
3699
3700 ln_step := 6;
3701 ln_bal_value := get_balance_value(
3702 p_defined_balance_id => ln_pymt_def_bal_id
3703 ,p_balcall_aaid => p_pymt_balcall_aaid);
3704 if lv_balance_name = 'EIC Advance' then
3705 ln_bal_value := -1 * ln_bal_value;
3706 end if;
3707
3708 -- elsif lv_balance_name = 'SS ER Taxable' then
3709 -- ln_bal_value
3710 -- := pay_ac_action_arch.lrr_act_tab(ln_index).act_info7;
3711 -- elsif lv_balance_name = 'SS ER Liability' then
3712 -- ln_bal_value
3713 -- := pay_ac_action_arch.lrr_act_tab(ln_index).act_info8;
3714 elsif lv_balance_name = 'Medicare ER Taxable' then
3715 ln_bal_value
3716 := pay_ac_action_arch.lrr_act_tab(ln_index).act_info13;
3717 -- elsif lv_balance_name = 'Medicare ER Liability' then
3718 -- ln_bal_value
3719 -- := pay_ac_action_arch.lrr_act_tab(ln_index).act_info14;
3720 end if;
3721
3722 else
3723 hr_utility.set_location(gv_package || lv_procedure_name, 50);
3724 ln_step := 10;
3725 ln_bal_value := get_balance_value(
3726 p_defined_balance_id => ln_run_def_bal_id
3727 ,p_balcall_aaid => p_rqp_action_id);
3728 end if;
3729
3730 hr_utility.trace('ln_bal_value is'||to_char(ln_bal_value));
3731 update_federal_values(p_balance => lv_balance_name
3732 ,p_bal_value => ln_bal_value
3733 ,p_index => ln_index
3734 ,p_category => 'US FEDERAL');
3735
3736 hr_utility.set_location(gv_package || lv_procedure_name, 60);
3737
3738 /*****************************************************************
3739 ** Insert data for Payslip
3740 ******************************************************************/
3741 if lv_balance_name = 'FIT Withheld' then
3742 ln_step := 12;
3743 ln_curr_withheld := ln_bal_value;
3744 ln_ytd_withheld := get_balance_value(
3745 p_defined_balance_id => ln_ytd_def_bal_id
3746 ,p_balcall_aaid => p_ytd_balcall_aaid);
3747 update_ytd_withheld(
3748 p_xfr_action_id => p_xfr_action_id
3749 ,p_balance_name => lv_balance_name
3750 ,p_balance_type_id => ln_balance_type_id
3751 ,p_processing_priority => 1
3752 ,p_jurisdiction => '00-000-0000'
3753 ,p_curr_withheld => ln_curr_withheld
3754 ,p_ytd_withheld => ln_ytd_withheld);
3755 elsif lv_balance_name = 'EIC Advance' then
3756 ln_step := 13;
3757 ln_curr_withheld := ln_bal_value;
3758 ln_ytd_withheld := get_balance_value(
3759 p_defined_balance_id => ln_ytd_def_bal_id
3760 ,p_balcall_aaid => p_ytd_balcall_aaid);
3761 ln_ytd_withheld := -1 * ln_ytd_withheld;
3762 update_ytd_withheld(
3763 p_xfr_action_id => p_xfr_action_id
3764 ,p_balance_name => lv_balance_name
3765 ,p_balance_type_id => ln_balance_type_id
3766 ,p_processing_priority => 4
3767 ,p_jurisdiction => '00-000-0000'
3768 ,p_curr_withheld => ln_curr_withheld
3769 ,p_ytd_withheld => ln_ytd_withheld);
3770 elsif lv_balance_name = 'Medicare EE Withheld' then
3771 ln_step := 14;
3772 ln_curr_withheld := ln_bal_value ;
3773 ln_ytd_withheld := get_balance_value(
3774 p_defined_balance_id => ln_ytd_def_bal_id
3775 ,p_balcall_aaid => p_ytd_balcall_aaid);
3776 update_ytd_withheld(
3777 p_xfr_action_id => p_xfr_action_id
3778 ,p_balance_name => lv_balance_name
3779 ,p_balance_type_id => ln_balance_type_id
3780 ,p_processing_priority => 3
3781 ,p_jurisdiction => '00-000-0000'
3782 ,p_curr_withheld => ln_curr_withheld
3783 ,p_ytd_withheld => ln_ytd_withheld);
3784 elsif lv_balance_name = 'SS EE Withheld' then
3785 ln_step := 16;
3786 ln_curr_withheld := ln_bal_value;
3787 ln_ytd_withheld := get_balance_value(
3788 p_defined_balance_id => ln_ytd_def_bal_id
3789 ,p_balcall_aaid => p_ytd_balcall_aaid);
3790 update_ytd_withheld(
3791 p_xfr_action_id => p_xfr_action_id
3792 ,p_balance_name => lv_balance_name
3793 ,p_balance_type_id => ln_balance_type_id
3794 ,p_processing_priority => 2
3795 ,p_jurisdiction => '00-000-0000'
3796 ,p_curr_withheld => ln_curr_withheld
3797 ,p_ytd_withheld => ln_ytd_withheld);
3798 elsif lv_balance_name = 'Non W2 FIT Withheld' then
3799
3800 ln_step := 18;
3801 if check_alien(p_xfr_action_id) = 'TRUE' then
3802 hr_utility.set_location(gv_package || lv_procedure_name||
3803 ' Chk Alien ', 20);
3804
3805 ln_bal_value := get_balance_value(
3806 p_defined_balance_id => ln_pymt_def_bal_id
3807 ,p_balcall_aaid => p_pymt_balcall_aaid);
3808
3809 ln_curr_withheld := ln_bal_value;
3810
3811 hr_utility.trace('NonW2FIT Pymt def balid = ' ||
3812 to_char(ln_pymt_def_bal_id));
3813 hr_utility.trace('NonW2FIT Cur = ' ||
3814 to_char(ln_curr_withheld));
3815
3816 ln_ytd_withheld := get_balance_value(
3817 p_defined_balance_id => ln_ytd_def_bal_id
3818 ,p_balcall_aaid => p_ytd_balcall_aaid);
3819
3820 hr_utility.trace('NonW2FIT YTD def balid = ' ||
3821 to_char(ln_ytd_def_bal_id));
3822 hr_utility.trace('NonW2FIT YTD = ' ||
3823 to_char(ln_ytd_withheld));
3824
3825 update_ytd_withheld(
3826 p_xfr_action_id => p_xfr_action_id
3827 ,p_balance_name => lv_balance_name
3828 ,p_balance_type_id => ln_balance_type_id
3829 ,p_jurisdiction => '00-000-0000'
3830 ,p_curr_withheld => ln_curr_withheld
3831 ,p_ytd_withheld => ln_ytd_withheld);
3832 end if;
3833 end if;
3834
3835 end loop;
3836
3837 hr_utility.set_location(gv_package || lv_procedure_name, 100);
3838 ln_step := 20;
3839
3840 EXCEPTION
3841 when others then
3842 lv_error_message := 'Error at step ' || ln_step || ' in ' ||
3843 gv_package || lv_procedure_name;
3844
3845 hr_utility.trace(lv_error_message || '-' || sqlerrm);
3846
3847 lv_error_message :=
3848 pay_emp_action_arch.set_error_message(lv_error_message);
3849
3850 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
3851 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
3852 hr_utility.raise_error;
3853
3854 END populate_federal_tax_balances;
3855
3856
3857 /******************************************************************
3858 Name : populate_state_tax_balances
3859 Purpose : This procedure gets all the state level tax balances
3860 and populates the PL/SQL table.
3861 Arguments :
3862 Notes :
3863 ******************************************************************/
3864 PROCEDURE populate_state_tax_balances(
3865 p_xfr_action_id in number
3866 ,p_pymt_balcall_aaid in number default null
3867 ,p_ytd_balcall_aaid in number default null
3868 ,p_rqp_action_id in number
3869 ,p_action_type in varchar2
3870 ,p_jurisdiction_tab in pay_ac_action_arch.emp_jd_rec_table)
3871 IS
3872 ln_index NUMBER ;
3873 lv_balance_name VARCHAR2(80);
3874 ln_balance_type_id NUMBER;
3875 ln_pymt_def_bal_id NUMBER;
3876 ln_ytd_def_bal_id NUMBER;
3877 ln_run_def_bal_id NUMBER;
3878
3879 lv_state_code VARCHAR2(10);
3880 lv_sit_exists VARCHAR2(1);
3881 lv_sdi_ee_exists VARCHAR2(1);
3882 lv_sdi_er_exists VARCHAR2(1);
3883 lv_sui_ee_exists VARCHAR2(1);
3884 lv_sui_er_exists VARCHAR2(1);
3885
3886 ln_bal_value NUMBER(15,2);
3887
3888 ln_curr_withheld NUMBER(15,2):=0;
3889 ln_ytd_withheld NUMBER(15,2):=0;
3890 lv_procedure_name VARCHAR2(100) := '.populate_state_tax_balances';
3891 lv_error_message VARCHAR2(200);
3892 ln_step NUMBER;
3893
3894
3895 BEGIN
3896 ln_step := 1;
3897 hr_utility.set_location(gv_package || lv_procedure_name, 10);
3898
3899 hr_utility.trace('State Balance Loop Count = ' ||
3900 p_jurisdiction_tab.count);
3901 if p_jurisdiction_tab.count > 0 then
3902 /*(*/
3903 for i in p_jurisdiction_tab.first..
3904 p_jurisdiction_tab.last loop
3905 if p_action_type = 'B' then
3906 lv_state_code := 'Y';
3907 lv_sit_exists := 'Y';
3908 lv_sui_ee_exists := 'Y';
3909 lv_sui_er_exists := 'Y';
3910 lv_sdi_ee_exists := 'Y';
3911 lv_sdi_er_exists := 'Y';
3912 else
3913 lv_state_code := substr(p_jurisdiction_tab(i).emp_jd,1,2);
3914 lv_sit_exists
3915 := pay_us_action_arch.ltr_state_tax_info(lv_state_code).sit_exists;
3916 lv_sui_ee_exists
3917 := pay_us_action_arch.ltr_state_tax_info(lv_state_code).sui_ee_exists;
3918 lv_sui_er_exists
3919 := pay_us_action_arch.ltr_state_tax_info(lv_state_code).sui_er_exists;
3920 lv_sdi_ee_exists
3921 := pay_us_action_arch.ltr_state_tax_info(lv_state_code).sdi_ee_exists;
3922 lv_sdi_er_exists
3923 := pay_us_action_arch.ltr_state_tax_info(lv_state_code).sdi_er_exists;
3924 end if;
3925
3926 hr_utility.trace('p_action_type = ' || p_action_type);
3927 hr_utility.trace('lv_sit_exists = ' || lv_sit_exists);
3928 hr_utility.trace('lv_sui_ee_exists = ' || lv_sui_ee_exists);
3929 hr_utility.trace('lv_sui_er_exists = ' || lv_sui_er_exists);
3930 hr_utility.trace('lv_sdi_ee_exists = ' || lv_sdi_ee_exists);
3931 hr_utility.trace('lv_sdi_er_exists = ' || lv_sdi_er_exists);
3932 hr_utility.trace('Archiving for Jurisdiction = ' ||
3933 p_jurisdiction_tab(i).emp_jd);
3934
3935 pay_balance_pkg.set_context('JURISDICTION_CODE',
3936 p_jurisdiction_tab(i).emp_jd);
3937
3938 ln_bal_value := 0;
3939 ln_curr_withheld := 0;
3940 ln_ytd_withheld := 0;
3941
3942 ln_step := 2;
3943 ln_index := get_table_index(p_jurisdiction_tab(i).emp_jd,
3944 'US STATE');
3945 hr_utility.trace('ln_index for state is '||to_char(ln_index));
3946
3947 pay_ac_action_arch.lrr_act_tab(ln_index).action_info_category
3948 := 'US STATE';
3949 pay_ac_action_arch.lrr_act_tab(ln_index).jurisdiction_code
3950 := p_jurisdiction_tab(i).emp_jd;
3951
3952 if pay_us_action_arch.ltr_state_tax_bal.count > 0 then
3953 --(
3954 for j in pay_us_action_arch.ltr_state_tax_bal.first..
3955 pay_us_action_arch.ltr_state_tax_bal.last loop
3956 lv_balance_name := pay_us_action_arch.ltr_state_tax_bal(j).balance_name;
3957 ln_balance_type_id := pay_us_action_arch.ltr_state_tax_bal(j).balance_type_id;
3958 ln_pymt_def_bal_id := pay_us_action_arch.ltr_state_tax_bal(j).payment_def_bal_id;
3959 ln_ytd_def_bal_id := pay_us_action_arch.ltr_state_tax_bal(j).ytd_def_bal_id;
3960 ln_run_def_bal_id := pay_us_action_arch.ltr_state_tax_bal(j).asg_run_def_bal_id;
3961
3962 hr_utility.trace('lv_balance_name =' || lv_balance_name);
3963 hr_utility.trace('ln_pymt_def_bal_id=' || ln_pymt_def_bal_id);
3964 hr_utility.trace('ln_ytd_def_bal_id =' || ln_ytd_def_bal_id);
3965 hr_utility.trace('ln_run_def_bal_id =' || ln_run_def_bal_id);
3966
3967 --SIT
3968 ln_step := 3;
3969 if substr(lv_balance_name, 1,3) = 'SIT' then
3970 hr_utility.trace('SIT');
3971 if lv_sit_exists = 'Y' then
3972 hr_utility.set_location(gv_package || lv_procedure_name,
3973 110);
3974 if p_action_type in ('U', 'P') then
3975 -- SIT Alien
3976 if lv_balance_name = 'SIT Alien Withheld' then
3977 ln_step := 4;
3978 -- Alien
3979 if check_alien (p_xfr_action_id) = 'TRUE' then
3980 ln_bal_value := get_balance_value(
3981 p_defined_balance_id => ln_pymt_def_bal_id
3982 ,p_balcall_aaid => p_pymt_balcall_aaid);
3983
3984 ln_curr_withheld := ln_bal_value;
3985 hr_utility.trace('NonW2SIT Cur = ' || ln_curr_withheld);
3986
3987 ln_ytd_withheld := get_balance_value(
3988 p_defined_balance_id => ln_ytd_def_bal_id
3989 ,p_balcall_aaid => p_ytd_balcall_aaid);
3990 hr_utility.trace('NonW2SIT YTD = ' || ln_ytd_withheld);
3991
3992 update_ytd_withheld(
3993 p_xfr_action_id => p_xfr_action_id
3994 ,p_balance_name => lv_balance_name
3995 ,p_balance_type_id => ln_balance_type_id
3996 ,p_jurisdiction =>
3997 p_jurisdiction_tab(i).emp_jd
3998 ,p_curr_withheld => ln_curr_withheld
3999 ,p_ytd_withheld => ln_ytd_withheld);
4000 end if;
4001
4002 else -- SIT Alien
4003 ln_step := 5;
4004 ln_bal_value := get_balance_value(
4005 p_defined_balance_id => ln_pymt_def_bal_id
4006 ,p_balcall_aaid => p_pymt_balcall_aaid);
4007
4008 if lv_balance_name = 'SIT Withheld' then
4009 ln_step := 6;
4010 ln_curr_withheld := ln_bal_value;
4011 ln_ytd_withheld := get_balance_value(
4012 p_defined_balance_id => ln_ytd_def_bal_id
4013 ,p_balcall_aaid => p_ytd_balcall_aaid);
4014 update_ytd_withheld(
4015 p_xfr_action_id => p_xfr_action_id
4016 ,p_balance_name => lv_balance_name
4017 ,p_balance_type_id => ln_balance_type_id
4018 ,p_processing_priority => 5
4019 ,p_jurisdiction =>
4020 p_jurisdiction_tab(i).emp_jd
4021 ,p_curr_withheld => ln_curr_withheld
4022 ,p_ytd_withheld => ln_ytd_withheld);
4023 end if;
4024 end if; -- SIT Alien
4025 else
4026 ln_step := 7;
4027 ln_bal_value := get_balance_value(
4028 p_defined_balance_id => ln_run_def_bal_id
4029 ,p_balcall_aaid => p_rqp_action_id);
4030 end if;
4031
4032 hr_utility.trace('ln_bal_value = ' || ln_bal_value);
4033 ln_step := 8;
4034 update_sit_values(p_balance => lv_balance_name
4035 ,p_bal_value => ln_bal_value
4036 ,p_index => ln_index);
4037
4038 end if; -- sit exists
4039 end if; -- taxtype is SIT
4040
4041 --SDI
4042 ln_step := 11;
4043 if substr(lv_balance_name, 1,3) = 'SDI' then
4044 hr_utility.trace('SDI');
4045 if substr(lv_balance_name, 5, 2) = 'EE' then
4046 if lv_sdi_ee_exists = 'Y' then
4047 if p_action_type in ( 'U', 'P') then
4048 ln_bal_value := get_balance_value(
4049 p_defined_balance_id => ln_pymt_def_bal_id
4050 ,p_balcall_aaid => p_pymt_balcall_aaid);
4051
4052 if lv_balance_name = 'SDI EE Withheld' then
4053 ln_curr_withheld := ln_bal_value;
4054 ln_ytd_withheld := get_balance_value(
4055 p_defined_balance_id => ln_ytd_def_bal_id
4056 ,p_balcall_aaid => p_ytd_balcall_aaid);
4057 update_ytd_withheld(
4058 p_xfr_action_id => p_xfr_action_id
4059 ,p_balance_name => 'SDI Withheld'
4060 ,p_balance_type_id => ln_balance_type_id
4061 ,p_jurisdiction =>
4062 p_jurisdiction_tab(i).emp_jd
4063 ,p_curr_withheld => ln_curr_withheld
4064 ,p_ytd_withheld => ln_ytd_withheld);
4065
4066 end if;
4067 else
4068 ln_bal_value := get_balance_value(
4069 p_defined_balance_id => ln_run_def_bal_id
4070 ,p_balcall_aaid => p_rqp_action_id);
4071 end if;
4072
4073 update_sdi_ee_values(p_balance => lv_balance_name
4074 ,p_bal_value => ln_bal_value
4075 ,p_index => ln_index);
4076
4077 end if;
4078 elsif substr(lv_balance_name,5,2) = 'ER' then
4079 if lv_sdi_er_exists = 'Y' then
4080 if p_action_type in ( 'U', 'P') then
4081 ln_bal_value := get_balance_value(
4082 p_defined_balance_id => ln_pymt_def_bal_id
4083 ,p_balcall_aaid => p_pymt_balcall_aaid);
4084 else
4085 ln_bal_value := get_balance_value(
4086 p_defined_balance_id => ln_run_def_bal_id
4087 ,p_balcall_aaid => p_rqp_action_id);
4088 end if;
4089 update_sdi_er_values(p_balance => lv_balance_name
4090 ,p_bal_value => ln_bal_value
4091 ,p_index => ln_index);
4092
4093 end if; -- if SDI ER exists
4094 end if; -- if type EE or ER
4095 end if; --if taxtype is SDI
4096
4097 --SUI
4098 ln_step := 15;
4099 if substr(lv_balance_name, 1, 3) = 'SUI' then
4100 hr_utility.trace('SUI');
4101 if substr(lv_balance_name, 5, 2) = 'EE' then
4102 if lv_sui_ee_exists = 'Y' then
4103 if p_action_type in ( 'U', 'P') then
4104 ln_bal_value := get_balance_value(
4105 p_defined_balance_id => ln_pymt_def_bal_id
4106 ,p_balcall_aaid => p_pymt_balcall_aaid);
4107 if lv_balance_name = 'SUI EE Withheld' then
4108 ln_curr_withheld := ln_bal_value;
4109 ln_ytd_withheld := get_balance_value(
4110 p_defined_balance_id => ln_ytd_def_bal_id
4111 ,p_balcall_aaid => p_ytd_balcall_aaid);
4112 update_ytd_withheld(
4113 p_xfr_action_id => p_xfr_action_id
4114 ,p_balance_name => 'SUI Withheld'
4115 ,p_balance_type_id => ln_balance_type_id
4116 ,p_jurisdiction =>
4117 p_jurisdiction_tab(i).emp_jd
4118 ,p_curr_withheld => ln_curr_withheld
4119 ,p_ytd_withheld => ln_ytd_withheld);
4120 end if;
4121 else
4122 ln_bal_value := get_balance_value(
4123 p_defined_balance_id => ln_run_def_bal_id
4124 ,p_balcall_aaid => p_rqp_action_id);
4125 end if;
4126
4127 update_sui_ee_values(p_balance => lv_balance_name
4128 ,p_bal_value => ln_bal_value
4129 ,p_index => ln_index);
4130
4131 end if; -- SUI EE exists
4132
4133 elsif substr(lv_balance_name,5,2) = 'ER' then
4134 if lv_sui_er_exists = 'Y' then
4135 if p_action_type in ( 'U', 'P') then
4136 ln_bal_value := get_balance_value(
4137 p_defined_balance_id => ln_pymt_def_bal_id
4138 ,p_balcall_aaid => p_pymt_balcall_aaid);
4139 else
4140 ln_bal_value := get_balance_value(
4141 p_defined_balance_id => ln_run_def_bal_id
4142 ,p_balcall_aaid => p_rqp_action_id);
4143 end if;
4144
4145 update_sui_er_values(p_balance => lv_balance_name
4146 ,p_bal_value => ln_bal_value
4147 ,p_index => ln_index);
4148 end if;
4149 end if;
4150 end if; --if taxtype is SUI
4151
4152 ln_step := 20;
4153 if substr(lv_balance_name, 1, 4) = 'Work' then
4154 hr_utility.trace('WORK');
4155 if p_action_type in ( 'U', 'P') then
4156 ln_bal_value := get_balance_value(
4157 p_defined_balance_id => ln_pymt_def_bal_id
4158 ,p_balcall_aaid => p_pymt_balcall_aaid);
4159 if lv_balance_name = 'Workers Comp Withheld' then
4160 ln_curr_withheld := ln_bal_value;
4161 ln_ytd_withheld := get_balance_value(
4162 p_defined_balance_id => ln_ytd_def_bal_id
4163 ,p_balcall_aaid => p_ytd_balcall_aaid);
4164 update_ytd_withheld(
4165 p_xfr_action_id => p_xfr_action_id
4166 ,p_balance_name => 'WC Withheld'
4167 ,p_balance_type_id => ln_balance_type_id
4168 ,p_jurisdiction =>
4169 p_jurisdiction_tab(i).emp_jd
4170 ,p_processing_priority => 10
4171 ,p_curr_withheld => ln_curr_withheld
4172 ,p_ytd_withheld => ln_ytd_withheld);
4173 elsif lv_balance_name = 'Workers Comp2 Withheld' then
4174 ln_curr_withheld := ln_bal_value;
4175 ln_ytd_withheld := get_balance_value(
4176 p_defined_balance_id => ln_ytd_def_bal_id
4177 ,p_balcall_aaid => p_ytd_balcall_aaid);
4178 update_ytd_withheld(
4179 p_xfr_action_id => p_xfr_action_id
4180 ,p_balance_name => 'WC2 Withheld'
4181 ,p_balance_type_id => ln_balance_type_id
4182 ,p_jurisdiction =>
4183 p_jurisdiction_tab(i).emp_jd
4184 ,p_processing_priority =>10
4185 ,p_curr_withheld => ln_curr_withheld
4186 ,p_ytd_withheld => ln_ytd_withheld);
4187 end if;
4188
4189 else
4190 ln_bal_value := get_balance_value(
4191 p_defined_balance_id => ln_run_def_bal_id
4192 ,p_balcall_aaid => p_rqp_action_id);
4193 end if;
4194 hr_utility.trace('State Balance value is '|| ln_bal_value);
4195
4196 update_work_comp_values(p_balance => lv_balance_name
4197 ,p_bal_value => ln_bal_value
4198 ,p_index => ln_index);
4199 end if; -- taxtype is Workerscomp
4200
4201 --STEIC /*Bug 3231253*/
4202 if substr(lv_balance_name, 1, 5) = 'STEIC' then
4203 hr_utility.trace('SITEIC');
4204 if p_action_type in ( 'U', 'P') then
4205 ln_bal_value := get_balance_value(
4206 p_defined_balance_id => ln_pymt_def_bal_id
4207 ,p_balcall_aaid => p_pymt_balcall_aaid);
4208 if lv_balance_name = 'STEIC Advance' then
4209 ln_bal_value := -1 * ln_bal_value;
4210 ln_curr_withheld := ln_bal_value;
4211 ln_ytd_withheld := get_balance_value(
4212 p_defined_balance_id => ln_ytd_def_bal_id
4213 ,p_balcall_aaid => p_ytd_balcall_aaid);
4214
4215 ln_ytd_withheld := -1 * ln_ytd_withheld ;
4216 update_ytd_withheld(
4217 p_xfr_action_id => p_xfr_action_id
4218 ,p_balance_name => 'STEIC Advance'
4219 ,p_balance_type_id => ln_balance_type_id
4220 ,p_jurisdiction =>
4221 p_jurisdiction_tab(i).emp_jd
4222 ,p_processing_priority => 10
4223 ,p_curr_withheld => ln_curr_withheld
4224 ,p_ytd_withheld => ln_ytd_withheld);
4225
4226 end if;
4227
4228 else
4229 ln_bal_value := get_balance_value(
4230 p_defined_balance_id => ln_run_def_bal_id
4231 ,p_balcall_aaid => p_rqp_action_id);
4232 end if;
4233 hr_utility.trace('STEIC State Balance value is '|| ln_bal_value);
4234
4235 update_steic_values(p_balance => lv_balance_name
4236 ,p_bal_value => ln_bal_value
4237 ,p_index => ln_index);
4238 end if; -- taxtype is STEIC Advance
4239
4240 hr_utility.trace('Bottom of loop');
4241
4242 ln_bal_value := 0;
4243 ln_curr_withheld := 0;
4244 ln_ytd_withheld := 0;
4245 end loop; -- of ltr_state_tax_bal.taxtype)
4246
4247 hr_utility.trace('After loop before end if of ltr_state_tax_bal.taxtype');
4248
4249 end if; -- of ltr_state_tax_bal.taxtype
4250
4251 -- TCL_SUI1 Begin
4252 --- NEW LOOP HERE
4253
4254 hr_utility.trace('US STATE2 loop begins here ');
4255
4256 ln_index := get_table_index(p_jurisdiction_tab(i).emp_jd,
4257 'US STATE2');
4258
4259 hr_utility.trace('US STATE2 ln_index = '|| to_char(ln_index));
4260
4261 pay_ac_action_arch.lrr_act_tab(ln_index).action_info_category
4262 := 'US STATE2';
4263 pay_ac_action_arch.lrr_act_tab(ln_index).jurisdiction_code
4264 := p_jurisdiction_tab(i).emp_jd;
4265
4266 if pay_us_action_arch.ltr_state2_tax_bal.count > 0 then
4267 --(
4268 hr_utility.trace('US STATE2 for J... ');
4269
4270 for j in pay_us_action_arch.ltr_state2_tax_bal.first..
4271 pay_us_action_arch.ltr_state2_tax_bal.last loop
4272 lv_balance_name := pay_us_action_arch.ltr_state2_tax_bal(j).balance_name;
4273 ln_balance_type_id := pay_us_action_arch.ltr_state2_tax_bal(j).balance_type_id;
4274 ln_pymt_def_bal_id := pay_us_action_arch.ltr_state2_tax_bal(j).payment_def_bal_id;
4275 ln_ytd_def_bal_id := pay_us_action_arch.ltr_state2_tax_bal(j).ytd_def_bal_id;
4276 ln_run_def_bal_id := pay_us_action_arch.ltr_state2_tax_bal(j).asg_run_def_bal_id;
4277
4278 hr_utility.trace('lv_balance_name =' || lv_balance_name);
4279 hr_utility.trace('ln_pymt_def_bal_id=' || ln_pymt_def_bal_id);
4280 hr_utility.trace('ln_ytd_def_bal_id =' || ln_ytd_def_bal_id);
4281 hr_utility.trace('ln_run_def_bal_id =' || ln_run_def_bal_id);
4282
4283 --SDI1
4284 ln_step := 24;
4285 if substr(lv_balance_name, 1,4) = 'SDI1' then
4286 hr_utility.trace('SDI1');
4287 if substr(lv_balance_name, 6, 2) = 'EE' then
4288 if lv_sdi_ee_exists = 'Y' then
4289 if p_action_type in ( 'U', 'P') then
4290 ln_bal_value := get_balance_value(
4291 p_defined_balance_id => ln_pymt_def_bal_id
4292 ,p_balcall_aaid => p_pymt_balcall_aaid);
4293
4294 if lv_balance_name = 'SDI1 EE Withheld' then
4295 ln_curr_withheld := ln_bal_value;
4296 ln_ytd_withheld := get_balance_value(
4297 p_defined_balance_id => ln_ytd_def_bal_id
4298 ,p_balcall_aaid => p_ytd_balcall_aaid);
4299 update_ytd_withheld(
4300 p_xfr_action_id => p_xfr_action_id
4301 ,p_balance_name => 'SDI1 Withheld'
4302 ,p_balance_type_id => ln_balance_type_id
4303 ,p_jurisdiction =>
4304 p_jurisdiction_tab(i).emp_jd
4305 ,p_curr_withheld => ln_curr_withheld
4306 ,p_ytd_withheld => ln_ytd_withheld);
4307
4308 end if;
4309 else
4310 ln_bal_value := get_balance_value(
4311 p_defined_balance_id => ln_run_def_bal_id
4312 ,p_balcall_aaid => p_rqp_action_id);
4313 end if;
4314
4315 update_sdi1_ee_values(p_balance => lv_balance_name
4316 ,p_bal_value => ln_bal_value
4317 ,p_index => ln_index);
4318
4319 end if;
4320 /* elsif substr(lv_balance_name,6,2) = 'ER' then
4321 if lv_sdi_er_exists = 'Y' then
4322 if p_action_type in ( 'U', 'P') then
4323 ln_bal_value := get_balance_value(
4324 p_defined_balance_id => ln_pymt_def_bal_id
4325 ,p_balcall_aaid => p_pymt_balcall_aaid);
4326 else
4327 ln_bal_value := get_balance_value(
4328 p_defined_balance_id => ln_run_def_bal_id
4329 ,p_balcall_aaid => p_rqp_action_id);
4330 end if;
4331 update_sdi_er_values(p_balance => lv_balance_name
4332 ,p_bal_value => ln_bal_value
4333 ,p_index => ln_index);
4334
4335 end if; -- if SDI1 ER exists
4336 */
4337 end if; -- if type EE or ER
4338 end if; --if taxtype is SDI1
4339
4340 ln_step := 25;
4341 if substr(lv_balance_name, 1, 4) = 'SUI1' then --SUI1 EE Withheld
4342
4343 hr_utility.trace('US STATE2 SUI1 ');
4344
4345 if substr(lv_balance_name, 6, 2) = 'EE' then
4346
4347 hr_utility.trace('US STATE2 SUI1 EE');
4348
4349 if lv_sui_ee_exists = 'Y' then
4350 if p_action_type in ( 'U', 'P') then
4351 ln_bal_value := get_balance_value(
4352 p_defined_balance_id => ln_pymt_def_bal_id
4353 ,p_balcall_aaid => p_pymt_balcall_aaid);
4354 if lv_balance_name = 'SUI1 EE Withheld' then
4355
4356 hr_utility.trace('US STATE2 lv_balance_name = SUI1 EE Withheld ');
4357
4358 ln_curr_withheld := ln_bal_value;
4359 ln_ytd_withheld := get_balance_value(
4360 p_defined_balance_id => ln_ytd_def_bal_id
4361 ,p_balcall_aaid => p_ytd_balcall_aaid);
4362 hr_utility.trace('US STATE2 Before update_ytd_withheld ');
4363
4364 update_ytd_withheld(
4365 p_xfr_action_id => p_xfr_action_id
4366 ,p_balance_name => 'SUI1 Withheld'
4367 ,p_balance_type_id => ln_balance_type_id
4368 ,p_jurisdiction =>
4369 p_jurisdiction_tab(i).emp_jd
4370 ,p_curr_withheld => ln_curr_withheld
4371 ,p_ytd_withheld => ln_ytd_withheld);
4372 end if;
4373 else
4374 ln_bal_value := get_balance_value(
4375 p_defined_balance_id => ln_run_def_bal_id
4376 ,p_balcall_aaid => p_rqp_action_id);
4377 end if;
4378
4379 hr_utility.trace('US STATE2 Before update_sui1_ee_values ');
4380
4381 update_sui1_ee_values(p_balance => lv_balance_name
4382 ,p_bal_value => ln_bal_value
4383 ,p_index => ln_index);
4384
4385 end if; -- SUI1 EE exists
4386
4387 /* elsif substr(lv_balance_name,6,2) = 'ER' then
4388 if lv_sui_er_exists = 'Y' then
4389 if p_action_type in ( 'U', 'P') then
4390 ln_bal_value := get_balance_value(
4391 p_defined_balance_id => ln_pymt_def_bal_id
4392 ,p_balcall_aaid => p_pymt_balcall_aaid);
4393 else
4394 ln_bal_value := get_balance_value(
4395 p_defined_balance_id => ln_run_def_bal_id
4396 ,p_balcall_aaid => p_rqp_action_id);
4397 end if;
4398
4399 update_sui_er_values(p_balance => lv_balance_name
4400 ,p_bal_value => ln_bal_value
4401 ,p_index => ln_index);
4402 end if;
4403 */
4404 end if;
4405 end if; --if taxtype is SUI1
4406
4407 -- TCL_SUI1 End
4408
4409
4410 ln_bal_value := 0;
4411 ln_curr_withheld := 0;
4412 ln_ytd_withheld := 0;
4413 end loop; -- of ltr_state2_tax_bal.taxtype)
4414 end if; -- of ltr_state2_tax_bal.taxtype
4415
4416
4417
4418 end loop; -- )state jurisdiction loop
4419 end if;
4420
4421 hr_utility.set_location(gv_package || lv_procedure_name, 150);
4422
4423 EXCEPTION
4424 when others then
4425 lv_error_message := 'Error at step ' || ln_step || ' in ' ||
4426 gv_package || lv_procedure_name;
4427
4428 hr_utility.trace(lv_error_message || '-' || sqlerrm);
4429
4430 lv_error_message :=
4431 pay_emp_action_arch.set_error_message(lv_error_message);
4432
4433 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
4434 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
4435 hr_utility.raise_error;
4436
4437 END populate_state_tax_balances;
4438
4439
4440 /******************************************************************
4441 Name : populate_county_tax_balances
4442 Purpose : This procedure gets all the County level tax balances
4443 and populates the PL/SQL table.
4444 Arguments :
4445 Notes :
4446 ******************************************************************/
4447 PROCEDURE populate_county_tax_balances(
4448 p_xfr_action_id in number
4449 ,p_pymt_balcall_aaid in number default null
4450 ,p_ytd_balcall_aaid in number default null
4451 ,p_rqp_action_id in number
4452 ,p_action_type in varchar2
4453 ,p_resident_state in varchar2
4454 ,p_resident_county in varchar2
4455 ,p_resident_city in varchar2
4456 ,p_jurisdiction_tab in pay_ac_action_arch.emp_jd_rec_table)
4457 IS
4458 ln_index NUMBER ;
4459 lv_balance_name VARCHAR2(80);
4460 ln_balance_type_id NUMBER;
4461 ln_pymt_def_bal_id NUMBER;
4462 ln_ytd_def_bal_id NUMBER;
4463 ln_run_def_bal_id NUMBER;
4464
4465 lv_county_tax_exists VARCHAR2(1);
4466 lv_county_head_tax_exists VARCHAR2(1);
4467
4468 ln_bal_value NUMBER(15,2) := 0;
4469 ln_curr_withheld NUMBER(15,2) := 0;
4470 ln_ytd_withheld NUMBER(15,2) := 0;
4471
4472 lv_procedure_name VARCHAR2(100) := '.populate_county_tax_balances';
4473 lv_error_message VARCHAR2(200);
4474 ln_step NUMBER;
4475
4476
4477 BEGIN
4478 hr_utility.set_location(gv_package || lv_procedure_name, 10);
4479 hr_utility.trace('County Balance Loop Count = ' ||
4480 pay_us_action_arch.ltr_county_tax_bal.count);
4481
4482 if p_jurisdiction_tab.count > 0 then
4483 for i in p_jurisdiction_tab.first..
4484 p_jurisdiction_tab.last loop
4485
4486 hr_utility.set_location(gv_package || lv_procedure_name, 160);
4487 if pay_us_action_arch.ltr_county_tax_info.count > 0 then
4488 if p_action_type = 'B' then
4489 lv_county_tax_exists := 'Y';
4490 lv_county_head_tax_exists := 'Y';
4491 else
4492 for j in pay_us_action_arch.ltr_county_tax_info.first ..
4493 pay_us_action_arch.ltr_county_tax_info.last loop
4494 if pay_us_action_arch.ltr_county_tax_info(j).jurisdiction_code
4495 = p_jurisdiction_tab(i).emp_jd then
4496 lv_county_tax_exists
4497 := pay_us_action_arch.ltr_county_tax_info(j).cnty_tax_exists;
4498 lv_county_head_tax_exists
4499 := pay_us_action_arch.ltr_county_tax_info(j).cnty_head_tax_exists;
4500 exit;
4501 end if;
4502 end loop;
4503 end if;
4504 end if;
4505
4506 hr_utility.trace('COUNTY lv_county_tax_exists = ' ||
4507 lv_county_tax_exists);
4508 hr_utility.trace('COUNTY lv_county_head_tax_exists = ' ||
4509 lv_county_head_tax_exists);
4510 hr_utility.trace('COUNTY Archiving for Jurisdiction = ' ||
4511 p_jurisdiction_tab(i).emp_jd);
4512
4513 pay_balance_pkg.set_context('JURISDICTION_CODE',
4514 p_jurisdiction_tab(i).emp_jd);
4515
4516 ln_index := get_table_index(p_jurisdiction_tab(i).emp_jd,
4517 NULL);
4518
4519 pay_ac_action_arch.lrr_act_tab(ln_index).jurisdiction_code
4520 := p_jurisdiction_tab(i).emp_jd;
4521 pay_ac_action_arch.lrr_act_tab(ln_index).action_info_category
4522 := 'US COUNTY';
4523
4524 if p_jurisdiction_tab(i).emp_jd
4525 = p_resident_state||'-'||p_resident_county|| '-0000' then
4526 pay_ac_action_arch.lrr_act_tab(ln_index).act_info30 := 'R';
4527 else
4528 pay_ac_action_arch.lrr_act_tab(ln_index).act_info30 := 'NR';
4529 end if;
4530
4531 if pay_us_action_arch.ltr_county_tax_bal.count > 0 then
4532 for k in pay_us_action_arch.ltr_county_tax_bal.first..
4533 pay_us_action_arch.ltr_county_tax_bal.last loop
4534 lv_balance_name := pay_us_action_arch.ltr_county_tax_bal(k).balance_name;
4535 ln_balance_type_id := pay_us_action_arch.ltr_county_tax_bal(k).balance_type_id;
4536 ln_pymt_def_bal_id := pay_us_action_arch.ltr_county_tax_bal(k).payment_def_bal_id;
4537 ln_ytd_def_bal_id := pay_us_action_arch.ltr_county_tax_bal(k).ytd_def_bal_id;
4538 ln_run_def_bal_id := pay_us_action_arch.ltr_county_tax_bal(k).asg_run_def_bal_id;
4539
4540 hr_utility.trace('lv_balance_name = '||lv_balance_name);
4541 hr_utility.trace('ln_pymt_def_bal_id = '||ln_pymt_def_bal_id);
4542 hr_utility.trace('ln_ytd_def_bal_id = '||ln_ytd_def_bal_id);
4543 hr_utility.trace('ln_run_def_bal_id = '||ln_run_def_bal_id);
4544
4545 if substr(lv_balance_name, 1, 6) = 'County' then
4546 if lv_county_tax_exists = 'Y' then
4547 if p_action_type in ( 'U', 'P') then
4548 ln_bal_value := get_balance_value(
4549 p_defined_balance_id => ln_pymt_def_bal_id
4550 ,p_balcall_aaid => p_pymt_balcall_aaid);
4551
4552 if lv_balance_name = 'County Withheld' then
4553 ln_curr_withheld := ln_bal_value;
4554 ln_ytd_withheld := get_balance_value(
4555 p_defined_balance_id => ln_ytd_def_bal_id
4556 ,p_balcall_aaid => p_ytd_balcall_aaid);
4557 update_ytd_withheld(
4558 p_xfr_action_id => p_xfr_action_id
4559 ,p_balance_name => 'County Withheld'
4560 ,p_balance_type_id => ln_balance_type_id
4561 ,p_processing_priority => 6
4562 ,p_jurisdiction =>
4563 p_jurisdiction_tab(i).emp_jd
4564 ,p_curr_withheld => ln_curr_withheld
4565 ,p_ytd_withheld => ln_ytd_withheld);
4566 end if;
4567 else
4568 ln_bal_value := get_balance_value(
4569 p_defined_balance_id => ln_run_def_bal_id
4570 ,p_balcall_aaid => p_rqp_action_id);
4571 end if;
4572
4573 update_county_values(p_balance => lv_balance_name
4574 ,p_bal_value => ln_bal_value
4575 ,p_index => ln_index);
4576 end if; --county tax exists
4577 end if; --substr is County
4578
4579 if substr(lv_balance_name, 1, 4) = 'Head' then
4580 if lv_county_head_tax_exists = 'Y' then
4581 if p_action_type in ( 'U', 'P') then
4582 ln_bal_value := get_balance_value(
4583 p_defined_balance_id => ln_pymt_def_bal_id
4584 ,p_balcall_aaid => p_pymt_balcall_aaid);
4585 if lv_balance_name = 'Head Tax Withheld' then
4586 ln_curr_withheld := ln_bal_value;
4587 ln_ytd_withheld := get_balance_value(
4588 p_defined_balance_id => ln_ytd_def_bal_id
4589 ,p_balcall_aaid => p_ytd_balcall_aaid);
4590
4591 update_ytd_withheld(
4592 p_xfr_action_id => p_xfr_action_id
4593 ,p_balance_name => 'Head Tax Withheld'
4594 ,p_balance_type_id => ln_balance_type_id
4595 ,p_jurisdiction =>
4596 p_jurisdiction_tab(i).emp_jd
4597 ,p_curr_withheld => ln_curr_withheld
4598 ,p_ytd_withheld => ln_ytd_withheld);
4599
4600 end if;
4601 else
4602 ln_bal_value := get_balance_value(
4603 p_defined_balance_id => ln_run_def_bal_id
4604 ,p_balcall_aaid => p_rqp_action_id);
4605 end if;
4606
4607 update_county_head_values(
4608 p_balance => lv_balance_name
4609 ,p_bal_value => ln_bal_value
4610 ,p_index => ln_index);
4611 end if; --head tax exists
4612 end if; --substr is Head
4613
4614 ln_bal_value := 0;
4615 ln_curr_withheld := 0;
4616 ln_ytd_withheld := 0;
4617
4618 end loop; -- ltr_county_tax_bal
4619 end if; -- ltr_county_tax_bal
4620
4621 end loop; -- of jurisdiction)
4622 end if; -- of jurisdiction)
4623 hr_utility.set_location(gv_package || lv_procedure_name, 100);
4624
4625 EXCEPTION
4626 when others then
4627 lv_error_message := 'Error in ' ||
4628 gv_package || lv_procedure_name;
4629
4630 hr_utility.trace(lv_error_message || '-' || sqlerrm);
4631
4632 lv_error_message :=
4633 pay_emp_action_arch.set_error_message(lv_error_message);
4634
4635 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
4636 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
4637 hr_utility.raise_error;
4638 END populate_county_tax_balances;
4639
4640
4641 /******************************************************************
4642 Name : populate_city_tax_balances
4643 Purpose : This procedure gets all the City level tax balances
4644 and populates the PL/SQL table.
4645 Arguments :
4646 Notes :
4647 ******************************************************************/
4648 PROCEDURE populate_city_tax_balances(
4649 p_xfr_action_id in number
4650 ,p_pymt_balcall_aaid in number default null
4651 ,p_ytd_balcall_aaid in number default null
4652 ,p_rqp_action_id in number
4653 ,p_action_type in varchar2
4654 ,p_resident_state in varchar2
4655 ,p_resident_county in varchar2
4656 ,p_resident_city in varchar2
4657 ,p_effective_date in date
4658 ,p_jurisdiction_tab in pay_ac_action_arch.emp_jd_rec_table)
4659 IS
4660 ln_index NUMBER ;
4661 lv_balance_name VARCHAR2(80);
4662 ln_balance_type_id NUMBER;
4663 ln_pymt_def_bal_id NUMBER;
4664 ln_ytd_def_bal_id NUMBER;
4665 ln_run_def_bal_id NUMBER;
4666
4667 lv_city_tax_exists VARCHAR2(1);
4668 lv_city_head_tax_exists VARCHAR2(1);
4669
4670 ln_bal_value NUMBER(15,2) := 0;
4671 ln_curr_withheld NUMBER(15,2) := 0;
4672 ln_ytd_withheld NUMBER(15,2) := 0;
4673
4674 lv_procedure_name VARCHAR2(100) := '.populate_city_tax_balances';
4675 lv_error_message VARCHAR2(200);
4676 ln_step NUMBER;
4677
4678
4679 BEGIN
4680 hr_utility.set_location(gv_package || lv_procedure_name, 10);
4681
4682 if p_jurisdiction_tab.count > 0 then
4683 for i in p_jurisdiction_tab.first..
4684 p_jurisdiction_tab.last loop
4685 if p_action_type = 'B' then
4686 lv_city_tax_exists := 'Y';
4687 lv_city_head_tax_exists := 'Y';
4688 else
4689 get_city_tax_info(p_effective_date,
4690 p_jurisdiction_tab(i).emp_jd,
4691 lv_city_tax_exists,
4692 lv_city_head_tax_exists);
4693 end if;
4694
4695 hr_utility.trace('CITY Archiving for Jurisdiction = ' ||
4696 p_jurisdiction_tab(i).emp_jd);
4697
4698 pay_balance_pkg.set_context('JURISDICTION_CODE',
4699 p_jurisdiction_tab(i).emp_jd);
4700
4701 ln_index := get_table_index(p_jurisdiction_tab(i).emp_jd,
4702 NULL);
4703 hr_utility.trace('Index = '|| ln_index);
4704
4705 pay_ac_action_arch.lrr_act_tab(ln_index).jurisdiction_code
4706 := p_jurisdiction_tab(i).emp_jd;
4707 pay_ac_action_arch.lrr_act_tab(ln_index).action_info_category
4708 := 'US CITY';
4709
4710 /************************************************************
4711 ** When comparing the City Jurisdiction for
4712 ** Resident/Non Resident flag, only check the State and City
4713 ** Codes i.e. do not check county codes.
4714 ** This is because a City could span multiple counties.
4715 ***********************************************************/
4716 if substr(p_jurisdiction_tab(i).emp_jd,1,2)
4717 || '-000-'
4718 || substr(p_jurisdiction_tab(i).emp_jd,8,4)
4719 = p_resident_state || '-000-'
4720 || p_resident_city then
4721 pay_ac_action_arch.lrr_act_tab(ln_index).act_info30 := 'R';
4722 else
4723 pay_ac_action_arch.lrr_act_tab(ln_index).act_info30 := 'NR';
4724 end if;
4725
4726 if pay_us_action_arch.ltr_city_tax_bal.count > 0 then
4727 for k in pay_us_action_arch.ltr_city_tax_bal.first..
4728 pay_us_action_arch.ltr_city_tax_bal.last loop
4729
4730 lv_balance_name :=
4731 pay_us_action_arch.ltr_city_tax_bal(k).balance_name;
4732 ln_balance_type_id :=
4733 pay_us_action_arch.ltr_city_tax_bal(k).balance_type_id;
4734 ln_pymt_def_bal_id :=
4735 pay_us_action_arch.ltr_city_tax_bal(k).payment_def_bal_id;
4736 ln_ytd_def_bal_id :=
4737 pay_us_action_arch.ltr_city_tax_bal(k).ytd_def_bal_id;
4738 ln_run_def_bal_id :=
4739 pay_us_action_arch.ltr_city_tax_bal(k).asg_run_def_bal_id;
4740
4741 hr_utility.trace('lv_balance_name ='||lv_balance_name);
4742 hr_utility.trace('ln_pymt_def_bal_id='||ln_pymt_def_bal_id);
4743 hr_utility.trace('ln_ytd_def_bal_id ='||ln_ytd_def_bal_id);
4744 hr_utility.trace('ln_run_def_bal_id ='||ln_run_def_bal_id);
4745
4746 if substr(lv_balance_name,1,4) = 'City' then
4747 if lv_city_tax_exists = 'Y' then
4748 if p_action_type in ('U', 'P') then
4749 ln_bal_value := get_balance_value(
4750 p_defined_balance_id => ln_pymt_def_bal_id
4751 ,p_balcall_aaid => p_pymt_balcall_aaid);
4752 if lv_balance_name = 'City Withheld' then
4753 ln_curr_withheld := ln_bal_value;
4754 ln_ytd_withheld := get_balance_value(
4755 p_defined_balance_id => ln_ytd_def_bal_id
4756 ,p_balcall_aaid => p_ytd_balcall_aaid);
4757
4758 update_ytd_withheld(
4759 p_xfr_action_id => p_xfr_action_id
4760 ,p_balance_name => 'City Withheld'
4761 ,p_balance_type_id => ln_balance_type_id
4762 ,p_jurisdiction =>
4763 p_jurisdiction_tab(i).emp_jd
4764 ,p_curr_withheld => ln_curr_withheld
4765 ,p_ytd_withheld => ln_ytd_withheld);
4766 end if;
4767 else
4768 ln_bal_value := get_balance_value(
4769 p_defined_balance_id => ln_run_def_bal_id
4770 ,p_balcall_aaid => p_rqp_action_id);
4771 end if;
4772 hr_utility.trace('ln_bal_value = '|| ln_bal_value);
4773
4774 update_city_values(
4775 p_balance => lv_balance_name
4776 ,p_bal_value => ln_bal_value
4777 ,p_index => ln_index);
4778
4779 end if; --city tax exists
4780 end if; --substr is City
4781
4782 if substr(lv_balance_name,1,4) = 'Head' then
4783 if lv_city_head_tax_exists = 'Y' then
4784 if p_action_type in ( 'U', 'P') then
4785 ln_bal_value := get_balance_value(
4786 p_defined_balance_id => ln_pymt_def_bal_id
4787 ,p_balcall_aaid => p_pymt_balcall_aaid);
4788 if lv_balance_name = 'Head Tax Withheld' then
4789 ln_curr_withheld := ln_bal_value;
4790 ln_ytd_withheld := get_balance_value(
4791 p_defined_balance_id => ln_ytd_def_bal_id
4792 ,p_balcall_aaid => p_ytd_balcall_aaid);
4793 update_ytd_withheld(
4794 p_xfr_action_id => p_xfr_action_id
4795 ,p_balance_name => 'Head Tax Withheld'
4796 ,p_balance_type_id => ln_balance_type_id
4797 ,p_jurisdiction =>
4798 p_jurisdiction_tab(i).emp_jd
4799 ,p_curr_withheld => ln_curr_withheld
4800 ,p_ytd_withheld => ln_ytd_withheld);
4801 end if;
4802 else
4803 ln_bal_value := get_balance_value(
4804 p_defined_balance_id => ln_run_def_bal_id
4805 ,p_balcall_aaid => p_rqp_action_id);
4806 end if;
4807 hr_utility.trace('ln_bal_value = '|| ln_bal_value);
4808
4809 update_city_head_values(
4810 p_balance => lv_balance_name
4811 ,p_bal_value => ln_bal_value
4812 ,p_index => ln_index);
4813 end if; -- city head tax exists
4814 end if; --substr is Head
4815
4816 ln_bal_value := 0;
4817 ln_curr_withheld := 0;
4818 ln_ytd_withheld := 0;
4819
4820 end loop; -- ltr_city_tax_bal
4821 end if; -- ltr_city_tax_bal
4822 end loop; -- of city jurisdiction
4823 end if; -- of city jurisdiction
4824
4825 hr_utility.set_location(gv_package || lv_procedure_name, 100);
4826
4827 EXCEPTION
4828 when others then
4829 lv_error_message := 'Error in ' ||
4830 gv_package || lv_procedure_name;
4831
4832 hr_utility.trace(lv_error_message || '-' || sqlerrm);
4833
4834 lv_error_message :=
4835 pay_emp_action_arch.set_error_message(lv_error_message);
4836
4837 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
4838 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
4839 hr_utility.raise_error;
4840 END populate_city_tax_balances;
4841
4842 ---- PA32 Change begin
4843
4844 /******************************************************************
4845 Name : populate_psd_tax_balances
4846 Purpose : This procedure gets all the PSD level tax balances
4847 and populates the PL/SQL table.
4848 Arguments :
4849 Notes :
4850 ******************************************************************/
4851 PROCEDURE populate_psd_tax_balances(
4852 p_xfr_action_id in number
4853 ,p_pymt_balcall_aaid in number default null
4854 ,p_ytd_balcall_aaid in number default null
4855 ,p_rqp_action_id in number
4856 ,p_action_type in varchar2
4857 ,p_resident_state in varchar2
4858 ,p_resident_county in varchar2
4859 ,p_resident_city in varchar2
4860 ,p_effective_date in date
4861 ,p_jurisdiction_tab in pay_ac_action_arch.emp_jd_rec_table)
4862 IS
4863 ln_index NUMBER ;
4864 lv_balance_name VARCHAR2(80);
4865 ln_balance_type_id NUMBER;
4866 ln_pymt_def_bal_id NUMBER;
4867 ln_ytd_def_bal_id NUMBER;
4868 ln_run_def_bal_id NUMBER;
4869
4870 lv_city_tax_exists VARCHAR2(1);
4871 lv_city_head_tax_exists VARCHAR2(1);
4872
4873 ln_bal_value NUMBER(15,2) := 0;
4874 ln_curr_withheld NUMBER(15,2) := 0;
4875 ln_ytd_withheld NUMBER(15,2) := 0;
4876
4877 lv_procedure_name VARCHAR2(100) := '.populate_psd_tax_balances';
4878 lv_error_message VARCHAR2(200);
4879 ln_step NUMBER;
4880
4881
4882 BEGIN
4883 hr_utility.set_location(gv_package || lv_procedure_name, 10);
4884
4885 if p_jurisdiction_tab.count > 0 then
4886 for i in p_jurisdiction_tab.first..
4887 p_jurisdiction_tab.last loop
4888
4889 hr_utility.trace('PSD Archiving for Jurisdiction = ' ||
4890 p_jurisdiction_tab(i).emp_jd);
4891
4892 pay_balance_pkg.set_context('JURISDICTION_CODE',
4893 p_jurisdiction_tab(i).emp_jd);
4894
4895 ln_index := get_table_index(p_jurisdiction_tab(i).emp_jd,
4896 NULL);
4897 hr_utility.trace('Index = '|| ln_index);
4898
4899 pay_ac_action_arch.lrr_act_tab(ln_index).jurisdiction_code
4900 := p_jurisdiction_tab(i).emp_jd;
4901 pay_ac_action_arch.lrr_act_tab(ln_index).action_info_category
4902 := 'US PSD';
4903
4904 /************************************************************
4905 ** When comparing the City Jurisdiction for
4906 ** Resident/Non Resident flag, only check the State and City
4907 ** Codes i.e. do not check county codes.
4908 ** This is because a City could span multiple counties.
4909 ***********************************************************/
4910
4911 -- Code to populate the 'R' / 'NR' Fetch the City WK PSD Withheld balance --
4912 -- If the value is 0 then the R / NR flag = 'R --
4913
4914 /* if get_balance_value(
4915 p_defined_balance_id => ln_run_def_bal_id
4916 ,p_balcall_aaid => g_cty_wk_psd_wh_def_bal_id) = 0 then*/
4917 if get_balance_value(
4918 p_defined_balance_id => g_cty_wk_psd_wh_def_bal_id
4919 ,p_balcall_aaid => p_ytd_balcall_aaid) = 0 then
4920 pay_ac_action_arch.lrr_act_tab(ln_index).act_info30 := 'R';
4921 else
4922 pay_ac_action_arch.lrr_act_tab(ln_index).act_info30 := 'NR';
4923 end if;
4924
4925
4926 if pay_us_action_arch.ltr_psd_tax_bal.count > 0 then
4927 for k in pay_us_action_arch.ltr_psd_tax_bal.first..
4928 pay_us_action_arch.ltr_psd_tax_bal.last loop
4929
4930 lv_balance_name :=
4931 pay_us_action_arch.ltr_psd_tax_bal(k).balance_name;
4932 ln_balance_type_id :=
4933 pay_us_action_arch.ltr_psd_tax_bal(k).balance_type_id;
4934 ln_pymt_def_bal_id :=
4935 pay_us_action_arch.ltr_psd_tax_bal(k).payment_def_bal_id;
4936 ln_ytd_def_bal_id :=
4937 pay_us_action_arch.ltr_psd_tax_bal(k).ytd_def_bal_id;
4938 ln_run_def_bal_id :=
4939 pay_us_action_arch.ltr_psd_tax_bal(k).asg_run_def_bal_id;
4940
4941 hr_utility.trace('lv_balance_name ='||lv_balance_name);
4942 hr_utility.trace('ln_pymt_def_bal_id='||ln_pymt_def_bal_id);
4943 hr_utility.trace('ln_ytd_def_bal_id ='||ln_ytd_def_bal_id);
4944 hr_utility.trace('ln_run_def_bal_id ='||ln_run_def_bal_id);
4945
4946 if p_action_type in ('U', 'P') then
4947
4948 if ln_ytd_def_bal_id is NULL then
4949 ln_bal_value := get_balance_value(
4950 p_defined_balance_id => ln_pymt_def_bal_id
4951 ,p_balcall_aaid => p_pymt_balcall_aaid);
4952 else
4953 ln_bal_value := get_balance_value(
4954 p_defined_balance_id => ln_ytd_def_bal_id
4955 ,p_balcall_aaid => p_ytd_balcall_aaid);
4956 end if;
4957 hr_utility.trace('ln_bal_value = '|| ln_bal_value);
4958
4959 update_psd_values( p_balance => lv_balance_name
4960 ,p_bal_value => ln_bal_value
4961 ,p_index => ln_index);
4962
4963
4964
4965 else
4966 if ln_ytd_def_bal_id is NULL then
4967 ln_bal_value := get_balance_value(
4968 p_defined_balance_id => ln_run_def_bal_id
4969 ,p_balcall_aaid => p_rqp_action_id);
4970 else
4971 ln_bal_value := get_balance_value(
4972 p_defined_balance_id => ln_ytd_def_bal_id
4973 ,p_balcall_aaid => p_rqp_action_id);
4974 hr_utility.trace('ln_bal_value = '|| ln_bal_value);
4975
4976 end if;
4977
4978 update_psd_values( p_balance => lv_balance_name
4979 ,p_bal_value => ln_bal_value
4980 ,p_index => ln_index);
4981
4982 end if;
4983
4984 ln_bal_value := 0;
4985 ln_curr_withheld := 0;
4986 ln_ytd_withheld := 0;
4987
4988 end loop; -- ltr_psd_tax_bal
4989 end if; -- ltr_psd_tax_bal
4990 end loop; -- of psd jurisdiction
4991 end if; -- of psd jurisdiction
4992
4993 hr_utility.set_location(gv_package || lv_procedure_name, 100);
4994
4995 EXCEPTION
4996 when others then
4997 lv_error_message := 'Error in ' ||
4998 gv_package || lv_procedure_name;
4999
5000 hr_utility.trace(lv_error_message || '-' || sqlerrm);
5001
5002 lv_error_message :=
5003 pay_emp_action_arch.set_error_message(lv_error_message);
5004
5005 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
5006 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
5007 hr_utility.raise_error;
5008 END populate_psd_tax_balances;
5009
5010 ---- PA32 Change end
5011
5012 /******************************************************************
5013 Name : populate_school_tax_balances
5014 Purpose : This procedure gets all the School level tax balances
5015 and populates the PL/SQL table.
5016 Arguments :
5017 Notes :
5018 ******************************************************************/
5019 PROCEDURE populate_school_tax_balances(
5020 p_xfr_action_id in number
5021 ,p_pymt_balcall_aaid in number default null
5022 ,p_ytd_balcall_aaid in number default null
5023 ,p_rqp_action_id in number
5024 ,p_action_type in varchar2
5025 ,p_jurisdiction_tab in pay_ac_action_arch.emp_rec_table)
5026 IS
5027 ln_index NUMBER ;
5028 lv_balance_name VARCHAR2(80);
5029 ln_balance_type_id NUMBER;
5030 ln_pymt_def_bal_id NUMBER;
5031 ln_ytd_def_bal_id NUMBER;
5032 ln_run_def_bal_id NUMBER;
5033
5034 lv_emp_school_jd VARCHAR2(15);
5035
5036 ln_bal_value NUMBER(15,2) := 0;
5037 ln_curr_withheld NUMBER(15,2) := 0;
5038 ln_ytd_withheld NUMBER(15,2) := 0;
5039
5040 lv_procedure_name VARCHAR2(100) := '.populate_school_tax_balances';
5041 lv_error_message VARCHAR2(200);
5042
5043 BEGIN
5044 hr_utility.set_location(gv_package || lv_procedure_name, 10);
5045
5046 if p_jurisdiction_tab.count > 0 then
5047 for j in p_jurisdiction_tab.first..
5048 p_jurisdiction_tab.last loop
5049
5050 hr_utility.trace(' Archiving for School Dist = ' ||
5051 p_jurisdiction_tab(j).emp_jd);
5052 hr_utility.trace(' Parent JD for School Dist = ' ||
5053 p_jurisdiction_tab(j).emp_parent_jd);
5054
5055 pay_balance_pkg.set_context('JURISDICTION_CODE',
5056 p_jurisdiction_tab(j).emp_jd);
5057
5058 lv_emp_school_jd := p_jurisdiction_tab(j).emp_jd;
5059 ln_index := get_table_index(p_jurisdiction_tab(j).emp_jd,
5060 NULL);
5061
5062 pay_ac_action_arch.lrr_act_tab(ln_index).jurisdiction_code
5063 := p_jurisdiction_tab(j).emp_jd;
5064 pay_ac_action_arch.lrr_act_tab(ln_index).action_info_category
5065 := 'US SCHOOL DISTRICT';
5066 pay_ac_action_arch.lrr_act_tab(ln_index).act_info30
5067 := p_jurisdiction_tab(j).emp_parent_jd;
5068
5069 if pay_us_action_arch.ltr_schdist_tax_bal.count > 0 then
5070 for k in pay_us_action_arch.ltr_schdist_tax_bal.first..
5071 pay_us_action_arch.ltr_schdist_tax_bal.last loop
5072
5073 lv_balance_name
5074 := pay_us_action_arch.ltr_schdist_tax_bal(k).balance_name;
5075 ln_balance_type_id
5076 := pay_us_action_arch.ltr_schdist_tax_bal(k).balance_type_id;
5077 ln_pymt_def_bal_id
5078 := pay_us_action_arch.ltr_schdist_tax_bal(k).payment_def_bal_id;
5079 ln_ytd_def_bal_id
5080 := pay_us_action_arch.ltr_schdist_tax_bal(k).ytd_def_bal_id;
5081 ln_run_def_bal_id
5082 := pay_us_action_arch.ltr_schdist_tax_bal(k).asg_run_def_bal_id;
5083
5084 hr_utility.trace('lv_balance_name = '||lv_balance_name);
5085 hr_utility.trace('ln_pymt_def_bal_id= '||ln_pymt_def_bal_id);
5086 hr_utility.trace('ln_ytd_def_bal_id = '||ln_ytd_def_bal_id);
5087 hr_utility.trace('ln_run_def_bal_id = '||ln_run_def_bal_id);
5088
5089 if p_action_type in ( 'U', 'P') then
5090 ln_bal_value := get_balance_value(
5091 p_defined_balance_id => ln_pymt_def_bal_id
5092 ,p_balcall_aaid => p_pymt_balcall_aaid);
5093
5094 if lv_balance_name = 'School Withheld' then
5095 ln_curr_withheld := ln_bal_value;
5096 ln_ytd_withheld := get_balance_value(
5097 p_defined_balance_id => ln_ytd_def_bal_id
5098 ,p_balcall_aaid => p_ytd_balcall_aaid);
5099 update_ytd_withheld(
5100 p_xfr_action_id => p_xfr_action_id
5101 ,p_balance_name => 'School Withheld'
5102 ,p_balance_type_id => ln_balance_type_id
5103 ,p_jurisdiction => lv_emp_school_jd
5104 ,p_curr_withheld => ln_curr_withheld
5105 ,p_ytd_withheld => ln_ytd_withheld);
5106 end if;
5107 else
5108 ln_bal_value := get_balance_value(
5109 p_defined_balance_id => ln_run_def_bal_id
5110 ,p_balcall_aaid => p_rqp_action_id);
5111 end if;
5112
5113 hr_utility.trace('ln_bal_value for school dist is '||
5114 ln_bal_value);
5115
5116 update_school_values(
5117 p_balance => lv_balance_name
5118 ,p_bal_value => ln_bal_value
5119 ,p_index => ln_index);
5120
5121 ln_bal_value := 0;
5122 ln_curr_withheld := 0;
5123 ln_ytd_withheld := 0;
5124
5125 end loop; -- ltr_schdist_tax_bal
5126 end if; -- ltr_schdist_tax_bal
5127 end loop; -- of sd jurisdiction
5128 end if; -- of sd jurisdiction
5129 hr_utility.set_location(gv_package || lv_procedure_name, 100);
5130
5131 EXCEPTION
5132 when others then
5133 lv_error_message := 'Error in ' ||
5134 gv_package || lv_procedure_name;
5135
5136 hr_utility.trace(lv_error_message || '-' || sqlerrm);
5137
5138 lv_error_message :=
5139 pay_emp_action_arch.set_error_message(lv_error_message);
5140
5141 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
5142 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
5143 hr_utility.raise_error;
5144 END populate_school_tax_balances;
5145
5146 /*********************************************************************
5147 Name : check_tax_exists
5148 Purpose : This function checks whether does tax exist for given
5149 assignment_id, tax_unit_id, effective_date, jurisdiction
5150 for State, County and City.
5151 This function calls another function
5152 pay_get_tax_exists_pkg.get_tax_exists
5153 This function returns a 'Y' or 'N'.
5154 Arguments : IN
5155 p_assignment_id number;
5156 p_tax_unit_id number;
5157 p_run_effective_date date;
5158 p_jurisdiction_code varchar2;
5159 Notes :
5160 *********************************************************************/
5161 FUNCTION check_tax_exists(
5162 p_assignment_id number,
5163 p_tax_unit_id number,
5164 p_run_effective_date date,
5165 p_jurisdiction_code varchar2)
5166 RETURN VARCHAR2
5167 IS
5168 cursor c_get_head_tax (cp_jd varchar2
5169 ,cp_date date) is
5170 select nvl(head_tax,'N')
5171 from pay_us_city_tax_info_f
5172 where jurisdiction_code = cp_jd
5173 and cp_date between effective_start_date and effective_end_date;
5174
5175
5176 lv_tax_exists varchar2(80) := 'N';
5177
5178 lv_procedure_name VARCHAR2(100) := '.check_tax_exists';
5179 lv_error_message VARCHAR2(200);
5180 ln_step NUMBER;
5181
5182 TYPE char_tabtype IS TABLE OF VARCHAR2(50) INDEX BY BINARY_INTEGER;
5183 lv_tax_type char_tabtype;
5184
5185 BEGIN
5186
5187 ln_step := 1;
5188 hr_utility.set_location(gv_package || lv_procedure_name, 10);
5189
5190 if length(p_jurisdiction_code) > 8 then
5191 if length(p_jurisdiction_code) = 11 and
5192 substr(p_jurisdiction_code, 4) = '000-0000' then
5193
5194 hr_utility.set_location(gv_package || lv_procedure_name, 20);
5195 ln_step := 2;
5196 lv_tax_type(1) := 'SIT_WK';
5197 lv_tax_type(2) := 'SIT_RS';
5198 lv_tax_type(3) := 'SUI';
5199 lv_tax_type(4) := 'SDI_EE';
5200
5201 for i in 1..4 loop
5202
5203 ln_step := 3;
5204 lv_tax_exists :=
5205 pay_get_tax_exists_pkg.get_tax_exists(p_juri_code => p_jurisdiction_code
5206 ,p_date_earned => p_run_effective_date
5207 ,p_tax_unit_id => p_tax_unit_id
5208 ,p_assign_id => p_assignment_id
5209 ,p_pact_id => NULL /** 5683349*/
5210 ,p_type => lv_tax_type(i)
5211 ,p_call => 'P');
5212 if lv_tax_exists = 'Y' then
5213 exit;
5214 end if;
5215
5216 end loop;
5217
5218 ln_step := 4;
5219 return(lv_tax_exists);
5220
5221 elsif length(p_jurisdiction_code) = 11 and
5222 substr(p_jurisdiction_code,8) = '0000' and
5223 substr(p_jurisdiction_code,4,3) <> '000' then
5224
5225 hr_utility.set_location(gv_package || lv_procedure_name, 30);
5226 ln_step := 5;
5227 lv_tax_type(1) := 'COUNTY_WK';
5228 lv_tax_type(2) := 'COUNTY_RS';
5229
5230 for i in 1..2 loop
5231
5232 ln_step := 6;
5233 lv_tax_exists :=
5234 pay_get_tax_exists_pkg.get_tax_exists(p_juri_code => p_jurisdiction_code
5235 ,p_date_earned => p_run_effective_date
5236 ,p_tax_unit_id => p_tax_unit_id
5237 ,p_assign_id => p_assignment_id
5238 ,p_pact_id => NULL /** 5683349*/
5239 ,p_type => lv_tax_type(i)
5240 ,p_call => 'P');
5241
5242 if lv_tax_exists = 'Y' then
5243 exit;
5244 end if;
5245
5246 end loop;
5247
5248 ln_step := 7;
5249 return(lv_tax_exists);
5250
5251 elsif length(p_jurisdiction_code) = 11 and
5252 substr(p_jurisdiction_code,8) <> '0000' then
5253
5254 hr_utility.set_location(gv_package || lv_procedure_name, 40);
5255 ln_step := 8;
5256 lv_tax_type(1) := 'CITY_WK';
5257 lv_tax_type(2) := 'CITY_RS';
5258 lv_tax_type(3) := 'HT_WK';
5259
5260 for i in 1..3 loop
5261
5262 ln_step := 9;
5263 if i in (1,2) then
5264 lv_tax_exists :=
5265 pay_get_tax_exists_pkg.get_tax_exists(p_juri_code => p_jurisdiction_code
5266 ,p_date_earned => p_run_effective_date
5267 ,p_tax_unit_id => p_tax_unit_id
5268 ,p_assign_id => p_assignment_id
5269 ,p_pact_id => NULL /** 5683349*/
5270 ,p_type => lv_tax_type(i)
5271 ,p_call => 'P');
5272
5273 elsif i = 3 then
5274 open c_get_head_tax(p_jurisdiction_code,p_run_effective_date);
5275 lv_tax_exists := ' ';
5276 fetch c_get_head_tax into lv_tax_exists;
5277 if c_get_head_tax%notfound then
5278 hr_utility.set_location(gv_package||lv_procedure_name,10);
5279 lv_error_message := 'No row in JIT Tables ' ||
5280 'for this Jurisdiction ';
5281 lv_tax_exists := 'N';
5282 --hr_utility.raise_error;
5283 end if;
5284 close c_get_head_tax;
5285
5286 end if;
5287
5288 if lv_tax_exists = 'Y' then
5289 exit;
5290 end if;
5291
5292 end loop;
5293
5294 ln_step := 10;
5295 return(lv_tax_exists);
5296
5297 elsif length(p_jurisdiction_code) = 16 then
5298
5299 hr_utility.set_location(gv_package || lv_procedure_name, 45);
5300 ln_step := 10.1;
5301 lv_tax_exists := 'Y';
5302 return(lv_tax_exists);
5303
5304 end if;
5305
5306 elsif length(p_jurisdiction_code) = 8 then
5307
5308 hr_utility.set_location(gv_package || lv_procedure_name, 50);
5309 ln_step := 11;
5310 lv_tax_exists := 'Y';
5311 return(lv_tax_exists);
5312
5313 end if;
5314
5315 hr_utility.set_location(gv_package || lv_procedure_name, 60);
5316 return(lv_tax_exists);
5317
5318 EXCEPTION
5319 when others then
5320 lv_error_message := 'Error at step ' || ln_step || ' in ' ||
5321 gv_package || lv_procedure_name;
5322
5323 hr_utility.trace(lv_error_message || '-' || sqlerrm);
5324
5325 lv_error_message :=
5326 pay_emp_action_arch.set_error_message(lv_error_message);
5327
5328 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
5329 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
5330 hr_utility.raise_error;
5331
5332 END check_tax_exists;
5333
5334 /******************************************************************
5335 Name : populate_puv_tax_balances
5336 Purpose : This is the procedure which is called for Quick/
5337 Pre-Payments and Reversals.
5338 Arguments :
5339 Notes :
5340 ******************************************************************/
5341 PROCEDURE populate_puv_tax_balances(
5342 p_xfr_action_id in number
5343 ,p_assignment_id in number
5344 ,p_tax_unit_id in number
5345 ,p_pymt_balcall_aaid in number
5346 ,p_ytd_balcall_aaid in number
5347 ,p_rqp_action_id in number
5348 ,p_action_type in varchar2
5349 ,p_start_date in date
5350 ,p_end_date in date
5351 ,p_run_effective_date in date
5352 ,p_sepchk_run_type_id in number default null
5353 ,p_sepchk_flag in varchar2 default null
5354 ,p_resident_jurisdiction out nocopy varchar2
5355 )
5356
5357 IS
5358
5359 cursor c_get_jd (cp_assignment_id number
5360 ,cp_tax_unit_id number) is
5361 select substr(puar.jurisdiction_code,1,2)||'-000-0000'
5362 from pay_us_asg_reporting puar
5363 where puar.assignment_id = cp_assignment_id
5364 and puar.tax_unit_id = cp_tax_unit_id
5365 union
5366 select substr(puar.jurisdiction_code,1,6)||'-0000'
5367 from pay_us_asg_reporting puar
5368 where puar.assignment_id = cp_assignment_id
5369 and puar.tax_unit_id = cp_tax_unit_id
5370 and length(puar.jurisdiction_code) <> 8
5371 union
5372 select puar.jurisdiction_code
5373 from pay_us_asg_reporting puar
5374 where puar.assignment_id = cp_assignment_id
5375 and puar.tax_unit_id = cp_tax_unit_id;
5376
5377 ln_index NUMBER ;
5378
5379 lv_rr_jurisdiction_code VARCHAR2(30);
5380 lv_rr_sd_parent_jd VARCHAR2(11);
5381 lv_state_code VARCHAR2(11);
5382
5383 lv_resident_state VARCHAR2(11);
5384 lv_resident_county VARCHAR2(11);
5385 lv_resident_city VARCHAR2(11);
5386
5387 lv_procedure_name VARCHAR2(100) := '.populate_puv_tax_balances';
5388 lv_error_message VARCHAR2(200);
5389
5390 BEGIN
5391 hr_utility.set_location(gv_package || lv_procedure_name, 10);
5392
5393 pay_balance_pkg.set_context('TAX_UNIT_ID', p_tax_unit_id);
5394
5395 /*****************************************************************
5396 ** Get Jurisdictions from pay_run_results for all locked actions
5397 ** actions of the U,P,V case and then populating different PLSQL
5398 ** tables for State, County, City, School Dist
5399 *****************************************************************/
5400 hr_utility.trace('c_get_rr_jd parameters are---------');
5401 hr_utility.trace('p_rqp_action_id = '||p_rqp_action_id);
5402 hr_utility.trace('p_assignment_id = '||p_assignment_id);
5403 hr_utility.trace('p_sepchk_run_type_id = '||p_sepchk_run_type_id);
5404 hr_utility.trace('p_run_effective_date = '||p_run_effective_date);
5405 hr_utility.trace('-----------------------------------------');
5406
5407 open c_get_jd( p_assignment_id
5408 ,p_tax_unit_id );
5409
5410 loop
5411 fetch c_get_jd into lv_rr_jurisdiction_code;
5412 exit when c_get_jd%notfound;
5413
5414 if check_tax_exists(p_assignment_id, p_tax_unit_id,
5415 p_run_effective_date, lv_rr_jurisdiction_code) = 'Y'
5416 then
5417
5418 hr_utility.trace('lv_rr_jurisdiction_code = '||lv_rr_jurisdiction_code);
5419
5420 /*************************************************************
5421 ** Populate the PLSQL table emp_state_jd with this jd
5422 *************************************************************/
5423 if length(lv_rr_jurisdiction_code) = 11 and
5424 lv_rr_jurisdiction_code = '00-000-0000' then
5425 -- don't do anything as this should never happen. Added this as
5426 -- a safety check. We don't care about Federal JD
5427 null;
5428 elsif length(lv_rr_jurisdiction_code) = 11 and
5429 substr(lv_rr_jurisdiction_code, 4) = '000-0000' then
5430 ln_index := pay_ac_action_arch.emp_state_jd.count;
5431 pay_ac_action_arch.emp_state_jd(ln_index).emp_jd
5432 := lv_rr_jurisdiction_code;
5433 /*************************************************************
5434 ** Populate the PLSQL table emp_county_jd with this jd
5435 *************************************************************/
5436 elsif length(lv_rr_jurisdiction_code) = 11 and
5437 substr(lv_rr_jurisdiction_code,8) = '0000' and
5438 substr(lv_rr_jurisdiction_code,4,3) <> '000' then
5439 ln_index := pay_ac_action_arch.emp_county_jd.count;
5440 pay_ac_action_arch.emp_county_jd(ln_index).emp_jd
5441 := lv_rr_jurisdiction_code;
5442 /*************************************************************
5443 ** Populate the PLSQL table emp_city_jd with this jd
5444 *************************************************************/
5445 elsif length(lv_rr_jurisdiction_code) = 11 and
5446 substr(lv_rr_jurisdiction_code,8) <> '0000' then
5447 ln_index := pay_ac_action_arch.emp_city_jd.count;
5448 pay_ac_action_arch.emp_city_jd(ln_index).emp_jd := lv_rr_jurisdiction_code;
5449 ---- PA32 Change begin
5450 /*************************************************************
5451 ** Populate the PLSQL table emp_psd_jd with this jd
5452 *************************************************************/
5453 elsif length(lv_rr_jurisdiction_code) = 16 and
5454 substr(lv_rr_jurisdiction_code,1,2) = '39' then
5455 ln_index := pay_ac_action_arch.emp_psd_jd.count;
5456 pay_ac_action_arch.emp_psd_jd(ln_index).emp_jd := lv_rr_jurisdiction_code;
5457 ---- PA32 Change end
5458 /*************************************************************
5459 ** Populate the PLSQL table emp_school_jd with this jd
5460 *************************************************************/
5461 elsif length(lv_rr_jurisdiction_code) = 8 then
5462 if substr(lv_rr_jurisdiction_code,1,2) = '39' then
5463 lv_rr_sd_parent_jd
5464 := get_school_parent_jd(
5465 p_assignment_id => p_assignment_id
5466 ,p_school_jurisdiction => lv_rr_jurisdiction_code
5467 ,p_start_date => p_start_date
5468 ,p_end_date => p_end_date);
5469 end if;
5470
5471 ln_index := pay_ac_action_arch.emp_school_jd.count;
5472 pay_ac_action_arch.emp_school_jd(ln_index).emp_jd
5473 := lv_rr_jurisdiction_code;
5474 pay_ac_action_arch.emp_school_jd(ln_index).emp_parent_jd
5475 := lv_rr_sd_parent_jd;
5476 end if;
5477 end if;
5478 end loop;
5479 close c_get_jd;
5480
5481 hr_utility.set_location(gv_package || lv_procedure_name, 50);
5482
5483
5484 /*****************************************************************
5485 ** Get Employee Resident Jurisdiction
5486 *****************************************************************/
5487 get_emp_residence(p_assignment_id => p_assignment_id
5488 ,p_end_date => p_end_date
5489 ,p_run_effective_date => p_run_effective_date
5490 ,p_resident_state_jd => lv_resident_state
5491 ,p_resident_county_jd => lv_resident_county
5492 ,p_resident_city_jd => lv_resident_city);
5493
5494 p_resident_jurisdiction := lv_resident_state || '-' ||
5495 lv_resident_county || '-' ||
5496 lv_resident_city;
5497 /*****************************************************************
5498 ** Federal Information Archiving
5499 *****************************************************************/
5500 populate_federal_tax_balances(p_xfr_action_id => p_xfr_action_id
5501 ,p_pymt_balcall_aaid => p_pymt_balcall_aaid
5502 ,p_ytd_balcall_aaid => p_ytd_balcall_aaid
5503 ,p_rqp_action_id => p_rqp_action_id
5504 ,p_action_type => p_action_type);
5505 hr_utility.set_location(gv_package || lv_procedure_name, 60);
5506
5507 /*****************************************************************
5508 ** State Information Archiving
5509 *****************************************************************/
5510 populate_state_tax_balances(
5511 p_xfr_action_id => p_xfr_action_id
5512 ,p_pymt_balcall_aaid => p_pymt_balcall_aaid
5513 ,p_ytd_balcall_aaid => p_ytd_balcall_aaid
5514 ,p_rqp_action_id => p_rqp_action_id
5515 ,p_action_type => p_action_type
5516 ,p_jurisdiction_tab => pay_ac_action_arch.emp_state_jd);
5517 hr_utility.set_location(gv_package || lv_procedure_name, 70);
5518
5519 /*****************************************************************
5520 ** County Information Archiving
5521 *****************************************************************/
5522 populate_county_tax_balances(
5523 p_xfr_action_id => p_xfr_action_id
5524 ,p_pymt_balcall_aaid => p_pymt_balcall_aaid
5525 ,p_ytd_balcall_aaid => p_ytd_balcall_aaid
5526 ,p_rqp_action_id => p_rqp_action_id
5527 ,p_resident_state => lv_resident_state
5528 ,p_resident_county => lv_resident_county
5529 ,p_resident_city => lv_resident_city
5530 ,p_action_type => p_action_type
5531 ,p_jurisdiction_tab => pay_ac_action_arch.emp_county_jd);
5532
5533 /*****************************************************************
5534 ** City Information Archiving
5535 *****************************************************************/
5536 populate_city_tax_balances(
5537 p_xfr_action_id => p_xfr_action_id
5538 ,p_pymt_balcall_aaid => p_pymt_balcall_aaid
5539 ,p_ytd_balcall_aaid => p_ytd_balcall_aaid
5540 ,p_rqp_action_id => p_rqp_action_id
5541 ,p_action_type => p_action_type
5542 ,p_resident_state => lv_resident_state
5543 ,p_resident_county => lv_resident_county
5544 ,p_resident_city => lv_resident_city
5545 ,p_effective_date => p_end_date
5546 ,p_jurisdiction_tab => pay_ac_action_arch.emp_city_jd);
5547
5548 ---- PA32 Change begin
5549 /*****************************************************************
5550 ** PSD Information Archiving
5551 *****************************************************************/
5552 populate_psd_tax_balances(
5553 p_xfr_action_id => p_xfr_action_id
5554 ,p_pymt_balcall_aaid => p_pymt_balcall_aaid
5555 ,p_ytd_balcall_aaid => p_ytd_balcall_aaid
5556 ,p_rqp_action_id => p_rqp_action_id
5557 ,p_action_type => p_action_type
5558 ,p_resident_state => lv_resident_state
5559 ,p_resident_county => lv_resident_county
5560 ,p_resident_city => lv_resident_city
5561 ,p_effective_date => p_end_date
5562 ,p_jurisdiction_tab => pay_ac_action_arch.emp_psd_jd);
5563 ---- PA32 Change end
5564
5565 /*****************************************************************
5566 ** School District Information Archiving
5567 *****************************************************************/
5568 populate_school_tax_balances(
5569 p_xfr_action_id => p_xfr_action_id
5570 ,p_pymt_balcall_aaid => p_pymt_balcall_aaid
5571 ,p_ytd_balcall_aaid => p_ytd_balcall_aaid
5572 ,p_rqp_action_id => p_rqp_action_id
5573 ,p_action_type => p_action_type
5574 ,p_jurisdiction_tab => pay_ac_action_arch.emp_school_jd);
5575
5576
5577 EXCEPTION
5578 when others then
5579 lv_error_message := 'Error in ' ||
5580 gv_package || lv_procedure_name;
5581
5582 hr_utility.trace(lv_error_message || '-' || sqlerrm);
5583
5584 lv_error_message :=
5585 pay_emp_action_arch.set_error_message(lv_error_message);
5586
5587 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
5588 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
5589 hr_utility.raise_error;
5590
5591 END populate_puv_tax_balances;
5592
5593
5594
5595 /******************************************************************
5596 Name : populate_adj_tax_balances
5597 Purpose : This is the procedure which is called for Balance
5598 Adjustments.
5599 Arguments :
5600 Notes : When archiving a balance adjustment, we should not
5601 check if a tax exists but do the balance calls and
5602 archive for a non-zero balance value.
5603 ******************************************************************/
5604 PROCEDURE populate_adj_tax_balances( p_xfr_action_id in number
5605 ,p_assignment_id in number
5606 ,p_tax_unit_id in number
5607 ,p_action_type in varchar2
5608 ,p_start_date in date
5609 ,p_end_date in date
5610 ,p_run_effective_date in date
5611 )
5612 IS
5613
5614 cursor c_get_emp_adjbal(cp_xfr_action_id number) IS
5615 select locked_action_id
5616 from pay_action_interlocks
5617 where locking_action_id = cp_xfr_action_id;
5618
5619 cursor c_get_baladj_jd(cp_baladj_action_id number
5620 ,cp_run_effective_date in date) is
5621 select distinct prr.jurisdiction_code
5622 from pay_run_results prr
5623 where prr.assignment_action_id = cp_baladj_action_id
5624 and length(prr.jurisdiction_code) >= 8
5625 and substr(prr.jurisdiction_code,8,1) <> 'U'
5626 order by prr.jurisdiction_code;
5627
5628 ln_index NUMBER;
5629 ln_baladj_action_id NUMBER;
5630
5631 lv_baladj_jurisdiction_code VARCHAR2(30);
5632
5633 lv_resident_city VARCHAR2(30);
5634 lv_resident_county VARCHAR2(30);
5635 lv_resident_state VARCHAR2(30);
5636
5637 lv_rr_sd_parent_jd VARCHAR2(30);
5638 lv_procedure_name VARCHAR2(100) := '.populate_adj_tax_balances';
5639 lv_error_message VARCHAR2(200);
5640
5641 BEGIN
5642 hr_utility.set_location(gv_package || lv_procedure_name, 10);
5643
5644 pay_balance_pkg.set_context('TAX_UNIT_ID', p_tax_unit_id);
5645
5646 open c_get_emp_adjbal(p_xfr_action_id);
5647 loop
5648 fetch c_get_emp_adjbal into ln_baladj_action_id;
5649 if c_get_emp_adjbal%notfound then
5650 hr_utility.set_location(gv_package || lv_procedure_name, 20);
5651 exit;
5652 end if;
5653 hr_utility.trace('ln_baladj_action_id = '|| ln_baladj_action_id);
5654
5655 open c_get_baladj_jd(ln_baladj_action_id
5656 ,p_run_effective_date);
5657 loop
5658 fetch c_get_baladj_jd into lv_baladj_jurisdiction_code;
5659 if c_get_baladj_jd%notfound or lv_baladj_jurisdiction_code is null then
5660 hr_utility.set_location(gv_package || '.archive_date', 222);
5661 exit;
5662 end if;
5663 hr_utility.trace('lv_baladj_jurisdiction_code = '||
5664 lv_baladj_jurisdiction_code);
5665
5666 /*************************************************************
5667 ** Populate the PLSQL table emp_state_jd with this jd
5668 *************************************************************/
5669 if length(lv_baladj_jurisdiction_code) = 11 and
5670 substr(lv_baladj_jurisdiction_code, 4) = '000-0000' then
5671 ln_index := pay_ac_action_arch.emp_state_jd.count;
5672 pay_ac_action_arch.emp_state_jd(ln_index).emp_jd
5673 := lv_baladj_jurisdiction_code;
5674 /*************************************************************
5675 ** Populate the PLSQL table emp_county_jd with this jd
5676 *************************************************************/
5677 elsif length(lv_baladj_jurisdiction_code) = 11 and
5678 substr(lv_baladj_jurisdiction_code,8) = '0000' and
5679 substr(lv_baladj_jurisdiction_code,4,3) <> '000' then
5680 ln_index := pay_ac_action_arch.emp_county_jd.count;
5681 pay_ac_action_arch.emp_county_jd(ln_index).emp_jd
5682 := lv_baladj_jurisdiction_code;
5683 /*************************************************************
5684 ** Populate the PLSQL table emp_city_jd with this jd
5685 *************************************************************/
5686 elsif length(lv_baladj_jurisdiction_code) = 11 and
5687 substr(lv_baladj_jurisdiction_code,8) <> '0000' then
5688 ln_index := pay_ac_action_arch.emp_city_jd.count;
5689 pay_ac_action_arch.emp_city_jd(ln_index).emp_jd := lv_baladj_jurisdiction_code;
5690 ---- PA32 Change begin
5691 /*************************************************************
5692 ** Populate the PLSQL table emp_psd_jd with this jd
5693 *************************************************************/
5694 elsif length(lv_baladj_jurisdiction_code) = 16 and
5695 substr(lv_baladj_jurisdiction_code,1,2) = '39' then
5696 ln_index := pay_ac_action_arch.emp_psd_jd.count;
5697 pay_ac_action_arch.emp_psd_jd(ln_index).emp_jd := lv_baladj_jurisdiction_code;
5698 ---- PA32 Change end
5699 /*************************************************************
5700 ** Populate the PLSQL table emp_school_jd with this jd
5701 *************************************************************/
5702 elsif length(lv_baladj_jurisdiction_code) = 8 then
5703 if substr(lv_baladj_jurisdiction_code,1,2) = '39' then
5704 lv_rr_sd_parent_jd := get_school_parent_jd(
5705 p_assignment_id => p_assignment_id
5706 ,p_school_jurisdiction => lv_baladj_jurisdiction_code
5707 ,p_start_date => p_start_date
5708 ,p_end_date => p_end_date);
5709 end if;
5710
5711 ln_index := pay_ac_action_arch.emp_school_jd.count;
5712 pay_ac_action_arch.emp_school_jd(ln_index).emp_jd := lv_baladj_jurisdiction_code;
5713 pay_ac_action_arch.emp_school_jd(ln_index).emp_parent_jd := lv_rr_sd_parent_jd;
5714 end if;
5715 end loop;
5716 close c_get_baladj_jd;
5717 hr_utility.set_location(gv_package || lv_procedure_name, 50);
5718
5719 /*****************************************************************
5720 ** Get Employee Resident Jurisdiction
5721 *****************************************************************/
5722 get_emp_residence(p_assignment_id => p_assignment_id
5723 ,p_end_date => p_end_date
5724 ,p_run_effective_date => p_run_effective_date
5725 ,p_resident_state_jd => lv_resident_state
5726 ,p_resident_county_jd => lv_resident_county
5727 ,p_resident_city_jd => lv_resident_city);
5728 hr_utility.set_location(gv_package || lv_procedure_name, 60);
5729 hr_utility.trace('lv_resident_state = ' || lv_resident_state);
5730 hr_utility.trace('lv_resident_county = ' || lv_resident_county);
5731 hr_utility.trace('lv_resident_city = ' || lv_resident_city);
5732
5733 /*****************************************************************
5734 ** Federal Information Archiving
5735 *****************************************************************/
5736 populate_federal_tax_balances(p_xfr_action_id => p_xfr_action_id
5737 ,p_rqp_action_id => ln_baladj_action_id
5738 ,p_action_type => p_action_type);
5739 hr_utility.set_location(gv_package || lv_procedure_name, 70);
5740
5741 /*****************************************************************
5742 ** State Information Archiving
5743 *****************************************************************/
5744 populate_state_tax_balances(
5745 p_xfr_action_id => p_xfr_action_id
5746 ,p_rqp_action_id => ln_baladj_action_id
5747 ,p_action_type => p_action_type
5748 ,p_jurisdiction_tab => pay_ac_action_arch.emp_state_jd);
5749 hr_utility.set_location(gv_package || lv_procedure_name, 80);
5750
5751 /*****************************************************************
5752 ** County Information Archiving
5753 *****************************************************************/
5754 populate_county_tax_balances(
5755 p_xfr_action_id => p_xfr_action_id
5756 ,p_rqp_action_id => ln_baladj_action_id
5757 ,p_resident_state => lv_resident_state
5758 ,p_resident_county => lv_resident_county
5759 ,p_resident_city => lv_resident_city
5760 ,p_action_type => p_action_type
5761 ,p_jurisdiction_tab => pay_ac_action_arch.emp_county_jd);
5762 hr_utility.set_location(gv_package || lv_procedure_name, 90);
5763
5764 /*****************************************************************
5765 ** City Information Archiving
5766 *****************************************************************/
5767 populate_city_tax_balances(
5768 p_xfr_action_id => p_xfr_action_id
5769 ,p_rqp_action_id => ln_baladj_action_id
5770 ,p_action_type => p_action_type
5771 ,p_resident_state => lv_resident_state
5772 ,p_resident_county => lv_resident_county
5773 ,p_resident_city => lv_resident_city
5774 ,p_effective_date => p_end_date
5775 ,p_jurisdiction_tab => pay_ac_action_arch.emp_city_jd);
5776 hr_utility.set_location(gv_package || lv_procedure_name, 100);
5777
5778 ---- PA32 Change begin
5779 /*****************************************************************
5780 ** PSD Information Archiving
5781 *****************************************************************/
5782 populate_psd_tax_balances(
5783 p_xfr_action_id => p_xfr_action_id
5784 ,p_rqp_action_id => ln_baladj_action_id
5785 ,p_action_type => p_action_type
5786 ,p_resident_state => lv_resident_state
5787 ,p_resident_county => lv_resident_county
5788 ,p_resident_city => lv_resident_city
5789 ,p_effective_date => p_end_date
5790 ,p_jurisdiction_tab => pay_ac_action_arch.emp_psd_jd);
5791 hr_utility.set_location(gv_package || lv_procedure_name, 105);
5792 ---- PA32 Change end
5793
5794 /*****************************************************************
5795 ** School District Information Archiving
5796 *****************************************************************/
5797 populate_school_tax_balances(
5798 p_xfr_action_id => p_xfr_action_id
5799 ,p_rqp_action_id => ln_baladj_action_id
5800 ,p_action_type => p_action_type
5801 ,p_jurisdiction_tab => pay_ac_action_arch.emp_school_jd);
5802 hr_utility.set_location(gv_package || lv_procedure_name, 110);
5803
5804 /*****************************************************************
5805 ** Initialize the PL/SQL tables for State, County, City and School
5806 *****************************************************************/
5807 pay_ac_action_arch.emp_state_jd.delete;
5808 pay_ac_action_arch.emp_city_jd.delete;
5809 pay_ac_action_arch.emp_county_jd.delete;
5810 pay_ac_action_arch.emp_school_jd.delete;
5811 hr_utility.set_location(gv_package || lv_procedure_name, 120);
5812
5813 end loop;
5814 close c_get_emp_adjbal;
5815 hr_utility.set_location(gv_package || lv_procedure_name, 130);
5816
5817 hr_utility.trace('Leaving populate_adj_tax_balances');
5818
5819 EXCEPTION
5820 when others then
5821 lv_error_message := 'Error in ' ||
5822 gv_package || lv_procedure_name;
5823
5824 hr_utility.trace(lv_error_message || '-' || sqlerrm);
5825
5826 lv_error_message :=
5827 pay_emp_action_arch.set_error_message(lv_error_message);
5828
5829 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
5830 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
5831 hr_utility.raise_error;
5832
5833 END populate_adj_tax_balances;
5834
5835
5836 /*********************************************************************
5837 Name : update_employee_information
5838 Purpose : This function updates the Employee Information which is
5839 archived by the global archive procedure.
5840 The only thing which is updated is employee name. The
5841 Global package archvies the full name for the employee.
5842 This procedure will update the name to
5843 First Name[space]Middle Initial[.][space]Last Name
5844 Arguments : IN
5845 p_assignment_action_id number;
5846 Notes :
5847 *********************************************************************/
5848 PROCEDURE update_employee_information(
5849 p_action_context_id in number
5850 ,p_assignment_id in number)
5851 IS
5852 cursor c_get_archive_info(cp_action_context_id in number
5853 ,cp_assignment_id in number) is
5854 select action_information_id, effective_date,
5855 object_version_number
5856 from pay_action_information
5857 where action_context_id = cp_action_context_id
5858 and action_context_type = 'AAP'
5859 and assignment_id = cp_assignment_id
5860 and action_information_category = 'EMPLOYEE DETAILS';
5861
5862 cursor c_get_employee_info(cp_assignment_id in number
5863 ,cp_effective_date in date) is
5864 select ltrim(rtrim(
5865 first_name || ' ' ||
5866 decode(nvl(length(ltrim(rtrim(middle_names))),0), 0, null,
5867 upper(substr(middle_names,1,1)) || '. ' ) ||
5868 pre_name_adjunct || last_name || ' '|| suffix))
5869 from per_all_people_f ppf
5870 where ppf.person_id =
5871 (select person_id from per_all_assignments_f paf
5872 where assignment_id = cp_assignment_id
5873 and cp_effective_date between paf.effective_start_date
5874 and paf.effective_end_date)
5875 and cp_effective_date between ppf.effective_start_date
5876 and ppf.effective_end_date;
5877
5878 ln_action_information_id NUMBER;
5879 ld_effective_date DATE;
5880
5881 lv_employee_name VARCHAR2(300);
5882
5883 ln_ovn NUMBER;
5884 lv_procedure_name VARCHAR2(200) := '.update_employee_information';
5885 lv_error_message VARCHAR2(200);
5886
5887
5888 BEGIN
5889 hr_utility.trace('Action_Context_ID = ' || p_action_context_id);
5890 hr_utility.trace('Asg ID = ' || p_assignment_id);
5891 open c_get_archive_info(p_action_context_id, p_assignment_id);
5892 loop
5893 fetch c_get_archive_info into ln_action_information_id,
5894 ld_effective_date,
5895 ln_ovn;
5896 if c_get_archive_info%notfound then
5897 exit;
5898 end if;
5899
5900 hr_utility.trace('Action_info_id = ' || ln_action_information_id);
5901 hr_utility.trace('ld_eff_date = ' || to_char(ld_effective_date, 'dd-mon-yyyy'));
5902
5903 open c_get_employee_info(p_assignment_id, ld_effective_date);
5904 fetch c_get_employee_info into lv_employee_name;
5905 close c_get_employee_info;
5906
5907 hr_utility.trace('lv_employee_name = *' || lv_employee_name ||'*');
5908
5909 pay_action_information_api.update_action_information
5910 (p_action_information_id => ln_action_information_id
5911 ,p_object_version_number => ln_ovn
5912 ,p_action_information1 => lv_employee_name
5913 );
5914
5915 end loop;
5916 close c_get_archive_info;
5917
5918 EXCEPTION
5919 when others then
5920 lv_error_message := 'Error in ' ||
5921 gv_package || lv_procedure_name;
5922
5923 hr_utility.trace(lv_error_message || '-' || sqlerrm);
5924
5925 lv_error_message :=
5926 pay_emp_action_arch.set_error_message(lv_error_message);
5927
5928 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
5929 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
5930 hr_utility.raise_error;
5931
5932 END update_employee_information;
5933
5934
5935 /************************************************************
5936 Name : get_employee_withholding_info
5937 Purpose :
5938 Arguments :
5939 Notes :
5940 ************************************************************/
5941 PROCEDURE get_employee_withholding_info(
5942 p_assignment_id in number
5943 ,p_run_effective_date in date
5944 ,p_resident_jurisdiction in varchar2
5945 )
5946 IS
5947 cursor c_emp_fed_info(cp_assignment_id in number
5948 ,cp_run_effective_date in date) is
5949 select fed.filing_status_code,
5950 decode(fed.fit_exempt,'Y','Exempt',hl.meaning), --8433161
5951 fed.withholding_allowances,
5952 fed.fit_additional_tax,
5953 fed.fit_override_amount,
5954 fed.fit_override_rate,
5955 fed.wage_exempt /*Added for Bug#9872952*/
5956 from pay_us_emp_fed_tax_rules_f fed,
5957 hr_lookups hl
5958 where fed.assignment_id = cp_assignment_id
5959 and hl.lookup_code = fed.filing_status_code
5960 and hl.lookup_type = 'US_FIT_FILING_STATUS'
5961 and cp_run_effective_date between effective_start_date
5962 and effective_end_date;
5963
5964 cursor c_get_asg_work_at_home (cp_assignment_id in number
5965 ,p_run_effective_date in date) is
5966 select nvl(paf.work_at_home, 'N')
5967 from per_all_assignments_f paf
5968 where paf.assignment_id = cp_assignment_id
5969 and p_run_effective_date between paf.effective_start_date
5970 and paf.effective_end_date;
5971
5972 cursor c_emp_state_info(cp_assignment_id in number
5973 ,cp_jurisdiction_code in varchar2
5974 ,cp_effective_date in date) is
5975 select pts.time_in_state,
5976 pts.state_name,
5977 pts.jurisdiction_code,
5978 pts.filing_status_code,
5979 decode(pst.sit_exempt,'Y','Exempt',pts.meaning), --8433161
5980 pts.withholding_allowances,
5981 pts.sit_additional_tax,
5982 pts.sit_override_amount,
5983 pts.sit_override_rate
5984 from pay_us_emp_time_in_state_v pts,
5985 pay_us_emp_state_tax_rules_f pst --8433161
5986 where pts.assignment_id = cp_assignment_id
5987 and pts.jurisdiction_code like cp_jurisdiction_code
5988 and pst.jurisdiction_code = pts.jurisdiction_code --8832183 RLN
5989 and pst.assignment_id = pts.assignment_id --8433161
5990 and cp_effective_date between pst.effective_start_date
5991 and pst.effective_end_date -- 8804636 RLN
5992 and cp_effective_date between pts.effective_start_date
5993 and pts.effective_end_date; -- 8804636 RLN
5994
5995 cursor c_fnd_session is
5996 select effective_date
5997 from fnd_sessions fs
5998 where session_id = userenv('sessionid');
5999
6000 /*Added for Bug#9872952*/
6001 CURSOR c_get_wage_acc_flag IS
6002 SELECT parameter_value
6003 FROM pay_action_parameters
6004 WHERE parameter_name = 'WAGE_ACCUMULATION_ENABLED';
6005
6006 ln_wage_exempt VARCHAR2(1) := 'N';
6007 lv_profile_value VARCHAR2(1) := 'N';
6008 lv_wage_accumulation VARCHAR2(1) := 'N';
6009
6010 /*End Bug#9872952*/
6011
6012 lv_fit_filing_status_code VARCHAR2(30);
6013 lv_fit_filing_status VARCHAR2(80);
6014 ln_fit_withholding_allowances NUMBER(3);
6015 ln_fit_additional_wa_amount NUMBER(11,2);
6016 ln_fit_override_amount NUMBER(11,2);
6017 ln_fit_override_rate NUMBER(6,3);
6018
6019 lv_asg_work_at_home VARCHAR2(10);
6020
6021 lv_time_in_state VARCHAR2(50);
6022 lv_state_name VARCHAR2(50);
6023 lv_jurisdiction_code VARCHAR2(11);
6024 lv_sit_filing_status_code VARCHAR2(30);
6025 lv_sit_filing_status VARCHAR2(80);
6026 ln_sit_withholding_allowances NUMBER(3);
6027 ln_sit_additional_wa_amount NUMBER(11,2);
6028 ln_sit_override_amount NUMBER(11,2);
6029 ln_sit_override_rate NUMBER(6,3);
6030
6031
6032 ld_session_date DATE;
6033 ln_index NUMBER;
6034
6035 lv_procedure_name VARCHAR2(100) := '.get_employee_withholding_info';
6036 lv_error_message VARCHAR2(200);
6037
6038
6039 BEGIN
6040 hr_utility.set_location(gv_package || lv_procedure_name, 10);
6041 open c_emp_fed_info(p_assignment_id,
6042 p_run_effective_date);
6043 hr_utility.trace('Opened c_emp_fed_info cursor of get_withholding_info');
6044 fetch c_emp_fed_info into lv_fit_filing_status_code,
6045 lv_fit_filing_status,
6046 ln_fit_withholding_allowances,
6047 ln_fit_additional_wa_amount,
6048 ln_fit_override_amount,
6049 ln_fit_override_rate,
6050 ln_wage_exempt; /*Added for Bug#9872952*/
6051 if c_emp_fed_info%found then
6052
6053 /*Added for Bug#9872952*/
6054 lv_profile_value := fnd_profile.value('PAY_DIRECT_US_FEDERAL_BALANCES');
6055
6056 IF lv_profile_value = 'Y' THEN
6057
6058 OPEN c_get_wage_acc_flag;
6059 FETCH c_get_wage_acc_flag INTO lv_wage_accumulation;
6060 CLOSE c_get_wage_acc_flag;
6061
6062 END IF;
6063 /*End Bug#9872952*/
6064
6065 hr_utility.trace('Going to write get_withholding_info record for fed');
6066
6067 ln_index := pay_ac_action_arch.lrr_act_tab.count;
6068
6069 hr_utility.trace('ln_index in get_withholding_info proc is '
6070 || pay_ac_action_arch.lrr_act_tab.count);
6071
6072 pay_ac_action_arch.lrr_act_tab(ln_index).action_info_category
6073 := 'US WITHHOLDINGS';
6074 pay_ac_action_arch.lrr_act_tab(ln_index).jurisdiction_code
6075 := '00-000-0000';
6076 pay_ac_action_arch.lrr_act_tab(ln_index).act_info4
6077 := 'Federal';
6078 pay_ac_action_arch.lrr_act_tab(ln_index).act_info5
6079 := lv_fit_filing_status;
6080 pay_ac_action_arch.lrr_act_tab(ln_index).act_info6
6081 := ln_fit_withholding_allowances;
6082 pay_ac_action_arch.lrr_act_tab(ln_index).act_info7
6083 := fnd_number.number_to_canonical(
6084 ln_fit_additional_wa_amount);
6085 pay_ac_action_arch.lrr_act_tab(ln_index).act_info8
6086 := fnd_number.number_to_canonical(
6087 ln_fit_override_amount);
6088 pay_ac_action_arch.lrr_act_tab(ln_index).act_info9
6089 := ln_fit_override_rate;
6090
6091 IF lv_wage_accumulation = 'Y' THEN
6092
6093 pay_ac_action_arch.lrr_act_tab(ln_index).act_info10/*Added for Bug#9872952*/
6094 := ln_wage_exempt;
6095
6096 g_wage_exempt := ln_wage_exempt;
6097
6098 hr_utility.trace('Archiving the Wage Exempt Flag');
6099
6100 END IF;
6101
6102 end if;
6103 close c_emp_fed_info;
6104 hr_utility.set_location(gv_package || lv_procedure_name, 30);
6105
6106
6107 open c_fnd_session;
6108 fetch c_fnd_session into ld_session_date;
6109 if c_fnd_session%notfound then
6110 insert into fnd_sessions (session_id, effective_date) values
6111 (userenv('sessionid'), p_run_effective_date);
6112 else
6113 if ld_session_date <> p_run_effective_date then
6114 update fnd_sessions
6115 set effective_date = p_run_effective_date
6116 where session_id = userenv('sessionid');
6117 end if;
6118 end if;
6119 close c_fnd_session;
6120
6121 open c_get_asg_work_at_home(p_assignment_id
6122 ,p_run_effective_date);
6123 fetch c_get_asg_work_at_home into lv_asg_work_at_home;
6124 close c_get_asg_work_at_home;
6125
6126 hr_utility.set_location(gv_package || lv_procedure_name, 30);
6127 if lv_asg_work_at_home = 'Y' then
6128 open c_emp_state_info(p_assignment_id,
6129 substr(p_resident_jurisdiction,1,2) || '-000-0000'
6130 ,p_run_effective_date); -- 8804636 RLN
6131 else
6132 open c_emp_state_info(p_assignment_id, '%',p_run_effective_date); -- 8804636 RLN
6133 end if;
6134
6135 loop
6136 fetch c_emp_state_info into lv_time_in_state,
6137 lv_state_name,
6138 lv_jurisdiction_code,
6139 lv_sit_filing_status_code,
6140 lv_sit_filing_status,
6141 ln_sit_withholding_allowances,
6142 ln_sit_additional_wa_amount,
6143 ln_sit_override_amount,
6144 ln_sit_override_rate;
6145
6146 if c_emp_state_info%notfound then
6147 hr_utility.set_location(gv_package || lv_procedure_name, 40);
6148 exit;
6149 end if;
6150
6151 hr_utility.set_location(gv_package || lv_procedure_name, 50);
6152 if ((lv_time_in_state > 0) or
6153 (lv_time_in_state = 0 and
6154 substr(lv_jurisdiction_code, 1,2) = substr(p_resident_jurisdiction,1,2))) then
6155
6156 ln_index := pay_ac_action_arch.lrr_act_tab.count;
6157 hr_utility.trace('ln_index = ' || ln_index);
6158
6159 pay_ac_action_arch.lrr_act_tab(ln_index).action_info_category
6160 := 'US WITHHOLDINGS';
6161 pay_ac_action_arch.lrr_act_tab(ln_index).jurisdiction_code
6162 := lv_jurisdiction_code;
6163 pay_ac_action_arch.lrr_act_tab(ln_index).act_info4
6164 := lv_state_name ;
6165 pay_ac_action_arch.lrr_act_tab(ln_index).act_info5
6166 := lv_sit_filing_status;
6167 pay_ac_action_arch.lrr_act_tab(ln_index).act_info6
6168 := ln_sit_withholding_allowances;
6169 pay_ac_action_arch.lrr_act_tab(ln_index).act_info7
6170 := fnd_number.number_to_canonical(
6171 ln_sit_additional_wa_amount);
6172 pay_ac_action_arch.lrr_act_tab(ln_index).act_info8
6173 := fnd_number.number_to_canonical(ln_sit_override_amount);
6174 pay_ac_action_arch.lrr_act_tab(ln_index).act_info9
6175 := ln_sit_override_rate;
6176 end if;
6177 end loop;
6178 close c_emp_state_info;
6179
6180 hr_utility.set_location(gv_package || lv_procedure_name, 100);
6181
6182 EXCEPTION
6183 when others then
6184 lv_error_message := 'Error in ' ||
6185 gv_package || lv_procedure_name;
6186
6187 hr_utility.trace(lv_error_message || '-' || sqlerrm);
6188
6189 lv_error_message :=
6190 pay_emp_action_arch.set_error_message(lv_error_message);
6191
6192 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
6193 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
6194 hr_utility.raise_error;
6195
6196 END get_employee_withholding_info;
6197
6198
6199 --13029995 start Changes to archive/support Third Party XML checks.
6200
6201 /* function get attachment number start */
6202 /************************************************************
6203 Name : get_attachment_number
6204 Purpose : This function is called in the procedure
6205 get_3rdparty_check. This function returns the
6206 attachment number from element entries and other
6207 required information like FIPS code and DOC no.
6208 Arguments :
6209 Notes :
6210 ************************************************************/
6211
6212 FUNCTION get_attachment_number (p_value in number
6213 ,p_pre_payment_id in number
6214 ,p_assignment_id in number
6215 ,p_tax_unit_id in number
6216 ,p_business_group_id in number
6217 ,p_fips_code out nocopy varchar2
6218 ,p_medical_indicator out nocopy varchar2
6219 ,p_third_party_note out nocopy varchar2
6220 ,p_payment_date out nocopy varchar2
6221 ,p_earned_date out nocopy varchar2
6222 ,p_jurisdiction out nocopy varchar2
6223 ,p_print_ssn out nocopy varchar2
6224 ,p_wages out nocopy varchar2
6225 ,p_cnty_name out nocopy varchar2
6226 )
6227 return varchar2 is
6228
6229 /* Following cursor is for NEW Wage Attachment Architecture elements */
6230 cursor c_get_att_no_new is
6231 select peev.screen_entry_value garn_ref_no
6232 ,round(ppp.value ,2)
6233 ,TO_CHAR(pay_us_payment_pkg.get_trx_date( NULL, --:business_group_id,
6234 NULL, --:ppa_payroll_action_id,
6235 NULL,
6236 NULL, --:ppa_payroll_id,
6237 NULL, --:ppa_consolidation_set_id,
6238 NULL, --:ppa_org_payment_method_id,
6239 NULL, --:ppa_effective_date,
6240 NULL, --:ppa_date_earned,
6241 NULL, --:ppa_override_date,
6242 p_pre_payment_id, --ppp.pre_payment_id,
6243 NULL --ppa.effective_date
6244 ),'DD-MON-YYYY') payment_date
6245 ,TO_CHAR(ppa.date_earned, 'DD-MON-YYYY')
6246 ,prr_att.run_result_id
6247 ,peef.entry_information2 -- FIPS code
6248 ,peef.entry_information1 -- Medical Indicator
6249 ,peef.entry_information3 -- DOC Number
6250 ,paa.assignment_action_id
6251 ,pet.element_type_id
6252 from pay_element_entry_values_f peev,
6253 pay_input_values_f piv_att,
6254 pay_element_entries_f peef,
6255 pay_run_results prr_att,
6256 pay_run_results prr_pay,
6257 pay_payroll_actions ppa,
6258 pay_assignment_actions paa,
6259 pay_action_interlocks pai,
6260 pay_pre_payments ppp,
6261 pay_input_values_f piv_pay,
6262 pay_run_result_values prrv_att,
6263 pay_run_result_values prrv_pay,
6264 pay_element_types_f pet,
6265 pay_element_types_f pet_calc,
6266 pay_element_classifications pec
6267 where round(ppp.value ,2) = round(p_value ,2)
6268 and ppp.pre_payment_id = p_pre_payment_id
6269 and ppp.assignment_action_id = pai.locking_action_id
6270 and pai.locked_action_id = paa.assignment_action_id
6271 and ppa.payroll_action_id = paa.payroll_action_id
6272 and ppa.action_type in ('R', 'Q')
6273 and ((paa.source_action_id is not null and ppa.run_type_id is not null) or
6274 (paa.source_action_id is null and ppa.run_type_id is null))
6275 and ppp.personal_payment_method_id = peef.personal_payment_method_id
6276 and peef.assignment_id = paa.assignment_id
6277 and ppa.date_earned between peev.effective_start_date
6278 and peev.effective_end_date
6279 and ppa.date_earned between peef.effective_start_date
6280 and peef.effective_end_date
6281 and piv_att.input_value_id = peev.input_value_id
6282 and upper(piv_att.name) = 'ATTACHMENT NUMBER'
6283 and ppa.effective_Date between piv_att.effective_start_date
6284 and piv_att.effective_end_date
6285 and piv_att.input_value_id = prrv_att.input_value_id
6286 and prrv_att.result_value = peev.screen_entry_value
6287 and prrv_att.run_result_id = prr_att.run_result_id
6288 and paa.assignment_Action_id = prr_att.assignment_Action_id
6289 and prr_att.element_type_id = peef.element_type_id
6290 and peef.element_type_id = pet.element_type_id
6291 and pet.classification_id = pec.classification_id
6292 and pec.classification_name = 'Involuntary Deductions'
6293 and pec.legislation_code = 'US'
6294 and pec.business_group_id IS NULL
6295 and fnd_number.canonical_to_number(pet.element_information5) = pet_calc.element_type_id
6296 and pet_calc.element_name like pet.element_name || '%Calculator'
6297 and pet_calc.element_type_id = piv_pay.element_type_id
6298 and NVL(ppa.date_earned, ppa.effective_date) between piv_pay.effective_start_date and piv_pay.effective_end_date
6299 and piv_pay.input_value_id = prrv_pay.input_value_id
6300 and upper(piv_pay.name) = 'PAY VALUE'
6301 and fnd_number.number_to_canonical(ppp.value) = prrv_pay.result_value
6302 and prr_pay.run_result_id = prrv_pay.run_result_id
6303 and prr_pay.assignment_action_id = paa.assignment_action_id
6304 and prr_pay.element_type_id = pet_calc.element_type_id
6305 and NVL(ppa.date_earned, ppa.effective_date) between pet.effective_start_date
6306 and pet.effective_end_date
6307 and NVL(ppa.date_earned, ppa.effective_date) between pet_calc.effective_start_date
6308 and pet_calc.effective_end_date
6309 order by prr_att.run_result_id;
6310
6311
6312 /* Following cursor is for OLD Wage Attachment Architecture elements */
6313 cursor c_get_att_no_old is
6314 select peev.screen_entry_value garn_ref_no
6315 ,round(ppp.value ,2)
6316 ,TO_CHAR(pay_us_payment_pkg.get_trx_date( NULL, --:business_group_id,
6317 NULL, --:ppa_payroll_action_id,
6318 NULL,
6319 NULL, --:ppa_payroll_id,
6320 NULL, --:ppa_consolidation_set_id,
6321 NULL, --:ppa_org_payment_method_id,
6322 NULL, --:ppa_effective_date,
6323 NULL, --:ppa_date_earned,
6324 NULL, --:ppa_override_date,
6325 p_pre_payment_id, --ppp.pre_payment_id,
6326 NULL --ppa.effective_date
6327 ),'DD-MON-YYYY') payment_date
6328 ,TO_CHAR(ppa.date_earned, 'DD-MON-YYYY')
6329 ,prr_pay.run_result_id
6330 ,peef.entry_information2 -- FIPS code
6331 ,peef.entry_information1 -- Medical Indicator
6332 ,peef.entry_information3 -- DOC Number
6333 ,paa.assignment_action_id
6334 ,peef.element_type_id
6335 from pay_element_entry_values_f peev,
6336 pay_element_entry_values_f peev_pay,
6337 pay_input_values_f piv_att,
6338 pay_element_entries_f peef,
6339 pay_run_results prr_att,
6340 pay_run_results prr_pay,
6341 pay_payroll_actions ppa,
6342 pay_assignment_actions paa,
6343 pay_action_interlocks pai,
6344 pay_pre_payments ppp,
6345 pay_input_values_f piv_pay,
6346 pay_run_result_values prrv_att,
6347 pay_run_result_values prrv_pay
6348 where round(ppp.value ,2) = round(p_value ,2)
6349 and ppp.pre_payment_id = p_pre_payment_id
6350 and ppp.assignment_action_id = pai.locking_action_id
6351 and pai.locked_action_id = paa.assignment_action_id
6352 and ppa.payroll_action_id = paa.payroll_action_id
6353 and ppa.action_type in ('R', 'Q')
6354 and ((paa.source_action_id is not null and ppa.run_type_id is not null) or
6355 (paa.source_action_id is null and ppa.run_type_id is null))
6356 and ppp.personal_payment_method_id = peef.personal_payment_method_id
6357 and peef.assignment_id = paa.assignment_id
6358 and ppa.date_earned between peev.effective_start_date
6359 and peev.effective_end_date
6360 and ppa.date_earned between peef.effective_start_date
6361 and peef.effective_end_date
6362 and piv_att.input_value_id = peev.input_value_id
6363 and upper(piv_att.name) = 'ATTACHMENT NUMBER'
6364 and ppa.effective_Date between piv_att.effective_start_date
6365 and piv_att.effective_end_date
6366 and piv_att.input_value_id = prrv_att.input_value_id
6367 and prrv_att.result_value = peev.screen_entry_value
6368 and piv_pay.input_value_id = peev_pay.input_value_id
6369 and ppa.effective_date between piv_pay.effective_start_date
6370 and piv_pay.effective_end_date
6371 and ppa.date_earned between peev_pay.effective_start_date
6372 and peev_pay.effective_end_date
6373 and piv_pay.input_value_id = prrv_pay.input_value_id
6374 and upper(piv_pay.name) = 'PAY VALUE'
6375 and fnd_number.number_to_canonical(ppp.value) = prrv_pay.result_value
6376 and peef.element_entry_id = peev.element_entry_id
6377 and peef.element_entry_id = peev_pay.element_entry_id
6378 and paa.assignment_Action_id = prr_att.assignment_Action_id
6379 and prr_att.run_result_id = prrv_att.run_result_id
6380 and paa.assignment_action_id = prr_pay.assignment_action_id
6381 and prr_pay.run_result_id = prrv_pay.run_result_id
6382 and prr_att.element_type_id = peef.element_type_id
6383 and prr_pay.element_type_id = peef.element_type_id
6384 order by prr_pay.run_result_id;
6385
6386 cursor csr_garn_arch IS
6387 select distinct 'Y'
6388 from pay_upgrade_definitions pud
6389 ,pay_upgrade_status pus
6390 where pud.short_name = 'US_INV_DEDN_UPGRADE'
6391 and pud.legislation_code = 'US'
6392 and pud.upgrade_definition_id = pus.upgrade_definition_id
6393 and pus.status = 'C'
6394 and pus.business_group_id = p_business_group_id;
6395
6396 cursor csr_action_param IS
6397 select parameter_value
6398 from pay_action_parameters
6399 where parameter_name = 'US_ADVANCED_WAGE_ATTACHMENT';
6400
6401 cursor jur ( ass_act_id number, ele_type_id number, date_ear date ) IS
6402 select prrv.result_value
6403 from pay_run_results prr,
6404 pay_run_result_values prrv,
6405 pay_input_values_f piv,
6406 pay_element_types_f pet,
6407 pay_element_types_f pet1
6408 where prr.assignment_action_id = ass_act_id and
6409 pet1.element_type_id = ele_type_id and
6410 pet.element_name = pet1.element_name ||' Calculator' and
6411 prr.element_type_id = pet.element_type_id and
6412 prrv.run_result_id = prr.run_result_id and
6413 prrv.input_value_id = piv.input_value_id and
6414 piv.element_type_id = prr.element_type_id and
6415 piv.name='Jurisdiction' and
6416 date_ear between piv.effective_start_date and piv.effective_end_date and
6417 date_ear between pet.effective_start_date and pet.effective_end_date and
6418 date_ear between pet1.effective_start_date and pet1.effective_end_date;
6419
6420 cursor cnty ( jur_code varchar2, date_ear date ) IS
6421 select cnty_information1
6422 from pay_us_county_tax_info_f
6423 where jurisdiction_code = jur_code and
6424 date_ear between effective_start_date and effective_end_date;
6425
6426 cursor state ( st_code varchar2, date_ear date ) IS
6427 select sta_information12,sta_information13
6428 from pay_us_state_tax_info_f
6429 where state_code = st_code and
6430 date_ear between effective_start_date and effective_end_date;
6431
6432 cursor cnty_name (jur_code varchar2) IS
6433 select county_name
6434 from pay_us_counties
6435 where state_code = substr(jur_code,1,2) and
6436 county_code = substr(jur_code,4,3);
6437
6438 -- Added for bug 14098797
6439
6440 cursor upgrade_status is
6441 select pet.element_type_id
6442 ,to_char(ppa.date_earned, 'DD-MM-YYYY')
6443 ,nvl(element_information4,-1)
6444 from pay_element_entry_values_f peev,
6445 pay_input_values_f piv_att,
6446 pay_element_entries_f peef,
6447 pay_run_results prr_att,
6448 pay_payroll_actions ppa,
6449 pay_assignment_actions paa,
6450 pay_action_interlocks pai,
6451 pay_pre_payments ppp,
6452 pay_run_result_values prrv_att,
6453 pay_element_types_f pet,
6454 pay_element_classifications pec
6455 WHERE round(ppp.value ,2) = round(p_value ,2)
6456 and ppp.pre_payment_id = p_pre_payment_id
6457 and ppp.assignment_action_id = pai.locking_action_id
6458 and pai.locked_action_id = paa.assignment_action_id
6459 and ppa.payroll_action_id = paa.payroll_action_id
6460 and ppa.action_type in ('R', 'Q')
6461 and ((paa.source_action_id is not null and ppa.run_type_id is not null) or
6462 (paa.source_action_id is null and ppa.run_type_id is null))
6463 and ppp.personal_payment_method_id = peef.personal_payment_method_id
6464 and peef.assignment_id = paa.assignment_id
6465 and ppa.date_earned between peev.effective_start_date
6466 and peev.effective_end_date
6467 and ppa.date_earned between peef.effective_start_date
6468 and peef.effective_end_date
6469 and piv_att.input_value_id = peev.input_value_id
6470 and upper(piv_att.name) = 'ATTACHMENT NUMBER'
6471 and ppa.date_earned between piv_att.effective_start_date
6472 and piv_att.effective_end_date
6473 and piv_att.input_value_id = prrv_att.input_value_id
6474 and prrv_att.result_value = peev.screen_entry_value
6475 and prrv_att.run_result_id = prr_att.run_result_id
6476 and paa.assignment_Action_id = prr_att.assignment_Action_id
6477 and prr_att.element_type_id = peef.element_type_id
6478 and peef.element_type_id = pet.element_type_id
6479 and pet.classification_id = pec.classification_id
6480 and ppa.date_earned between pet.effective_start_date
6481 and pet.effective_end_date
6482 and pec.classification_name = 'Involuntary Deductions'
6483 and pec.legislation_code = 'US'
6484 and pec.business_group_id IS NULL;
6485
6486 cursor upgrade_date (ele_type_id number) is
6487 select to_char(min(petf_calc.creation_date),'DD-MM-YYYY')
6488 from pay_element_types_f petf_calc,
6489 pay_element_types_f petf
6490 where petf.element_type_id = ele_type_id
6491 and petf_calc.element_name like petf.element_name||'\_New_ Calculator' escape '\';
6492
6493 -- End of changes for 14098797
6494
6495 l_ele_type_id number;
6496 l_garn_ref_no varchar2(100);
6497 l_amount number;
6498 l_run_result_id number;
6499 l_printed number;
6500 l_fips_code varchar2(240);
6501 l_third_party_note varchar2(240);
6502 l_run_assignment_action_id number ;
6503 l_jurisdiction varchar2(20);
6504 l_state varchar2(2);
6505 l_county varchar2(240);
6506 l_print_ssn varchar2(1) ;
6507 l_print_wages varchar(1) ;
6508 l_print_county_name varchar2(1);
6509 l_def_bal_id number;
6510 l_cnty_name varchar2(240);
6511 lv_garn_arch VARCHAR2(10);
6512 lv_act_param pay_action_parameters.parameter_value%TYPE;
6513 lb_use_new_arch boolean;
6514 lv_procedure_name VARCHAR2(100) := '.get_attachment_number';
6515 lv_error_message VARCHAR2(200);
6516 ln_step NUMBER;
6517 l_ele_upg_stat number; -- Added for 14098797
6518 l_upg_date varchar2(25); -- Added for 14098797
6519 l_date_earned varchar2(25); -- Added for 14098797
6520
6521 BEGIN --FUNCTION get_attachment_number
6522 hr_utility.set_location(gv_package || lv_procedure_name, 10);
6523 ln_step := 1;
6524 hr_utility.trace('p_value = ' || p_value);
6525 hr_utility.trace('p_pre_payment_id = ' || p_pre_payment_id);
6526 hr_utility.trace('p_assignment_id = ' || p_assignment_id);
6527 hr_utility.trace('p_tax_unit_id = ' || p_tax_unit_id);
6528 hr_utility.trace('p_business_group_id = ' || p_business_group_id);
6529 if p_assignment_id <> g_assignment_id then
6530 g_assignment_id := p_assignment_id;
6531 g_printed := '-1';
6532 end if;
6533
6534 /* Checking if BG is Upgraded */
6535
6536 open csr_garn_arch;
6537 fetch csr_garn_arch into lv_garn_arch;
6538 if csr_garn_arch%NOTFOUND then
6539 lv_garn_arch := 'X';
6540 end if;
6541 close csr_garn_arch;
6542 hr_utility.trace('lv_garn_arch := ' || lv_garn_arch);
6543
6544
6545 /* Checking Action Parameter value */
6546
6547 open csr_action_param;
6548 fetch csr_action_param into lv_act_param;
6549 if csr_action_param%NOTFOUND then
6550 lv_act_param := 'X';
6551 end if;
6552 close csr_action_param;
6553 hr_utility.trace('lv_act_param := ' || lv_act_param);
6554
6555
6556 /* Following is the logic to determine what WA Arch is in use
6557 BG Upgraded + Action Param 'Y' = New WA Arch
6558 BG Upgraded + Action Param 'N' = New WA Arch
6559 BG Upgraded + NO Action Param = New WA Arch
6560 BG Not Upgraded + Action Param 'Y' = New WA Arch
6561 BG Not Upgraded + Action Param 'N' = Old WA Arch
6562 BG Not Upgraded + NO Action Param = New WA Arch
6563 */
6564
6565 lb_use_new_arch := FALSE;
6566
6567 if (NVL(lv_garn_arch, 'X') = 'Y'
6568 or NVL(lv_act_param, 'X') = 'Y'
6569 or ( NVL(lv_garn_arch, 'X') = 'X' AND NVL(lv_act_param, 'X') = 'X' )) then
6570
6571 lb_use_new_arch := TRUE;
6572 hr_utility.set_location(gv_package || lv_procedure_name, 20);
6573 else
6574 lb_use_new_arch := FALSE;
6575 ln_step := 5;
6576 end if;
6577
6578 -- Added for 14098797
6579 if lb_use_new_arch then
6580 open upgrade_status;
6581 fetch upgrade_status into l_ele_type_id, l_date_earned, l_ele_upg_stat;
6582 close upgrade_status;
6583
6584 if l_ele_upg_stat > 0 then
6585 hr_utility.trace( 'l_ele_type_id := '||l_ele_type_id);
6586 hr_utility.trace( 'l_date_earned := '||l_date_earned);
6587 hr_utility.trace( 'l_ele_upg_stat := '||l_ele_upg_stat);
6588 hr_utility.trace( 'Upgraded Element.');
6589 open upgrade_date(l_ele_type_id);
6590 fetch upgrade_date into l_upg_date;
6591 close upgrade_date;
6592 hr_utility.trace( 'l_upg_date := '||l_upg_date);
6593
6594 if to_date(l_date_earned,'DD-MM-YYYY') < to_date(l_upg_date,'DD-MM-YYYY') then
6595 lb_use_new_arch := FALSE;
6596 hr_utility.trace( 'Upgrade is after the Date Earned');
6597 end if;
6598 end if;
6599 end if;
6600 -- End of changes for 14098797
6601
6602 if lb_use_new_arch then
6603 open c_get_att_no_new ;
6604 else
6605 open c_get_att_no_old ;
6606 end if;
6607
6608 /* open c_get_att_no; */
6609
6610 loop
6611 hr_utility.set_location(gv_package || lv_procedure_name, 30);
6612 if lb_use_new_arch then
6613
6614 fetch c_get_att_no_new into
6615 l_garn_ref_no
6616 ,l_amount
6617 ,p_payment_date
6618 ,p_earned_date
6619 ,l_run_result_id
6620 ,p_fips_code
6621 ,p_medical_indicator
6622 ,p_third_party_note
6623 ,l_run_assignment_action_id
6624 ,l_ele_type_id;
6625 exit when c_get_att_no_new%NOTFOUND;
6626 ln_step := 10;
6627 hr_utility.trace('New Garn Ref No = '||l_garn_ref_no);
6628 hr_utility.trace('New Amount = '||l_amount);
6629 hr_utility.trace('New Payment_date = '||p_payment_date);
6630 hr_utility.trace('New Date Earned = '||p_earned_date);
6631 hr_utility.trace('New RRI = '||to_char(l_run_result_id));
6632 hr_utility.trace('New l_printed = '||to_char(l_printed));
6633 else
6634 fetch c_get_att_no_old into
6635 l_garn_ref_no
6636 ,l_amount
6637 ,p_payment_date
6638 ,p_earned_date
6639 ,l_run_result_id
6640 ,p_fips_code
6641 ,p_medical_indicator
6642 ,p_third_party_note
6643 ,l_run_assignment_action_id
6644 ,l_ele_type_id;
6645 exit when c_get_att_no_old%NOTFOUND;
6646 ln_step := 15;
6647 hr_utility.trace('Old Garn Ref No = '||l_garn_ref_no);
6648 hr_utility.trace('Old Amount = '||l_amount);
6649 hr_utility.trace('Old Payment_date = '||p_payment_date);
6650 hr_utility.trace('Old Date Earned = '||p_earned_date);
6651 hr_utility.trace('Old RRI = '||to_char(l_run_result_id));
6652 hr_utility.trace('Old l_printed = '||to_char(l_printed));
6653 end if;
6654
6655 l_printed := instr(g_printed,to_char(l_run_result_id));
6656 hr_utility.trace('New l_printed = '||to_char(l_printed));
6657
6658 if l_printed > 0 then
6659 null;
6660 hr_utility.trace('Already printed RRI = '||to_char(l_run_result_id));
6661 hr_utility.set_location(gv_package || lv_procedure_name, 40);
6662 ln_step := 20;
6663 else
6664 g_printed := g_printed||','||to_char(l_run_result_id);
6665 ln_step := 25;
6666
6667 -- get the jurisdiction
6668 l_jurisdiction := null ;
6669
6670 open jur(l_run_assignment_action_id, l_ele_type_id, p_earned_date) ;
6671 fetch jur into l_jurisdiction ;
6672 IF jur%NOTFOUND then
6673 l_jurisdiction := null;
6674 end if;
6675 close jur ;
6676
6677 IF l_jurisdiction is not null THEN
6678 p_jurisdiction := l_jurisdiction;
6679 l_state := substr(l_jurisdiction,1,2) ;
6680 l_county := substr(l_jurisdiction,1,6) || '-0000' ;
6681 END IF;
6682
6683 -- Get the print_ssn for a county
6684 -- from pay_us_county_tax_info_f with the cnty_information1
6685 -- For example Monroe County in Ohio State should return Y
6686
6687 l_print_ssn := null;
6688 l_print_wages := null;
6689 l_print_county_name := null ;
6690
6691 IF l_jurisdiction is not null THEN
6692 open cnty ( l_county, p_earned_date ) ;
6693 fetch cnty into l_print_ssn;
6694 close cnty ;
6695 END IF;
6696 if l_print_ssn ='Y' then
6697 p_print_ssn := l_print_ssn;
6698 end if;
6699
6700
6701 IF l_jurisdiction is not null THEN
6702 open state( l_state, p_earned_date );
6703 fetch state into l_print_wages, l_print_county_name ;
6704 close state ;
6705 END IF;
6706
6707 if l_print_wages ='Y' then
6708 null;
6709 pay_balance_pkg.set_context ('TAX_UNIT_ID',p_tax_unit_id );
6710 pay_balance_pkg.set_context ('BUSINESS_GROUP_ID',p_business_group_id );
6711 l_def_bal_id := hr_us_reports.get_defined_balance_id
6712 ('Gross Earnings','_ASG_GRE_RUN',p_business_group_id );
6713 p_wages := pay_balance_pkg.get_value(l_def_bal_id, l_run_assignment_action_id );
6714 end if;
6715
6716 if l_print_county_name ='Y' then
6717 -- get county name
6718 open cnty_name ( l_jurisdiction );
6719 fetch cnty_name into l_cnty_name ;
6720 close cnty_name ;
6721 if l_cnty_name is not null then
6722 p_cnty_name := l_cnty_name;
6723 end if;
6724 end if ;
6725 ln_step := 30;
6726 hr_utility.set_location(gv_package || lv_procedure_name, 50);
6727 hr_utility.trace('g_printed = '||g_printed);
6728 hr_utility.trace('g_assignment_id = '||g_assignment_id);
6729 hr_utility.trace('l_garn_ref_no = '||l_garn_ref_no);
6730 return(l_garn_ref_no);
6731 end if;
6732 end loop;
6733
6734 if lb_use_new_arch then
6735 close c_get_att_no_new ;
6736 else
6737 close c_get_att_no_old ;
6738 end if;
6739
6740 return (null);
6741 EXCEPTION
6742 when others then
6743 lv_error_message := 'Error in ' ||
6744 gv_package || lv_procedure_name;
6745
6746 hr_utility.trace(lv_error_message || '-' || sqlerrm);
6747
6748 lv_error_message :=
6749 pay_emp_action_arch.set_error_message(lv_error_message);
6750
6751 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
6752 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
6753 hr_utility.raise_error;
6754 END get_attachment_number;
6755 /* get attachment number end */
6756
6757
6758
6759 /************************************************************
6760 Name : get_3rdparty_check
6761 Purpose : This procedure Archives data which are used in
6762 Third Party Check Writer (XML). Context used is
6763 'US THIRD PARTY CHECKS'
6764 Arguments :
6765 Notes :
6766 ************************************************************/
6767 PROCEDURE get_3rdparty_check(p_pre_pay_action_id in number
6768 ,p_assignment_id in number
6769 ,p_curr_pymt_eff_date in date
6770 ,p_ppp_source_action_id in number
6771 ,p_payroll_id in number
6772 ,p_xfr_action_id in number
6773 ,p_tax_unit_id in number
6774 ,p_business_group_id in number
6775 )
6776 IS
6777
6778 cursor c_child_action (cp_pre_pay_action_id in number
6779 ,cp_assignment_id in number) is
6780 select paa.assignment_action_id
6781 from pay_assignment_actions paa
6782 where paa.source_action_id = cp_pre_pay_action_id
6783 and paa.assignment_id = cp_assignment_id
6784 and paa.action_status = 'C';
6785
6786 cursor c_third_party_pay(cp_pre_pay_action_id in number
6787 ,cp_assignment_id in number
6788 ,cp_curr_pymt_eff_date in date
6789 ,cp_ppp_source_action_id in number
6790 ) is
6791 select ppp.value amount,
6792 ppp.pre_payment_id,
6793 popm.org_payment_method_id,
6794 popm.org_payment_method_name,
6795 pppm.personal_payment_method_id,
6796 pppm.payee_id,
6797 pppm.payee_type
6798 from pay_assignment_actions paa,
6799 pay_pre_payments ppp,
6800 pay_org_payment_methods_f popm ,
6801 pay_personal_payment_methods_f pppm,
6802 pay_payment_types ppt
6803 where ppt.payment_type_id = popm.payment_type_id
6804 and ppt.category = 'CH'
6805 and paa.assignment_action_id = cp_pre_pay_action_id
6806 and ppp.assignment_action_id = paa.assignment_action_id
6807 and paa.assignment_id = cp_assignment_id
6808 and ( ( ppp.source_action_id is null
6809 and cp_ppp_source_action_id is null)
6810 or
6811 -- is it a Normal or Process Separate specific
6812 -- Payments should be included in the Standard
6813 -- SOE. Only Separate Payments should be in
6814 -- a Separate SOE.
6815 (ppp.source_action_id is not null
6816 and cp_ppp_source_action_id is null
6817 and exists (
6818 select ''
6819 from pay_run_types_f prt,
6820 pay_assignment_actions paa_run,
6821 pay_payroll_actions ppa_run
6822 where paa_run.assignment_action_id
6823 = ppp.source_action_id
6824 and paa_run.payroll_action_id
6825 = ppa_run.payroll_action_id
6826 and paa_run.run_type_id = prt.run_type_id
6827 and prt.run_method in ('P', 'N')
6828 and ppa_run.effective_date
6829 between prt.effective_start_date
6830 and prt.effective_end_date
6831 )
6832 )
6833 or
6834 (cp_ppp_source_action_id is not null
6835 and ppp.source_action_id = cp_ppp_source_action_id)
6836 )
6837 and ppp.org_payment_method_id = popm.org_payment_method_id
6838 and popm.defined_balance_id is null
6839 and pppm.personal_payment_method_id(+)
6840 = ppp.personal_payment_method_id
6841 and cp_curr_pymt_eff_date between popm.effective_start_date
6842 and popm.effective_end_date
6843 and cp_curr_pymt_eff_date between nvl(pppm.effective_start_date,
6844 cp_curr_pymt_eff_date)
6845 and nvl(pppm.effective_end_date,
6846 cp_curr_pymt_eff_date);
6847
6848
6849 cursor get_payee_person_dets(cp_payee_id in number
6850 ,cp_business_group_id in number
6851 ,cp_payment_date in date
6852 ) is
6853 select initcap(rtrim(ppf.title))||' '||
6854 rtrim(ppf.first_name)||' '||rtrim(ppf.last_name),
6855 addr.address_line1,
6856 addr.address_line2,
6857 addr.address_line3,
6858 rtrim(addr.town_or_city),
6859 addr.region_2,
6860 addr.postal_code
6861 from
6862 per_addresses addr,
6863 per_all_people_f ppf
6864 where
6865 ppf.person_id = cp_payee_id
6866 and ppf.business_group_id = cp_business_group_id
6867 and cp_payment_date between ppf.effective_start_date
6868 and ppf.effective_end_date
6869 and addr.person_id = ppf.person_id
6870 and addr.primary_flag = 'Y'
6871 and cp_payment_date between addr.date_from
6872 and nvl(addr.date_to, cp_payment_date);
6873
6874
6875
6876 cursor get_payee_org_dets(cp_payee_id in number
6877 ,cp_business_group_id in number
6878 ,cp_payment_date in date
6879 ) is
6880 select hou.name,
6881 loc.address_line_1,
6882 loc.address_line_2,
6883 loc.address_line_3,
6884 rtrim(loc.town_or_city),
6885 loc.region_2,
6886 loc.postal_code
6887 from
6888 hr_locations_all loc,
6889 hr_all_organization_units hou
6890 where
6891 hou.organization_id = cp_payee_id
6892 and hou.business_group_id = cp_business_group_id
6893 and cp_payment_date between hou.date_from
6894 and nvl(hou.date_to, cp_payment_date)
6895 and loc.location_id = hou.location_id;
6896
6897 cursor c_legislation (cp_business_group_id in number) is
6898 select org_information9
6899 from hr_organization_information
6900 where org_information_context = 'Business Group Information'
6901 and organization_id = cp_business_group_id;
6902
6903 lv_procedure_name VARCHAR2(100) := '.get_3rdparty_check';
6904 ln_step NUMBER;
6905 lv_error_message VARCHAR2(500);
6906 ln_index NUMBER;
6907 ln_value NUMBER(15,2);
6908 ln_pre_payment_id NUMBER;
6909 ln_org_payment_method_id NUMBER;
6910 lv_org_payment_method_name VARCHAR2(300);
6911 ln_emp_payment_method_id NUMBER;
6912 k NUMBER;
6913 ln_payee_id NUMBER;
6914 ln_payee_type VARCHAR2(5);
6915 ln_payee_name VARCHAR2(300);
6916 ln_address_line1 VARCHAR2(300);
6917 ln_address_line2 VARCHAR2(300);
6918 ln_address_line3 VARCHAR2(300);
6919 ln_town_or_city VARCHAR2(300);
6920 ln_region2 VARCHAR2(300);
6921 ln_postal_code VARCHAR2(300);
6922 lv_legislation_code VARCHAR2(2);
6923 ln_attachment_number VARCHAR2(300);
6924 ln_fips_code VARCHAR2(300);
6925 ln_medical_indicator VARCHAR2(300);
6926 ln_third_party_note VARCHAR2(300);
6927 ln_payment_date VARCHAR2(300);
6928 ln_earned_date VARCHAR2(300);
6929 ln_jurisdiction VARCHAR2(20);
6930 ln_print_ssn VARCHAR2(1);
6931 ln_wages NUMBER;
6932 ln_cnty_name VARCHAR2(240);
6933
6934 TYPE actions_tab IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
6935 ltt_actions actions_tab;
6936
6937 BEGIN -- begin get 3rd party checks
6938 hr_utility.trace('p_xfr_action_id = ' || p_xfr_action_id);
6939 hr_utility.trace('p_pre_pay_action_id = ' || p_pre_pay_action_id);
6940 hr_utility.trace('p_assignment_id = ' || p_assignment_id);
6941 hr_utility.trace('p_curr_pymt_eff_date = ' || p_curr_pymt_eff_date);
6942 hr_utility.trace('p_ppp_source_action_id = '|| p_ppp_source_action_id);
6943 hr_utility.trace('p_payroll_id = ' || p_payroll_id);
6944 hr_utility.trace('p_tax_unit_id = ' || p_tax_unit_id);
6945 hr_utility.trace('p_business_group_id = ' || p_business_group_id);
6946
6947 pay_emp_action_arch.gv_error_message := NULL;
6948 hr_utility.set_location(gv_package || lv_procedure_name, 10);
6949 ln_step := 1;
6950 k:=0;
6951
6952 -- Check if Multi assignment payment is enabled
6953 if pay_emp_action_arch.gv_multi_payroll_pymt is null then
6954 pay_emp_action_arch.gv_multi_payroll_pymt
6955 := pay_emp_action_arch.get_multi_assignment_flag(
6956 p_payroll_id => p_payroll_id
6957 ,p_effective_date => p_curr_pymt_eff_date);
6958 end if;
6959 hr_utility.set_location(gv_package || lv_procedure_name,20);
6960
6961 if nvl(pay_emp_action_arch.gv_multi_payroll_pymt, 'N') = 'Y' then
6962 -- If Multi Assignment Payment is enabled, get the child prepayment
6963 -- actions as payment information is stored against child.
6964 -- Insert this data in pl/sql table.
6965 for cval in c_child_action(p_pre_pay_action_id, p_assignment_id) loop
6966 ltt_actions(k) := cval.assignment_action_id;
6967 k := k + 1;
6968 end loop;
6969 hr_utility.set_location(gv_package || lv_procedure_name,30);
6970 else
6971 ltt_actions(k) := p_pre_pay_action_id;
6972 k := k + 1;
6973 hr_utility.set_location(gv_package || lv_procedure_name,40);
6974 end if;
6975
6976 -- Value of k will be zero only if the payroll is enabled for multi
6977 -- assignment payments and we are processing seperate check action.
6978 -- In this case, passed assignment action is added to pl/sql table.
6979 if k = 0 then
6980 ltt_actions(k) := p_pre_pay_action_id;
6981 hr_utility.set_location(gv_package || lv_procedure_name, 50);
6982 end if;
6983
6984 for j in ltt_actions.first .. ltt_actions.last loop
6985 hr_utility.trace('assignment action = ' || ltt_actions(j));
6986 end loop;
6987
6988 for j in ltt_actions.first .. ltt_actions.last loop
6989 open c_third_party_pay(ltt_actions(j)
6990 ,p_assignment_id
6991 ,p_curr_pymt_eff_date
6992 ,p_ppp_source_action_id);
6993
6994 loop
6995 fetch c_third_party_pay into ln_value
6996 ,ln_pre_payment_id
6997 ,ln_org_payment_method_id
6998 ,lv_org_payment_method_name
6999 ,ln_emp_payment_method_id
7000 ,ln_payee_id
7001 ,ln_payee_type;
7002 hr_utility.trace('Fetched c_third_party_pay ');
7003 if c_third_party_pay%notfound then
7004 exit;
7005 end if;
7006
7007 open c_legislation (p_business_group_id);
7008 fetch c_legislation into lv_legislation_code ;
7009 close c_legislation;
7010 hr_utility.trace('lv_legislation_code := '||lv_legislation_code);
7011
7012 if ln_payee_id is not null and ln_payee_type is not null then
7013 if ln_payee_type='O' then
7014 hr_utility.set_location(gv_package || lv_procedure_name, 60);
7015 open get_payee_org_dets(ln_payee_id
7016 ,p_business_group_id
7017 ,p_curr_pymt_eff_date);
7018 fetch get_payee_org_dets into ln_payee_name
7019 ,ln_address_line1
7020 ,ln_address_line2
7021 ,ln_address_line3
7022 ,ln_town_or_city
7023 ,ln_region2
7024 ,ln_postal_code;
7025 hr_utility.trace('Fetched get_payee_org_dets for payee ID '||ln_payee_id);
7026 close get_payee_org_dets;
7027 elsif ln_payee_type='P' then
7028 hr_utility.set_location(gv_package || lv_procedure_name, 70);
7029 open get_payee_person_dets(ln_payee_id, p_business_group_id,
7030 p_curr_pymt_eff_date);
7031 fetch get_payee_person_dets into ln_payee_name
7032 ,ln_address_line1
7033 ,ln_address_line2
7034 ,ln_address_line3
7035 ,ln_town_or_city
7036 ,ln_region2
7037 ,ln_postal_code;
7038 hr_utility.trace('Fetched get_payee_person_dets for payee ID '||ln_payee_id);
7039 close get_payee_person_dets;
7040 end if;
7041 end if;
7042
7043 ln_attachment_number := get_attachment_number(p_value => ln_value
7044 ,p_pre_payment_id => ln_pre_payment_id
7045 ,p_assignment_id => p_assignment_id
7046 ,p_tax_unit_id => p_tax_unit_id
7047 ,p_business_group_id => p_business_group_id
7048 ,p_fips_code => ln_fips_code
7049 ,p_medical_indicator => ln_medical_indicator
7050 ,p_third_party_note => ln_third_party_note
7051 ,p_payment_date => ln_payment_date
7052 ,p_earned_date => ln_earned_date
7053 ,p_jurisdiction => ln_jurisdiction
7054 ,p_print_ssn => ln_print_ssn
7055 ,p_wages => ln_wages
7056 ,p_cnty_name => ln_cnty_name
7057 );
7058
7059 hr_utility.set_location(gv_package || lv_procedure_name, 80);
7060
7061 ln_index := pay_ac_action_arch.lrr_act_tab.count;
7062
7063 hr_utility.trace('ln_index in get_3rdparty_pay_distribution proc is '
7064 || pay_ac_action_arch.lrr_act_tab.count);
7065 hr_utility.trace('Attachment details ln_earned_date = '|| ln_earned_date);
7066 hr_utility.trace('ln_fips_code = '|| ln_fips_code);
7067 hr_utility.trace('ln_third_party_note = '|| ln_third_party_note);
7068 hr_utility.trace('ln_medical_indicator = '|| ln_medical_indicator);
7069 hr_utility.trace('ln_jurisdiction = '|| ln_jurisdiction);
7070 hr_utility.trace('ln_print_ssn = '|| ln_print_ssn);
7071 hr_utility.trace('ln_wages = '|| ln_wages);
7072 hr_utility.trace('ln_cnty_name = '|| ln_cnty_name);
7073
7074 pay_ac_action_arch.lrr_act_tab(ln_index).action_info_category
7075 := 'US THIRD PARTY CHECKS';
7076 pay_ac_action_arch.lrr_act_tab(ln_index).jurisdiction_code
7077 := '00-000-0000';
7078 pay_ac_action_arch.lrr_act_tab(ln_index).act_info1
7079 := NULL;
7080 hr_utility.trace('ln_org_payment_method_id'||ln_org_payment_method_id);
7081 pay_ac_action_arch.lrr_act_tab(ln_index).act_info2
7082 := ln_pre_payment_id;
7083 pay_ac_action_arch.lrr_act_tab(ln_index).act_info3
7084 := fnd_number.number_to_canonical(ln_value);
7085 pay_ac_action_arch.lrr_act_tab(ln_index).act_info4
7086 := ltt_actions(j);
7087 pay_ac_action_arch.lrr_act_tab(ln_index).act_info5
7088 := ln_org_payment_method_id;
7089 pay_ac_action_arch.lrr_act_tab(ln_index).act_info6
7090 := lv_org_payment_method_name;
7091 pay_ac_action_arch.lrr_act_tab(ln_index).act_info7
7092 := ln_emp_payment_method_id;
7093 pay_ac_action_arch.lrr_act_tab(ln_index).act_info8
7094 := ln_payee_id;
7095 pay_ac_action_arch.lrr_act_tab(ln_index).act_info9
7096 := fnd_date.date_to_canonical(ln_earned_date);
7097 pay_ac_action_arch.lrr_act_tab(ln_index).act_info10
7098 := fnd_date.date_to_canonical(ln_payment_date);
7099 pay_ac_action_arch.lrr_act_tab(ln_index).act_info11
7100 := ln_payee_name ;
7101 pay_ac_action_arch.lrr_act_tab(ln_index).act_info12
7102 := ln_address_line1;
7103 pay_ac_action_arch.lrr_act_tab(ln_index).act_info13
7104 := ln_address_line2;
7105 pay_ac_action_arch.lrr_act_tab(ln_index).act_info14
7106 := ln_address_line3;
7107 pay_ac_action_arch.lrr_act_tab(ln_index).act_info15
7108 := ln_town_or_city;
7109 pay_ac_action_arch.lrr_act_tab(ln_index).act_info16
7110 := ln_region2;
7111 pay_ac_action_arch.lrr_act_tab(ln_index).act_info17
7112 := ln_postal_code;
7113 pay_ac_action_arch.lrr_act_tab(ln_index).act_info18
7114 := ln_attachment_number;
7115 pay_ac_action_arch.lrr_act_tab(ln_index).act_info19
7116 := ln_jurisdiction;
7117 pay_ac_action_arch.lrr_act_tab(ln_index).act_info20
7118 := ln_print_ssn;
7119 pay_ac_action_arch.lrr_act_tab(ln_index).act_info21
7120 := ln_fips_code;
7121 pay_ac_action_arch.lrr_act_tab(ln_index).act_info22
7122 := ln_third_party_note;
7123 pay_ac_action_arch.lrr_act_tab(ln_index).act_info23
7124 := ln_wages;
7125 pay_ac_action_arch.lrr_act_tab(ln_index).act_info24
7126 := ln_cnty_name;
7127 pay_ac_action_arch.lrr_act_tab(ln_index).act_info25
7128 := ln_medical_indicator;
7129
7130 end loop;
7131 close c_third_party_pay;
7132 end loop;
7133 hr_utility.set_location(gv_package || lv_procedure_name,100);
7134
7135 EXCEPTION
7136 when others then
7137 lv_error_message := 'Error at step ' || ln_step || ' in ' ||
7138 gv_package || lv_procedure_name;
7139
7140 hr_utility.trace(lv_error_message || '-' || sqlerrm);
7141
7142 lv_error_message :=
7143 pay_emp_action_arch.set_error_message(lv_error_message);
7144
7145 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
7146 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
7147 hr_utility.raise_error;
7148
7149 END get_3rdparty_check;
7150 -- 13029995 changes to support/archive Third Party XML Checks end
7151
7152
7153
7154 /************************************************************
7155 Name : process_actions
7156 Purpose :
7157 Arguments : p_rqp_action_id - For Child actions we pass the
7158 Action ID of Run/Quick Pay
7159 - For Master we pass the Action ID
7160 of Pre Payment Process.
7161 Notes :
7162 ************************************************************/
7163 PROCEDURE process_actions( p_xfr_payroll_action_id in number
7164 ,p_xfr_action_id in number
7165 ,p_pre_pay_action_id in number
7166 ,p_payment_action_id in number
7167 ,p_rqp_action_id in number
7168 ,p_seperate_check_flag in varchar2 default 'N'
7169 ,p_sepcheck_run_type_id in number
7170 ,p_action_type in varchar2
7171 ,p_legislation_code in varchar2
7172 ,p_assignment_id in number
7173 ,p_payroll_id in number
7174 ,p_consolidation_set_id in number
7175 ,p_tax_unit_id in number
7176 ,p_curr_pymt_eff_date in date
7177 ,p_xfr_start_date in date
7178 ,p_xfr_end_date in date
7179 ,p_ppp_source_action_id in number default null
7180 ,p_archive_balance_info in varchar2 default 'Y'
7181 ,p_last_xfr_eff_date out nocopy date
7182 ,p_last_xfr_action_id out nocopy number
7183 )
7184 IS
7185
7186 cursor c_ytd_aaid(cp_prepayment_action_id in number
7187 ,cp_assignment_id in number
7188 ,cp_sepchk_run_type in number) is
7189 select paa.assignment_action_id
7190 from pay_assignment_actions paa,
7191 pay_action_interlocks pai,
7192 pay_payroll_actions ppa
7193 where pai.locking_action_id = cp_prepayment_action_id
7194 and paa.assignment_action_id = pai.locked_action_id
7195 and paa.assignment_id = cp_assignment_id
7196 and ppa.payroll_action_id = paa.payroll_action_id
7197 and nvl(paa.run_type_id,0) <> cp_sepchk_run_type
7198 order by paa.assignment_action_id desc;
7199
7200 cursor c_time_period(cp_run_assignment_action in number) is
7201 select ptp.time_period_id,
7202 --bug 7379102
7203 -- ppa.date_earned,
7204 nvl(ppa.date_earned,ppa.effective_date),
7205 --bug 7379102
7206 ppa.effective_date
7207 from pay_assignment_actions paa,
7208 pay_payroll_actions ppa,
7209 per_time_periods ptp
7210 where paa.assignment_action_id = cp_run_assignment_action
7211 and ppa.payroll_action_id = paa.payroll_action_id
7212 and ptp.payroll_id = ppa.payroll_id
7213 --bug 7379102
7214 -- and ppa.date_earned between ptp.start_date and ptp.end_date;
7215 and nvl(ppa.date_earned,ppa.effective_date) between ptp.start_date and ptp.end_date;
7216 --bug 7379102
7217
7218 cursor c_chk_act_type(cp_last_xfr_act_id number) is
7219 select substr(serial_number,1,1)
7220 from pay_assignment_actions paa
7221 where paa.assignment_action_id = cp_last_xfr_act_id;
7222
7223 -- added below cursor for 13029995
7224 cursor cur_busgrp is
7225 select paf.business_group_id
7226 from per_assignments_f paf
7227 where paf.assignment_id = p_assignment_id
7228 and p_curr_pymt_eff_date between paf.effective_start_date
7229 and paf.effective_end_date;
7230
7231 lv_pre_xfr_act_type VARCHAR2(80);
7232
7233 ln_run_action_id NUMBER;
7234 ln_ytd_balcall_aaid NUMBER;
7235 ld_run_date_earned DATE;
7236 ld_run_effective_date DATE;
7237
7238 ld_last_xfr_eff_date DATE;
7239 ln_last_xfr_action_id NUMBER;
7240 ld_last_pymt_eff_date DATE;
7241 ln_last_pymt_action_id NUMBER;
7242
7243 ln_time_period_id NUMBER;
7244 lv_resident_jurisdiction VARCHAR2(15);
7245
7246 lv_resident_city VARCHAR2(30); -- Bug 3452149
7247 lv_resident_county VARCHAR2(30);
7248 lv_resident_state VARCHAR2(30);
7249
7250 lv_procedure_name VARCHAR2(100) := '.process_actions';
7251 lv_error_message VARCHAR2(200);
7252
7253 --added for 13029995
7254 ln_business_group_id NUMBER;
7255
7256 BEGIN
7257 hr_utility.set_location(gv_package || lv_procedure_name, 10);
7258 pay_balance_pkg.set_context('TAX_UNIT_ID', p_tax_unit_id);
7259 /****************************************************************
7260 ** For Seperate Check we do the YTD balance calls with the Run
7261 ** Action ID. So, we do not need to get the max. action which is
7262 ** not seperate Check.
7263 ** Also, p_ppp_source_action_id is set to null as we want to get
7264 ** all records from pay_pre_payments where source_action_id is
7265 ** is null.
7266 ****************************************************************/
7267 ln_ytd_balcall_aaid := p_payment_action_id;
7268 if p_seperate_check_flag = 'N' and
7269 p_action_type in ('U', 'P') then
7270 hr_utility.set_location(gv_package || lv_procedure_name, 40);
7271 open c_ytd_aaid(p_rqp_action_id,
7272 p_assignment_id,
7273 p_sepcheck_run_type_id);
7274 fetch c_ytd_aaid into ln_ytd_balcall_aaid;
7275 if c_ytd_aaid%notfound then
7276 hr_utility.set_location(gv_package || lv_procedure_name, 50);
7277 hr_utility.raise_error;
7278 end if;
7279 close c_ytd_aaid;
7280 end if;
7281
7282 hr_utility.set_location(gv_package || lv_procedure_name, 60);
7283
7284 open c_time_period(p_payment_action_id);
7285 fetch c_time_period into ln_time_period_id,
7286 ld_run_date_earned,
7287 ld_run_effective_date;
7288 close c_time_period;
7289
7290 hr_utility.set_location(gv_package || lv_procedure_name, 70);
7291 pay_ac_action_arch.get_last_xfr_info(
7292 p_assignment_id => p_assignment_id
7293 ,p_curr_effective_date => p_xfr_end_date
7294 ,p_action_info_category => 'EMPLOYEE DETAILS'
7295 ,p_xfr_action_id => p_xfr_action_id
7296 ,p_sepchk_flag => p_seperate_check_flag
7297 ,p_last_xfr_eff_date => ld_last_xfr_eff_date
7298 ,p_last_xfr_action_id => ln_last_xfr_action_id
7299 ,p_arch_bal_info => p_archive_balance_info
7300 ,p_legislation_code => p_legislation_code
7301 );
7302
7303 if ld_last_xfr_eff_date is not null then
7304 if gv_act_param_val is not null then
7305 if gv_act_param_val = 'Y'
7306 then
7307 ld_last_xfr_eff_date := NULL;
7308 elsif fnd_date.canonical_to_date(gv_act_param_val) = p_xfr_end_date
7309 then
7310 ld_last_xfr_eff_date := NULL;
7311 end if;
7312 end if;
7313 end if;
7314
7315 -- This is no longer going to be called as ln_last_xfr_action_id
7316 -- will never be a archive for balance adjustment
7317 if ld_last_xfr_eff_date is not null then
7318 open c_chk_act_type(ln_last_xfr_action_id);
7319 fetch c_chk_act_type into lv_pre_xfr_act_type;
7320 close c_chk_act_type;
7321
7322 if lv_pre_xfr_act_type = 'B' then
7323 ld_last_xfr_eff_date := NULL;
7324 end if;
7325 end if;
7326
7327 p_last_xfr_eff_date := ld_last_xfr_eff_date;
7328 p_last_xfr_action_id := ln_last_xfr_action_id;
7329
7330 hr_utility.trace('p_xfr_payroll_action_id= '|| p_xfr_payroll_action_id);
7331 hr_utility.trace('p_xfr_action_id = ' || p_xfr_action_id);
7332 hr_utility.trace('p_seperate_check_flag = ' || p_seperate_check_flag);
7333 hr_utility.trace('p_action_type = ' || p_action_type);
7334 hr_utility.trace('p_pre_pay_action_id = ' || p_pre_pay_action_id);
7335 hr_utility.trace('p_payment_action_id = ' || p_payment_action_id);
7336 hr_utility.trace('p_rqp_action_id = ' || p_rqp_action_id);
7337 hr_utility.trace('p_sepcheck_run_type_id = '|| p_sepcheck_run_type_id);
7338 hr_utility.trace('p_assignment_id = ' || p_assignment_id);
7339 hr_utility.trace('p_xfr_start_date = ' || p_xfr_start_date );
7340 hr_utility.trace('p_xfr_end_date = ' || p_xfr_end_date );
7341 hr_utility.trace('p_curr_pymt_eff_date = ' || p_curr_pymt_eff_date);
7342 hr_utility.trace('ld_run_effective_date = ' || ld_run_effective_date);
7343 hr_utility.trace('ln_ytd_balcall_aaid = ' || ln_ytd_balcall_aaid);
7344 hr_utility.trace('p_ppp_source_action_id = '|| p_ppp_source_action_id);
7345 hr_utility.trace('ld_run_date_earned = ' || ld_run_date_earned);
7346 hr_utility.trace('ld_last_xfr_eff_date = ' || ld_last_xfr_eff_date);
7347 hr_utility.trace('ln_last_xfr_action_id = ' || ln_last_xfr_action_id);
7348
7349 pay_ac_action_arch.initialization_process;
7350
7351 /*********************************************************************
7352 ** If p_archive_balance_info is not Y then it mean that the assignment
7353 ** does not have any Gross or Payments in the Run. In this case, we
7354 ** only archive the employee level information and also move forward
7355 ** elements from previous archive.
7356 ** The only issue with the approach is if the first archiver run
7357 ** for the employee has no Gross or Payments Balance. In this case
7358 ** any non-recurring processed from 1st Jan till date willl not be
7359 ** archived.
7360 *********************************************************************/
7361 if p_archive_balance_info = 'Y' then
7362 populate_puv_tax_balances(
7363 p_xfr_action_id => p_xfr_action_id
7364 ,p_assignment_id => p_assignment_id
7365 ,p_pymt_balcall_aaid => p_payment_action_id
7366 ,p_ytd_balcall_aaid => ln_ytd_balcall_aaid
7367 ,p_tax_unit_id => p_tax_unit_id
7368 ,p_action_type => p_action_type
7369 ,p_rqp_action_id => p_rqp_action_id
7370 ,p_start_date => p_xfr_start_date
7371 ,p_end_date => p_xfr_end_date
7372 ,p_run_effective_date => ld_run_effective_date
7373 ,p_sepchk_run_type_id => p_sepcheck_run_type_id
7374 ,p_sepchk_flag => p_seperate_check_flag
7375 ,p_resident_jurisdiction => lv_resident_jurisdiction
7376 );
7377 hr_utility.set_location(gv_package || lv_procedure_name, 90);
7378
7379 /******************************************************************
7380 ** For seperate check cases, the ld_last_xfr_eff_date is never null
7381 ** as the master is always processed before the child actions. The
7382 ** master data is already in the archive table and as it is in the
7383 ** same session the process will always go to the else statement
7384 ******************************************************************/
7385 if ld_last_xfr_eff_date is null then
7386 hr_utility.set_location(gv_package || lv_procedure_name, 100);
7387 pay_ac_action_arch.first_time_process(
7388 p_xfr_action_id => p_xfr_action_id
7389 ,p_assignment_id => p_assignment_id
7390 ,p_curr_pymt_action_id => p_rqp_action_id
7391 ,p_curr_pymt_eff_date => p_curr_pymt_eff_date
7392 ,p_curr_eff_date => p_xfr_end_date
7393 ,p_tax_unit_id => p_tax_unit_id
7394 ,p_pymt_balcall_aaid => p_payment_action_id
7395 ,p_ytd_balcall_aaid => ln_ytd_balcall_aaid
7396 ,p_sepchk_run_type_id => p_sepcheck_run_type_id
7397 ,p_sepchk_flag => p_seperate_check_flag
7398 ,p_legislation_code => p_legislation_code
7399 );
7400
7401 else
7402 hr_utility.set_location(gv_package || lv_procedure_name, 110);
7403 pay_ac_action_arch.get_current_elements(
7404 p_xfr_action_id => p_xfr_action_id
7405 ,p_curr_pymt_action_id => p_rqp_action_id
7406 ,p_curr_pymt_eff_date => p_curr_pymt_eff_date
7407 ,p_assignment_id => p_assignment_id
7408 ,p_tax_unit_id => p_tax_unit_id
7409 ,p_pymt_balcall_aaid => p_payment_action_id
7410 ,p_ytd_balcall_aaid => ln_ytd_balcall_aaid
7411 ,p_sepchk_run_type_id => p_sepcheck_run_type_id
7412 ,p_sepchk_flag => p_seperate_check_flag
7413 ,p_legislation_code => p_legislation_code);
7414
7415 end if;
7416
7417 hr_utility.set_location(gv_package || lv_procedure_name, 120);
7418
7419 else
7420
7421 /*****************************************************************
7422 ** Get Employee Resident Jurisdiction seperately as we do not
7423 ** call populate_puv_tax_balances which returns
7424 ** lv_resident_jurisdiction. This value is used when archiving
7425 ** W4 Information.
7426 *****************************************************************/
7427 hr_utility.set_location(gv_package || lv_procedure_name, 130);
7428 get_emp_residence(p_assignment_id => p_assignment_id
7429 ,p_end_date => p_xfr_end_date
7430 ,p_run_effective_date => ld_run_effective_date
7431 ,p_resident_state_jd => lv_resident_state
7432 ,p_resident_county_jd => lv_resident_county
7433 ,p_resident_city_jd => lv_resident_city);
7434
7435 lv_resident_jurisdiction := lv_resident_state || '-' ||
7436 lv_resident_county || '-' ||
7437 lv_resident_city;
7438
7439 end if; /* p_archive_balance_info = 'Y' */
7440
7441 hr_utility.set_location(gv_package || lv_procedure_name, 135);
7442 pay_ac_action_arch.get_xfr_elements(
7443 p_xfr_action_id => p_xfr_action_id
7444 ,p_last_xfr_action_id => ln_last_xfr_action_id
7445 ,p_ytd_balcall_aaid => ln_ytd_balcall_aaid
7446 ,p_pymt_eff_date => p_curr_pymt_eff_date
7447 ,p_legislation_code => p_legislation_code
7448 ,p_sepchk_flag => p_seperate_check_flag
7449 ,p_assignment_id => p_assignment_id);
7450
7451 hr_utility.set_location(gv_package || lv_procedure_name, 140);
7452 pay_ac_action_arch.get_last_pymt_info(
7453 p_assignment_id => p_assignment_id
7454 ,p_curr_pymt_eff_date => p_curr_pymt_eff_date
7455 ,p_last_pymt_eff_date => ld_last_pymt_eff_date
7456 ,p_last_pymt_action_id => ln_last_pymt_action_id);
7457
7458 if ld_last_xfr_eff_date <> ld_last_pymt_eff_date then
7459 hr_utility.set_location(gv_package || lv_procedure_name, 145);
7460 pay_ac_action_arch.get_missing_xfr_info(
7461 p_xfr_action_id => p_xfr_action_id
7462 ,p_tax_unit_id => p_tax_unit_id
7463 ,p_assignment_id => p_assignment_id
7464 ,p_last_pymt_action_id => ln_last_pymt_action_id
7465 ,p_last_pymt_eff_date => ld_last_pymt_eff_date
7466 ,p_last_xfr_eff_date => ld_last_xfr_eff_date
7467 ,p_ytd_balcall_aaid => ln_ytd_balcall_aaid
7468 ,p_pymt_eff_date => p_curr_pymt_eff_date
7469 ,p_legislation_code => p_legislation_code);
7470 end if;
7471
7472
7473 hr_utility.set_location(gv_package || lv_procedure_name, 155);
7474 pay_emp_action_arch.get_personal_information(
7475 p_payroll_action_id => p_xfr_payroll_action_id
7476 ,p_assactid => p_xfr_action_id
7477 ,p_assignment_id => p_assignment_id
7478 ,p_curr_pymt_ass_act_id => p_pre_pay_action_id
7479 ,p_curr_eff_date => p_xfr_end_date
7480 ,p_date_earned => ld_run_date_earned
7481 ,p_curr_pymt_eff_date => p_curr_pymt_eff_date
7482 ,p_tax_unit_id => p_tax_unit_id
7483 ,p_time_period_id => ln_time_period_id
7484 ,p_ppp_source_action_id => p_ppp_source_action_id
7485 ,p_run_action_id => p_payment_action_id
7486 ,p_ytd_balcall_aaid => ln_ytd_balcall_aaid
7487 );
7488
7489 hr_utility.set_location(gv_package || lv_procedure_name, 160);
7490
7491 g_wage_exempt := 'N';
7492
7493 get_employee_withholding_info(
7494 p_assignment_id => p_assignment_id
7495 ,p_run_effective_date => ld_run_effective_date
7496 ,p_resident_jurisdiction => lv_resident_jurisdiction);
7497
7498 hr_utility.trace('Value of g_wage_exempt '||g_wage_exempt);
7499
7500 /*Added for Bug#9872952*/
7501
7502 if g_wage_exempt = 'Y' then
7503
7504 hr_utility.trace('Updating the Wage Exempt value');
7505
7506 for t in pay_ac_action_arch.lrr_act_tab.first..
7507 pay_ac_action_arch.lrr_act_tab.last LOOP
7508
7509 if pay_ac_action_arch.lrr_act_tab(t).action_info_category = 'US FEDERAL'
7510 then
7511 pay_ac_action_arch.lrr_act_tab(t).act_info27 := g_wage_exempt;
7512 exit;
7513 end if;
7514
7515 end loop;
7516
7517 end if;
7518
7519 /*End Bug#9872952*/
7520
7521 if p_seperate_check_flag = 'N' then
7522 hr_utility.set_location(gv_package || lv_procedure_name, 170);
7523 -- Archive element processed in balance adjustment. This only
7524 -- needs to be done for master action as once the element is
7525 -- in archive, it will be carried forward.
7526 pay_ac_action_arch.process_baladj_elements(
7527 p_assignment_id => p_assignment_id
7528 ,p_xfr_action_id => p_xfr_action_id
7529 ,p_last_xfr_action_id => ln_last_xfr_action_id
7530 ,p_curr_pymt_action_id => p_rqp_action_id
7531 ,p_curr_pymt_eff_date => p_curr_pymt_eff_date
7532 ,p_ytd_balcall_aaid => ln_ytd_balcall_aaid
7533 ,p_sepchk_flag => p_seperate_check_flag
7534 ,p_sepchk_run_type_id => p_sepcheck_run_type_id
7535 ,p_payroll_id => p_payroll_id
7536 ,p_consolidation_set_id => p_consolidation_set_id
7537 ,p_legislation_code => p_legislation_code
7538 ,p_tax_unit_id => p_tax_unit_id);
7539
7540 hr_utility.set_location(gv_package || lv_procedure_name, 175);
7541
7542 open c_ytd_aaid(p_rqp_action_id,
7543 p_assignment_id,
7544 p_sepcheck_run_type_id);
7545 loop
7546 fetch c_ytd_aaid into ln_run_action_id;
7547 if c_ytd_aaid%notfound then
7548 hr_utility.set_location(gv_package || lv_procedure_name, 180);
7549 exit;
7550 end if;
7551
7552 hr_utility.set_location(gv_package || lv_procedure_name, 190);
7553 populate_emp_hours_by_rate(
7554 p_action_context_id => p_xfr_action_id
7555 ,p_assignment_id => p_assignment_id
7556 ,p_run_action_id => ln_run_action_id);
7557
7558 end loop;
7559 close c_ytd_aaid;
7560 else
7561 hr_utility.set_location(gv_package || lv_procedure_name, 200);
7562 populate_emp_hours_by_rate(
7563 p_action_context_id => p_xfr_action_id
7564 ,p_assignment_id => p_assignment_id
7565 ,p_run_action_id => p_payment_action_id);
7566 end if;
7567
7568 hr_utility.set_location(gv_package || lv_procedure_name, 205);
7569 pay_ac_action_arch.populate_summary(
7570 p_xfr_action_id => p_xfr_action_id);
7571 change_processing_priority;
7572
7573 hr_utility.set_location(gv_package || lv_procedure_name, 210);
7574
7575 --13029995 Call to the procedure for Third Party Cheque Information.
7576
7577 open cur_busgrp;
7578 fetch cur_busgrp into ln_business_group_id;
7579 close cur_busgrp;
7580
7581 get_3rdparty_check( p_pre_pay_action_id => p_pre_pay_action_id
7582 ,p_assignment_id => p_assignment_id
7583 ,p_curr_pymt_eff_date => p_curr_pymt_eff_date
7584 ,p_ppp_source_action_id => p_ppp_source_action_id
7585 ,p_payroll_id => p_payroll_id
7586 ,p_xfr_action_id => p_xfr_action_id
7587 ,p_tax_unit_id => p_tax_unit_id
7588 ,p_business_group_id => ln_business_group_id
7589 );
7590
7591 hr_utility.set_location(gv_package || lv_procedure_name, 215);
7592
7593 pay_emp_action_arch.insert_rows_thro_api_process(
7594 p_action_context_id => p_xfr_action_id
7595 ,p_action_context_type=> 'AAP'
7596 ,p_assignment_id => p_assignment_id
7597 ,p_tax_unit_id => p_tax_unit_id
7598 ,p_curr_pymt_eff_date => p_curr_pymt_eff_date
7599 ,p_tab_rec_data => pay_ac_action_arch.lrr_act_tab
7600 );
7601
7602 hr_utility.set_location(gv_package || lv_procedure_name, 220);
7603
7604 update_employee_information(
7605 p_action_context_id => p_xfr_action_id
7606 ,p_assignment_id => p_assignment_id);
7607
7608 hr_utility.set_location(gv_package || lv_procedure_name, 250);
7609
7610 EXCEPTION
7611 when others then
7612 lv_error_message := 'Error in ' ||
7613 gv_package || lv_procedure_name;
7614
7615 hr_utility.trace(lv_error_message || '-' || sqlerrm);
7616
7617 lv_error_message :=
7618 pay_emp_action_arch.set_error_message(lv_error_message);
7619
7620 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
7621 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
7622 hr_utility.raise_error;
7623
7624 END process_actions;
7625
7626
7627 /************************************************************
7628 Name : action_archive_data
7629 Purpose : This procedure Archives data which are used in
7630 Tax Remittance Archiver, Payslip, Check Writer,
7631 Deposit Advice modules.
7632 Arguments :
7633 Notes :
7634 ************************************************************/
7635 PROCEDURE action_archive_data(p_xfr_action_id in number
7636 ,p_effective_date in date)
7637 IS
7638
7639 cursor c_xfr_info (cp_assignment_action in number) is
7640 select paa.payroll_action_id,
7641 paa.assignment_action_id,
7642 paa.assignment_id,
7643 paa.tax_unit_id,
7644 paa.serial_number,
7645 paa.chunk_number
7646 from pay_assignment_actions paa
7647 where paa.assignment_action_id = cp_assignment_action;
7648
7649 cursor c_legislation (cp_business_group in number) is
7650 select org_information9
7651 from hr_organization_information
7652 where org_information_context = 'Business Group Information'
7653 and organization_id = cp_business_group;
7654
7655 cursor c_sepchk_ryn_type is
7656 select prt.run_type_id
7657 from pay_run_types_f prt
7658 where prt.shortname = 'SEPCHECK'
7659 and prt.legislation_code = 'US';
7660
7661 cursor c_assignment_run (cp_prepayment_action_id in number) is
7662 select distinct paa.assignment_id
7663 from pay_action_interlocks pai,
7664 pay_assignment_actions paa,
7665 pay_payroll_actions ppa
7666 where pai.locking_action_id = cp_prepayment_action_id
7667 and paa.assignment_action_id = pai.locked_action_id
7668 and ppa.payroll_action_id = paa.payroll_action_id
7669 and ppa.action_type in ('R', 'Q', 'B')
7670 and ((ppa.run_type_id is null and paa.source_action_id is null) or
7671 (ppa.run_type_id is not null and paa.source_action_id is not null))
7672 and paa.action_status = 'C';
7673
7674 cursor c_master_run_action(
7675 cp_prepayment_action_id in number,
7676 cp_assignment_id in number) is
7677 select paa.assignment_action_id, paa.payroll_action_id,
7678 ppa.action_type
7679 from pay_payroll_actions ppa,
7680 pay_assignment_actions paa,
7681 pay_action_interlocks pai
7682 where pai.locking_action_id = cp_prepayment_action_id
7683 and pai.locked_action_id = paa.assignment_action_id
7684 and paa.assignment_id = cp_assignment_id
7685 and paa.source_action_id is null
7686 and ppa.payroll_action_id = paa.payroll_action_id
7687 order by paa.assignment_action_id desc;
7688
7689 cursor c_pymt_eff_date(cp_prepayment_action_id in number) is
7690 select ppa.effective_date
7691 from pay_payroll_actions ppa,
7692 pay_assignment_actions paa
7693 where ppa.payroll_action_id = paa.payroll_action_id
7694 and paa.assignment_action_id = cp_prepayment_action_id;
7695
7696 cursor c_check_pay_action( cp_payroll_action_id in number) is
7697 select count(*)
7698 from pay_action_information
7699 where action_context_id = cp_payroll_action_id
7700 and action_context_type = 'PA';
7701
7702 cursor c_payment_info(cp_prepay_action_id number) is
7703 select distinct
7704 assignment_id
7705 ,tax_unit_id
7706 ,nvl(source_action_id,-999)
7707 ,assignment_action_id
7708 from pay_payment_information_v
7709 where assignment_action_id = cp_prepay_action_id
7710 order by 3,1,2;
7711
7712 cursor c_run_aa_id(cp_pp_asg_act_id number
7713 ,cp_assignment_id number
7714 ,cp_tax_unit_id number) is
7715 select paa.assignment_action_id
7716 ,paa.source_action_id
7717 from pay_assignment_actions paa
7718 ,pay_action_interlocks pai
7719 where pai.locking_action_id = cp_pp_asg_act_id
7720 and paa.assignment_action_id = pai.locked_action_id
7721 and paa.assignment_id = cp_assignment_id
7722 and paa.tax_unit_id = cp_tax_unit_id
7723 and paa.source_action_id is not null
7724 and not exists ( select 1
7725 from pay_run_types_f prt
7726 where prt.legislation_code = 'US'
7727 and prt.run_type_id = paa.run_type_id
7728 and prt.run_method in ('C', 'S'))
7729 order by paa.action_sequence desc;
7730
7731 cursor c_get_prepay_aaid_for_sepchk( cp_asg_act_id number,
7732 cp_source_act_id number ) is
7733 select ppp.assignment_action_id
7734 from pay_assignment_actions paa
7735 ,pay_pre_payments ppp
7736 where ( paa.assignment_action_id = cp_asg_act_id OR
7737 paa.source_action_id = cp_asg_act_id )
7738 and ppp.assignment_action_id = paa.assignment_action_id
7739 and ppp.source_action_id = cp_source_act_id;
7740
7741
7742 /* Following cursor is changed for performance issue Bug# 7418142 */
7743
7744 cursor c_get_unproc_asg(cp_assignment_id in number,
7745 cp_effective_date in date,
7746 cp_payroll_id in number,
7747 cp_xfr_action_id in number,
7748 cp_prepay_action_id in number) is
7749 select /*+ ORDERED */
7750 paf1.assignment_id,
7751 paa.assignment_action_id
7752 from per_all_assignments_f paf1
7753 ,pay_assignment_actions paa
7754 ,pay_payroll_actions ppa
7755 where paf1.person_id = (select /*+ PUSH_SUBQ */ person_id
7756 from per_all_assignments_f START_ASS
7757 where START_ASS.assignment_id = cp_assignment_id
7758 and rownum = 1)
7759 and paf1.effective_end_date >= trunc(cp_effective_date,'Y')
7760 and paf1.effective_start_date <= cp_effective_date
7761 and paa.assignment_id = paf1.assignment_id
7762 and paa.payroll_action_id = ppa.payroll_action_id
7763 and ppa.payroll_id = cp_payroll_id
7764 and paf1.payroll_id = cp_payroll_id -- #9242223
7765 and ppa.action_type in ('Q', 'R', 'I','B')
7766 and not exists (select 'x'
7767 from pay_action_information pai
7768 where pai.action_context_id = cp_xfr_action_id
7769 and pai.assignment_id = paf1.assignment_id)
7770 and not exists (select 1
7771 from pay_payment_information_v ppi
7772 where ppi.assignment_action_id = cp_prepay_action_id
7773 and ppi.assignment_id = paf1.assignment_id
7774 and ppi.source_action_id is null)
7775 order by paf1.assignment_id,
7776 paa.action_sequence desc;
7777
7778
7779
7780 cursor c_prev_run_information(cp_assignment_id in number
7781 ,cp_xfr_action_id in number
7782 ,cp_effective_date in date) is
7783 select max(pai.effective_date)
7784 from pay_action_information pai
7785 where pai.action_context_type = 'AAP'
7786 and pai.assignment_id = cp_assignment_id
7787 and pai.action_information_category in ('AC EARNINGS', 'AC DEDUCTIONS')
7788 and pai.action_context_id <> cp_xfr_action_id
7789 and pai.effective_date <= cp_effective_date;
7790
7791 cursor c_run_aa_id_bal_adj(cp_pp_asg_act_id number
7792 ,cp_assignment_id number
7793 ,cp_tax_unit_id number) is
7794 select paa.assignment_action_id
7795 ,paa.source_action_id
7796 from pay_assignment_actions paa
7797 ,pay_action_interlocks pai
7798 where pai.locking_action_id = cp_pp_asg_act_id
7799 and paa.assignment_action_id = pai.locked_action_id
7800 and paa.assignment_id = cp_assignment_id
7801 and paa.tax_unit_id = cp_tax_unit_id
7802 order by paa.action_sequence desc;
7803
7804 cursor c_all_runs(cp_pp_asg_act_id in number
7805 ,cp_assignment_id in number
7806 ,cp_tax_unit_id in number
7807 ,cp_sepchk_run_type in number) is
7808 select paa.assignment_action_id
7809 from pay_assignment_actions paa,
7810 pay_action_interlocks pai
7811 where pai.locking_action_id = cp_pp_asg_act_id
7812 and paa.assignment_action_id = pai.locked_action_id
7813 and paa.assignment_id = cp_assignment_id
7814 and paa.tax_unit_id = cp_tax_unit_id
7815 and nvl(paa.run_type_id,0) <> cp_sepchk_run_type
7816 and not exists ( select 1
7817 from pay_run_types_f prt
7818 where prt.legislation_code = 'US'
7819 and prt.run_type_id = nvl(paa.run_type_id,0)
7820 and prt.run_method = 'C' );
7821
7822 ld_curr_pymt_eff_date DATE;
7823 ln_sepchk_run_type_id NUMBER;
7824 lv_legislation_code VARCHAR2(2);
7825
7826 ln_xfr_master_action_id NUMBER;
7827
7828 ln_tax_unit_id NUMBER;
7829 ln_xfr_payroll_action_id NUMBER; /* of current xfr */
7830 ln_xfr_assignment_id NUMBER; -- Bug 3452149
7831 ln_assignment_id NUMBER;
7832 ln_chunk_number NUMBER;
7833
7834 lv_xfr_master_serial_number VARCHAR2(30);
7835 lv_master_action_type VARCHAR2(1);
7836 lv_master_sepcheck_flag VARCHAR2(1);
7837 ln_asg_action_id NUMBER;
7838
7839 ln_master_run_action_id NUMBER;
7840 ln_master_run_pact_id NUMBER;
7841 lv_master_run_action_type VARCHAR2(1);
7842
7843 ln_pymt_balcall_aaid NUMBER;
7844 ln_pay_action_count NUMBER;
7845
7846 ld_start_date DATE;
7847 ld_end_date DATE;
7848 ln_business_group_id NUMBER;
7849 ln_cons_set_id NUMBER;
7850 ln_payroll_id NUMBER;
7851
7852 lv_resident_jurisdiction VARCHAR2(30);
7853
7854 lv_procedure_name VARCHAR2(100) := '.action_archive_data';
7855 lv_error_message VARCHAR2(200);
7856 ln_step NUMBER;
7857
7858 ln_np_asg_id NUMBER;
7859 ln_np_asg_action_id NUMBER;
7860 ln_np_prev_asg_id NUMBER := '-1';
7861 ld_np_last_xfr_eff_date DATE;
7862
7863 ln_source_action_id NUMBER;
7864 ln_child_xfr_action_id NUMBER;
7865 ln_run_aa_id NUMBER;
7866 ln_run_source_action_id NUMBER;
7867 ln_rqp_action_id NUMBER;
7868 ln_ppp_source_action_id NUMBER;
7869 ln_master_run_aa_id NUMBER;
7870 ln_earnings NUMBER;
7871 lv_serial_number VARCHAR2(30);
7872
7873 ln_run_qp_found NUMBER;
7874 ln_all_run_asg_act_id NUMBER;
7875
7876 lv_archive_balance_info VARCHAR2(1) := 'Y'; -- Bug 3452149
7877 ld_last_xfr_eff_date DATE;
7878 ln_last_xfr_action_id NUMBER;
7879
7880 BEGIN
7881 pay_emp_action_arch.gv_error_message := NULL;
7882 hr_utility.set_location(gv_package || lv_procedure_name, 10);
7883 ln_step := 1;
7884 open c_xfr_info (p_xfr_action_id);
7885 fetch c_xfr_info into ln_xfr_payroll_action_id,
7886 ln_xfr_master_action_id,
7887 ln_xfr_assignment_id,
7888 ln_tax_unit_id,
7889 lv_xfr_master_serial_number,
7890 ln_chunk_number;
7891 close c_xfr_info;
7892
7893 ln_step := 2;
7894 get_payroll_action_info(p_payroll_action_id => ln_xfr_payroll_action_id
7895 ,p_start_date => ld_start_date
7896 ,p_end_date => ld_end_date
7897 ,p_business_group_id => ln_business_group_id
7898 ,p_cons_set_id => ln_cons_set_id
7899 ,p_payroll_id => ln_payroll_id);
7900
7901 hr_utility.set_location(gv_package || lv_procedure_name, 15);
7902
7903 ln_step := 205;
7904 pay_emp_action_arch.gv_multi_payroll_pymt
7905 := pay_emp_action_arch.get_multi_assignment_flag(
7906 p_payroll_id => ln_payroll_id
7907 ,p_effective_date => ld_end_date);
7908
7909 hr_utility.trace('pay_emp_action_arch.gv_multi_payroll_pymt = ' ||
7910 pay_emp_action_arch.gv_multi_payroll_pymt);
7911
7912 ln_step := 3;
7913 open c_legislation (ln_business_group_id);
7914 fetch c_legislation into lv_legislation_code ;
7915 if c_legislation%notfound then
7916 hr_utility.trace('Business Group for Interface Process Not Found');
7917 hr_utility.raise_error;
7918 end if;
7919 close c_legislation;
7920 hr_utility.trace('lv_legislation_code '||lv_legislation_code);
7921
7922 ln_step := 4;
7923 open c_sepchk_ryn_type;
7924 fetch c_sepchk_ryn_type into ln_sepchk_run_type_id;
7925 if c_sepchk_ryn_type%notfound then
7926 hr_utility.set_location(gv_package || lv_procedure_name, 20);
7927 hr_utility.raise_error;
7928 end if;
7929 close c_sepchk_ryn_type;
7930
7931 -- process the master_action
7932 lv_master_action_type := substr(lv_xfr_master_serial_number,1,1);
7933 -- Always N for Master Assignment Action
7934 lv_master_sepcheck_flag := substr(lv_xfr_master_serial_number,2,1);
7935 -- Assignment Action of Quick Pay Pre Payment, Pre Payment, Reversal
7936 ln_asg_action_id := substr(lv_xfr_master_serial_number,3);
7937
7938 ln_step := 5;
7939 open c_pymt_eff_date(ln_asg_action_id);
7940 fetch c_pymt_eff_date into ld_curr_pymt_eff_date;
7941 if c_pymt_eff_date%notfound then
7942 hr_utility.trace('PayrollAction for InterfaceProcess NotFound');
7943 hr_utility.raise_error;
7944 end if;
7945 close c_pymt_eff_date;
7946
7947 hr_utility.trace('End Date=' || to_char(ld_end_date, 'dd-mon-yyyy'));
7948 hr_utility.trace('Start Date='||to_char(ld_start_date, 'dd-mon-yyyy'));
7949 hr_utility.trace('Business Group Id='||to_char(ln_business_group_id));
7950 hr_utility.trace('Serial Number='||lv_xfr_master_serial_number);
7951 hr_utility.trace('ln_xfr_payroll_action_id ='||to_char(ln_xfr_payroll_action_id));
7952
7953 ln_step := 6;
7954 if lv_master_action_type in ( 'P','U') then
7955 /************************************************************
7956 ** For Master Pre Payment Action get the distinct
7957 ** Assignment_ID's and archive the data seperately for
7958 ** all the assigments.
7959 *************************************************************/
7960 ln_step := 7;
7961 open c_payment_info(ln_asg_action_id);
7962 loop
7963
7964 fetch c_payment_info into ln_assignment_id
7965 ,ln_tax_unit_id
7966 ,ln_source_action_id
7967 ,ln_asg_action_id;
7968 exit when c_payment_info%notfound;
7969
7970 hr_utility.trace('archive_data:payment_info:ln_asg_action_id = ' ||
7971 ln_asg_action_id );
7972 hr_utility.trace('archive_data:payment_info:ln_assignment_id = ' ||
7973 ln_assignment_id );
7974 hr_utility.trace('archive_data:payment_info:ln_tax_unit_id = ' ||
7975 ln_tax_unit_id );
7976 hr_utility.trace('archive_data:payment_info:ln_source_action_id = ' ||
7977 ln_source_action_id );
7978
7979 ln_step := 8;
7980
7981 if ln_source_action_id = -999 then
7982 ln_step := 9;
7983 lv_master_sepcheck_flag := 'N';
7984 ln_master_run_aa_id := NULL;
7985 ln_master_run_aa_id := NULL;
7986 ln_run_qp_found := 0;
7987
7988
7989 /********************************************************
7990 ** Getting Run Assignment Action Id for normal cheque.
7991 ********************************************************/
7992 open c_run_aa_id(ln_asg_action_id
7993 ,ln_assignment_id
7994 ,ln_tax_unit_id);
7995 fetch c_run_aa_id into ln_run_aa_id, ln_run_source_action_id;
7996 if c_run_aa_id%found then
7997 ln_run_qp_found := 1;
7998 end if;
7999 close c_run_aa_id;
8000
8001 ln_step := 10;
8002 hr_utility.trace('GRE ln_run_aa_id = ' || ln_run_aa_id);
8003
8004 if ln_run_source_action_id is not null then
8005 ln_master_run_aa_id := ln_run_source_action_id; -- Normal Chk
8006 else
8007 if ln_run_qp_found = 0 then
8008 /* Balance Adjustment or Reversal */
8009 open c_run_aa_id_bal_adj(ln_asg_action_id
8010 ,ln_assignment_id
8011 ,ln_tax_unit_id);
8012 fetch c_run_aa_id_bal_adj into ln_run_aa_id,
8013 ln_run_source_action_id;
8014 close c_run_aa_id_bal_adj;
8015 ln_master_run_aa_id := ln_asg_action_id;
8016 else
8017 ln_master_run_aa_id := ln_run_aa_id; -- Normal Chk
8018 end if;
8019 end if;
8020
8021 ln_rqp_action_id := ln_asg_action_id;
8022 ln_ppp_source_action_id := NULL;
8023
8024 else
8025
8026 ln_step := 11;
8027 lv_master_sepcheck_flag := 'Y';
8028 ln_master_run_aa_id := ln_source_action_id; -- Sep Chk
8029 ln_rqp_action_id := ln_source_action_id; -- Sep Chk
8030 ln_ppp_source_action_id := ln_source_action_id; -- Sep Chk
8031 ln_run_aa_id := ln_source_action_id; -- Sep Chk
8032
8033 end if;
8034
8035 if ln_source_action_id <> -999 then
8036
8037 open c_get_prepay_aaid_for_sepchk(ln_asg_action_id
8038 ,ln_source_action_id);
8039 fetch c_get_prepay_aaid_for_sepchk into ln_asg_action_id;
8040 close c_get_prepay_aaid_for_sepchk;
8041
8042 ln_step := 12;
8043 select pay_assignment_actions_s.nextval
8044 into ln_child_xfr_action_id
8045 from dual;
8046
8047 hr_utility.set_location(gv_package || lv_procedure_name, 30);
8048
8049 -- insert into pay_assignment_actions.
8050 ln_step := 13;
8051 hr_nonrun_asact.insact(ln_child_xfr_action_id,
8052 ln_assignment_id,
8053 ln_xfr_payroll_action_id,
8054 ln_chunk_number,
8055 ln_tax_unit_id,
8056 null,
8057 'C',
8058 p_xfr_action_id);
8059
8060 hr_utility.set_location(gv_package || lv_procedure_name, 40);
8061
8062 hr_utility.trace('GRE Locking Action = ' ||ln_child_xfr_action_id);
8063 hr_utility.trace('GRE Locked Action = ' ||ln_asg_action_id);
8064
8065 -- insert an interlock to this action
8066 ln_step := 14;
8067 hr_nonrun_asact.insint(ln_child_xfr_action_id,
8068 ln_asg_action_id);
8069
8070 ln_step := 15;
8071
8072 lv_serial_number := lv_master_action_type ||
8073 lv_master_sepcheck_flag || ln_source_action_id;
8074
8075 ln_step := 16;
8076
8077 update pay_assignment_actions
8078 set serial_number = lv_serial_number
8079 where assignment_action_id = ln_child_xfr_action_id;
8080
8081 hr_utility.trace('Processing Child action ' ||
8082 p_xfr_action_id);
8083
8084 else
8085 ln_step := 17;
8086 ln_child_xfr_action_id := p_xfr_action_id;
8087 end if;
8088
8089 ln_earnings := 0;
8090 ln_step := 18;
8091
8092 if gn_gross_earn_def_bal_id + gn_payments_def_bal_id <> 0 then
8093
8094 if ln_source_action_id = -999 then
8095
8096 ln_step := 19;
8097
8098 open c_all_runs(ln_asg_action_id,
8099 ln_assignment_id,
8100 ln_tax_unit_id,
8101 ln_sepchk_run_type_id);
8102 loop
8103 fetch c_all_runs into ln_all_run_asg_act_id;
8104 if c_all_runs%notfound then
8105 exit;
8106 end if;
8107
8108 ln_earnings := nvl(pay_balance_pkg.get_value(
8109 gn_gross_earn_def_bal_id,
8110 ln_all_run_asg_act_id),0);
8111
8112 /**************************************************
8113 ** For Non-payroll Payments element is processed
8114 ** alone, the gross earning balance returns zero.
8115 ** In this case check payment.
8116 **************************************************/
8117
8118 if ln_earnings = 0 then
8119
8120 ln_step := 20;
8121 ln_earnings := nvl(pay_balance_pkg.get_value(
8122 gn_payments_def_bal_id,
8123 ln_all_run_asg_act_id),0);
8124
8125 end if;
8126
8127 if ln_earnings <> 0 then
8128 exit;
8129 end if;
8130
8131 end loop;
8132 close c_all_runs;
8133 else
8134 ln_earnings := 1; -- For Separate Check
8135 end if;
8136
8137 end if;
8138
8139
8140 ln_step := 21;
8141 /* Bug 3452149 */
8142 if ln_earnings = 0 and
8143 pay_emp_action_arch.gv_multi_payroll_pymt = 'Y' then
8144 ln_earnings := 1;
8145 lv_archive_balance_info := 'N';
8146 else
8147 lv_archive_balance_info := 'Y';
8148 end if;
8149
8150 /* Bug 3452149 */
8151 hr_utility.trace('archive_data:payment_info: ln_earnings = ' ||
8152 ln_earnings);
8153 hr_utility.trace('archive_data:payment_info: lv_archive_balance_info = ' ||
8154 lv_archive_balance_info);
8155 if ln_earnings <> 0 then
8156 process_actions(p_xfr_payroll_action_id => ln_xfr_payroll_action_id
8157 ,p_xfr_action_id => ln_child_xfr_action_id
8158 ,p_pre_pay_action_id => ln_asg_action_id
8159 ,p_payment_action_id => ln_master_run_aa_id
8160 ,p_rqp_action_id => ln_rqp_action_id
8161 ,p_seperate_check_flag => lv_master_sepcheck_flag
8162 ,p_sepcheck_run_type_id => ln_sepchk_run_type_id
8163 ,p_action_type => lv_master_action_type
8164 ,p_legislation_code => lv_legislation_code
8165 ,p_assignment_id => ln_assignment_id
8166 ,p_payroll_id => ln_payroll_id
8167 ,p_consolidation_set_id => ln_cons_set_id
8168 ,p_tax_unit_id => ln_tax_unit_id
8169 ,p_curr_pymt_eff_date => ld_curr_pymt_eff_date
8170 ,p_xfr_start_date => ld_start_date
8171 ,p_xfr_end_date => ld_end_date
8172 ,p_ppp_source_action_id => ln_ppp_source_action_id
8173 ,p_archive_balance_info => lv_archive_balance_info
8174 ,p_last_xfr_eff_date => ld_last_xfr_eff_date
8175 ,p_last_xfr_action_id => ln_last_xfr_action_id
8176 );
8177
8178 if pay_emp_action_arch.gv_multi_payroll_pymt = 'Y' and
8179 nvl(lv_master_sepcheck_flag, 'N') = 'N' and
8180 ld_last_xfr_eff_date is not null then
8181 hr_utility.trace('---------Check for un-processed asignments --------');
8182 hr_utility.trace('ln_assignment_id = '||ln_assignment_id);
8183 hr_utility.trace('ld_curr_pymt_eff_date = '||ld_curr_pymt_eff_date);
8184 hr_utility.trace('ln_payroll_id = '||ln_payroll_id);
8185 hr_utility.trace('p_xfr_action_id = '||p_xfr_action_id);
8186
8187 /***************************************************************
8188 Find out if any assignments have been un-processed. If so,
8189 archive elements processed in the un-processed assignment
8190 ***************************************************************/
8191 open c_get_unproc_asg(ln_assignment_id,
8192 ld_curr_pymt_eff_date,
8193 ln_payroll_id,
8194 p_xfr_action_id,
8195 ln_asg_action_id);
8196 loop
8197 fetch c_get_unproc_asg into ln_np_asg_id, ln_np_asg_action_id;
8198 hr_utility.trace('ln_np_asg_id ='||ln_np_asg_id);
8199 hr_utility.trace('ln_np_asg_action_id ='||ln_np_asg_action_id);
8200
8201 exit when c_get_unproc_asg%NOTFOUND;
8202
8203 -- An assignment only needs to be processed once as that will
8204 -- move all elements.
8205 if ln_np_asg_id <> ln_np_prev_asg_id then
8206 pay_ac_action_arch.emp_elements_tab.delete;
8207 pay_ac_action_arch.lrr_act_tab.delete;
8208
8209 -- Check if the date of assignment process is the same as
8210 -- last archive date. If they are the same, the element just
8211 -- needs to be moved forward otherwise we need to get the
8212 -- data from run results
8213
8214 hr_utility.trace('PrevRun ln_np_asg_id := ' || ln_np_asg_id);
8215 hr_utility.trace('PrevRun ln_child_xfr_action_id := ' || ln_child_xfr_action_id);
8216 hr_utility.trace('PrevRun ld_curr_pymt_eff_date := ' || ld_curr_pymt_eff_date);
8217
8218 open c_prev_run_information(ln_np_asg_id
8219 ,ln_child_xfr_action_id
8220 ,ld_curr_pymt_eff_date);
8221 fetch c_prev_run_information into ld_np_last_xfr_eff_date;
8222 close c_prev_run_information;
8223
8224 hr_utility.trace('ld_np_last_xfr_eff_date='||ld_np_last_xfr_eff_date);
8225 hr_utility.trace('ld_last_xfr_eff_date ='||ld_last_xfr_eff_date);
8226
8227 if ld_np_last_xfr_eff_date >= ld_last_xfr_eff_date then
8228 -- To be Changed
8229 pay_ac_action_arch.get_xfr_elements(
8230 p_xfr_action_id => ln_child_xfr_action_id
8231 ,p_last_xfr_action_id => ln_last_xfr_action_id
8232 ,p_ytd_balcall_aaid => ln_np_asg_action_id
8233 ,p_pymt_eff_date => ld_curr_pymt_eff_date
8234 ,p_legislation_code => lv_legislation_code
8235 ,p_sepchk_flag => lv_master_sepcheck_flag
8236 ,p_assignment_id => ln_np_asg_id);
8237 else
8238 pay_ac_action_arch.process_additional_elements
8239 (p_assignment_id => ln_np_asg_id,
8240 p_assignment_action_id => ln_np_asg_action_id,
8241 p_curr_eff_date => ld_curr_pymt_eff_date,
8242 p_xfr_action_id => ln_child_xfr_action_id,
8243 p_legislation_code => lv_legislation_code,
8244 p_tax_unit_id => ln_tax_unit_id);
8245
8246 change_processing_priority;
8247 end if;
8248
8249 pay_ac_action_arch.populate_summary(
8250 p_xfr_action_id => p_xfr_action_id);
8251
8252 pay_emp_action_arch.insert_rows_thro_api_process(
8253 p_action_context_id => ln_child_xfr_action_id
8254 ,p_action_context_type=> 'AAP'
8255 ,p_assignment_id => ln_np_asg_id
8256 ,p_tax_unit_id => ln_tax_unit_id
8257 ,p_curr_pymt_eff_date => ld_curr_pymt_eff_date
8258 ,p_tab_rec_data => pay_ac_action_arch.lrr_act_tab
8259 );
8260
8261 end if;
8262 ln_np_prev_asg_id := ln_np_asg_id;
8263
8264 end loop;
8265 close c_get_unproc_asg;
8266 end if;
8267
8268 end if; -- ln_earnings
8269
8270 end loop; -- c_payment_info
8271 close c_payment_info;
8272 hr_utility.trace('archive_data:payment_info:DONE');
8273
8274 end if; /* P,U */
8275
8276
8277 ln_step := 11;
8278 if lv_master_action_type = 'V' then
8279 ln_pymt_balcall_aaid := ln_asg_action_id ;
8280 hr_utility.trace('Reversal ln_pymt_balcall_aaid'
8281 ||to_char(ln_pymt_balcall_aaid));
8282 ln_step := 12;
8283 pay_ac_action_arch.initialization_process;
8284 ln_step := 13;
8285 populate_puv_tax_balances(
8286 p_xfr_action_id => p_xfr_action_id
8287 ,p_assignment_id => ln_xfr_assignment_id
8288 ,p_pymt_balcall_aaid => ln_pymt_balcall_aaid
8289 ,p_ytd_balcall_aaid => null
8290 ,p_tax_unit_id => ln_tax_unit_id
8291 ,p_action_type => lv_master_action_type
8292 ,p_rqp_action_id => ln_asg_action_id
8293 ,p_start_date => ld_start_date
8294 ,p_end_date => ld_end_date
8295 ,p_run_effective_date => ld_curr_pymt_eff_date
8296 ,p_resident_jurisdiction => lv_resident_jurisdiction
8297 );
8298
8299 ln_step := 14;
8300 change_processing_priority;
8301 pay_emp_action_arch.insert_rows_thro_api_process(
8302 p_action_context_id => p_xfr_action_id
8303 ,p_action_context_type=> 'AAP'
8304 ,p_assignment_id => ln_xfr_assignment_id
8305 ,p_tax_unit_id => ln_tax_unit_id
8306 ,p_curr_pymt_eff_date => ld_curr_pymt_eff_date
8307 ,p_tab_rec_data => pay_ac_action_arch.lrr_act_tab
8308 );
8309
8310 end if;
8311
8312 ln_step := 15;
8313 if lv_master_action_type = 'B' then
8314 hr_utility.trace('Reversal ln_pymt_balcall_aaid'
8315 ||to_char(ln_pymt_balcall_aaid));
8316 pay_ac_action_arch.initialization_process;
8317 ln_step := 16;
8318 populate_adj_tax_balances(
8319 p_xfr_action_id => p_xfr_action_id
8320 ,p_assignment_id => ln_xfr_assignment_id
8321 ,p_tax_unit_id => ln_tax_unit_id
8322 ,p_action_type => lv_master_action_type
8323 ,p_start_date => ld_start_date
8324 ,p_end_date => ld_end_date
8325 ,p_run_effective_date => ld_curr_pymt_eff_date
8326 );
8327
8328 ln_step := 17;
8329 change_processing_priority;
8330 pay_emp_action_arch.insert_rows_thro_api_process(
8331 p_action_context_id => p_xfr_action_id
8332 ,p_action_context_type=> 'AAP'
8333 ,p_assignment_id => ln_xfr_assignment_id
8334 ,p_tax_unit_id => ln_tax_unit_id
8335 ,p_curr_pymt_eff_date => ld_curr_pymt_eff_date
8336 ,p_tab_rec_data => pay_ac_action_arch.lrr_act_tab
8337 );
8338
8339 end if;
8340
8341 /****************************************************************
8342 ** Archive all the payroll action level data once only when
8343 ** chunk number is 1. Also check if this has not been archived
8344 ** earlier
8345 *****************************************************************/
8346 hr_utility.set_location(gv_package || lv_procedure_name,210);
8347 ln_step := 20;
8348 open c_check_pay_action(ln_xfr_payroll_action_id);
8349 fetch c_check_pay_action into ln_pay_action_count;
8350 close c_check_pay_action;
8351 if ln_pay_action_count = 0 then
8352 hr_utility.set_location(gv_package || lv_procedure_name,210);
8353 if ln_chunk_number = 1 then
8354 ln_step := 25;
8355 pay_emp_action_arch.arch_pay_action_level_data(
8356 p_payroll_action_id => ln_xfr_payroll_action_id
8357 ,p_payroll_id => ln_payroll_id
8358 ,p_effective_Date => ld_end_date
8359 );
8360 end if;
8361
8362 end if;
8363
8364 EXCEPTION
8365 when others then
8366 lv_error_message := 'Error at step ' || ln_step || ' in ' ||
8367 gv_package || lv_procedure_name;
8368
8369 hr_utility.trace(lv_error_message || '-' || sqlerrm);
8370
8371 lv_error_message :=
8372 pay_emp_action_arch.set_error_message(lv_error_message);
8373
8374 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
8375 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
8376 hr_utility.raise_error;
8377
8378 end action_archive_data;
8379
8380
8381 /*********************************************************************
8382 Name : check_alien
8383 Purpose : This function checks if the given assignemnt is ALIEN
8384 it returns a 'TRUE' or 'FALSE'.
8385 Arguments : IN
8386 p_assignment_action_id number;
8387 Notes :
8388 *********************************************************************/
8389 FUNCTION check_alien(
8390 p_assignment_action_id in number)
8391 RETURN VARCHAR2
8392 IS
8393
8394 ln_assignment_id number;
8395 lv_error_message VARCHAR2(200);
8396 lv_procedure_name VARCHAR2(100) := '.check_alien';
8397
8398 cursor c_get_assignment_id (cp_assignment_action_id in number) is
8399 select assignment_id
8400 from pay_assignment_actions
8401 where assignment_action_id = cp_assignment_action_id;
8402
8403 BEGIN
8404 hr_utility.trace('opened c_get_assignment_id');
8405
8406 open c_get_assignment_id(p_assignment_action_id);
8407 fetch c_get_assignment_id into ln_assignment_id;
8408 close c_get_assignment_id;
8409
8410 hr_utility.trace('ln_assignment_id = ' ||
8411 to_char(ln_assignment_id));
8412
8413 return pqp_us_ff_functions.is_windstar(p_assignment_id => ln_assignment_id);
8414
8415 EXCEPTION
8416 when others then
8417 lv_error_message := 'Error in ' ||
8418 gv_package || lv_procedure_name;
8419
8420 hr_utility.trace(lv_error_message || '-' || sqlerrm);
8421
8422 lv_error_message :=
8423 pay_emp_action_arch.set_error_message(lv_error_message);
8424
8425 hr_utility.set_message(801,'HR_ELE_ENTRY_FORMULA_HINT');
8426 hr_utility.set_message_token('FORMULA_TEXT', lv_error_message);
8427 hr_utility.raise_error;
8428 END check_alien;
8429
8430 --begin
8431 --hr_utility.trace_on (null, 'XFR');
8432
8433 end pay_us_action_arch;