from employee import Employee

class HourlyEmployee(Employee):
    """
    An employee whose pay is computed based on an hourly rate.
        hourly_wage: number  - This employee's hourly rate of pay
        not_yet_paid: int    - The number of hours of work this Employee
                               has accumulated since their last pay day,
                               and has therefore not yet been paid for.
    """
    
    def __init__(self, eid, name, SIN, pay_period, hourly_wage):
        """
        (Employee) -> NoneType
        
        >>> e = HourlyEmployee(23, 'Barney Rubble', 333333333, \
        'weekly', 1.25)
        >>> e.hourly_wage
        1.25
        >>> e.not_yet_paid
        0
        """
        Employee.__init__(self, eid, name, SIN, pay_period)
        self.hourly_wage = hourly_wage
        
    def log_hours(self, number_of_hours):
        """
        (Employee, int) -> NoneType
        
        Record the fact that this Employee has worked number_of_hours
        more hours.
        
        >>> e = HourlyEmployee(23, 'Barney Rubble', 333333333, \
        'weekly', 1.25)
        >>> e.log_hours(10)
        >>> e.log_hours(5)
        >>> e.not_yet_paid
        15
        """
        self.not_yet_paid += number_of_hours
        
    def amount_of_pay(self):
        """
        (Employee) -> number
        
        Return the amount that this Employee should be paid in the next
        pay period.
        
        >>> e = HourlyEmployee(23, 'Barney Rubble', 333333333, \
        'weekly', 1.25)
        >>> e.log_hours(15)
        >>> e.amount_of_pay()
        18.75
        """
        return self.hourly_wage * self.not_yet_paid
    
    def record_pay(self, date):
        """
        (Employee, str) -> NoneType
        
        Record the amount this Employee should be paid for the next pay
        period in their pay history, with the associated date. Reset their
        not_yet_paid hours.
        
        >>> e = HourlyEmployee(23, 'Barney Rubble', 333333333, \
        'weekly', 1.25)
        >>> e.log_hours(15)
        >>> e.record_pay('150129')
        >>> e.pay_history == {'150129': 18.75}
        True
        >>> e.not_yet_paid == 0
        True
        """
        Employee.record_pay(self, date)
        self.not_yet_paid = 0
        
if __name__ == '__main__':
    import doctest
    doctest.testmod()
