source: main/waeup.sirp/trunk/src/waeup/sirp/students/utils.py @ 6897

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

In Student Online Payments we have to store the item session. Thus we need StudentOnlinePayment? must get its own interface which includes a session attribute.

  • Property svn:keywords set to Id
File size: 2.6 KB
Line 
1"""General helper functions for the student section.
2"""
3
4from random import SystemRandom as r
5from waeup.sirp.students.vocabularies import academic_sessions_vocab
6
7def generate_student_id(students,letter):
8    if letter == '?':
9        letter= r().choice('ABCDEFGHKLMNPQRSTUVWXY')
10    sid = u"%c%d" % (letter,r().randint(99999,1000000))
11    while sid in students.keys():
12        sid = u"%c%d" % (letter,r().randint(99999,1000000))
13    return sid
14
15def set_returning_data(student):
16    student['studycourse'].current_level += 100
17    student['studycourse'].current_session += 1
18    verdict = student['studycourse'].current_verdict
19    student['studycourse'].current_verdict = '0'
20    student['studycourse'].previous_verdict = verdict
21    return
22
23def getPaymentDetails(category, student):
24    p_session = student['studycourse'].current_session
25    surcharge_1 = surcharge_2 = surcharge_3 = 0
26    p_item = u''
27    if category == 'transfer':
28        amount = 500
29    elif category == 'gown':
30        amount = 500
31    elif category == 'hostel_maintenance':
32        amount = 300
33    elif category == 'schoolfee':
34        surcharge_1 = 1500 # BT amount
35        surcharge_2 = 300 # Interswitch amount
36        amount = getSchoolFee(student, surcharge_1 + surcharge_2)
37        code = student['studycourse'].certificate.code
38        #session_string = academic_sessions_vocab.by_value[p_session + 1].title
39        p_item = code
40        p_session += 1
41    return amount, p_item, p_session, surcharge_1, surcharge_2, surcharge_3
42
43# To be moved to the FUTMinna customization package
44def getSchoolFee(student, surcharge):
45    study_mode = student['studycourse'].certificate.study_mode
46    entry_mode = student.entry_mode
47    state = student.state
48    #lga = student.lga
49    lga = 'nothing'
50    current_level = student['studycourse'].current_level
51    CLEARED = 'cleared'
52
53    if study_mode.endswith('_ft'):
54        # fresh remedial
55        if current_level == 0 and state == CLEARED:
56            if entry_mode == 'rmd_ft':
57                return 80200 - surcharge
58            else:
59                return 74200 - surcharge
60        # fresh
61        elif state == CLEARED:
62            if study_mode == 'jm_ft':
63                return 72700 - surcharge
64            elif lga == 'foreigner':
65                return 131500 - surcharge
66            else:
67                return 41500 - surcharge
68        # returning
69        elif state == 'returning':
70            if study_mode == 'jm_ft':
71                return 32500 - surcharge
72            elif lga == 'foreigner':
73                return 109500 - surcharge
74            else:
75                return 19500 - surcharge
76        else:
77            return 0
78    else:
79        return 0
Note: See TracBrowser for help on using the repository browser.