0% found this document useful (0 votes)
319 views76 pages

XXCF

This package body defines procedures for creating extra person information records in Oracle. It includes procedures for annual leave return requests and exit permit requests that validate date overlaps and eligibility requirements. Various cursors are used to retrieve assignment, payroll, and other attribute data for validation.

Uploaded by

syedmehar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
319 views76 pages

XXCF

This package body defines procedures for creating extra person information records in Oracle. It includes procedures for annual leave return requests and exit permit requests that validate date overlaps and eligibility requirements. Various cursors are used to retrieve assignment, payroll, and other attribute data for validation.

Uploaded by

syedmehar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 76

create or replace PACKAGE BODY xxqsc_user_hook

AS
PROCEDURE create_person_extra_info_b (
p_person_id NUMBER,
p_information_type VARCHAR2,
p_pei_attribute_category VARCHAR2,
p_pei_attribute1 VARCHAR2,
p_pei_attribute2 VARCHAR2,
p_pei_attribute3 VARCHAR2,
p_pei_attribute4 VARCHAR2,
p_pei_attribute5 VARCHAR2,
p_pei_attribute6 VARCHAR2,
p_pei_attribute7 VARCHAR2,
p_pei_attribute8 VARCHAR2,
p_pei_attribute9 VARCHAR2,
p_pei_attribute10 VARCHAR2,
p_pei_attribute11 VARCHAR2,
p_pei_attribute12 VARCHAR2,
p_pei_attribute13 VARCHAR2,
p_pei_attribute14 VARCHAR2,
p_pei_attribute15 VARCHAR2,
p_pei_attribute16 VARCHAR2,
p_pei_attribute17 VARCHAR2,
p_pei_attribute18 VARCHAR2,
p_pei_attribute19 VARCHAR2,
p_pei_attribute20 VARCHAR2,
p_pei_information_category VARCHAR2,
p_pei_information1 VARCHAR2,
p_pei_information2 VARCHAR2,
p_pei_information3 VARCHAR2,
p_pei_information4 VARCHAR2,
p_pei_information5 VARCHAR2,
p_pei_information6 VARCHAR2,
p_pei_information7 VARCHAR2,
p_pei_information8 VARCHAR2,
p_pei_information9 VARCHAR2,
p_pei_information10 VARCHAR2,
p_pei_information11 VARCHAR2,
p_pei_information12 VARCHAR2,
p_pei_information13 VARCHAR2,
p_pei_information14 VARCHAR2,
p_pei_information15 VARCHAR2,
p_pei_information16 VARCHAR2,
p_pei_information17 VARCHAR2,
p_pei_information18 VARCHAR2,
p_pei_information19 VARCHAR2,
p_pei_information20 VARCHAR2,
p_pei_information21 VARCHAR2,
p_pei_information22 VARCHAR2,
p_pei_information23 VARCHAR2,
p_pei_information24 VARCHAR2,
p_pei_information25 VARCHAR2,
p_pei_information26 VARCHAR2,
p_pei_information27 VARCHAR2,
p_pei_information28 VARCHAR2,
p_pei_information29 VARCHAR2,
p_pei_information30 VARCHAR2)
IS
v_nat VARCHAR2 (30000);
v_user_id NUMBER;
v_count NUMBER;
v_resp_id NUMBER;
v_resp_appl_id NUMBER;
v_assignment_id NUMBER
:= xxqsc_hr_wf_pkg.get_person_assignmnet_id (p_person_id);
v_validate_date NUMBER;
v_sponser VARCHAR2 (500);
v_sponser_exit_permt VARCHAR2 (500);

CURSOR c_valid
IS
SELECT DECODE (grade_id, NULL, -1, grade_id) grade,
DECODE (payroll_id, NULL, -1, payroll_id) payroll,
DECODE (pay_basis_id, NULL, -1, pay_basis_id) salary_basis
FROM per_assignments_f
WHERE person_id = p_person_id
AND TRUNC (SYSDATE) BETWEEN effective_start_date
AND effective_end_date;

CURSOR c_prob_period
IS
/*SELECT ass_attribute1
FROM per_assignments_f
WHERE person_id = p_person_id
AND TRUNC (SYSDATE) BETWEEN effective_start_date
AND effective_end_date;*/
SELECT CASE
WHEN TRUNC (
TO_DATE (a.attribute7, 'RRRR/MM/DD HH24:MI:SS')) >=
TRUNC (SYSDATE)
OR a.attribute7 IS NULL
THEN
'N'
WHEN TRUNC (
TO_DATE (a.attribute7, 'RRRR/MM/DD HH24:MI:SS')) <
TRUNC (SYSDATE)
THEN
'Y'
END
prob_pass
FROM per_all_people_f a
WHERE SYSDATE BETWEEN a.effective_start_date
AND a.effective_end_date
AND a.person_id = p_person_id;

v_prob VARCHAR2 (4);

CURSOR c_start
IS
SELECT MONTHS_BETWEEN (
TO_DATE (TO_CHAR (TRUNC (SYSDATE), 'MM/DD/RRRR'),
'MM/DD/RRRR'),
TO_DATE (TO_CHAR (TRUNC (start_date), 'MM/DD/RRRR'),
'MM/DD/RRRR'))
hiredate
FROM per_people_f
WHERE person_id = p_person_id;
v_hire NUMBER;

CURSOR c_ticket
IS
SELECT segment5
FROM pay_people_groups
WHERE people_group_id =
(SELECT people_group_id
FROM per_assignments_f
WHERE person_id = p_person_id
AND TRUNC (SYSDATE) BETWEEN effective_start_date
AND effective_end_date);

CURSOR c_school
IS
SELECT segment7
FROM pay_people_groups
WHERE people_group_id =
(SELECT people_group_id
FROM per_assignments_f
WHERE person_id = p_person_id
AND TRUNC (SYSDATE) BETWEEN effective_start_date
AND effective_end_date);

CURSOR c_effective_date
IS
SELECT MONTHS_BETWEEN (
TO_DATE (TO_CHAR (TRUNC (SYSDATE), 'MM/DD/RRRR'),
'MM/DD/RRRR'),
TO_DATE (
TO_CHAR (TRUNC (f.effective_start_date), 'MM/DD/RRRR'),
'MM/DD/RRRR'))
total,
f.effective_start_date,
elementtl.element_name,
f.element_entry_id
FROM pay_element_entries_f f,
pay_element_types_f_tl elementtl,
pay_element_types_f ELEMENT
WHERE f.assignment_id =
(SELECT assignment_id
FROM per_assignments_f
WHERE person_id = p_person_id
AND TRUNC (SYSDATE) BETWEEN effective_start_date
AND effective_end_date)
AND ELEMENT.element_type_id = elementtl.element_type_id
AND elementtl.LANGUAGE = USERENV ('LANG')
AND ELEMENT.element_type_id = f.element_type_id
AND elementtl.element_name = 'Furniture Grant Payment'
AND f.element_entry_id =
(SELECT MAX (element_entry_id)
FROM pay_element_entries_f f1,
pay_element_types_f_tl elementtl1,
pay_element_types_f element1
WHERE f1.assignment_id =
(SELECT assignment_id
FROM per_assignments_f
WHERE person_id = p_person_id
AND TRUNC (SYSDATE) BETWEEN
effective_start_date
AND
effective_end_date)
AND element1.element_type_id =
elementtl1.element_type_id
AND elementtl1.LANGUAGE = USERENV ('LANG')
AND element1.element_type_id =
f1.element_type_id
AND elementtl1.element_name =
'Furniture Grant Payment');

v_effective_date DATE;
v_num NUMBER;
v_ticket VARCHAR2 (300);
v_school VARCHAR2 (300);
v_exit_eligible_date DATE;

V_RESULT VARCHAR2 (50);

V_START_DATE VARCHAR2 (50);


V_END_DATE VARCHAR2 (50);
BEGIN
---------------------Annual Leave Return Request
------------------------------
IF p_information_type = 'QSC_SS_ANNUAL_LEAVE_RETURN_REQ'
THEN
/*IF NVL(XXQSC_HR_WF_PKG.GET_ABSENCE_OVERLAP( 81,v_assignment_id,TO_DATE
(TO_CHAR
(TO_DATE
(p_pei_information2, 'RRRR/MM/DD HH24:MI:SS'
), 'MM/DD/RRRR'
), 'MM/DD/RRRR'
),
TO_DATE
(TO_CHAR
(TO_DATE
(p_pei_information3, 'RRRR/MM/DD HH24:MI:SS'
), 'MM/DD/RRRR'
), 'MM/DD/RRRR'
)) ,p_pei_information1)<>p_pei_information1 */
IF NVL (xxqsc_hr_wf_pkg.get_absence_overlap (
81,
v_assignment_id,
TO_DATE (P_PEI_INFORMATION2, 'YYYY/MM/DD HH24:MI:SS'),
TO_DATE (P_PEI_INFORMATION3, 'YYYY/MM/DD HH24:MI:SS')),
p_pei_information1) <> p_pei_information1
THEN
hr_utility.set_message (800, 'XXQSC_ANNUAL_LEAVE_OVERLAP');
hr_utility.raise_error;
END IF;
END IF;

------------------Exit Permit------------------------------
IF p_information_type = 'QSC_SS_EXIT_PERMIT_REQUEST'
THEN
v_nat := xxqsc_hr_wf_pkg.get_employee_nationality (81, p_person_id);
-- v_exit_eligible_date :=
-- fnd_date.canonical_to_date (P_PEI_INFORMATION3) - 6;
-- v_validate_date :=
-- ( fnd_date.canonical_to_date (P_PEI_INFORMATION3)
-- - TRUNC (SYSDATE))
-- + 1;

----------------------- EDIT ------------------------


v_exit_eligible_date :=
TO_DATE (P_PEI_INFORMATION3, 'YYYY/MM/DD HH24:MI:SS') - 6;
v_validate_date :=
( (TO_DATE (P_PEI_INFORMATION3, 'YYYY/MM/DD HH24:MI:SS'))
- TRUNC (SYSDATE))
+ 1;

-------------------------EDIT -----------------------

/* intejar--- st */

BEGIN
SELECT DISTINCT ATTRIBUTE5
INTO v_sponser
FROM per_all_people_f
WHERE person_id = p_person_id
AND TRUNC (SYSDATE) BETWEEN EFFECTIVE_START_DATE
AND EFFECTIVE_end_DATE;
EXCEPTION
WHEN OTHERS
THEN
NULL;
END;

IF NVL (v_sponser, 'N') <> 'ESHAILSAT'


