Saturday, August 24, 2013

Query to Get Payments made through Cheque

SELECT per.employee_number,
       per.full_name,
       pac.effective_date payement_date,
       paa.serial_number cheque_number,
       (SELECT 'Yes'
          FROM pay_payroll_actions ppa
         WHERE ppa.target_payroll_action_id = pac.payroll_action_id)
          Void,
       popm.org_payment_method_name payment_method,
       ppp.VALUE amount,
       hr_general.decode_lookup ('SA_BANKS', pea.segment1) bank_name,
       pea.segment2 bank_branch,
       pea.segment3 account_type,
       pea.segment4 account_number
  FROM pay_assignment_actions paa,
       pay_payroll_actions pac,
       per_all_assignments_f paaf,
       per_all_people_f per,
       pay_pre_payments ppp,
       pay_org_payment_methods_f popm,
       pay_external_accounts pea
 WHERE     paa.payroll_action_id = pac.payroll_action_id
       AND pac.action_type = 'H'
       AND paaf.assignment_id = paa.assignment_id
       AND paaf.assignment_type = 'E'
       AND paaf.primary_flag = 'Y'
       AND paaf.assignment_status_type_id = 1
       AND paaf.person_id = per.person_id
       AND pac.effective_date BETWEEN per.effective_start_date
                                  AND per.effective_end_date
       AND pac.effective_date BETWEEN paaf.effective_start_date
                                  AND paaf.effective_end_date
       AND ppp.pre_payment_id = paa.pre_payment_id
       AND popm.org_payment_method_id = ppp.org_payment_method_id
       AND popm.org_payment_method_id =
              NVL (:p_org_payement_method_id, popm.org_payment_method_id)
       AND paaf.business_group_id =
              fnd_profile.VALUE ('PER_BUSINESS_GROUP_ID')
       AND paaf.payroll_id = 61
       AND pac.effective_date BETWEEN :l_date_start AND :l_date_end
       AND pea.external_account_id = popm.external_account_id
       AND NVL (pea.enabled_flag, 'N') = 'Y'
       AND popm.payment_type_id = 24                   -- Payment Type: Cheque

No comments:

Post a Comment