示例#1
0
def test_not_paying_an_hourly_employee_on_wrong_date():
    db = MemoryDB()
    empId =  AddHourlyEmployee("Bob", "Home", 15.25, db).execute()
    pay_date = datetime.date(2001, 11, 29)
    pt = Payday(pay_date, db)
    pt.execute()

    try:
        pt.get_paycheck(empId)
        raise "pay on wrong date"
    except KeyError:
        pass
示例#2
0
def test_not_paying_an_hourly_employee_on_wrong_date():
    db = MemoryDB()
    empId = AddHourlyEmployee("Bob", "Home", 15.25, db).execute()
    pay_date = datetime.date(2001, 11, 29)
    pt = Payday(pay_date, db)
    pt.execute()

    try:
        pt.get_paycheck(empId)
        raise "pay on wrong date"
    except KeyError:
        pass
示例#3
0
def test_not_paying_a_commissioned_employee_on_wrong_date():
    db = MemoryDB()
    empId = AddCommissionedEmployee("Bob", "Home", 10, 1000, db).execute()

    pay_date = datetime.date(2001, 11, 23)
    pt = Payday(pay_date, db)
    pt.execute()

    try:
        pt.get_paycheck(empId)
        raise "pay on wrong date"
    except KeyError:
        pass
示例#4
0
def test_not_paying_a_commissioned_employee_on_wrong_date():
    db = MemoryDB()
    empId = AddCommissionedEmployee("Bob", "Home", 10, 1000, db).execute()

    pay_date = datetime.date(2001, 11, 23)
    pt = Payday(pay_date, db)
    pt.execute()

    try:
        pt.get_paycheck(empId)
        raise "pay on wrong date"
    except KeyError:
        pass
示例#5
0
def test_not_paying_a_salaried_employee_on_wrong_date():
    db = MemoryDB()
    t = AddSalariedEmployee("Bill", "Home", 1000.0, db)
    empId = t.execute()

    pay_date = datetime.date(2001, 11, 29)
    pt = Payday(pay_date, db)
    pt.execute()

    try:
        pt.get_paycheck(empId)
        raise "paycheck found on wrong date"
    except KeyError:
        pass
示例#6
0
def test_not_paying_a_salaried_employee_on_wrong_date():
    db = MemoryDB()
    t = AddSalariedEmployee("Bill", "Home", 1000.0, db)
    empId = t.execute()

    pay_date = datetime.date(2001, 11, 29)
    pt = Payday(pay_date, db)
    pt.execute()

    try:
        pt.get_paycheck(empId)
        raise "paycheck found on wrong date"
    except KeyError:
        pass
示例#7
0
def test_paying_nothing_to_an_hourly_employee_with_no_timecards():
    db = MemoryDB()
    empId =  AddHourlyEmployee("Bob", "Home", 15.25, db).execute()
    pay_date = datetime.date(2001, 11, 9)
    pt = Payday(pay_date, db)
    pt.execute()

    pc = pt.get_paycheck(empId)
    assert pc.pay_date == datetime.date(2001, 11, 9)
    assert pc.gross_pay == 0
    assert pc.deductions == 0
    assert pc.net_pay == 0
示例#8
0
def test_paying_nothing_to_an_hourly_employee_with_no_timecards():
    db = MemoryDB()
    empId = AddHourlyEmployee("Bob", "Home", 15.25, db).execute()
    pay_date = datetime.date(2001, 11, 9)
    pt = Payday(pay_date, db)
    pt.execute()

    pc = pt.get_paycheck(empId)
    assert pc.pay_date == datetime.date(2001, 11, 9)
    assert pc.gross_pay == 0
    assert pc.deductions == 0
    assert pc.net_pay == 0
