Changeset 9632246 in rattail


Ignore:
Timestamp:
04/12/19 12:54:02 (11 months ago)
Author:
Lance Edgar <ledgar@…>
Branches:
master
Children:
f03413b
Parents:
db251fa
Message:

Add Employee.get_current_history() convenience method

should return the "currently active" history record, or the most "recent" one
if none is currently active

File:
1 edited

Legend:

Unmodified
Added
Removed
  • rattail/db/model/employees.py

    rdb251fa r9632246  
    109109        phone = EmployeePhoneNumber(number=number, type=type)
    110110        self.phones.append(phone)
     111
     112    def get_current_history(self):
     113        """
     114        Returns the "current" history record for the employee, if found.
     115        """
     116        if self.history:
     117            history = sorted(self.history, key=lambda h: (h.start_date, h.end_date))
     118            return history[-1]
    111119
    112120
Note: See TracChangeset for help on using the changeset viewer.