Friday, July 3, 2015

Query: People State Tax Rules





select
    ppf.employee_number                                         "Employee Number",
    --
    pus.state_name                                             "State",
    hrl.meaning                                                "W4 Info :Filing Status",
    str.withholding_allowances                                 "W4 Info :Allowances",
    str.secondary_wa                                           "W4 Info: Secon Allowances",
    str.additional_wa_amount                                   "W4 Info:Exemption Aaount",
    str.sit_additional_tax                                     "W4 Info:Addn Tax",
    str.sit_optional_calc_ind                                  "W4 Info :Opt Calc" ,
    str.sit_exempt                                             "Tax Ex: SIT",
    str.sdi_exempt                                             "Tax Ex: SDI",
    str.sui_exempt                                             "Tax Ex: SUI",
    str.wc_exempt                                              "Tax Ex: WC",
    str.sit_override_rate                                      "SIT Override:Regular Rate",
    str.sit_override_amount                                    "SIT Override:Regular Amount",
    str.supp_tax_override_rate                                 "SIT Override: Supp Rate",
    str.sui_wage_base_override_amount                          "SUI Base Override",
    str.excessive_wa_reject_date                               "Lock in Date",
    str.state_non_resident_cert                                "Non Resi Certi",
    str.wage_exempt                                            "SIT Exm Fm Wg Accm",
    str.effective_start_date                                   "Effective Date : From",
    decode (str.effective_end_date,
    to_date ('31124712', 'DDMMYYYY'), null,
    str.effective_end_date)                                    "Effective Date: To",
    --
    str.assignment_id,
    str.business_group_id
    --
from
    pay_us_emp_state_tax_rules_f str,
    pay_us_states pus,
    pay_state_rules psr,
    hr_lookups hrl,
    per_all_assignments_f paaf,
    per_people_f ppf
where    
    pus.state_code = str.state_code
and psr.state_code = pus.state_abbrev
and hrl.lookup_type = psr.fs_lookup_type
and nvl(str.effective_end_date,sysdate)>sysdate-1
and hrl.lookup_code = ltrim (str.filing_status_code, '0')
and str.assignment_id = paaf.assignment_id
and nvl(paaf.effective_end_date,sysdate)>sysdate-1
and paaf.person_id = ppf.person_id
--
and ppf.employee_number='1309'
order by
      1,2;         

Query: People County Tax Rules




select
    ppf.employee_number                               "Employee Number",
    --
    pus.state_name                                    "State",
    puc.county_name                                   "County",
    hrl.meaning                                       "W4 Info: Filing Status",
    ctr.withholding_allowances                        "W4 Info: Allowances",
    ctr.lit_additional_tax                            "W4 Info: Additional Tax",
    ctr.additional_wa_rate                            "W4 Info:Add Alllow Rate",
    ctr.lit_exempt                                    "Tax Ex:Local Income",
    ctr.sd_exempt                                     "Tax Ex:School District",
    ctr.ht_exempt                                     "Tax Ex: Occu Privilage",
    ctr.lit_override_rate                             "LIT Override: Rate",
    ctr.lit_override_amount                           "LIT Override: Amount",
    psd.school_dst_name                               "School District",
    ctr.wage_exempt                                   "LIT Ex from Wge Accu",
    ctr.effective_start_date                          "Effective Dates: From",
    decode (ctr.effective_end_date,
    to_date ('31124712', 'DDMMYYYY'), null,
    ctr.effective_end_date)                           "Effective Dates: To",
    --
    ctr.assignment_id
from
    pay_us_emp_county_tax_rules_f ctr,
    pay_us_states pus,
    pay_us_counties puc,
    hr_lookups hrl,
    pay_us_county_school_dsts psd,
    per_all_assignments_f paaf,
    per_people_f ppf
where  
    1=1
and ctr.state_code = pus.state_code
and ctr.state_code = puc.state_code
and ctr.county_code = puc.county_code
and ctr.filing_status_code = hrl.lookup_code
and hrl.lookup_type = 'US_LIT_FILING_STATUS'
and ctr.state_code = psd.state_code(+)
and ctr.county_code = psd.county_code(+)
and ctr.school_district_code = psd.school_dst_code(+)
and ctr.assignment_id = paaf.assignment_id
and nvl(paaf.effective_end_date,sysdate)>sysdate-1
and paaf.person_id = ppf.person_id
--
and ppf.employee_number='1309'
order by
      1,2;

Query: People City Tax Rules





