def test_teacher_payment_find_classes_fixed_rate_class_specific(client, web2py):
    """
    Is the fixed rate class specific rate applied when finding classes?
    """
    prepare_classes(web2py)
    populate_auth_user_teachers_fixed_rate_default(web2py)
    populate_auth_user_teachers_fixed_rate_class_1(web2py)

    url = '/finance/teacher_payment_find_classes'
    client.get(url)
    assert client.status == 200

    data = {
        'Startdate': '2014-01-01',
        'Enddate': '2014-01-31'
    }

    client.post(url, data=data)
    assert client.status == 200

    assert web2py.db(web2py.db.teachers_payment_classes).count() == 3

    class_rate = web2py.db.teachers_payment_fixed_rate_class(1)

    tpc = web2py.db.teachers_payment_classes(1)
    assert tpc.ClassDate == datetime.date(2014, 1, 6)
    assert tpc.classes_id == 1
    assert tpc.ClassRate == class_rate.ClassRate
    assert tpc.tax_rates_id == class_rate.tax_rates_id
def test_teacher_payment_find_classes_attendance(client, web2py):
    """
    Is the fixed rate applied when finding classes?
    """
    prepare_classes(web2py)
    populate_auth_user_teachers_fixed_rate_default(web2py)
    populate_teachers_payment_attendance_lists_school_classtypes(web2py)

    url = '/finance/teacher_payment_find_classes'
    client.get(url)
    assert client.status == 200

    sprop = web2py.db.sys_properties(Property='TeacherPaymentRateType')
    sprop.PropertyValue = 'attendance'
    sprop.update_record()
    web2py.db.commit()

    data = {
        'Startdate': '2014-01-01',
        'Enddate': '2014-01-31'
    }

    client.post(url, data=data)
    assert client.status == 200

    list = web2py.db.teachers_payment_attendance_lists(1)
    rate = web2py.db.teachers_payment_attendance_lists_rates(1)

    tpc = web2py.db.teachers_payment_classes(1)
    assert tpc.ClassDate == datetime.date(2014, 1, 6)
    assert tpc.classes_id == 1
    assert tpc.ClassRate == rate.Rate
    assert tpc.tax_rates_id == list.tax_rates_id
def test_teachers_payment_travel_delete(client, web2py):
    """
        Is the delete permission working for teacher travel allowance
    """
    setup_permission_tests(web2py)
    prepare_classes(web2py)
    populate_auth_user_teachers_fixed_rate_default(web2py)
    populate_auth_user_teachers_fixed_rate_class_1(web2py)
    populate_auth_user_teachers_travel(web2py)

    str_check = 'fa-times'

    gid = 2
    web2py.auth.add_permission(200, 'read', 'teachers_payment_travel', 0)
    web2py.db.commit()

    url = '/teachers/payment_travel?teID=2'
    client.get(url)
    assert client.status == 200
    assert str_check not in client.text

    gid = 2
    web2py.auth.add_permission(200, 'delete', 'teachers_payment_travel', 0)
    web2py.db.commit()

    client.get(url)
    assert client.status == 200
    assert str_check in client.text
def test_payment_travel(client, web2py):
    """
        Check display of travel allowance for a teacher
    """
    prepare_classes(web2py)
    populate_auth_user_teachers_fixed_rate_default(web2py)
    populate_auth_user_teachers_fixed_rate_class_1(web2py)
    populate_auth_user_teachers_travel(web2py)

    next_monday = next_weekday(datetime.date.today(), 0)

    url = '/teachers/payment_travel?teID=2'
    client.get(url)
    assert client.status == 200

    travel_allowance = web2py.db.teachers_payment_travel(1)
    assert str(travel_allowance.TravelAllowance) in client.text
def test_payment_fixed_rate(client, web2py):
    """
        Check display of default and class specific fixed rates
    """
    prepare_classes(web2py)
    populate_auth_user_teachers_fixed_rate_default(web2py)
    populate_auth_user_teachers_fixed_rate_class_1(web2py)
    populate_auth_user_teachers_travel(web2py)

    next_monday = next_weekday(datetime.date.today(), 0)

    url = '/teachers/payment_fixed_rate?teID=2'
    client.get(url)
    assert client.status == 200

    default_rate = web2py.db.teachers_payment_fixed_rate_default(1)
    assert str(default_rate.ClassRate) in client.text

    class_rate = web2py.db.teachers_payment_fixed_rate_class(1)
    assert str(class_rate.ClassRate) in client.text
