DECLARE
v_eff_start_date DATE := NULL;
v_eff_end_date DATE := NULL;
v_input_value_id NUMBER := NULL;
v_element_link_id NUMBER := NULL;
v_element_name VARCHAR2 (500) := NULL;
v_element_type_id NUMBER := NULL;
v_batch_id NUMBER := NULL;
v_batch_line_id NUMBER := NULL;
v_batch_object_version_number NUMBER := NULL;
BEGIN
-- blcok to get batch id
BEGIN
SELECT batch_id
INTO v_batch_id
FROM pay_batch_headers pbh
WHERE TRIM (pbh.batch_name) = 'PASSPORT_JUNE';
EXCEPTION
WHEN OTHERS
THEN
NULL;
END;
-- block to get the effective start and end date as per hijri
BEGIN
SELECT start_date, end_date
INTO v_eff_start_date, v_eff_end_date
FROM per_time_periods ptp
WHERE TRUNC (SYSDATE) BETWEEN ptp.start_date AND ptp.end_date
AND ptp.payroll_id = 62;
EXCEPTION
WHEN OTHERS
THEN
NULL;
END;
-- get element details as per passport_deductions
BEGIN
SELECT pivf.input_value_id,
pelf.element_link_id,
petf.element_name,
petf.element_type_id
INTO v_input_value_id,
v_element_link_id,
v_element_name,
v_element_type_id
FROM pay_element_types_f petf,
pay_element_links_f pelf,
pay_input_values_f pivf
WHERE pelf.element_type_id = petf.element_type_id
AND TRUNC (SYSDATE) BETWEEN petf.effective_start_date
AND petf.effective_end_date
AND TRUNC (SYSDATE) BETWEEN pelf.effective_start_date
AND pelf.effective_end_date
AND pelf.payroll_id = 62
AND pivf.element_type_id = pivf.element_type_id
AND pivf.name = 'Amount'
AND TRUNC (SYSDATE) BETWEEN pivf.effective_start_date
AND pivf.effective_end_date
AND pivf.element_type_id = pelf.element_type_id
AND petf.element_name = 'PASSPORT_DEDUCTIONS';
EXCEPTION
WHEN OTHERS
THEN
v_input_value_id := NULL;
v_element_link_id := NULL;
END;
-- api to create element
pay_batch_element_entry_api.create_batch_line (
p_session_date => TRUNC (SYSDATE),
p_batch_id => v_batch_id,
p_assignment_id => 414,
p_assignment_number => 40180,
p_date_earned => TRUNC (SYSDATE),
p_effective_date => TRUNC (SYSDATE),
p_effective_start_date => v_eff_start_date,
p_effective_end_date => v_eff_end_date,
p_element_name => v_element_name,
p_element_type_id => v_element_type_id,
p_value_3 => 500,
p_batch_line_id => v_batch_line_id,
p_object_version_number => v_batch_object_version_number
);
COMMIT;
DBMS_OUTPUT.put_line (v_batch_id || ': SUCCESS');
DBMS_OUTPUT.put_line (v_batch_line_id || ': SUCCESS');
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('Main Exception: ' || SQLERRM);
END;
-- query
SELECT *
FROM pay_batch_lines
WHERE batch_line_id = 2913983
No comments:
Post a Comment