100: --
101:
102: l_proc VARCHAR2(100) := 'pay_gb_payroll_rules.validate_update';
103: BEGIN
104: hr_utility.trace('Entering '||l_proc);
105: hr_utility.trace('p_effective_date='||fnd_date.date_to_displaydate(p_effective_date));
106: hr_utility.trace('p_datetrack_mode='||p_datetrack_mode);
107: hr_utility.trace('p_payroll_id='||p_payroll_id);
108: hr_utility.trace('p_payroll_name='||p_payroll_name);
101:
102: l_proc VARCHAR2(100) := 'pay_gb_payroll_rules.validate_update';
103: BEGIN
104: hr_utility.trace('Entering '||l_proc);
105: hr_utility.trace('p_effective_date='||fnd_date.date_to_displaydate(p_effective_date));
106: hr_utility.trace('p_datetrack_mode='||p_datetrack_mode);
107: hr_utility.trace('p_payroll_id='||p_payroll_id);
108: hr_utility.trace('p_payroll_name='||p_payroll_name);
109: hr_utility.trace('p_soft_coding_keyflex_id_in='||p_soft_coding_keyflex_id_in);
102: l_proc VARCHAR2(100) := 'pay_gb_payroll_rules.validate_update';
103: BEGIN
104: hr_utility.trace('Entering '||l_proc);
105: hr_utility.trace('p_effective_date='||fnd_date.date_to_displaydate(p_effective_date));
106: hr_utility.trace('p_datetrack_mode='||p_datetrack_mode);
107: hr_utility.trace('p_payroll_id='||p_payroll_id);
108: hr_utility.trace('p_payroll_name='||p_payroll_name);
109: hr_utility.trace('p_soft_coding_keyflex_id_in='||p_soft_coding_keyflex_id_in);
110: hr_utility.trace('Fetching PAYE Ref for new scl id='|| p_soft_coding_keyflex_id_in);
103: BEGIN
104: hr_utility.trace('Entering '||l_proc);
105: hr_utility.trace('p_effective_date='||fnd_date.date_to_displaydate(p_effective_date));
106: hr_utility.trace('p_datetrack_mode='||p_datetrack_mode);
107: hr_utility.trace('p_payroll_id='||p_payroll_id);
108: hr_utility.trace('p_payroll_name='||p_payroll_name);
109: hr_utility.trace('p_soft_coding_keyflex_id_in='||p_soft_coding_keyflex_id_in);
110: hr_utility.trace('Fetching PAYE Ref for new scl id='|| p_soft_coding_keyflex_id_in);
111: OPEN get_paye_ref(p_soft_coding_keyflex_id_in);
104: hr_utility.trace('Entering '||l_proc);
105: hr_utility.trace('p_effective_date='||fnd_date.date_to_displaydate(p_effective_date));
106: hr_utility.trace('p_datetrack_mode='||p_datetrack_mode);
107: hr_utility.trace('p_payroll_id='||p_payroll_id);
108: hr_utility.trace('p_payroll_name='||p_payroll_name);
109: hr_utility.trace('p_soft_coding_keyflex_id_in='||p_soft_coding_keyflex_id_in);
110: hr_utility.trace('Fetching PAYE Ref for new scl id='|| p_soft_coding_keyflex_id_in);
111: OPEN get_paye_ref(p_soft_coding_keyflex_id_in);
112: FETCH get_paye_ref INTO l_new_paye_ref;
105: hr_utility.trace('p_effective_date='||fnd_date.date_to_displaydate(p_effective_date));
106: hr_utility.trace('p_datetrack_mode='||p_datetrack_mode);
107: hr_utility.trace('p_payroll_id='||p_payroll_id);
108: hr_utility.trace('p_payroll_name='||p_payroll_name);
109: hr_utility.trace('p_soft_coding_keyflex_id_in='||p_soft_coding_keyflex_id_in);
110: hr_utility.trace('Fetching PAYE Ref for new scl id='|| p_soft_coding_keyflex_id_in);
111: OPEN get_paye_ref(p_soft_coding_keyflex_id_in);
112: FETCH get_paye_ref INTO l_new_paye_ref;
113: CLOSE get_paye_ref;
106: hr_utility.trace('p_datetrack_mode='||p_datetrack_mode);
107: hr_utility.trace('p_payroll_id='||p_payroll_id);
108: hr_utility.trace('p_payroll_name='||p_payroll_name);
109: hr_utility.trace('p_soft_coding_keyflex_id_in='||p_soft_coding_keyflex_id_in);
110: hr_utility.trace('Fetching PAYE Ref for new scl id='|| p_soft_coding_keyflex_id_in);
111: OPEN get_paye_ref(p_soft_coding_keyflex_id_in);
112: FETCH get_paye_ref INTO l_new_paye_ref;
113: CLOSE get_paye_ref;
114: --
111: OPEN get_paye_ref(p_soft_coding_keyflex_id_in);
112: FETCH get_paye_ref INTO l_new_paye_ref;
113: CLOSE get_paye_ref;
114: --
115: hr_utility.trace('New Paye Ref is '||l_new_paye_ref);
116: --
117: hr_utility.trace('Fetching current payroll details');
118: OPEN get_current_details;
119: FETCH get_current_details INTO l_cur_scl_id, l_cur_eff_start, l_cur_eff_end;
113: CLOSE get_paye_ref;
114: --
115: hr_utility.trace('New Paye Ref is '||l_new_paye_ref);
116: --
117: hr_utility.trace('Fetching current payroll details');
118: OPEN get_current_details;
119: FETCH get_current_details INTO l_cur_scl_id, l_cur_eff_start, l_cur_eff_end;
120: CLOSE get_current_details;
121: --
118: OPEN get_current_details;
119: FETCH get_current_details INTO l_cur_scl_id, l_cur_eff_start, l_cur_eff_end;
120: CLOSE get_current_details;
121: --
122: hr_utility.trace('Currrent l_cur_scl_id='||l_cur_scl_id);
123: hr_utility.trace('Currrent l_cur_eff_start='||fnd_date.date_to_displaydate(l_cur_eff_start));
124: hr_utility.trace('Currrent l_cur_eff_end='||fnd_date.date_to_displaydate(l_cur_eff_end));
125: --
126: hr_utility.trace('Fetching Current PAYE Ref.');
119: FETCH get_current_details INTO l_cur_scl_id, l_cur_eff_start, l_cur_eff_end;
120: CLOSE get_current_details;
121: --
122: hr_utility.trace('Currrent l_cur_scl_id='||l_cur_scl_id);
123: hr_utility.trace('Currrent l_cur_eff_start='||fnd_date.date_to_displaydate(l_cur_eff_start));
124: hr_utility.trace('Currrent l_cur_eff_end='||fnd_date.date_to_displaydate(l_cur_eff_end));
125: --
126: hr_utility.trace('Fetching Current PAYE Ref.');
127: OPEN get_paye_ref(l_cur_scl_id);
120: CLOSE get_current_details;
121: --
122: hr_utility.trace('Currrent l_cur_scl_id='||l_cur_scl_id);
123: hr_utility.trace('Currrent l_cur_eff_start='||fnd_date.date_to_displaydate(l_cur_eff_start));
124: hr_utility.trace('Currrent l_cur_eff_end='||fnd_date.date_to_displaydate(l_cur_eff_end));
125: --
126: hr_utility.trace('Fetching Current PAYE Ref.');
127: OPEN get_paye_ref(l_cur_scl_id);
128: FETCH get_paye_ref INTO l_cur_paye_ref;
122: hr_utility.trace('Currrent l_cur_scl_id='||l_cur_scl_id);
123: hr_utility.trace('Currrent l_cur_eff_start='||fnd_date.date_to_displaydate(l_cur_eff_start));
124: hr_utility.trace('Currrent l_cur_eff_end='||fnd_date.date_to_displaydate(l_cur_eff_end));
125: --
126: hr_utility.trace('Fetching Current PAYE Ref.');
127: OPEN get_paye_ref(l_cur_scl_id);
128: FETCH get_paye_ref INTO l_cur_paye_ref;
129: CLOSE get_paye_ref;
130: hr_utility.trace('Current PAYE Ref is '||l_cur_paye_ref);
126: hr_utility.trace('Fetching Current PAYE Ref.');
127: OPEN get_paye_ref(l_cur_scl_id);
128: FETCH get_paye_ref INTO l_cur_paye_ref;
129: CLOSE get_paye_ref;
130: hr_utility.trace('Current PAYE Ref is '||l_cur_paye_ref);
131: --
132: hr_utility.trace('Fetching fiest start date and last end date of the payroll');
133: OPEN get_min_max_dates;
134: FETCH get_min_max_dates INTO l_first_eff_start, l_last_eff_end;
128: FETCH get_paye_ref INTO l_cur_paye_ref;
129: CLOSE get_paye_ref;
130: hr_utility.trace('Current PAYE Ref is '||l_cur_paye_ref);
131: --
132: hr_utility.trace('Fetching fiest start date and last end date of the payroll');
133: OPEN get_min_max_dates;
134: FETCH get_min_max_dates INTO l_first_eff_start, l_last_eff_end;
135: CLOSE get_min_max_dates;
136: hr_utility.trace('l_first_eff_start='||fnd_date.date_to_displaydate(l_first_eff_start));
132: hr_utility.trace('Fetching fiest start date and last end date of the payroll');
133: OPEN get_min_max_dates;
134: FETCH get_min_max_dates INTO l_first_eff_start, l_last_eff_end;
135: CLOSE get_min_max_dates;
136: hr_utility.trace('l_first_eff_start='||fnd_date.date_to_displaydate(l_first_eff_start));
137: hr_utility.trace('l_last_eff_end='||fnd_date.date_to_displaydate(l_last_eff_end));
138: --
139: IF p_datetrack_mode = hr_api.g_correction THEN
140: hr_utility.trace('Datetrack Action is Correction.');
133: OPEN get_min_max_dates;
134: FETCH get_min_max_dates INTO l_first_eff_start, l_last_eff_end;
135: CLOSE get_min_max_dates;
136: hr_utility.trace('l_first_eff_start='||fnd_date.date_to_displaydate(l_first_eff_start));
137: hr_utility.trace('l_last_eff_end='||fnd_date.date_to_displaydate(l_last_eff_end));
138: --
139: IF p_datetrack_mode = hr_api.g_correction THEN
140: hr_utility.trace('Datetrack Action is Correction.');
141: --
136: hr_utility.trace('l_first_eff_start='||fnd_date.date_to_displaydate(l_first_eff_start));
137: hr_utility.trace('l_last_eff_end='||fnd_date.date_to_displaydate(l_last_eff_end));
138: --
139: IF p_datetrack_mode = hr_api.g_correction THEN
140: hr_utility.trace('Datetrack Action is Correction.');
141: --
142: IF l_new_paye_ref <> l_cur_paye_ref THEN
143: hr_utility.trace('PAYE Refs is changing, validating the change');
144: --
139: IF p_datetrack_mode = hr_api.g_correction THEN
140: hr_utility.trace('Datetrack Action is Correction.');
141: --
142: IF l_new_paye_ref <> l_cur_paye_ref THEN
143: hr_utility.trace('PAYE Refs is changing, validating the change');
144: --
145: hr_utility.trace('Fetching Previous PAYE Ref');
146: OPEN get_prev_details;
147: FETCH get_prev_details INTO l_prev_scl_id;
141: --
142: IF l_new_paye_ref <> l_cur_paye_ref THEN
143: hr_utility.trace('PAYE Refs is changing, validating the change');
144: --
145: hr_utility.trace('Fetching Previous PAYE Ref');
146: OPEN get_prev_details;
147: FETCH get_prev_details INTO l_prev_scl_id;
148: CLOSE get_prev_details;
149: --
146: OPEN get_prev_details;
147: FETCH get_prev_details INTO l_prev_scl_id;
148: CLOSE get_prev_details;
149: --
150: hr_utility.trace('l_prev_scl_id = '||l_prev_scl_id);
151: OPEN get_paye_ref(l_prev_scl_id);
152: FETCH get_paye_ref INTO l_prev_paye_ref;
153: CLOSE get_paye_ref;
154: --
151: OPEN get_paye_ref(l_prev_scl_id);
152: FETCH get_paye_ref INTO l_prev_paye_ref;
153: CLOSE get_paye_ref;
154: --
155: hr_utility.trace('l_prev_paye_ref = '||l_prev_paye_ref);
156: --
157: IF l_prev_paye_ref <> l_new_paye_ref AND
158: l_cur_eff_start <> l_first_eff_start AND
159: to_char(l_cur_eff_start, 'DD-MM') <> '06-04' THEN
156: --
157: IF l_prev_paye_ref <> l_new_paye_ref AND
158: l_cur_eff_start <> l_first_eff_start AND
159: to_char(l_cur_eff_start, 'DD-MM') <> '06-04' THEN
160: hr_utility.trace('New PAYE Ref does not match the previous ');
161: hr_utility.trace('PAYE Ref and current effective start date ');
162: hr_utility.trace('is not the first effective start date and ');
163: hr_utility.trace('current effective date is not start of a ');
164: hr_utility.trace('tax year therefore raise an error message.');
157: IF l_prev_paye_ref <> l_new_paye_ref AND
158: l_cur_eff_start <> l_first_eff_start AND
159: to_char(l_cur_eff_start, 'DD-MM') <> '06-04' THEN
160: hr_utility.trace('New PAYE Ref does not match the previous ');
161: hr_utility.trace('PAYE Ref and current effective start date ');
162: hr_utility.trace('is not the first effective start date and ');
163: hr_utility.trace('current effective date is not start of a ');
164: hr_utility.trace('tax year therefore raise an error message.');
165: --
158: l_cur_eff_start <> l_first_eff_start AND
159: to_char(l_cur_eff_start, 'DD-MM') <> '06-04' THEN
160: hr_utility.trace('New PAYE Ref does not match the previous ');
161: hr_utility.trace('PAYE Ref and current effective start date ');
162: hr_utility.trace('is not the first effective start date and ');
163: hr_utility.trace('current effective date is not start of a ');
164: hr_utility.trace('tax year therefore raise an error message.');
165: --
166: l_span_start := hr_gbbal.span_start(l_cur_eff_start);
159: to_char(l_cur_eff_start, 'DD-MM') <> '06-04' THEN
160: hr_utility.trace('New PAYE Ref does not match the previous ');
161: hr_utility.trace('PAYE Ref and current effective start date ');
162: hr_utility.trace('is not the first effective start date and ');
163: hr_utility.trace('current effective date is not start of a ');
164: hr_utility.trace('tax year therefore raise an error message.');
165: --
166: l_span_start := hr_gbbal.span_start(l_cur_eff_start);
167: l_span_end := hr_gbbal.span_end(l_cur_eff_start);
160: hr_utility.trace('New PAYE Ref does not match the previous ');
161: hr_utility.trace('PAYE Ref and current effective start date ');
162: hr_utility.trace('is not the first effective start date and ');
163: hr_utility.trace('current effective date is not start of a ');
164: hr_utility.trace('tax year therefore raise an error message.');
165: --
166: l_span_start := hr_gbbal.span_start(l_cur_eff_start);
167: l_span_end := hr_gbbal.span_end(l_cur_eff_start);
168: --
172: substr(fnd_date.date_to_canonical(l_span_end), 1, 4));
173: fnd_message.raise_error;
174: END IF;
175: --
176: hr_utility.trace('Change as at the start date is ok, Checking end date');
177: --
178: hr_utility.trace('Fetching Next PAYE Ref');
179: OPEN get_next_details;
180: FETCH get_next_details INTO l_next_scl_id;
174: END IF;
175: --
176: hr_utility.trace('Change as at the start date is ok, Checking end date');
177: --
178: hr_utility.trace('Fetching Next PAYE Ref');
179: OPEN get_next_details;
180: FETCH get_next_details INTO l_next_scl_id;
181: CLOSE get_next_details;
182: --
179: OPEN get_next_details;
180: FETCH get_next_details INTO l_next_scl_id;
181: CLOSE get_next_details;
182: --
183: hr_utility.trace('l_next_scl_id = '||l_next_scl_id);
184: OPEN get_paye_ref(l_next_scl_id);
185: FETCH get_paye_ref INTO l_next_paye_ref;
186: CLOSE get_paye_ref;
187: --
184: OPEN get_paye_ref(l_next_scl_id);
185: FETCH get_paye_ref INTO l_next_paye_ref;
186: CLOSE get_paye_ref;
187: --
188: hr_utility.trace('l_next_paye_ref = '||l_next_paye_ref);
189: --
190: IF l_next_paye_ref <> l_new_paye_ref AND
191: l_cur_eff_end <> l_last_eff_end AND
192: to_char(l_cur_eff_end, 'DD-MM') <> '05-04' THEN
189: --
190: IF l_next_paye_ref <> l_new_paye_ref AND
191: l_cur_eff_end <> l_last_eff_end AND
192: to_char(l_cur_eff_end, 'DD-MM') <> '05-04' THEN
193: hr_utility.trace('New PAYE Ref does not match the next ');
194: hr_utility.trace('PAYE Ref and current effective end date ');
195: hr_utility.trace('is not the last effective end date and ');
196: hr_utility.trace('current effective date is not end of a ');
197: hr_utility.trace('tax year therefore raise an error message.');
190: IF l_next_paye_ref <> l_new_paye_ref AND
191: l_cur_eff_end <> l_last_eff_end AND
192: to_char(l_cur_eff_end, 'DD-MM') <> '05-04' THEN
193: hr_utility.trace('New PAYE Ref does not match the next ');
194: hr_utility.trace('PAYE Ref and current effective end date ');
195: hr_utility.trace('is not the last effective end date and ');
196: hr_utility.trace('current effective date is not end of a ');
197: hr_utility.trace('tax year therefore raise an error message.');
198: --
191: l_cur_eff_end <> l_last_eff_end AND
192: to_char(l_cur_eff_end, 'DD-MM') <> '05-04' THEN
193: hr_utility.trace('New PAYE Ref does not match the next ');
194: hr_utility.trace('PAYE Ref and current effective end date ');
195: hr_utility.trace('is not the last effective end date and ');
196: hr_utility.trace('current effective date is not end of a ');
197: hr_utility.trace('tax year therefore raise an error message.');
198: --
199: l_span_start := hr_gbbal.span_start(l_cur_eff_end);
192: to_char(l_cur_eff_end, 'DD-MM') <> '05-04' THEN
193: hr_utility.trace('New PAYE Ref does not match the next ');
194: hr_utility.trace('PAYE Ref and current effective end date ');
195: hr_utility.trace('is not the last effective end date and ');
196: hr_utility.trace('current effective date is not end of a ');
197: hr_utility.trace('tax year therefore raise an error message.');
198: --
199: l_span_start := hr_gbbal.span_start(l_cur_eff_end);
200: l_span_end := hr_gbbal.span_end(l_cur_eff_end);
193: hr_utility.trace('New PAYE Ref does not match the next ');
194: hr_utility.trace('PAYE Ref and current effective end date ');
195: hr_utility.trace('is not the last effective end date and ');
196: hr_utility.trace('current effective date is not end of a ');
197: hr_utility.trace('tax year therefore raise an error message.');
198: --
199: l_span_start := hr_gbbal.span_start(l_cur_eff_end);
200: l_span_end := hr_gbbal.span_end(l_cur_eff_end);
201: --
205: substr(fnd_date.date_to_canonical(l_span_end), 1, 4));
206: fnd_message.raise_error;
207: END IF;
208: --
209: hr_utility.trace('Change as at the end date is ok too.');
210: --
211:
212: -- START CHECK - Termination Assignment exists at the Effective start date
213: IF (l_prev_paye_ref <> l_new_paye_ref AND
264: END IF; -- Date track mode is correction
265: --
266: IF p_datetrack_mode = hr_api.g_update
267: OR p_datetrack_mode = hr_api.g_update_override THEN
268: hr_utility.trace('Datetrack Action is Update or Update Override.');
269: --
270: IF l_new_paye_ref <> l_cur_paye_ref THEN
271: hr_utility.trace('PAYE Refs is changing, validating the change');
272: --
267: OR p_datetrack_mode = hr_api.g_update_override THEN
268: hr_utility.trace('Datetrack Action is Update or Update Override.');
269: --
270: IF l_new_paye_ref <> l_cur_paye_ref THEN
271: hr_utility.trace('PAYE Refs is changing, validating the change');
272: --
273: IF l_cur_paye_ref <> l_new_paye_ref AND
274: p_effective_date <> l_first_eff_start AND
275: to_char(p_effective_date, 'DD-MM') <> '06-04' THEN
272: --
273: IF l_cur_paye_ref <> l_new_paye_ref AND
274: p_effective_date <> l_first_eff_start AND
275: to_char(p_effective_date, 'DD-MM') <> '06-04' THEN
276: hr_utility.trace('New PAYE Ref does not match the current ');
277: hr_utility.trace('PAYE Ref and new effective start date ');
278: hr_utility.trace('is not the first effective start date and ');
279: hr_utility.trace('new effective date is not start of a ');
280: hr_utility.trace('tax year therefore raise an error message.');
273: IF l_cur_paye_ref <> l_new_paye_ref AND
274: p_effective_date <> l_first_eff_start AND
275: to_char(p_effective_date, 'DD-MM') <> '06-04' THEN
276: hr_utility.trace('New PAYE Ref does not match the current ');
277: hr_utility.trace('PAYE Ref and new effective start date ');
278: hr_utility.trace('is not the first effective start date and ');
279: hr_utility.trace('new effective date is not start of a ');
280: hr_utility.trace('tax year therefore raise an error message.');
281: --
274: p_effective_date <> l_first_eff_start AND
275: to_char(p_effective_date, 'DD-MM') <> '06-04' THEN
276: hr_utility.trace('New PAYE Ref does not match the current ');
277: hr_utility.trace('PAYE Ref and new effective start date ');
278: hr_utility.trace('is not the first effective start date and ');
279: hr_utility.trace('new effective date is not start of a ');
280: hr_utility.trace('tax year therefore raise an error message.');
281: --
282: l_span_start := hr_gbbal.span_start(p_effective_date);
275: to_char(p_effective_date, 'DD-MM') <> '06-04' THEN
276: hr_utility.trace('New PAYE Ref does not match the current ');
277: hr_utility.trace('PAYE Ref and new effective start date ');
278: hr_utility.trace('is not the first effective start date and ');
279: hr_utility.trace('new effective date is not start of a ');
280: hr_utility.trace('tax year therefore raise an error message.');
281: --
282: l_span_start := hr_gbbal.span_start(p_effective_date);
283: l_span_end := hr_gbbal.span_end(p_effective_date);
276: hr_utility.trace('New PAYE Ref does not match the current ');
277: hr_utility.trace('PAYE Ref and new effective start date ');
278: hr_utility.trace('is not the first effective start date and ');
279: hr_utility.trace('new effective date is not start of a ');
280: hr_utility.trace('tax year therefore raise an error message.');
281: --
282: l_span_start := hr_gbbal.span_start(p_effective_date);
283: l_span_end := hr_gbbal.span_end(p_effective_date);
284: --
288: substr(fnd_date.date_to_canonical(l_span_end), 1, 4));
289: fnd_message.raise_error;
290: END IF;
291: --
292: hr_utility.trace('Change as at the new effective date ok, no need to check as at the effective end date');
293: --
294:
295: -- START CHECK - Termination Assignment exists at the Effective start date
296: IF l_cur_paye_ref <> l_new_paye_ref AND
322: END IF; -- PAYE Ref Changing
323: END IF; -- Date track update or update override
324: --
325: IF p_datetrack_mode = hr_api.g_update_change_insert THEN
326: hr_utility.trace('Datetrack Action is Update Change Insert.');
327: --
328: IF l_new_paye_ref <> l_cur_paye_ref THEN
329: hr_utility.trace('PAYE Refs is changing, validating the change');
330: --
325: IF p_datetrack_mode = hr_api.g_update_change_insert THEN
326: hr_utility.trace('Datetrack Action is Update Change Insert.');
327: --
328: IF l_new_paye_ref <> l_cur_paye_ref THEN
329: hr_utility.trace('PAYE Refs is changing, validating the change');
330: --
331: IF l_cur_paye_ref <> l_new_paye_ref AND
332: p_effective_date <> l_first_eff_start AND
333: to_char(p_effective_date, 'DD-MM') <> '06-04' THEN
330: --
331: IF l_cur_paye_ref <> l_new_paye_ref AND
332: p_effective_date <> l_first_eff_start AND
333: to_char(p_effective_date, 'DD-MM') <> '06-04' THEN
334: hr_utility.trace('New PAYE Ref does not match the current ');
335: hr_utility.trace('PAYE Ref and new effective start date ');
336: hr_utility.trace('is not the first effective start date and ');
337: hr_utility.trace('new effective date is not start of a ');
338: hr_utility.trace('tax year therefore raise an error message.');
331: IF l_cur_paye_ref <> l_new_paye_ref AND
332: p_effective_date <> l_first_eff_start AND
333: to_char(p_effective_date, 'DD-MM') <> '06-04' THEN
334: hr_utility.trace('New PAYE Ref does not match the current ');
335: hr_utility.trace('PAYE Ref and new effective start date ');
336: hr_utility.trace('is not the first effective start date and ');
337: hr_utility.trace('new effective date is not start of a ');
338: hr_utility.trace('tax year therefore raise an error message.');
339: --
332: p_effective_date <> l_first_eff_start AND
333: to_char(p_effective_date, 'DD-MM') <> '06-04' THEN
334: hr_utility.trace('New PAYE Ref does not match the current ');
335: hr_utility.trace('PAYE Ref and new effective start date ');
336: hr_utility.trace('is not the first effective start date and ');
337: hr_utility.trace('new effective date is not start of a ');
338: hr_utility.trace('tax year therefore raise an error message.');
339: --
340: l_span_start := hr_gbbal.span_start(p_effective_date);
333: to_char(p_effective_date, 'DD-MM') <> '06-04' THEN
334: hr_utility.trace('New PAYE Ref does not match the current ');
335: hr_utility.trace('PAYE Ref and new effective start date ');
336: hr_utility.trace('is not the first effective start date and ');
337: hr_utility.trace('new effective date is not start of a ');
338: hr_utility.trace('tax year therefore raise an error message.');
339: --
340: l_span_start := hr_gbbal.span_start(p_effective_date);
341: l_span_end := hr_gbbal.span_end(p_effective_date);
334: hr_utility.trace('New PAYE Ref does not match the current ');
335: hr_utility.trace('PAYE Ref and new effective start date ');
336: hr_utility.trace('is not the first effective start date and ');
337: hr_utility.trace('new effective date is not start of a ');
338: hr_utility.trace('tax year therefore raise an error message.');
339: --
340: l_span_start := hr_gbbal.span_start(p_effective_date);
341: l_span_end := hr_gbbal.span_end(p_effective_date);
342: --
346: substr(fnd_date.date_to_canonical(l_span_end), 1, 4));
347: fnd_message.raise_error;
348: END IF;
349: --
350: hr_utility.trace('Change as at the new effective date ok, Checking as at the effective end date');
351: --
352: --
353: hr_utility.trace('Fetching Next PAYE Ref');
354: OPEN get_next_details;
349: --
350: hr_utility.trace('Change as at the new effective date ok, Checking as at the effective end date');
351: --
352: --
353: hr_utility.trace('Fetching Next PAYE Ref');
354: OPEN get_next_details;
355: FETCH get_next_details INTO l_next_scl_id;
356: CLOSE get_next_details;
357: --
354: OPEN get_next_details;
355: FETCH get_next_details INTO l_next_scl_id;
356: CLOSE get_next_details;
357: --
358: hr_utility.trace('l_next_scl_id = '||l_next_scl_id);
359: OPEN get_paye_ref(l_next_scl_id);
360: FETCH get_paye_ref INTO l_next_paye_ref;
361: CLOSE get_paye_ref;
362: --
359: OPEN get_paye_ref(l_next_scl_id);
360: FETCH get_paye_ref INTO l_next_paye_ref;
361: CLOSE get_paye_ref;
362: --
363: hr_utility.trace('l_next_paye_ref = '||l_next_paye_ref);
364: --
365: IF l_next_paye_ref <> l_new_paye_ref AND
366: l_cur_eff_end <> l_last_eff_end AND
367: to_char(l_cur_eff_end, 'DD-MM') <> '05-04' THEN
364: --
365: IF l_next_paye_ref <> l_new_paye_ref AND
366: l_cur_eff_end <> l_last_eff_end AND
367: to_char(l_cur_eff_end, 'DD-MM') <> '05-04' THEN
368: hr_utility.trace('New PAYE Ref does not match the next ');
369: hr_utility.trace('PAYE Ref and current effective end date ');
370: hr_utility.trace('is not the last effective end date and ');
371: hr_utility.trace('current effective date is not end of a ');
372: hr_utility.trace('tax year therefore raise an error message.');
365: IF l_next_paye_ref <> l_new_paye_ref AND
366: l_cur_eff_end <> l_last_eff_end AND
367: to_char(l_cur_eff_end, 'DD-MM') <> '05-04' THEN
368: hr_utility.trace('New PAYE Ref does not match the next ');
369: hr_utility.trace('PAYE Ref and current effective end date ');
370: hr_utility.trace('is not the last effective end date and ');
371: hr_utility.trace('current effective date is not end of a ');
372: hr_utility.trace('tax year therefore raise an error message.');
373: --
366: l_cur_eff_end <> l_last_eff_end AND
367: to_char(l_cur_eff_end, 'DD-MM') <> '05-04' THEN
368: hr_utility.trace('New PAYE Ref does not match the next ');
369: hr_utility.trace('PAYE Ref and current effective end date ');
370: hr_utility.trace('is not the last effective end date and ');
371: hr_utility.trace('current effective date is not end of a ');
372: hr_utility.trace('tax year therefore raise an error message.');
373: --
374: l_span_start := hr_gbbal.span_start(l_cur_eff_end);
367: to_char(l_cur_eff_end, 'DD-MM') <> '05-04' THEN
368: hr_utility.trace('New PAYE Ref does not match the next ');
369: hr_utility.trace('PAYE Ref and current effective end date ');
370: hr_utility.trace('is not the last effective end date and ');
371: hr_utility.trace('current effective date is not end of a ');
372: hr_utility.trace('tax year therefore raise an error message.');
373: --
374: l_span_start := hr_gbbal.span_start(l_cur_eff_end);
375: l_span_end := hr_gbbal.span_end(l_cur_eff_end);
368: hr_utility.trace('New PAYE Ref does not match the next ');
369: hr_utility.trace('PAYE Ref and current effective end date ');
370: hr_utility.trace('is not the last effective end date and ');
371: hr_utility.trace('current effective date is not end of a ');
372: hr_utility.trace('tax year therefore raise an error message.');
373: --
374: l_span_start := hr_gbbal.span_start(l_cur_eff_end);
375: l_span_end := hr_gbbal.span_end(l_cur_eff_end);
376: --
380: substr(fnd_date.date_to_canonical(l_span_end), 1, 4));
381: fnd_message.raise_error;
382: END IF;
383: --
384: hr_utility.trace('Change as at the end date is ok too.');
385: --
386:
387: -- START CHECK - Termination Assignment exists at the Effective start date
388: IF (l_cur_paye_ref <> l_new_paye_ref AND
437: END IF; -- PAYE Ref Changing
438: END IF; -- Date track update change insert
439: --
440:
441: hr_utility.trace('No problem with this update/correction.');
442: hr_utility.trace('Leaving pay_gb_payroll_rules.validate_update');
443: END validate_update;
444:
445: PROCEDURE validate_delete(p_effective_date IN DATE
438: END IF; -- Date track update change insert
439: --
440:
441: hr_utility.trace('No problem with this update/correction.');
442: hr_utility.trace('Leaving pay_gb_payroll_rules.validate_update');
443: END validate_update;
444:
445: PROCEDURE validate_delete(p_effective_date IN DATE
446: ,p_datetrack_mode IN VARCHAR2
531: --
532:
533: l_proc VARCHAR2(100) := 'pay_gb_payroll_rules.validate_delete';
534: BEGIN
535: hr_utility.trace('Entering '||l_proc);
536: hr_utility.trace('p_effective_date='||fnd_date.date_to_displaydate(p_effective_date));
537: hr_utility.trace('p_datetrack_mode='||p_datetrack_mode);
538: hr_utility.trace('p_payroll_id='||p_payroll_id);
539: --
532:
533: l_proc VARCHAR2(100) := 'pay_gb_payroll_rules.validate_delete';
534: BEGIN
535: hr_utility.trace('Entering '||l_proc);
536: hr_utility.trace('p_effective_date='||fnd_date.date_to_displaydate(p_effective_date));
537: hr_utility.trace('p_datetrack_mode='||p_datetrack_mode);
538: hr_utility.trace('p_payroll_id='||p_payroll_id);
539: --
540: hr_utility.trace('Fetching current payroll details');
533: l_proc VARCHAR2(100) := 'pay_gb_payroll_rules.validate_delete';
534: BEGIN
535: hr_utility.trace('Entering '||l_proc);
536: hr_utility.trace('p_effective_date='||fnd_date.date_to_displaydate(p_effective_date));
537: hr_utility.trace('p_datetrack_mode='||p_datetrack_mode);
538: hr_utility.trace('p_payroll_id='||p_payroll_id);
539: --
540: hr_utility.trace('Fetching current payroll details');
541: OPEN get_current_details;
534: BEGIN
535: hr_utility.trace('Entering '||l_proc);
536: hr_utility.trace('p_effective_date='||fnd_date.date_to_displaydate(p_effective_date));
537: hr_utility.trace('p_datetrack_mode='||p_datetrack_mode);
538: hr_utility.trace('p_payroll_id='||p_payroll_id);
539: --
540: hr_utility.trace('Fetching current payroll details');
541: OPEN get_current_details;
542: FETCH get_current_details INTO l_cur_scl_id, l_cur_eff_end;
536: hr_utility.trace('p_effective_date='||fnd_date.date_to_displaydate(p_effective_date));
537: hr_utility.trace('p_datetrack_mode='||p_datetrack_mode);
538: hr_utility.trace('p_payroll_id='||p_payroll_id);
539: --
540: hr_utility.trace('Fetching current payroll details');
541: OPEN get_current_details;
542: FETCH get_current_details INTO l_cur_scl_id, l_cur_eff_end;
543: CLOSE get_current_details;
544: --
541: OPEN get_current_details;
542: FETCH get_current_details INTO l_cur_scl_id, l_cur_eff_end;
543: CLOSE get_current_details;
544: --
545: hr_utility.trace('Currrent l_cur_scl_id='||l_cur_scl_id);
546: hr_utility.trace('Currrent l_cur_eff_end='||fnd_date.date_to_displaydate(l_cur_eff_end));
547: --
548: hr_utility.trace('Fetching Current PAYE Ref.');
549: OPEN get_paye_ref(l_cur_scl_id);
542: FETCH get_current_details INTO l_cur_scl_id, l_cur_eff_end;
543: CLOSE get_current_details;
544: --
545: hr_utility.trace('Currrent l_cur_scl_id='||l_cur_scl_id);
546: hr_utility.trace('Currrent l_cur_eff_end='||fnd_date.date_to_displaydate(l_cur_eff_end));
547: --
548: hr_utility.trace('Fetching Current PAYE Ref.');
549: OPEN get_paye_ref(l_cur_scl_id);
550: FETCH get_paye_ref INTO l_cur_paye_ref;
544: --
545: hr_utility.trace('Currrent l_cur_scl_id='||l_cur_scl_id);
546: hr_utility.trace('Currrent l_cur_eff_end='||fnd_date.date_to_displaydate(l_cur_eff_end));
547: --
548: hr_utility.trace('Fetching Current PAYE Ref.');
549: OPEN get_paye_ref(l_cur_scl_id);
550: FETCH get_paye_ref INTO l_cur_paye_ref;
551: CLOSE get_paye_ref;
552: hr_utility.trace('Current PAYE Ref is '||l_cur_paye_ref);
548: hr_utility.trace('Fetching Current PAYE Ref.');
549: OPEN get_paye_ref(l_cur_scl_id);
550: FETCH get_paye_ref INTO l_cur_paye_ref;
551: CLOSE get_paye_ref;
552: hr_utility.trace('Current PAYE Ref is '||l_cur_paye_ref);
553: --
554: hr_utility.trace('Fetching fiest start date and last end date of the payroll');
555: OPEN get_min_max_dates;
556: FETCH get_min_max_dates INTO l_first_eff_start, l_last_eff_end;
550: FETCH get_paye_ref INTO l_cur_paye_ref;
551: CLOSE get_paye_ref;
552: hr_utility.trace('Current PAYE Ref is '||l_cur_paye_ref);
553: --
554: hr_utility.trace('Fetching fiest start date and last end date of the payroll');
555: OPEN get_min_max_dates;
556: FETCH get_min_max_dates INTO l_first_eff_start, l_last_eff_end;
557: CLOSE get_min_max_dates;
558: hr_utility.trace('l_first_eff_start='||fnd_date.date_to_displaydate(l_first_eff_start));
554: hr_utility.trace('Fetching fiest start date and last end date of the payroll');
555: OPEN get_min_max_dates;
556: FETCH get_min_max_dates INTO l_first_eff_start, l_last_eff_end;
557: CLOSE get_min_max_dates;
558: hr_utility.trace('l_first_eff_start='||fnd_date.date_to_displaydate(l_first_eff_start));
559: hr_utility.trace('l_last_eff_end='||fnd_date.date_to_displaydate(l_last_eff_end));
560: --
561: IF p_datetrack_mode = hr_api.g_delete_next_change THEN
562: hr_utility.trace('Datetrack Mode is Delete next change.');
555: OPEN get_min_max_dates;
556: FETCH get_min_max_dates INTO l_first_eff_start, l_last_eff_end;
557: CLOSE get_min_max_dates;
558: hr_utility.trace('l_first_eff_start='||fnd_date.date_to_displaydate(l_first_eff_start));
559: hr_utility.trace('l_last_eff_end='||fnd_date.date_to_displaydate(l_last_eff_end));
560: --
561: IF p_datetrack_mode = hr_api.g_delete_next_change THEN
562: hr_utility.trace('Datetrack Mode is Delete next change.');
563: hr_utility.trace('Fetching end date of next instance.');
558: hr_utility.trace('l_first_eff_start='||fnd_date.date_to_displaydate(l_first_eff_start));
559: hr_utility.trace('l_last_eff_end='||fnd_date.date_to_displaydate(l_last_eff_end));
560: --
561: IF p_datetrack_mode = hr_api.g_delete_next_change THEN
562: hr_utility.trace('Datetrack Mode is Delete next change.');
563: hr_utility.trace('Fetching end date of next instance.');
564: OPEN get_next_details;
565: FETCH get_next_details INTO l_next_eff_end;
566: CLOSE get_next_details;
559: hr_utility.trace('l_last_eff_end='||fnd_date.date_to_displaydate(l_last_eff_end));
560: --
561: IF p_datetrack_mode = hr_api.g_delete_next_change THEN
562: hr_utility.trace('Datetrack Mode is Delete next change.');
563: hr_utility.trace('Fetching end date of next instance.');
564: OPEN get_next_details;
565: FETCH get_next_details INTO l_next_eff_end;
566: CLOSE get_next_details;
567: --
564: OPEN get_next_details;
565: FETCH get_next_details INTO l_next_eff_end;
566: CLOSE get_next_details;
567: --
568: hr_utility.trace('l_next_eff_date='||fnd_date.date_to_displaydate(l_next_eff_end));
569: hr_utility.trace('Fetching PAYE Ref on next to next instance.');
570: OPEN get_next_to_next_details;
571: FETCH get_next_to_next_details INTO l_next_to_next_scl_id;
572: CLOSE get_next_to_next_details;
565: FETCH get_next_details INTO l_next_eff_end;
566: CLOSE get_next_details;
567: --
568: hr_utility.trace('l_next_eff_date='||fnd_date.date_to_displaydate(l_next_eff_end));
569: hr_utility.trace('Fetching PAYE Ref on next to next instance.');
570: OPEN get_next_to_next_details;
571: FETCH get_next_to_next_details INTO l_next_to_next_scl_id;
572: CLOSE get_next_to_next_details;
573: hr_utility.trace('l_next_to_next_scl_id='||l_next_to_next_scl_id);
569: hr_utility.trace('Fetching PAYE Ref on next to next instance.');
570: OPEN get_next_to_next_details;
571: FETCH get_next_to_next_details INTO l_next_to_next_scl_id;
572: CLOSE get_next_to_next_details;
573: hr_utility.trace('l_next_to_next_scl_id='||l_next_to_next_scl_id);
574: --
575: OPEN get_paye_ref(l_next_to_next_scl_id);
576: FETCH get_paye_ref INTO l_next_to_next_paye_ref;
577: CLOSE get_paye_ref;
574: --
575: OPEN get_paye_ref(l_next_to_next_scl_id);
576: FETCH get_paye_ref INTO l_next_to_next_paye_ref;
577: CLOSE get_paye_ref;
578: hr_utility.trace('l_next_to_next_paye_ref='||l_next_to_next_paye_ref);
579: --
580: IF l_next_to_next_paye_ref <> l_cur_paye_ref AND
581: l_next_eff_end <> l_last_eff_end AND
582: to_char(l_next_eff_end, 'DD-MM') <> '05-04' THEN
580: IF l_next_to_next_paye_ref <> l_cur_paye_ref AND
581: l_next_eff_end <> l_last_eff_end AND
582: to_char(l_next_eff_end, 'DD-MM') <> '05-04' THEN
583: --
584: hr_utility.trace('Current PAYE Ref does not match the PAYE ');
585: hr_utility.trace('Ref on next to next instance and next effective ');
586: hr_utility.trace('end date is not the last effective end date and ');
587: hr_utility.trace('next effective end date is not end of a ');
588: hr_utility.trace('tax year therefore raise an error message.');
581: l_next_eff_end <> l_last_eff_end AND
582: to_char(l_next_eff_end, 'DD-MM') <> '05-04' THEN
583: --
584: hr_utility.trace('Current PAYE Ref does not match the PAYE ');
585: hr_utility.trace('Ref on next to next instance and next effective ');
586: hr_utility.trace('end date is not the last effective end date and ');
587: hr_utility.trace('next effective end date is not end of a ');
588: hr_utility.trace('tax year therefore raise an error message.');
589: --
582: to_char(l_next_eff_end, 'DD-MM') <> '05-04' THEN
583: --
584: hr_utility.trace('Current PAYE Ref does not match the PAYE ');
585: hr_utility.trace('Ref on next to next instance and next effective ');
586: hr_utility.trace('end date is not the last effective end date and ');
587: hr_utility.trace('next effective end date is not end of a ');
588: hr_utility.trace('tax year therefore raise an error message.');
589: --
590: l_span_start := hr_gbbal.span_start(l_next_eff_end);
583: --
584: hr_utility.trace('Current PAYE Ref does not match the PAYE ');
585: hr_utility.trace('Ref on next to next instance and next effective ');
586: hr_utility.trace('end date is not the last effective end date and ');
587: hr_utility.trace('next effective end date is not end of a ');
588: hr_utility.trace('tax year therefore raise an error message.');
589: --
590: l_span_start := hr_gbbal.span_start(l_next_eff_end);
591: l_span_end := hr_gbbal.span_end(l_next_eff_end);
584: hr_utility.trace('Current PAYE Ref does not match the PAYE ');
585: hr_utility.trace('Ref on next to next instance and next effective ');
586: hr_utility.trace('end date is not the last effective end date and ');
587: hr_utility.trace('next effective end date is not end of a ');
588: hr_utility.trace('tax year therefore raise an error message.');
589: --
590: l_span_start := hr_gbbal.span_start(l_next_eff_end);
591: l_span_end := hr_gbbal.span_end(l_next_eff_end);
592: --
626: -- END CHECK - Termination Assignment exists at the Effective start date
627:
628: END IF; -- Datetrack mode is Remove next change
629: --
630: hr_utility.trace('No problem with this delete.');
631: hr_utility.trace('Leaving pay_gb_payroll_rules.validate_delete');
632: END validate_delete;
633:
634: END;
627:
628: END IF; -- Datetrack mode is Remove next change
629: --
630: hr_utility.trace('No problem with this delete.');
631: hr_utility.trace('Leaving pay_gb_payroll_rules.validate_delete');
632: END validate_delete;
633:
634: END;