THEN
hr_utility.set_message (800, 'XXQSC_RENWAL_NON_SPONSER_MSG');
---hr_utility.set_message ('You are not a valid sponser for apply this
document');
hr_utility.raise_error;
END IF;

/* intejar--- end */
----IF (v_nat = 'QATAR' THEN INTEJAR ADDED BELOW

IF (v_nat = 'QATAR' OR NVL (v_sponser, 'N') <> 'ESHAILSAT')


THEN
hr_utility.set_message (800, 'XXQSC_EXIT_PERMIT_ERROR');
hr_utility.raise_error;
END IF;

IF v_validate_date > 7 AND P_PEI_INFORMATION1 = 'TEMP'


THEN
hr_utility.set_message (800, 'XXQSC_DYNAMIC_MESSAGE');
hr_utility.set_message_token (
'MESSAGE',
'You are not Eligible to submit Exit Permit Request before : '
|| v_exit_eligible_date);
hr_utility.raise_error;
END IF;

IF P_PEI_INFORMATION1 = 'TEMP' AND P_PEI_INFORMATION3 IS NULL


THEN
-- raise_application_error (-20555,
-- 'You have to enter Exit Permit
Date');

hr_utility.set_message (800, 'XXQSC_DYNAMIC_MESSAGE');


hr_utility.set_message_token (
'MESSAGE',
'You have to enter Exit Permit Date ');
hr_utility.raise_error;
END IF;

v_exit_eligible_date := NULL;
END IF;

-----------------------Update payroll information-----------------


IF p_information_type = 'QSC_SS_UPDATE_PAYROLL_INFO_REQ'
THEN
FOR i IN c_valid
LOOP
IF ( /*i.grade = -1 OR*/
i.payroll = -1 OR i.salary_basis = -1)
THEN
hr_utility.set_message (800, 'XXQSC_UPDATE_PAYROLL_ERROR');
hr_utility.raise_error;
END IF;
END LOOP;
END IF;

------------------------permit Renewal -------------------------------


IF p_information_type = 'QSC_SS_RP_RENEWAL_REQ'
THEN
v_nat := xxqsc_hr_wf_pkg.get_employee_nationality (81, p_person_id);

---IF v_nat = 'QATAR' /*commented by intejar*/


IF v_nat = 'QATAR'
THEN
hr_utility.set_message (800, 'XXQSC_RENWAL_NON_QATARI_MSG');
hr_utility.raise_error;
END IF;

BEGIN
SELECT DISTINCT ATTRIBUTE5
INTO v_sponser
FROM per_all_people_f
WHERE person_id = p_person_id
AND TRUNC (SYSDATE) BETWEEN EFFECTIVE_START_DATE
AND EFFECTIVE_end_DATE;
EXCEPTION
WHEN OTHERS
THEN
NULL;
END;
IF NVL (v_sponser, 'N') <> 'ESHAILSAT'
THEN
hr_utility.set_message (800, 'XXQSC_RENWAL_NON_SPONSER_MSG');
---hr_utility.set_message ('You are not a valid sponser for apply this
document');
hr_utility.raise_error;
END IF;
---ATTRIBUTE5 <> 'ESHAILSAT'

END IF;

--------------------------carloan-------------------------------
IF p_information_type = 'QSC_SS_CAR_LOAN_REQUEST'
THEN
FOR j IN c_prob_period
LOOP
v_prob := j.prob_pass;
END LOOP;

IF (NVL (v_prob, 'N') <> 'Y' OR v_prob IS NULL)


THEN
hr_utility.set_message (800, 'XXQSC_CARLOAN_RENEWAL_PROB');
hr_utility.raise_error;
ELSE
v_nat :=
xxqsc_hr_wf_pkg.get_employee_nationality (81, p_person_id);

FOR o IN c_start
LOOP
v_hire := o.hiredate;
END LOOP;
/* IF (v_nat <> 'QATAR' AND v_hire < 12)
THEN
hr_utility.set_message (800, 'XXQSC_CAR_LOAN_VALIDATION');
hr_utility.raise_error;
END IF;*/
END IF;
END IF;

--------------------- Baggage Allowance --------------------------------


----------------------Social/Emergency Loan request-----------------------
IF p_information_type = 'QSC_SS_SOCIAL_LOAN_REQUEST'
THEN
FOR w IN c_prob_period
LOOP
v_prob := w.prob_pass;
END LOOP;

v_nat := xxqsc_hr_wf_pkg.get_employee_nationality (81, p_person_id);

IF NVL (v_prob, 'N') <> 'Y'


THEN
hr_utility.set_message (800, 'XXQSC_CARLOAN_RENEWAL_PROB');
hr_utility.raise_error;
ELSE
IF v_nat <> 'QATAR'
THEN
hr_utility.set_message (800, 'XXQSC_SOCIAL_EMR_LOAN_VALID');
hr_utility.raise_error;
END IF;
END IF;
END IF;

---------------------Furniture Grant Request---------------------


IF p_information_type = 'QSC_SS_FURNITURE_GRANT_REQ'
THEN
FOR w IN c_prob_period
LOOP
v_prob := w.prob_pass;
END LOOP;

IF NVL (v_prob, 'N') <> 'Y'


THEN
hr_utility.set_message (800, 'XXQSC_CARLOAN_RENEWAL_PROB');
hr_utility.raise_error;
END IF;

SELECT COUNT (papf.person_id)


INTO v_count
FROM per_people_info_types ppt,
per_people_extra_info ex,
per_all_people_f papf,
per_all_assignments_f paaf
WHERE ppt.information_type = ex.information_type
AND papf.person_id = ex.person_id
AND papf.person_id = paaf.person_id
AND ex.information_type = 'QSC_SS_FURNITURE_GRANT_REQ'
AND SYSDATE BETWEEN papf.effective_start_date
AND papf.effective_end_date
AND SYSDATE BETWEEN paaf.effective_start_date
AND paaf.effective_end_date
AND papf.person_id = p_person_id;

IF v_count > 0
THEN
-- raise_application_error (
-- -20200,
-- 'Unfortunately you cannot be able to Create another
Request as it was being applied before');
-- -- hr_utility.set_message (800, 'XX_ONE_TIME_REQ');
-- hr_utility.raise_error;

hr_utility.set_message (800, 'XXQSC_DYNAMIC_MESSAGE');


hr_utility.set_message_token (
'MESSAGE',
'Unfortunately you cannot be able to Create another Request as it
was being applied before');
hr_utility.raise_error;
END IF;
END IF;

--------------------------Mobile Set Allowance Request--------------------


IF p_information_type = 'QSC_SS_MOBILE_SET_REQUEST'
THEN
FOR w IN c_prob_period
LOOP
v_prob := w.prob_pass;
END LOOP;

IF NVL (v_prob, 'N') <> 'Y'


THEN
hr_utility.set_message (800, 'XXQSC_CARLOAN_RENEWAL_PROB');
hr_utility.raise_error;
END IF;
END IF;

------------Ticket Request---------------------------------------------
IF p_information_type = 'QSC_SS_ANNUAL_TICKET_HR_REQ'
THEN
v_nat := xxqsc_hr_wf_pkg.get_employee_nationality (81, p_person_id);

FOR w IN c_ticket
LOOP
v_ticket := w.segment5;
END LOOP;

IF v_nat = 'QATAR'
THEN
hr_utility.set_message (800, 'XXQSC_RENWAL_NON_QATARI_MSG');
hr_utility.raise_error;
ELSE
IF (NVL (v_ticket, 'N') <> 'Y')
THEN
hr_utility.set_message (800, 'XXQSC_TICKET_ENTITLED_VALIE');
hr_utility.raise_error;
END IF;
END IF;
END IF;

----------------------------------Furniture Maintenance Request


IF p_information_type = 'QSC_SS_FURNITURE_MAINTAIN_REQ'
THEN
FOR w IN c_prob_period
LOOP
v_prob := w.prob_pass;
END LOOP;

IF NVL (v_prob, 'N') <> 'Y'


THEN
hr_utility.set_message (800, 'XXQSC_CARLOAN_RENEWAL_PROB');
hr_utility.raise_error;
ELSE
FOR h IN c_effective_date
LOOP
v_num := h.total;
END LOOP;

IF v_num < 48
THEN
hr_utility.set_message (800, 'XXQSC_FUR_MAIN_VALI');
hr_utility.raise_error;
END IF;
END IF;
END IF;
-----------------------------------------Schooling Allowance Request
--------------------------------
IF p_information_type = 'QSC_SS_SCHOOL_ALLOWANCE_REQ'
THEN
DECLARE
v_proc NUMBER;
v_unproc NUMBER;
v_entitled_smstr NUMBER := 0;
p_hire_date DATE
:= TO_DATE (p_pei_information8, 'YYYY-MM-DD HH24:MI:SS'); --
fnd_date.date_to_canonical(p_pei_information8);
BEGIN
-- IF TO_DATE (p_pei_information8) <= TO_DATE ('31-12-' ||
SUBSTR (p_pei_information4, 1, 4), 'dd-mm-yyyy')
-- THEN
-- v_entitled_smstr := 3;
-- ELSIF TO_DATE (p_pei_information8) > TO_DATE ( '31-
12-' || SUBSTR (p_pei_information4, 1, 4), 'dd-mm-yyyy')
-- AND TO_DATE (p_pei_information8) <= TO_DATE ( '31-
03-' || SUBSTR (p_pei_information4, 6, 4), 'dd-mm-yyyy')
-- THEN
-- v_entitled_smstr := 2;
-- ELSIF TO_DATE (p_pei_information8) > TO_DATE ( '31-
03-' || SUBSTR (p_pei_information4, 6, 4), 'dd-mm-yyyy')
-- AND TO_DATE (p_pei_information8) <= TO_DATE ( '30-
06-' || SUBSTR (p_pei_information4, 6, 4), 'dd-mm-yyyy')
-- THEN
-- v_entitled_smstr := 1;
-- END IF;

/* Updated to check change the date format*/

-- IF TO_DATE (p_pei_information8 ,'MM-DD-RRRR') <= TO_DATE


('31-12-' || SUBSTR (p_pei_information4, 1, 4), 'dd-mm-rrrr')
-- THEN
-- v_entitled_smstr := 3;
-- ELSIF TO_DATE (p_pei_information8 ,'MM-DD-RRRR') >
TO_DATE ( '31-12-' || SUBSTR (p_pei_information4, 1, 4), 'dd-mm-rrrr')
-- AND TO_DATE (p_pei_information8 ,'MM-DD-RRRR') <=
TO_DATE ( '31-03-' || SUBSTR (p_pei_information4, 6, 4), 'dd-mm-rrrr')
-- THEN
-- v_entitled_smstr := 2;
-- ELSIF TO_DATE (p_pei_information8 ,'MM-DD-RRRR') >
TO_DATE ( '31-03-' || SUBSTR (p_pei_information4, 6, 4), 'dd-mm-rrrr')
-- AND TO_DATE (p_pei_information8 ,'MM-DD-RRRR') <=
TO_DATE ( '30-06-' || SUBSTR (p_pei_information4, 6, 4), 'dd-mm-rrrr')
-- THEN
-- v_entitled_smstr := 1;
-- END IF;

IF p_hire_date <=
TO_DATE ('31-12-' || SUBSTR (p_pei_information4, 1, 4),
'dd-mm-rrrr')
THEN
v_entitled_smstr := 3;
ELSIF p_hire_date >
TO_DATE (
'31-12-' || SUBSTR (p_pei_information4, 1, 4),
'dd-mm-rrrr')
AND p_hire_date <=
TO_DATE (
'31-03-' || SUBSTR (p_pei_information4, 6, 4),
'dd-mm-rrrr')
THEN
v_entitled_smstr := 2;
ELSIF p_hire_date >
TO_DATE (
'31-03-' || SUBSTR (p_pei_information4, 6, 4),
'dd-mm-rrrr')
AND p_hire_date <=
TO_DATE (
'30-06-' || SUBSTR (p_pei_information4, 6, 4),
'dd-mm-rrrr')
THEN
v_entitled_smstr := 1;
END IF;

-- check married and male


IF xxqsc_hr_wf_pkg.get_emp_status (p_person_id, 'sex') <> 'M'
OR xxqsc_hr_wf_pkg.get_emp_status (p_person_id,
'marital_status') <> 'M'
THEN
hr_utility.set_message (800, 'XXQSC_SS_GENDER_MSTATUS');
hr_utility.raise_error;
END IF;

-- check entitled
IF xxqsc_hr_wf_pkg.get_ppg_segment_val (p_person_id, 7) <> 'Y'
THEN
hr_utility.set_message (800, 'XXQSC_SS_NOT_ENTITLED');
hr_utility.raise_error;
END IF;

--- chek grade rate


v_proc :=
xxqsc_hr_wf_pkg.get_proc_edu_allow (
p_ed_year => p_pei_information4,
p_person_id => v_assignment_id,
p_name => xxqsc_hr_wf_pkg.get_emp_status (
p_pei_information3,
'full_name'));
v_unproc :=
xxqsc_hr_wf_pkg.get_unproc_edu_allow (
p_person_id => v_assignment_id,
p_name => xxqsc_hr_wf_pkg.get_emp_status (
p_pei_information3,
'full_name'),
p_ed_year => p_pei_information4);

IF NVL (p_pei_information1, 0)
+ NVL (v_proc, 0)
+ NVL (v_unproc, 0) >
xxqsc_hr_wf_pkg.get_entitled_edu_allow (v_assignment_id,
SYSDATE)
* (v_entitled_smstr / 3)
THEN
hr_utility.set_message (800, 'XXQSC_SS_EXCEED_AMOUNT');
fnd_message.set_token (
'msg',
ROUND (
( xxqsc_hr_wf_pkg.get_entitled_edu_allow (
v_assignment_id,
SYSDATE)
* (v_entitled_smstr / 3))
- (NVL (v_proc, 0) + NVL (v_unproc, 0)),
2)
|| ' are entitled only for '
|| v_entitled_smstr
|| ' Semester(s)');
hr_utility.raise_error;
END IF;

IF TO_NUMBER(NVL (p_pei_information1, 0)) <>


TO_NUMBER(( NVL (p_pei_information9, 0) + NVL (p_pei_information11,
0) + NVL (p_pei_information12, 0) + NVL (p_pei_information14, 0) ))
THEN
hr_utility.set_message (800, 'XXQSC_SS_TOTAL_AMT_NOT_MATCH');
fnd_message.set_token (
'msg',
'Invoice Amount : ' || ROUND (p_pei_information1,2)
|| ' is not matching for total amount of
Admission,Tuition,Transport,Books Fees'
);
hr_utility.raise_error;
END IF;

IF to_number(NVL (p_pei_information1, 0)) > to_number(NVL


(p_pei_information15, 0))
THEN
hr_utility.set_message (800, 'XXQSC_SS_TOTAL_AMT_NOT_MATCH');
fnd_message.set_token (
'msg',
'Invoice Amount : ' || ROUND (p_pei_information1,2)
|| ' is more than remainig amount ( '|| ROUND
(p_pei_information15,2) || ' ) '
);
hr_utility.raise_error;
END IF;

END;
END IF;

-----------------------------------------Ticket First EMP Request


-- validation--------------------------------
IF p_information_type IN ('QSC_SS_FIRST_FINAL_TICKET_REQ')
THEN
DECLARE
v_nat VARCHAR2 (20)
:= xxqsc_hr_wf_pkg.get_employee_nationality (81, p_person_id);
BEGIN
IF v_nat = 'QATAR'
THEN
hr_utility.set_message (800, 'For Non Qatari');
hr_utility.raise_error;
END IF;

IF xxqsc_hr_wf_pkg.get_emp_status (p_person_id, 'attribute5') =


'HUSBAND'
AND ( p_pei_information4 IS NOT NULL
OR p_pei_information6 IS NOT NULL
OR p_pei_information8 IS NOT NULL
OR p_pei_information10 IS NOT NULL
OR p_pei_information12 IS NOT NULL)
THEN
hr_utility.set_message (800, 'XXQSC_SPONSOR');
hr_utility.raise_error;
END IF;
END;
END IF;

-----------------------------------------Ticket First HR Request


-- validation--------------------------------
IF p_information_type IN ('QSC_SS_FIRST_FINAL_TKT_HR_REQ')
THEN
DECLARE
v_nat VARCHAR2 (20)
:= xxqsc_hr_wf_pkg.get_employee_nationality (81, p_person_id);
BEGIN
IF v_nat = 'QATAR'
THEN
hr_utility.set_message (800, 'For Non Qatari');
hr_utility.raise_error;
END IF;

IF xxqsc_hr_wf_pkg.get_emp_status (p_person_id, 'attribute5') =


'HUSBAND'
AND ( p_pei_information5 IS NOT NULL
OR p_pei_information7 IS NOT NULL
OR p_pei_information9 IS NOT NULL
OR p_pei_information11 IS NOT NULL
OR p_pei_information13 IS NOT NULL)
THEN
hr_utility.set_message (800, 'XXQSC_SPONSOR');
hr_utility.raise_error;
END IF;
END;
END IF;

-----------------------------------------Ticket EMP Request validation


--------------------------------
IF p_information_type = 'QSC_SS_ANNUAL_TICKET_EMP_REQ'
THEN
DECLARE
v_nat VARCHAR2 (20)
:= xxqsc_hr_wf_pkg.get_employee_nationality (81, p_person_id);
BEGIN
IF v_nat = 'QATAR'
THEN
hr_utility.set_message (800, 'For Non Qatari');
hr_utility.raise_error;
END IF;

IF xxqsc_hr_wf_pkg.get_emp_status (p_person_id, 'attribute5') =


'HUSBAND'
AND ( p_pei_information3 IS NOT NULL
OR p_pei_information4 IS NOT NULL
OR p_pei_information5 IS NOT NULL
OR p_pei_information6 IS NOT NULL
OR p_pei_information7 IS NOT NULL)
THEN
hr_utility.set_message (800, 'XXQSC_SPONSOR');
hr_utility.raise_error;
END IF;
END;
END IF;

-----------------------------------------
QSC_SS_TRAVEL_ADVANCED----------------------
DECLARE
v_eligible_date DATE;
v_working_days NUMBER := 15;
BEGIN
SELECT ( fnd_date.canonical_to_date (P_PEI_INFORMATION10)
- v_working_days)
- (xxqsc_payroll.get_holidays (
p_start_date => fnd_date.canonical_to_date (
P_PEI_INFORMATION10)
- v_working_days,
p_end_date => fnd_date.canonical_to_date (
P_PEI_INFORMATION10)))
INTO v_eligible_date
FROM DUAL;

IF P_INFORMATION_TYPE = 'QSC_SS_BTR_ADVANC_PAY_REQ'
THEN
IF fnd_date.canonical_to_date (P_PEI_INFORMATION10)
- TRUNC (SYSDATE)
- xxqsc_payroll.get_holidays (
SYSDATE,
fnd_date.canonical_to_date (P_PEI_INFORMATION10)) >
v_working_days
THEN
-- raise_application_error (
-- -20555,
-- 'You are not Eligible to submit Advanced Per
Diem Request before : '
-- || v_eligible_date);
-- HR_UTILITY.RAISE_ERROR;

hr_utility.set_message (800, 'XXQSC_DYNAMIC_MESSAGE');


hr_utility.set_message_token (
'MESSAGE',
'You are not Eligible to submit Advanced Per Diem Request
before : '
|| v_eligible_date);
hr_utility.raise_error;
--ELSIF fnd_date.canonical_to_date (P_PEI_INFORMATION10) < SYSDATE
Commented by Ravindra
ELSIF fnd_date.canonical_to_date (P_PEI_INFORMATION10)+1 < SYSDATE --
added by Ravindra
THEN
-- raise_application_error (
-- -20556,
-- 'You are not Eligible to submit Advanced Per
Diem Request After Departure date which is : '
-- || fnd_date.canonical_to_date
(P_PEI_INFORMATION10));

hr_utility.set_message (800, 'XXQSC_DYNAMIC_MESSAGE');


hr_utility.set_message_token (
'MESSAGE',
'You are not Eligible to submit Advanced Per Diem Request
After Departure date which is : '
|| fnd_date.canonical_to_date (P_PEI_INFORMATION10));
hr_utility.raise_error;
HR_UTILITY.RAISE_ERROR;
END IF;
END IF;
END;

-----------------------------------------QSC_SS_DUTY_RESUMP_REQ
--------------------------------
IF p_information_type = 'QSC_SS_TRAVEL_RESUMP_REQ'
THEN
DECLARE
CURSOR c5
IS
SELECT 'X'
FROM per_people_extra_info a
WHERE a.person_id = p_person_id
AND a.information_type = 'QSC_SS_TRAVEL_RESUMP_REQ'
AND ( fnd_date.canonical_to_date (p_pei_information2)
BETWEEN fnd_date.canonical_to_date (

a.pei_information2)

AND fnd_date.canonical_to_date (

a.pei_information3)
OR fnd_date.canonical_to_date (p_pei_information3)
BETWEEN fnd_date.canonical_to_date (

a.pei_information2)

AND fnd_date.canonical_to_date (

a.pei_information3)
OR fnd_date.canonical_to_date (
p_pei_information10) BETWEEN
fnd_date.canonical_to_date (

a.pei_information10)
AND
fnd_date.canonical_to_date (

a.pei_information11)
OR fnd_date.canonical_to_date (
p_pei_information11) BETWEEN
fnd_date.canonical_to_date (

a.pei_information10)
AND
fnd_date.canonical_to_date (
a.pei_information11))
HAVING COUNT (*) > 0;

--
x5 CHAR (1);

--
CURSOR c_days
IS
SELECT NVL (a.nights_by_host_eshailsat, 0) host_days
FROM xxqsc_travel_authorization_v a
WHERE a.person_extra_info_id = p_pei_information13;

v_inf14 DATE
:= CASE
WHEN fnd_date.canonical_to_date (p_pei_information14) =
'01-Jan-2010'
THEN
NULL
ELSE
fnd_date.canonical_to_date (p_pei_information14)
END;
v_inf15 DATE
:= CASE
WHEN fnd_date.canonical_to_date (p_pei_information15) =
'01-Jan-2010'
THEN
NULL
ELSE
fnd_date.canonical_to_date (p_pei_information15)
END;
v_inf16 DATE
:= CASE
WHEN fnd_date.canonical_to_date (p_pei_information16) =
'01-Jan-2010'
THEN
NULL
ELSE
fnd_date.canonical_to_date (p_pei_information16)
END;
v_inf17 DATE
:= CASE
WHEN fnd_date.canonical_to_date (p_pei_information17) =
'01-Jan-2010'
THEN
NULL
ELSE
fnd_date.canonical_to_date (p_pei_information17)
END;
v_inf19 DATE
:= CASE
WHEN fnd_date.canonical_to_date (p_pei_information19) =
'01-Jan-2010'
THEN
NULL
ELSE
fnd_date.canonical_to_date (p_pei_information19)
END;
v_inf20 DATE
:= CASE
WHEN fnd_date.canonical_to_date (p_pei_information20) =
'01-Jan-2010'
THEN
NULL
ELSE
fnd_date.canonical_to_date (p_pei_information20)
END;
BEGIN
-------- Check if last day of bs date from greater than first day of bs
-- date
IF TRUNC (TO_DATE (p_pei_information2, 'RRRR-MM-DD HH24:MI:SS')) >
TRUNC (
TO_DATE (p_pei_information3, 'RRRR-MM-DD HH24:MI:SS'))
THEN
hr_utility.set_message (800, 'XXQSC_DUTY_RESUMP_ERR');
hr_utility.raise_error;
END IF;

-------- Check if first check in < departure date or < first day of bs
/* IF P_PEI_INFORMATION15 < P_PEI_INFORMATION10 or
P_PEI_INFORMATION15 < P_PEI_INFORMATION2 THEN
HR_UTILITY.SET_MESSAGE(800, 'XXQSC_DUTY_RESUMP_ERR');
HR_UTILITY.RAISE_ERROR;
END IF; */
-------- Check if return date < departure date
IF TRUNC (TO_DATE (p_pei_information10, 'RRRR-MM-DD HH24:MI:SS')) >
TRUNC (
TO_DATE (p_pei_information11, 'RRRR-MM-DD HH24:MI:SS'))
THEN
hr_utility.set_message (800, 'XXQSC_DUTY_RESUMP_ERR');
hr_utility.raise_error;
END IF;

---------- Check check in dates


/* IF P_PEI_INFORMATION15 < P_PEI_INFORMATION14 OR P_PEI_INFORMATION17
<
P_PEI_INFORMATION16
OR P_PEI_INFORMATION20 < P_PEI_INFORMATION19 then
HR_UTILITY.SET_MESSAGE(800, 'XXQSC_CHECK_DATES_ERR');
HR_UTILITY.RAISE_ERROR;
END IF;*/
---------- Check check in dates
/* IF P_PEI_INFORMATION16 between P_PEI_INFORMATION14 and
P_PEI_INFORMATION15
OR P_PEI_INFORMATION19 between P_PEI_INFORMATION16 and
P_PEI_INFORMATION17 then
HR_UTILITY.SET_MESSAGE(800, 'XXQSC_CHECK_DATES_ERR');
HR_UTILITY.RAISE_ERROR;
END IF;*/
---------- Check check in dates
/*IF P_PEI_INFORMATION16 < P_PEI_INFORMATION15
OR P_PEI_INFORMATION19 < P_PEI_INFORMATION16 then
HR_UTILITY.SET_MESSAGE(800, 'XXQSC_CHECK_DATES_ERR');
HR_UTILITY.RAISE_ERROR;
END IF;*/
--------------------- Check Overlaping
OPEN c5;
FETCH c5 INTO x5;

IF c5%FOUND
THEN
CLOSE c5;

hr_utility.set_message (800, 'XXQSC_DATE_ERR_DUTY');


hr_utility.raise_error;
ELSE
CLOSE c5;
END IF;
--------------
/* FOR R1 IN C_DAYS LOOP
IF R1.HOST_DAYS <>
nvl(v_inf15-v_inf14+1,0)
+ nvl(v_inf17-v_inf16+1,0)
+nvl(v_inf20-v_inf19+1,0)
then
HR_UTILITY.SET_MESSAGE(800, 'XXQSC_CHECK_IN_OUT_HOST_DAYS');
HR_UTILITY.RAISE_ERROR;
end if;
end loop;*/
END;
END IF;

-------- Travel Authorization Validation


-----------------------------------------------------------
IF p_information_type = 'QSC_SS_TRAVEL_AUTHORIZE_REQ'
THEN
DECLARE
CURSOR c1
IS
SELECT 'X'
FROM per_people_extra_info a
WHERE a.person_id = p_person_id
AND a.information_type = 'QSC_SS_TRAVEL_AUTHORIZE_REQ'
AND ( fnd_date.canonical_to_date (
p_pei_information10) BETWEEN
fnd_date.canonical_to_date (

a.pei_information10)
AND
fnd_date.canonical_to_date (

a.pei_information11)
OR fnd_date.canonical_to_date (
p_pei_information11) BETWEEN
fnd_date.canonical_to_date (

a.pei_information10)
AND
fnd_date.canonical_to_date (

a.pei_information11)
OR fnd_date.canonical_to_date (p_pei_information8)
BETWEEN fnd_date.canonical_to_date (

a.pei_information8)
AND fnd_date.canonical_to_date (

a.pei_information9)
OR fnd_date.canonical_to_date (p_pei_information9)
BETWEEN fnd_date.canonical_to_date (

a.pei_information8)

AND fnd_date.canonical_to_date (

a.pei_information9))
AND NVL (a.pei_information30, 'EMPTY') NOT IN
('CANCELED')
HAVING COUNT (*) > 0;

x CHAR (1);
v_departure_days NUMBER
:= GREATEST (
NVL (
xxqsc_hr_utility2.get_dest_days_per_diem (
p_person_id,
p_pei_information20),
0),
1);
BEGIN
--- check if departure date = first day of business and travel days >1
IF v_departure_days > 1
AND (p_pei_information8 = p_pei_information10)
THEN
hr_utility.set_message (800, 'XXQSC_TRAVEL_DAYS_ERR');
hr_utility.raise_error;
END IF;

-- check if return date < departure date


IF p_pei_information9 < p_pei_information8
THEN
hr_utility.set_message (800, 'XXQSC_DAT_END_> DAT_START_ERR');
hr_utility.raise_error;
END IF;

-- Last day of business < departure date or last day of business >
return
-- date
IF p_pei_information11 < p_pei_information8
OR p_pei_information11 > p_pei_information9
THEN
hr_utility.set_message (800, 'XXQSC_LAST_DATE<DEPARTURE_ERR');
hr_utility.raise_error;
END IF;

-- -- First day of business < departure date or First day of business >
-- return date
IF p_pei_information10 < p_pei_information8
OR p_pei_information10 > p_pei_information9
THEN
hr_utility.set_message (800, 'XXQSC_FIRST_DATE<DEPARTURE_ERR');
hr_utility.raise_error;
END IF;
----- Arranged By
IF p_pei_information7 = 'EMPLOYEE'
AND NVL (p_pei_information24, 0) > 0
THEN
hr_utility.set_message (800, 'XXQSC_ARRANGED_BY_EMP_ERR');
hr_utility.raise_error;
ELSIF p_pei_information7 IN ('EMP_HOST', 'EMP_ESHAILSAT')
AND ( NVL (p_pei_information21, 0) = 0
OR NVL (p_pei_information24, 0) = 0)
THEN
hr_utility.set_message (800, 'XXQSC_ARRANGED_HOST_ZERO_ERR');
hr_utility.raise_error;
--ELSIF P_PEI_INFORMATION7 IN ('ESHAILSAT','HOST') AND NVL(
-- P_PEI_INFORMATION21,0)>0 THEN
-- HR_UTILITY.SET_MESSAGE(800, 'XXQSC_ARRANGED_BY_HOST_ERR');
--HR_UTILITY.RAISE_ERROR;
END IF;

---------- TOTAL NIGHTS+DAYS


IF fnd_date.canonical_to_date (p_pei_information11)
- fnd_date.canonical_to_date (p_pei_information10)
+ 1 <>
NVL (p_pei_information24, 0) + NVL (p_pei_information21, 0)
THEN
hr_utility.set_message (800, 'XXQSC_NIGHTS_DAYS>BS_DAYS');
hr_utility.raise_error;
END IF;

-- Training days no more than 90 days


IF p_pei_information2 = 'TRAINING'
THEN
IF fnd_date.canonical_to_date (p_pei_information11)
- fnd_date.canonical_to_date (p_pei_information10)
+ 1 > 90
THEN
hr_utility.set_message (800,
'XXQSC_TRAINING_GREATER_90_ERR');
hr_utility.raise_error;
END IF;
END IF;

--- Nights by Employee or Host couldn't be negative


IF p_pei_information21 < 0 OR p_pei_information24 < 0
THEN
hr_utility.set_message (800, 'XXQSC_NEGATIVE_VALUE_ERR');
hr_utility.raise_error;
END IF;

---------- No Duplicate
OPEN c1;

FETCH c1 INTO x;

IF c1%FOUND
THEN
CLOSE c1;

hr_utility.set_message (800, 'XXQSC_DATE_ERR');


hr_utility.raise_error;
ELSE
CLOSE c1;
END IF;
END;
END IF;

-----------------------------------------Ticket HR Request validation


--------------------------------
/* IF P_INFORMATION_TYPE = 'QSC_SS_ANNUAL_TICKET_HR_REQ' THEN
DECLARE
V_TICKET_VAL NUMBER := 0;
BEGIN
-- Check if the employee entitled
-- Check if the amount iss correct
IF XXQSC_HR_WF_PKG.get_emp_status(P_PERSON_ID,'attribute5') = 'HUSBAND'
AND (P_PEI_INFORMATION4 IS NOT NULL OR P_PEI_INFORMATION6 IS NOT NULL OR
P_PEI_INFORMATION8 IS NOT NULL OR P_PEI_INFORMATION10 IS NOT NULL OR
P_PEI_INFORMATION12 IS NOT NULL) THEN
HR_UTILITY.SET_MESSAGE(800, 'XXQSC_SPONSOR');
HR_UTILITY.RAISE_ERROR;
END IF;
IF P_PEI_INFORMATION3 IS NOT NULL AND
\* V_TICKET_VAL :=*\ NVL(xxqsc_HR_WF_PKG.get_ticket_val(P_PERSON_ID),
0) < P_PEI_INFORMATION3 THEN
HR_UTILITY.SET_MESSAGE(800, 'The parent ticket is '||NVL(
xxqsc_HR_WF_PKG.get_ticket_val(P_PERSON_ID),
0));
HR_UTILITY.RAISE_ERROR;
END IF;
IF P_PEI_INFORMATION5 IS NOT NULL AND
\*V_TICKET_VAL := V_TICKET_VAL +*\ NVL(xxqsc_HR_WF_PKG.get_ticket_val(
P_PERSON_ID),
0)<P_PEI_INFORMATION5 THEN
HR_UTILITY.SET_MESSAGE(800, 'The spouse ticket '||NVL(
xxqsc_HR_WF_PKG.get_ticket_val(P_PERSON_ID),
0));
HR_UTILITY.RAISE_ERROR;
END IF;
IF P_PEI_INFORMATION7 IS NOT NULL AND
\*V_TICKET_VAL := V_TICKET_VAL +*\ NVL(xxqsc_HR_WF_PKG.get_contact_ticket(
P_PERSON_ID,
xxqsc_HR_WF_PKG.get_contact_age(P_PERSON_ID,
P_PEI_INFORMATION6)),
0)<P_PEI_INFORMATION7 THEN
HR_UTILITY.SET_MESSAGE(800, 'The child1 ticket '||NVL(
xxqsc_HR_WF_PKG.get_contact_ticket(P_PERSON_ID,
xxqsc_HR_WF_PKG.get_contact_age(P_PERSON_ID,
P_PEI_INFORMATION6)),
0));
HR_UTILITY.RAISE_ERROR;
END IF;
IF P_PEI_INFORMATION9 IS NOT NULL AND
\*V_TICKET_VAL := V_TICKET_VAL + *\NVL(xxqsc_HR_WF_PKG.get_contact_ticket(
P_PERSON_ID,
xxqsc_HR_WF_PKG.get_contact_age(P_PERSON_ID,
P_PEI_INFORMATION8)),
0)<P_PEI_INFORMATION9 THEN
HR_UTILITY.SET_MESSAGE(800, 'The child2 ticket '||NVL(
xxqsc_HR_WF_PKG.get_contact_ticket(P_PERSON_ID,
xxqsc_HR_WF_PKG.get_contact_age(P_PERSON_ID,
P_PEI_INFORMATION8)),
0));
HR_UTILITY.RAISE_ERROR;
END IF;
IF P_PEI_INFORMATION11 IS NOT NULL AND
\*V_TICKET_VAL := V_TICKET_VAL + *\NVL(xxqsc_HR_WF_PKG.get_contact_ticket(
P_PERSON_ID,
xxqsc_HR_WF_PKG.get_contact_age(P_PERSON_ID,
P_PEI_INFORMATION10)),
0)<P_PEI_INFORMATION11 THEN
HR_UTILITY.SET_MESSAGE(800, 'The child3 ticket '||NVL(
xxqsc_HR_WF_PKG.get_contact_ticket(P_PERSON_ID,
xxqsc_HR_WF_PKG.get_contact_age(P_PERSON_ID,
P_PEI_INFORMATION10)),
0));
HR_UTILITY.RAISE_ERROR;
END IF;
IF P_PEI_INFORMATION13 IS NOT NULL AND
\* V_TICKET_VAL := V_TICKET_VAL + *\NVL(xxqsc_HR_WF_PKG.get_contact_ticket(
P_PERSON_ID,
xxqsc_HR_WF_PKG.get_contact_age(P_PERSON_ID,
P_PEI_INFORMATION12)),
0)<P_PEI_INFORMATION13 THEN
HR_UTILITY.SET_MESSAGE(800, 'The child4 ticket '||NVL(
xxqsc_HR_WF_PKG.get_contact_ticket(P_PERSON_ID,
xxqsc_HR_WF_PKG.get_contact_age(P_PERSON_ID,
P_PEI_INFORMATION13)),
0));
HR_UTILITY.RAISE_ERROR;
END IF;
END;
END IF; */
-- Validate Baggage Allowance
IF p_information_type = 'QSC_SS_BAGGAGE_ALLOWANCE_REQ'
THEN
DECLARE
v_adult_bag_val NUMBER := 0;
v_child_bag_val NUMBER := 0;
BEGIN
IF p_pei_information2 IS NOT NULL
THEN
v_adult_bag_val :=
v_adult_bag_val
+ xxqsc_hr_wf_pkg.get_contact_baggage (p_pei_information2,
'ADULT',
p_pei_information1);
END IF;

IF p_pei_information3 IS NOT NULL


THEN
v_adult_bag_val :=
v_adult_bag_val
+ xxqsc_hr_wf_pkg.get_contact_baggage (p_pei_information2,
'ADULT',
p_pei_information1);
END IF;

IF p_pei_information4 IS NOT NULL


THEN
IF xxqsc_hr_wf_pkg.get_contact_age (p_pei_information2,
p_pei_information4) =
'ADULT'
THEN
v_adult_bag_val :=
v_adult_bag_val
+ xxqsc_hr_wf_pkg.get_contact_baggage (
p_pei_information2,
'ADULT',
p_pei_information1);
ELSE
v_child_bag_val :=
v_child_bag_val
+ xxqsc_hr_wf_pkg.get_contact_baggage (
p_pei_information2,
'CHILD',
p_pei_information1);
END IF;
END IF;

IF p_pei_information5 IS NOT NULL


THEN
IF xxqsc_hr_wf_pkg.get_contact_age (p_pei_information2,
p_pei_information5) =
'ADULT'
THEN
v_adult_bag_val :=
v_adult_bag_val
+ xxqsc_hr_wf_pkg.get_contact_baggage (
p_pei_information2,
'ADULT',
p_pei_information1);
ELSE
v_child_bag_val :=
v_child_bag_val
+ xxqsc_hr_wf_pkg.get_contact_baggage (
p_pei_information2,
'CHILD',
p_pei_information1);
END IF;
END IF;

IF p_pei_information6 IS NOT NULL


THEN
IF xxqsc_hr_wf_pkg.get_contact_age (p_pei_information2,
p_pei_information6) =
'ADULT'
THEN
v_adult_bag_val :=
v_adult_bag_val
+ xxqsc_hr_wf_pkg.get_contact_baggage (
p_pei_information2,
'ADULT',
p_pei_information1);
ELSE
v_child_bag_val :=
v_child_bag_val
+ xxqsc_hr_wf_pkg.get_contact_baggage (
p_pei_information2,
'CHILD',
p_pei_information1);
END IF;
END IF;

IF p_pei_information7 IS NOT NULL


THEN
IF xxqsc_hr_wf_pkg.get_contact_age (p_pei_information2,
p_pei_information7) =
'ADULT'
THEN
v_adult_bag_val :=
v_adult_bag_val
+ xxqsc_hr_wf_pkg.get_contact_baggage (
p_pei_information2,
'ADULT',
p_pei_information1);
ELSE
v_child_bag_val :=
v_child_bag_val
+ xxqsc_hr_wf_pkg.get_contact_baggage (
p_pei_information2,
'CHILD',
p_pei_information1);
END IF;
END IF;

--
IF v_adult_bag_val < NVL (p_pei_information8, 0)
OR v_child_bag_val < NVL (p_pei_information9, 0)
THEN
hr_utility.set_message (
800,
'Adult kg to be '
|| v_adult_bag_val
|| ' Child kg '
|| v_child_bag_val);
hr_utility.raise_error;
END IF;
END;
END IF;

--------------------- Incensive Long Term ---------------------------------


IF p_information_type = 'QSC_SS_LONG_TERM_INC_REQUEST'
THEN
FOR w IN c_prob_period
LOOP
v_prob := w.prob_pass;
END LOOP;

v_nat := xxqsc_hr_wf_pkg.get_employee_nationality (81, p_person_id);

IF NVL (v_prob, 'N') <> 'Y'


THEN
hr_utility.set_message (800, 'XXQSC_CARLOAN_RENEWAL_PROB');
hr_utility.raise_error;
ELSE
IF v_nat <> 'QATAR'
THEN
hr_utility.set_message (800, 'XXQSC_SOCIAL_EMR_LOAN_VALID');
hr_utility.raise_error;
END IF;

IF p_pei_information3 < 1
THEN
hr_utility.set_message (800, 'XXQSC_DYNAMIC_MESSAGE');
hr_utility.set_message_token (
'MESSAGE',
'You are not Eligible to submit Long Term Incentive Request,
before completing 5 years of service');
hr_utility.raise_error;
END IF;
END IF;
END IF;

IF p_information_type = 'QSC_SS_ANNUAL_LEAVE_PLAN_REQ'
THEN
V_RESULT :=
XX_HR_PKG.GET_VACATION_PLAN_EXIST (
p_person_id,
TO_DATE (p_pei_information2, 'RRRR/MM/DD HH24:MI:SS'),
TO_DATE (p_pei_information3, 'RRRR/MM/DD HH24:MI:SS'),
-- TO_DATE (FND_DATE.CANONICAL_TO_DATE
(p_pei_information2), 'DD/MM/RRRR'),
-- TO_DATE (FND_DATE.CANONICAL_TO_DATE
(p_pei_information3), 'DD/MM/RRRR'),
V_START_DATE,
V_END_dATE);

IF V_RESULT = 1
THEN
V_START_DATE :=
INITCAP (TO_CHAR (TO_DATE (V_START_DATE), 'DD-MON-RRRR'));
V_END_dATE :=
INITCAP (TO_CHAR (TO_DATE (V_END_dATE), 'DD-MON-RRRR'));

hr_utility.set_message (800, 'XXQSC_DYNAMIC_MESSAGE');


hr_utility.set_message_token (
'MESSAGE',
'Overlab Between Vacation Plan Exist From '
|| V_START_DATE
|| ' to '
|| V_END_dATE);
hr_utility.raise_error;
END IF;

V_COUNT := XX_HR_PKG.GET_NET_BALANCE_ANNUAL (p_person_id);

SELECT SUM (PEI_INFORMATION4)


INTO V_NUM
FROM per_people_extra_info
WHERE pei_information_category = 'QSC_SS_ANNUAL_LEAVE_PLAN_REQ'
AND PERSON_ID = p_person_id
AND EXTRACT (
YEAR FROM FND_DATE.CANONICAL_TO_DATE (
PEI_INFORMATION2)) =
EXTRACT (YEAR FROM SYSDATE);

IF V_NUM + p_pei_information4 > V_COUNT


THEN
V_NUM := V_NUM + p_pei_information4 - V_COUNT;
hr_utility.set_message (800, 'XXQSC_DYNAMIC_MESSAGE');
hr_utility.set_message_token (
'MESSAGE',
'Vacation Plan Duration is more than balance by '
|| V_NUM
|| ' Day(s)');
hr_utility.raise_error;
END IF;
END IF;
END create_person_extra_info_b;

---------------------
PROCEDURE create_person_extra_info_a (
p_person_id NUMBER,
p_information_type VARCHAR2,
p_pei_attribute_category VARCHAR2,
p_pei_attribute1 VARCHAR2,
p_pei_attribute2 VARCHAR2,
p_pei_attribute3 VARCHAR2,
p_pei_attribute4 VARCHAR2,
p_pei_attribute5 VARCHAR2,
p_pei_attribute6 VARCHAR2,
p_pei_attribute7 VARCHAR2,
p_pei_attribute8 VARCHAR2,
p_pei_attribute9 VARCHAR2,
p_pei_attribute10 VARCHAR2,
p_pei_attribute11 VARCHAR2,
p_pei_attribute12 VARCHAR2,
p_pei_attribute13 VARCHAR2,
p_pei_attribute14 VARCHAR2,
p_pei_attribute15 VARCHAR2,
p_pei_attribute16 VARCHAR2,
p_pei_attribute17 VARCHAR2,
p_pei_attribute18 VARCHAR2,
p_pei_attribute19 VARCHAR2,
p_pei_attribute20 VARCHAR2,
p_pei_information_category VARCHAR2,
p_pei_information1 VARCHAR2,
p_pei_information2 VARCHAR2,
p_pei_information3 VARCHAR2,
p_pei_information4 VARCHAR2,
p_pei_information5 VARCHAR2,
p_pei_information6 VARCHAR2,
p_pei_information7 VARCHAR2,
p_pei_information8 VARCHAR2,
p_pei_information9 VARCHAR2,
p_pei_information10 VARCHAR2,
p_pei_information11 VARCHAR2,
p_pei_information12 VARCHAR2,
p_pei_information13 VARCHAR2,
p_pei_information14 VARCHAR2,
p_pei_information15 VARCHAR2,
p_pei_information16 VARCHAR2,
p_pei_information17 VARCHAR2,
p_pei_information18 VARCHAR2,
p_pei_information19 VARCHAR2,
p_pei_information20 VARCHAR2,
p_pei_information21 VARCHAR2,
p_pei_information22 VARCHAR2,
p_pei_information23 VARCHAR2,
p_pei_information24 VARCHAR2,
p_pei_information25 VARCHAR2,
p_pei_information26 VARCHAR2,
p_pei_information27 VARCHAR2,
p_pei_information28 VARCHAR2,
p_pei_information29 VARCHAR2,
p_pei_information30 VARCHAR2)
AS
--v_assignment_id number := xxqsc_hr_wf_pkg.get_person_assignmnet_id(
-- p_person_id);
CURSOR c_get_assignment_id
IS
SELECT f.assignment_id
FROM per_all_assignments_f f
WHERE f.person_id = p_person_id
AND SYSDATE BETWEEN f.effective_start_date
AND f.effective_end_date
AND f.primary_flag = 'Y';

CURSOR c_pay_id (
p_ass_id NUMBER)
IS
SELECT personal_payment_method_id,
external_account_id,
effective_start_date,
effective_end_date,
object_version_number
FROM pay_personal_payment_methods_f
WHERE assignment_id = p_ass_id
AND TRUNC (SYSDATE) BETWEEN effective_start_date
AND effective_end_date;

v_assignment_id NUMBER
:= xxqsc_hr_wf_pkg.get_person_assignmnet_id (p_person_id);
v_element_link_id NUMBER;
v_effective_start_date DATE;
v_effective_end_date DATE;
v_element_entry_id NUMBER;
v_create_warning BOOLEAN;
v_update_warning BOOLEAN;
v_object_version_number NUMBER;
v_effective_date DATE := SYSDATE;
v_pay_id NUMBER;
v_ext_id NUMBER;
o_comment_id NUMBER;
o_effective_start_date DATE;
o_effective_end_date DATE;
o_external_account_id NUMBER;
v_mean VARCHAR2 (100);
v_number NUMBER := 2;
v_abs NUMBER;
v_version_number NUMBER;
v_occurence NUMBER;
v_days BOOLEAN;
v_hours BOOLEAN;
v_extend BOOLEAN;
v_run BOOLEAN;
v_override BOOLEAN;
v_abs_day BOOLEAN;
v_warning BOOLEAN;

--v_number_days NUMBER;
CURSOR c_abs
IS
SELECT absence_attendance_id,
business_group_id,
absence_attendance_type_id,
abs_attendance_reason_id,
person_id,
authorising_person_id,
replacement_person_id,
period_of_incapacity_id,
absence_days,
absence_hours,
date_end,
date_notification,
date_projected_end,
date_projected_start,
date_start,
occurrence,
ssp1_issued,
time_end,
time_projected_end,
time_projected_start,
time_start,
request_id,
program_application_id,
program_id,
program_update_date,
attribute_category,
attribute1,
attribute2,
attribute3,
attribute4,
attribute5,
attribute6,
attribute7,
attribute8,
attribute9,
attribute10,
attribute11,
attribute12,
attribute13,
attribute14,
attribute15,
attribute16,
attribute17,
attribute18,
attribute19,
attribute20,
last_update_date,
last_updated_by,
last_update_login,
created_by,
creation_date,
maternity_id,
sickness_start_date,
sickness_end_date,
pregnancy_related_illness,
reason_for_notification_delay,
accept_late_notification_flag,
linked_absence_id,
batch_id,
abs_information_category,
abs_information1,
abs_information2,
abs_information3,
abs_information4,
abs_information5,
abs_information6,
abs_information7,
abs_information8,
abs_information9,
abs_information10,
abs_information11,
abs_information12,
abs_information13,
abs_information14,
abs_information15,
abs_information16,
abs_information17,
abs_information18,
abs_information19,
abs_information20,
abs_information21,
abs_information22,
abs_information23,
abs_information24,
abs_information25,
abs_information26,
abs_information27,
abs_information28,
abs_information29,
abs_information30,
object_version_number,
comments,
absence_case_id,
approval_status,
confirmed_until,
SOURCE,
advance_pay
FROM xxper_absence_attendances
WHERE absence_attendance_id = p_pei_information1;
BEGIN
FOR i IN c_get_assignment_id
LOOP
v_assignment_id := i.assignment_id;
END LOOP;

v_effective_date := TRUNC (SYSDATE);

IF p_information_type = 'QSC_SS_MOBILE_SET_REQUEST'
THEN
DECLARE
BEGIN
IF TO_NUMBER (TO_CHAR (TRUNC (SYSDATE), 'DD')) > 22
THEN
v_effective_date :=
TRUNC (ADD_MONTHS (TRUNC (SYSDATE, 'MM'), 1), 'MM');
v_effective_start_date :=
TRUNC (ADD_MONTHS (TRUNC (SYSDATE, 'MM'), 1), 'MM');
v_effective_end_date :=
LAST_DAY (TRUNC (ADD_MONTHS (TRUNC (SYSDATE), 1)));
END IF;

v_element_link_id :=
hr_entry_api.get_link (
p_assignment_id => v_assignment_id,
p_element_type_id => xxqsc_payroll.get_element_type_id (
p_business_group_id => 81,
p_element_name => 'Mobile Set
Allowance'),
p_session_date => v_effective_date);
pay_element_entry_api.create_element_entry (
p_effective_date => v_effective_date,
p_business_group_id => 81,
p_assignment_id => v_assignment_id,
p_element_link_id => v_element_link_id,
p_entry_type => 'E',
p_creator_type => 'F',
p_effective_start_date => v_effective_start_date,
p_effective_end_date => v_effective_end_date,
p_element_entry_id => v_element_entry_id,
p_object_version_number => v_object_version_number,
p_create_warning => v_create_warning);
/* hr_utility.set_message
(800,
'date'||v_effective_date|| v_assignment_id ||V_ELEMENT_LINK_ID||
V_ELEMENT_ENTRY_ID
);
hr_utility.raise_error;
*/
END;
END IF;

------------------------ticket allowance-------------------------------
IF p_information_type = 'QSC_SS_FIRST_FINAL_TKT_HR_REQ'
THEN
DECLARE
v_ticket_val NUMBER := 0;
v_input1 NUMBER;
v_input2 NUMBER;
BEGIN
/*hr_utility.set_message (800,p_information_type);
hr_utility.raise_error;*/
IF p_pei_information2 = 'FAMILY_JOIN'
THEN
v_element_link_id :=
hr_entry_api.get_link (
p_assignment_id => v_assignment_id,
p_element_type_id => xxqsc_payroll.get_element_type_id (
p_business_group_id => 81,
p_element_name => 'Family
Joining Ticket Payment'),
p_session_date => v_effective_date);
v_input2 :=
xxqsc_hr_wf_pkg.get_input_id (
'Family Joining Ticket Payment',
'Ticket Price'); --828;
v_input1 :=
xxqsc_hr_wf_pkg.get_input_id (
'Family Joining Ticket Payment',
'Name of Beneficiary'); --1056;
ELSIF p_pei_information2 = 'FIRST_ARRIVAL'
THEN
v_element_link_id :=
hr_entry_api.get_link (
p_assignment_id => v_assignment_id,
p_element_type_id => xxqsc_payroll.get_element_type_id (
p_business_group_id => 81,
p_element_name => 'First
Arrival Ticket Payment'),
p_session_date => v_effective_date);
v_input2 :=
xxqsc_hr_wf_pkg.get_input_id (
'First Arrival Ticket Payment',
'Ticket Price'); --828;
v_input1 :=
xxqsc_hr_wf_pkg.get_input_id (
'First Arrival Ticket Payment',
'Name of Beneficiary'); --1056;
ELSIF p_pei_information2 = 'LAST_DEPARTURE'
THEN
v_element_link_id :=
hr_entry_api.get_link (
p_assignment_id => v_assignment_id,
p_element_type_id => xxqsc_payroll.get_element_type_id (
p_business_group_id => 81,
p_element_name => 'Last
Departure Ticket Payment'),
p_session_date => v_effective_date);
v_input2 :=
xxqsc_hr_wf_pkg.get_input_id (
'Last Departure Ticket Payment',
'Ticket Price'); --828;
v_input1 :=
xxqsc_hr_wf_pkg.get_input_id (
'Last Departure Ticket Payment',
'Name of Beneficiary'); --1056;
END IF;
-- Check if the amount iss correct
IF p_pei_information4 IS NOT NULL
THEN
-- PARENT
pay_element_entry_api.create_element_entry (
p_effective_date => v_effective_date,
p_business_group_id => 81,
p_assignment_id => v_assignment_id,
p_element_link_id => v_element_link_id,
p_entry_type => 'E',
--p_input_value_id1 => 713,
p_input_value_id2 => v_input1,
p_input_value_id3 => v_input2,
--p_entry_value1 => P_PEI_INFORMATION2,
p_entry_value2 => p_pei_information3,
p_entry_value3 => p_pei_information4,
p_effective_start_date => v_effective_start_date,
p_effective_end_date => v_effective_end_date,
p_element_entry_id => v_element_entry_id,
p_object_version_number => v_object_version_number,
p_create_warning => v_create_warning);
END IF;

IF p_pei_information6 IS NOT NULL


THEN
-- SPOUSE
pay_element_entry_api.create_element_entry (
p_effective_date => v_effective_date,
p_business_group_id => 81,
p_assignment_id => v_assignment_id,
p_element_link_id => v_element_link_id,
p_entry_type => 'E',
--p_input_value_id1 => 713,
p_input_value_id2 => v_input1,
p_input_value_id3 => v_input2,
--p_entry_value1 => P_PEI_INFORMATION2,
p_entry_value2 => p_pei_information5,
p_entry_value3 => p_pei_information6,
p_effective_start_date => v_effective_start_date,
p_effective_end_date => v_effective_end_date,
p_element_entry_id => v_element_entry_id,
p_object_version_number => v_object_version_number,
p_create_warning => v_create_warning);
END IF;

IF p_pei_information8 IS NOT NULL


THEN
-- CHILD1
pay_element_entry_api.create_element_entry (
p_effective_date => v_effective_date,
p_business_group_id => 81,
p_assignment_id => v_assignment_id,
p_element_link_id => v_element_link_id,
p_entry_type => 'E',
--p_input_value_id1 => 713,
p_input_value_id2 => v_input1,
p_input_value_id3 => v_input2,
--p_entry_value1 => P_PEI_INFORMATION2,
p_entry_value2 => p_pei_information7,
p_entry_value3 => p_pei_information8,
p_effective_start_date => v_effective_start_date,
p_effective_end_date => v_effective_end_date,
p_element_entry_id => v_element_entry_id,
p_object_version_number => v_object_version_number,
p_create_warning => v_create_warning);
END IF;

IF p_pei_information10 IS NOT NULL


THEN
-- CHILD2
pay_element_entry_api.create_element_entry (
p_effective_date => v_effective_date,
p_business_group_id => 81,
p_assignment_id => v_assignment_id,
p_element_link_id => v_element_link_id,
p_entry_type => 'E',
--p_input_value_id1 => 713,
p_input_value_id2 => v_input1,
p_input_value_id3 => v_input2,
--p_entry_value1 => P_PEI_INFORMATION2,
p_entry_value2 => p_pei_information9,
p_entry_value3 => p_pei_information10,
p_effective_start_date => v_effective_start_date,
p_effective_end_date => v_effective_end_date,
p_element_entry_id => v_element_entry_id,
p_object_version_number => v_object_version_number,
p_create_warning => v_create_warning);
END IF;

IF p_pei_information12 IS NOT NULL


THEN
-- CHILD3
pay_element_entry_api.create_element_entry (
p_effective_date => v_effective_date,
p_business_group_id => 81,
p_assignment_id => v_assignment_id,
p_element_link_id => v_element_link_id,
p_entry_type => 'E',
--p_input_value_id1 => 713,
p_input_value_id2 => v_input1,
p_input_value_id3 => v_input2,
--p_entry_value1 => P_PEI_INFORMATION2,
p_entry_value2 => p_pei_information11,
p_entry_value3 => p_pei_information12,
p_effective_start_date => v_effective_start_date,
p_effective_end_date => v_effective_end_date,
p_element_entry_id => v_element_entry_id,
p_object_version_number => v_object_version_number,
p_create_warning => v_create_warning);
END IF;

IF p_pei_information14 IS NOT NULL


THEN
-- CHILD4
pay_element_entry_api.create_element_entry (
p_effective_date => v_effective_date,
p_business_group_id => 81,
p_assignment_id => v_assignment_id,
p_element_link_id => v_element_link_id,
p_entry_type => 'E',
--p_input_value_id1 => 713,
p_input_value_id2 => v_input1,
p_input_value_id3 => v_input2,
--p_entry_value1 => P_PEI_INFORMATION2,
p_entry_value2 => p_pei_information13,
p_entry_value3 => p_pei_information14,
p_effective_start_date => v_effective_start_date,
p_effective_end_date => v_effective_end_date,
p_element_entry_id => v_element_entry_id,
p_object_version_number => v_object_version_number,
p_create_warning => v_create_warning);
END IF;
END;
END IF;

----------------------------------Furniture Maintenance Request


/* IF p_information_type = 'QSC_SS_FURNITURE_MAINTAIN_REQ'
THEN
DECLARE
BEGIN
if TO_NUMBER(to_char(TRUNC (SYSDATE),'DD'))>22 THEN
v_effective_date := trunc(add_months(trunc(sysdate,'MM'),1),'MM');
v_effective_start_date := trunc(add_months(trunc(sysdate,'MM'),1),'MM');
v_effective_end_date:=last_day(trunc(Add_months(trunc(sysdate),1)));
end if;
v_element_link_id :=
hr_entry_api.get_link
(p_assignment_id => v_assignment_id,
p_element_type_id => xxqsc_payroll.get_element_type_id
(p_business_group_id => 81,
p_element_name => 'Furnishing Maintenance Allowance Calculation'
),
p_session_date => v_effective_date
);
pay_element_entry_api.create_element_entry
(p_effective_date => v_effective_date,
p_business_group_id => 81,
p_assignment_id => v_assignment_id,
p_element_link_id => v_element_link_id,
p_entry_type => 'E',
-- p_input_value_id1 => 274,
-- p_entry_value1 => 'No',
p_effective_start_date => v_effective_start_date,
p_effective_end_date => v_effective_end_date,
p_element_entry_id => v_element_entry_id,
p_object_version_number => v_object_version_number,
p_create_warning => v_create_warning
);
END;
END IF;
----------------------------------Furniture Grant Request
IF p_information_type = 'QSC_SS_FURNITURE_GRANT_REQ'
THEN
DECLARE
BEGIN
if TO_NUMBER(to_char(TRUNC (SYSDATE),'DD'))>22 THEN
v_effective_date := trunc(add_months(trunc(sysdate,'MM'),1),'MM');
v_effective_start_date := trunc(add_months(trunc(sysdate,'MM'),1),'MM');
v_effective_end_date:=last_day(trunc(Add_months(trunc(sysdate),1)));
end if;
v_element_link_id :=
hr_entry_api.get_link
(p_assignment_id => v_assignment_id,
p_element_type_id => xxqsc_payroll.get_element_type_id
(p_business_group_id => 81,
p_element_name => 'Furniture Grant Calculation'
),
p_session_date => v_effective_date
);
pay_element_entry_api.create_element_entry
(p_effective_date => v_effective_date,
p_business_group_id => 81,
p_assignment_id => v_assignment_id,
p_element_link_id => v_element_link_id,
p_entry_type => 'E',
p_input_value_id1 => 274,
p_entry_value1 => 'No',
p_effective_start_date => v_effective_start_date,
p_effective_end_date => v_effective_end_date,
p_element_entry_id => v_element_entry_id,
p_object_version_number => v_object_version_number,
p_create_warning => v_create_warning
);
END;
END IF;*/

----------------------------------Furniture Grant Request


IF p_information_type = 'QSC_SS_FURNITURE_GRANT_REQ'
THEN
DECLARE
BEGIN
IF TO_NUMBER (TO_CHAR (TRUNC (SYSDATE), 'DD')) > 22
THEN
NULL;
v_effective_date := TRUNC (SYSDATE);
-- v_effective_date :=
-- TRUNC (ADD_MONTHS (TRUNC (SYSDATE, 'MM'), 1),
'MM');
-- v_effective_start_date :=
-- TRUNC (ADD_MONTHS (TRUNC (SYSDATE, 'MM'), 1),
'MM');
-- v_effective_end_date :=
-- LAST_DAY (TRUNC (ADD_MONTHS (TRUNC (SYSDATE), 1)));
END IF;

v_element_link_id :=
hr_entry_api.get_link (
p_assignment_id => v_assignment_id,
p_element_type_id => xxqsc_payroll.get_element_type_id (
p_business_group_id => 81,
p_element_name => 'Furniture
Allowance' -- 'Furniture Grant
Calculation'

),
p_session_date => v_effective_date);

pay_element_entry_api.create_element_entry (
p_effective_date => v_effective_date,
p_business_group_id => 81,
p_assignment_id => v_assignment_id,
p_element_link_id => v_element_link_id,
p_entry_type => 'E',
-- p_input_value_id1 => 274,
-- p_entry_value1 => 'No',
p_effective_start_date => v_effective_start_date,
p_effective_end_date => v_effective_end_date,
p_element_entry_id => v_element_entry_id,
p_object_version_number => v_object_version_number,
p_create_warning => v_create_warning);
END;
END IF;

----- Baggage Allowance action-----------------------------


/* IF p_information_type = 'QSC_SS_BAGGAGE_ALLOWANCE_REQ'
THEN
DECLARE
BEGIN
if TO_NUMBER(to_char(TRUNC (SYSDATE),'DD'))>22 THEN
v_effective_date := trunc(add_months(trunc(sysdate,'MM'),1),'MM');
v_effective_start_date := trunc(add_months(trunc(sysdate,'MM'),1),'MM');
v_effective_end_date:=last_day(trunc(Add_months(trunc(sysdate),1)));
end if;
v_element_link_id :=
hr_entry_api.get_link
(p_assignment_id => v_assignment_id,
p_element_type_id => xxqsc_payroll.get_element_type_id
(p_business_group_id => 0,
p_element_name => 'Baggage Allowance'
),
p_session_date => v_effective_date
);
pay_element_entry_api.create_element_entry
(p_effective_date => v_effective_date,
p_business_group_id => 0,
p_assignment_id => v_assignment_id,
p_element_link_id => v_element_link_id,
p_entry_type => 'E',
p_input_value_id1 => 601,
p_entry_value1 =>

p_effective_start_date => v_effective_start_date,


p_effective_end_date => v_effective_end_date,
p_element_entry_id => v_element_entry_id,
p_object_version_number => v_object_version_number,
p_create_warning => v_create_warning
);
END;
END IF;*/
------social request action------------------------------------------
IF p_information_type = 'QSC_SS_SOCIAL_LOAN_REQUEST'
THEN
DECLARE
BEGIN

IF TO_NUMBER (TO_CHAR (TRUNC (SYSDATE), 'DD')) > 22


THEN
v_effective_date :=
TRUNC (ADD_MONTHS (TRUNC (SYSDATE, 'MM'), 1), 'MM');
v_effective_start_date :=
TRUNC (ADD_MONTHS (TRUNC (SYSDATE, 'MM'), 1), 'MM');
v_effective_end_date :=
LAST_DAY (TRUNC (ADD_MONTHS (TRUNC (SYSDATE), 1)));
END IF;

--hr_utility.set_message (800, 'XXQSC_DYNAMIC_MESSAGE');


-- hr_utility.set_message_token (
-- 'MESSAGE',
-- 'Errors are :'||v_effective_start_date);
---hr_utility.raise_error;

v_element_link_id :=
hr_entry_api.get_link (
p_assignment_id => v_assignment_id,
p_element_type_id => xxqsc_payroll.get_element_type_id (
p_business_group_id => 81,
p_element_name => 'Social Loan'),
p_session_date => v_effective_date);

pay_element_entry_api.create_element_entry (
p_effective_date => v_effective_date,
p_business_group_id => 81,
p_assignment_id => v_assignment_id,
p_element_link_id => v_element_link_id,
p_entry_type => 'E',
/* p_input_value_id1 => 372,
p_input_value_id2 => 373,
p_entry_value1 => p_pei_information2,
p_entry_value2 => p_pei_information3,*/
p_effective_start_date => v_effective_start_date,
p_effective_end_date => v_effective_end_date,
p_element_entry_id => v_element_entry_id,
p_object_version_number => v_object_version_number,
p_create_warning => v_create_warning);
END;
END IF;

--------------------- QSC_SS_FIRST_FINAL_TICKET_REQ ( integration with


Element Enteries Payroll)--------------------
-- IF p_information_type = 'QSC_SS_FIRST_FINAL_TICKET_REQ'
-- THEN
-- DECLARE
-- v_ticket_val NUMBER := 0;
-- v_input1 NUMBER;
-- v_input2 NUMBER;
-- BEGIN
-- IF p_pei_information2 = 'FAMILY_JOIN' and p_pei_information1 =
'CASH'
--
-- THEN
-- v_element_link_id :=
-- hr_entry_api.get_link
-- (p_assignment_id => v_assignment_id,
-- p_element_type_id =>
xxqsc_payroll.get_element_type_id
-- (p_business_group_id
=> 81,
-- p_element_name
=> 'Family Joining Ticket Payment'
-- ),
-- p_session_date => v_effective_date
-- );
-- v_input2 :=
-- xxqsc_hr_wf_pkg.get_input_id
-- ('Family Joining Ticket
Payment',
-- 'Ticket Price'
-- ); --
828;
-- v_input1 :=
-- xxqsc_hr_wf_pkg.get_input_id
-- ('Family Joining Ticket
Payment',
-- 'Name of Beneficiary'
-- ); --
1056;
-- ELSIF p_pei_information2 = 'FIRST_ARRIVAL' and
p_pei_information1 = 'CASH'
-- THEN
-- v_element_link_id :=
-- hr_entry_api.get_link
-- (p_assignment_id => v_assignment_id,
-- p_element_type_id =>
xxqsc_payroll.get_element_type_id
-- (p_business_group_id
=> 81,
-- p_element_name
=> 'First Arrival Ticket Payment'
-- ),
-- p_session_date => v_effective_date
-- );
-- v_input2 :=
-- xxqsc_hr_wf_pkg.get_input_id
-- ('First Arrival Ticket
Payment',
-- 'Ticket Price'
-- ); --
828;
-- v_input1 :=
-- xxqsc_hr_wf_pkg.get_input_id
-- ('First Arrival Ticket
Payment',
-- 'Name of Beneficiary'
-- ); --
1056;
-- ELSIF p_pei_information2 = 'LAST_DEPARTURE' and
p_pei_information1 = 'CASH'
-- THEN
-- v_element_link_id :=
-- hr_entry_api.get_link
-- (p_assignment_id => v_assignment_id,
-- p_element_type_id =>
xxqsc_payroll.get_element_type_id
-- (p_business_group_id
=> 81,
-- p_element_name
=> 'Last Departure Ticket Payment'
-- ),
-- p_session_date => v_effective_date
-- );
-- v_input2 :=
-- xxqsc_hr_wf_pkg.get_input_id
-- ('Last Departure Ticket
Payment',
-- 'Ticket Price'
-- ); --
828;
-- v_input1 :=
-- xxqsc_hr_wf_pkg.get_input_id
-- ('Last Departure Ticket
Payment',
-- 'Name of Beneficiary'
-- ); --
1056;
-- END IF;

-- IF p_pei_information16 IS NOT NULL


-- THEN --
PARENT
-- pay_element_entry_api.create_element_entry
-- (p_effective_date => v_effective_date,
-- p_business_group_id => 81,
-- p_assignment_id => v_assignment_id,
-- p_element_link_id =>
v_element_link_id,
-- p_entry_type => 'E',
-- --p_input_value_id1 => 713,
-- p_input_value_id2 => v_input1,
-- p_input_value_id3 => v_input2,
-- --p_entry_value1 => P_PEI_INFORMATION2,
-- p_entry_value2 =>
p_pei_information3,
-- p_entry_value3 =>
p_pei_information16,
-- p_effective_start_date =>
v_effective_start_date,
-- p_effective_end_date =>
v_effective_end_date,
-- p_element_entry_id =>
v_element_entry_id,
-- p_object_version_number =>
v_object_version_number,
-- p_create_warning => v_create_warning
-- );
-- END IF;

-- IF p_pei_information5 IS NOT NULL


-- THEN
-- -- SPOUSE
-- pay_element_entry_api.create_element_entry
-- (p_effective_date => v_effective_date,
-- p_business_group_id => 81,
-- p_assignment_id => v_assignment_id,
-- p_element_link_id =>
v_element_link_id,
-- p_entry_type => 'E',
-- --p_input_value_id1 => 713,
-- p_input_value_id2 => v_input1,
-- p_input_value_id3 => v_input2,
-- --p_entry_value1 => P_PEI_INFORMATION2,
-- p_entry_value2 =>
p_pei_information4,
-- p_entry_value3 =>
p_pei_information5,
-- p_effective_start_date =>
v_effective_start_date,
-- p_effective_end_date =>
v_effective_end_date,
-- p_element_entry_id =>
v_element_entry_id,
-- p_object_version_number =>
v_object_version_number,
-- p_create_warning => v_create_warning
-- );
-- END IF;

-- IF p_pei_information7 IS NOT NULL


-- THEN
-- -- CHILD1
-- pay_element_entry_api.create_element_entry
-- (p_effective_date => v_effective_date,
-- p_business_group_id => 81,
-- p_assignment_id => v_assignment_id,
-- p_element_link_id =>
v_element_link_id,
-- p_entry_type => 'E',
-- --p_input_value_id1 => 713,
-- p_input_value_id2 => v_input1,
-- p_input_value_id3 => v_input2,
-- --p_entry_value1 => P_PEI_INFORMATION2,
-- p_entry_value2 =>
p_pei_information6,
-- p_entry_value3 =>
p_pei_information7,
-- p_effective_start_date =>
v_effective_start_date,
-- p_effective_end_date =>
v_effective_end_date,
-- p_element_entry_id =>
v_element_entry_id,
-- p_object_version_number =>
v_object_version_number,
-- p_create_warning => v_create_warning
-- );
-- END IF;

-- IF p_pei_information9 IS NOT NULL


-- THEN
-- -- CHILD2
-- pay_element_entry_api.create_element_entry
-- (p_effective_date => v_effective_date,
-- p_business_group_id => 81,
-- p_assignment_id => v_assignment_id,
-- p_element_link_id =>
v_element_link_id,
-- p_entry_type => 'E',
-- --p_input_value_id1 => 713,
-- p_input_value_id2 => v_input1,
-- p_input_value_id3 => v_input2,
-- --p_entry_value1 => P_PEI_INFORMATION2,
-- p_entry_value2 =>
p_pei_information8,
-- p_entry_value3 =>
p_pei_information9,
-- p_effective_start_date =>
v_effective_start_date,
-- p_effective_end_date =>
v_effective_end_date,
-- p_element_entry_id =>
v_element_entry_id,
-- p_object_version_number =>
v_object_version_number,
-- p_create_warning => v_create_warning
-- );
-- END IF;

-- IF p_pei_information11 IS NOT NULL


-- THEN
-- -- CHILD3
-- pay_element_entry_api.create_element_entry
-- (p_effective_date => v_effective_date,
-- p_business_group_id => 81,
-- p_assignment_id => v_assignment_id,
-- p_element_link_id =>
v_element_link_id,
-- p_entry_type => 'E',
-- --p_input_value_id1 => 713,
-- p_input_value_id2 => v_input1,
-- p_input_value_id3 => v_input2,
-- --p_entry_value1 => P_PEI_INFORMATION2,
-- p_entry_value2 =>
p_pei_information10,
-- p_entry_value3 =>
p_pei_information11,
-- p_effective_start_date =>
v_effective_start_date,
-- p_effective_end_date =>
v_effective_end_date,
-- p_element_entry_id =>
v_element_entry_id,
-- p_object_version_number =>
v_object_version_number,
-- p_create_warning => v_create_warning
-- );
-- END IF;
-- IF p_pei_information13 IS NOT NULL
-- THEN
-- -- CHILD4
-- pay_element_entry_api.create_element_entry
-- (p_effective_date => v_effective_date,
-- p_business_group_id => 81,
-- p_assignment_id => v_assignment_id,
-- p_element_link_id =>
v_element_link_id,
-- p_entry_type => 'E',
-- --p_input_value_id1 => 713,
-- p_input_value_id2 => v_input1,
-- p_input_value_id3 => v_input2,
-- --p_entry_value1 => P_PEI_INFORMATION2,
-- p_entry_value2 =>
p_pei_information12,
-- p_entry_value3 =>
p_pei_information13,
-- p_effective_start_date =>
v_effective_start_date,
-- p_effective_end_date =>
v_effective_end_date,
-- p_element_entry_id =>
v_element_entry_id,
-- p_object_version_number =>
v_object_version_number,
-- p_create_warning => v_create_warning
-- );
-- END IF;
-- EXCEPTION
-- WHEN OTHERS THEN NULL;
-- END;
-- END IF;

------------car loan action -------------------


IF p_information_type = 'QSC_SS_CAR_LOAN_REQUEST'
THEN
DECLARE
BEGIN
v_element_link_id :=
hr_entry_api.get_link (
p_assignment_id => v_assignment_id,
p_element_type_id => xxqsc_payroll.get_element_type_id (
p_business_group_id => 81,
p_element_name => 'Car Loan'),
p_session_date => v_effective_date);
pay_element_entry_api.create_element_entry (
p_effective_date => v_effective_date,
p_business_group_id => 81,
p_assignment_id => v_assignment_id,
p_element_link_id => v_element_link_id,
p_entry_type => 'E',
/* p_input_value_id1 => 300,
p_input_value_id2 => 301,
p_entry_value1 => p_pei_information2,
p_entry_value2 => p_pei_information3,*/
p_effective_start_date => v_effective_start_date,
p_effective_end_date => v_effective_end_date,
p_element_entry_id => v_element_entry_id,
p_object_version_number => v_object_version_number,
p_create_warning => v_create_warning);
END;
END IF;

IF p_information_type = 'QSC_SS_UPDATE_PAYROLL_INFO_REQ'
THEN
FOR k IN c_pay_id (v_assignment_id)
LOOP
NULL;
v_pay_id := k.personal_payment_method_id;
--v_ext_id:=k.EXTERNAL_ACCOUNT_ID;
--v_effective_start_date:=k.EFFECTIVE_START_DATE;
--v_effective_end_date:=k.EFFECTIVE_END_DATE;
v_number := k.object_version_number;
END LOOP;

IF v_pay_id IS NULL
THEN
DECLARE
ln_method_id
pay_personal_payment_methods_f.personal_payment_method_id%TYPE;
ln_ext_acc_id pay_external_accounts.external_account_id%TYPE;
ln_obj_ver_num
pay_personal_payment_methods_f.object_version_number%TYPE;
ld_eff_start_date DATE;
ld_eff_end_date DATE;
ln_comment_id NUMBER;
v_method NUMBER;
BEGIN
/* SELECT hr.pay_personal_payment_methods_s.NEXTVAL
INTO ln_method_id
FROM DUAL;*/
/* SELECT org_payment_method_id
INTO v_method
FROM pay_org_payment_methods_f_tl
WHERE org_payment_method_name = p_pei_information4
AND LANGUAGE = USERENV ('LANG');*/
hr_personal_pay_method_api.create_personal_pay_method ( -- Input
data elements
-- ------------------------------
p_effective_date => TRUNC (SYSDATE),
p_assignment_id => v_assignment_id,
p_org_payment_method_id => 61, --v_method,
p_priority => 1 /*p_pei_information5
- 1*/
,
p_percentage => 100,
p_territory_code => 'QA',
p_segment1 => p_pei_information3,
--- bank
p_segment3 => p_pei_information4,
-- Account number
p_segment2 => p_pei_information5,
-- Branch
p_segment5 => p_pei_information6,
--- account type
p_segment4 => p_pei_information7,
-- swift
p_segment6 => p_pei_information8,
-- IBAN --Added By Ravindra(19-02-2020)
--p_attribute1 => 'Y',
-- Output data elements
-- --------------------------------
p_personal_payment_method_id => ln_method_id,
p_external_account_id => ln_ext_acc_id,
p_object_version_number => ln_obj_ver_num,
p_effective_start_date => ld_eff_start_date,
p_effective_end_date => ld_eff_end_date,
p_comment_id => ln_comment_id);
END;
ELSE
DECLARE
BEGIN
/*select meaning into v_mean from FND_LOOKUP_VALUES
Where lookup_type='QSC_PAY_BANK' and ENABLED_FLAG='Y' and LANGUAGE=
USERENV('LANG')
and lookup_code=p_PEI_INFORMATION1;
*/
hr_personal_pay_method_api.update_personal_pay_method (
p_validate => FALSE,
p_effective_date => TRUNC (SYSDATE),
p_datetrack_update_mode => 'UPDATE',
p_personal_payment_method_id => v_pay_id,
p_object_version_number => v_number,
p_comments => 'Updated by USER HOOK',
p_percentage => 100,
p_priority => 1,
p_territory_code => 'QA',
p_segment1 => p_pei_information3,
--- bank
p_segment3 => p_pei_information4,
-- Account number
p_segment2 => p_pei_information5,
-- Branch
p_segment5 => p_pei_information6,
--- account type
p_segment4 => p_pei_information7,
-- swift
p_segment6 => p_pei_information8,
-- IBAN --Added By Ravindra(19-02-2020)
p_comment_id => o_comment_id,
p_external_account_id => v_ext_id,
p_effective_start_date => v_effective_start_date,
p_effective_end_date => v_effective_end_date);
END;
END IF;
/* hr_utility.set_message
(800,
'date'||v_effective_date|| v_assignment_id ||'update'
);
hr_utility.raise_error;
*/
END IF;

---------------------Annual Leave Return Request


------------------------------
IF p_information_type = 'QSC_SS_ANNUAL_LEAVE_RETURN_REQ'
THEN
-- NEW ACTIONS MOVED FROM PWA
DECLARE
v_requested_days NUMBER;
v_actual_days NUMBER;
v_extra_days NUMBER;
v_balance NUMBER;
v_unpaid_leave_id NUMBER;
v_unpaid_days NUMBER;
v_annual_days NUMBER;
v_version_number NUMBER;
v_abs NUMBER;
v_abs_unpaid NUMBER;
v_occurence NUMBER;
v_days BOOLEAN;
v_hours BOOLEAN;
v_extend BOOLEAN;
v_run BOOLEAN;
v_override BOOLEAN;
v_abs_day BOOLEAN;
v_warning BOOLEAN;

CURSOR c_abs
IS
SELECT absence_attendance_id,
business_group_id,
absence_attendance_type_id,
abs_attendance_reason_id,
person_id,
authorising_person_id,
replacement_person_id,
period_of_incapacity_id,
absence_days,
absence_hours,
date_end,
date_notification,
date_projected_end,
date_projected_start,
date_start,
occurrence,
ssp1_issued,
time_end,
time_projected_end,
time_projected_start,
time_start,
request_id,
program_application_id,
program_id,
program_update_date,
attribute_category,
attribute1,
attribute2,
attribute3,
attribute4,
attribute5,
attribute6,
attribute7,
attribute8,
attribute9,
attribute10,
attribute11,
attribute12,
attribute13,
attribute14,
attribute15,
attribute16,
attribute17,
attribute18,
attribute19,
attribute20,
last_update_date,
last_updated_by,
last_update_login,
created_by,
creation_date,
maternity_id,
sickness_start_date,
sickness_end_date,
pregnancy_related_illness,
reason_for_notification_delay,
accept_late_notification_flag,
linked_absence_id,
batch_id,
abs_information_category,
abs_information1,
abs_information2,
abs_information3,
abs_information4,
abs_information5,
abs_information6,
abs_information7,
abs_information8,
abs_information9,
abs_information10,
abs_information11,
abs_information12,
abs_information13,
abs_information14,
abs_information15,
abs_information16,
abs_information17,
abs_information18,
abs_information19,
abs_information20,
abs_information21,
abs_information22,
abs_information23,
abs_information24,
abs_information25,
abs_information26,
abs_information27,
abs_information28,
abs_information29,
abs_information30,
object_version_number,
absence_case_id,
approval_status,
confirmed_until,
SOURCE,
advance_pay
FROM xxper_absence_attendances
WHERE absence_attendance_id = p_pei_information1;

CURSOR c2
IS
SELECT paa.absence_days
FROM per_absence_attendances paa
WHERE paa.absence_attendance_id = p_pei_information1;

CURSOR c3
IS
SELECT paat.absence_attendance_type_id
FROM per_absence_attendance_types paat
WHERE paat.NAME = 'Unpaid Leave';

BEGIN
OPEN c2;

FETCH c2 INTO v_requested_days;

CLOSE c2;

OPEN c3;

FETCH c3 INTO v_unpaid_leave_id;

CLOSE c3;

v_actual_days :=
/*TO_DATE
(TO_CHAR
(TO_DATE
(p_pei_information3,
'RRRR/MM/DD HH24:MI:SS'
),
'MM/DD/RRRR'
),
'MM/DD/RRRR'
) - TO_DATE
(TO_CHAR
(TO_DATE
(p_pei_information2,
'RRRR/MM/DD HH24:MI:SS'
),
'MM/DD/RRRR'
),
'MM/DD/RRRR'
)+1;*/
xxqsc_payroll.get_return_working_days (
TO_DATE (
TO_CHAR (
TO_DATE (p_pei_information2, 'RRRR/MM/DD HH24:MI:SS'),
'MM/DD/RRRR'),
'MM/DD/RRRR'),
TO_DATE (
TO_CHAR (
TO_DATE (p_pei_information3, 'RRRR/MM/DD HH24:MI:SS'),
'MM/DD/RRRR'),
'MM/DD/RRRR'));
v_extra_days := v_actual_days - v_requested_days;

/*IF v_extra_days > v_balance \* not enough balance, so unpaid are


applied*\
THEN
v_difference := v_extra_days - v_balance;
v_annual_days := v_requested_days + v_balance;
v_unpaid_days := v_actual_days - v_annual_days;
v_annual_start_date := v_actual_start_date;*/
INSERT INTO xxper_absence_attendances (
absence_attendance_id,
business_group_id,
absence_attendance_type_id,
abs_attendance_reason_id,
person_id,
authorising_person_id,
replacement_person_id,
period_of_incapacity_id,
absence_days,
absence_hours,
date_end,
date_notification,
date_projected_end,
date_projected_start,
date_start,
occurrence,
ssp1_issued,
time_end,
time_projected_end,
time_projected_start,
time_start,
request_id,
program_application_id,
program_id,
program_update_date,
attribute_category,
attribute1,
attribute2,
attribute3,
attribute4,
attribute5,
attribute6,
attribute7,
attribute8,
attribute9,
attribute10,
attribute11,
attribute12,
attribute13,
attribute14,
attribute15,
attribute16,
attribute17,
attribute18,
attribute19,
attribute20,
last_update_date,
last_updated_by,
last_update_login,
created_by,
creation_date,
maternity_id,
sickness_start_date,
sickness_end_date,
pregnancy_related_illness,
reason_for_notification_delay,
accept_late_notification_flag,
linked_absence_id,
batch_id,
abs_information_category,
abs_information1,
abs_information2,
abs_information3,
abs_information4,
abs_information5,
abs_information6,
abs_information7,
abs_information8,
abs_information9,
abs_information10,
abs_information11,
abs_information12,
abs_information13,
abs_information14,
abs_information15,
abs_information16,
abs_information17,
abs_information18,
abs_information19,
abs_information20,
abs_information21,
abs_information22,
abs_information23,
abs_information24,
abs_information25,
abs_information26,
abs_information27,
abs_information28,
abs_information29,
abs_information30,
object_version_number,
absence_case_id,
approval_status,
confirmed_until,
SOURCE,
advance_pay)
(SELECT absence_attendance_id,
business_group_id,
absence_attendance_type_id,
abs_attendance_reason_id,
person_id,
authorising_person_id,
replacement_person_id,
period_of_incapacity_id,
absence_days,
absence_hours,
date_end,
date_notification,
date_projected_end,
date_projected_start,
date_start,
occurrence,
ssp1_issued,
time_end,
time_projected_end,
time_projected_start,
time_start,
request_id,
program_application_id,
program_id,
program_update_date,
attribute_category,
attribute1,
attribute2,
attribute3,
attribute4,
attribute5,
attribute6,
attribute7,
attribute8,
attribute9,
attribute10,
attribute11,
attribute12,
attribute13,
attribute14,
attribute15,
attribute16,
attribute17,
attribute18,
attribute19,
attribute20,
last_update_date,
last_updated_by,
last_update_login,
created_by,
creation_date,
maternity_id,
sickness_start_date,
sickness_end_date,
pregnancy_related_illness,
reason_for_notification_delay,
accept_late_notification_flag,
linked_absence_id,
batch_id,
abs_information_category,
abs_information1,
abs_information2,
abs_information3,
abs_information4,
abs_information5,
abs_information6,
abs_information7,
abs_information8,
abs_information9,
abs_information10,
abs_information11,
abs_information12,
abs_information13,
abs_information14,
abs_information15,
abs_information16,
abs_information17,
abs_information18,
abs_information19,
abs_information20,
abs_information21,
abs_information22,
abs_information23,
abs_information24,
abs_information25,
abs_information26,
abs_information27,
abs_information28,
abs_information29,
abs_information30,
object_version_number,
absence_case_id,
approval_status,
confirmed_until,
SOURCE,
advance_pay
FROM hr.per_absence_attendances
WHERE absence_attendance_id = p_pei_information1);

FOR r1
IN (SELECT paa.object_version_number,
paa.absence_attendance_id
FROM per_absence_attendances paa
WHERE paa.absence_attendance_id = p_pei_information1)
LOOP
hr_person_absence_api.delete_person_absence (
p_validate => FALSE,
p_absence_attendance_id => r1.absence_attendance_id,
p_object_version_number => r1.object_version_number);
END LOOP;

v_balance :=
xxqsc_payroll.get_net_accrual (81,
v_assignment_id,
SYSDATE,
'Annual Leave Accrual');

IF v_actual_days <= v_requested_days


OR v_actual_days >= v_requested_days
OR v_extra_days <= v_balance - v_actual_days
THEN
/*hr_utility.set_message
(800,
v_balance||'-'||v_actual_days||'-'||v_requested_days||'-'||
v_extra_days
);
hr_utility.raise_error;*/
FOR l IN c_abs
LOOP
hr_person_absence_api.create_person_absence (
p_validate => FALSE,
p_effective_date => v_effective_date,
p_person_id => p_person_id,
p_business_group_id => 81,
p_absence_attendance_type_id =>
l.absence_attendance_type_id,
p_abs_attendance_reason_id => l.abs_attendance_reason_id,
p_comments => NULL,
p_date_notification => l.date_notification,
p_date_projected_start => l.date_projected_start,
p_time_projected_start => l.time_projected_start,
p_date_projected_end => l.date_projected_start,
p_time_projected_end => l.time_projected_end,
p_date_start => TO_DATE (
TO_CHAR (
TO_DATE (
p_pei_information2,
'RRRR/MM/DD
HH24:MI:SS'),
'MM/DD/RRRR'),
'MM/DD/RRRR'),
p_time_start => l.time_start,
p_date_end => TO_DATE (
TO_CHAR (
TO_DATE (
p_pei_information3,
'RRRR/MM/DD
HH24:MI:SS'),
'MM/DD/RRRR'),
'MM/DD/RRRR'),
p_time_end => l.time_end,
p_absence_days => v_actual_days,
p_absence_hours => l.absence_hours,
p_authorising_person_id => l.authorising_person_id,
p_replacement_person_id => l.replacement_person_id,
p_attribute_category => '63',
--l.attribute_category,
p_attribute1 => 'Y',
p_attribute4 => l.attribute4,
p_absence_attendance_id => v_abs,
p_object_version_number => v_version_number,
p_occurrence => v_occurence,
p_dur_dys_less_warning => v_days,
p_dur_hrs_less_warning => v_hours,
p_exceeds_pto_entit_warning => v_extend,
p_exceeds_run_total_warning => v_run,
p_abs_overlap_warning => v_override,
p_abs_day_after_warning => v_abs_day,
p_dur_overwritten_warning => v_warning);

-- Move attachments
UPDATE applsys.fnd_attached_documents t
SET t.pk1_value = v_abs
WHERE t.pk1_value = TO_CHAR (l.absence_attendance_id)
AND t.entity_name = 'PER_ABSENCE_ATTENDANCES';
END LOOP;
ELSIF v_extra_days > v_balance - v_actual_days
THEN
v_unpaid_days := v_actual_days - v_balance;
v_annual_days := v_balance;

-- Test Messages
/*hr_utility.set_message
(800,'- to'||TO_DATE
(TO_CHAR
(TO_DATE
(p_pei_information3,
'RRRR/MM/DD HH24:MI:SS'
),
'MM/DD/RRRR'
),
'MM/DD/RRRR'
)-v_unpaid_days);
hr_utility.raise_error;
hr_utility.set_message
(800,
v_balance||'-'||v_actual_days||'-'||v_requested_days||'-'||
v_extra_days
||'-'||v_unpaid_days||'-'||v_annual_days
);
hr_utility.raise_error;*/
-- Test Messages
FOR l IN c_abs
LOOP
IF v_annual_days > 0
THEN
hr_person_absence_api.create_person_absence (
p_validate => FALSE,
p_effective_date => v_effective_date,
p_person_id => p_person_id,
p_business_group_id => 81,
p_absence_attendance_type_id =>
l.absence_attendance_type_id,
p_abs_attendance_reason_id =>
l.abs_attendance_reason_id,
p_comments => NULL,
p_date_notification => l.date_notification,
p_date_projected_start => l.date_projected_start,
p_time_projected_start => l.time_projected_start,
p_date_projected_end => l.date_projected_start,
p_time_projected_end => l.time_projected_end,
p_date_start => TO_DATE (
TO_CHAR (
TO_DATE (

p_pei_information2,
'RRRR/MM/DD
HH24:MI:SS'),
'MM/DD/RRRR'),
'MM/DD/RRRR'),
p_time_start => l.time_start,
p_date_end => TO_DATE (
TO_CHAR (
TO_DATE (

p_pei_information3,
'RRRR/MM/DD
HH24:MI:SS'),
'MM/DD/RRRR'),
'MM/DD/RRRR')
- v_unpaid_days,
p_time_end => l.time_end,
p_absence_days => v_annual_days,
p_absence_hours => l.absence_hours,
p_authorising_person_id => l.authorising_person_id,
p_replacement_person_id => l.replacement_person_id,
p_attribute_category => '63',
--l.attribute_category,
p_attribute1 => 'Y',
p_attribute4 => l.attribute4,
p_absence_attendance_id => v_abs,
p_object_version_number => v_version_number,
p_occurrence => v_occurence,
p_dur_dys_less_warning => v_days,
p_dur_hrs_less_warning => v_hours,
p_exceeds_pto_entit_warning => v_extend,
p_exceeds_run_total_warning => v_run,
p_abs_overlap_warning => v_override,
p_abs_day_after_warning => v_abs_day,
p_dur_overwritten_warning => v_warning);
END IF;

-- unpaid
hr_person_absence_api.create_person_absence (
p_validate => FALSE,
p_effective_date => v_effective_date,
p_person_id => p_person_id,
p_business_group_id => 81,
p_absence_attendance_type_id => v_unpaid_leave_id,
p_abs_attendance_reason_id => l.abs_attendance_reason_id,
p_comments => NULL,
p_date_notification => l.date_notification,
p_date_projected_start => l.date_projected_start,
p_time_projected_start => l.time_projected_start,
p_date_projected_end => l.date_projected_start,
p_time_projected_end => l.time_projected_end,
p_date_start => TO_DATE (
TO_CHAR (
TO_DATE (

p_pei_information3,
'RRRR/MM/DD
HH24:MI:SS'),
'MM/DD/RRRR'),
'MM/DD/RRRR')
- v_unpaid_days
+ 1,
p_time_start => l.time_start,
p_date_end => TO_DATE (
TO_CHAR (
TO_DATE (
p_pei_information3,
'RRRR/MM/DD
HH24:MI:SS'),
'MM/DD/RRRR'),
'MM/DD/RRRR'),
p_time_end => l.time_end,
p_absence_days => v_unpaid_days,
p_absence_hours => l.absence_hours,
p_authorising_person_id => l.authorising_person_id,
p_replacement_person_id => l.replacement_person_id,
--p_attribute_category => l.attribute_category,
--p_attribute1 => l.attribute1,
p_absence_attendance_id => v_abs_unpaid,
--v_abs,
p_object_version_number => v_version_number,
p_occurrence => v_occurence,
p_dur_dys_less_warning => v_days,
p_dur_hrs_less_warning => v_hours,
p_exceeds_pto_entit_warning => v_extend,
p_exceeds_run_total_warning => v_run,
p_abs_overlap_warning => v_override,
p_abs_day_after_warning => v_abs_day,
p_dur_overwritten_warning => v_warning);

-- Move attachments
UPDATE applsys.fnd_attached_documents t
SET t.pk1_value = v_abs
WHERE t.pk1_value = TO_CHAR (l.absence_attendance_id)
AND t.entity_name = 'PER_ABSENCE_ATTENDANCES';
END LOOP;
END IF;
END;
END IF;

---------------------Annual Leave Return Request Cancel


------------------------------

IF p_information_type = 'QSC_SS_ANNUAL_LEAVE_CANCEL_REQ'
THEN
INSERT INTO XXPER_ABS_ATTENDANCES_CANCELED (
absence_attendance_id,
business_group_id,
absence_attendance_type_id,
abs_attendance_reason_id,
person_id,
authorising_person_id,
replacement_person_id,
period_of_incapacity_id,
absence_days,
absence_hours,
date_end,
date_notification,
date_projected_end,
date_projected_start,
date_start,
occurrence,
ssp1_issued,
time_end,
time_projected_end,
time_projected_start,
time_start,
request_id,
program_application_id,
program_id,
program_update_date,
attribute_category,
attribute1,
attribute2,
attribute3,
attribute4,
attribute5,
attribute6,
attribute7,
attribute8,
attribute9,
attribute10,
attribute11,
attribute12,
attribute13,
attribute14,
attribute15,
attribute16,
attribute17,
attribute18,
attribute19,
attribute20,
last_update_date,
last_updated_by,
last_update_login,
created_by,
creation_date,
maternity_id,
sickness_start_date,
sickness_end_date,
pregnancy_related_illness,
reason_for_notification_delay,
accept_late_notification_flag,
linked_absence_id,
batch_id,
abs_information_category,
abs_information1,
abs_information2,
abs_information3,
abs_information4,
abs_information5,
abs_information6,
abs_information7,
abs_information8,
abs_information9,
abs_information10,
abs_information11,
abs_information12,
abs_information13,
abs_information14,
abs_information15,
abs_information16,
abs_information17,
abs_information18,
abs_information19,
abs_information20,
abs_information21,
abs_information22,
abs_information23,
abs_information24,
abs_information25,
abs_information26,
abs_information27,
abs_information28,
abs_information29,
abs_information30,
object_version_number,
absence_case_id,
approval_status,
confirmed_until,
SOURCE,
advance_pay)
(SELECT absence_attendance_id,
business_group_id,
absence_attendance_type_id,
abs_attendance_reason_id,
person_id,
authorising_person_id,
replacement_person_id,
period_of_incapacity_id,
absence_days,
absence_hours,
date_end,
date_notification,
date_projected_end,
date_projected_start,
date_start,
occurrence,
ssp1_issued,
time_end,
time_projected_end,
time_projected_start,
time_start,
request_id,
program_application_id,
program_id,
program_update_date,
attribute_category,
attribute1,
attribute2,
attribute3,
attribute4,
attribute5,
attribute6,
attribute7,
attribute8,
attribute9,
attribute10,
attribute11,
attribute12,
attribute13,
attribute14,
attribute15,
attribute16,
attribute17,
attribute18,
attribute19,
attribute20,
last_update_date,
last_updated_by,
last_update_login,
created_by,
creation_date,
maternity_id,
sickness_start_date,
sickness_end_date,
pregnancy_related_illness,
reason_for_notification_delay,
accept_late_notification_flag,
linked_absence_id,
batch_id,
abs_information_category,
abs_information1,
abs_information2,
abs_information3,
abs_information4,
abs_information5,
abs_information6,
abs_information7,
abs_information8,
abs_information9,
abs_information10,
abs_information11,
abs_information12,
abs_information13,
abs_information14,
abs_information15,
abs_information16,
abs_information17,
abs_information18,
abs_information19,
abs_information20,
abs_information21,
abs_information22,
abs_information23,
abs_information24,
abs_information25,
abs_information26,
abs_information27,
abs_information28,
abs_information29,
abs_information30,
object_version_number,
absence_case_id,
approval_status,
confirmed_until,
SOURCE,
advance_pay
FROM hr.per_absence_attendances
WHERE absence_attendance_id = p_pei_information1);

FOR r1
IN (SELECT paa.object_version_number, paa.absence_attendance_id
FROM per_absence_attendances paa
WHERE paa.absence_attendance_id = p_pei_information1)
LOOP
hr_person_absence_api.delete_person_absence (
p_validate => FALSE,
p_absence_attendance_id => r1.absence_attendance_id,
p_object_version_number => r1.object_version_number);
END LOOP;
END IF;

------------------------------School Allowance Request Action


---------------------------------
IF p_information_type = 'QSC_SS_SCHOOL_ALLOWANCE_REQ'
THEN
DECLARE
BEGIN
v_element_link_id :=
hr_entry_api.get_link (
p_assignment_id => v_assignment_id,
p_element_type_id => xxqsc_payroll.get_element_type_id (
p_business_group_id => 81,
p_element_name => 'Education
Allowance'),
p_session_date => v_effective_date);
pay_element_entry_api.create_element_entry (
p_effective_date => v_effective_date,
p_business_group_id => 81,
p_assignment_id => v_assignment_id,
p_element_link_id => v_element_link_id,
p_entry_type => 'E',
p_input_value_id1 => xxqsc_hr_wf_pkg.get_input_id (
'Education Allowance',
'Invoice Amount'), --713,
p_input_value_id2 => xxqsc_hr_wf_pkg.get_input_id (
'Education Allowance',
'Accrued Semesters'), --713,
p_input_value_id3 => xxqsc_hr_wf_pkg.get_input_id (
'Education Allowance',
'Child Name'), --714,
p_input_value_id4 => xxqsc_hr_wf_pkg.get_input_id (
'Education Allowance',
'Educational Year'), --715,
p_input_value_id5 => xxqsc_hr_wf_pkg.get_input_id (
'Education Allowance',
'Payment Description'),
p_input_value_id6 => xxqsc_hr_wf_pkg.get_input_id (
'Education Allowance',
'Notes 2'),

p_entry_value1 => p_pei_information1,


p_entry_value2 => p_pei_information7,
p_entry_value3 => p_pei_information3,
p_entry_value4 => p_pei_information4,
p_entry_value5 => p_pei_information6,
p_entry_value6 => p_pei_information29,
p_effective_start_date => v_effective_start_date,
p_effective_end_date => v_effective_end_date,
p_element_entry_id => v_element_entry_id,
p_object_version_number => v_object_version_number,
p_create_warning => v_create_warning);
END;
END IF;

-----------------------------QSC_SS_DUTY_RESUMP_REQ
---------------------------------
/*IF P_INFORMATION_TYPE = 'QSC_SS_TRAVEL_RESUMP_REQ' THEN
DECLARE
V_TRIP_TYPE varchar2(100);
BEGIN
IF P_PEI_INFORMATION1 in ('RFBT','TRAINING','CONFERENCE') THEN
IF NVL(P_PEI_INFORMATION9,0) > 0 THEN
IF P_PEI_INFORMATION1= 'RFBT' THEN V_TRIP_TYPE := 'Business Trip Per Diem';
ELSIF P_PEI_INFORMATION1='TRAINING' THEN V_TRIP_TYPE := 'Training Per Diem';
ELSIF P_PEI_INFORMATION1='CONFERENCE' THEN V_TRIP_TYPE := 'Conference Seminar
and Trade Fairs Per Diem';
END IF;
V_ELEMENT_LINK_ID := HR_ENTRY_API.GET_LINK(P_ASSIGNMENT_ID =>
V_ASSIGNMENT_ID,
P_ELEMENT_TYPE_ID => XXQSC_PAYROLL.GET_ELEMENT_TYPE_ID(P_BUSINESS_GROUP_ID =>
81,
P_ELEMENT_NAME => V_TRIP_TYPE),
P_SESSION_DATE => V_EFFECTIVE_DATE);
PAY_ELEMENT_ENTRY_API.CREATE_ELEMENT_ENTRY(P_EFFECTIVE_DATE =>
V_EFFECTIVE_DATE,
P_BUSINESS_GROUP_ID => 81,
P_ASSIGNMENT_ID => V_ASSIGNMENT_ID,
P_ELEMENT_LINK_ID => V_ELEMENT_LINK_ID,
P_ENTRY_TYPE => 'E',
p_input_value_id1 => xxqsc_hr_wf_pkg.get_input_id(V_TRIP_TYPE,'Amount'
),
p_input_value_id2 => xxqsc_hr_wf_pkg.get_input_id(V_TRIP_TYPE,'
Official Travel Description'),
p_input_value_id3 => xxqsc_hr_wf_pkg.get_input_id(V_TRIP_TYPE,'
Departure Date'),
p_input_value_id4 => xxqsc_hr_wf_pkg.get_input_id(V_TRIP_TYPE,'Return
Date'),
p_input_value_id5 => xxqsc_hr_wf_pkg.get_input_id(V_TRIP_TYPE,'First
Day Of Business'),
p_input_value_id6 => xxqsc_hr_wf_pkg.get_input_id(V_TRIP_TYPE,'Last
Day Of Business'),
p_input_value_id7 => xxqsc_hr_wf_pkg.get_input_id(V_TRIP_TYPE,'Source'
),
p_entry_value1 => P_PEI_INFORMATION9,
p_entry_value2 => P_PEI_INFORMATION1,
p_entry_value3 => fnd_date.canonical_to_date(P_PEI_INFORMATION10),
p_entry_value4 => fnd_date.canonical_to_date(P_PEI_INFORMATION11),
p_entry_value5 => fnd_date.canonical_to_date(P_PEI_INFORMATION2),
p_entry_value6 => fnd_date.canonical_to_date(P_PEI_INFORMATION3),
p_entry_value7 => 'Travel Duty Resumption',
P_EFFECTIVE_START_DATE => V_EFFECTIVE_START_DATE,
P_EFFECTIVE_END_DATE => V_EFFECTIVE_END_DATE,
P_ELEMENT_ENTRY_ID => V_ELEMENT_ENTRY_ID,
P_OBJECT_VERSION_NUMBER => V_OBJECT_VERSION_NUMBER,
P_CREATE_WARNING => V_CREATE_WARNING);
END IF;
END IF;
END;
END IF; */
-----------------------------QSC_SS_TRAVEL_RESUMP_REQ
---------------------------------
IF p_information_type = 'QSC_SS_TRAVEL_RESUMP_REQ'
THEN
DECLARE
v_trip_type VARCHAR2 (100);
v_ele_date DATE;
BEGIN
/*IF SYSDATE > TO_DATE(NVL(XXQSC_HR_UTILITY2.GET_GLOBAL_VAL('
GV_CREATE_TRAVEL_ELEMENT_DAY'),'19')
||TO_CHAR(SYSDATE,'MM-YYYY'),'DD-MM-YYYY')
THEN
V_ELE_DATE := TRUNC(ADD_MONTHS(SYSDATE,1),'MONTH');
ELSE*/
v_ele_date := SYSDATE;

--END IF;
---------- changed by anas to accept minus value 23.11.2015
IF p_pei_information1 IN ('RFBT', 'TRAINING', 'CONFERENCE')
THEN
IF NVL (p_pei_information9, 0) IS NOT NULL
THEN -- NVL(P_PEI_INFORMATION9,0) > 0 THEN
IF p_pei_information1 = 'RFBT'
THEN
v_trip_type := 'Business Trip Per Diem';
ELSIF p_pei_information1 = 'TRAINING'
THEN
v_trip_type := 'Training Per Diem';
ELSIF p_pei_information1 = 'CONFERENCE'
THEN
v_trip_type :=
'Conference Seminar and Trade Fairs Per Diem';
END IF;

v_element_link_id :=
hr_entry_api.get_link (
p_assignment_id => v_assignment_id,
p_element_type_id => xxqsc_payroll.get_element_type_id (
p_business_group_id => 81,
p_element_name =>
v_trip_type),
p_session_date => v_effective_date);

pay_element_entry_api.create_element_entry (
p_effective_date => TO_CHAR (v_ele_date, 'DD-MON-
RRRR'),
p_business_group_id => 81,
p_assignment_id => v_assignment_id,
p_element_link_id => v_element_link_id,
p_entry_type => 'E',
p_input_value_id1 => xxqsc_hr_wf_pkg.get_input_id (
v_trip_type,
'Amount'),
p_input_value_id2 => xxqsc_hr_wf_pkg.get_input_id (
v_trip_type,
'Official Travel Description'),
p_input_value_id3 => xxqsc_hr_wf_pkg.get_input_id (
v_trip_type,
'Departure Date'),
p_input_value_id4 => xxqsc_hr_wf_pkg.get_input_id (
v_trip_type,
'Return Date'),
p_input_value_id5 => xxqsc_hr_wf_pkg.get_input_id (
v_trip_type,
'First Day Of Business'),
p_input_value_id6 => xxqsc_hr_wf_pkg.get_input_id (
v_trip_type,
'Last Day Of Business'),
p_input_value_id7 => xxqsc_hr_wf_pkg.get_input_id (
v_trip_type,
'Source'),
p_entry_value1 => p_pei_information28,
p_entry_value2 => p_pei_information1,
p_entry_value3 => fnd_date.canonical_to_date (
p_pei_information10),
p_entry_value4 => fnd_date.canonical_to_date (
p_pei_information11),
p_entry_value5 => fnd_date.canonical_to_date (
p_pei_information2),
p_entry_value6 => fnd_date.canonical_to_date (
p_pei_information3),
p_entry_value7 => 'Travel Duty Self Service',
p_effective_start_date => v_effective_start_date,
p_effective_end_date => v_effective_end_date,
p_element_entry_id => v_element_entry_id,
p_object_version_number => v_object_version_number,
p_create_warning => v_create_warning);
END IF;
END IF;
END;

-------------------
UPDATE per_people_extra_info a
SET a.pei_information30 = 'RETURNED'
WHERE a.person_extra_info_id = p_pei_information13;
--------------------
END IF;

------------------------------------------Tracel Athuraization Advanced


Payment Request----------------------------------------------------------------
IF P_INFORMATION_TYPE = 'QSC_SS_BTR_ADVANC_PAY_REQ'
THEN
DECLARE
V_TRIP_TYPE VARCHAR2 (100);
V_ELE_DATE DATE;
V_P_ENTRY_VALUE2 VARCHAR2 (100);
BEGIN
/*IF SYSDATE > TO_DATE(NVL(XXQSC_HR_UTILITY2.GET_GLOBAL_VAL('
GV_CREATE_TRAVEL_ELEMENT_DAY'),'19')
||TO_CHAR(SYSDATE,'MM-YYYY'),'DD-MM-YYYY')
THEN
V_ELE_DATE := TRUNC(ADD_MONTHS(SYSDATE,1),'MONTH');
ELSE*/
V_ELE_DATE := SYSDATE;
--END IF;
---------- changed by anas to accept minus value 23.11.2015
IF P_PEI_INFORMATION1 IN ('RFBT', 'TRAINING', 'CONFERENCE')
THEN
IF NVL (P_PEI_INFORMATION9, 0) IS NOT NULL
THEN -- NVL(P_PEI_INFORMATION9,0) > 0 THEN
IF P_PEI_INFORMATION1 = 'RFBT'
THEN
V_TRIP_TYPE := 'Business Trip Per Diem';
ELSIF P_PEI_INFORMATION1 = 'TRAINING'
THEN
V_TRIP_TYPE := 'Training Per Diem';
ELSIF P_PEI_INFORMATION1 = 'CONFERENCE'
THEN
V_TRIP_TYPE :=
'Conference Seminar and Trade Fairs Per Diem';
END IF;

SELECT DECODE (P_PEI_INFORMATION1,


'RFBT', 'Business Trip',
'TRAINING', 'Training',
P_PEI_INFORMATION1)
INTO V_P_ENTRY_VALUE2
FROM DUAL;

V_ELEMENT_LINK_ID :=
HR_ENTRY_API.GET_LINK (
P_ASSIGNMENT_ID => V_ASSIGNMENT_ID,
P_ELEMENT_TYPE_ID => XXQSC_PAYROLL.GET_ELEMENT_TYPE_ID (
P_BUSINESS_GROUP_ID => 81,
P_ELEMENT_NAME =>
V_TRIP_TYPE),
P_SESSION_DATE => V_EFFECTIVE_DATE);
PAY_ELEMENT_ENTRY_API.CREATE_ELEMENT_ENTRY (
P_EFFECTIVE_DATE => V_ELE_DATE,
P_BUSINESS_GROUP_ID => 81,
P_ASSIGNMENT_ID => V_ASSIGNMENT_ID,
P_ELEMENT_LINK_ID => V_ELEMENT_LINK_ID,
P_ENTRY_TYPE => 'E',
p_input_value_id1 => xxqsc_hr_wf_pkg.get_input_id (
V_TRIP_TYPE,
'Amount'),
p_input_value_id2 => xxqsc_hr_wf_pkg.get_input_id (
V_TRIP_TYPE,
'Official Travel Description'),
p_input_value_id3 => xxqsc_hr_wf_pkg.get_input_id (
V_TRIP_TYPE,
'Departure Date'),
p_input_value_id4 => xxqsc_hr_wf_pkg.get_input_id (
V_TRIP_TYPE,
'Return Date'),
p_input_value_id5 => xxqsc_hr_wf_pkg.get_input_id (
V_TRIP_TYPE,
'First Day Of Business'),
p_input_value_id6 => xxqsc_hr_wf_pkg.get_input_id (
V_TRIP_TYPE,
'Last Day Of Business'),
p_input_value_id7 => xxqsc_hr_wf_pkg.get_input_id (
V_TRIP_TYPE,
'Source'),
p_entry_value1 => P_PEI_INFORMATION27,
p_entry_value2 => V_P_ENTRY_VALUE2,
p_entry_value3 => fnd_date.canonical_to_date (
P_PEI_INFORMATION10),
p_entry_value4 => fnd_date.canonical_to_date (
P_PEI_INFORMATION11),
p_entry_value5 => fnd_date.canonical_to_date (
P_PEI_INFORMATION2),
p_entry_value6 => fnd_date.canonical_to_date (
P_PEI_INFORMATION3),
p_entry_value7 => 'Travel Advance Self Service',
P_EFFECTIVE_START_DATE => V_EFFECTIVE_START_DATE,
P_EFFECTIVE_END_DATE => V_EFFECTIVE_END_DATE,
P_ELEMENT_ENTRY_ID => V_ELEMENT_ENTRY_ID,
P_OBJECT_VERSION_NUMBER => V_OBJECT_VERSION_NUMBER,
P_CREATE_WARNING => V_CREATE_WARNING);
END IF;
END IF;
END;

-------------------
UPDATE PER_PEOPLE_EXTRA_INFO a
SET A.PEI_INFORMATION28 = 'PAID' --- Advanced Status Field----
WHERE A.PERSON_EXTRA_INFO_ID = P_PEI_INFORMATION13;
--------------------
END IF;

-----------------------------------------------------------------------------------
---------------------------------------------

-----------------------------QSC_SS_TRAVEL_AUTHORIZATION_REQ
---------------------------------
IF p_information_type = 'QSC_SS_TRAVEL_AUTHORIZE_REQ'
THEN
DECLARE
v_trip_type VARCHAR2 (100);
v_ele_date DATE;
BEGIN
/*IF SYSDATE > TO_DATE(NVL(XXQSC_HR_UTILITY2.GET_GLOBAL_VAL('
GV_CREATE_TRAVEL_ELEMENT_DAY'),'19')
||TO_CHAR(SYSDATE,'MM-YYYY'),'DD-MM-YYYY')
THEN
V_ELE_DATE := TRUNC(ADD_MONTHS(SYSDATE,1),'MONTH');
ELSE*/
v_ele_date := SYSDATE;

--END IF;
----------
IF p_pei_information2 IN ('BT', 'TRAINING', 'CONFERENCE')
THEN
IF NVL (p_pei_information23, 0) > 0
THEN
IF p_pei_information2 = 'BT'
THEN
v_trip_type := 'Business Trip Per Diem';
ELSIF p_pei_information2 = 'TRAINING'
THEN
v_trip_type := 'Training Per Diem';
ELSIF p_pei_information2 = 'CONFERENCE'
THEN
v_trip_type :=
'Conference Seminar and Trade Fairs Per Diem';
END IF;

v_element_link_id :=
hr_entry_api.get_link (
p_assignment_id => v_assignment_id,
p_element_type_id => xxqsc_payroll.get_element_type_id (
p_business_group_id => 81,
p_element_name =>
v_trip_type),
p_session_date => v_effective_date);
pay_element_entry_api.create_element_entry (
p_effective_date => v_ele_date,
p_business_group_id => 81,
p_assignment_id => v_assignment_id,
p_element_link_id => v_element_link_id,
p_entry_type => 'E',
p_input_value_id1 => xxqsc_hr_wf_pkg.get_input_id (
v_trip_type,
'Amount'),
p_input_value_id2 => xxqsc_hr_wf_pkg.get_input_id (
v_trip_type,
'Official Travel Description'),
p_input_value_id3 => xxqsc_hr_wf_pkg.get_input_id (
v_trip_type,
'Departure Date'),
p_input_value_id4 => xxqsc_hr_wf_pkg.get_input_id (
v_trip_type,
'Return Date'),
p_input_value_id5 => xxqsc_hr_wf_pkg.get_input_id (
v_trip_type,
'First Day Of Business'),
p_input_value_id6 => xxqsc_hr_wf_pkg.get_input_id (
v_trip_type,
'Last Day Of Business'),
p_input_value_id7 => xxqsc_hr_wf_pkg.get_input_id (
v_trip_type,
'Source'),
p_entry_value1 => p_pei_information23,
p_entry_value2 => p_pei_information2,
p_entry_value3 => fnd_date.canonical_to_date (
p_pei_information8),
p_entry_value4 => fnd_date.canonical_to_date (
p_pei_information9),
p_entry_value5 => fnd_date.canonical_to_date (
p_pei_information10),
p_entry_value6 => fnd_date.canonical_to_date (
p_pei_information11),
p_entry_value7 => 'Travel Authorization Self
Service',
p_effective_start_date => v_effective_start_date,
p_effective_end_date => v_effective_end_date,
p_element_entry_id => v_element_entry_id,
p_object_version_number => v_object_version_number,
p_create_warning => v_create_warning);
END IF;
END IF;

-----------
UPDATE per_people_extra_info a
SET a.pei_information30 = 'APPROVED'
WHERE a.person_id = p_person_id
AND a.information_type = 'QSC_SS_TRAVEL_AUTHORIZE_REQ'
AND fnd_date.canonical_to_date (p_pei_information10) =
fnd_date.canonical_to_date (a.pei_information10)
AND fnd_date.canonical_to_date (p_pei_information11) =
fnd_date.canonical_to_date (a.pei_information11)
AND fnd_date.canonical_to_date (p_pei_information8) =
fnd_date.canonical_to_date (a.pei_information8)
AND fnd_date.canonical_to_date (p_pei_information9) =
fnd_date.canonical_to_date (a.pei_information9)
AND NVL (a.pei_information30, 'EMPTY') <> 'CANCELED';
END;
END IF;

-----------------------------QSC_SS_TRAVEL_CANCEL_REQ
---------------------------------
IF p_information_type = 'QSC_SS_TRAVEL_CANCEL_REQ'
THEN
DECLARE
CURSOR c1
IS
SELECT *
FROM xxqsc_travel_authorization_v
WHERE person_extra_info_id = p_pei_information1;

BEGIN
FOR r1 IN c1
LOOP
/*hr_utility.set_message (800,
XXQSC_HR_UTILITY2.get_element_process_status(v_assignment_id,
r1.Official_Travel_Description,r1.Departure_Date) );
hr_utility.raise_error;*/
IF NVL (r1.PER_DIEM_PAID_AMOUNT, r1.Per_Diem_Amount) > 0
--xxqsc_hr_utility2.get_element_process_status (
--v_assignment_id,
--r1.official_travel_description,
--r1.departure_date) = 'Y'
THEN
--------
DECLARE
v_trip_type VARCHAR2 (100);
BEGIN
IF r1.official_travel_description = 'BT'
THEN
v_trip_type := 'Business Trip Per Diem';
ELSIF r1.official_travel_description = 'TRAINING'
THEN
v_trip_type := 'Training Per Diem';
ELSIF r1.official_travel_description = 'CONFERENCE'
THEN
v_trip_type :=
'Conference Seminar and Trade Fairs Per Diem';
END IF;

v_element_link_id :=
hr_entry_api.get_link (
p_assignment_id => v_assignment_id,
p_element_type_id => xxqsc_payroll.get_element_type_id
(
p_business_group_id => 81,
p_element_name =>
v_trip_type),
p_session_date => v_effective_date);
pay_element_entry_api.create_element_entry (
p_effective_date => v_effective_date,
p_business_group_id => 81,
p_assignment_id => v_assignment_id,
p_element_link_id => v_element_link_id,
p_entry_type => 'E',
p_input_value_id1 => xxqsc_hr_wf_pkg.get_input_id (
v_trip_type,
'Amount'),
p_input_value_id2 => xxqsc_hr_wf_pkg.get_input_id (
v_trip_type,
'Official Travel
Description'),
p_input_value_id3 => xxqsc_hr_wf_pkg.get_input_id (
v_trip_type,
'Departure Date'),
p_input_value_id4 => xxqsc_hr_wf_pkg.get_input_id (
v_trip_type,
'Return Date'),
p_input_value_id5 => xxqsc_hr_wf_pkg.get_input_id (
v_trip_type,
'First Day Of Business'),
p_input_value_id6 => xxqsc_hr_wf_pkg.get_input_id (
v_trip_type,
'Last Day Of Business'),
p_input_value_id7 => xxqsc_hr_wf_pkg.get_input_id (
v_trip_type,
'Source'),
p_entry_value1 => NVL (
r1.PER_DIEM_PAID_AMOUNT,
r1.Per_Diem_Amount)
* -1,
p_entry_value2 =>
r1.official_travel_description,
p_entry_value3 => fnd_date.canonical_to_date (
r1.departure_date),
p_entry_value4 => fnd_date.canonical_to_date (
r1.return_date),
p_entry_value5 => fnd_date.canonical_to_date (
r1.first_day_of_business),
p_entry_value6 => fnd_date.canonical_to_date (
r1.last_day_of_business),
p_entry_value7 => 'Canceled Self Service TA',
p_effective_start_date => v_effective_start_date,
p_effective_end_date => v_effective_end_date,
p_element_entry_id => v_element_entry_id,
p_object_version_number => v_object_version_number,
p_create_warning => v_create_warning);
END;
-------
ELSIF xxqsc_hr_utility2.get_element_process_status (
v_assignment_id,
r1.official_travel_description,
r1.departure_date) = 'N'
THEN
DECLARE
v_start DATE;
v_end DATE;
v_del_w BOOLEAN;
v_entry_id NUMBER
:= xxqsc_hr_utility2.get_element_entry_id (
v_assignment_id,
r1.official_travel_description,
r1.departure_date);
v_ovn NUMBER;
BEGIN
--- get ovn number;
BEGIN
SELECT c.object_version_number
INTO v_ovn
FROM pay_element_entries_f c
WHERE c.element_entry_id = v_entry_id;
EXCEPTION
WHEN OTHERS
THEN
NULL;
END;

/*hr_utility.set_message (800, V_OVN);


hr_utility.raise_error;*/
IF v_entry_id > 0
THEN
pay_element_entry_api.delete_element_entry (
p_datetrack_delete_mode => 'ZAP',
p_effective_date => SYSDATE,
p_element_entry_id => v_entry_id,
p_object_version_number => v_ovn,
p_effective_start_date => v_start,
p_effective_end_date => v_end,
p_delete_warning => v_del_w);
END IF;
END;
END IF;
END LOOP;

UPDATE per_people_extra_info a
SET a.pei_information30 = 'CANCELED'
WHERE a.person_extra_info_id = p_pei_information1;
END;
END IF;

------------------------------Ticket Allowance HR Request Action


---------------------------------
IF p_information_type = 'QSC_SS_ANNUAL_TICKET_HR_REQ'
THEN
DECLARE
v_ticket_val NUMBER := 0;
v_input1 NUMBER;
v_input2 NUMBER;
v_input3 NUMBER;
v_input4 NUMBER;
v_input5 NUMBER;
v_input6 NUMBER;
v_input7 NUMBER;
BEGIN
v_element_link_id :=
hr_entry_api.get_link (
p_assignment_id => v_assignment_id,
p_element_type_id => xxqsc_payroll.get_element_type_id (
p_business_group_id => 81,
p_element_name => 'Annual Ticket
Payment'),
p_session_date => v_effective_date);
v_input1 :=
xxqsc_hr_wf_pkg.get_input_id ('Annual Ticket Payment',
'Pay Value');
v_input2 :=
xxqsc_hr_wf_pkg.get_input_id ('Annual Ticket Payment',
'Employee Name');
v_input3 :=
xxqsc_hr_wf_pkg.get_input_id ('Annual Ticket Payment',
'Spouse Name');
v_input4 :=
xxqsc_hr_wf_pkg.get_input_id ('Annual Ticket Payment',
'Child 1 Name');
v_input5 :=
xxqsc_hr_wf_pkg.get_input_id ('Annual Ticket Payment',
'Child 2 Name');
v_input6 :=
xxqsc_hr_wf_pkg.get_input_id ('Annual Ticket Payment',
'Child 3 Name');
v_input7 :=
xxqsc_hr_wf_pkg.get_input_id ('Annual Ticket Payment',
'Child 4 Name');

IF p_pei_information2 IS NOT NULL


THEN
v_ticket_val := NVL (p_pei_information3, 0);
-- PARENT
END IF;

IF p_pei_information4 IS NOT NULL


THEN
v_ticket_val := v_ticket_val + NVL (p_pei_information5, 0);
-- SPOUSE
END IF;

IF p_pei_information6 IS NOT NULL


THEN
v_ticket_val := v_ticket_val + NVL (p_pei_information7, 0);
-- CHILD1
END IF;

IF p_pei_information8 IS NOT NULL


THEN
v_ticket_val := v_ticket_val + NVL (p_pei_information9, 0);
-- CHILD2
END IF;

IF p_pei_information10 IS NOT NULL


THEN
v_ticket_val := v_ticket_val + NVL (p_pei_information11, 0);
END IF;

IF p_pei_information12 IS NOT NULL


THEN
v_ticket_val := v_ticket_val + NVL (p_pei_information13, 0);
-- CHILD4
END IF;

IF v_ticket_val > 0
THEN
pay_element_entry_api.create_element_entry (
p_effective_date => v_effective_date,
p_business_group_id => 81,
p_assignment_id => v_assignment_id,
p_element_link_id => v_element_link_id,
p_entry_type => 'E',
p_input_value_id1 => v_input1,
p_input_value_id2 => v_input2,
p_input_value_id3 => v_input3,
p_input_value_id4 => v_input4,
p_input_value_id5 => v_input5,
p_input_value_id6 => v_input6,
p_input_value_id7 => v_input7,
p_entry_value1 => v_ticket_val,
p_entry_value2 => p_pei_information2,
p_entry_value3 => p_pei_information4,
p_entry_value4 => p_pei_information6,
p_entry_value5 => p_pei_information8,
p_entry_value6 => p_pei_information10,
p_entry_value7 => p_pei_information12,
p_effective_start_date => v_effective_start_date,
p_effective_end_date => v_effective_end_date,
p_element_entry_id => v_element_entry_id,
p_object_version_number => v_object_version_number,
p_create_warning => v_create_warning);
END IF;
END;
END IF;

--------------------- LONG TERM INCENTIVE REQUEST


------------------------------
IF p_information_type = 'QSC_SS_LONG_TERM_INC_REQUEST'
THEN
DECLARE
v_input1 NUMBER;
v_input2 NUMBER;
v_input3 NUMBER;
v_input4 NUMBER;
v_input5 NUMBER;
v_input6 NUMBER;
v_input7 NUMBER;
v_input8 NUMBER;
v_input9 NUMBER;
v_input10 NUMBER;
BEGIN
v_input1 :=
xxqsc_hr_wf_pkg.get_input_id ('Long Term Incentive',
'Pay Value');
v_input2 :=
xxqsc_hr_wf_pkg.get_input_id ('Long Term Incentive',
'Override Amount');
v_input3 :=
xxqsc_hr_wf_pkg.get_input_id ('Long Term Incentive',
'Joining Date');
v_input4 :=
xxqsc_hr_wf_pkg.get_input_id ('Long Term Incentive',
'Total Period of Service');
v_input5 :=
xxqsc_hr_wf_pkg.get_input_id ('Long Term Incentive',
'Eligible for');
v_input6 :=
xxqsc_hr_wf_pkg.get_input_id ('Long Term Incentive', 'Rate');
v_input7 :=
xxqsc_hr_wf_pkg.get_input_id ('Long Term Incentive',
'Basic Salary');
v_input8 :=
xxqsc_hr_wf_pkg.get_input_id ('Long Term Incentive',
'Payment Period');

v_input9 :=
xxqsc_hr_wf_pkg.get_input_id ('Long Term Incentive', 'Note');

v_input10 :=
xxqsc_hr_wf_pkg.get_input_id ('Long Term Incentive', 'Source');

v_element_link_id :=
hr_entry_api.get_link (
p_assignment_id => v_assignment_id,
p_element_type_id => xxqsc_payroll.get_element_type_id (
p_business_group_id => 81,
p_element_name => 'Long Term
Incentive'),
p_session_date => v_effective_date);
pay_element_entry_api.create_element_entry (
p_effective_date => v_effective_date,
p_business_group_id => 81,
p_assignment_id => v_assignment_id,
p_element_link_id => v_element_link_id,
p_entry_type => 'E',
p_input_value_id1 => v_input1,
p_input_value_id2 => v_input2,
p_input_value_id3 => v_input3,
p_input_value_id4 => v_input4,
p_input_value_id5 => v_input5,
p_input_value_id6 => v_input6,
p_input_value_id7 => v_input7,
p_input_value_id8 => v_input8,
p_input_value_id9 => v_input9,
p_input_value_id10 => v_input10,
p_entry_value1 => NULL,
p_entry_value2 => NULL,
p_entry_value3 => (fnd_date.canonical_to_date (
p_pei_information6)),
p_entry_value4 => p_pei_information2,
p_entry_value5 => p_pei_information3,
p_entry_value6 => p_pei_information4,
p_entry_value7 => p_pei_information7,
p_entry_value8 => TO_CHAR (SYSDATE, 'MM-RRRR'),
p_entry_value9 => p_pei_information5,
p_entry_value10 => 'SSHR Long Term Incentive Request',
p_effective_start_date => v_effective_start_date,
p_effective_end_date => v_effective_end_date,
p_element_entry_id => v_element_entry_id,
p_object_version_number => v_object_version_number,
p_create_warning => v_create_warning);
END;
END IF;

------------------------ Acting Allowance Request ------------------


IF p_information_type = 'QSC_SS_ACTING_ALLOWANCE_REQ'
THEN
DECLARE
v_input1 NUMBER;
v_input2 NUMBER;
v_input3 NUMBER;
v_input4 NUMBER;
v_input5 NUMBER;
v_input6 NUMBER;
v_input7 NUMBER;
v_input8 NUMBER;
v_input9 NUMBER;
v_input10 NUMBER;
BEGIN
v_input1 :=
xxqsc_hr_wf_pkg.get_input_id ('Acting Allowance',
'Type Of Acting');
v_input2 :=
xxqsc_hr_wf_pkg.get_input_id ('Acting Allowance',
'Start Date');
v_input3 :=
xxqsc_hr_wf_pkg.get_input_id ('Acting Allowance', 'End Date');
v_input4 :=
xxqsc_hr_wf_pkg.get_input_id ('Acting Allowance', 'Notes');
v_input5 :=
xxqsc_hr_wf_pkg.get_input_id ('Acting Allowance', 'Notes 2');

v_effective_date := TRUNC (SYSDATE);

v_element_link_id :=
hr_entry_api.get_link (p_assignment_id => v_assignment_id,
p_element_type_id => 174
/*xxqsc_payroll.get_element_type_id (
p_business_group_id
=> 81,
p_element_name
=> 'Acting Allowance')*/
,
p_session_date => v_effective_date);
pay_element_entry_api.create_element_entry (
p_effective_date => v_effective_date,
p_business_group_id => 81,
p_assignment_id => v_assignment_id,
p_element_link_id => v_element_link_id,
p_entry_type => 'E',
p_input_value_id1 => v_input1,
p_input_value_id2 => v_input2,
p_input_value_id3 => v_input3,
p_input_value_id4 => v_input4,
p_input_value_id5 => v_input5,
p_entry_value1 => 'BEHALF',
p_entry_value2 => fnd_date.canonical_to_date (
p_PEI_INFORMATION2),
p_entry_value3 => fnd_date.canonical_to_date (
p_PEI_INFORMATION3),
p_entry_value4 => XXCONTRACT_Pkg.Get_Employee_Name_EC (
p_PEI_INFORMATION5,
'US'),
p_entry_value5 => p_PEI_INFORMATION29,
p_effective_start_date => v_effective_start_date,
p_effective_end_date => v_effective_end_date,
p_element_entry_id => v_element_entry_id,
p_object_version_number => v_object_version_number,
p_create_warning => v_create_warning);
END;
END IF;
END;

------------------------------------- ABS USER HOOK


------------------------------------------------------
PROCEDURE create_person_absence_b (
p_person_id IN NUMBER,
p_effective_date IN DATE,
p_business_group_id IN NUMBER,
p_absence_attendance_type_id IN NUMBER,
p_abs_attendance_reason_id IN NUMBER,
p_comments IN CLOB,
p_date_notification IN DATE,
p_date_projected_start IN DATE,
p_time_projected_start IN VARCHAR2,
p_date_projected_end IN DATE,
p_time_projected_end IN VARCHAR2,
p_date_start IN DATE,
p_time_start IN VARCHAR2,
p_date_end IN DATE,
p_time_end IN VARCHAR2,
p_absence_days IN NUMBER,
p_absence_hours IN NUMBER,
p_authorising_person_id IN NUMBER,
p_replacement_person_id IN NUMBER,
p_attribute_category IN VARCHAR2,
p_attribute1 IN VARCHAR2,
p_attribute2 IN VARCHAR2,
p_attribute3 IN VARCHAR2,
p_attribute4 IN VARCHAR2,
p_attribute5 IN VARCHAR2,
p_attribute6 IN VARCHAR2,
p_attribute7 IN VARCHAR2,
p_attribute8 IN VARCHAR2,
p_attribute9 IN VARCHAR2,
p_attribute10 IN VARCHAR2,
p_attribute11 IN VARCHAR2,
p_attribute12 IN VARCHAR2,
p_attribute13 IN VARCHAR2,
p_attribute14 IN VARCHAR2,
p_attribute15 IN VARCHAR2,
p_attribute16 IN VARCHAR2,
p_attribute17 IN VARCHAR2,
p_attribute18 IN VARCHAR2,
p_attribute19 IN VARCHAR2,
p_attribute20 IN VARCHAR2)
AS
v_bg NUMBER := 81;
v_nat VARCHAR2 (10);
lx_selected_leave_type VARCHAR2 (150);

CURSOR leaves (
p_selected_leave VARCHAR2)
IS
SELECT TRIM (meaning) Leave_Type
FROM fnd_lookup_values
WHERE lookup_type = 'XXQSC_LEAVE_ATTACH_REQ'
AND language = 'US'
AND TRIM (meaning) = p_selected_leave;

BEGIN
v_nat := xxqsc_hr_wf_pkg.get_employee_nationality (v_bg, p_person_id);

------------------- check Vacation Plan validations


IF p_absence_attendance_type_id = 63 AND p_attribute4 IS NULL
THEN
FND_MESSAGE.SET_NAME ('FND', 'FND_GENERIC_MESSAGE');
FND_MESSAGE.SET_TOKEN (
'MESSAGE',
'You cannot submit Annual Leave without selecting Planned Leave, Please
select Planned Leave from list.');
fnd_message.raise_error;
END IF;

IF p_absence_attendance_type_id = 63 AND p_attribute4 = 1 AND p_absence_days


> 4 and p_attribute1 is null
THEN
FND_MESSAGE.SET_NAME ('FND', 'FND_GENERIC_MESSAGE');
FND_MESSAGE.SET_TOKEN (
'MESSAGE',
'Annual Leave with More than 4 days of Not Planned Not Allowed ');
fnd_message.raise_error;
END IF;

--Annual Leave Return


------------------- check leave exit permit validations
IF v_nat = 'QATAR' AND p_attribute2 = 'Y'
THEN
fnd_message.set_name ('PER', 'XX_SS_FOR_NONQA');
fnd_message.raise_error;
END IF;

IF UPPER (fnd_profile.VALUE ('RESP_NAME')) LIKE ('%SELF%SERVICE')


THEN
BEGIN
SELECT name
INTO lx_selected_leave_type
FROM per_absence_attendance_types
WHERE absence_attendance_type_id = p_absence_attendance_type_id;
EXCEPTION
WHEN OTHERS
THEN
lx_selected_leave_type := NULL;
END;

FOR rec IN leaves (lx_selected_leave_type)


LOOP
IF lx_selected_leave_type = rec.leave_type
THEN
IF XX_HR_PKG.GET_ATTACH_THE_DOCUMENT (
p_person_id,
P_EFFECTIVE_DATE,
p_date_start,
p_date_end,
p_absence_attendance_type_id) = 0
THEN
FND_MESSAGE.SET_NAME ('FND', 'FND_GENERIC_MESSAGE');
FND_MESSAGE.SET_TOKEN (
'MESSAGE',
'Attachment Required for selected leave type : '
|| lx_selected_leave_type
|| ' . ');
FND_MESSAGE.RAISE_ERROR;
END IF;
END IF;
END LOOP;
END IF;
--
-- IF UPPER (fnd_profile.VALUE ('RESP_NAME')) LIKE ('%SELF%SERVICE')
-- THEN
-- IF p_absence_attendance_type_id = 81
-- THEN
-- IF XX_HR_PKG.GET_ATTACH_THE_DOCUMENT (
-- p_person_id,
-- P_EFFECTIVE_DATE,
-- p_date_start,
-- p_date_end,
-- p_absence_attendance_type_id) = 0
-- THEN
-- FND_MESSAGE.SET_NAME ('FND', 'FND_GENERIC_MESSAGE');
-- FND_MESSAGE.SET_TOKEN (
-- 'MESSAGE',
-- 'You can not submit sick leave with certificate without
attachment, Please Attach the certificate.');
-- FND_MESSAGE.RAISE_ERROR;
-- END IF;
-- END IF;
-- END IF;
END;
END xxqsc_user_hook;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy