Changeset 8306


Ignore:
Timestamp:
29 Apr 2012, 06:26:08 (13 years ago)
Author:
Henrik Bettermann
Message:

Configure school fee calculation.

Location:
main/waeup.uniben/trunk/src/waeup/uniben/students
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_browser.py

    r8294 r8306  
    166166        ticket = self.student['payments'].items()[0][1]
    167167        ticket.p_state = 'paid'
    168         IWorkflowState(self.student).setState('returning')
    169168        self.browser.open(self.payments_path + '/addop')
    170169        self.browser.getControl("Create ticket").click()
     
    206205        self.assertMatches('...ticket created...',
    207206                           self.browser.contents)
    208         self.certificate.study_mode = 'ug_pt'
    209207        self.browser.open(self.payments_path + '/addop')
    210208        self.browser.getControl(name="form.p_category").value = ['schoolfee']
    211209        self.browser.getControl("Create ticket").click()
     210        self.assertMatches('...ticket created...',
     211                           self.browser.contents)
     212        # In state returning we can add a new school fee ticket since
     213        # p_session and p_level is different
     214        IWorkflowState(self.student).setState('returning')
     215        self.browser.open(self.payments_path + '/addop')
     216        self.browser.getControl(name="form.p_category").value = ['schoolfee']
     217        self.browser.getControl("Create ticket").click()
     218        self.assertMatches('...ticket created...',
     219                           self.browser.contents)
     220        IWorkflowState(self.student).setState('admitted')
     221        self.browser.open(self.payments_path + '/addop')
     222        self.browser.getControl(name="form.p_category").value = ['schoolfee']
     223        self.browser.getControl("Create ticket").click()
    212224        self.assertMatches('...Amount could not be determined...',
    213225                           self.browser.contents)
    214226
    215         # If the session configuration doesn't exist and error message will
    216         # be shown
     227        # If the session configuration doesn't exist an error message will
     228        # be shown. No other requirement is being checked.
    217229        del self.app['configuration']['2004']
    218230        self.browser.open(self.payments_path)
  • main/waeup.uniben/trunk/src/waeup/uniben/students/utils.py

    r8294 r8306  
    1717##
    1818import grok
     19from waeup.kofa.interfaces import CLEARED, RETURNING
    1920from waeup.kofa.students.workflow import CLEARED, RETURNING
    2021from waeup.kofa.students.utils import StudentsUtils
     
    2425
    2526def get_school_fee(student):
    26     study_mode = student['studycourse'].certificate.study_mode
    27     entry_mode = student['studycourse'].entry_mode
    2827    state = student.state
    29     #lga = student.lga
    30     lga = 'nothing'
    31     current_level = student['studycourse'].current_level
    32 
    33     if study_mode.endswith('_ft'):
    34         # fresh
    35         if state == CLEARED:
    36             return 40000.0
    37         # returning
    38         elif state == RETURNING:
    39             return 20000.0
    40         else:
    41             return 0.0
    42     else:
    43         return 0.0
     28    fee = None
     29    if state == CLEARED:
     30        fee = getattr(student['studycourse'].certificate,'school_fee_1')
     31    elif state == RETURNING:
     32        fee = getattr(student['studycourse'].certificate,'school_fee_2')
     33    if fee is not None:
     34        return fee
     35    return 0.0
    4436
    4537def actions_after_student_payment(student, payment, view):
     
    9082
    9183    def getPaymentDetails(self, category, student):
    92         d = {}
    93         d['p_item'] = u''
    94         d['amount'] = 0.0
    95         d['error'] = u''
    96         d['p_session'] = student['studycourse'].current_session
    97         session = str(d['p_session'])
    98         d['p_level'] = student['studycourse'].current_level
     84        details = {}
     85        details['p_item'] = u''
     86        details['amount'] = 0.0
     87        details['error'] = u''
     88        details['p_session'] = student['studycourse'].current_session
     89        session = str(details['p_session'])
     90        details['p_level'] = student['studycourse'].current_level
    9991        try:
    10092            academic_session = grok.getSite()['configuration'][session]
    10193        except KeyError:
    102             d['error'] = _(u'Session configuration object is not available.')
    103             return d
     94            details['error'] = _(u'Session configuration object is not available.')
     95            return details
    10496        if category == 'transfer':
    105             d['amount'] = academic_session.transfer_fee
     97            details['amount'] = academic_session.transfer_fee
    10698        elif category == 'gown':
    107             d['amount'] = academic_session.gown_fee
     99            details['amount'] = academic_session.gown_fee
    108100        elif category == 'bed_allocation':
    109             d['amount'] = academic_session.booking_fee
     101            details['amount'] = academic_session.booking_fee
    110102        elif category == 'hostel_maintenance':
    111             d['amount'] = academic_session.maint_fee
     103            details['amount'] = academic_session.maint_fee
    112104        elif category == 'clearance':
    113             d['p_item'] = student['studycourse'].certificate.code
    114             if d['p_item'] in ('BEDCET', 'BIOEDCET', 'CHMEDCET', 'ISEDCET',
     105            details['p_item'] = student['studycourse'].certificate.code
     106            if details['p_item'] in ('BEDCET', 'BIOEDCET', 'CHMEDCET', 'ISEDCET',
    115107                'MTHEDCET', 'PHYEDCET', 'ITECET', 'AGREDCET', 'HEEDCET'):
    116                 d['amount'] = 17250.0
     108                details['amount'] = 17250.0
    117109            else:
    118                 d['amount'] = 34250.0
     110                details['amount'] = 34250.0
    119111        elif category == 'schoolfee':
    120             d['amount'] = get_school_fee(student)
     112            details['amount'] = get_school_fee(student)
    121113            code = student['studycourse'].certificate.code
    122             d['p_item'] = code
    123             # In case of school fee payment the payment session and level
    124             # contain the values of the session the student has paid for
    125             d['p_session'], d['p_level'] = self.getReturningData(student)
    126         if d['amount'] == 0.0:
    127             d['error'] = _(u'Amount could not be determined.')
    128         return d
     114            details['p_item'] = code
     115            if student.state == RETURNING:
     116                # In case of returning school fee payment the payment session
     117                # and level contain the values of the session the student
     118                # has paid for.
     119                details['p_session'], details['p_level'] = self.getReturningData(student)
     120        if details['amount'] == 0.0:
     121            details['error'] = _(u'Amount could not be determined.')
     122        return details
    129123
    130124    VERDICTS_DICT = {
Note: See TracChangeset for help on using the changeset viewer.