from . import base
from . import mixins


class TransformedRecord(mixins.GenericCompensationMixin,
        mixins.GenericDepartmentMixin, mixins.GenericIdentifierMixin,
        mixins.GenericJobTitleMixin, mixins.GenericPersonMixin,
        mixins.MembershipMixin, mixins.OrganizationMixin, mixins.PostMixin,
        mixins.RaceMixin, base.BaseTransformedRecord):
    MAP = {
        'last_name': 'FAMILY_NAME',
        'first_name': 'GIVEN_NAME',
        'department': 'DEPARTMENT',
        'job_title': 'JOBTITLE',
        'gender': 'GENDER',
        'race': 'RACE/ETHNICITY',
        'hire_date': 'LAST_HIRE_DT',
        'compensation': 'ANNUAL_PAY',
        #TODO ask what this is, include in compensation
        'longevity': 'ANNUALIZED_LONGEVITY'
    }

    NAME_FIELDS = ('first_name', 'last_name', )

    gender_map = {'Female': 'F', 'Male': 'M'}

    ORGANIZATION_NAME = 'The University of Texas Medical Branch at Galveston'

    # TODO not given on spreadsheet, but they appear to give part time
    compensation_type = 'Full Time'

    @property
    def is_valid(self):
        # Adjust to return False on invalid fields.  For example:
        return self.last_name.strip() != ''

    @property
    def person(self):
        data = {
            'family_name': self.last_name,
            'given_name': self.first_name,
            'name': self.get_raw_name(),
        }
        try:
            data.update({
                'gender': self.gender_map[self.gender.strip()]
            })
            return data
        except KeyError:
            return data


transform = base.transform_factory(TransformedRecord)

@@ -651,64 +651,8 @@
 Y',%0A
-        #TODO ask what this is, include in compensation%0A
     
@@ -691,16 +691,16 @@
 GEVITY'%0A
+
     %7D%0A%0A 
@@ -1486,16 +1486,16 @@
 yError:%0A
-
         
@@ -1511,16 +1511,944 @@
 n data%0A%0A
+    def process_compensation(self):%0A        #TODO longevity is in addition to base annual_pay, add if applicable%0A        if self.longevity.strip() == '0':%0A            return self.compensation%0A        else:%0A            longevity = self.longevity.strip().replace(',', '')%0A            salary = self.compensation.strip().replace(',', '')%0A            return float(salary) + float(longevity)%0A%0A    @property%0A    def compensations(self):%0A        compensation = self.process_compensation()%0A        return %5B%0A            %7B%0A                'tx_salaries.CompensationType': %7B%0A                    'name': self.compensation_type,%0A                %7D,%0A                'tx_salaries.Employee': %7B%0A                    'hire_date': self.hire_date,%0A                    'compensation': compensation,%0A                %7D,%0A                'tx_salaries.EmployeeTitle': %7B%0A                    'name': self.job_title,%0A                %7D,%0A            %7D%0A        %5D%0A%0A
 %0Atransfo

Update UTMB based on request clarifications