def execute(self): emp_ids = PayrollDatabase.get_all_employee_ids() for emp_id in emp_ids: employee = PayrollDatabase.get_employee(emp_id) if employee.is_pay_date(self.date): paycheck = Paycheck( employee.get_pay_period_start_date(self.date), self.date) self.paycheck_map[emp_id] = paycheck employee.payday(paycheck)
def test_delete_employee_transaction(): emp_id = 4 t = AddCommissionedEmployee(emp_id, "Bill", "Home", 2500, 3.2) t.execute() e = PayrollDatabase.get_employee(emp_id) assert e.name == "Bill" dt = DeleteEmployeeTransaction(emp_id=emp_id) dt.execute() e = PayrollDatabase.get_employee(emp_id) assert e == None
def test_change_union_member(): emp_id = 8 member_id = 7743 t = AddHourlyEmployee(emp_id, "Bill", "Home", 15.25) t.execute() cmt = ChangeMemberTransaction(emp_id, member_id, 99.42) cmt.execute() e = PayrollDatabase.get_employee(emp_id) assert e.name == "Bill" affiliation = e.affiliation assert affiliation is not None assert isinstance(affiliation, UnionAffiliation) assert affiliation.weekly_charge == 99.42 member = PayrollDatabase.get_union_member(member_id) assert e == member
def execute(self): e = PayrollDatabase.get_employee(self._emp_id) if e is not None: hc = e.classification if isinstance(hc, HourlyClassification): hc.add_time_card(TimeCard(self._date, self._hours)) else: raise ValueError( "Tried to add time_card to non-hourly employee") else: raise ValueError("No such employee.")
def test_change_name_transaction(): emp_id = 2 t = AddHourlyEmployee(emp_id, "Bill", "Home", 15.25) t.execute() cnt = ChangeNameTransaction(emp_id, "Bob") cnt.execute() e = PayrollDatabase.get_employee(emp_id) assert e.name == "Bob"
def test_add_service_charge(): emp_id = 2 member_id = 86 t = AddHourlyEmployee(emp_id, "Bill", "Home", 15.25) t.execute() e = PayrollDatabase.get_employee(emp_id) assert e.name == "Bill" af = UnionAffiliation(member_id, 12.5) e.affiliation = af PayrollDatabase.add_union_member(member_id, e) sct = ServiceChargeTransaction(member_id, datetime.date(2005, 8, 8), 12.95) sct.execute() sc = af.get_service_charge(datetime.date(2005, 8, 8)) assert sc != None assert sc.get_amount() == 12.95
def execute(self): e = PayrollDatabase.get_union_member(self.member_id) if e is not None: ua = None if isinstance(e.affiliation, UnionAffiliation): ua = e.affiliation if ua is not None: ua.add_service_charge(ServiceCharge(self.date, self.charge)) else: raise ValueError( "Tries to add service charge to union member without a union affiliation" ) else: raise ValueError("No such union member")
def test_add_salaried_employee(): emp_id = 1 t = AddSalariedEmployee(emp_id, "Bob", "Home", 1000.00) t.execute() e = PayrollDatabase.get_employee(emp_id) assert e.name == "Bob" pc = e.classification assert isinstance(pc, SalariedClassification) == True ps = e.schedule assert isinstance(ps, MonthlySchedule) == True pm = e.method assert isinstance(pm, HoldMethod) == True
def test_change_hourly_transaction(): emp_id = 3 t = AddCommissionedEmployee(emp_id, "Lance", "Home", 2500, 3.2) t.execute() cht = ChangeHourlyTransaction(emp_id, 27.52) cht.execute() e = PayrollDatabase.get_employee(emp_id) assert e.name == "Lance" pc = e.classification hc: HourlyClassification = pc assert isinstance(pc, HourlyClassification) assert hc.hour_salary == 27.52 ps = e.schedule assert isinstance(ps, WeeklySchedule)
def test_time_card_transaction(): emp_id = 5 t = AddHourlyEmployee(emp_id, "Bill", "Home", 15.25) t.execute() tct = TimeCardTransaction(date=datetime.date(2005, 7, 31), hours=8.0, emp_id=emp_id) tct.execute() e = PayrollDatabase.get_employee(emp_id) assert e.name == "Bill" pc: HourlyClassification = e.classification assert isinstance(pc, HourlyClassification) tc = pc.get_time_card(datetime.date(2005, 7, 31)) assert tc.get_hours() == 8.0
def execute(self): e = Employee(self.emp_id, self.name, self.address) e.classification = self.make_classification() e.schedule = self.make_schedule() e.method = HoldMethod() PayrollDatabase.add_employee(self.emp_id, e)
def execute(self): e = PayrollDatabase.get_employee(self.emp_id) if e is not None: self.change(e)
def record_membership(self, employee: Employee): affiliation = employee.affiliation if isinstance(affiliation, UnionAffiliation): member_id = affiliation.member_id PayrollDatabase.remove_union_member(member_id)
def record_membership(self, employee: Employee): PayrollDatabase.add_union_member(self.member_id, employee)
def execute(self): PayrollDatabase.delete_employee(emp_id=self._emp_id)