select
    ppf.employee_number                                         "Employee Number",
    --
    pus.state_name                                             "State",
    pucnty.county_name                                         "County",
    pucity.city_name                                           "City",
    hrl.meaning                                                "W4 Info: Filing Status",
    ctr.withholding_allowances                                 "W4 Info: Allowances",
    ctr.lit_additional_tax                                     "W4 Info: Additional Tax",
    ctr.additional_wa_rate                                     "W4 Info: Additional All Rate",
    ctr.lit_exempt                                             "Tax Exn:Local Income",
    ctr.sd_exempt                                              "Tax Exn:School District",
    ctr.ht_exempt                                              "Tax Exn: Occupational Pri",
    ctr.lit_override_rate                                      "LIT Override:Rate",  
    ctr.lit_override_amount                                    "LIT Override:Amount",
    psd.school_dst_name                                        "School District",
    ctr.wage_exempt                                            "LIT Exmp From Wage Accn",
    ctr.effective_start_date                                   "Effective Dates: From",
    decode (ctr.effective_end_date,
    to_date ('31124712', 'DDMMYYYY'), null,
                  ctr.effective_end_date)                      "Effective Dates: To",
    --
    ctr.business_group_id,
    ctr.emp_city_tax_rule_id,
    ctr.assignment_id
    --
from
    pay_us_emp_city_tax_rules_f ctr,
    pay_us_states pus,
    pay_us_counties pucnty,
    pay_us_city_names pucity,
    hr_lookups hrl,
    pay_us_city_school_dsts psd,
    per_all_assignments_f paaf,
    per_people_f ppf
where
    ctr.state_code = pus.state_code
and ctr.state_code = pucnty.state_code
and ctr.county_code = pucnty.county_code
and ctr.state_code = pucity.state_code
and ctr.county_code = pucity.county_code
and ctr.city_code = pucity.city_code
and (pucity.primary_flag = 'Y' or substr (pucity.city_code, 1, 1) = 'U')
and ctr.filing_status_code = hrl.lookup_code
and hrl.lookup_type = 'US_LIT_FILING_STATUS'
and ctr.state_code = psd.state_code(+)
and ctr.county_code = psd.county_code(+)
and ctr.city_code = psd.city_code(+)
and ctr.school_district_code = psd.school_dst_code(+)
and ctr.assignment_id = paaf.assignment_id
and nvl(paaf.effective_end_date,sysdate)>sysdate-1
and paaf.person_id = ppf.person_id
--
and ppf.employee_number='1309'
order by
      1,2;

Query: Job Work Preferences




select
    pjt.name                         "Job",
    --
    pdf.work_any_location            "All Locations",
    pdf.passport_required            "Passport Required",
    pdf.relocation_required          "Relocation Required",
    pdf.relocate_domestically        "Relocation for Position",
    pdf.travel_required              "Travel Required",
    pdf.work_duration                "Work Duration",
    pdf.work_hours                   "Work Hours",
    pdf.service_minimum              "Minimum Service",     -- lookup :per_lengths_of_service
    pdf.work_schedule                "Work Schedule",       -- lookup :per_work_schedule
    pdf.fte_capacity                 "FTE Capacity",        -- lookup :per_work_hours
    pdf.work_any_country             "All Countries",
    pdf.relocate_internationally     "Willing to Relocate ",
    pdf.other_requirements           "Required Locations",
    ptv1.territory_short_name        "Rquired Countries1",
    hrl1tl.location_code             "Location1",
    ptv2.territory_short_name        "Rquired Countries2",
    hrl2tl.location_code             "Location2",
    ptv3.territory_short_name        "Rquired Countries3",
    hrl3tl.location_code             "Location3",
    --
    pj.job_id
from
    per_deployment_factors pdf,
    per_jobs pj,
    per_jobs_tl pjt,
    fnd_territories_vl ptv1,
    fnd_territories_vl ptv2,
    fnd_territories_vl ptv3,
    hr_locations_no_join hrl1,
    hr_locations_no_join hrl2,
    hr_locations_no_join hrl3,
    hr_locations_all_tl hrl1tl,
    hr_locations_all_tl hrl2tl,
    hr_locations_all_tl hrl3tl
where
    1=1
