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

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

Add clearance fee and to session configuration.

  • Property svn:keywords set to Id
File size: 2.0 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 getPaymentDetails(category, student):
6
7    surcharge_1 = surcharge_2 = surcharge_3 = 0
8    p_item = u''
9    amount = 0
10    error = u''
11    p_session = student['studycourse'].current_session
12    session = str(p_session)
13    try:
14        academic_session = getSite()['configuration'][session]
15    except KeyError:
16        error = u'Session configuration object is not available.'
17        return (amount, p_item, p_session,
18            surcharge_1, surcharge_2, surcharge_3, error)
19    if category == 'transfer':
20        amount = academic_session.transfer
21    elif category == 'gown':
22        amount = academic_session.gown
23    elif category == 'hostel_maintenance':
24        amount = academic_session.hostelmaintenance
25    elif category == 'clearance':
26        p_item = student['studycourse'].certificate.code
27        amount = academic_session.clearance
28    elif category == 'schoolfee':
29        surcharge_1 = academic_session.surcharge_1
30        surcharge_2 = academic_session.surcharge_2
31        amount = getSchoolFee(student, surcharge_1 + surcharge_2)
32        code = student['studycourse'].certificate.code
33        #session_string = academic_sessions_vocab.by_value[p_session + 1].title
34        p_item = code
35        p_session += 1
36    if amount ==0:
37        error = u'Amount could not be determined.'
38    return (amount, p_item, p_session,
39        surcharge_1, surcharge_2, surcharge_3, error)
40
41def getSchoolFee(student, surcharge):
42    study_mode = student['studycourse'].certificate.study_mode
43    entry_mode = student.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.