Ignore:
Timestamp:
22 Oct 2011, 07:29:31 (13 years ago)
Author:
Henrik Bettermann
Message:

The customized payment functions can now use the new SessionConfiguration? objects.

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

Legend:

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

    r6903 r6925  
    2020            payment.surcharge_1,
    2121            payment.surcharge_2,
    22             payment.surcharge_3)  = getPaymentDetails(
     22            payment.surcharge_3,
     23            error)  = getPaymentDetails(
    2324            data['p_category'],self.context.__parent__)
    24         if payment.amount_auth == 0:
    25             self.flash('Payment amount could not be determined.')
     25        if error:
     26            self.flash(error)
    2627            self.redirect(self.url(self.context, u'@@manage'))
    2728            return
  • main/waeup.custom/trunk/src/waeup/custom/students/tests.py

    r6903 r6925  
    11from waeup.custom.testing import FunctionalLayer
    22from waeup.sirp.students.tests.test_browser import StudentsFullSetup
     3from waeup.custom.configuration import SessionConfiguration
    34
    45class StudentUITests(StudentsFullSetup):
     
    89
    910    def test_manage_payments(self):
     11
     12        # Set up SessionConfiguration object
     13        configuration = SessionConfiguration()
     14        configuration.academic_session = 2004
     15        configuration.fee_1 = 20000
     16        self.app['configuration'].addSessionConfiguration(configuration)
     17
    1018        # Managers can add online payment tickets
    1119        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     
    1422        self.browser.getControl("Add online payment ticket").click()
    1523        self.browser.getControl("Create ticket").click()
    16         self.assertMatches('...amount could not be determined...',
     24        self.assertMatches('...Amount could not be determined...',
    1725                           self.browser.contents)
    1826        self.browser.open(self.manage_student_path)
     
    2937        self.assertMatches('...ticket created...',
    3038                           self.browser.contents)
     39        self.browser.open(self.manage_student_path)
     40        self.browser.getControl(name="transition").value = ['pay_first_school_fee']
     41        self.browser.getControl("Save").click()
     42        self.browser.getControl(name="transition").value = ['reset6']
     43        self.browser.getControl("Save").click()
     44        self.browser.open(self.payments_student_path + '/addop')
     45        self.browser.getControl("Create ticket").click()
     46        self.assertMatches('...ticket created...',
     47                           self.browser.contents)
  • main/waeup.custom/trunk/src/waeup/custom/students/utils.py

    r6902 r6925  
     1from grok import getSite
    12from waeup.sirp.students.vocabularies import academic_sessions_vocab
     3from waeup.sirp.students.workflow import CLEARED, RETURNING
    24
    35def getPaymentDetails(category, student):
    4     p_session = student['studycourse'].current_session
     6
    57    surcharge_1 = surcharge_2 = surcharge_3 = 0
    68    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)
    719    if category == 'transfer':
    8         amount = 500
     20        amount = academic_session.transfer
    921    elif category == 'gown':
    10         amount = 500
     22        amount = academic_session.gown
    1123    elif category == 'hostel_maintenance':
    12         amount = 300
     24        amount = academic_session.hostelmaintenance
    1325    elif category == 'schoolfee':
    14         surcharge_1 = 1500 # BT amount
    15         surcharge_2 = 300 # Interswitch amount
     26        surcharge_1 = academic_session.surcharge_1
     27        surcharge_2 = academic_session.surcharge_2
    1628        try:
    1729            amount = getSchoolFee(student, surcharge_1 + surcharge_2)
    1830            code = student['studycourse'].certificate.code
    1931        except AttributeError:
    20             return 0, None, None, 0, 0, 0
     32            return 0, None, None, 0, 0, 0, 'School Fee could not be determined.'
    2133        #session_string = academic_sessions_vocab.by_value[p_session + 1].title
    2234        p_item = code
    2335        p_session += 1
    24     return amount, p_item, p_session, surcharge_1, surcharge_2, surcharge_3
     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)
    2540
    2641def getSchoolFee(student, surcharge):
     
    3146    lga = 'nothing'
    3247    current_level = student['studycourse'].current_level
    33     CLEARED = 'cleared'
    3448
    3549    if study_mode.endswith('_ft'):
    36         # fresh remedial
    37         if current_level == 0 and state == CLEARED:
    38             if entry_mode == 'rmd_ft':
    39                 return 80200 - surcharge
    40             else:
    41                 return 74200 - surcharge
    4250        # fresh
    43         elif state == CLEARED:
    44             if study_mode == 'jm_ft':
    45                 return 72700 - surcharge
    46             elif lga == 'foreigner':
    47                 return 131500 - surcharge
    48             else:
    49                 return 41500 - surcharge
     51        if state == CLEARED:
     52            return 40000 - surcharge
    5053        # returning
    51         elif state == 'returning':
    52             if study_mode == 'jm_ft':
    53                 return 32500 - surcharge
    54             elif lga == 'foreigner':
    55                 return 109500 - surcharge
    56             else:
    57                 return 19500 - surcharge
     54        elif state == RETURNING:
     55            return 20000 - surcharge
    5856        else:
    5957            return 0
Note: See TracChangeset for help on using the changeset viewer.