Changeset 6876 for main


Ignore:
Timestamp:
12 Oct 2011, 19:30:01 (13 years ago)
Author:
Henrik Bettermann
Message:

Implement getPaymentDetails and getSchoolFee functions (to be moved to the FUTMinna customization package).

Location:
main/waeup.sirp/trunk/src/waeup/sirp/students
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py

    r6870 r6876  
    4343from waeup.sirp.students.studylevel import StudentStudyLevel, CourseTicket
    4444from waeup.sirp.students.vocabularies import StudyLevelSource
     45from waeup.sirp.students.utils import getPaymentDetails
    4546from waeup.sirp.browser.resources import toggleall
    4647from waeup.sirp.payments.interfaces import IOnlinePayment
     
    865866    @grok.action('Create ticket')
    866867    def createTicket(self, **data):
    867         payment = createObject(u'waeup.OnlinePayment')
     868        payment = createObject(u'waeup.StudentOnlinePayment')
    868869        self.applyData(payment, **data)
    869870        timestamp = "%d" % int(time()*1000)
    870871        #order_id = "%s%s" % (student_id[1:],timestamp)
    871872        payment.p_id = "p%s" % timestamp
     873        (payment.amount_auth,
     874            payment.p_item,
     875            payment.surcharge_1,
     876            payment.surcharge_2,
     877            payment.surcharge_3)  = getPaymentDetails(
     878            data['p_category'],self.context.__parent__)
     879        if payment.amount_auth == 0:
     880            self.flash('Payment amount could not be determined.')
     881            self.redirect(self.url(self.context, u'@@manage'))
     882            return
    872883        self.context[payment.p_id] = payment
    873884        self.flash('Payment ticket created.')
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py

    r6852 r6876  
    620620        self.assertEqual(self.student.state, 'courses registered')
    621621        return
     622
     623    def test_manage_access(self):
     624        # Managers can add online payment tickets
     625        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     626        self.browser.open(self.payments_student_path)
     627        self.browser.getLink("Manage").click()
     628        self.browser.getControl("Add online payment ticket").click()
  • main/waeup.sirp/trunk/src/waeup/sirp/students/utils.py

    r6804 r6876  
    33
    44from random import SystemRandom as r
     5from waeup.sirp.students.vocabularies import academic_sessions_vocab
    56
    67def generate_student_id(students,letter):
     
    1920    student['studycourse'].previous_verdict = verdict
    2021    return
     22
     23def getPaymentDetails(category, student):
     24    #import pdb; pdb.set_trace()
     25    session_string = academic_sessions_vocab.by_value[
     26        student['studycourse'].current_session].title
     27    surcharge_1 = surcharge_2 = surcharge_3 = 0
     28    if category == 'transfer':
     29        amount = 500
     30        item = u'Session %s' % session_string
     31    elif category == 'gown':
     32        amount = 500
     33        item = u'Session %s' % session_string
     34    elif category == 'hostel_maintenance':
     35        amount = 300
     36        item = u'Session %s' % session_string
     37    elif category == 'schoolfee':
     38        surcharge_1 = 1500 # BT amount
     39        surcharge_2 = 300 # Interswitch amount
     40        amount = getSchoolFee(student, surcharge_1 + surcharge_2)
     41        item = u'Session %s' % session_string
     42    return amount, item, surcharge_1, surcharge_2, surcharge_3
     43
     44# To be moved to the FUTMinna customization package
     45def getSchoolFee(student, surcharge):
     46    study_mode = student['studycourse'].certificate.study_mode
     47    entry_mode = student.entry_mode
     48    state = student.state
     49    #lga = student.lga
     50    lga = 'nothing'
     51    current_level = student['studycourse'].current_level
     52    CLEARED = 'cleared'
     53
     54    if study_mode.endswith('_ft'):
     55        # fresh remedial
     56        if current_level == 0 and state == CLEARED:
     57            if entry_mode == 'rmd_ft':
     58                return 80200 - surcharge
     59            else:
     60                return 74200 - surcharge
     61        # fresh
     62        elif state == CLEARED:
     63            if study_mode == 'jm_ft':
     64                return 72700 - surcharge
     65            elif lga == 'foreigner':
     66                return 131500 - surcharge
     67            else:
     68                return 41500 - surcharge
     69        # returning
     70        elif state == 'returning':
     71            if study_mode == 'jm_ft':
     72                return 32500 - surcharge
     73            elif lga == 'foreigner':
     74                return 109500 - surcharge
     75            else:
     76                return 19500 - surcharge
     77        else:
     78            return 0
     79    else:
     80        return 0
Note: See TracChangeset for help on using the changeset viewer.