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

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

Test coverage now 100%

  • Property svn:keywords set to Id
File size: 1.9 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 == 'schoolfee':
26        surcharge_1 = academic_session.surcharge_1
27        surcharge_2 = academic_session.surcharge_2
28        amount = getSchoolFee(student, surcharge_1 + surcharge_2)
29        code = student['studycourse'].certificate.code
30        #session_string = academic_sessions_vocab.by_value[p_session + 1].title
31        p_item = code
32        p_session += 1
33    if amount ==0:
34        error = u'Amount could not be determined.'
35    return (amount, p_item, p_session,
36        surcharge_1, surcharge_2, surcharge_3, error)
37
38def getSchoolFee(student, surcharge):
39    study_mode = student['studycourse'].certificate.study_mode
40    entry_mode = student.entry_mode
41    state = student.state
42    #lga = student.lga
43    lga = 'nothing'
44    current_level = student['studycourse'].current_level
45
46    if study_mode.endswith('_ft'):
47        # fresh
48        if state == CLEARED:
49            return 40000 - surcharge
50        # returning
51        elif state == RETURNING:
52            return 20000 - surcharge
53        else:
54            return 0
55    else:
56        return 0
Note: See TracBrowser for help on using the repository browser.