示例#9
0
def test_paying_a_commissioned_employee_with_no_sales():
    db = MemoryDB()
    empId = AddCommissionedEmployee("Bob", "Home", 10, 1000, db).execute()

    pay_date = datetime.date(2001, 11, 16)
    pt = Payday(pay_date, db)
    pt.execute()

    pc = pt.get_paycheck(empId)
    assert pc.pay_date == datetime.date(2001, 11, 16)
    assert pc.gross_pay == 1000
    assert pc.deductions == 0
    assert pc.net_pay == 1000
示例#10
0
def test_paying_a_commissioned_employee_with_no_sales():
    db = MemoryDB()
    empId = AddCommissionedEmployee("Bob", "Home", 10, 1000, db).execute()

    pay_date = datetime.date(2001, 11, 16)
    pt = Payday(pay_date, db)
    pt.execute()

    pc = pt.get_paycheck(empId)
    assert pc.pay_date == datetime.date(2001, 11, 16)
    assert pc.gross_pay == 1000
    assert pc.deductions == 0
    assert pc.net_pay == 1000
示例#11
0
def test_paying_an_hourly_employee_only_in_one_period():
    db = MemoryDB()
    empId = AddHourlyEmployee("Bob", "Home", 15.25, db).execute()
    pay_date = datetime.date(2001, 11, 9)
    AddTimeCard(empId, pay_date, 2.0, db).execute()
    AddTimeCard(empId, datetime.date(2001, 11, 1), 2.0, db).execute()
    pt = Payday(pay_date, db)
    pt.execute()

    pc = pt.get_paycheck(empId)
    assert pc.pay_date == datetime.date(2001, 11, 9)
    assert pc.gross_pay == 30.5
    assert pc.deductions == 0
    assert pc.net_pay == 30.5
示例#12
0
def test_paying_an_hourly_employee_only_in_one_period():
    db = MemoryDB()
    empId =  AddHourlyEmployee("Bob", "Home", 15.25, db).execute()
    pay_date = datetime.date(2001, 11, 9)
    AddTimeCard(empId, pay_date, 2.0, db).execute()
    AddTimeCard(empId, datetime.date(2001, 11, 1), 2.0, db).execute()
    pt = Payday(pay_date, db)
    pt.execute()

    pc = pt.get_paycheck(empId)
    assert pc.pay_date == datetime.date(2001, 11, 9)
    assert pc.gross_pay == 30.5
    assert pc.deductions == 0
    assert pc.net_pay == 30.5
示例#13
0
def test_paying_an_hourly_employee_for_over_time():
    db = MemoryDB()
    empId =  AddHourlyEmployee("Bob", "Home", 10.0, db).execute()
    pay_date = datetime.date(2001, 11, 9)
    AddTimeCard(empId, pay_date, 10.0, db).execute()
    pt = Payday(pay_date, db)
    pt.execute()

    pc = pt.get_paycheck(empId)
    assert pc.pay_date == datetime.date(2001, 11, 9)
    print pc.gross_pay
    assert pc.gross_pay == 110
    assert pc.deductions == 0
    assert pc.net_pay == 110
示例#14
0
def test_paying_an_hourly_employee_for_over_time():
    db = MemoryDB()
    empId = AddHourlyEmployee("Bob", "Home", 10.0, db).execute()
    pay_date = datetime.date(2001, 11, 9)
    AddTimeCard(empId, pay_date, 10.0, db).execute()
    pt = Payday(pay_date, db)
    pt.execute()

    pc = pt.get_paycheck(empId)
    assert pc.pay_date == datetime.date(2001, 11, 9)
    print pc.gross_pay
    assert pc.gross_pay == 110
    assert pc.deductions == 0
    assert pc.net_pay == 110
示例#15
0
def test_paying_a_single_salaried_employee():
    db = MemoryDB()
    t = AddSalariedEmployee("Bill", "Home", 1000.0, db)
    empId = t.execute()

    pay_date = datetime.date(2001, 11, 30)
    pt = Payday(pay_date, db)
    pt.execute()

    pc = pt.get_paycheck(empId)
    assert pc.pay_date == datetime.date(2001, 11, 30)
    assert pc.gross_pay == 1000.0
    assert pc.deductions == 0
    assert pc.net_pay == 1000.0
    assert pc.disposition == "Hold"
