示例#1
0
文件: tests.py 项目: fbserkov/praxis
    def test_hourly_union_member_service_charge(self):
        emp_id = EmpId(1)
        transaction = AddHourlyEmployee(emp_id,
                                        'Bill',
                                        'Home',
                                        hourly_rate=15.24)
        transaction.execute()
        member_id = MemberId(7734)
        transaction = ChangeMemberTransaction(emp_id, member_id, dues=9.42)
        transaction.execute()

        pay_date = date(2001, 11, 9)
        transaction = ServiceChargeTransaction(member_id,
                                               pay_date,
                                               charge=19.42)
        transaction.execute()
        transaction = TimecardTransaction(emp_id, pay_date, hours=8.0)
        transaction.execute()
        transaction = PaydayTransaction(pay_date)
        transaction.execute()

        paycheck = transaction.get_paycheck(emp_id)
        self.assertEqual(pay_date, paycheck.get_period_end_date())
        self.assertEqual(8 * 15.24, paycheck.get_gross_pay())
        self.assertEqual('Hold', paycheck.get_field('Disposition'))
        self.assertEqual(9.42 + 19.42, paycheck.get_deductions())
        self.assertEqual(8 * 15.24 - (9.42 + 19.42), paycheck.get_net_pay())
示例#2
0
文件: tests.py 项目: fbserkov/praxis
    def test_change_address_transaction(self):
        emp_id = EmpId(2)
        transaction = AddHourlyEmployee(emp_id,
                                        'Bill',
                                        'Home',
                                        hourly_rate=15.25)
        transaction.execute()

        transaction = ChangeAddressTransaction(emp_id, 'Garage')
        transaction.execute()
        employee = g_payroll_database.get_employee(emp_id)
        self.assertEqual('Garage', employee.get_address())
示例#3
0
文件: tests.py 项目: fbserkov/praxis
    def test_pay_single_hourly_employee_no_time_cards(self):
        emp_id = EmpId(2)
        transaction = AddHourlyEmployee(emp_id,
                                        'Bill',
                                        'Home',
                                        hourly_rate=15.25)
        transaction.execute()

        pay_date = date(2001, 11, 9)  # Friday
        transaction = PaydayTransaction(pay_date)
        transaction.execute()
        self.validate_paycheck(transaction, emp_id, pay_date, 0.0)
示例#4
0
文件: tests.py 项目: fbserkov/praxis
    def test_change_name_transaction(self):
        emp_id = EmpId(2)
        transaction = AddHourlyEmployee(emp_id,
                                        'Bill',
                                        'Home',
                                        hourly_rate=15.25)
        transaction.execute()

        transaction = ChangeNameTransaction(emp_id, 'Bob')
        transaction.execute()
        employee = g_payroll_database.get_employee(emp_id)
        self.assertEqual('Bob', employee.get_name())
示例#5
0
文件: tests.py 项目: fbserkov/praxis
    def test_change_salaried_transaction(self):
        emp_id = EmpId(2)
        transaction = AddHourlyEmployee(emp_id,
                                        'Bill',
                                        'Home',
                                        hourly_rate=15.25)
        transaction.execute()
        transaction = ChangeSalariedTransaction(emp_id, salary=1000)
        transaction.execute()

        employee = g_payroll_database.get_employee(emp_id)
        classification = employee.get_classification()
        self.assertIsInstance(classification, SalariedClassification)
        self.assertEqual(1000, classification.get_salary())
        self.assertIsInstance(employee.get_schedule(), MonthlySchedule)
示例#6
0
文件: tests.py 项目: fbserkov/praxis
    def test_change_member_transaction(self):
        emp_id = EmpId(2)
        member_id = MemberId(7734)
        transaction = AddHourlyEmployee(emp_id,
                                        'Bill',
                                        'Home',
                                        hourly_rate=15.25)
        transaction.execute()
        transaction = ChangeMemberTransaction(emp_id, member_id, dues=99.42)
        transaction.execute()

        employee = g_payroll_database.get_employee(emp_id)
        affiliation = employee.get_affiliation()
        self.assertIsInstance(affiliation, UnionAffiliation)
        self.assertEqual(99.42, affiliation.get_dues())
        self.assertIs(employee, g_payroll_database.get_union_member(member_id))
示例#7
0
文件: tests.py 项目: fbserkov/praxis
    def test_timecard_transaction(self):
        emp_id = EmpId(2)
        transaction = AddHourlyEmployee(emp_id,
                                        'Bill',
                                        'Home',
                                        hourly_rate=15.25)
        transaction.execute()

        transaction = TimecardTransaction(emp_id, date=20011031, hours=8.0)
        transaction.execute()
        employee = g_payroll_database.get_employee(emp_id)
        classification = employee.get_classification()

        timecard = classification.get_timecard(date=20011031)
        self.assertTrue(timecard)
        self.assertEqual(8.0, timecard.get_hours())
示例#8
0
文件: tests.py 项目: fbserkov/praxis
    def test_add_hourly_employee(self):
        emp_id = EmpId(1)
        transaction = AddHourlyEmployee(emp_id,
                                        'Bob',
                                        'Home',
                                        hourly_rate=10.00)
        transaction.execute()

        employee = g_payroll_database.get_employee(emp_id)
        self.assertEqual('Bob', employee.get_name())
        self.assertEqual('Home', employee.get_address())

        classification = employee.get_classification()
        self.assertEqual(10.00, classification.get_hourly_rate())

        self.assertIsInstance(classification, HourlyClassification)
        self.assertIsInstance(employee.get_schedule(), WeeklySchedule)
        self.assertIsInstance(employee.get_method(), HoldMethod)
