示例#1
0
文件: tests.py 项目: fbserkov/praxis
    def test_pay_single_commissioned_employee_one_sales_receipt(self):
        emp_id = EmpId(3)
        transaction = AddCommissionedEmployee(emp_id,
                                              'Lance',
                                              'Home',
                                              salary=2500,
                                              commission_rate=3.2)
        transaction.execute()
        pay_date = date(2001, 11, 9)  # Friday

        transaction = SalesReceiptTransaction(emp_id, pay_date, amount=1000)
        transaction.execute()
        transaction = PaydayTransaction(pay_date)
        transaction.execute()
        self.validate_paycheck(transaction, emp_id, pay_date,
                               2500 + 1000 * 3.2 / 100)
示例#2
0
def test_adding_a_sales_receipt():
    db = MemoryDB()
    t = AddCommissionedEmployee("John", "Home", 5.0, 1500, db)
    empId = t.execute()
    date = datetime.date(2005, 3, 30)
    srt = AddSalesReceipt(empId, date, 500, db)
    srt.execute()

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

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

    srs = pc.get_sales_receipts()
    assert srs[0].amount == 500
    assert srs[0].date == date
def test_adding_a_sales_receipt():
    db = MemoryDB()
    t = AddCommissionedEmployee("John", "Home", 5.0, 1500, db)
    empId = t.execute()
    date = datetime.date(2005, 3, 30)
    srt = AddSalesReceipt(empId, date, 500, db)
    srt.execute()

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

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

    srs = pc.get_sales_receipts()
    assert srs[0].amount == 500
    assert srs[0].date == date
def test_adding_an_employee_paid_by_commission():
    db = MemoryDB()
    t = AddCommissionedEmployee("Sorro", "Firm", 5.0, 1000, db)
    empId = t.execute()

    e = db.get_employee(empId)
    assert e.name == "Sorro"
    assert e.address == "Firm"

    pc = e.classification
    assert isinstance(pc, CommissionedClassification)
    assert pc.commission == 5.0
    assert pc.baseRate == 1000

    ps = e.schedule
    assert isinstance(ps, BiWeeklySchedule)

    pm = e.method
    assert isinstance(pm, HoldMethod)
def test_adding_an_employee_paid_by_commission():
    db = MemoryDB()
    t = AddCommissionedEmployee("Sorro", "Firm", 5.0, 1000, db)
    empId = t.execute()

    e = db.get_employee(empId)
    assert e.name == "Sorro"
    assert e.address == "Firm"

    pc = e.classification
    assert isinstance(pc, CommissionedClassification)
    assert pc.commission == 5.0
    assert pc.baseRate == 1000

    ps = e.schedule
    assert isinstance(ps, BiWeeklySchedule)

    pm = e.method
    assert isinstance(pm, HoldMethod)
示例#6
0
文件: tests.py 项目: fbserkov/praxis
    def test_add_commissioned_employee(self):
        emp_id = EmpId(1)
        transaction = AddCommissionedEmployee(emp_id,
                                              'Bob',
                                              'Home',
                                              salary=1000.00,
                                              commission_rate=1.0)
        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(1000.00, classification.get_salary())
        self.assertEqual(1.0, classification.get_commission_rate())

        self.assertIsInstance(classification, CommissionedClassification)
        self.assertIsInstance(employee.get_schedule(), BiweeklySchedule)
        self.assertIsInstance(employee.get_method(), HoldMethod)
示例#7
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
示例#8
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
示例#9
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
示例#10
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
示例#11
0
文件: tests.py 项目: fbserkov/praxis
    def test_delete_employee(self):
        emp_id = EmpId(3)
        transaction = AddCommissionedEmployee(emp_id,
                                              'Lance',
                                              'Home',
                                              salary=2500,
                                              commission_rate=3.2)
        transaction.execute()
        employee = g_payroll_database.get_employee(emp_id)
        self.assertTrue(employee)

        transaction = DeleteEmployeeTransaction(emp_id)
        transaction.execute()
        employee = g_payroll_database.get_employee(emp_id)
        self.assertIsNone(employee)
示例#12
0
文件: tests.py 项目: fbserkov/praxis
    def test_change_hourly_transaction(self):
        emp_id = EmpId(3)
        transaction = AddCommissionedEmployee(emp_id,
                                              'Lance',
                                              'Home',
                                              salary=2500,
                                              commission_rate=3.2)
        transaction.execute()
        transaction = ChangeHourlyTransaction(emp_id, hourly_rate=27.52)
        transaction.execute()

        employee = g_payroll_database.get_employee(emp_id)
        classification = employee.get_classification()
        self.assertIsInstance(classification, HourlyClassification)
        self.assertEqual(27.52, classification.get_hourly_rate())
        self.assertIsInstance(employee.get_schedule(), WeeklySchedule)
示例#13
0
文件: tests.py 项目: fbserkov/praxis
    def test_sales_receipt_transaction(self):
        emp_id = EmpId(3)
        transaction = AddCommissionedEmployee(emp_id,
                                              'Lance',
                                              'Home',
                                              salary=2500,
                                              commission_rate=3.2)
        transaction.execute()

        transaction = SalesReceiptTransaction(emp_id,
                                              date=20011031,
                                              amount=3500)
        transaction.execute()
        employee = g_payroll_database.get_employee(emp_id)
        classification = employee.get_classification()

        sales_receipt = classification.get_sales_receipt(date=20011031)
        self.assertTrue(sales_receipt)
        self.assertEqual(3500, sales_receipt.get_amount())
示例#14
0
文件: tests.py 项目: fbserkov/praxis
    def test_pay_single_commissioned_employee_with_sales_receipts_spanning_two_pay_periods(
            self):
        emp_id = EmpId(3)
        transaction = AddCommissionedEmployee(emp_id,
                                              'Lance',
                                              'Home',
                                              salary=2500,
                                              commission_rate=3.2)
        transaction.execute()
        pay_date = date(2001, 11, 9)  # Friday
        date_in_previous_pay_period = date(2001, 10, 26)

        transaction = SalesReceiptTransaction(emp_id, pay_date, amount=1000)
        transaction.execute()
        transaction = SalesReceiptTransaction(emp_id,
                                              date_in_previous_pay_period,
                                              amount=900)
        transaction.execute()
        transaction = PaydayTransaction(pay_date)
        transaction.execute()
        self.validate_paycheck(transaction, emp_id, pay_date,
                               2500 + 1000 * 3.2 / 100)
示例#15
0
文件: tests.py 项目: fbserkov/praxis
    def test_pay_single_commissioned_employee_one_wrong_date(self):
        emp_id = EmpId(3)
        transaction = AddCommissionedEmployee(emp_id,
                                              'Lance',
                                              'Home',
                                              salary=2500,
                                              commission_rate=3.2)
        transaction.execute()
        pay_date = date(2001, 11, 2)  # Friday, but first

        transaction = SalesReceiptTransaction(emp_id, pay_date, amount=1000)
        transaction.execute()
        transaction = PaydayTransaction(pay_date)
        transaction.execute()
        self.assertFalse(transaction.get_paycheck(emp_id))