source: main/waeup.custom/trunk/src/waeup/custom/students/utils.py @ 7145

Last change on this file since 7145 was 7145, checked in by Henrik Bettermann, 13 years ago

Change some function names according to the style guide:

Function names should be lowercase, with words separated by underscores as necessary to improve readability.

  • Property svn:keywords set to Id
File size: 2.1 KB
Line 
1from grok import getSite
2from waeup.sirp.students.vocabularies import academic_sessions_vocab
3from waeup.sirp.students.workflow import CLEARED, RETURNING
4
5def get_payment_details(category, student):
6    d = {}
7    d['surcharge_1'] = d['surcharge_2'] = d['surcharge_3'] = 0
8    d['p_item'] = u''
9    d['amount'] = 0
10    d['error'] = u''
11    d['p_session'] = student['studycourse'].current_session
12    session = str(d['p_session'])
13    try:
14        academic_session = getSite()['configuration'][session]
15    except KeyError:
16        d['error'] = u'Session configuration object is not available.'
17        return d
18    if category == 'transfer':
19        d['amount'] = academic_session.transfer_fee
20    elif category == 'gown':
21        d['amount'] = academic_session.gown_fee
22    elif category == 'bed_allocation':
23        d['amount'] = academic_session.booking_fee
24    elif category == 'hostel_maintenance':
25        d['amount'] = academic_session.maint_fee
26    elif category == 'clearance':
27        d['p_item'] = student['studycourse'].certificate.code
28        d['amount'] = academic_session.clearance_fee
29    elif category == 'schoolfee':
30        d['surcharge_1'] = academic_session.surcharge_1
31        d['surcharge_2'] = academic_session.surcharge_2
32        d['amount'] = getSchoolFee(student, d['surcharge_1'] + d['surcharge_2'])
33        code = student['studycourse'].certificate.code
34        #session_string = academic_sessions_vocab.by_value[p_session + 1].title
35        d['p_item'] = code
36        d['p_session'] += 1
37    if d['amount'] == 0:
38        d['error'] = u'Amount could not be determined.'
39    return d
40
41def getSchoolFee(student, surcharge):
42    study_mode = student['studycourse'].certificate.study_mode
43    entry_mode = student['studycourse'].entry_mode
44    state = student.state
45    #lga = student.lga
46    lga = 'nothing'
47    current_level = student['studycourse'].current_level
48
49    if study_mode.endswith('_ft'):
50        # fresh
51        if state == CLEARED:
52            return 40000 - surcharge
53        # returning
54        elif state == RETURNING:
55            return 20000 - surcharge
56        else:
57            return 0
58    else:
59        return 0
Note: See TracBrowser for help on using the repository browser.