and pdf.job_id = pj.job_id
and pj.job_id = pjt.job_id
and pjt.language = userenv('LANG')
and ptv1.territory_code(+) = pdf.country1
and ptv2.territory_code(+) = pdf.country2
and ptv3.territory_code(+) = pdf.country3
and hrl1.location_id(+) = pdf.location1
and hrl2.location_id(+) = pdf.location2
and hrl3.location_id(+) = pdf.location3
and hrl1.location_id = hrl1tl.location_id(+)
and hrl2.location_id = hrl2tl.location_id(+)
and hrl3.location_id = hrl3tl.location_id(+)
and decode (hrl1tl.location_id, null, '1', hrl1tl.language) = decode (hrl1tl.location_id, null, '1', userenv ('LANG'))
and decode (hrl2tl.location_id, null, '1', hrl2tl.language) = decode (hrl2tl.location_id, null, '1', userenv ('LANG'))
and decode (hrl3tl.location_id, null, '1', hrl3tl.language) = decode (hrl3tl.location_id, null, '1', userenv ('LANG'))
--
and pjt.name = 'AA900.Administrative Assistant'
order by
    1,2,3;

Query: Contracts




select
    per.employee_number                                                              "Employee Number",
    --
    per.full_name                                                                    "Full Name",
    con.reference                                                                    "Contract Reference",
    asg.assignment_number                                                            "Assignment Number",
    hr_person_type_usage_info.get_user_person_type (sysdate,per.person_id)           "Person Type",
    per.applicant_number                                                             "Applicant Number",
    pps.date_start                                                                   "Hire Date",
    substr (hr_general.decode_lookup('CONTRACT_TYPE', con.type), 1, 80)              "Contract Type",  
    substr (hr_general.decode_lookup('CONTRACT_STATUS', con.status),1,80)            "Contract Status",
    substr ( hr_general.decode_lookup('CONTRACT_STATUS_REASON',con.status_reason),1,80) "Contract Status Reason",
    con.description                                                                     "Contract Description",
    con.duration                                                                        "Duration",
    substr ( hr_general.decode_lookup ('QUALIFYING_UNITS',con.duration_units), 1,80)    "Duration Units",
    con.contractual_job_title                                                           "Contractual Job Title",
    con.parties                                                                         "Parties",
    substr (hr_general.decode_lookup ('CONTRACT_START_REASON',con.start_reason),1,80)   "Start Reason",
    substr (hr_general.decode_lookup ('CONTRACT_END_REASON',con.end_reason),1,80)       "End Reason",
    con.number_of_extensions                                                            "Number of Extensions",
    con.extension_reason                                                                "Extension Reason",
    con.extension_period                                                                "Extension Period",
    substr (hr_general.decode_lookup ('QUALIFYING_UNITS',con.extension_period_units),1,80)  "Extension Period Units",
    greatest (con.effective_start_date, per.effective_start_date)                   "Effective Start Date",
    least (con.effective_end_date, per.effective_end_date)                          "Effective End Date",
     substr( hr_general.decode_lookup ('DOCUMENT_STATUS',con.doc_status),1,80)      "Document Status",
    con.doc_status_change_date                                                      "Date of Change",
    fnd_attachment_util_pkg.get_atchmt_exists ('PER_CONTRACTS',
                             con.contract_id,null,null,null,null,
                            'PERWSCTR','O')                                         "Attachment Exists",
    --
    asg.people_group_id,
    per.business_group_id,
    per.person_id
from
    per_people_f per,
    per_assignments_f asg,
    per_person_types ppt,
    per_periods_of_service pps,
    per_contracts_f con,
    per_business_groups bg
where
    con.person_id(+) = per.person_id
and pps.person_id = per.person_id
and asg.person_id = per.person_id
and asg.assignment_type in ('E','C')
and ppt.person_type_id = per.person_type_id
and sysdate between asg.effective_start_date and asg.effective_end_date
and sysdate between per.effective_start_date and per.effective_end_date
and per.business_group_id = bg.business_group_id
--
and bg.name = 'Vision Corporation'
and per.employee_number='388'
order by
    1,2,3,4;

Query: Contract Details





