diff --git a/resources/models.py b/resources/models.py index 69f0475..e2ff524 100644 --- a/resources/models.py +++ b/resources/models.py @@ -25,6 +25,8 @@ class UnnormalizedEmployees(db.Base): ce_code = Column(String(10), index=True) ce_department = Column(String(15)) hourly_rate = Column(DECIMAL(10,2)) + work_email = Column(String(100)) + personal_email = Column(String(100)) class UnnormalizedTimecards(db.Base): diff --git a/resources/response_filter.py b/resources/response_filter.py index ee4260f..d574f3e 100644 --- a/resources/response_filter.py +++ b/resources/response_filter.py @@ -20,10 +20,12 @@ class Employee: is_active = False termination_date = None hourly_rate = None + personal_email = None + work_email = None def __init__(self, associate_oid, worker_id, payroll_name, first_name, last_name, middle_name, location_code, loc_desc, dept_code, dept_desc, ce_name, ce_dept, - worker_status, termination_date, hourly_rate): + worker_status, termination_date, hourly_rate, personal_email, work_email): self.associate_oid = associate_oid self.worker_id = worker_id self.payroll_name = payroll_name @@ -38,6 +40,8 @@ def __init__(self, associate_oid, worker_id, payroll_name, first_name, last_name self.ce_dept = ce_dept self.worker_status = worker_status self.hourly_rate = hourly_rate + self.personal_email = personal_email + self.work_email = work_email if termination_date != "": self.termination_date = datetime.strptime(termination_date, "%Y-%m-%d") if self.termination_date > datetime.today() - timedelta(days = 15): @@ -46,12 +50,12 @@ def __init__(self, associate_oid, worker_id, payroll_name, first_name, last_name self.is_active = True def __str__(self) -> str: - out_string = "{0} \t {1} \t {2}, {3}, {4} \n {5}, {6} \t {7}, {8} \n {9}, {10}, {11}".format(self.associate_oid, self.payroll_name, self.first_name, self.last_name, self.middle_name, - self.location_code, self.loc_desc, self.dept_code, self.dept_desc, self.ce_name, self.ce_dept, self.hourly_rate) + out_string = "{0} \t {1} \t {2}, {3}, {4} \n {5}, {6} \t {7}, {8} \n {9}, {10}, {11}, \n {12}, {13}".format(self.associate_oid, self.payroll_name, self.first_name, self.last_name, self.middle_name, + self.location_code, self.loc_desc, self.dept_code, self.dept_desc, self.ce_name, self.ce_dept, self.hourly_rate, self.personal_email, self.work_email) - if self.termination_date != None: - out_string = "{0} \t {1} \t {2}, {3}, {4} \n {5}, {6} \t {7}, {8} \n {9}, {10} \t {11}, {12}".format(self.associate_oid, self.payroll_name, self.first_name, self.last_name, self.middle_name, - self.location_code, self.loc_desc, self.dept_code, self.dept_desc, self.ce_name, self.ce_dept, self.termination_date, self.is_active) + if self.termination_date is not None: + out_string = "{0} \t {1} \t {2}, {3}, {4} \n {5}, {6} \t {7}, {8} \n {9}, {10} \t {11}, {12}, \n {13}, {14}".format(self.associate_oid, self.payroll_name, self.first_name, self.last_name, self.middle_name, + self.location_code, self.loc_desc, self.dept_code, self.dept_desc, self.ce_name, self.ce_dept, self.termination_date, self.is_active, self.personal_email, self.work_email) return out_string def __UnnormalizedEmployees__(self) -> UnnormalizedEmployees: @@ -60,7 +64,8 @@ def __UnnormalizedEmployees__(self) -> UnnormalizedEmployees: location_code=self.location_code, location_description=self.loc_desc, department_code=self.dept_code, department_description=self.dept_desc, worker_status=self.worker_status, is_active=self.is_active, - ce_code=self.ce_name, ce_department=self.ce_dept, hourly_rate=self.hourly_rate) + ce_code=self.ce_name, ce_department=self.ce_dept, hourly_rate=self.hourly_rate, + work_email=self.work_email, personal_email=self.personal_email) class TimeEntry: @@ -194,6 +199,8 @@ def filter_each_worker(worker_dict : dict): termination_date = "" worker_status = "" hourly_rate = None + personal_email = None + work_email = None # associate_id if "associateOID" in worker_dict: @@ -221,6 +228,17 @@ def filter_each_worker(worker_dict : dict): if "middleName" in legal_name_dict: middle_name = legal_name_dict["middleName"] + # personal_email + if worker_dict["person"].get("communication") is not None: + if "emails" in worker_dict["person"]["communication"]: + personal_email = worker_dict["person"]["communication"]["emails"][0]["emailUri"] + # work_email + if "businessCommunication" in worker_dict: + if "emails" in worker_dict["businessCommunication"]: + work_email = worker_dict["businessCommunication"]["emails"][0]["emailUri"] + + print(payroll_name, personal_email, work_email, "\n") + # worker_status if "workerStatus" in worker_dict: if "statusCode" in worker_dict["workerStatus"]: @@ -280,7 +298,8 @@ def filter_each_worker(worker_dict : dict): termination_date = worker_dict["workerDates"]["terminationDate"] return Employee(associate_id, worker_id, payroll_name, first_name, last_name, middle_name, location_code, - loc_desc, dept_code, dept_desc, ce_name, ce_dept, worker_status, termination_date, hourly_rate) + loc_desc, dept_code, dept_desc, ce_name, ce_dept, worker_status, termination_date, hourly_rate, + personal_email, work_email) @staticmethod def get_location_code(location_name_code_dict: dict):