Ignore:
Timestamp:
12 Dec 2016, 12:02:31 (8 years ago)
Author:
Henrik Bettermann
Message:

Configure schoolfee and clearance payments.

Location:
main/kofacustom.coewarri/trunk/src/kofacustom/coewarri/students
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • main/kofacustom.coewarri/trunk/src/kofacustom/coewarri/students/utils.py

    r14333 r14336  
    1818from time import time
    1919from zope.component import createObject, getUtility
     20from waeup.kofa.fees import FeeTable
    2021from waeup.kofa.interfaces import (IKofaUtils,
    2122    ADMITTED, CLEARED, RETURNING, PAID, REGISTERED, VALIDATED)
    2223from kofacustom.nigeria.students.utils import NigeriaStudentsUtils
    2324from kofacustom.coewarri.interfaces import MessageFactory as _
     25from kofacustom.coewarri.interswitch.browser import GATEWAY_AMT
    2426
    2527
     
    3133        return 'non-local'
    3234
     35PAYMENT_LEVELS = (100, 110, 200, 210, 300, 310, 400, 410, 500, 999)
     36
     37FEES_PARAMS = (
     38        ('local', 'non-local'),
     39        ('nce_ft', 'nce_pt', 'ug_ft'),
     40        PAYMENT_LEVELS
     41    )
     42
     43FEES_VALUES = (
     44      ( # 100      110      200      210      300      310      400      410     500  999
     45        (42000.0, 42000.0, 20600.0, 20600.0, 18100.0, 18100.0,     0.0,     0.0, 0.0, 0.0), # nce_ft
     46        (55200.0, 55200.0, 42200.0, 42200.0, 44700.0, 44700.0, 42200.0, 42200.0, 0.0, 0.0), # nce_pt
     47        (69200.0, 69200.0, 63100.0, 63100.0, 63100.0, 63100.0, 62100.0, 62100.0, 0.0, 0.0), # ug_ft
     48      ), # local
     49      ( #
     50        (54600.0, 54600.0, 22600.0, 22600.0, 20100.0, 20100.0,     0.0,     0.0, 0.0, 0.0), # nce_ft
     51        (55200.0, 55200.0, 42200.0, 42200.0, 44700.0, 44700.0, 42200.0, 42200.0, 0.0, 0.0), # nce_pt
     52        (79200.0, 79200.0, 63100.0, 63100.0, 63100.0, 63100.0, 62100.0, 62100.0, 0.0, 0.0), # ug_ft
     53      ), # non-local
     54    )
     55
     56SCHOOL_FEES = FeeTable(FEES_PARAMS, FEES_VALUES)
     57
    3358class CustomStudentsUtils(NigeriaStudentsUtils):
    3459    """A collection of customized methods.
     
    3762
    3863    def setPaymentDetails(self, category, student,
    39             previous_session, previous_level):
     64            previous_session=None, previous_level=None):
    4065        """Create a payment ticket and set the payment data of a
    4166        student for the payment category specified.
     
    4368        p_item = u''
    4469        amount = 0.0
    45         if previous_session:
    46             if previous_session < student['studycourse'].entry_session:
    47                 return _('The previous session must not fall below '
    48                          'your entry session.'), None
    49             if category == 'schoolfee':
    50                 # School fee is always paid for the following session
    51                 if previous_session > student['studycourse'].current_session:
    52                     return _('This is not a previous session.'), None
    53             else:
    54                 if previous_session > student['studycourse'].current_session - 1:
    55                     return _('This is not a previous session.'), None
    56             p_session = previous_session
    57             p_level = previous_level
    58             p_current = False
    59         else:
    60             p_session = student['studycourse'].current_session
    61             p_level = student['studycourse'].current_level
    62             p_current = True
     70        p_session = student['studycourse'].current_session
     71        p_level = student['studycourse'].current_level
     72        p_current = True
    6373        academic_session = self._getSessionConfiguration(p_session)
    6474        if academic_session == None:
     
    7181            except (AttributeError, TypeError):
    7282                return _('Study course data are incomplete.'), None
    73             if previous_session:
    74                 # Students can pay for previous sessions in all
    75                 # workflow states.  Fresh students are excluded by the
    76                 # update method of the PreviousPaymentAddFormPage.
    77                 if previous_level == 100:
    78                     amount = getattr(certificate, 'school_fee_1', 0.0)
    79                 else:
    80                     amount = getattr(certificate, 'school_fee_2', 0.0)
    81             else:
    82                 if student.state == CLEARED:
    83                     amount = getattr(certificate, 'school_fee_1', 0.0)
    84                 elif student.state == RETURNING:
    85                     # In case of returning school fee payment the
    86                     # payment session and level contain the values of
    87                     # the session the student has paid for. Payment
    88                     # session is always next session.
    89                     p_session, p_level = self.getReturningData(student)
    90                     academic_session = self._getSessionConfiguration(p_session)
    91                     if academic_session == None:
    92                         return _(
    93                             u'Session configuration object is not available.'
    94                             ), None
    95                     amount = getattr(certificate, 'school_fee_2', 0.0)
    96                 elif student.is_postgrad and student.state == PAID:
    97                     # Returning postgraduate students also pay for the
    98                     # next session but their level always remains the
    99                     # same.
    100                     p_session += 1
    101                     academic_session = self._getSessionConfiguration(p_session)
    102                     if academic_session == None:
    103                         return _(
    104                             u'Session configuration object is not available.'
    105                             ), None
    106                     amount = getattr(certificate, 'school_fee_2', 0.0)
     83            if student.state == RETURNING:
     84                # Override p_session and p_level
     85                p_session, p_level = self.getReturningData(student)
     86                academic_session = self._getSessionConfiguration(p_session)
     87                if academic_session == None:
     88                    return _(u'Session configuration object '
     89                              'is not available.'), None
     90            if student.state in (RETURNING, CLEARED):
     91                if p_level in PAYMENT_LEVELS:
     92                    amount = SCHOOL_FEES.get_fee(
     93                        (
     94                         local_nonlocal(student),
     95                         student.current_mode,
     96                         p_level)
     97                        )
     98                    amount += GATEWAY_AMT
    10799        elif category == 'clearance':
    108100            try:
     
    111103                return _('Study course data are incomplete.'), None
    112104            amount = academic_session.clearance_fee
     105            if local_nonlocal(student) == 'non-local':
     106                amount += 5000.0
    113107        elif category == 'bed_allocation':
    114108            p_item = self.getAccommodationDetails(student)['bt']
Note: See TracChangeset for help on using the changeset viewer.