def test_payment_fixed_rate_default_edit(client, web2py):
    """
        Can we add a default rate
    """
    prepare_classes(web2py)
    populate_auth_user_teachers_fixed_rate_default(web2py)

    url = '/teachers/payment_fixed_rate_default?teID=2'
    client.get(url)
    assert client.status == 200

    data = {'id': 1, 'ClassRate': '30232', 'tax_rates_id': 1}

    client.post(url, data=data)
    assert client.status == 200

    row = web2py.db.teachers_payment_fixed_rate_default(1)
    assert row.ClassRate == float(data['ClassRate'])
    assert row.tax_rates_id == data['tax_rates_id']
    assert row.auth_teacher_id == 2
Esempio n. 7
0
def test_teacher_payment_find_classes_travel_allowance(client, web2py):
    """
    Is the fixed rate applied when finding classes?
    """
    prepare_classes(web2py)
    populate_auth_user_teachers_fixed_rate_default(web2py)
    populate_auth_user_teachers_travel(web2py)

    url = '/finance/teacher_payment_find_classes'
    client.get(url)
    assert client.status == 200

    data = {'Startdate': '2014-01-01', 'Enddate': '2014-01-31'}

    client.post(url, data=data)
    assert client.status == 200
    assert web2py.db(web2py.db.teachers_payment_classes).count() == 3

    tpc = web2py.db.teachers_payment_classes(1)
    ta = web2py.db.teachers_payment_travel(1)
    assert tpc.TravelAllowance == ta.TravelAllowance
def test_teacher_payment_find_classes_fixed_rate_default_skip_karma_role_teacher1(client, web2py):
    """
    Is the fixed rate applied when finding classes?
    """
    prepare_classes(web2py)
    populate_auth_user_teachers_fixed_rate_default(web2py)
    web2py.db(web2py.db.classes_teachers.auth_teacher_id == 2).update(teacher_role=3)
    web2py.db.commit()

    url = '/finance/teacher_payment_find_classes'
    client.get(url)
    assert client.status == 200

    data = {
        'Startdate': '2014-01-01',
        'Enddate': '2014-01-31'
    }

    client.post(url, data=data)
    assert client.status == 200

    query = (web2py.db.teachers_payment_classes.auth_teacher_id == 2)
    assert web2py.db(query).count() == 0
def test_teacher_payments_batch_set_status_sent_to_bank_add_payments(client, web2py):
    """
        Check if payments are added to invoices when the status of a batch
        becomes 'sent to bank'
    """
    url = '/finance/batch_add?export=payment&what=teacher_invoices'
    client.get(url)
    assert client.status == 200

    prepare_classes(web2py)
    populate_auth_user_teachers_fixed_rate_default(web2py)
    populate_auth_user_teachers_fixed_rate_class_1(web2py)
    populate_auth_user_teachers_travel(web2py)

    ##
    # Create invoices
    ##

    # Find classes
    url = '/finance/teacher_payment_find_classes'
    client.get(url)
    assert client.status == 200

    data = {
        'Startdate': '2014-01-01',
        'Enddate': '2014-01-31'
    }

    client.post(url, data=data)
    assert client.status == 200

    # Verify
    url = '/finance/teachers_payment_classes_verify_all'
    client.get(url)
    assert client.status == 200

    # Process (create invoices)
    url = '/finance/teachers_payment_classes_process_verified'
    client.get(url)


    # Create batch
    url = '/finance/batch_add?export=payment&what=teacher_payments'
    client.get(url)
    assert client.status == 200

    today = datetime.date.today()
    data = {
        'Name': 'Batch3435435',
        'ColMonth': today.month,
        'ColYear': today.year,
        'Exdate': '2099-01-01',
    }
    client.post(url, data=data)
    assert client.status == 200

    # check setting of status 'sent_to_bank'
    url = '/finance/batch_content_set_status?pbID=1&status=sent_to_bank'
    client.get(url)
    assert client.status == 200

    # check if 2 payments have been added
    assert web2py.db(web2py.db.invoices_payments.id > 0).count() == 1

    ip = web2py.db.invoices_payments(1)
    assert ip.payment_methods_id == 2

    # check payment amounts
    sum = web2py.db.invoices_amounts.TotalPriceVAT.sum()
    invoices_amount = web2py.db().select(sum).first()[sum]

    sum = web2py.db.invoices_payments.Amount.sum()
    payments_amount = web2py.db().select(sum).first()[sum]

    assert invoices_amount == payments_amount