Code to Retrive Balance Values

Submitted by code_admin on Thu, 07/12/2018 - 15:51
  1. select
  2.     so_far.assignment_id,
  3.     so_far.assignment_number,
  4.     so_far.payroll_name,
  5.     ptp.period_name,
  6.     ptp.regular_payment_date,
  7.     bv.defined_balance_id,
  8.     hr_gbbal.calc_all_balances (ptp.regular_payment_date,so_far.assignment_id,bv.defined_balance_id) as "BalVal",
  9.     papf_o.full_name    
  10. from (
  11.     select
  12.         paaf.person_id,
  13.         paaf.assignment_id,
  14.         paaf.assignment_number,
  15.         papf.payroll_name
  16.     from per_all_assignments_f paaf
  17.     inner join (
  18.         select papf1.payroll_id, papf1.payroll_name
  19.         from pay_all_payrolls_f papf1
  20.         where sysdate between papf1.effective_start_date and papf1.effective_end_date
  21.     ) papf on papf.payroll_id=paaf.payroll_id
  22.     where paaf.payroll_id in (nvl(p_payroll_id_one,0),nvl(p_payroll_id_two,0),nvl(p_payroll_id_three,0))
  23.     ---***********************TEST LINES TO RUN 2 EMPS ONLY*****************************
  24.     --and paaf.assignment_number in ('33474','46754')
  25.     --******************************END OF TEST LINES***********************************
  26.     and not (
  27.         (paaf.effective_end_date < p_tax_start)
  28.         or (paaf.effective_start_date > p_tax_end)
  29.     )
  30.     group by paaf.person_id, paaf.assignment_id, paaf.assignment_number, papf.payroll_name
  31. ) so_far
  32. inner join (
  33.     select period_name, regular_payment_date
  34.     from per_time_periods
  35.     where payroll_id in (
  36.         select papf1.payroll_id
  37.         from pay_all_payrolls_f papf1
  38.         where payroll_id in (nvl(p_payroll_id_one,0),nvl(p_payroll_id_two,0),nvl(p_payroll_id_three,0))
  39.         and regular_payment_date between p_tax_start and p_tax_end      
  40.     )
  41.     group by period_name, regular_payment_date
  42. ) ptp on 1=1
  43. left join (
  44.     select
  45.         pdb.defined_balance_id
  46.     from pay_balance_types pbt
  47.     inner join pay_defined_balances pdb on pdb.balance_type_id=pbt.balance_type_id
  48.     inner join pay_balance_dimensions pbd on pbd.balance_dimension_id=pdb.balance_dimension_id
  49.     where pbt.balance_name = p_balance_name
  50.     AND PBD.DIMENSION_name = p_balance_dimension
  51. ) bv on 1=1
  52. left join (
  53.     select papf1.person_id, papf1.full_name
  54.     from per_all_people_f papf1
  55.     where papf1.effective_start_date = (
  56.         select max(papf2.effective_start_date)
  57.         from per_all_people_f papf2
  58.         where papf1.person_id=papf2.person_id
  59.     )
  60. ) papf_o on papf_o.person_id=so_far.person_id
  61. order by so_far.assignment_id, ptp.regular_payment_date;

Search Terms

Balances Dimensions Dimension

RJM Article Type
Quick Reference