diff --git a/uw_hrp/models.py b/uw_hrp/models.py index f2de25a..3dd7dc3 100644 --- a/uw_hrp/models.py +++ b/uw_hrp/models.py @@ -116,6 +116,7 @@ class WorkerPosition(models.Model): end_date = models.DateTimeField(null=True, default=None) ecs_job_cla_code_desc = models.CharField(max_length=96, null=True, default=None) + is_future_date = models.BooleanField(default=False) is_primary = models.BooleanField(default=False) location = models.CharField(max_length=96, null=True, default=None) pos_type = models.CharField(max_length=64, null=True, default=None) @@ -129,14 +130,12 @@ class WorkerPosition(models.Model): def is_active_position(self): return self.end_date is None or self.end_date > get_now() - def is_future_position(self): - return self.start_date is not None and self.start_date > get_now() - def to_json(self): data = {'start_date': date_to_str(self.start_date), 'end_date': date_to_str(self.end_date), 'ecs_job_cla_code_desc': self.ecs_job_cla_code_desc, 'fte_percent': self.fte_percent, + 'is_future_date': self.is_future_date, 'is_primary': self.is_primary, 'location': self.location, 'pos_type': self.pos_type, @@ -169,6 +168,7 @@ def __init__(self, *args, **kwargs): self.ecs_job_cla_code_desc = \ data.get("EcsJobClassificationCodeDescription") + self.is_future_date = data.get("IsFutureDate") self.is_primary = data.get("IsPrimaryPosition") if data.get("Location") is not None: self.location = data["Location"]["ID"] @@ -227,13 +227,14 @@ def __init__(self, *args, **kwargs): self.employee_status = EmploymentStatus( data=data.get("WorkerEmploymentStatus")) - if (self.employee_status.is_active and - data.get("WorkerPositions") is not None): - for position in data["WorkerPositions"]: - position = WorkerPosition(data=position) - if position.is_active_position(): - if position.is_primary: - self.primary_manager_id = position.supervisor_eid - self.primary_position = position - else: - self.other_active_positions.append(position) + if self.employee_status.is_active: + positions = data.get("WorkerPositions") + if positions is not None and len(positions) > 0: + for position in positions: + position = WorkerPosition(data=position) + if position.is_active_position(): + if position.is_primary: + self.primary_manager_id = position.supervisor_eid + self.primary_position = position + else: + self.other_active_positions.append(position) diff --git a/uw_hrp/resources/hrpws/file/hrp/v2/worker/10000000000000000000000000000015.json_workerpositionstate_current_future b/uw_hrp/resources/hrpws/file/hrp/v2/worker/10000000000000000000000000000015.json_workerpositionstate_current_future new file mode 100644 index 0000000..4701a57 --- /dev/null +++ b/uw_hrp/resources/hrpws/file/hrp/v2/worker/10000000000000000000000000000015.json_workerpositionstate_current_future @@ -0,0 +1,250 @@ +{ + "AcademicAppointments": + [{"AcademicAppointmentCompletedDate":"2017-06-22T07:00:00.000Z", + "AcademicAppointmentEndDate":null, + "AcademicAppointmentIdentifierID":"A", + "AcademicAppointmentIdentifierTypeID":"Administrative", + "AcademicAppointmentStartDate":"2017-04-01T07:00:00.000Z", + "AcademicAppointmentState":"Current", + "AcademicAppointmentTitle":"Chair", + "AcademicAppointmentTrackID":"AC-000000015-2", + "AcademicUnitID":"050", + "AcademicUnitName":"Family Medicine", + "AcademicUnitSupervisoryOrganizations": + [{"AcademicUnitID":"050", + "Code":"SOM:", + "CostCenter": + {"Description":"WORKDAY DEFAULT DEPTBG", + "ID":"681925", + "OrganizationCode":"3040111000", + "OrganizationDescription":"FAMILY MEDICINE"}, + "Description":"SOM: Family Medicine (Visor, Super1)", + "Href":"\/hrp\/v2\/organization\/SOM_000420.json", + "ID":"SOM_000420", + "Name":"Family Medicine"}, + {"AcademicUnitID":"081", + "Code":"SOM:", + "CostCenter": + {"Description":"DOM PAYROLL SUSPENSE", + "ID":"656131", + "OrganizationCode":"3040510019", + "OrganizationDescription":"FINANCE ABC\/DEANS HR"}, + "Description":"School of Medicine (Dean, Bill)", + "Href":"\/hrp\/v2\/organization\/SOM_000001.json", + "ID":"SOM_000001", + "Name":"School of Medicine"} + ], + "ActualAcademicAppointmentEndDate":null, + "AppointmentPositionID":null, + "PositionSupervisoryOrganization":null, + "PrimaryPositionID":"PN-0000809", + "SuperiorAcademicUnitID":"081"}, + {"AcademicAppointmentCompletedDate":"2017-06-22T07:00:00.000Z", + "AcademicAppointmentEndDate":null, + "AcademicAppointmentIdentifierID":"P", + "AcademicAppointmentIdentifierTypeID":"Primary", + "AcademicAppointmentStartDate":"2017-04-01T07:00:00.000Z", + "AcademicAppointmentState":"Current", + "AcademicAppointmentTitle":"Professor", + "AcademicAppointmentTrackID":"AC-000000015-1", + "AcademicUnitID":"050", + "AcademicUnitName":"Family Medicine", + "AcademicUnitSupervisoryOrganizations": + [{"AcademicUnitID":"050", + "Code":"SOM:", + "CostCenter": + {"Description":"WORKDAY DEFAULT DEPTBG", + "ID":"681925", + "OrganizationCode":"3040111000", + "OrganizationDescription":"FAMILY MEDICINE"}, + "Description":"SOM: Family Medicine (Visor, Super1)", + "Href":"\/hrp\/v2\/organization\/SOM_000420.json", + "ID":"SOM_000420", + "Name":"Family Medicine"}, + {"AcademicUnitID":"081", + "Code":"SOM:", + "CostCenter": + {"Description":"DOM PAYROLL SUSPENSE", + "ID":"656131", + "OrganizationCode":"3040510019", + "OrganizationDescription":"FINANCE ABC\/DEANS HR"}, + "Description":"School of Medicine (Dean, Bill)", + "Href":"\/hrp\/v2\/organization\/SOM_000001.json", + "ID":"SOM_000001", + "Name":"School of Medicine"} + ], + "ActualAcademicAppointmentEndDate":null, + "AppointmentPositionID":"PN-0000809", + "PositionSupervisoryOrganization": + {"AcademicUnitID":null, + "Code":"SOM:", + "CostCenter": + {"Description":"DOM PAYROLL SUSPENSE", + "ID":"656131", + "OrganizationCode":"3040510019", + "OrganizationDescription":"FINANCE ABC\/DEANS HR"}, + "Description":"School of Medicine (Dean, Bill)", + "Href":"\/hrp\/v2\/organization\/SOM_000001.json", + "ID":"SOM_000001", + "Name":"School of Medicine"}, + "PrimaryPositionID":"PN-0000809", + "SuperiorAcademicUnitID":"081"}], + "DisplayFirstName":"Super1", + "DisplayLastName":"Visor", + "DisplayMiddleName":null, + "DisplayName":"Super1 Visor", + "EmployeeID":"100000015", + "EmployeeIDPrior":null, + "FormattedLegalNameFirstLast":"Super1 Visor", + "FormattedLegalNameFirstMiddleLast":"Super1 Visor", + "FormattedLegalNameLastFirstMiddle":"Visor, Super1", + "FormattedPreferredNameFirstLast":"Super1 Visor", + "FormattedPreferredNameFirstMiddleLast":"Super1 Visor", + "FormattedPreferredNameLastFirstMiddle":"Visor, Super1", + "HuskyCardOverride":null, + "IsCurrentFaculty":true, + "IsFutureDate":false, + "LegalFirstName":"Super1", + "LegalLastName":"Visor", + "LegalMiddleName":"A", + "LegalNameSuffix":null, + "NetID":"jamespa", + "PreferredFirstName":"Super1", + "PreferredLastName":"Visor", + "PreferredMiddleName":null, + "PreferredNameSuffix":null, + "RegID":"10000000000000000000000000000015", + "RepositoryTimeStamp":"2019-03-06T16:12:12.214Z", + "SystemMetadata":{"LastModified":null}, + "WorkdayPersonType":"Employee", + "WorkerContact": + {"Addresses":[ + {"Country":"United States of America", + "CountryCodeISO2":"US", + "IsPrimary":true, + "IsPubliclyAvailable":true, + "Lines":["Seattle Main Campus"], + "Municipality":"Seattle", + "PostalCode":"98195", + "Region":"Washington", + "Type":"WORK"}, + {"Country":"United States of America", + "CountryCodeISO2":"US", + "IsPrimary":false, + "IsPubliclyAvailable":true, + "Lines":["1705 NE Pacific St"], + "Municipality":"Seattle", + "PostalCode":"98195-0000", + "Region":"Washington", + "Type":"WORK"}], + "CampusBox":"356390", + "EmailAddresses":[ + {"Address":"jamespa@uw.edu", + "IsPrimary":true, + "IsPubliclyAvailable":true, + "Type":"WORK"}], + "Phones":[{"AreaCode":"206", + "DeviceType":"Telephone", + "InternationalCode":"1", + "IsPrimary":true, + "IsPubliclyAvailable":true, + "NANPPhoneNumber":"+1 (206) 123-1234", + "Number":"123-1234", + "Type":"WORK"}, + {"AreaCode":"206", + "DeviceType":"Telephone", + "InternationalCode":"1", + "IsPrimary":false, + "IsPubliclyAvailable":true, + "NANPPhoneNumber":"+1 (206) 123-1235", + "Number":"123-1235", + "Type":"WORK"} + ] + }, + "WorkerEmploymentStatus": + {"ActiveStatusDate":"2017-04-01T07:00:00.000Z", + "EmployeeStatus":"Active", + "EmployeeStatusCode":"A", + "EndEmploymentDate":null, + "EstimatedLastDayOfLeave":null, + "FirstDayOfLeave":null, + "FirstDayOfWork":"2017-04-01T07:00:00.000Z", + "HireDate":"2017-04-01T07:00:00.000Z", + "IsActive":true, + "IsRetired":false, + "IsTerminated":false, + "LastDayOfWorkForLeave":null, + "OriginalHireDate":"2017-03-31T07:00:00.000Z", + "RetirementDate":null, + "TerminationDate":null}, + "WorkerPositions":[ + {"CostCenter": + {"Description":"WORKDAY DEFAULT DEPTBG", + "ID":"681925", + "OrganizationCode":"3040111000", + "OrganizationDescription":"FAMILY MEDICINE" + }, + "EcsJobClassificationCode":"F", + "EcsJobClassificationCodeDescription":"Academic Personnel", + "FutureTransactions":[], + "IsFutureDate":false, + "IsMedicalCenterPosition":false, + "IsOnLeaveFromPosition":false, + "IsPrimaryPosition":true, + "JobProfileSummary": + {"Href":"\/hrp\/v2\/jobProfile\/10101.json", + "JobCategory":"Faculty", + "JobFamilies":[ + {"JobFamilyID":"Faculty - Indefinite and Multi-Year", + "JobFamilyName":"01 - Academic Personnel - Faculty - Indefinite and Multi-Year", + "JobFamilySummary":"Academic positions designated as faculty under the Faculty Code Chapter 21"} + ], + "JobProfileDescription":"Professor", + "JobProfileID":"10101" + }, + "Location": + {"ID":"Seattle Campus", + "Name":"Seattle Campus" + }, + "ObjectCode":"01", + "PayRateType":"Salary", + "PayrollUnitCode":"00753", + "PlannedDistributions":{}, + "PositionBusinessTitle":"Chair", + "PositionEffectiveDate":"2017-04-01T07:00:00.000Z", + "PositionEndDate":null, + "PositionFTEPercent":"100.00000", + "PositionID":"PN-0000809", + "PositionStartDate":"2017-04-01T00:00:00.000Z", + "PositionSupervisor": + {"EmployeeID":"100000115", + "Href":"\/hrp\/v2\/worker\/100000115.json" + }, + "PositionTimeTypeID":"Full_time", + "PositionTitle":"PROFESSOR, School of Medicine", + "PositionType":"Regular_Practice_Plan", + "ServicePeriodDescription":"Service_Period_12.00", + "ServicePeriodID":"12", + "SubObjectCode":"10", + "SupervisoryOrganization": + {"AcademicUnitID":null, + "Code":"SOM:", + "CostCenter": + {"Description":"DOM PAYROLL SUSPENSE", + "ID":"656131", + "OrganizationCode":"3040510019", + "OrganizationDescription":"FINANCE ABC\/DEANS HR" + }, + "Description":"School of Medicine (Dean, Bill)", + "Href":"\/hrp\/v2\/organization\/SOM_000001.json", + "ID":"SOM_000001", + "Name":"School of Medicine" + }, + "TotalBasePayAmount":"0.00000", + "TotalBasePayAnnualizedAmount":"0.00000", + "TotalBasePayFrequency":"Monthly", + "TotalPayAnnualizedAmount":"0.00000", + "WorkShift":"First Shift" + } + ] +} diff --git a/uw_hrp/resources/hrpws/file/hrp/v2/worker/100000015.json_workerpositionstate_current_future b/uw_hrp/resources/hrpws/file/hrp/v2/worker/100000015.json_workerpositionstate_current_future new file mode 100644 index 0000000..4701a57 --- /dev/null +++ b/uw_hrp/resources/hrpws/file/hrp/v2/worker/100000015.json_workerpositionstate_current_future @@ -0,0 +1,250 @@ +{ + "AcademicAppointments": + [{"AcademicAppointmentCompletedDate":"2017-06-22T07:00:00.000Z", + "AcademicAppointmentEndDate":null, + "AcademicAppointmentIdentifierID":"A", + "AcademicAppointmentIdentifierTypeID":"Administrative", + "AcademicAppointmentStartDate":"2017-04-01T07:00:00.000Z", + "AcademicAppointmentState":"Current", + "AcademicAppointmentTitle":"Chair", + "AcademicAppointmentTrackID":"AC-000000015-2", + "AcademicUnitID":"050", + "AcademicUnitName":"Family Medicine", + "AcademicUnitSupervisoryOrganizations": + [{"AcademicUnitID":"050", + "Code":"SOM:", + "CostCenter": + {"Description":"WORKDAY DEFAULT DEPTBG", + "ID":"681925", + "OrganizationCode":"3040111000", + "OrganizationDescription":"FAMILY MEDICINE"}, + "Description":"SOM: Family Medicine (Visor, Super1)", + "Href":"\/hrp\/v2\/organization\/SOM_000420.json", + "ID":"SOM_000420", + "Name":"Family Medicine"}, + {"AcademicUnitID":"081", + "Code":"SOM:", + "CostCenter": + {"Description":"DOM PAYROLL SUSPENSE", + "ID":"656131", + "OrganizationCode":"3040510019", + "OrganizationDescription":"FINANCE ABC\/DEANS HR"}, + "Description":"School of Medicine (Dean, Bill)", + "Href":"\/hrp\/v2\/organization\/SOM_000001.json", + "ID":"SOM_000001", + "Name":"School of Medicine"} + ], + "ActualAcademicAppointmentEndDate":null, + "AppointmentPositionID":null, + "PositionSupervisoryOrganization":null, + "PrimaryPositionID":"PN-0000809", + "SuperiorAcademicUnitID":"081"}, + {"AcademicAppointmentCompletedDate":"2017-06-22T07:00:00.000Z", + "AcademicAppointmentEndDate":null, + "AcademicAppointmentIdentifierID":"P", + "AcademicAppointmentIdentifierTypeID":"Primary", + "AcademicAppointmentStartDate":"2017-04-01T07:00:00.000Z", + "AcademicAppointmentState":"Current", + "AcademicAppointmentTitle":"Professor", + "AcademicAppointmentTrackID":"AC-000000015-1", + "AcademicUnitID":"050", + "AcademicUnitName":"Family Medicine", + "AcademicUnitSupervisoryOrganizations": + [{"AcademicUnitID":"050", + "Code":"SOM:", + "CostCenter": + {"Description":"WORKDAY DEFAULT DEPTBG", + "ID":"681925", + "OrganizationCode":"3040111000", + "OrganizationDescription":"FAMILY MEDICINE"}, + "Description":"SOM: Family Medicine (Visor, Super1)", + "Href":"\/hrp\/v2\/organization\/SOM_000420.json", + "ID":"SOM_000420", + "Name":"Family Medicine"}, + {"AcademicUnitID":"081", + "Code":"SOM:", + "CostCenter": + {"Description":"DOM PAYROLL SUSPENSE", + "ID":"656131", + "OrganizationCode":"3040510019", + "OrganizationDescription":"FINANCE ABC\/DEANS HR"}, + "Description":"School of Medicine (Dean, Bill)", + "Href":"\/hrp\/v2\/organization\/SOM_000001.json", + "ID":"SOM_000001", + "Name":"School of Medicine"} + ], + "ActualAcademicAppointmentEndDate":null, + "AppointmentPositionID":"PN-0000809", + "PositionSupervisoryOrganization": + {"AcademicUnitID":null, + "Code":"SOM:", + "CostCenter": + {"Description":"DOM PAYROLL SUSPENSE", + "ID":"656131", + "OrganizationCode":"3040510019", + "OrganizationDescription":"FINANCE ABC\/DEANS HR"}, + "Description":"School of Medicine (Dean, Bill)", + "Href":"\/hrp\/v2\/organization\/SOM_000001.json", + "ID":"SOM_000001", + "Name":"School of Medicine"}, + "PrimaryPositionID":"PN-0000809", + "SuperiorAcademicUnitID":"081"}], + "DisplayFirstName":"Super1", + "DisplayLastName":"Visor", + "DisplayMiddleName":null, + "DisplayName":"Super1 Visor", + "EmployeeID":"100000015", + "EmployeeIDPrior":null, + "FormattedLegalNameFirstLast":"Super1 Visor", + "FormattedLegalNameFirstMiddleLast":"Super1 Visor", + "FormattedLegalNameLastFirstMiddle":"Visor, Super1", + "FormattedPreferredNameFirstLast":"Super1 Visor", + "FormattedPreferredNameFirstMiddleLast":"Super1 Visor", + "FormattedPreferredNameLastFirstMiddle":"Visor, Super1", + "HuskyCardOverride":null, + "IsCurrentFaculty":true, + "IsFutureDate":false, + "LegalFirstName":"Super1", + "LegalLastName":"Visor", + "LegalMiddleName":"A", + "LegalNameSuffix":null, + "NetID":"jamespa", + "PreferredFirstName":"Super1", + "PreferredLastName":"Visor", + "PreferredMiddleName":null, + "PreferredNameSuffix":null, + "RegID":"10000000000000000000000000000015", + "RepositoryTimeStamp":"2019-03-06T16:12:12.214Z", + "SystemMetadata":{"LastModified":null}, + "WorkdayPersonType":"Employee", + "WorkerContact": + {"Addresses":[ + {"Country":"United States of America", + "CountryCodeISO2":"US", + "IsPrimary":true, + "IsPubliclyAvailable":true, + "Lines":["Seattle Main Campus"], + "Municipality":"Seattle", + "PostalCode":"98195", + "Region":"Washington", + "Type":"WORK"}, + {"Country":"United States of America", + "CountryCodeISO2":"US", + "IsPrimary":false, + "IsPubliclyAvailable":true, + "Lines":["1705 NE Pacific St"], + "Municipality":"Seattle", + "PostalCode":"98195-0000", + "Region":"Washington", + "Type":"WORK"}], + "CampusBox":"356390", + "EmailAddresses":[ + {"Address":"jamespa@uw.edu", + "IsPrimary":true, + "IsPubliclyAvailable":true, + "Type":"WORK"}], + "Phones":[{"AreaCode":"206", + "DeviceType":"Telephone", + "InternationalCode":"1", + "IsPrimary":true, + "IsPubliclyAvailable":true, + "NANPPhoneNumber":"+1 (206) 123-1234", + "Number":"123-1234", + "Type":"WORK"}, + {"AreaCode":"206", + "DeviceType":"Telephone", + "InternationalCode":"1", + "IsPrimary":false, + "IsPubliclyAvailable":true, + "NANPPhoneNumber":"+1 (206) 123-1235", + "Number":"123-1235", + "Type":"WORK"} + ] + }, + "WorkerEmploymentStatus": + {"ActiveStatusDate":"2017-04-01T07:00:00.000Z", + "EmployeeStatus":"Active", + "EmployeeStatusCode":"A", + "EndEmploymentDate":null, + "EstimatedLastDayOfLeave":null, + "FirstDayOfLeave":null, + "FirstDayOfWork":"2017-04-01T07:00:00.000Z", + "HireDate":"2017-04-01T07:00:00.000Z", + "IsActive":true, + "IsRetired":false, + "IsTerminated":false, + "LastDayOfWorkForLeave":null, + "OriginalHireDate":"2017-03-31T07:00:00.000Z", + "RetirementDate":null, + "TerminationDate":null}, + "WorkerPositions":[ + {"CostCenter": + {"Description":"WORKDAY DEFAULT DEPTBG", + "ID":"681925", + "OrganizationCode":"3040111000", + "OrganizationDescription":"FAMILY MEDICINE" + }, + "EcsJobClassificationCode":"F", + "EcsJobClassificationCodeDescription":"Academic Personnel", + "FutureTransactions":[], + "IsFutureDate":false, + "IsMedicalCenterPosition":false, + "IsOnLeaveFromPosition":false, + "IsPrimaryPosition":true, + "JobProfileSummary": + {"Href":"\/hrp\/v2\/jobProfile\/10101.json", + "JobCategory":"Faculty", + "JobFamilies":[ + {"JobFamilyID":"Faculty - Indefinite and Multi-Year", + "JobFamilyName":"01 - Academic Personnel - Faculty - Indefinite and Multi-Year", + "JobFamilySummary":"Academic positions designated as faculty under the Faculty Code Chapter 21"} + ], + "JobProfileDescription":"Professor", + "JobProfileID":"10101" + }, + "Location": + {"ID":"Seattle Campus", + "Name":"Seattle Campus" + }, + "ObjectCode":"01", + "PayRateType":"Salary", + "PayrollUnitCode":"00753", + "PlannedDistributions":{}, + "PositionBusinessTitle":"Chair", + "PositionEffectiveDate":"2017-04-01T07:00:00.000Z", + "PositionEndDate":null, + "PositionFTEPercent":"100.00000", + "PositionID":"PN-0000809", + "PositionStartDate":"2017-04-01T00:00:00.000Z", + "PositionSupervisor": + {"EmployeeID":"100000115", + "Href":"\/hrp\/v2\/worker\/100000115.json" + }, + "PositionTimeTypeID":"Full_time", + "PositionTitle":"PROFESSOR, School of Medicine", + "PositionType":"Regular_Practice_Plan", + "ServicePeriodDescription":"Service_Period_12.00", + "ServicePeriodID":"12", + "SubObjectCode":"10", + "SupervisoryOrganization": + {"AcademicUnitID":null, + "Code":"SOM:", + "CostCenter": + {"Description":"DOM PAYROLL SUSPENSE", + "ID":"656131", + "OrganizationCode":"3040510019", + "OrganizationDescription":"FINANCE ABC\/DEANS HR" + }, + "Description":"School of Medicine (Dean, Bill)", + "Href":"\/hrp\/v2\/organization\/SOM_000001.json", + "ID":"SOM_000001", + "Name":"School of Medicine" + }, + "TotalBasePayAmount":"0.00000", + "TotalBasePayAnnualizedAmount":"0.00000", + "TotalBasePayFrequency":"Monthly", + "TotalPayAnnualizedAmount":"0.00000", + "WorkShift":"First Shift" + } + ] +} diff --git a/uw_hrp/resources/hrpws/file/hrp/v2/worker/faculty.json_workerpositionstate_current_future b/uw_hrp/resources/hrpws/file/hrp/v2/worker/faculty.json_workerpositionstate_current_future new file mode 100644 index 0000000..9843d9c --- /dev/null +++ b/uw_hrp/resources/hrpws/file/hrp/v2/worker/faculty.json_workerpositionstate_current_future @@ -0,0 +1,217 @@ +{ + "AcademicAppointments":[ + { + "AcademicAppointmentCompletedDate":"2018-05-17T07:00:00.000Z", + "AcademicAppointmentEndDate":"2019-06-30T07:00:00.000Z", + "AcademicAppointmentIdentifierID":"P", + "AcademicAppointmentIdentifierTypeID":"Primary", + "AcademicAppointmentStartDate":"2012-07-01T07:00:00.000Z", + "AcademicAppointmentState":"Current", + "AcademicAppointmentTitle":"Clinical Associate Professor", + "AcademicAppointmentTrackID":"AC-000000005-1", + "AcademicUnitID":"050", + "AcademicUnitName":"Family Medicine", + "AcademicUnitSupervisoryOrganizations":[ + {"AcademicUnitID":"050", + "Code":"SOM:", + "CostCenter": + {"Description":"WORKDAY DEFAULT DEPTBG", + "ID":"681925", + "OrganizationCode":"3040111000", + "OrganizationDescription":"FAMILY MEDICINE" + }, + "Description":"SOM: Family Medicine (Visor, Super1)", + "Href":"\/hrp\/v2\/organization\/SOM_000420.json", + "ID":"SOM_000420", + "Name":"Family Medicine"}, + {"AcademicUnitID":"081", + "Code":"SOM:", + "CostCenter": + { + "Description":"DOM PAYROLL SUSPENSE", + "ID":"656131", + "OrganizationCode":"3040510019", + "OrganizationDescription":"FINANCE ABC\/DEANS HR" + }, + "Description":"School of Medicine (Dean, Bill)", + "Href":"\/hrp\/v2\/organization\/SOM_000001.json", + "ID":"SOM_000001", + "Name":"School of Medicine" + } + ], + "ActualAcademicAppointmentEndDate":"2019-06-30T07:00:00.000Z", + "AppointmentPositionID":"PN-0054525", + "PositionSupervisoryOrganization": + { + "AcademicUnitID":null, + "Code":"SOM:", + "CostCenter": + {"Description":"WORKDAY DEFAULT DEPTBG", + "ID":"681925", + "OrganizationCode":"3040111000", + "OrganizationDescription":"FAMILY MEDICINE" + }, + "Description":"SOM: Family Medicine: Volunteer (Visor, Super1)", + "Href":"\/hrp\/v2\/organization\/SOM_000420.json", + "ID":"SOM_000420", + "Name":"Family Medicine: Volunteer JM Academic" + }, + "PrimaryPositionID":"PN-0054525", + "SuperiorAcademicUnitID":"081" + } + ], + "DisplayFirstName":"William E", + "DisplayLastName":"Faculty", + "DisplayMiddleName":null, + "DisplayName":"William E Faculty", + "EmployeeID":"000000005", + "EmployeeIDPrior":null, + "FormattedLegalNameFirstLast":"William Faculty", + "FormattedLegalNameFirstMiddleLast":"William E Faculty", + "FormattedLegalNameLastFirstMiddle":"Faculty, William E", + "FormattedPreferredNameFirstLast":"William E Faculty", + "FormattedPreferredNameFirstMiddleLast":"William E Faculty", + "FormattedPreferredNameLastFirstMiddle":"Faculty, William E", + "HuskyCardOverride":null, + "IsCurrentFaculty":true, + "IsFutureDate":false, + "LegalFirstName":"William", + "LegalLastName":"Faculty", + "LegalMiddleName":"E", + "LegalNameSuffix":null, + "NetID":"faculty", + "PreferredFirstName":"William E", + "PreferredLastName":"Faculty", + "PreferredMiddleName":null, + "PreferredNameSuffix":null, + "RegID":"10000000000000000000000000000005", + "RepositoryTimeStamp":"2019-01-25T16:05:03.721Z", + "SystemMetadata":{"LastModified":null}, + "WorkdayPersonType":"Academic Affiliate", + "WorkerContact": + {"Addresses":[ + {"Country":"United States of America", + "CountryCodeISO2":"US", + "IsPrimary":true, + "IsPubliclyAvailable":true, + "Lines":["Seattle Main Campus"], + "Municipality":"Seattle", + "PostalCode":"98195", + "Region":"Washington", + "Type":"WORK"}, + {"Country":"United States of America", + "CountryCodeISO2":"US", + "IsPrimary":false, + "IsPubliclyAvailable":true, + "Lines":["1705 NE Pacific St"], + "Municipality":"Seattle", + "PostalCode":"98195-0000", + "Region":"Washington", + "Type":"WORK"} + ], + "CampusBox":"356390", + "EmailAddresses":[ + {"Address":"faculty@uw.edu", + "IsPrimary":true, + "IsPubliclyAvailable":true, + "Type":"WORK"}], + "Phones":[ + {"AreaCode":"253", + "DeviceType":"Telephone", + "InternationalCode":"1", + "IsPrimary":true, + "IsPubliclyAvailable":true, + "NANPPhoneNumber":"+1 (206) 123-1234", + "Number":"123-1234", + "Type":"WORK"}, + {"AreaCode":"203", + "DeviceType":"Telephone", + "InternationalCode":"1", + "IsPrimary":false, + "IsPubliclyAvailable":true, + "NANPPhoneNumber":"+1 (203) 678-1234", + "Number":"678-1234", + "Type":"WORK"} + ] + }, + "WorkerEmploymentStatus":{ + "ActiveStatusDate":"2006-05-16T07:00:00.000Z", + "EmployeeStatus":"Active", + "EmployeeStatusCode":"A", + "EndEmploymentDate":null, + "EstimatedLastDayOfLeave":null, + "FirstDayOfLeave":null, + "FirstDayOfWork":"2006-05-16T07:00:00.000Z", + "HireDate":"2006-05-16T07:00:00.000Z", + "IsActive":true, + "IsRetired":false, + "IsTerminated":false, + "LastDayOfWorkForLeave":null, + "OriginalHireDate":"2006-05-16T07:00:00.000Z", + "RetirementDate":null, + "TerminationDate":null}, + "WorkerPositions":[ + {"CostCenter": + {"Description":"WORKDAY DEFAULT DEPTBG", + "ID":"681925", + "OrganizationCode":"3040111000", + "OrganizationDescription":"FAMILY MEDICINE"}, + "EcsJobClassificationCode":"F", + "EcsJobClassificationCodeDescription":"Academic Personnel", + "FutureTransactions":[], + "IsFutureDate":false, + "IsMedicalCenterPosition":false, + "IsOnLeaveFromPosition":false, + "IsPrimaryPosition":true, + "JobProfileSummary":{ + "Href":"\/hrp\/v2\/jobProfile\/21184.json", + "JobCategory":"Faculty", + "JobFamilies":[ + {"JobFamilyID":"Faculty - Annual or Shorter", + "JobFamilyName":"01 - Academic Personnel - Faculty - Annual or Shorter", + "JobFamilySummary":null}], + "JobProfileDescription":"Unpaid Academic", + "JobProfileID":"21184"}, + "Location":{ + "ID":"Seattle Campus", + "Name":"Seattle Campus"}, + "ObjectCode":null, + "PayRateType":"N\/A", + "PayrollUnitCode":"00753", + "PlannedDistributions":{ + "PeriodActivityAssignments":[], + "PlannedCompensationAllocations":[]}, + "PositionBusinessTitle":"Clinical Associate Professor", + "PositionEffectiveDate":"2012-07-01T07:00:00.000Z", + "PositionEndDate":null, + "PositionFTEPercent":"0.00000", + "PositionID":"PN-0054525", + "PositionStartDate":"2012-07-01T00:00:00.000Z", + "PositionSupervisor":{ + "EmployeeID":"100000015", + "Href":"\/hrp\/v2\/worker\/100000015.json"}, + "PositionTimeTypeID":"Part_time", + "PositionTitle":"CLINICAL ASSOCIATE PROFESSOR, Family Medicine JM Academic", + "PositionType":"Unpaid_Academic", + "ServicePeriodDescription":"Service_Period_12.00", + "ServicePeriodID":"12", + "SubObjectCode":null, + "SupervisoryOrganization":{ + "AcademicUnitID":null, + "Code":"SOM", + "CostCenter": + {"Description":"WORKDAY DEFAULT DEPTBG", + "ID":"681925", + "OrganizationCode":"3040111000", + "OrganizationDescription":"FAMILY MEDICINE"}, + "Description":"SOM: Family Medicine: Volunteer (Visor, Super1)", + "Href":"\/hrp\/v2\/organization\/SOM_000420.json", + "ID":"SOM_000420", + "Name":"Family Medicine: Volunteer"}, + "TotalBasePayAmount":"0.00000", + "TotalBasePayAnnualizedAmount":"0.00000", + "TotalBasePayFrequency":null, + "TotalPayAnnualizedAmount":"0.00000", + "WorkShift":"First Shift"} + ] +} diff --git a/uw_hrp/tests/test_models.py b/uw_hrp/tests/test_models.py index ef7d284..75b847a 100644 --- a/uw_hrp/tests/test_models.py +++ b/uw_hrp/tests/test_models.py @@ -18,17 +18,29 @@ def test_employment_status(self): self.assertIsNotNone(str(emp_status)) emp_status = EmploymentStatus( - data={ - "ActiveStatusDate": "1980-07-01T07:00:00.000Z", - "EmployeeStatus": "Active", - "EmployeeStatusCode": "A", - "EndEmploymentDate": "2017-09-16T07:00:00.000Z", - "HireDate": "1980-07-01T07:00:00.000Z", - "IsActive": True, - "OriginalHireDate": "1980-07-01T07:00:00.000Z", - "RetirementDate": "2017-09-16T07:00:00.000Z", - "TerminationDate": "2017-09-16T07:00:00.000Z"}) + data={"IsActive": False, + "EmployeeStatus": "Terminated", + "EmployeeStatusCode": "N", + "IsTerminated": True, + "IsRetired": False, + "EndEmploymentDate": "2017-09-16T07:00:00.000Z", + "HireDate": "1980-07-01T07:00:00.000Z", + "RetirementDate": "2017-09-16T07:00:00.000Z", + "TerminationDate": "2017-09-16T07:00:00.000Z"}) self.assertIsNotNone(str(emp_status)) + self.assertTrue(emp_status.is_terminated) + self.assertFalse(emp_status.is_active) + self.assertEqual( + emp_status.to_json(), + {'end_emp_date': '2017-09-16 07:00:00+00:00', + 'hire_date': '1980-07-01 07:00:00+00:00', + 'is_active': False, + 'is_retired': False, + 'is_terminated': True, + 'retirement_date': '2017-09-16 07:00:00+00:00', + 'status': 'Terminated', + 'status_code': 'N', + 'termination_date': '2017-09-16 07:00:00+00:00'}) def test_job_profile(self): job_prof = JobProfile(job_code="1", description="A") @@ -113,6 +125,7 @@ def test_worker_position(self): "end_date": "1997-10-01 00:00:00+00:00", "ecs_job_cla_code_desc": "Professional Staff", "fte_percent": 100.0, + 'is_future_date': False, "is_primary": True, "location": "Seattle Campus", "pos_type": "Regular", @@ -133,17 +146,19 @@ def test_worker_position(self): data={"PositionStartDate": "1994-10-01T00:00:00.000Z", "PositionEndDate": str(datetime.now(timezone.utc) + timedelta(minutes=1)), + "IsFutureDate": False, "PositionFTEPercent": "100.00000"}) self.assertTrue(work_position.is_active_position()) - self.assertFalse(work_position.is_future_position()) + self.assertFalse(work_position.is_future_date) work_position = WorkerPosition( data={"PositionStartDate": str(datetime.now(timezone.utc) + timedelta(minutes=1)), + "IsFutureDate": True, "PositionEndDate": None, "PositionFTEPercent": "100.00000"}) + self.assertTrue(work_position.is_future_date) self.assertTrue(work_position.is_active_position()) - self.assertTrue(work_position.is_future_position()) def test_worker(self): worker = Worker(netid='none', @@ -273,6 +288,7 @@ def test_worker(self): {'ecs_job_cla_code_desc': 'Classified Staff', 'end_date': None, 'fte_percent': 100.0, + 'is_future_date': False, 'is_primary': True, 'job_profile': {'description': None, 'job_code': None}, 'location': 'Bothell Campus', @@ -288,14 +304,3 @@ def test_worker(self): self.assertIsNotNone(str(worker.primary_position)) self.assertEqual(len(worker.other_active_positions), 0) self.assertIsNotNone(str(worker.employee_status)) - self.assertEqual( - worker.employee_status.to_json(), - {"end_emp_date": None, - "hire_date": "1980-07-01 07:00:00+00:00", - "is_active": True, - "is_retired": False, - "is_terminated": False, - "retirement_date": None, - "status": "Active", - "status_code": "A", - "termination_date": None}) diff --git a/uw_hrp/tests/test_worker.py b/uw_hrp/tests/test_worker.py index aeb778a..0607da1 100644 --- a/uw_hrp/tests/test_worker.py +++ b/uw_hrp/tests/test_worker.py @@ -38,6 +38,7 @@ def test_get_worker_by_netid(self): "end_date": None, "ecs_job_cla_code_desc": "Academic Personnel", 'fte_percent': 0.0, + 'is_future_date': False, "is_primary": True, "location": "Seattle Campus", "pos_type": "Unpaid_Academic", @@ -58,6 +59,7 @@ def test_get_worker_by_netid(self): "end_date": None, "ecs_job_cla_code_desc": "Academic Personnel", 'fte_percent': 0.0, + 'is_future_date': False, "is_primary": True, "location": "Seattle Campus", "pos_type": "Unpaid_Academic", @@ -73,18 +75,28 @@ def test_get_worker_by_netid(self): "org_name": "Family Medicine: Volunteer"}}) self.assertEqual(len(worker.other_active_positions), 0) + worker = get_worker_by_netid("faculty", current_future=False) + self.assertIsNotNone(worker) + def test_get_worker_by_employee_id(self): worker = get_worker_by_employee_id("100000015") - self.assertTrue(worker.netid, - 'chair') + self.assertTrue(worker.netid, 'chair') + + worker = get_worker_by_employee_id("100000015", current_future=False) + self.assertIsNotNone(worker) + self.assertRaises(InvalidEmployeeID, get_worker_by_employee_id, "") def test_get_worker_by_regid(self): worker = get_worker_by_regid("10000000000000000000000000000015") - self.assertTrue(worker.netid, - 'chair') + self.assertTrue(worker.netid, 'chair') + + worker = get_worker_by_regid("10000000000000000000000000000015", + current_future=False) + self.assertIsNotNone(worker) + self.assertRaises(DataFailureException, get_worker_by_regid, "00000000000000000000000000000001") diff --git a/uw_hrp/worker.py b/uw_hrp/worker.py index e1c1008..9b7612f 100644 --- a/uw_hrp/worker.py +++ b/uw_hrp/worker.py @@ -14,29 +14,32 @@ logger = logging.getLogger(__name__) URL_PREFIX = "/hrp/v2/worker" +CURRENT_FUTURE_SUFFIX = "workerpositionstate=current,future" -def get_worker_by_employee_id(employee_id): +def get_worker_by_employee_id(employee_id, current_future=True): if not PWS().valid_employee_id(employee_id): raise InvalidEmployeeID(employee_id) - return _get_worker(employee_id) + return _get_worker(employee_id, current_future=True) -def get_worker_by_netid(netid): +def get_worker_by_netid(netid, current_future=True): if not PWS().valid_uwnetid(netid): raise InvalidNetID(netid) - return _get_worker(netid) + return _get_worker(netid, current_future=True) -def get_worker_by_regid(regid): +def get_worker_by_regid(regid, current_future=True): if not PWS().valid_uwregid(regid): raise InvalidRegID(regid) - return _get_worker(regid) + return _get_worker(regid, current_future=True) -def _get_worker(id): +def _get_worker(id, current_future=True): """ Return a restclients.models.hrp.WorkerPerson object """ url = "{0}/{1}.json".format(URL_PREFIX, id) + if current_future: + url = "{0}?{1}".format(url, CURRENT_FUTURE_SUFFIX) return Worker(data=json.loads(get_resource(url)))