select
    ppf.employee_number                                              "Employee Number",
    --
    pcf1.reference                                                                  "Reference",
    hr_contract_api.get_meaning (pcf1.type, 'CONTRACT_TYPE')                        "Type",
    hr_contract_api.get_meaning (pcf1.status, 'CONTRACT_STATUS')                    "Status",
    hr_contract_api.get_meaning (pcf1.status_reason, 'CONTRACT_STATUS_REASON')      "Status Reason",
    pcf1.description                                                                "Description",
    hr_contract_api.get_meaning (pcf1.doc_status,'DOCUMENT_STATUS')                 "Document Status",
    doc_status_change_date                                                          "Date of Change",
    hr_contract_api.get_active_start_date(pcf1.contract_id,sysdate,pcf1.status)     "Active Dates:Start",
    hr_contract_api.get_active_end_date(pcf1.contract_id,sysdate,pcf1.status)       "Active Dates: End",
    hr_contract_api.get_pps_start_date(pcf1.person_id,
                hr_contract_api.get_active_start_date(pcf1.contract_id,
                        sysdate,pcf1.status))                                       "Per of Ser Dates:From",
    hr_contract_api.get_pps_end_date ( pcf1.person_id,
                hr_contract_api.get_active_start_date(pcf1.contract_id,
                        sysdate,pcf1.status))                                       "Per of Ser Dates:To",  
    pcf1.duration                                                                   "Duration",
    hr_contract_api.get_meaning (pcf1.duration_units,'QUALIFYING_UNITS')            "Units",
    hr_contract_api.get_meaning (pcf1.start_reason,'CONTRACT_START_REASON')         "Start Reason",
    hr_contract_api.get_meaning (pcf1.end_reason,'CONTRACT_END_REASON')             "End Reason",
    pcf1.contractual_job_title                                                      "Contractual Job",
    pcf1.parties                                                                    "Parties",
    pcf1.extension_period                                                           "Extension Period",
    hr_contract_api.get_meaning (pcf1.extension_period_units,'QUALIFYING_UNITS')    "Extension Period Units",
    pcf1.extension_reason                                                           "Extension Reason",
    pcf1.number_of_extensions                                                       "Number of Extensions",
    pcf1.effective_start_date                                                       "Effective Dates : From",
    pcf1.effective_end_date                                                         "Effective Dates : TO",
    --
    pcf1.contract_id,
    pcf1.person_id,
    pcf1.business_group_id
from
    per_contracts_f pcf1,
    per_people_f ppf,
    per_business_groups bg
where
    1=1
and pcf1.person_id = ppf.person_id
and sysdate between ppf.effective_start_date and ppf.effective_end_date
and ppf.business_group_id = bg.business_group_id
--
and bg.name = 'Vision Corporation'
and ppf.employee_number='388'
order by
    1,2,3;

Query: Events and Booking



select
    hr.meaning                                              "Type",
    pe.date_start                                           "Date:Start",
    pe.date_end                                             "Date: End",
    pe.time_start                                           "Time:Start",
    pe.time_end                                             "Time:End",
    hotl.name                                               "Org Run By",
    hltl.location_code                                      "Location",
    hl.timezone_code                                        "TimeZone",
    pe.external_contact                                     "External Contact: Name",
    pe.contact_telephone_number                             "External contact:Telephone",
    pap.full_name                                           "Internal Contact:Name",
    nvl (pap.employee_number, pap.npw_number)               "Internal Contact:Number",
    (select full_name
        from per_all_people_f
        where person_id = pb.person_id
        and sysdate between effective_start_date and effective_end_date)        "Bookings Name",
    (select employee_number
        from per_all_people_f
        where person_id = pb.person_id
        and sysdate between effective_start_date and effective_end_date)        "Worker Number",
    (select applicant_number
        from per_all_people_f
        where person_id = pb.person_id
        and sysdate between effective_start_date and effective_end_date)        "Applicant Number",
    --
    pe.event_id,
    pe.business_group_id,
    pe.assignment_id
    --
from
    per_events pe,
    per_bookings pb,
    per_all_people_f pap,
    hr_lookups hr,
    hr_locations_all_tl hltl,
    hr_locations_no_join hl,
    hr_all_organization_units ho,
    hr_all_organization_units_tl hotl
where  
    1=1
and ho.organization_id = hotl.organization_id(+)
and pe.organization_run_by_id = ho.organization_id(+)
and pe.event_or_interview = 'E'
and pe.type = hr.lookup_code
and pe.event_id=pb.event_id
and hr.lookup_type =decode (pe.emp_or_apl, 'E', 'EMP_EVENT_TYPE','A', 'APL_EVENT_TYPE')
and pe.location_id = hl.location_id(+)
and pe.internal_contact_person_id = pap.person_id(+)
and pe.date_start between nvl (pap.effective_start_date, pe.date_start)
and nvl (pap.effective_end_date, pe.date_start)
and decode (hotl.organization_id, null, '1', hotl.language) = decode (hotl.organization_id, null, '1', userenv ('LANG'))
and hl.location_id = hltl.location_id(+)
and decode (hltl.location_id, null, '1', hltl.language) =decode (hltl.location_id, null, '1', userenv ('LANG'))
--
and hr.meaning = 'Orientation Day'
order by
    1,2,3,4,5