Tuesday, August 2, 2011

Payroll GL Account wise Break Up

/* Payroll GL Account wise Break Up */
/* You have a GL account for payrole , one can sue this query to find out break up for accounts like staff deduction etc */

SELECT FULL_NAME,EMPLOYEE_NUMBER,RESULT_VALUE,REPORTING_NAME,NAME, COST_SEGMENTS,COSTED_VALUE,DEBIT_OR_CREDIT
FROM
(
SELECT PAP.FULL_NAME,PAP.EMPLOYEE_NUMBER,V.RESULT_VALUE,
E.REPORTING_NAME,HORG.NAME, PCAK.CONCATENATED_SEGMENTS COST_SEGMENTS, PC.COSTED_VALUE, PC.BALANCE_OR_COST, PC.DEBIT_OR_CREDIT
FROM
APPS.PAY_RUN_RESULT_VALUES V,
APPS.PAY_RUN_RESULTS R,
APPS.PAY_ELEMENT_TYPES_F E,
APPS.PAY_ASSIGNMENT_ACTIONS A,
APPS.pay_payroll_actions P,
APPS.HR_ALL_ORGANIZATION_UNITS HORG,
APPS.per_all_assignments_f PAA,
APPS.PAY_COST_ALLOCATION_KEYFLEX PCAK,
APPS.PAY_COSTS PC,
APPS.per_all_people_f PAP,
APPS.PAY_INPUT_VALUES_F PIV
WHERE R.ELEMENT_TYPE_ID=E.ELEMENT_TYPE_ID
AND V.RUN_RESULT_ID=R.RUN_RESULT_ID
--AND R.SOURCE_TYPE<>'E'
AND R.ASSIGNMENT_ACTION_ID=A.ASSIGNMENT_ACTION_ID
AND A.PAYROLL_ACTION_ID=P.PAYROLL_ACTION_ID
AND A.ASSIGNMENT_ID=PAA.ASSIGNMENT_ID
AND (:P_EFFECTIVE_DATE BETWEEN PAA.EFFECTIVE_START_DATE AND PAA.EFFECTIVE_END_DATE)
AND PAA.PERSON_ID=PAP.PERSON_ID
AND (:P_EFFECTIVE_DATE BETWEEN PAP.EFFECTIVE_START_DATE AND PAP.EFFECTIVE_END_DATE)
AND PAA.ORGANIZATION_ID = HORG.ORGANIZATION_ID
AND P.EFFECTIVE_DATE= :P_EFFECTIVE_DATE
AND PCAK.SEGMENT5 = :P_ACCOUNT_NO
AND PC.COST_ALLOCATION_KEYFLEX_ID = PCAK.COST_ALLOCATION_KEYFLEX_ID
AND R.RUN_RESULT_ID = PC.RUN_RESULT_ID
AND V.INPUT_VALUE_ID = PIV.INPUT_VALUE_ID
AND PIV.UOM = 'M'
AND p.PAYROLL_ID = 63 -- will chage as per your company setup
)
WHERE RESULT_VALUE IS NOT NULL
GROUP BY FULL_NAME,EMPLOYEE_NUMBER,RESULT_VALUE,REPORTING_NAME,NAME, COST_SEGMENTS,COSTED_VALUE,DEBIT_OR_CREDIT

No comments:

Post a Comment