示例#16
0
def test_paying_a_single_salaried_employee():
    db = MemoryDB()
    t = AddSalariedEmployee("Bill", "Home", 1000.0, db)
    empId = t.execute()

    pay_date = datetime.date(2001, 11, 30)
    pt = Payday(pay_date, db)
    pt.execute()

    pc = pt.get_paycheck(empId)
    assert pc.pay_date == datetime.date(2001, 11, 30)
    assert pc.gross_pay == 1000.0
    assert pc.deductions == 0
    assert pc.net_pay == 1000.0
    assert pc.disposition == "Hold"
示例#17
0
def test_deducting_service_charges():
    db = MemoryDB()
    empId = AddCommissionedEmployee("Bob", "Home", 10, 1000, db).execute()
    ChangeUnionMember(empId, 99.42, db).execute()
    mId = db.get_employee(empId).memberId

    pay_date = datetime.date(2001, 11, 16)
    AddServiceCharge(mId, pay_date, 10, db).execute()
    pt = Payday(pay_date, db)
    pt.execute()

    pc = pt.get_paycheck(empId)
    assert pc.gross_pay == 1000
    print pc.deductions
    assert pc.deductions == 109.42
    assert pc.net_pay == 1000 - 109.42
示例#18
0
def test_deducting_service_charges():
    db = MemoryDB()
    empId = AddCommissionedEmployee("Bob", "Home", 10, 1000, db).execute()
    ChangeUnionMember(empId, 99.42, db).execute()
    mId = db.get_employee(empId).memberId

    pay_date = datetime.date(2001, 11, 16)
    AddServiceCharge(mId, pay_date, 10, db).execute()
    pt = Payday(pay_date, db)
    pt.execute()

    pc = pt.get_paycheck(empId)
    assert pc.gross_pay == 1000
    print pc.deductions
    assert pc.deductions == 109.42
    assert pc.net_pay == 1000 - 109.42
示例#19
0
def test_paying_a_commissioned_employee_only_for_one_period():
    db = MemoryDB()
    empId = AddCommissionedEmployee("Bob", "Home", 10, 1000, db).execute()

    pay_date = datetime.date(2001, 11, 16)
    AddSalesReceipt(empId, pay_date, 500, db).execute()
    AddSalesReceipt(empId, datetime.date(2001, 11, 16-14), 500, db).execute()
    AddSalesReceipt(empId, datetime.date(2001, 11, 16+1), 500, db).execute()
    pt = Payday(pay_date, db)
    pt.execute()

    pc = pt.get_paycheck(empId)
    assert pc.pay_date == datetime.date(2001, 11, 16)
    print pc.gross_pay
    assert pc.gross_pay == 1050
    assert pc.deductions == 0
    assert pc.net_pay == 1050
示例#20
0
def test_paying_a_commissioned_employee_only_for_one_period():
    db = MemoryDB()
    empId = AddCommissionedEmployee("Bob", "Home", 10, 1000, db).execute()

    pay_date = datetime.date(2001, 11, 16)
    AddSalesReceipt(empId, pay_date, 500, db).execute()
    AddSalesReceipt(empId, datetime.date(2001, 11, 16 - 14), 500, db).execute()
    AddSalesReceipt(empId, datetime.date(2001, 11, 16 + 1), 500, db).execute()
    pt = Payday(pay_date, db)
    pt.execute()

    pc = pt.get_paycheck(empId)
    assert pc.pay_date == datetime.date(2001, 11, 16)
    print pc.gross_pay
    assert pc.gross_pay == 1050
    assert pc.deductions == 0
    assert pc.net_pay == 1050