DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_AU_TAX_API

Source


1 PACKAGE BODY hr_au_tax_api AS
2 /* $Header: hrauwrtx.pkb 120.10.12020000.3 2012/12/06 12:17:17 dduvvuri ship $ */
3 /*
4  +===========================================================================
5  |              Copyright (c) 1999 Oracle Corporation Ltd
6  |                           All rights reserved.
7  +===========================================================================
8  |SQL Script File Name : HR AU WR TX . PKB
9  |                Name : hr_au_person_tax_api
10  |         Description : Person Tax API Wrapper for AU
11  |
12  |   Name           Date         Version Bug     Text
13  |   -------------- ----------   ------- -----   ----
14  |   sgoggin        11-JUN-1999  110.0           Created for AU
15  |   sclarke        28-APR-2000  115.1   1262179
16  |   sparker        30-JUN-2000  115.2   StatUpd Changed "PAYE INFORMATION"->"TAX INFORMATION"
17  |   abajpai        30-SEP-2000  115.6   Added SFSS
18  |   abajpai        11-OCT-2000  115.7   SFSS Changes Rolledback
19  |   rayyadev       30-OCT-2000  115.9   considered the case of SFSS before  31-JUL-2000
20  |   rsinghal       27-FEB-2001  115.10  changes for Medicare levy surcharge
21      apunekar       30-APR-2001  115.11  Removed the DEFAULT null criteria for
22                                          p_rebate_amount,p_dependent_children,
23                                          p_tax_variation_amount in
24                                          maintain_PAYE_tax_info.
25      apunekar       24-APR-2001  115.12  Reintroduced the Default null criteria.
26      srussell       28-FEB-2002  115.17  2240759 Add new parameter
27                                          p_override_user_ent_chk in calls to
28                                          py_element_entry_api.
29      shoskatt       30-MAY-2002  115.18  Bug 2145933 - Changed the package to handle
30                                          Senior Australian.
31      kaverma        26-NOV-2002  115.19  Bug 2601218 - Changed maintain_paye_tax_info and
32                                          maintain_super_info procedures.
33      kaverma        04-DEC-2002  115.20  Added nocopy for parameters
34      vgsriniv       17-DEC-2003  115.21  Bug:3318756. Modified cursor get_passed_tax_field_values
35                                          to use fnd_date.chardate_to_date instead of to_date
36      srrajago       07-JUN-2004  115.22  Bug: 3648796 - Performance Fix to remove FTS.Assigned the correct element name to the variable
37                                          g_paye_element(as in seed).In the cursors csr_paye_element,csr_paye_tax_element(in the procedures
38                                          maintain_paye_tax_info and maintain_SUPER_info),removed UPPER function on element_name.Value
39                                          assigned to the element_name is also corrected (as in seed).Removed GSCC warnings(File.Sql.35).
40      avenkatk       16-SEP-2004  115.23  Bug 3875404 -Procedure - maintain_SUPER_info - Added a new local variable for binding IN parameter.Done to avoid errors
41                                          while using NOCOPY params in the Core element entry API.
42      sclarke        20-NOV-2004  115.24  4035174 Added input for SFSS in procedure get_paye_input_ids
43      JLin           12-JAN-2005  115.25  4108099 Changed the mode to 'CORRECTION' when it calls update_element_entry
44                                          if effective_start_date is same as the session date in maintain_PAYE_tax_info
45      abhkumar       30-MAR-2005  115.26  4244787 Changed the mode from UPDATE_CHANGE_INSERT to UPDATE if there dosen't exists any future rows
46                                          for Tax Information
47      abhkumar       08-SEP-2005  115.27  4598178 Changed related to tax variation on bonus enhancement.
48      sclarke        25-FEB-2006  115.28  4704141 Added new procedure to create workbench tax info.
49      sclarke        10-MAR-2006  115.30  element link for CRP tax information
50      abhargav       14-Mar-2007  115.31  Renamed parameter p_hecs_sfss_flag to p_help_sfss_flag in procedure maintain_PAYE_tax_info().
51      vaisriva       26-May-2008  115.32  7042960 2008 Statutory Updates - FTA Claim Changes
52      keyazawa       11-SEP-2008  115.33  6310002 added set_eev_upd_mode
53      keyazawa       29-SEP-2008  115.34          reverted to 115.32 ver
54                                                  (removed set_eev_upd_mode, moved to pay_au_tax_info_pkg because of non public)
55      dduvvuri       05-JAN-2009  115.35  7664100 'Tax Free Threshold' field in Tax Information element is not getting
56                                                   updated when it is null for the first time for an assignment. It
57 						  should be updated with default of 'No' if it is not checked at all,
58 						  otherwise the payroll completes with invalid field error.
59      dduvvuri       07-JUN-1985  115.36  12570937 Added flood_levy_changes wef 01-jul-2011. Modified maintain_PAYE_tax_info,create_paye_tax_info,update_adi_tax_crp procedures
60      dduvvuri       14-may-2012  115.37  13906256 Cursor get_prev_database_tax_fields, get_passed_tax_field_values are modified to fetch appropriate spouse input values
61                                                   new parameter p_mls_rate added for procedure update_adi_tax_crp
62      dduvvuri       06-dec-2012  115.38  14729338 modified logic in update_adi_tax_crp to upload elements even if hire date of employee is below 01-07-1997
63 
64  |NOTES
65  +==========================================================================================
66 */
67 type paye_number_table   is table of number not null index by binary_integer;
68 g_package                           constant varchar2(33)   := 'hr_au_tax_api.';
69 g_paye_element                      constant varchar2(60)   := 'Tax Information'; -- Bug: 3648796
70 g_paye_input1                       constant varchar2(60)   := 'AUSTRALIAN RESIDENT';
71 g_paye_input2                       constant varchar2(60)   := 'TAX FREE THRESHOLD';
72 g_paye_input3                       constant varchar2(60)   := 'REBATE AMOUNT';
73 g_paye_input4                       constant varchar2(60)   := 'FTA CLAIM';
74 g_paye_input5                       constant varchar2(60)   := 'SAVINGS REBATE';
75 g_paye_input6                       constant varchar2(60)   := 'HECS';
76 g_paye_input7                       constant varchar2(60)   := 'DATE DECLARATION SIGNED';
77 g_paye_input8                       constant varchar2(60)   := 'MEDICARE LEVY VARIATION';
78 g_paye_input9                       constant varchar2(60)   := 'SPOUSE';
79 g_paye_input10                      constant varchar2(60)   := 'DEPENDENT CHILDREN';
80 g_paye_input11                      constant varchar2(60)   := 'TAX VARIATION TYPE';
81 g_paye_input12                      constant varchar2(60)   := 'TAX VARIATION AMOUNT';
82 g_paye_input13                      constant varchar2(60)   := 'TAX SCALE';
83 g_paye_input14                      constant varchar2(60)   := 'TAX FILE NUMBER';
84 g_paye_input15                      constant varchar2(60)   := 'SFSS';
85 g_paye_input16                      constant varchar2(60)   := 'EXEMPT FLOOD LEVY';
86 g_legislation_code                  constant varchar2(2)    := 'AU';
87 
88 g_debug   boolean := hr_utility.debug_enabled;
89 
90 
91 PROCEDURE maintain_PAYE_tax_info
92 (p_validate                         IN      BOOLEAN   DEFAULT FALSE
93 ,p_assignment_id                    IN      NUMBER
94 ,p_effective_start_date             IN OUT nocopy DATE
95 ,p_effective_end_date               IN OUT nocopy DATE
96 ,p_session_date                     IN      DATE
97 ,p_mode                             IN      VARCHAR2
98 ,p_business_group_id                IN      NUMBER
99 ,p_attribute_category               IN      VARCHAR2  DEFAULT NULL
100 ,p_attribute1                       IN      VARCHAR2  DEFAULT NULL
101 ,p_attribute2                       IN      VARCHAR2  DEFAULT NULL
102 ,p_attribute3                       IN      VARCHAR2  DEFAULT NULL
103 ,p_attribute4                       IN      VARCHAR2  DEFAULT NULL
104 ,p_attribute5                       IN      VARCHAR2  DEFAULT NULL
105 ,p_attribute6                       IN      VARCHAR2  DEFAULT NULL
106 ,p_attribute7                       IN      VARCHAR2  DEFAULT NULL
107 ,p_attribute8                       IN      VARCHAR2  DEFAULT NULL
108 ,p_attribute9                       IN      VARCHAR2  DEFAULT NULL
109 ,p_attribute10                      IN      VARCHAR2  DEFAULT NULL
110 ,p_attribute11                      IN      VARCHAR2  DEFAULT NULL
111 ,p_attribute12                      IN      VARCHAR2  DEFAULT NULL
112 ,p_attribute13                      IN      VARCHAR2  DEFAULT NULL
113 ,p_attribute14                      IN      VARCHAR2  DEFAULT NULL
114 ,p_attribute15                      IN      VARCHAR2  DEFAULT NULL
115 ,p_attribute16                      IN      VARCHAR2  DEFAULT NULL
116 ,p_attribute17                      IN      VARCHAR2  DEFAULT NULL
117 ,p_attribute18                      IN      VARCHAR2  DEFAULT NULL
118 ,p_attribute19                      IN      VARCHAR2  DEFAULT NULL
119 ,p_attribute20                      IN      VARCHAR2  DEFAULT NULL
120 ,p_entry_information_category       IN      VARCHAR2  DEFAULT NULL
121 ,p_entry_information1               IN      VARCHAR2  DEFAULT NULL
122 ,p_australian_resident_flag         IN      VARCHAR2
123 ,p_tax_free_threshold_flag          IN      VARCHAR2
124 ,p_rebate_amount                    IN      NUMBER DEFAULT NULL
125 ,p_fta_claim_flag                   IN      VARCHAR2
126 ,p_savings_rebate_flag              IN      VARCHAR2
127 ,p_help_sfss_flag                   IN      VARCHAR2   /* Bug# 5258625  */
128 ,p_declaration_signed_date          IN      VARCHAR2
129 ,p_medicare_levy_variation_code     IN      VARCHAR2
130 ,p_spouse_mls_flag                  IN      VARCHAR2
131 ,p_dependent_children               IN      VARCHAR2 DEFAULT NULL
132 ,p_tax_variation_type               IN      VARCHAR2
133 ,p_tax_variation_amount             IN      NUMBER DEFAULT NULL
134 ,p_tax_file_number                  IN      VARCHAR2
135 ,p_exempt_flood_levy_flag           IN      VARCHAR2 DEFAULT 'N'
136 ,p_update_warning                      OUT nocopy BOOLEAN
137 ) IS
138 
139 
140     type number_table   is table of number not null index by binary_integer;
141     type varchar2_table is table of varchar2(60) index by binary_integer;
142 
143     l_inp_value_id_table   number_table;
144     l_scr_value_table      varchar2_table;
145 
146     l_dummy                 NUMBER  := NULL;
147     l_element_type_id       NUMBER  :=0;
148     l_element_link_id       NUMBER  :=0;
149     l_element_entry_id      NUMBER  :=0;
150     l_object_version_number NUMBER;
151 
152     l_entry_information_category  pay_element_entries_f.entry_information_category%type;
153     l_entry_information1          pay_element_entries_f.entry_information1%type;
154 
155     l_session_date      DATE;
156     l_mode              VARCHAR2(100);
157 
158     CURSOR csr_paye_tax_element IS
159         SELECT pet.element_type_id
160         FROM   pay_element_types_f pet
161         WHERE  pet.element_name  = 'Tax Information' -- Bug No: 3648796
162         AND    l_session_date BETWEEN pet.effective_start_date AND pet.effective_end_date
163         AND    legislation_code = 'AU';
164 
165 
166     CURSOR csr_paye_tax_input_values(p_element_type_id pay_input_values_f.element_type_id%TYPE) IS
167         SELECT piv.input_value_id
168               ,piv.name
169         FROM   pay_input_values_f  piv
170         WHERE  piv.element_type_id = p_element_type_id
171         AND    l_session_date BETWEEN piv.effective_start_date AND piv.effective_end_date;
172 
173 
174     CURSOR csr_ele_entry (p_element_link NUMBER, p_inp_val NUMBER)IS
175         SELECT  pee.element_entry_id,
176                  object_version_number
177         FROM    pay_element_entries_f pee,
178                 pay_element_entry_values_f pev
179         WHERE   pee.assignment_id        = p_assignment_id
180         AND     l_session_date BETWEEN pee.effective_start_date AND pee.effective_end_date
181         AND     pee.element_link_id      = p_element_link
182         AND     pev.element_entry_id     = pee.element_entry_id
183         AND     l_session_date BETWEEN pev.effective_start_date AND pev.effective_end_date
184         AND     pev.input_value_id       = p_inp_val;
185 
186 
187 /* Bug# 4244787 - Cursor added to check whether future element entry exists for Tax Information when the mode
188                   is UPDATE_CHANGE_INSERT*/
189     CURSOR csr_fut_ele_entry(c_element_entry_id NUMBER, c_effective_date DATE) is
190         SELECT pee.effective_start_date, pee.effective_end_date
191         FROM pay_element_entries_f pee
192         WHERE pee.element_entry_id = c_element_entry_id
193         AND pee.effective_start_date > c_effective_date
194   ORDER BY pee.effective_start_date;
195 
196     cursor csr_leave_loading_flag
197     (p_assignment_id            number
198     ,p_effective_date           date
199     ) is
200     select scl.segment2
201     from   per_all_assignments_f            asg
202     ,      hr_soft_coding_keyflex           scl
203     where  scl.soft_coding_keyflex_id       = asg.soft_coding_keyflex_id
204     and    asg.effective_start_date         <= p_effective_date
205     and    asg.effective_end_date           >= p_effective_date
206     and    asg.assignment_id                = p_assignment_id;
207 
208    /* Bug No : 2601218 - Cursor to get the database tax detail field values */
209    /* Bug 12570937 - Added flood levy changes to the cursor */
210     CURSOR get_prev_database_tax_fields(p_element_entry_id               NUMBER,
211                                         p_au_res_input_value_id          NUMBER,
212                                         p_tax_free_input_value_id        NUMBER,
213                                         p_fta_input_value_id             NUMBER,
214                                         p_savings_reb_input_value_id     NUMBER,
215                                         p_hecs_sfss_input_value_id       NUMBER,
216                                         p_dec_date_input_value_id        NUMBER,
217                                         p_spouse_input_value_id          NUMBER,
218                                         p_tfn_input_value_id             NUMBER,
219 					p_exem_flood_input_value_id      NUMBER,
220                                         p_effective_start_date           DATE) IS
221        SELECT decode(eev0.SCREEN_ENTRY_VALUE,'YS','Y','YI','Y','YC','Y','NN','N','YN','Y','Y','Y','N','N',Null)  ,
222               eev1.SCREEN_ENTRY_VALUE  ,
223               DECODE(
224                eev2.SCREEN_ENTRY_VALUE,
225                'N', 'N',
226                    'Y', 'Y',
227                    'NF','N',
228                    'NP','N',
229                    'NC','N',
230                    'YF','Y',
231                    'YP','Y',
232                    'YC','Y',
233                'N'
234                     ),
235               DECODE(
236                eev2.SCREEN_ENTRY_VALUE,
237                    'Y', 'X',
238                'N', 'X',
239                    'NF','F',
240                    'NP','P',
241                    'NC','C',
242                    'YF','F',
243                    'YP','P',
244                    'YC','C',
245                    'X'),
246               decode(eev4.SCREEN_ENTRY_VALUE,'Y','Y','N','N','YY','Y','NY','N',Null) ,
247               decode(eev4.SCREEN_ENTRY_VALUE,'YY','Y','NY','Y','N')  ,
248               eev5.SCREEN_ENTRY_VALUE  ,
249               decode(decode(eev6.SCREEN_ENTRY_VALUE,'Y','Y','N','N','YY','Y','NY','N','NYA','N','NYB','N','NYC','N','YYA','Y','YYB','Y','YYC','Y','N'),'Y','Y',decode(eev3.SCREEN_ENTRY_VALUE,'Y','Y','N')) ,
250               eev7.SCREEN_ENTRY_VALUE  ,
251 	      eev8.screen_entry_value ,
252               pee.entry_information1
253        FROM  pay_element_entries_f      pee   ,
254              pay_element_entry_values_f eev0  ,
255              pay_element_entry_values_f eev1  ,
256              pay_element_entry_values_f eev2  ,
257              pay_element_entry_values_f eev3  ,
258              pay_element_entry_values_f eev4  ,
259              pay_element_entry_values_f eev5  ,
260              pay_element_entry_values_f eev6  ,
261              pay_element_entry_values_f eev7  ,
262 	     pay_element_entry_values_f eev8  ,
263              hr_lookups               hrl0  ,
264              hr_lookups               hrl1  ,
265              hr_lookups               hrl2  ,
266              hr_lookups               hrl3  ,
267              hr_lookups               hrl4  ,
268              hr_lookups               hrl5  ,
269 	     hr_lookups               hr16
270       WHERE  pee.element_entry_id  = p_element_entry_id
271       AND    eev0.INPUT_VALUE_ID   = p_au_res_input_value_id
272       AND    eev0.ELEMENT_ENTRY_ID = pee.element_entry_id
273       AND    hrl0.lookup_type  (+) = 'AU_AUST_RES_SENR_AUS'
274       AND    hrl0.lookup_code (+)  = eev0.SCREEN_ENTRY_VALUE
275       AND    hrl0.enabled_flag  (+)= 'Y'
276       AND    eev1.INPUT_VALUE_ID   = p_tax_free_input_value_id
277       AND    eev1.ELEMENT_ENTRY_ID = pee.element_entry_id
278       AND    hrl1.lookup_type  (+) = 'YES_NO'
279       AND    hrl1.lookup_code (+)  = eev1.SCREEN_ENTRY_VALUE
280       AND    hrl1.enabled_flag  (+)= 'Y'
281       AND    eev2.INPUT_VALUE_ID   = p_fta_input_value_id
282       AND    eev2.ELEMENT_ENTRY_ID = pee.element_entry_id
283       AND    hrl2.lookup_type (+)  = 'HR_AU_FTA_PAYMENT_BASIS'
284       AND    hrl2.lookup_code  (+) = eev2.SCREEN_ENTRY_VALUE
285       AND    hrl2.enabled_flag (+) = 'Y'
286       AND    eev3.INPUT_VALUE_ID   = p_savings_reb_input_value_id
287       AND    eev3.ELEMENT_ENTRY_ID = pee.element_entry_id
288       AND    hrl3.lookup_type(+)   = 'YES_NO'
289       AND    hrl3.lookup_code(+)   = eev3.SCREEN_ENTRY_VALUE
290       AND    hrl3.enabled_flag (+) = 'Y'
291       AND    eev4.INPUT_VALUE_ID   = p_hecs_sfss_input_value_id
292       AND    eev4.ELEMENT_ENTRY_ID = pee.element_entry_id
293       AND    hrl4.lookup_type(+)   = 'AU_HECS_SFSS'
294       AND    hrl4.lookup_code (+)  = eev4.SCREEN_ENTRY_VALUE
295       AND    hrl4.enabled_flag (+) = 'Y'
296       AND    eev5.INPUT_VALUE_ID   = p_dec_date_input_value_id
297       AND    eev5.ELEMENT_ENTRY_ID = pee.element_entry_id
298       AND    eev6.INPUT_VALUE_ID   = p_spouse_input_value_id
299       AND    eev6.ELEMENT_ENTRY_ID = pee.element_entry_id
300       AND    hrl5.lookup_type  (+) = 'AU_SPOUSE_MLS'
301       AND    hrl5.lookup_code (+)  = eev6.SCREEN_ENTRY_VALUE
302       AND    hrl5.enabled_flag (+) = 'Y'
303       AND    eev7.INPUT_VALUE_ID  = p_tfn_input_value_id
304       AND    eev7.ELEMENT_ENTRY_ID= pee.element_entry_id
305       AND    eev8.INPUT_VALUE_ID = p_exem_flood_input_value_id
306       AND    eev8.ELEMENT_ENTRY_ID= pee.element_entry_id
307       AND    hr16.lookup_type  (+) = 'YES_NO'
308       AND    hr16.lookup_code (+)  = eev8.SCREEN_ENTRY_VALUE
309       AND    hr16.enabled_flag (+) = 'Y'
310       AND    p_effective_start_date between eev0.effective_start_date and eev0.effective_end_date
311       AND    p_effective_start_date between eev1.effective_start_date and eev1.effective_end_date
312       AND    p_effective_start_date between eev2.effective_start_date and eev2.effective_end_date
313       AND    p_effective_start_date between eev3.effective_start_date and eev3.effective_end_date
314       AND    p_effective_start_date between eev4.effective_start_date and eev4.effective_end_date
315       AND    p_effective_start_date between eev5.effective_start_date and eev5.effective_end_date
316       AND    p_effective_start_date between eev6.effective_start_date and eev6.effective_end_date
317       AND    p_effective_start_date between eev7.effective_start_date and eev7.effective_end_date
318       AND    p_effective_start_date between eev8.effective_start_date and eev8.effective_end_date
319       AND    p_effective_start_date between pee.effective_start_date and pee.effective_end_date;
320 
321    /* Bug 7042960: 2008 Statutory Updates - FTA Claim Changes */
322     CURSOR get_fta_claim_flag(p_fta_claim_flag     VARCHAR2) IS
323       SELECT DECODE(
324                   p_fta_claim_flag,
325                  'N', 'N',
326                  'Y', 'N',
327                  'NF','NF',
328                  'NP','NP',
329                  'NC','NC',
330                  'YF','NF',
331                  'YP','NP',
332                  'YC','NC',
333                  'N'
334                   )
335        FROM   DUAL
336        WHERE rownum=1;
337 
338     /* Bug : 2601218 - Cursor to get the tax detail field value from parameters passed */
339     /* Bug : 3318756 - Replaced to_date with fnd_date.chardate_to_date in the select
340                        statement for p_declaration_signed_date parameter */
341     /* 12570937 - Added flood_levy changes to cursor */
342     CURSOR get_passed_tax_field_values( p_australian_resident_flag       VARCHAR2
343                                        ,p_tax_free_threshold_flag        VARCHAR2
344                                        ,p_fta_claim_flag                 VARCHAR2
345                                        ,p_savings_rebate_flag            VARCHAR2
346                                        ,p_hecs_sfss_flag                 VARCHAR2
347                                        ,p_declaration_signed_date        VARCHAR2
348                                        ,p_spouse_mls_flag                VARCHAR2
349                                        ,p_tax_file_number                VARCHAR2
350 				       ,p_exem_flood_levy_flag           VARCHAR2) IS
351        SELECT decode(p_australian_resident_flag,'YS','Y','YI','Y','YC','Y','NN','N','YN','Y','Y','Y','N','N',Null)  ,
352               p_tax_free_threshold_flag,
353               DECODE(
354                   p_fta_claim_flag,
355                  'N', 'N',
356                  'Y', 'Y',
357                  'NF','N',
358                  'NP','N',
359                  'NC','N',
360                  'YF','Y',
361                  'YP','Y',
362                  'YC','Y',
363                  'N'
364                   ),
365               DECODE(
366                   p_fta_claim_flag,
367                  'Y', 'X',
368                  'N', 'X',
369                  'NF','F',
370                  'NP','P',
371                  'NC','C',
372                  'YF','F',
373                  'YP','P',
374                  'YC','C',
375                  'X'),
376               decode(p_hecs_sfss_flag,'Y','Y','N','N','YY','Y','NY','N',Null) ,
377               decode(p_hecs_sfss_flag,'YY','Y','NY','Y','N')  ,
378               fnd_date.date_to_canonical(fnd_date.chardate_to_date(p_declaration_signed_date))  ,
379               decode(decode(p_spouse_mls_flag,'Y','Y','N','N','YY','Y','NY','N','NYA','N','NYB','N','NYC','N','YYA','Y','YYB','Y','YYC','Y','N'),'Y','Y',decode(p_savings_rebate_flag,'Y','Y','N')) ,
380               p_tax_file_number,
381 	      p_exem_flood_levy_flag
382        FROM   DUAL
383        WHERE rownum=1;
384 
385 
386     -- Tax scale temp variable
387     L_TAX_SCALE         INTEGER         := 2;
388     L_lev_lod_flg       VARCHAR2(3);
389     l_upd_tax_scale     varchar2(2);
390 
391     l_curr_australian_res_flag          VARCHAR2(1);
392     l_curr_tax_free_threshold_flag      VARCHAR2(1);
393     l_curr_fta_claim_flag               VARCHAR2(1);
394     l_curr_basis_of_payment             VARCHAR2(1);
395     l_curr_hecs_flag                    VARCHAR2(1);
396     l_curr_sfss_flag                    VARCHAR2(1);
397     l_curr_declaration_signed_date      VARCHAR2(19);
398     l_curr_rebate_flag                  VARCHAR2(1);
399     l_curr_tax_file_number              VARCHAR2(11);
400     l_curr_exempt_flood_levy_flag       VARCHAR2(1);
401 
402     l_fta_claim_flag			VARCHAR2(2); /* Bug 7042960 */
403 
404     l_prev_australian_res_flag          VARCHAR2(1);
405     l_prev_tax_free_threshold_flag      VARCHAR2(1);
406     l_prev_fta_claim_flag               VARCHAR2(1);
407     l_prev_basis_of_payment             VARCHAR2(1);
408     l_prev_hecs_flag                    VARCHAR2(1);
409     l_prev_sfss_flag                    VARCHAR2(1);
410     l_prev_declaration_signed_date      VARCHAR2(19);
411     l_prev_rebate_flag                  VARCHAR2(1);
412     l_prev_tax_file_number              VARCHAR2(11);
413     l_prev_entry_information1           VARCHAR2(19);
414     l_prev_exempt_flood_levy_flag       VARCHAR2(1);
415     l_prev_record_exists                VARCHAR2(1); -- Bug No: 3648796
416     l_start_date      DATE; /*Bug# 4244787*/
417     l_end_date        DATE; /*Bug# 4244787*/
418 
419     l_calling_source                    VARCHAR2(10);
420 
421 BEGIN
422 
423    l_prev_record_exists  :=  'Y'; -- Bug No: 3648796
424    l_mode := p_mode; -- Bug 4108099
425 
426    l_session_date := TRUNC(p_session_date);
427    if l_session_date = TRUNC(p_effective_start_date) -- Bug 4108099
428        and l_mode = 'UPDATE' then
429      l_mode := 'CORRECTION';
430    end if;
431 
432    -- Get the leave loading flags.
433     OPEN  csr_leave_loading_flag (p_assignment_id, l_session_date);
434     FETCH csr_leave_loading_flag INTO l_lev_lod_flg;
435     CLOSE csr_leave_loading_flag;
436 
437     hr_utility.trace('after leave loading');
438 
439     --SFSS Value cannot exist before 31-JUL-2000
440     -- Bug#5258625
441     if ((l_session_date < to_date('31/07/2000','DD/MM/YYYY')) and (substr(P_help_sfss_flag,2,1) is not null)) then
442         hr_utility.set_message(801,'HR_AU_SFSS_NOT_VALID');
443         hr_utility.raise_error;
444     end If;
445 
446     -- MLS is not valid before 01-JUL-2000
447      if ((l_session_date < to_date('01/07/2000','DD/MM/YYYY')) and (substr(p_spouse_mls_flag,2,1) =
448      'Y'))
449      then
450         hr_utility.set_message(801,'HR_AU_MLS_NOT_VALID');
451         hr_utility.raise_error;
452      end If;
453 
454 
455     -- Derive the tax scale
456     L_tax_Scale := hr_au_tax_api.tax_scale
457         (
458         p_tax_file_number       => p_tax_file_number
459         ,p_australian_resident_flag     => p_australian_resident_flag
460         ,p_tax_free_threshold_flag      => nvl(p_tax_free_threshold_flag,'N') /* Bug 7664100 */
461         ,p_lev_lod_flg                  => l_lev_lod_flg
462         ,p_medicare_levy_variation_code => p_medicare_levy_variation_code
463         ,p_tax_variation_type           => substr(p_tax_variation_type,1,1) /*Bug 4598178*/
464         );
465     hr_utility.trace('Tax Scale : '||to_char(L_tax_scale));
466     --
467     -- Get the element type id for the Tax element
468     hr_utility.trace('element_type_id');
469     --
470     OPEN csr_paye_tax_element;
471          fetch csr_paye_tax_element into l_element_type_id;
472     IF (csr_paye_tax_element%NOTFOUND)
473     THEN
474         CLOSE csr_paye_tax_element;
475         hr_utility.set_message(801,'HR_AU_NZ_ELE_TYP_NOT_FND');
476         hr_utility.raise_error;
477     END IF;
478     CLOSE csr_paye_tax_element;
479 
480     --
481     -- Get the Input Value Id for each Tax Input
482 
483     hr_utility.trace('input value id');
484 
485     --
486     FOR rec_paye_tax_element in csr_paye_tax_input_values(l_element_type_id) LOOP
487         IF UPPER(rec_paye_tax_element.name) = 'AUSTRALIAN RESIDENT' THEN
488             l_inp_value_id_table(1) := rec_paye_tax_element.input_value_id;
489 
490         ELSIF UPPER(rec_paye_tax_element.name) = 'TAX FREE THRESHOLD' THEN
491                 l_inp_value_id_table(2) := rec_paye_tax_element.input_value_id;
492 
493         ELSIF UPPER(rec_paye_tax_element.name) = 'REBATE AMOUNT' THEN
494             l_inp_value_id_table(3) := rec_paye_tax_element.input_value_id;
495 
496         ELSIF UPPER(rec_paye_tax_element.name) = 'FTA CLAIM' THEN
497             l_inp_value_id_table(4) := rec_paye_tax_element.input_value_id;
498 
499         ELSIF UPPER(rec_paye_tax_element.name) = 'SAVINGS REBATE' THEN
500             l_inp_value_id_table(5) := rec_paye_tax_element.input_value_id;
501 
502         ELSIF UPPER(rec_paye_tax_element.name) = 'HECS' THEN
503             l_inp_value_id_table(6) := rec_paye_tax_element.input_value_id;
504 
505         ELSIF UPPER(rec_paye_tax_element.name) = 'DATE DECLARATION SIGNED' THEN
506                 l_inp_value_id_table(7) := rec_paye_tax_element.input_value_id;
507 
508         ELSIF UPPER(rec_paye_tax_element.name) = 'MEDICARE LEVY VARIATION' THEN
509             l_inp_value_id_table(8) := rec_paye_tax_element.input_value_id;
510 
511         ELSIF UPPER(rec_paye_tax_element.name) = 'SPOUSE' THEN
512             l_inp_value_id_table(9) := rec_paye_tax_element.input_value_id;
513 
514         ELSIF UPPER(rec_paye_tax_element.name) = 'DEPENDENT CHILDREN' THEN
515             l_inp_value_id_table(10) := rec_paye_tax_element.input_value_id;
516 
517         ELSIF UPPER(rec_paye_tax_element.name) = 'TAX VARIATION TYPE' THEN
518                     l_inp_value_id_table(11) := rec_paye_tax_element.input_value_id;
519 
520         ELSIF UPPER(rec_paye_tax_element.name) = 'TAX VARIATION AMOUNT' THEN
521             l_inp_value_id_table(12) := rec_paye_tax_element.input_value_id;
522 
523         ELSIF UPPER(rec_paye_tax_element.name) = 'TAX SCALE' THEN
524             l_inp_value_id_table(13) := rec_paye_tax_element.input_value_id;
525 
526         ELSIF UPPER(rec_paye_tax_element.name) = 'TAX FILE NUMBER' THEN
527             l_inp_value_id_table(14) := rec_paye_tax_element.input_value_id;
528 
529 	ELSIF UPPER(rec_paye_tax_element.name) = 'EXEMPT FLOOD LEVY' THEN
530             l_inp_value_id_table(15) := rec_paye_tax_element.input_value_id;
531 
532         END IF;
533     END LOOP;
534 
535     --
536     -- Get the element link id for the tax information element
537     --
538        l_element_link_id := hr_entry_api.get_link
539                             (p_assignment_id    => p_assignment_id
540                             ,p_element_type_id  => l_element_type_id
541                             ,p_session_date   => l_session_date);
542 
543 
544     IF (l_element_link_id IS NULL OR l_element_link_id = 0)
545     THEN
546         hr_utility.set_message(801,'HR_AU_ELE_LNK_NOT_FND');
547         hr_utility.raise_error;
548     END IF;
549 
550 
551     IF (l_mode IN ('CORRECTION','UPDATE','UPDATE_CHANGE_INSERT','UPDATE_OVERRIDE')) THEN
552         -----------------------------------------------------------------------------
553         -- Get the element entry of the tax element entry that is to be updated
554         ------------------------------------------------------------------------------
555         hr_utility.set_location('hr_au_tax_api.maintain_tax_info' ,7);
556 
557         OPEN csr_ele_entry(l_element_link_id, l_inp_value_id_table(1));
558         FETCH csr_ele_entry INTO l_element_entry_id,l_object_version_number;
559         IF (csr_ele_entry%NOTFOUND) THEN
560             CLOSE csr_ele_entry;
561             hr_utility.set_message(801,'HR_AU_ELE_ENT_NOT_FND');
562             hr_utility.raise_error;
563         END IF;
564         CLOSE csr_ele_entry;
565 
566 
567 /*Bug# 4244787 - This piece of code added to change mode from UPDATE_CHANGE_INSERT to UPDATE when there are no
568                  future element entry for Tax Information*/
569   IF l_mode = 'UPDATE_CHANGE_INSERT' THEN
570            OPEN csr_fut_ele_entry(l_element_entry_id, l_session_date);
571      FETCH csr_fut_ele_entry INTO l_start_date,l_end_date;
572      IF csr_fut_ele_entry%NOTFOUND THEN
573         l_mode := 'UPDATE';
574      END IF ;
575      CLOSE csr_fut_ele_entry;
576   END IF ;
577 
578         -- Bug 2145933 -- Set the Tax Scales to S,C,I for Tax Scales 11,12,13 respectively
579 
580         IF (l_tax_scale = 11 ) THEN
581            l_upd_tax_scale := 'S';
582         ELSIF (l_tax_scale = 12) THEN
583            l_upd_tax_scale := 'I';
584         ELSIF (l_tax_scale = 13) THEN
585            l_upd_tax_scale := 'C';
586         ELSE
587            l_upd_tax_scale := l_tax_scale;
588         END IF;
589 
590         hr_utility.trace('Session Date = '||l_session_date);
591         hr_utility.trace('to_date = '||to_date('01/07/2008','DD/MM/YYYY'));
592 
593            /* Bug 7042960: 2008 Statutory Updates - FTA Claim Changes */
594            IF (l_session_date >= to_date('01/07/2008','DD/MM/YYYY')) THEN
595                open get_fta_claim_flag(p_fta_claim_flag);
596                fetch get_fta_claim_flag into l_fta_claim_flag;
597                close get_fta_claim_flag;
598            hr_utility.trace('Inside IF: l_fta_claim_flag Value = '||l_fta_claim_flag);
599            ELSE
600                l_fta_claim_flag := p_fta_claim_flag;
601            hr_utility.trace('Inside ELSE: l_fta_claim_flag Value = '||l_fta_claim_flag);
602            END IF;
603 
604         -- Check if the API is called from Tax Declaration form or not
605 
606         /* Bug No : 2601218 - Check if the any of reportable tax field is changed
607           and pass the parameters to the core api accordingly */
608 
609         l_calling_source  := pay_au_tfn_magtape.get_value();
610 
611         IF  l_calling_source = 'FORM' THEN
612            l_entry_information_category  := p_entry_information_category;
613            l_entry_information1          := p_entry_information1;
614         ELSE
615 
616            open get_prev_database_tax_fields(
617                                     l_element_entry_id,
618                                     l_inp_value_id_table(1),
619                                     l_inp_value_id_table(2),
620                                     l_inp_value_id_table(4),
621                                     l_inp_value_id_table(5),
622                                     l_inp_value_id_table(6),
623                                     l_inp_value_id_table(7),
624                                     l_inp_value_id_table(9),
625                                     l_inp_value_id_table(14),
626 				    l_inp_value_id_table(15),
627                                     p_effective_start_date);
628            fetch get_prev_database_tax_fields into
629                                     l_prev_australian_res_flag      ,
630                                     l_prev_tax_free_threshold_flag  ,
631                                     l_prev_fta_claim_flag           ,
632                                     l_prev_basis_of_payment         ,
633                                     l_prev_hecs_flag                ,
634                                     l_prev_sfss_flag                ,
635                                     l_prev_declaration_signed_date  ,
636                                     l_prev_rebate_flag              ,
637                                     l_prev_tax_file_number          ,
638 				    l_prev_exempt_flood_levy_flag   ,
639                                     l_prev_entry_information1       ;
640 
641            IF get_prev_database_tax_fields%notfound then
642               l_prev_record_exists := 'N';
643            END IF;
644 
645            close get_prev_database_tax_fields;
646 
647            open  get_passed_tax_field_values(
648                                     p_australian_resident_flag ,
649                                     p_tax_free_threshold_flag  ,
650                                     l_fta_claim_flag           ,  /* Bug 7042960 */
651                                     p_savings_rebate_flag      ,
652                                     p_help_sfss_flag           ,  /* Bug#5258625 */
653                                     p_declaration_signed_date  ,
654                                     p_spouse_mls_flag          ,
655                                     p_tax_file_number,
656 				    p_exempt_flood_levy_flag);
657 
658            fetch get_passed_tax_field_values into
659                                     l_curr_australian_res_flag      ,
660                                     l_curr_tax_free_threshold_flag  ,
661                                     l_curr_fta_claim_flag           ,
662                                     l_curr_basis_of_payment         ,
663                                     l_curr_hecs_flag                ,
664                                     l_curr_sfss_flag                ,
665                                     l_curr_declaration_signed_date  ,
666                                     l_curr_rebate_flag              ,
667                                     l_curr_tax_file_number          ,
668 				    l_curr_exempt_flood_levy_flag;
669            close get_passed_tax_field_values;
670 
671            IF(l_curr_australian_res_flag      <>  l_prev_australian_res_flag     or
672               l_curr_tax_free_threshold_flag  <>  l_prev_tax_free_threshold_flag or
673               l_curr_fta_claim_flag           <>  l_prev_fta_claim_flag          or
674               l_curr_basis_of_payment         <>  l_prev_basis_of_payment        or
675               l_curr_hecs_flag                <>  l_prev_hecs_flag               or
676               l_curr_sfss_flag                <>  l_prev_sfss_flag               or
677               l_curr_declaration_signed_date  <>  l_prev_declaration_signed_date or
678               l_curr_rebate_flag              <>  l_prev_rebate_flag             or
679               l_curr_tax_file_number          <>  l_prev_tax_file_number         or
680 	      l_curr_exempt_flood_levy_flag   <>  l_prev_exempt_flood_levy_flag  or
681               l_prev_record_exists            = 'N'       ) THEN
682 
683               l_entry_information_category := 'AU_TAX DEDUCTIONS';
684               l_entry_information1         := fnd_date.date_to_canonical(sysdate);
685            ELSE
686               l_entry_information_category := 'AU_TAX DEDUCTIONS';
687               l_entry_information1         := l_prev_entry_information1;
688            END IF;
689 
690         END IF;
691 
692         -- Pass entry_information1 as null if basis of payment is null
693         IF l_curr_basis_of_payment = 'X' THEN
694             l_entry_information_category := 'AU_TAX DEDUCTIONS';
695             l_entry_information1         := null;
696         END IF;
697 
698         hr_utility.trace('Upd Tax Scale' || l_upd_tax_scale);
699   hr_utility.trace('fta_claim_flag' || p_fta_claim_flag);
700   /* Bug 12570937 - Added flood levy parameter to the below call */
701         py_element_entry_api.update_element_entry
702             (p_validate             => p_validate
703             ,p_datetrack_update_mode=> l_mode
704             ,p_effective_date       => l_session_date
705             ,p_business_group_id    => p_business_group_id
706             ,p_element_entry_id     => l_element_entry_id
707             ,p_object_version_number=> l_object_version_number
708             ,p_attribute_category   => p_attribute_category
709             ,p_attribute1           => p_attribute1
710             ,p_attribute2           => p_attribute2
711             ,p_attribute3           => p_attribute3
712             ,p_attribute4           => p_attribute4
713             ,p_attribute5           => p_attribute5
714             ,p_attribute6           => p_attribute6
715             ,p_attribute7           => p_attribute7
716             ,p_attribute8           => p_attribute8
717             ,p_attribute9           => p_attribute9
718             ,p_attribute10          => p_attribute10
719             ,p_attribute11          => p_attribute11
720             ,p_attribute12          => p_attribute12
721             ,p_attribute13          => p_attribute13
722             ,p_attribute14          => p_attribute14
723             ,p_attribute15          => p_attribute15
724             ,p_attribute16          => p_attribute16
725             ,p_attribute17          => p_attribute17
726             ,p_attribute18          => p_attribute18
727             ,p_attribute19          => p_attribute19
728             ,p_attribute20          => p_attribute20
729             ,p_input_value_id1      => l_inp_value_id_table(1)
730             ,p_input_value_id2      => l_inp_value_id_table(2)
731             ,p_input_value_id3      => l_inp_value_id_table(3)
732             ,p_input_value_id4      => l_inp_value_id_table(4)
733             ,p_input_value_id5      => l_inp_value_id_table(5)
734             ,p_input_value_id6      => l_inp_value_id_table(6)
735             ,p_input_value_id7      => l_inp_value_id_table(7)
736             ,p_input_value_id8      => l_inp_value_id_table(8)
737             ,p_input_value_id9      => l_inp_value_id_table(9)
738             ,p_input_value_id10     => l_inp_value_id_table(10)
739             ,p_input_value_id11     => l_inp_value_id_table(11)
740             ,p_input_value_id12     => l_inp_value_id_table(12)
741             ,p_input_value_id13     => l_inp_value_id_table(13)
742             ,p_input_value_id14     => l_inp_value_id_table(14)
743 	    ,p_input_value_id15     => l_inp_value_id_table(15)
744             ,p_entry_value1         => p_australian_resident_flag
745             ,p_entry_value2         => nvl(p_tax_free_threshold_flag,'N') /* Bug 7664100 */
746             ,p_entry_value3         => p_rebate_amount
747             ,p_entry_value4         => l_fta_claim_flag          /* Bug 7042960 */
748             ,p_entry_value5         => p_savings_rebate_flag
749             ,p_entry_value6         => p_help_sfss_flag          /* Bug#5258625 */
750             ,p_entry_value7         => p_declaration_signed_date
751             ,p_entry_value8         => p_medicare_levy_variation_code
752             ,p_entry_value9         => p_spouse_mls_flag
753             ,p_entry_value10        => p_dependent_children
754             ,p_entry_value11        => p_tax_variation_type
755             ,p_entry_value12        => p_tax_variation_amount
756             ,p_entry_value13        => l_upd_tax_scale   /* Bug 2145933 */
757             ,p_entry_value14        => p_tax_file_number
758 	    ,p_entry_value15        => p_exempt_flood_levy_flag
759             ,p_entry_information_category => l_entry_information_category
760             ,p_entry_information1   => l_entry_information1
761             ,p_override_user_ent_chk   => 'Y'
762             ,p_effective_start_date => p_effective_start_date
763             ,p_effective_end_date   => p_effective_end_date
764             ,p_update_warning       => p_update_warning);
765     END IF;
766 END maintain_PAYE_tax_info;
767 
768 
769 PROCEDURE maintain_SUPER_info
770     (p_validate                     IN      BOOLEAN  DEFAULT FALSE
771     ,p_assignment_id                IN      NUMBER
772     ,p_effective_start_date         IN OUT nocopy DATE
773     ,p_effective_end_date           IN OUT nocopy DATE
774     ,p_session_date                 IN      DATE
775     ,p_mode                         IN      VARCHAR2
776     ,p_business_group_id            IN      NUMBER
777     ,p_attribute_category           IN      VARCHAR2  DEFAULT NULL
778     ,p_attribute1                   IN      VARCHAR2  DEFAULT NULL
779     ,p_attribute2                   IN      VARCHAR2  DEFAULT NULL
780     ,p_attribute3                   IN      VARCHAR2  DEFAULT NULL
781     ,p_attribute4                   IN      VARCHAR2  DEFAULT NULL
782     ,p_attribute5                   IN      VARCHAR2  DEFAULT NULL
783     ,p_attribute6                   IN      VARCHAR2  DEFAULT NULL
784     ,p_attribute7                   IN      VARCHAR2  DEFAULT NULL
785     ,p_attribute8                   IN      VARCHAR2  DEFAULT NULL
786     ,p_attribute9                   IN      VARCHAR2  DEFAULT NULL
787     ,p_attribute10                  IN      VARCHAR2  DEFAULT NULL
788     ,p_attribute11                  IN      VARCHAR2  DEFAULT NULL
789     ,p_attribute12                  IN      VARCHAR2  DEFAULT NULL
790     ,p_attribute13                  IN      VARCHAR2  DEFAULT NULL
791     ,p_attribute14                  IN      VARCHAR2  DEFAULT NULL
792     ,p_attribute15                  IN      VARCHAR2  DEFAULT NULL
793     ,p_attribute16                  IN      VARCHAR2  DEFAULT NULL
794     ,p_attribute17                  IN      VARCHAR2  DEFAULT NULL
795     ,p_attribute18                  IN      VARCHAR2  DEFAULT NULL
796     ,p_attribute19                  IN      VARCHAR2  DEFAULT NULL
797     ,p_attribute20                  IN      VARCHAR2  DEFAULT NULL
798     ,p_tfn_for_super_flag           IN      VARCHAR2  DEFAULT NULL
799     ,p_update_warning                  OUT nocopy BOOLEAN
800     ) IS
801 
802 
803       type number_table   is table of number not null index by binary_integer;
804       type varchar2_table is table of varchar2(60) index by binary_integer;
805 
806     l_inp_value_id_table   number_table;
807     l_scr_value_table      varchar2_table;
808 
809     l_dummy                 NUMBER  := NULL;
810     l_element_type_id       NUMBER  :=0;
811     l_element_link_id       NUMBER  :=0;
812     l_element_entry_id      NUMBER  :=0;
813     l_object_version_number NUMBER;
814     l_session_date      DATE;
815 
816     l_prev_spr_flag_value        VARCHAR2(1);
817     l_calling_source             VARCHAR2(10);
818     l_paye_element_entry_id      NUMBER;
819     l_paye_object_version_number NUMBER;
820     l_paye_effective_start_date  DATE;
821     l_paye_effective_end_date    DATE;
822 
823 -- Bug 3875404 - Local Variable added to l_tax_effective_date to support NOCOPY construct.
824       l_tax_effective_date  DATE;
825 
826     CURSOR csr_paye_tax_element IS
827         SELECT pet.element_type_id
828         FROM   pay_element_types_f pet
829         WHERE  pet.element_name  = 'Superannuation Guarantee Information'  -- Bug No: 3648796
830         AND    l_session_date BETWEEN pet.effective_start_date AND pet.effective_end_date
831         AND    legislation_code = 'AU';
832 
833 
834     CURSOR csr_paye_tax_input_values(p_element_type_id pay_input_values_f.element_type_id%TYPE) IS
835         SELECT piv.input_value_id
836               ,piv.name
837         FROM   pay_input_values_f  piv
838         WHERE  piv.element_type_id = p_element_type_id
839         AND    l_session_date BETWEEN piv.effective_start_date AND piv.effective_end_date;
840 
841 
842     CURSOR csr_ele_entry (p_element_link NUMBER, p_inp_val NUMBER)IS
843         SELECT  pee.element_entry_id
844                  ,object_version_number
845         FROM    pay_element_entries_f pee,
846                 pay_element_entry_values_f pev
847         WHERE   pee.assignment_id        = p_assignment_id
848         AND     l_session_date BETWEEN pee.effective_start_date AND pee.effective_end_date
849         AND     pee.element_link_id      = p_element_link
850         AND     pev.element_entry_id     = pee.element_entry_id
851         AND     l_session_date BETWEEN pev.effective_start_date AND pev.effective_end_date
852         AND     pev.input_value_id       = p_inp_val;
853 
854     /* Bug 2601218 : Cursor to get the database value of Superannuation flag */
855 
856     CURSOR get_prev_tfn_super_value(p_element_entry_id         NUMBER,
857                                     p_spr_flag_input_value_id  NUMBER,
858                                     p_effective_start_date     DATE) IS
859         SELECT nvl(screen_entry_value,'N')
860         FROM   pay_element_entry_values_f
861         WHERE  element_entry_id = p_element_entry_id
862         AND    input_value_id   = p_spr_flag_input_value_id
863         AND    p_effective_start_date between effective_start_date and effective_end_date;
864 
865     /* Bug 2601218 : Cursor to get the 'Tax Information' element entry details
866        for the current where Superannuation is updated */
867 
868     CURSOR get_tax_info_to_update(p_effective_start_date DATE,
869                                   p_assignment_id        NUMBER) IS
870         SELECT pee.element_entry_id,
871                pee.object_version_number,
872                pee.effective_start_date,
873                pee.effective_end_date
874         FROM   pay_element_types_f   pet,
875                pay_element_links_f   pel,
876                pay_element_entries_f pee
877         WHERE  pet.element_name      = 'Tax Information'
878         AND    pel.element_type_id   = pet.element_type_id
879         AND    pee.element_link_id   = pel.element_link_id
880         AND    pee.assignment_id     = p_assignment_id
881         AND    pel.effective_start_date between pet.effective_start_date and pet.effective_end_date
882         AND    p_effective_start_date   between pee.effective_start_date and pee.effective_end_date;
883 
884 
885   BEGIN
886     l_session_date := TRUNC(p_session_date);
887 
888     --
889     -- Get the element type id for the Tax element
890     --
891     OPEN csr_paye_tax_element;
892     FETCH csr_paye_tax_element INTO l_element_type_id;
893     IF (csr_paye_tax_element%NOTFOUND)
894     THEN
895         CLOSE csr_paye_tax_element;
896         hr_utility.set_message(801,'HR_AU_NZ_ELE_TYP_NOT_FND');
897         hr_utility.raise_error;
898     END IF;
899     CLOSE csr_paye_tax_element;
900 
901     --
902     -- Get the Input Value Id for each Tax Input
903     --
904     FOR rec_paye_tax_element in csr_paye_tax_input_values(l_element_type_id) LOOP
905         IF UPPER(rec_paye_tax_element.name) = 'TFN FOR SUPERANNUATION' THEN
906             l_inp_value_id_table(1) := rec_paye_tax_element.input_value_id;
907         END IF;
908     END LOOP;
909 
910     --
911     -- Get the element link id for the tax information element
912     --
913     l_element_link_id := hr_entry_api.get_link
914                             (p_assignment_id    => p_assignment_id
915                             ,p_element_type_id  => l_element_type_id
916                             ,p_session_date     => l_session_date);
917     IF (l_element_link_id IS NULL OR l_element_link_id = 0)
918     THEN
919         hr_utility.set_message(801,'HR_AU_ELE_LNK_NOT_FND');
920         hr_utility.raise_error;
921     END IF;
922 
923     IF (p_mode IN ('CORRECTION','UPDATE','UPDATE_CHANGE_INSERT','UPDATE_OVERRIDE')) THEN
924 
925         -----------------------------------------------------------------------------
926         -- Get the element entry of the tax element entry that is to be updated
927         ------------------------------------------------------------------------------
928 
929         hr_utility.set_location('hr_au_tax_api.maintain_tax_info' ,7);
930 
931         OPEN csr_ele_entry(l_element_link_id, l_inp_value_id_table(1));
932         FETCH csr_ele_entry INTO l_element_entry_id,l_object_version_number;
933         IF (csr_ele_entry%NOTFOUND) THEN
934             CLOSE csr_ele_entry;
935             hr_utility.set_message(801,'HR_AU_ELE_ENT_NOT_FND');
936             hr_utility.raise_error;
937         END IF;
938         CLOSE csr_ele_entry;
939 
940         -- Bug 2601218 : Update 'Tax Information' segment 1 as last update date
941 
942         l_calling_source  := pay_au_tfn_magtape.get_value();
943 
944         IF l_calling_source <> 'FORM' THEN
945 
946             OPEN get_prev_tfn_super_value(
947                           l_element_entry_id ,
948                           l_inp_value_id_table(1),
949                           p_effective_start_date );
950             FETCH get_prev_tfn_super_value INTO l_prev_spr_flag_value;
951             CLOSE get_prev_tfn_super_value;
952 
953             IF nvl(p_tfn_for_super_flag,'N') <> nvl(l_prev_spr_flag_value,'N') THEN
954 
955                OPEN get_tax_info_to_update(p_effective_start_date ,
956                                            p_assignment_id );
957                FETCH get_tax_info_to_update INTO l_paye_element_entry_id,
958                                                  l_paye_object_version_number,
959                                                  l_paye_effective_start_date,
960                                                  l_paye_effective_end_date;
961                CLOSE get_tax_info_to_update;
962 
963 -- Bug 3875404 - Stored the Value in a temporary variable for IN parameter binding.
964            l_tax_effective_date := l_paye_effective_start_date ;
965 
966                py_element_entry_api.update_element_entry
967                  (p_validate                 => p_validate
968                  ,p_datetrack_update_mode    => 'CORRECTION'
969                  ,p_effective_date           => l_tax_effective_date
970                  ,p_business_group_id        => p_business_group_id
971                  ,p_element_entry_id         => l_paye_element_entry_id
972                  ,p_object_version_number    => l_paye_object_version_number
973                  ,p_entry_information_category => 'AU_TAX_DEDUCTIONS'
974                  ,p_entry_information1       => fnd_date.date_to_canonical(sysdate)
975                  ,p_override_user_ent_chk    => 'Y'
976                  ,p_effective_start_date     => l_paye_effective_start_date
977                  ,p_effective_end_date       => l_paye_effective_end_date
978                  ,p_update_warning           => p_update_warning);
979 
980             END IF;
981 
982         END IF;
983 
984         py_element_entry_api.update_element_entry
985             (p_validate                 => p_validate
986             ,p_datetrack_update_mode    => p_mode
987             ,p_effective_date           => l_session_date
988             ,p_business_group_id        => p_business_group_id
989             ,p_element_entry_id         => l_element_entry_id
990             ,p_object_version_number    => l_object_version_number
991             ,p_attribute_category       => p_attribute_category
992             ,p_attribute1               => p_attribute1
993             ,p_attribute2               => p_attribute2
994             ,p_attribute3               => p_attribute3
995             ,p_attribute4               => p_attribute4
996             ,p_attribute5               => p_attribute5
997             ,p_attribute6               => p_attribute6
998             ,p_attribute7               => p_attribute7
999             ,p_attribute8               => p_attribute8
1000             ,p_attribute9               => p_attribute9
1001             ,p_attribute10              => p_attribute10
1002             ,p_attribute11              => p_attribute11
1003             ,p_attribute12              => p_attribute12
1004             ,p_attribute13              => p_attribute13
1005             ,p_attribute14              => p_attribute14
1006             ,p_attribute15              => p_attribute15
1007             ,p_attribute16              => p_attribute16
1008             ,p_attribute17              => p_attribute17
1009             ,p_attribute18              => p_attribute18
1010             ,p_attribute19              => p_attribute19
1011             ,p_attribute20              => p_attribute20
1012             ,p_input_value_id1          => l_inp_value_id_table(1)
1013             ,p_entry_value1             => p_tfn_for_super_flag
1014             ,p_override_user_ent_chk    => 'Y'
1015             ,p_effective_start_date     => p_effective_start_date
1016             ,p_effective_end_date       => p_effective_end_date
1017             ,p_update_warning           => p_update_warning);
1018 
1019     END IF;
1020 END maintain_SUPER_info;
1021 
1022 
1023 FUNCTION tax_scale
1024          (p_tax_file_number               IN    VARCHAR2
1025          ,p_australian_resident_flag      IN    VARCHAR2
1026          ,p_tax_free_threshold_flag       IN    VARCHAR2
1027          ,p_lev_lod_flg                   IN    VARCHAR2
1028          ,p_medicare_levy_variation_code  IN    VARCHAR2
1029          ,p_tax_variation_type            IN    VARCHAR2
1030          )
1031 RETURN INTEGER IS
1032 
1033     L_valid_tfn_provided    BOOLEAN := FALSE;
1034     L_tax_scale             INTEGER; -- Bug No: 3648796
1035     l_procedure             varchar2(60); -- Bug No: 3648796
1036 
1037 BEGIN
1038     l_procedure  :=  'tax_scale'; -- Bug No: 3648796
1039     L_tax_scale  := -1; -- Bug No: 3648796
1040 
1041     hr_utility.set_location(g_package||l_procedure, 1);
1042     hr_utility.trace('p_tax_file_number              - '||p_tax_file_number);
1043     hr_utility.trace('p_australian_resident_flag     - '||p_australian_resident_flag);
1044     hr_utility.trace('p_tax_free_threshold_flag      - '||p_tax_free_threshold_flag);
1045     hr_utility.trace('p_lev_lod_flg                  - '||p_lev_lod_flg);
1046     hr_utility.trace('p_medicare_levy_variation_code - '||p_medicare_levy_variation_code);
1047     hr_utility.trace('p_tax_variation_type           - '||p_tax_variation_type);
1048     --
1049     -- Check if a valid TFN has been supplied
1050     IF nvl(P_Tax_File_number,'000 000 000') ='000 000 000' THEN
1051         L_valid_tfn_provided := FALSE;
1052     ELSE
1053         L_valid_tfn_provided := TRUE;
1054     END IF;
1055 
1056     -- TAX SCALE 8
1057     IF P_tax_variation_Type = 'E' THEN
1058         L_tax_scale := 8;
1059 
1060         -- No further processing needed.
1061         -- Bug 980658
1062         hr_utility.trace('tax_scale - '||to_char(l_tax_scale));
1063         return (L_tax_scale);
1064     END IF;
1065 
1066     -- TAX SCALE 9
1067     IF P_tax_variation_Type = 'P' THEN
1068         L_tax_scale := 9;
1069         -- No further processing needed.
1070         -- Bug 980658
1071         hr_utility.trace('tax_scale - '||to_char(l_tax_scale));
1072         return (L_tax_scale);
1073     END IF;
1074 
1075     -- TAX SCALE 10
1076     IF P_tax_variation_Type = 'F' THEN
1077         L_tax_scale := 10;
1078         -- No further processing needed.
1079         -- Bug 980658
1080         hr_utility.trace('tax_scale - '||to_char(l_tax_scale));
1081         return (L_tax_scale);
1082     END IF;
1083 
1084     -- TAX SCALE 4
1085     IF not L_valid_tfn_provided THEN
1086 
1087         L_tax_scale := 4;
1088 
1089         -- No further processing necessary,  is no valid TFN supplied
1090         -- then always scale 4. Refer to bug 971984
1091         hr_utility.trace('tax_scale - '||to_char(l_tax_scale));
1092         return (L_tax_scale);
1093     END IF;
1094 
1095     -- TAX SCALE 3
1096     IF   L_valid_tfn_provided
1097     AND substr(P_australian_resident_flag,1,1)  = 'N' THEN /* Bug 2145933 */
1098         L_tax_scale := 3;
1099 
1100         -- No further processing needed.
1101         -- If a person has a TFN and is non resident the scale is
1102         -- always 3,   refer to bug 971982
1103         hr_utility.trace('tax_scale - '||to_char(l_tax_scale));
1104         return (L_tax_scale);
1105     END IF;
1106 
1107     -- TAX SCALE 1
1108     IF  L_valid_tfn_provided
1109     AND P_tax_free_threshold_flag = 'N'
1110     AND substr(P_australian_resident_flag,1,1)  = 'Y' THEN /* Bug 2145933 */
1111         L_tax_scale := 1;
1112 
1113         -- No further processing needed.
1114         -- Bug 971980
1115         hr_utility.trace('tax_scale - '||to_char(l_tax_scale));
1116         return (L_tax_scale);
1117     END IF;
1118 
1119     -- Bug 2145933 - Tax Scales 11 - 13 based on Tax Scales C,S,I
1120 
1121     IF   L_valid_tfn_provided
1122     AND  substr(p_australian_resident_flag,2,1) = 'S' THEN
1123        L_tax_scale := 11;
1124        hr_utility.trace('tax_scale - '||to_char(l_tax_scale));
1125        return(L_tax_scale);
1126     END IF;
1127 
1128     IF   L_valid_tfn_provided
1129     AND  substr(p_australian_resident_flag,2,1) = 'I' THEN
1130        L_tax_scale := 12;
1131        hr_utility.trace('tax_scale - '||to_char(l_tax_scale));
1132        return(L_tax_scale);
1133     END IF;
1134 
1135     IF   L_valid_tfn_provided
1136     AND  substr(p_australian_resident_flag,2,1) = 'C' THEN
1137        L_tax_scale := 13;
1138        hr_utility.trace('tax_scale - '||to_char(l_tax_scale));
1139        return(L_tax_scale);
1140     END IF;
1141 
1142 
1143     -- TAX SCALE 5
1144     IF  L_valid_tfn_provided
1145     AND substr(P_australian_resident_flag,1,1)  = 'Y'  /* Bug 2145933 */
1146     AND P_tax_free_threshold_flag = 'Y'
1147     AND P_medicare_levy_variation_code = 'F' THEN
1148         L_tax_scale := 5;
1149         -- No further processing needed.
1150         -- Bug 971978
1151         hr_utility.trace('tax_scale - '||to_char(l_tax_scale));
1152         return (L_tax_scale);
1153     END IF;
1154 
1155     -- TAX SCALE 6
1156     IF  L_valid_tfn_provided
1157     AND substr(P_australian_resident_flag,1,1)  = 'Y'  /* Bug 2145933 */
1158     AND P_tax_free_threshold_flag = 'Y'
1159     AND p_medicare_levy_variation_code in ('H','HA') THEN
1160         L_tax_scale := 6;
1161         hr_utility.trace('tax_scale - '||to_char(l_tax_scale));
1162         return (L_tax_scale);
1163     END IF;
1164 
1165     -- TAX SCALE 2
1166     IF  L_valid_tfn_provided
1167     AND substr(P_australian_resident_flag,1,1)  = 'Y'  /* Bug 2145933 */
1168     AND P_tax_free_threshold_flag = 'Y'
1169     AND P_lev_lod_flg               = 'Y' THEN
1170         L_tax_scale := 2;
1171         hr_utility.trace('tax_scale - '||to_char(l_tax_scale));
1172         return (L_tax_scale);
1173     END IF;
1174 
1175     -- TAX SCALE 7
1176     IF  L_valid_tfn_provided
1177     AND substr(P_australian_resident_flag,1,1)  = 'Y' /* Bug 2145933 */
1178     AND P_tax_free_threshold_flag = 'Y'
1179     AND P_lev_lod_flg               = 'N' THEN
1180         L_tax_scale := 7;
1181         hr_utility.trace('tax_scale - '||to_char(l_tax_scale));
1182         return (L_tax_scale);
1183     END IF;
1184 
1185     return (L_tax_scale);
1186 
1187 END tax_scale;
1188 --
1189 -- Function to validate the national identifier
1190 --  REturn Codes
1191 --          TRUE  - VALID
1192 --          FALSE - INVALID
1193 PROCEDURE  Validate_TFN
1194            (p_tax_file_number IN    VARCHAR2)
1195 IS
1196     L_VALID             BOOLEAN := FALSE;
1197     L_Weighted_result   NUMBER;
1198     L_Remainder         NUMBER;
1199 
1200 BEGIN
1201 
1202     -- Check the format of the TFN is 111 111 111
1203     -- Check length is 11 characters
1204     L_VALID := length (P_Tax_File_Number) <= 11;
1205 
1206     -- Check space is in position 4
1207     IF L_VALID THEN
1208         L_VALID := substr (P_tax_file_number,4,1) = ' ';
1209     END IF;
1210 
1211     -- Check space is in position 8
1212     IF L_VALID THEN
1213             L_VALID := substr (P_tax_file_number,8,1) = ' ';
1214     END IF;
1215 
1216     -- Obtain the weighted result
1217     l_weighted_result :=
1218         TO_NUMBER (substr (p_tax_file_number,1,1) ) * 10 +
1219        TO_NUMBER (substr (p_tax_file_number,2,1) ) * 7 +
1220        TO_NUMBER (substr (p_tax_file_number,3,1) ) * 8 +
1221        TO_NUMBER (substr (p_tax_file_number,5,1) ) * 4 +
1222        TO_NUMBER (substr (p_tax_file_number,6,1) ) * 6 +
1223        TO_NUMBER (substr (p_tax_file_number,7,1) ) * 3+
1224        TO_NUMBER (substr (p_tax_file_number,9,1) ) * 5 +
1225        TO_NUMBER (substr (p_tax_file_number,10,1) ) * 2 +
1226       TO_NUMBER (substr (p_tax_file_number,11,1)
1227       );
1228 
1229    l_weighted_result := l_weighted_result/11;
1230 
1231    l_remainder := l_weighted_result - trunc(l_weighted_result,0);
1232 
1233 
1234    -- IF OK then return true
1235    IF l_valid and (l_remainder = 0) THEN
1236     null;
1237 
1238    -- If a valid format and one of the secret nos then this is OK
1239    ELSIF l_valid and p_tax_file_number in ('111 111 111','333 333 333',
1240                                                     '444 444 444','987 654 321',
1241                                                     '222 222 222' ) THEN
1242     null;
1243 
1244    ELSE
1245     hr_utility.set_message(801, 'HR_AU_INVALID_NATIONAL_ID');
1246         hr_utility.raise_error;
1247 
1248    END IF;
1249    EXCEPTION WHEN OTHERS THEN
1250     hr_utility.set_message(801, 'HR_AU_INVALID_NATIONAL_ID');
1251         hr_utility.raise_error;
1252 
1253 END VALIDATE_TFN;
1254 --
1255 --
1256 ---------------------------------------------------------------------------------------------
1257 --          PRIVATE PROCEDURE get_paye_input_ids
1258 ---------------------------------------------------------------------------------------------
1259 --
1260 procedure get_paye_input_ids
1261 (p_effective_date           in      date
1262 ,p_element_type_id          in out nocopy number
1263 ,p_inp_value_id_table       in out nocopy paye_number_table
1264 ) is
1265   --
1266   l_procedure                       constant varchar2(60)   := 'get_paye_input_ids';
1267   --
1268   cursor csr_paye_input_values
1269   (p_element_type_id  pay_input_values_f.element_type_id%type
1270   ,p_effective_date   date
1271   ) is
1272   select piv.input_value_id
1273   ,      piv.name
1274   from   pay_input_values_f         piv
1275   where  piv.element_type_id        = p_element_type_id
1276   and    p_effective_date           between piv.effective_start_date and piv.effective_end_date
1277   order  by piv.display_sequence;
1278   --
1279   cursor csr_paye_element
1280   (p_effective_date         date
1281   ) is
1282   select pet.element_type_id
1283   from   pay_element_types_f        pet
1284   where  pet.element_name      = g_paye_element -- Bug No: 3648796
1285   and    p_effective_date      between pet.effective_start_date and pet.effective_end_date
1286   and    legislation_code      = g_legislation_code;
1287   --
1288 begin
1289   --
1290   -- get the element type id for the paye element
1291   --
1292   hr_utility.set_location(g_package||l_procedure, 1);
1293   --
1294   open csr_paye_element(p_effective_date);
1295   fetch csr_paye_element
1296   into p_element_type_id;
1297   if (csr_paye_element%notfound)
1298   then
1299     close csr_paye_element;
1300     hr_utility.trace('p_effective_date: '||to_char(p_effective_date,'MM/DD/YYYY'));
1301     hr_utility.set_message(801,'HR_AU_NZ_ELE_TYP_NOT_FND');
1302     hr_utility.raise_error;
1303   end if;
1304   close csr_paye_element;
1305   --
1306   -- get the input value id for each tax input
1307   --
1308   for rec_paye_element in csr_paye_input_values(p_element_type_id, p_effective_date)
1309   loop
1310     if upper(rec_paye_element.name) = g_paye_input1
1311     then
1312       p_inp_value_id_table(1) := rec_paye_element.input_value_id;
1313       --
1314     elsif upper(rec_paye_element.name) = g_paye_input2
1315     then
1316       p_inp_value_id_table(2) := rec_paye_element.input_value_id;
1317       --
1318     elsif upper(rec_paye_element.name) = g_paye_input3
1319     then
1320       p_inp_value_id_table(3) := rec_paye_element.input_value_id;
1321       --
1322     elsif upper(rec_paye_element.name) = g_paye_input4
1323     then
1324       p_inp_value_id_table(4) := rec_paye_element.input_value_id;
1325       --
1326     elsif upper(rec_paye_element.name) = g_paye_input5
1327     then
1328       p_inp_value_id_table(5) := rec_paye_element.input_value_id;
1329       --
1330     elsif upper(rec_paye_element.name) = g_paye_input6
1331     then
1332       p_inp_value_id_table(6) := rec_paye_element.input_value_id;
1333       --
1334     elsif upper(rec_paye_element.name) = g_paye_input7
1335     then
1336       p_inp_value_id_table(7) := rec_paye_element.input_value_id;
1337       --
1338     elsif upper(rec_paye_element.name) = g_paye_input8
1339     then
1340       p_inp_value_id_table(8) := rec_paye_element.input_value_id;
1341       --
1342     elsif upper(rec_paye_element.name) = g_paye_input9
1343     then
1344       p_inp_value_id_table(9) := rec_paye_element.input_value_id;
1345       --
1346     elsif upper(rec_paye_element.name) = g_paye_input10
1347     then
1348       p_inp_value_id_table(10) := rec_paye_element.input_value_id;
1349       --
1350     elsif upper(rec_paye_element.name) = g_paye_input11
1351     then
1352       p_inp_value_id_table(11) := rec_paye_element.input_value_id;
1353       --
1354     elsif upper(rec_paye_element.name) = g_paye_input12
1355     then
1356       p_inp_value_id_table(12) := rec_paye_element.input_value_id;
1357       --
1358     elsif upper(rec_paye_element.name) = g_paye_input13
1359     then
1360       p_inp_value_id_table(13) := rec_paye_element.input_value_id;
1361       --
1362     elsif upper(rec_paye_element.name) = g_paye_input14
1363     then
1364       p_inp_value_id_table(14) := rec_paye_element.input_value_id;
1365       --
1366     elsif upper(rec_paye_element.name) = g_paye_input15
1367     then
1368       p_inp_value_id_table(15) := rec_paye_element.input_value_id;      --
1369 
1370     else
1371       hr_utility.trace('p_element_type_id: '||to_char(p_element_type_id));
1372       hr_utility.trace('Input name: '||rec_paye_element.name);
1373       hr_utility.trace('p_effective_date: '||to_char(p_effective_date,'MM/DD/YYYY'));
1374       hr_utility.set_message(801,'HR_NZ_INPUT_VALUE_NOT_FOUND');
1375       hr_utility.raise_error;
1376     end if;
1377   end loop;
1378   --
1379   hr_utility.set_location(g_package||l_procedure, 10);
1380   --
1381 end get_paye_input_ids;
1382 --
1383 ---------------------------------------------------------------------------------------------
1384 --              PRIVATE FUNCTION valid_business_group
1385 ---------------------------------------------------------------------------------------------
1386 --
1387 function valid_business_group
1388 (p_business_group_id    number
1389 ) return boolean is
1390   --
1391   l_procedure           constant varchar2(60)   := 'valid_business_group';
1392   l_legislation_code    varchar2(30);
1393   --
1394   cursor csr_per_business_groups
1395   is
1396   select legislation_code
1397   from   per_business_groups
1398   where  business_group_id      = p_business_group_id;
1399   --
1400 begin
1401   hr_utility.set_location(g_package||l_procedure, 1);
1402   open csr_per_business_groups;
1403   fetch csr_per_business_groups
1404   into l_legislation_code;
1405   if csr_per_business_groups%notfound
1406   then
1407     close csr_per_business_groups;
1408     hr_utility.set_location(g_package||l_procedure, 2);
1409     hr_utility.trace('p_business_group_id: '||to_char(p_business_group_id));
1410     return false;
1411   end if;
1412   close csr_per_business_groups;
1413   --
1414   hr_utility.set_location(g_package||l_procedure, 10);
1415   if l_legislation_code = g_legislation_code
1416   then
1417     return true;
1418   else
1419     return false;
1420   end if;
1421   --
1422 end valid_business_group;
1423 --
1424 ---------------------------------------------------------------------------------------------
1425 --      PUBLIC PROCEDURE create_paye_tax_info
1426 ---------------------------------------------------------------------------------------------
1427 --
1428 procedure create_paye_tax_info
1429 (p_validate                         in      boolean     default false
1430 ,p_effective_date                   in      date
1431 ,p_business_group_id                in      number
1432 ,p_original_entry_id                in      number      default null
1433 ,p_assignment_id                    in      number
1434 ,p_entry_type                       in      varchar2
1435 ,p_cost_allocation_keyflex_id       in      number      default null
1436 ,p_updating_action_id               in      number      default null
1437 ,p_comment_id                       in      number      default null
1438 ,p_reason                           in      varchar2    default null
1439 ,p_target_entry_id                  in      number      default null
1440 ,p_subpriority                      in      number      default null
1441 ,p_date_earned                      in      date        default null
1442 ,p_attribute_category               in      varchar2    default null
1443 ,p_attribute1                       in      varchar2    default null
1444 ,p_attribute2                       in      varchar2    default null
1445 ,p_attribute3                       in      varchar2    default null
1446 ,p_attribute4                       in      varchar2    default null
1447 ,p_attribute5                       in      varchar2    default null
1448 ,p_attribute6                       in      varchar2    default null
1449 ,p_attribute7                       in      varchar2    default null
1450 ,p_attribute8                       in      varchar2    default null
1451 ,p_attribute9                       in      varchar2    default null
1452 ,p_attribute10                      in      varchar2    default null
1453 ,p_attribute11                      in      varchar2    default null
1454 ,p_attribute12                      in      varchar2    default null
1455 ,p_attribute13                      in      varchar2    default null
1456 ,p_attribute14                      in      varchar2    default null
1457 ,p_attribute15                      in      varchar2    default null
1458 ,p_attribute16                      in      varchar2    default null
1459 ,p_attribute17                      in      varchar2    default null
1460 ,p_attribute18                      in      varchar2    default null
1461 ,p_attribute19                      in      varchar2    default null
1462 ,p_attribute20                      in      varchar2    default null
1463 ,p_australian_resident_flag         in      varchar2
1464 ,p_tax_free_threshold_flag          in      varchar2
1465 ,p_rebate_amount                    in      number      default null
1466 ,p_fta_claim_flag                   in      varchar2
1467 ,p_savings_rebate_flag              in      varchar2
1468 ,p_hecs_sfss_flag                   in      varchar2
1469 ,p_declaration_signed_date          in      varchar2
1470 ,p_medicare_levy_variation_code     in      varchar2
1471 ,p_spouse_mls_flag                  in      varchar2
1472 ,p_dependent_children               in      varchar2    default null
1473 ,p_tax_variation_type               in      varchar2
1474 ,p_tax_variation_amount             in      number      default null
1475 ,p_tax_file_number                  in      varchar2
1476 ,p_exempt_flood_levy_flag           in      varchar2    default 'N'
1477 ,p_effective_start_date                out nocopy date
1478 ,p_effective_end_date                  out nocopy date
1479 ,p_element_entry_id                    out nocopy number
1480 ,p_object_version_number               out nocopy number
1481 ,p_create_warning                      out nocopy boolean
1482 ) is
1483   --
1484   type varchar2_table is table of varchar2(60) index by binary_integer;
1485   --
1486   l_procedure                   varchar2(33); -- Bug No: 3648796
1487   l_inp_value_id_table          paye_number_table;
1488   l_effective_start_date        date;
1489   l_effective_end_date          date;
1490   l_element_entry_id            number;
1491   l_object_version_number       number;
1492   l_create_warning              boolean;
1493   l_element_type_id             number;
1494   l_element_link_id             number;
1495   --
1496   -- tax scale temp variable
1497   l_update_warning    boolean;
1498   --
1499 begin
1500   l_procedure  :=  'create_paye_tax_info'; -- Bug No: 3648796
1501 
1502   hr_utility.set_location(g_package||l_procedure, 1);
1503   --
1504   -- Ensure business group supplied is Australian
1505   --
1506   if not valid_business_group(p_business_group_id)
1507   then
1508     hr_utility.set_location(g_package||l_procedure, 2);
1509     hr_utility.set_message(801,'HR_7208_API_BUS_GRP_INVALID');
1510     hr_utility.raise_error;
1511   end if;
1512   --
1513   -- Get Element type id and input value ids
1514   --
1515   get_paye_input_ids(p_effective_date, l_element_type_id, l_inp_value_id_table);
1516   --
1517   -- Get the element link id for the Superannuation Contribution element
1518   --
1519   l_element_link_id     := hr_entry_api.get_link
1520                            (p_assignment_id     => p_assignment_id
1521                            ,p_element_type_id   => l_element_type_id
1522                            ,p_session_date      => p_effective_date
1523                            );
1524   if (l_element_link_id is null or l_element_link_id = 0)
1525   then
1526     hr_utility.set_message(801,'HR_AU_NZ_ELE_LNK_NOT_FND');
1527     hr_utility.raise_error;
1528   end if;
1529   --
1530   validate_tfn(p_tax_file_number);
1531   --
1532   py_element_entry_api.create_element_entry
1533   (p_validate                      => p_validate
1534   ,p_effective_date                => p_effective_date
1535   ,p_business_group_id             => p_business_group_id
1536   ,p_original_entry_id             => p_original_entry_id
1537   ,p_assignment_id                 => p_assignment_id
1538   ,p_element_link_id               => l_element_link_id
1539   ,p_entry_type                    => p_entry_type
1540   ,p_cost_allocation_keyflex_id    => p_cost_allocation_keyflex_id
1541   ,p_updating_action_id            => p_updating_action_id
1542   ,p_comment_id                    => p_comment_id
1543   ,p_reason                        => p_reason
1544   ,p_target_entry_id               => p_target_entry_id
1545   ,p_subpriority                   => p_subpriority
1546   ,p_date_earned                   => p_date_earned
1547   ,p_attribute_category            => p_attribute_category
1548   ,p_attribute1                    => p_attribute1
1549   ,p_attribute2                    => p_attribute2
1550   ,p_attribute3                    => p_attribute3
1551   ,p_attribute4                    => p_attribute4
1552   ,p_attribute5                    => p_attribute5
1553   ,p_attribute6                    => p_attribute6
1554   ,p_attribute7                    => p_attribute7
1555   ,p_attribute8                    => p_attribute8
1556   ,p_attribute9                    => p_attribute9
1557   ,p_attribute10                   => p_attribute10
1558   ,p_attribute11                   => p_attribute11
1559   ,p_attribute12                   => p_attribute12
1560   ,p_attribute13                   => p_attribute13
1561   ,p_attribute14                   => p_attribute14
1562   ,p_attribute15                   => p_attribute15
1563   ,p_attribute16                   => p_attribute16
1564   ,p_attribute17                   => p_attribute17
1565   ,p_attribute18                   => p_attribute18
1566   ,p_attribute19                   => p_attribute19
1567   ,p_attribute20                   => p_attribute20
1568   ,p_override_user_ent_chk         => 'Y'
1569   ,p_effective_start_date          => p_effective_start_date
1570   ,p_effective_end_date            => p_effective_end_date
1571   ,p_element_entry_id              => l_element_entry_id
1572   ,p_object_version_number         => l_object_version_number
1573   ,p_create_warning                => l_create_warning
1574   );
1575   --
1576   /* 12570937 - Added flood levy parameter to below procedure call */
1577   maintain_PAYE_tax_info
1578   (p_validate                         => p_validate
1579   ,p_assignment_id                    => p_assignment_id
1580   ,p_effective_start_date             => l_effective_start_date
1581   ,p_effective_end_date               => l_effective_end_date
1582   ,p_session_date                     => p_effective_date
1583   ,p_mode                             => 'CORRECTION'
1584   ,p_business_group_id                => p_business_group_id
1585   ,p_attribute_category               => p_attribute_category
1586   ,p_attribute1                       => p_attribute1
1587   ,p_attribute2                       => p_attribute2
1588   ,p_attribute3                       => p_attribute3
1589   ,p_attribute4                       => p_attribute4
1590   ,p_attribute5                       => p_attribute5
1591   ,p_attribute6                       => p_attribute6
1592   ,p_attribute7                       => p_attribute7
1593   ,p_attribute8                       => p_attribute8
1594   ,p_attribute9                       => p_attribute9
1595   ,p_attribute10                      => p_attribute10
1596   ,p_attribute11                      => p_attribute11
1597   ,p_attribute12                      => p_attribute12
1598   ,p_attribute13                      => p_attribute13
1599   ,p_attribute14                      => p_attribute14
1600   ,p_attribute15                      => p_attribute15
1601   ,p_attribute16                      => p_attribute16
1602   ,p_attribute17                      => p_attribute17
1603   ,p_attribute18                      => p_attribute18
1604   ,p_attribute19                      => p_attribute19
1605   ,p_attribute20                      => p_attribute20
1606   ,p_entry_information_category       => 'AU_TAX DEDUCTIONS'
1607   ,p_entry_information1               => fnd_date.date_to_canonical(sysdate)
1608   ,p_australian_resident_flag         => p_australian_resident_flag
1609   ,p_tax_free_threshold_flag          => p_tax_free_threshold_flag
1610   ,p_rebate_amount                    => p_rebate_amount
1611   ,p_fta_claim_flag                   => p_fta_claim_flag
1612   ,p_savings_rebate_flag              => p_savings_rebate_flag
1613   ,p_help_sfss_flag                   => p_hecs_sfss_flag    /* Bug#5258625 */
1614   ,p_declaration_signed_date          => p_declaration_signed_date
1615   ,p_medicare_levy_variation_code     => p_medicare_levy_variation_code
1616   ,p_spouse_mls_flag                  => p_spouse_mls_flag
1617   ,p_dependent_children               => p_dependent_children
1618   ,p_tax_variation_type               => p_tax_variation_type
1619   ,p_tax_variation_amount             => p_tax_variation_amount
1620   ,p_tax_file_number                  => p_tax_file_number
1621   ,p_exempt_flood_levy_flag           => p_exempt_flood_levy_flag
1622   ,p_update_warning                   => l_update_warning
1623   );
1624   --
1625   hr_utility.set_location(g_package||l_procedure, 30);
1626 
1627 end create_paye_tax_info;
1628 
1629 ---------------------------------------------------------------------------------------------
1630 --      PUBLIC PROCEDURE update_adi_tax_crp
1631 ---------------------------------------------------------------------------------------------
1632 
1633 procedure update_adi_tax_crp
1634   (p_validate                     in         boolean     default false
1635   ,p_assignment_id                in         number
1636   ,p_hire_date                    in         date
1637   ,p_business_group_id            in         number
1638   ,p_payroll_id                   in         number
1639   ,p_legal_employer               in varchar2
1640   ,p_tax_file_number              in varchar2
1641   ,p_tax_free_threshold           in varchar2
1642   ,p_australian_resident          in varchar2
1643   ,p_hecs                         in varchar2
1644   ,p_sfss                         in varchar2
1645   ,p_leave_loading                in varchar2
1646   ,p_basis_of_payment             in varchar2
1647   ,p_declaration_signed_date      in varchar2
1648   ,p_medicare_levy_surcharge      in varchar2
1649   ,p_medicare_levy_exemption      in varchar2
1650   ,p_medicare_levy_dep_children   in varchar2    default null
1651   ,p_medicare_levy_spouse         in varchar2
1652   ,p_tax_variation_type           in varchar2
1653   ,p_tax_variation_amount         in number      default null
1654   ,p_tax_variation_bonus          in varchar2
1655   ,p_rebate_amount                in number      default null
1656   ,p_savings_rebate               in varchar2
1657   ,p_ftb_claim                    in varchar2
1658   ,p_senior_australian            in varchar2
1659   ,p_exempt_flood_levy            in varchar2    default 'N'
1660   ,p_mls_rate                     in varchar2    default 'A'
1661   ,p_effective_date               in date        default null
1662   ) IS
1663     cursor csr_tax_element is
1664     select pet.element_type_id
1665     from   pay_element_types_f   pet
1666     where  pet.element_name      = g_paye_element
1667     and    sysdate between pet.effective_start_date and pet.effective_end_date
1668     and    legislation_code      = g_legislation_code;
1669     --
1670     cursor csr_asg_version is
1671     select object_version_number
1672     from per_assignments_f
1673     where assignment_id     = p_assignment_id
1674     and   business_group_id = p_business_group_id;
1675     --
1676     cursor csr_element_entry(p_element_link_id number) is
1677     select element_entry_id
1678     from   pay_element_entries_f
1679     where  assignment_id     = p_assignment_id
1680     and    element_link_id   = p_element_link_id;
1681     --
1682     -- Cursor to check the element links.
1683     -- Checks if the element is linked to a payroll or linked to all payrolls
1684     --
1685     cursor csr_element_link
1686     (p_element_type_id pay_element_types_f.element_type_id%type
1687     ,p_payroll_id      pay_element_links_f.payroll_id%type
1688     ,p_business_group_id pay_element_links_f.business_group_id%type
1689     ,p_hire_date       date
1690     )  is
1691     select element_link_id
1692     ,      object_version_number
1693     from   pay_element_links_f
1694     where  element_type_id    = p_element_type_id
1695     and    business_group_id  = p_business_group_id
1696     and    (payroll_id         = p_payroll_id or link_to_all_payrolls_flag is not null)
1697     and    sysdate between effective_start_date and effective_end_date;
1698     --
1699     l_procedure                     varchar2(100) := g_package||'update_adi_tax_crp';
1700     --
1701     l_effective_start_date          per_all_assignments_f.effective_start_date%type;
1702     l_effective_end_date            per_all_assignments_f.effective_end_date%type;
1703     l_element_entry_id              pay_element_entries_f.element_entry_id%type;
1704     l_element_type_id               pay_element_types_f.element_type_id%type;
1705     l_element_link_id               pay_element_links_f.element_link_id%type;
1706     l_object_version_number         per_all_assignments_f.object_version_number%type;
1707     l_create_warning                boolean;
1708     l_update_warning                boolean;
1709     l_cagr_grade_def_id             number;
1710     l_cagr_concatenated_segments    varchar2(2000);
1711     l_comment_id                    number;
1712     l_soft_coding_keyflex_id        per_all_assignments_f.soft_coding_keyflex_id%type;
1713     l_concatenated_segments         hr_soft_coding_keyflex.concatenated_segments%TYPE;
1714     l_no_managers_warning           boolean;
1715     l_other_manager_warning         boolean;
1716     l_special_ceiling_step_id       per_all_assignments_f.special_ceiling_step_id%type;
1717     l_people_group_id               per_all_assignments_f.people_group_id%type;
1718     l_group_name                    pay_people_groups.group_name%type;
1719     l_org_now_no_manager_warning    boolean;
1720     l_spp_delete_warning            boolean;
1721     l_entries_changed_warning       varchar2(1);
1722     l_tax_district_changed_warning  boolean;
1723     l_australian_resident_flag      varchar2(20);
1724     l_hecs_sfss_flag                varchar2(10);
1725     l_fta_claim_flag                varchar2(10);
1726     l_spouse_mls_flag               varchar2(20);
1727     l_tax_variation_type            varchar2(20);
1728     l_exempt_flood_levy_flag        varchar2(10);
1729     l_date date;
1730     --
1731   begin
1732   g_debug := hr_utility.debug_enabled;
1733     if g_debug then
1734       hr_utility.set_location(l_procedure,10);
1735       hr_utility.trace('p_assignment_id     => '||p_assignment_id);
1736       hr_utility.trace('p_business_group_id => '||p_business_group_id);
1737       hr_utility.trace('p_hire_date    => '||p_hire_date);
1738       hr_utility.trace('p_payroll_id               => '||to_char(p_payroll_id));
1739     END if;
1740     --
1741     -- Need the object_version_number to update the assignment
1742     --
1743     open csr_asg_version;
1744     fetch csr_asg_version into l_object_version_number;
1745     close csr_asg_version;
1746     --
1747     -- Update assignment with leave loading flag and Legal Employer.
1748     -- We are able to pass on the variables as is here since they are not overloaded
1749     -- for this API.
1750     -- The main purpose of this API is to enter field related to Australian Tax
1751     -- therefore additional fields (e.g. descriptive flex) are not provided.
1752     --
1753     hr_au_assignment_api.update_au_emp_asg
1754     (p_validate                     => p_validate
1755     ,p_effective_date               => p_hire_date
1756     ,p_datetrack_update_mode        => 'CORRECTION'        -- hard code this mode since we only use this API for RI
1757     ,p_assignment_id                => p_assignment_id
1758     ,p_object_version_number        => l_object_version_number  -- out parameter
1759     ,p_legal_employer_id            => p_legal_employer
1760     ,p_lev_lod_flg                  => p_leave_loading
1761     ,p_cagr_grade_def_id            => l_cagr_grade_def_id      -- out parameter
1762     ,p_cagr_concatenated_segments   => l_cagr_concatenated_segments               -- out parameter
1763     ,p_comment_id                   => l_comment_id                               -- out parameter
1764     ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id                   -- out parameter
1765     ,p_effective_start_date         => l_effective_start_date                     -- out parameter
1766     ,p_effective_end_date           => l_effective_end_date                       -- out parameter
1767     ,p_concatenated_segments        => l_concatenated_segments                    -- out parameter
1768     ,p_no_managers_warning          => l_no_managers_warning                      -- out parameter
1769     ,p_other_manager_warning        => l_other_manager_warning                   -- out parameter
1770     );
1771     IF g_debug THEN
1772       hr_utility.set_location(l_procedure,20);
1773       hr_utility.trace('l_object_version_number => '||l_object_version_number);
1774     END if;
1775 
1776     --
1777     -- The intended use of the following API call is to allow the update of
1778     -- payroll only ,for the assignment on implementation (creation) of employee
1779     -- tax information.  This means that the majority
1780     -- of the out parameters will not need to be returned.
1781     --
1782     hr_assignment_api.update_emp_asg_criteria
1783     (p_effective_date               => p_hire_date
1784     ,p_datetrack_update_mode        => 'CORRECTION'
1785     ,p_assignment_id                => p_assignment_id
1786     ,p_validate                     => p_validate
1787     ,p_payroll_id                   => p_payroll_id
1788     ,p_object_version_number        => l_object_version_number  -- from when we updated the asg earlier
1789     ,p_special_ceiling_step_id      => l_special_ceiling_step_id
1790     ,p_people_group_id              => l_people_group_id
1791     ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
1792     ,p_group_name                   => l_group_name
1793     ,p_effective_start_date         => l_effective_start_date
1794     ,p_effective_end_date           => l_effective_end_date
1795     ,p_org_now_no_manager_warning   => l_org_now_no_manager_warning
1796     ,p_other_manager_warning        => l_other_manager_warning
1797     ,p_spp_delete_warning           => l_spp_delete_warning
1798     ,p_entries_changed_warning      => l_entries_changed_warning
1799     ,p_tax_district_changed_warning => l_tax_district_changed_warning
1800     ,p_concatenated_segments        => l_concatenated_segments
1801     );
1802 
1803     IF g_debug THEN
1804       hr_utility.set_location(l_procedure,30);
1805       hr_utility.trace('p_australian_resident_flag => '||p_australian_resident);
1806       hr_utility.trace('p_senior_australian        => '||p_senior_australian);
1807       hr_utility.trace('p_payroll_id               => '||to_char(p_payroll_id));
1808 
1809     END if;
1810 
1811     --
1812     -- Create the "Tax Information"
1813     -- We call the existing API since it already encapsulates the tax business logic and therefore
1814     -- it will be contained in a single location.
1815     -- Parameters (ie. Input Values) are overloaded for "Tax Information" so we need
1816     -- to "translate" the appropriate values before calling the main API.
1817     --
1818     -- ---------------------------------------
1819     -- AUSTRALIAN RESIDENT and SENIOR
1820     -- ---------------------------------------
1821     --p_austrlian_resident_flag values Y or N
1822     --p_seniour                 values C,I,N,S
1823     --p_australian_resident_flag values NN,YC,YI,YN,YS,N,Y
1824     --
1825     -- Senior flag cannot be set if not an Australian resident
1826     --
1827     if p_australian_resident = 'N' then
1828       l_australian_resident_flag := p_australian_resident;
1829     else
1830       l_australian_resident_flag := p_australian_resident || p_senior_australian;
1831     end if;
1832     if g_debug then
1833       hr_utility.set_location(l_procedure,31);
1834     end if;
1835 
1836     if p_exempt_flood_levy = 'N' THEN
1837        l_exempt_flood_levy_flag := 'N';
1838     else
1839        l_exempt_flood_levy_flag := 'Y';
1840     end if;
1841 
1842     -- ---------------------------------------
1843     -- PAYMENT BASIS and FTB CLAIM
1844     -- ---------------------------------------
1845     --p_ftb_claim_flag values Y or N
1846     --p_basis_of_payment values C,F,P
1847     --l_fta_claim_flag values N,NC,NF,NP,Y,YC,YF,YP
1848     --
1849     l_fta_claim_flag :=  p_ftb_claim || p_basis_of_payment;
1850     if g_debug then
1851       hr_utility.set_location(l_procedure,32);
1852     end if;
1853 
1854     -- ---------------------------------------
1855     -- HECS and SFSS
1856     -- ---------------------------------------
1857     --p_hecs_flag values Y,N
1858     --p_sfss_flag values Y,N
1859     --l_hecs_sfss_flag values NY,YY,N,Y
1860     --
1861     if p_sfss = 'N' then
1862       l_hecs_sfss_flag := p_hecs;
1863     else
1864       l_hecs_sfss_flag := p_hecs || p_sfss;
1865     end if;
1866     --
1867     if g_debug then
1868       hr_utility.set_location(l_procedure,33);
1869     end if;
1870 
1871     -- ---------------------------------------
1872     -- SPOUSE and MLS
1873     -- ---------------------------------------
1874     --p_spouse_flag values Y,N
1875     --p_medicare_levy_surcharge_flag values Y,N
1876     --p_spouse_mls_flag values Y,N,NY,YY
1877     --
1878     if p_medicare_levy_surcharge = 'N' then
1879       l_spouse_mls_flag := p_medicare_levy_spouse;
1880     else
1881       l_spouse_mls_flag := p_medicare_levy_spouse || p_medicare_levy_surcharge;
1882       IF p_hire_date >= to_date('01-07-2012','dd-mm-yyyy') THEN
1883          l_spouse_mls_flag := l_spouse_mls_flag || p_mls_rate;
1884       END IF;
1885     end if;
1886 
1887     -- ---------------------------------------
1888     -- TAX VARIATION and BONUS
1889     -- ---------------------------------------
1890     -- p_tax_variation_type values E,N,F,P
1891     -- p_tax_variation_bonus values Y,N
1892     -- l_tax_variation_type values E,EN,EY,F,FN,FY,N,P,PN,PY
1893     --
1894     if p_tax_variation_type = 'N' then
1895       l_tax_variation_type := p_tax_variation_type;
1896     else
1897       l_tax_variation_type := p_tax_variation_type || p_tax_variation_bonus;
1898     end if;
1899 
1900     if g_debug then
1901       hr_utility.set_location(l_procedure,40);
1902       hr_utility.trace('l_australian_resident_flag => '||l_australian_resident_flag);
1903       hr_utility.trace('l_fta_claim_flag           => '||l_fta_claim_flag);
1904       hr_utility.trace('l_hecs_sfss_flag           => '||l_hecs_sfss_flag);
1905       hr_utility.trace('l_spouse_mls_flag          => '||l_spouse_mls_flag);
1906       hr_utility.trace('l_tax_variation_type       => '||l_tax_variation_type);
1907     end if;
1908 
1909     -- If the Tax Information already exists for this assignment then
1910     -- call maintain_paye_tax_info... otherwise call call create_paye_tax_info.
1911     -- (After updating the payroll against the assignment the Tax element entry
1912     -- gets automatically created since it is a standard element.  However we
1913     -- still allow for case when it does not exist.
1914     --
1915     -- First need to get the element_type_id to then find the element_link_id
1916     open csr_tax_element;
1917     fetch csr_tax_element
1918     into l_element_type_id;
1919     if (csr_tax_element%notfound)
1920     then
1921       close csr_tax_element;
1922       IF g_debug THEN
1923         hr_utility.set_location(l_procedure, 50);
1924         hr_utility.trace('p_effective_date: '||to_char(p_hire_date,'MM/DD/YYYY'));
1925       END if;
1926       hr_utility.set_message(801,'HR_AU_NZ_ELE_TYP_NOT_FND');
1927       hr_utility.raise_error;
1928     end if;
1929     close csr_tax_element;
1930 
1931     if g_debug then
1932       hr_utility.set_location(l_procedure,60);
1933       hr_utility.trace('p_assignment_id   => '||p_assignment_id);
1934       hr_utility.trace('l_element_type_id => '||l_element_type_id);
1935     end if;
1936     --
1937     -- Got the element_type_id so can now get the element_link_id
1938     l_element_link_id     := hr_entry_api.get_link
1939                              (p_assignment_id     => p_assignment_id
1940                              ,p_element_type_id   => l_element_type_id
1941                              ,p_session_date      => sysdate
1942                              );
1943     if (l_element_link_id is null or l_element_link_id = 0)
1944     then
1945       if g_debug then
1946         hr_utility.set_location(l_procedure, 61);
1947       end if;
1948       --
1949       -- It is possible that the current assignment is on a payroll for which an element link does
1950       -- not exist, therefore we need to check the link before we create.
1951       --
1952       open csr_element_link(l_element_type_id, p_payroll_id, p_business_group_id, p_hire_date);
1953       fetch csr_element_link
1954       into l_element_link_id
1955       , l_object_version_number;
1956       if csr_element_link%notfound then
1957         --
1958         -- Create the element link
1959 
1960         if p_hire_date >= to_date('01-07-1997','dd-mm-yyyy') then
1961            l_date := p_hire_date;
1962         else
1963            l_date := to_date('01-07-1997','dd-mm-yyyy');
1964         end if;
1965 
1966         pay_element_link_api.CREATE_ELEMENT_LINK
1967         (P_EFFECTIVE_DATE               => l_date
1968         ,P_ELEMENT_TYPE_ID              => l_element_type_id
1969         ,P_BUSINESS_GROUP_ID            => p_business_group_id
1970         ,P_COSTABLE_TYPE                => 'N'
1971         ,P_PAYROLL_ID                   => p_payroll_id
1972         ,P_LINK_TO_ALL_PAYROLLS_FLAG    => 'N'
1973         ,P_STANDARD_LINK_FLAG           => 'Y'
1974         ,P_COST_CONCAT_SEGMENTS         => null
1975         ,P_BALANCE_CONCAT_SEGMENTS      => null
1976         ,P_ELEMENT_LINK_ID              => l_element_link_id
1977         ,P_COMMENT_ID                   => l_comment_id
1978         ,P_OBJECT_VERSION_NUMBER        => l_object_version_number
1979         ,P_EFFECTIVE_START_DATE         => l_effective_start_date
1980         ,P_EFFECTIVE_END_DATE           => l_effective_end_date
1981         );
1982 
1983       end if;
1984       --hr_utility.set_message(801,'HR_AU_NZ_ELE_LNK_NOT_FND');
1985       --hr_utility.raise_error;
1986     end if;
1987     --
1988     if g_debug then
1989       hr_utility.set_location(l_procedure, 62);
1990       hr_utility.trace('l_element_link_id = '||to_char(l_element_link_id));
1991     end if;
1992     --
1993     -- Verify whether an element entry exists.
1994     -- (This is where to use the element_link_id)
1995     --
1996     open csr_element_entry(l_element_link_id);
1997     fetch csr_element_entry into l_element_entry_id;
1998     if csr_element_entry%notfound then
1999       if g_debug then
2000         hr_utility.set_location(l_procedure,70);
2001       end if;
2002       --
2003       -- The element entry does not exist so call the CREATE API
2004       --
2005       close csr_element_entry;
2006       /* 12570937 - Added flood levy parameter to below procedure call */
2007         if l_effective_start_date >= to_date('01-07-1997','dd-mm-yyyy') then
2008            l_date := l_effective_start_date;
2009         else
2010            l_date := to_date('01-07-1997','dd-mm-yyyy');
2011         end if;
2012 
2013       hr_au_tax_api.create_paye_tax_info
2014       (p_validate                         => false
2015       ,p_effective_date                   => l_date
2016       ,p_business_group_id                => p_business_group_id
2017       ,p_assignment_id                    => p_assignment_id
2018       ,p_entry_type                       => 'E'                                 --p_entry_type
2019       ,p_australian_resident_flag         => l_australian_resident_flag           --AU_AUST_RES_SENR_AUS
2020       ,p_tax_free_threshold_flag          => p_tax_free_threshold
2021       ,p_rebate_amount                    => p_rebate_amount
2022       ,p_fta_claim_flag                   => l_fta_claim_flag
2023       ,p_savings_rebate_flag              => p_savings_rebate
2024       ,p_hecs_sfss_flag                   => l_hecs_sfss_flag
2025       ,p_declaration_signed_date          => p_declaration_signed_date
2026       ,p_medicare_levy_variation_code     => p_medicare_levy_exemption
2027       ,p_spouse_mls_flag                  => l_spouse_mls_flag
2028       ,p_dependent_children               => p_medicare_levy_dep_children
2029       ,p_tax_variation_type               => l_tax_variation_type
2030       ,p_tax_variation_amount             => p_tax_variation_amount
2031       ,p_tax_file_number                  => p_tax_file_number
2032       ,p_exempt_flood_levy_flag           => l_exempt_flood_levy_flag
2033       ,p_effective_start_date             => l_effective_start_date
2034       ,p_effective_end_date               => l_effective_end_date
2035       ,p_element_entry_id                 => l_element_entry_id
2036       ,p_object_version_number            => l_object_version_number
2037       ,p_create_warning                   => l_create_warning
2038       );
2039     else
2040       if g_debug then
2041         hr_utility.set_location(l_procedure,80);
2042         hr_utility.trace('dep children = '||p_medicare_levy_dep_children);
2043 
2044       end if;
2045       --
2046       -- The element entry exists so call the UPDATE API
2047       --
2048       close csr_element_entry;
2049       /* 12570937 - Added flood levy parameter to below procedure call */
2050         if l_effective_start_date >= to_date('01-07-1997','dd-mm-yyyy') then
2051            l_date := l_effective_start_date;
2052         else
2053            l_date := to_date('01-07-1997','dd-mm-yyyy');
2054         end if;
2055 
2056       maintain_PAYE_tax_info
2057       (p_validate                         => false
2058       ,p_assignment_id                    => p_assignment_id
2059       ,p_effective_start_date             => l_effective_start_date
2060       ,p_effective_end_date               => l_effective_end_date
2061       ,p_session_date                     => l_date
2062       ,p_mode                             => 'CORRECTION'
2063       ,p_business_group_id                => p_business_group_id
2064       ,p_entry_information_category       => 'AU_TAX DEDUCTIONS'
2065       ,p_entry_information1               => fnd_date.date_to_canonical(sysdate)
2066       ,p_australian_resident_flag         => l_australian_resident_flag
2067       ,p_tax_free_threshold_flag          => p_tax_free_threshold
2068       ,p_rebate_amount                    => p_rebate_amount
2069       ,p_fta_claim_flag                   => l_fta_claim_flag
2070       ,p_savings_rebate_flag              => p_savings_rebate
2071       ,p_help_sfss_flag                   => l_hecs_sfss_flag  /* Bug#5258625 */
2072       ,p_declaration_signed_date          => p_declaration_signed_date
2073       ,p_medicare_levy_variation_code     => p_medicare_levy_exemption
2074       ,p_spouse_mls_flag                  => l_spouse_mls_flag
2075       ,p_dependent_children               => p_medicare_levy_dep_children
2076       ,p_tax_variation_type               => l_tax_variation_type
2077       ,p_tax_variation_amount             => p_tax_variation_amount
2078       ,p_tax_file_number                  => p_tax_file_number
2079       ,p_exempt_flood_levy_flag           => l_exempt_flood_levy_flag
2080       ,p_update_warning                   => l_update_warning
2081       );
2082     end if;
2083     --
2084     if g_debug then
2085       hr_utility.set_location(l_procedure,90);
2086     end if;
2087   end update_adi_tax_crp;
2088 
2089 END hr_au_tax_api ;