Fix Business Unit assignment for inactive workers
This commit is contained in:
@@ -20,7 +20,7 @@ latest_positions AS (
|
||||
FROM {{ source('tap_spreadsheets_anywhere', 'positions') }}
|
||||
WHERE _sdc_deleted_at IS NULL
|
||||
AND primary_position = 'Yes'
|
||||
ORDER BY assigned_employee_id, _sdc_received_at DESC, assigned_employee_effective_date
|
||||
ORDER BY assigned_employee_id, _sdc_received_at DESC, assigned_employee_effective_date DESC
|
||||
),
|
||||
|
||||
joined_data AS (
|
||||
@@ -60,7 +60,7 @@ joined_data AS (
|
||||
NULL::INTEGER AS employment_criticality,
|
||||
NULL::VARCHAR AS employment_probation_status,
|
||||
NULL::DATE AS employment_probation_end_date,
|
||||
d.path::ltree AS employment_department_path,
|
||||
COALESCE(d.path::ltree, d2.path::ltree) AS employment_department_path,
|
||||
NULL::VARCHAR(254) AS email,
|
||||
NULL::DATE AS employment_earliest_retirement_date,
|
||||
ROUND(p.fte_utilized_by_employee_in_this_position * 100)::INTEGER AS employment_fte_percentage,
|
||||
@@ -76,8 +76,10 @@ joined_data AS (
|
||||
FROM latest_workers w
|
||||
LEFT JOIN latest_positions p
|
||||
ON w.user_id = p.assigned_employee_id
|
||||
LEFT JOIN {{ ref('department') }} d
|
||||
LEFT JOIN {{ ref('department') }} d -- Source = Department from Positions report, only relevant for active workers
|
||||
ON p.assigned_unit_id = d.department_hris_id
|
||||
LEFT JOIN {{ ref('department') }} d2 -- Source = Business Unit from All Users report, only relevant for inactive workers
|
||||
ON w.business_unit = d2.name
|
||||
)
|
||||
|
||||
SELECT
|
||||
|
||||
Reference in New Issue
Block a user