161: --
162: procedure check_parameters is
163: begin
164: --
165: hr_utility.trace (l_proc||' p_effective_date = '
166: ||to_char (p_effective_date));
167: --
168: hr_api.mandatory_arg_error (
169: p_api_name => l_proc,
172: end check_parameters;
173: --
174: begin
175: --
176: hr_utility.set_location (l_proc,1);
177: --
178: check_parameters;
179: --
180: open csr_PAB_element_details (p_effective_date,c_PAB_corr_element_name);
180: open csr_PAB_element_details (p_effective_date,c_PAB_corr_element_name);
181: fetch csr_PAB_element_details into g_PAB_Correction_element;
182: close csr_PAB_element_details;
183: --
184: hr_utility.set_location (l_proc,100);
185: --
186: end get_PAB_correction_element;
187: --------------------------------------------------------------------------------
188: procedure get_PAB_element (p_effective_date in date) is
191: --
192: procedure check_parameters is
193: begin
194: --
195: hr_utility.trace (l_proc||' p_effective_date = '
196: ||to_char (p_effective_date));
197: --
198: hr_api.mandatory_arg_error (
199: p_api_name => l_proc,
202: end check_parameters;
203: --
204: begin
205: --
206: hr_utility.set_location (l_proc,1);
207: --
208: check_parameters;
209: --
210: open csr_PAB_element_details (p_effective_date,c_PAB_element_name);
210: open csr_PAB_element_details (p_effective_date,c_PAB_element_name);
211: fetch csr_PAB_element_details into g_PAB_element;
212: close csr_PAB_element_details;
213: --
214: hr_utility.set_location (l_proc,100);
215: --
216: end get_PAB_element;
217: --------------------------------------------------------------------------------
218: function EARLIEST_PPP_START_DATE (p_birth_date in date) return date is
312: and effective_date = l_effective_date;
313: --
314: begin
315: --
316: hr_utility.set_location ('Entering '||l_proc,1);
317: --
318: l_effective_date := greatest(person.QW, person.date_start);
319: --
320: open csr_average_earnings;
333: end if;
334: --
335: close csr_average_earnings;
336: --
337: hr_utility.set_location ('Leaving '||l_proc,10);
338: --
339: return l_average_earnings;
340: --
341: end average_earnings;
419: procedure check_parameters is
420: --
421: begin
422: --
423: hr_utility.trace (l_proc||' p_reason = '||p_reason);
424: hr_utility.trace (l_proc||' withhold from '||to_char (p_withhold_from));
425: hr_utility.trace (l_proc||' withhold to '||to_char (p_withhold_to));
426: --
427: hr_api.mandatory_arg_error (
420: --
421: begin
422: --
423: hr_utility.trace (l_proc||' p_reason = '||p_reason);
424: hr_utility.trace (l_proc||' withhold from '||to_char (p_withhold_from));
425: hr_utility.trace (l_proc||' withhold to '||to_char (p_withhold_to));
426: --
427: hr_api.mandatory_arg_error (
428: p_api_name => l_proc,
421: begin
422: --
423: hr_utility.trace (l_proc||' p_reason = '||p_reason);
424: hr_utility.trace (l_proc||' withhold from '||to_char (p_withhold_from));
425: hr_utility.trace (l_proc||' withhold to '||to_char (p_withhold_to));
426: --
427: hr_api.mandatory_arg_error (
428: p_api_name => l_proc,
429: p_argument => 'reason',
437: end check_parameters;
438: --
439: begin
440: --
441: hr_utility.set_location (l_proc,1);
442: --
443: check_parameters;
444: --
445: l_reason_id := ssp_smp_support_pkg.withholding_reason_id (
462: p_maternity_id => p_maternity_id,
463: p_user_entered => 'N',
464: p_reason_id => l_reason_id);
465: else
466: hr_utility.trace (l_proc||' Stoppage is overridden');
467: end if;
468: --
469: hr_utility.set_location (l_proc,100);
470: --
465: else
466: hr_utility.trace (l_proc||' Stoppage is overridden');
467: end if;
468: --
469: hr_utility.set_location (l_proc,100);
470: --
471: end create_stoppage;
472: --
473: procedure remove_stoppages is
485: l_proc varchar2 (72) := g_package||'remove_stoppages';
486: --
487: begin
488: --
489: hr_utility.set_location (l_proc,1);
490: --
491: for each_stoppage in csr_stoppages LOOP
492: ssp_stp_del.del (p_stoppage_id => each_stoppage.stoppage_id,
493: p_object_version_number => l_dummy);
492: ssp_stp_del.del (p_stoppage_id => each_stoppage.stoppage_id,
493: p_object_version_number => l_dummy);
494: end loop;
495: --
496: hr_utility.set_location (l_proc,100);
497: --
498: end remove_stoppages;
499: --
500: procedure check_employment_end is
512: l_proc varchar2(72) := g_package||'check_employment_end';
513: --
514: begin
515: --
516: hr_utility.set_location (l_proc,1);
517: --
518: open csr_termination_date;
519: fetch csr_termination_date into l_termination_date;
520: close csr_termination_date;
527: create_stoppage (p_withhold_from => person.actual_birth_date,
528: p_reason => 'Not employed on Birth Date');
529: end if;
530: --
531: hr_utility.set_location (l_proc,100);
532: --
533: end check_employment_end;
534: --
535: procedure check_continuity_rule is
551: l_proc varchar2 (72) := g_package||'check_continuity_rule';
552: --
553: begin
554: --
555: hr_utility.set_location (l_proc,1);
556: --
557: open period_of_service;
558: fetch period_of_service into l_dummy;
559: --
567: end if;
568: --
569: close period_of_service;
570: --
571: hr_utility.set_location (l_proc,100);
572: --
573: end check_continuity_rule;
574: --
575: procedure check_start_date is
580: l_PAB_element csr_PAB_element_details%rowtype;
581: --
582: begin
583: --
584: hr_utility.set_location (l_proc,1);
585: --
586: open csr_PAB_element_details (person.actual_birth_date,c_PAB_element_name);
587: fetch csr_PAB_element_details into l_PAB_element;
588: close csr_PAB_element_details;
595: p_reason => 'Max PPP Period Exceeded');
596:
597: end if;
598: --
599: hr_utility.set_location (l_proc,100);
600: --
601: end check_start_date;
602:
603: procedure check_stillbirth is
607: l_proc varchar2 (72) := g_package||'check_stillbirth';
608: --
609: begin
610: --
611: hr_utility.set_location (l_proc,1);
612: --
613: -- Woman must be still pregnant, have had a live birth, or have had a
614: -- stillbirth after the threshhold week to be eligible for PAB
615: --
625: create_stoppage (p_withhold_from => person.APP_start_date,
626: p_reason => 'Stillbirth');
627: end if;
628: --
629: hr_utility.set_location (l_proc,100);
630: --
631: end check_stillbirth;
632: --
633: procedure check_new_employer is
638: l_proc varchar2 (72) := g_package||'check_new_employer';
639: --
640: begin
641: --
642: hr_utility.set_location (l_proc,1);
643: --
644: if person.start_date_with_new_employer >= person.actual_birth_date then
645: --
646: -- Stop SAP payment from the start of the week in which the person
650: (person.start_date_with_new_employer),
651: p_reason => 'Worked for another employer');
652: end if;
653: --
654: hr_utility.set_location (l_proc,100);
655: --
656: end check_new_employer;
657: --
658: procedure check_maternity_allowance is
662: l_proc varchar2 (72) := g_package||'check_maternity_allowance';
663: --
664: begin
665: --
666: hr_utility.set_location (l_proc,1);
667: --
668: if person.start_date_maternity_allowance is not null then
669: --
670: -- Stop SAP payment from the start of the week in which SMA was first
674: (person.start_date_maternity_allowance),
675: p_reason => 'Employee is receiving SMA');
676: end if;
677: --
678: hr_utility.set_location (l_proc,100);
679: --
680: end check_maternity_allowance;
681: --
682: procedure check_death is
694: l_death_date date;
695: --
696: begin
697: --
698: hr_utility.set_location (l_proc,1);
699: --
700: -- PAB ceases on the Saturday following death
701: --
702: l_death_date := null;
710: l_sunday),
711: p_reason => 'Employee died');
712: end if;
713: --
714: hr_utility.set_location (l_proc,100);
715: --
716: end check_death;
717: --
718: procedure check_average_earnings is
725: earnings_not_derived exception;
726: --
727: begin
728: --
729: hr_utility.set_location (l_proc,1);
730: --
731: if l_average_earnings = 0
732: then
733: --
756: create_stoppage (p_withhold_from => person.APP_start_date,
757: p_reason => 'Earnings too low');
758: end if;
759: --
760: hr_utility.set_location (l_proc,100);
761: --
762: exception
763: --
764: when earnings_not_derived then
764: when earnings_not_derived then
765: --
766: -- Exit silently from this procedure
767: --
768: hr_utility.trace (l_proc||' Earnings not derived');
769: null;
770: --
771: end check_average_earnings;
772: --
777: l_proc varchar2 (72) := g_package||'check_birth_confirmation';
778: --
779: begin
780: --
781: hr_utility.set_location (l_proc,1);
782: --
783: hr_utility.set_location (l_proc,100);
784: --
785: end check_birth_confirmation;
779: begin
780: --
781: hr_utility.set_location (l_proc,1);
782: --
783: hr_utility.set_location (l_proc,100);
784: --
785: end check_birth_confirmation;
786: --
787: procedure check_parameters is
787: procedure check_parameters is
788: --
789: begin
790: --
791: hr_utility.trace (l_proc||' p_maternity_id = '
792: ||to_char (p_maternity_id));
793: --
794: hr_api.mandatory_arg_error (
795: p_api_name => l_proc,
799: end check_parameters;
800: --
801: begin
802: --
803: hr_utility.set_location (l_proc,1);
804: --
805: check_parameters;
806: --
807: -- Get the details of the woman and her maternity.
815: -- If no maternity record exists then there can be no entitlement to SAP
816: --
817: close csr_personal_details;
818: --
819: hr_utility.trace (l_proc||' Person has no maternity record - exiting');
820: --
821: raise no_prima_facia_entitlement;
822: end if;
823: --
826: if person.APP_start_date is null then
827: --
828: -- If the APP has not started then there is no entitlement to SAP.
829: --
830: hr_utility.trace (l_proc||' Person has no APP start date - exiting');
831: --
832: raise no_prima_facia_entitlement;
833: end if;
834: --
847: fetch csr_check_if_existing_entries into l_existing_entries;
848: --
849: if csr_check_if_existing_entries%NOTFOUND
850: then
851: hr_utility.trace (l_proc||' Person has not stopped work - exiting');
852: raise no_prima_facia_entitlement;
853: end if;
854: --
855: -- if entries are found then the absence has been deleted and entries remain
865: --
866: -- Having established a prima facia entitlement to SAP, perform checks which
867: -- may lead to creation of stoppages for particular periods.
868: --
869: hr_utility.set_location ('ssp_smp_pkg.entitled_to_PAB',2);
870: --
871: -- Get the SAP legislative parameters.
872: --
873: get_PAB_element (person.due_date);
910: p_reason => 'Late absence notification');
911: */
912: end if;
913: --
914: hr_utility.set_location ('ssp_sap_pkg.entitled_to_SaP',3);
915: --
916: -- Check for any work done during the APP.
917: --
918: -- Check if this is the first absence period in the APP
984: else
985: --
986: -- This is not the last absence in the maternity but it has no end date.
987: --
988: hr_utility.trace (l_proc||' ERROR: Invalid null absence end date');
989: --
990: raise invalid_absence_date;
991: end if;
992: end if;
1166: l_proc varchar2 (72) := g_package||'.remove_stoppages';
1167: --
1168: begin
1169: --
1170: hr_utility.set_location (l_proc,1);
1171: --
1172: for each_stoppage in csr_stoppages LOOP
1173: ssp_stp_del.del (p_stoppage_id => each_stoppage.stoppage_id,
1174: p_object_version_number => l_dummy);
1174: p_object_version_number => l_dummy);
1175:
1176: end loop;
1177: --
1178: hr_utility.set_location (l_proc,100);
1179: --
1180: end remove_stoppages;
1181: --
1182: begin
1180: end remove_stoppages;
1181: --
1182: begin
1183: --
1184: hr_utility.set_location('Entering: '||l_proc,10);
1185: --
1186: get_PAB_correction_element (person.due_date);
1187: --
1188: -- Check each existing SaP entry in turn against all the potential new ones.
1219: = hypothetical_entry.week_commencing (entry_number)
1220: and not hypothetical_entry.stopped (entry_number) = 'TRUE'
1221: and ssp_smp_pkg.g_smp_update = 'Y'));
1222: end loop;
1223: hr_utility.trace (l_proc||' Old entry / Hypo entry time Match with values:');
1224: hr_utility.trace (l_proc||' Rate: ' ||old_entry.rate||' / '
1225: ||hypothetical_entry.rate (Entry_number));
1226: hr_utility.trace (l_proc||' Amount: '
1227: ||old_entry.amount||' / '
1220: and not hypothetical_entry.stopped (entry_number) = 'TRUE'
1221: and ssp_smp_pkg.g_smp_update = 'Y'));
1222: end loop;
1223: hr_utility.trace (l_proc||' Old entry / Hypo entry time Match with values:');
1224: hr_utility.trace (l_proc||' Rate: ' ||old_entry.rate||' / '
1225: ||hypothetical_entry.rate (Entry_number));
1226: hr_utility.trace (l_proc||' Amount: '
1227: ||old_entry.amount||' / '
1228: ||hypothetical_entry.amount (entry_number));
1222: end loop;
1223: hr_utility.trace (l_proc||' Old entry / Hypo entry time Match with values:');
1224: hr_utility.trace (l_proc||' Rate: ' ||old_entry.rate||' / '
1225: ||hypothetical_entry.rate (Entry_number));
1226: hr_utility.trace (l_proc||' Amount: '
1227: ||old_entry.amount||' / '
1228: ||hypothetical_entry.amount (entry_number));
1229: hr_utility.trace (l_proc||' Recoverable: '
1230: ||old_entry.recoverable_amount||' / '
1225: ||hypothetical_entry.rate (Entry_number));
1226: hr_utility.trace (l_proc||' Amount: '
1227: ||old_entry.amount||' / '
1228: ||hypothetical_entry.amount (entry_number));
1229: hr_utility.trace (l_proc||' Recoverable: '
1230: ||old_entry.recoverable_amount||' / '
1231: ||hypothetical_entry.recoverable_amount (entry_number));
1232: hr_utility.trace (l_proc||' Week Comm: '
1233: ||hypothetical_entry.week_commencing (entry_number) );
1228: ||hypothetical_entry.amount (entry_number));
1229: hr_utility.trace (l_proc||' Recoverable: '
1230: ||old_entry.recoverable_amount||' / '
1231: ||hypothetical_entry.recoverable_amount (entry_number));
1232: hr_utility.trace (l_proc||' Week Comm: '
1233: ||hypothetical_entry.week_commencing (entry_number) );
1234: --A hypo entry covers the same week as the old one
1235: if old_entry.rate = hypothetical_entry.rate (entry_number)
1236: and old_entry.amount = hypothetical_entry.amount(entry_number)
1240: -- the hypo entry has the same values as the old one
1241: -- don't create a correction element.
1242: -- don't create a new entry
1243: hypothetical_entry.dealt_with (entry_number) := 'TRUE';
1244: hr_utility.trace (l_proc||' leave unchanged');
1245: else
1246: if ssp_smp_support_pkg.entry_already_processed
1247: (old_entry.element_entry_id)
1248: then
1246: if ssp_smp_support_pkg.entry_already_processed
1247: (old_entry.element_entry_id)
1248: then
1249: l_ins_corr_ele := TRUE;
1250: hr_utility.trace (l_proc||' processed - correct it');
1251: else
1252: -- update old entry
1253: hr_utility.trace (l_proc||' unprocessed - update it');
1254: hr_entry_api.update_element_entry (
1249: l_ins_corr_ele := TRUE;
1250: hr_utility.trace (l_proc||' processed - correct it');
1251: else
1252: -- update old entry
1253: hr_utility.trace (l_proc||' unprocessed - update it');
1254: hr_entry_api.update_element_entry (
1255: p_dt_update_mode => 'CORRECTION',
1256: p_session_date => old_entry.effective_start_date,
1257: p_element_entry_id => old_entry.element_entry_id,
1272: when no_data_found then
1273: -- There was no new entry which exactly matched the old entry.
1274: -- or we are deleting.
1275: entry_number := null;
1276: hr_utility.trace (l_proc||' No Old entry - Hypo entry time Match');
1277: hr_utility.trace (l_proc||' or p_deleting is true');
1278: hr_utility.trace (l_proc||' Old entry values:');
1279: hr_utility.trace (l_proc||' Rate: '||old_entry.rate);
1280: hr_utility.trace (l_proc||' Amount: '||old_entry.amount);
1273: -- There was no new entry which exactly matched the old entry.
1274: -- or we are deleting.
1275: entry_number := null;
1276: hr_utility.trace (l_proc||' No Old entry - Hypo entry time Match');
1277: hr_utility.trace (l_proc||' or p_deleting is true');
1278: hr_utility.trace (l_proc||' Old entry values:');
1279: hr_utility.trace (l_proc||' Rate: '||old_entry.rate);
1280: hr_utility.trace (l_proc||' Amount: '||old_entry.amount);
1281: hr_utility.trace (l_proc||' Recoverable: '
1274: -- or we are deleting.
1275: entry_number := null;
1276: hr_utility.trace (l_proc||' No Old entry - Hypo entry time Match');
1277: hr_utility.trace (l_proc||' or p_deleting is true');
1278: hr_utility.trace (l_proc||' Old entry values:');
1279: hr_utility.trace (l_proc||' Rate: '||old_entry.rate);
1280: hr_utility.trace (l_proc||' Amount: '||old_entry.amount);
1281: hr_utility.trace (l_proc||' Recoverable: '
1282: ||old_entry.recoverable_amount);
1275: entry_number := null;
1276: hr_utility.trace (l_proc||' No Old entry - Hypo entry time Match');
1277: hr_utility.trace (l_proc||' or p_deleting is true');
1278: hr_utility.trace (l_proc||' Old entry values:');
1279: hr_utility.trace (l_proc||' Rate: '||old_entry.rate);
1280: hr_utility.trace (l_proc||' Amount: '||old_entry.amount);
1281: hr_utility.trace (l_proc||' Recoverable: '
1282: ||old_entry.recoverable_amount);
1283: if ssp_smp_support_pkg.entry_already_processed
1276: hr_utility.trace (l_proc||' No Old entry - Hypo entry time Match');
1277: hr_utility.trace (l_proc||' or p_deleting is true');
1278: hr_utility.trace (l_proc||' Old entry values:');
1279: hr_utility.trace (l_proc||' Rate: '||old_entry.rate);
1280: hr_utility.trace (l_proc||' Amount: '||old_entry.amount);
1281: hr_utility.trace (l_proc||' Recoverable: '
1282: ||old_entry.recoverable_amount);
1283: if ssp_smp_support_pkg.entry_already_processed
1284: (old_entry.element_entry_id)
1277: hr_utility.trace (l_proc||' or p_deleting is true');
1278: hr_utility.trace (l_proc||' Old entry values:');
1279: hr_utility.trace (l_proc||' Rate: '||old_entry.rate);
1280: hr_utility.trace (l_proc||' Amount: '||old_entry.amount);
1281: hr_utility.trace (l_proc||' Recoverable: '
1282: ||old_entry.recoverable_amount);
1283: if ssp_smp_support_pkg.entry_already_processed
1284: (old_entry.element_entry_id)
1285: then l_ins_corr_ele := TRUE;
1282: ||old_entry.recoverable_amount);
1283: if ssp_smp_support_pkg.entry_already_processed
1284: (old_entry.element_entry_id)
1285: then l_ins_corr_ele := TRUE;
1286: hr_utility.trace (l_proc||' Old entry already processed');
1287: else
1288: hr_utility.trace (l_proc||' Old entry NOT already processed');
1289: --Old entry not already processed so delete it
1290: hr_entry_api.delete_element_entry (
1284: (old_entry.element_entry_id)
1285: then l_ins_corr_ele := TRUE;
1286: hr_utility.trace (l_proc||' Old entry already processed');
1287: else
1288: hr_utility.trace (l_proc||' Old entry NOT already processed');
1289: --Old entry not already processed so delete it
1290: hr_entry_api.delete_element_entry (
1291: p_dt_delete_mode => 'ZAP',
1292: p_session_date => old_entry.effective_start_date,
1297: then
1298: -- Create a correction element to reverse the old entry. Then create a
1299: -- brand new entry with the correct values.
1300: --
1301: hr_utility.trace (l_proc ||
1302: ' Inserting CORRECTION entry for week commencing ' ||
1303: to_char (old_entry.week_commencing));
1304: hr_utility.trace (l_proc||' Old value / New value:');
1305: if entry_number is null then
1300: --
1301: hr_utility.trace (l_proc ||
1302: ' Inserting CORRECTION entry for week commencing ' ||
1303: to_char (old_entry.week_commencing));
1304: hr_utility.trace (l_proc||' Old value / New value:');
1305: if entry_number is null then
1306: hr_utility.trace (l_proc||' Rate: '
1307: ||old_entry.rate||' / NA');
1308: hr_utility.trace (l_proc||' Amount: '
1302: ' Inserting CORRECTION entry for week commencing ' ||
1303: to_char (old_entry.week_commencing));
1304: hr_utility.trace (l_proc||' Old value / New value:');
1305: if entry_number is null then
1306: hr_utility.trace (l_proc||' Rate: '
1307: ||old_entry.rate||' / NA');
1308: hr_utility.trace (l_proc||' Amount: '
1309: ||old_entry.amount||' / NA');
1310: hr_utility.trace (l_proc||' Recoverable: '
1304: hr_utility.trace (l_proc||' Old value / New value:');
1305: if entry_number is null then
1306: hr_utility.trace (l_proc||' Rate: '
1307: ||old_entry.rate||' / NA');
1308: hr_utility.trace (l_proc||' Amount: '
1309: ||old_entry.amount||' / NA');
1310: hr_utility.trace (l_proc||' Recoverable: '
1311: ||old_entry.recoverable_amount||' / NA');
1312: else
1306: hr_utility.trace (l_proc||' Rate: '
1307: ||old_entry.rate||' / NA');
1308: hr_utility.trace (l_proc||' Amount: '
1309: ||old_entry.amount||' / NA');
1310: hr_utility.trace (l_proc||' Recoverable: '
1311: ||old_entry.recoverable_amount||' / NA');
1312: else
1313: hr_utility.trace (l_proc||' Rate: '
1314: ||old_entry.rate||' / '
1309: ||old_entry.amount||' / NA');
1310: hr_utility.trace (l_proc||' Recoverable: '
1311: ||old_entry.recoverable_amount||' / NA');
1312: else
1313: hr_utility.trace (l_proc||' Rate: '
1314: ||old_entry.rate||' / '
1315: ||hypothetical_entry.rate (Entry_number));
1316: hr_utility.trace (l_proc||' Amount: '
1317: ||old_entry.amount||' / '
1312: else
1313: hr_utility.trace (l_proc||' Rate: '
1314: ||old_entry.rate||' / '
1315: ||hypothetical_entry.rate (Entry_number));
1316: hr_utility.trace (l_proc||' Amount: '
1317: ||old_entry.amount||' / '
1318: ||hypothetical_entry.amount (entry_number));
1319: hr_utility.trace (l_proc||' Recoverable: '
1320: ||old_entry.recoverable_amount||' /'
1315: ||hypothetical_entry.rate (Entry_number));
1316: hr_utility.trace (l_proc||' Amount: '
1317: ||old_entry.amount||' / '
1318: ||hypothetical_entry.amount (entry_number));
1319: hr_utility.trace (l_proc||' Recoverable: '
1320: ||old_entry.recoverable_amount||' /'
1321: ||hypothetical_entry.recoverable_amount (entry_number));
1322: end if;
1323: --
1368: -- Having been through all the existing entries, we now check that we
1369: -- have dealt with all the newly derived entries by inserting any which
1370: -- were not flagged as dealt with during the above actions.
1371: --
1372: hr_utility.set_location (l_proc,20);
1373: --
1374: <
1375: begin
1376: if p_deleting then
1373: --
1374: <
1375: begin
1376: if p_deleting then
1377: hr_utility.trace('Deleting an absence so don''t insert entries');
1378: else
1379: for new_entry in 1..g_PAB_element.maximum_PPP_weeks LOOP
1380:
1381: if (not hypothetical_entry.dealt_with (new_entry) = 'TRUE')
1424: if l_no_of_absence_periods = 0 then
1425: remove_stoppages;
1426: end if;
1427: --
1428: hr_utility.set_location(' Leaving: '||l_proc,100);
1429: --
1430: end save_hypothetical_entries;
1431: --
1432: procedure derive_PAB_week (p_week_number in integer) is
1436: -- we are and finding the offset from the start date.
1437: --
1438: begin
1439: --
1440: hr_utility.set_location ('Entering: ssp_sap_pkg.derive_PAB_week',1);
1441: hr_utility.trace ('Entry number = '||to_char (p_week_number));
1442: --
1443: hypothetical_entry.week_commencing (p_week_number)
1444: := (person.APP_start_date + ((p_week_number -1) * 7));
1437: --
1438: begin
1439: --
1440: hr_utility.set_location ('Entering: ssp_sap_pkg.derive_PAB_week',1);
1441: hr_utility.trace ('Entry number = '||to_char (p_week_number));
1442: --
1443: hypothetical_entry.week_commencing (p_week_number)
1444: := (person.APP_start_date + ((p_week_number -1) * 7));
1445: --
1447: hypothetical_entry.stopped (p_week_number) := 'FALSE';
1448: hypothetical_entry.element_link_id (p_week_number) := null;
1449: hypothetical_entry.assignment_id (p_week_number) := null;
1450: --
1451: hr_utility.trace ('week_commencing = '
1452: ||to_char (hypothetical_entry.week_commencing (p_week_number)));
1453: --
1454: hr_utility.set_location ('Leaving : ssp_sap_pkg.derive_PAB_week',100);
1455: --
1450: --
1451: hr_utility.trace ('week_commencing = '
1452: ||to_char (hypothetical_entry.week_commencing (p_week_number)));
1453: --
1454: hr_utility.set_location ('Leaving : ssp_sap_pkg.derive_PAB_week',100);
1455: --
1456: end derive_PAB_week;
1457: --
1458: procedure Check_PAB_stoppages (p_week_number in integer) is
1487: l_dummy integer (1);
1488: --
1489: begin
1490: --
1491: hr_utility.set_location ('ssp_sap_pkg.Check_PAB_stoppages',1);
1492: --
1493: hypothetical_entry.stopped (p_week_number) := 'FALSE';
1494: --
1495: --
1507: -- is payable.
1508: --
1509: hypothetical_entry.stopped (p_week_number) := 'TRUE';
1510: --
1511: hr_utility.trace ('Entry is STOPPED');
1512: --
1513: -- Keep a tally of the number of stopped weeks
1514: --
1515: l_stopped_weeks := l_stopped_weeks +1;
1516: end if;
1517: --
1518: close csr_stoppages;
1519: --
1520: hr_utility.set_location ('ssp_sap_pkg.Check_PAB_stoppages',10);
1521: --
1522: end Check_PAB_stoppages;
1523: --
1524: procedure Calculate_correct_PAB_rate (p_week_number in number) is
1534: and lookup_code = p_rate_band;
1535: --
1536: begin
1537: --
1538: hr_utility.set_location ('ssp_sap_pkg.Calculate_correct_PAB_rate',1);
1539: --
1540: if l_high_rate is null then
1541: --
1542: -- Get the meanings for the rate bands
1552: /*
1553: if (p_week_number - l_stopped_weeks)
1554: <= g_SMP_element.period_at_higher_rate
1555: then
1556: hr_utility.set_location ('ssp_smp_pkg.Calculate_correct_SMP_rate',1);
1557: --
1558: -- We have not yet given the employee all their higher rate weeks
1559: --
1560: */
1564: hypothetical_entry.rate (p_week_number) := l_low_rate;
1565: end if;
1566: */
1567: --
1568: hr_utility.trace ('PAB Rate = '
1569: ||hypothetical_entry.rate (p_week_number));
1570: --
1571: hr_utility.set_location ('ssp_sap_pkg.Calculate_correct_PAB_rate',10);
1572: --
1567: --
1568: hr_utility.trace ('PAB Rate = '
1569: ||hypothetical_entry.rate (p_week_number));
1570: --
1571: hr_utility.set_location ('ssp_sap_pkg.Calculate_correct_PAB_rate',10);
1572: --
1573: end Calculate_correct_PAB_rate;
1574: --
1575: procedure Calculate_PAB_amounts (p_week_number in integer, p_APP_start_date in date) is
1575: procedure Calculate_PAB_amounts (p_week_number in integer, p_APP_start_date in date) is
1576: --
1577: begin
1578: --
1579: hr_utility.set_location('Entering: ssp_sAp_pkg.Calculate_SaP_amounts',1);
1580: --
1581: -- Get the SAP element for each week in case the SAP rate has changed
1582: --
1583: get_PAB_element (hypothetical_entry.week_commencing (p_week_number));
1591: hypothetical_entry.recoverable_amount (p_week_number)
1592: := round (hypothetical_entry.amount (p_week_number)
1593: * g_PAB_element.recovery_rate,2);
1594: --
1595: hr_utility.trace ('PAB amount = '
1596: ||to_char (hypothetical_entry.amount (p_week_number)));
1597: hr_utility.trace ('Recoverable amount = '
1598: ||to_char (hypothetical_entry.recoverable_amount (p_week_number)));
1599: --
1593: * g_PAB_element.recovery_rate,2);
1594: --
1595: hr_utility.trace ('PAB amount = '
1596: ||to_char (hypothetical_entry.amount (p_week_number)));
1597: hr_utility.trace ('Recoverable amount = '
1598: ||to_char (hypothetical_entry.recoverable_amount (p_week_number)));
1599: --
1600: hr_utility.set_location('Leaving : ssp_sap_pkg.Calculate_PAB_amounts',100);
1601: --
1596: ||to_char (hypothetical_entry.amount (p_week_number)));
1597: hr_utility.trace ('Recoverable amount = '
1598: ||to_char (hypothetical_entry.recoverable_amount (p_week_number)));
1599: --
1600: hr_utility.set_location('Leaving : ssp_sap_pkg.Calculate_PAB_amounts',100);
1601: --
1602: end calculate_PAB_amounts;
1603: --
1604: procedure check_parameters is
1611: end check_parameters;
1612: --
1613: begin
1614: --
1615: hr_utility.set_location ('ssp_sap_pkg.generate_payments',1);
1616: --
1617: check_parameters;
1618: --
1619: <
1705: l_proc varchar2 (72) := g_package||'PAB_control';
1706: --
1707: begin
1708: --
1709: hr_utility.set_location (l_proc,1);
1710: --
1711: open csr_maternity;
1712: fetch csr_maternity into l_dummy;
1713: --
1733: -- The maternity may have been deleted. Remove any element entries associated
1734: -- with it (the absences, stoppages and medicals are handled by constraints).
1735: --
1736: for obsolete in csr_entries LOOP
1737: hr_utility.trace (l_proc||' Deleting element entry_id '||
1738: to_char (obsolete.element_entry_id));
1739: hr_utility.trace (l_proc||'-------------------------------------------');
1740: --
1741: hr_entry_api.delete_element_entry (
1735: --
1736: for obsolete in csr_entries LOOP
1737: hr_utility.trace (l_proc||' Deleting element entry_id '||
1738: to_char (obsolete.element_entry_id));
1739: hr_utility.trace (l_proc||'-------------------------------------------');
1740: --
1741: hr_entry_api.delete_element_entry (
1742: p_dt_delete_mode => 'ZAP',
1743: p_session_date => obsolete.effective_start_date,
1744: p_element_entry_id => obsolete.element_entry_id);
1745: end loop;
1746: end if;
1747: --
1748: hr_utility.set_location (l_proc,100);
1749: --
1750: end PAB_control;
1751: --------------------------------------------------------------------------------
1752: end ssp_pab_pkg;