示例#9
0
文件: tests.py 项目: fbserkov/praxis
    def test_add_service_charge(self):
        emp_id = EmpId(2)
        transaction = AddHourlyEmployee(emp_id,
                                        'Bill',
                                        'Home',
                                        hourly_rate=15.25)
        transaction.execute()
        employee = g_payroll_database.get_employee(emp_id)

        union_affiliation = UnionAffiliation()
        employee.set_affiliation(union_affiliation)
        member_id = MemberId(86)  # Maxwell Smart
        g_payroll_database.add_union_member(member_id, employee)

        transaction = ServiceChargeTransaction(member_id,
                                               date=20011101,
                                               charge=12.95)
        transaction.execute()
        service_charge = union_affiliation.get_service_charge(20011101)
        self.assertTrue(service_charge)
        self.assertEqual(12.95, service_charge.get_amount())
def test_adding_a_time_card():
    db = MemoryDB()
    t = AddHourlyEmployee("Bill", "Home", 15.25, db)
    empId = t.execute()
    date = datetime.date(2005, 3, 30)
    tct = AddTimeCard(empId, date, 8.0, db)
    tct.execute()

    e = db.get_employee(empId)
    assert e is not None

    pc = e.classification
    assert isinstance(pc, HourlyClassification)

    tc = pc.get_time_card(date)
    assert tc.hours == 8.0
    assert tc.date == date
示例#11
0
def test_adding_a_time_card():
    db = MemoryDB()
    t = AddHourlyEmployee("Bill", "Home", 15.25, db)
    empId = t.execute()
    date = datetime.date(2005, 3, 30)
    tct = AddTimeCard(empId, date, 8.0, db)
    tct.execute()

    e = db.get_employee(empId)
    assert e is not None

    pc = e.classification
    assert isinstance(pc, HourlyClassification)

    tc = pc.get_time_card(date)
    assert tc.hours == 8.0
    assert tc.date == date
示例#12
0
def test_adding_an_hourly_paid_employee():
    db = MemoryDB()
    at = AddHourlyEmployee("John", "Home", 15.75, db)
    empId = at.execute()
    e = db.get_employee(empId)

    assert e is not None
    assert e.id == empId
    assert e.name == "John"
    assert e.address == "Home"
    pc = e.classification
    assert isinstance(pc, HourlyClassification)
    assert pc.hourly_rate == 15.75
    ps = e.schedule
    assert isinstance(ps, WeeklySchedule)
    pm = e.method
    assert isinstance(pm, HoldMethod)
示例#13
0
文件: tests.py 项目: fbserkov/praxis
    def test_pay_single_hourly_employee_with_time_cards_spanning_two_pay_periods(
            self):
        emp_id = EmpId(2)
        transaction = AddHourlyEmployee(emp_id,
                                        'Bill',
                                        'Home',
                                        hourly_rate=15.25)
        transaction.execute()
        pay_date = date(2001, 11, 9)  # Friday
        date_in_previous_pay_period = date(2001, 11, 2)

        transaction = TimecardTransaction(emp_id, pay_date, hours=2.0)
        transaction.execute()
        transaction = TimecardTransaction(emp_id,
                                          date_in_previous_pay_period,
                                          hours=5.0)
        transaction.execute()
        transaction = PaydayTransaction(pay_date)
        transaction.execute()
        self.validate_paycheck(transaction, emp_id, pay_date, 2.0 * 15.25)
示例#14
0
文件: tests.py 项目: fbserkov/praxis
    def test_pay_single_hourly_employee_one_wrong_date(self):
        emp_id = EmpId(2)
        transaction = AddHourlyEmployee(emp_id,
                                        'Bill',
                                        'Home',
                                        hourly_rate=15.25)
        transaction.execute()
        pay_date = date(2001, 11, 8)  # Thursday

        transaction = TimecardTransaction(emp_id, pay_date, hours=9.0)
        transaction.execute()
        transaction = PaydayTransaction(pay_date)
        transaction.execute()
        self.assertFalse(transaction.get_paycheck(emp_id))
示例#15
0
文件: tests.py 项目: fbserkov/praxis
    def test_service_charge_spanning_multiple_pay_periods(self):
        emp_id = EmpId(1)
        transaction = AddHourlyEmployee(emp_id,
                                        'Bill',
                                        'Home',
                                        hourly_rate=15.24)
        transaction.execute()
        member_id = MemberId(7734)
        transaction = ChangeMemberTransaction(emp_id, member_id, dues=9.42)
        transaction.execute()

        early_date = date(2001, 11, 2)  # previous Friday
        pay_date = date(2001, 11, 9)
        late_date = date(2001, 11, 16)  # next Friday
        transaction = ServiceChargeTransaction(member_id,
                                               pay_date,
                                               charge=19.42)
        transaction.execute()
        transaction = ServiceChargeTransaction(member_id,
                                               early_date,
                                               charge=100)
        transaction.execute()
        transaction = ServiceChargeTransaction(member_id,
                                               late_date,
                                               charge=200)
        transaction.execute()
        transaction = TimecardTransaction(emp_id, pay_date, hours=8.0)
        transaction.execute()
        transaction = PaydayTransaction(pay_date)
        transaction.execute()

        paycheck = transaction.get_paycheck(emp_id)
        self.assertEqual(pay_date, paycheck.get_period_end_date())
        self.assertEqual(8 * 15.24, paycheck.get_gross_pay())
        self.assertEqual('Hold', paycheck.get_field('Disposition'))
        self.assertEqual(9.42 + 19.42, paycheck.get_deductions())
        self.assertEqual(8 * 15.24 - (9.42 + 19.42), paycheck.get_net_pay())